View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  package org.apache.commons.vfs.provider;
    18
    19  import org.apache.commons.vfs.FileSystemException;
    20  import org.apache.commons.vfs.RandomAccessContent;
    21
    22  import java.io.IOException;
    23  import java.io.InputStream;
    24  import java.util.ArrayList;
    25
    26  /***
    27   * Holds the data which needs to be local to the current thread
    28   */
    29  class FileContentThreadData
    30  {
    31      // private int state = DefaultFileContent.STATE_CLOSED;
    32
    33      private final ArrayList instrs = new ArrayList();
    34  	private final ArrayList rastrs = new ArrayList();
    35      private DefaultFileContent.FileContentOutputStream outstr;
    36
    37      FileContentThreadData()
    38      {
    39      }
    40
    41      /*
    42      int getState()
    43      {
    44          return state;
    45      }
    46
    47      void setState(int state)
    48      {
    49          this.state = state;
    50      }
    51      */
    52
    53      void addInstr(InputStream is)
    54      {
    55          this.instrs.add(is);
    56      }
    57
    58      void setOutstr(DefaultFileContent.FileContentOutputStream os)
    59      {
    60          this.outstr = os;
    61      }
    62
    63      DefaultFileContent.FileContentOutputStream getOutstr()
    64      {
    65          return this.outstr;
    66      }
    67
    68      void addRastr(RandomAccessContent ras)
    69      {
    70          this.rastrs.add(ras);
    71      }
    72
    73      int getInstrsSize()
    74      {
    75          return this.instrs.size();
    76      }
    77
    78      public Object removeInstr(int pos)
    79      {
    80          return this.instrs.remove(pos);
    81      }
    82
    83      public void removeInstr(InputStream instr)
    84      {
    85          this.instrs.remove(instr);
    86      }
    87
    88  	public Object removeRastr(int pos)
    89  	{
    90  		return this.rastrs.remove(pos);
    91  	}
    92
    93  	public void removeRastr(RandomAccessContent ras)
    94  	{
    95  		this.instrs.remove(ras);
    96  	}
    97
    98  	public boolean hasStreams()
    99      {
    100         return instrs.size() > 0 || outstr != null || rastrs.size() > 0;
    101     }
    102
    103     public void closeOutstr() throws FileSystemException
    104     {
    105         outstr.close();
    106         outstr = null;
    107     }
    108
    109 	int getRastrsSize()
    110 	{
    111 		return rastrs.size();
    112 	}
    113 }