Coverage details for edu.uci.ics.jung.utils.StringInputStream

LineHitsSource
1 /*
2 * Copyright (c) 2003, the JUNG Project and the Regents of the University
3 * of California
4 * All rights reserved.
5 *
6 * This software is open-source under the BSD license; see either
7 * "license.txt" or
8 * http://jung.sourceforge.net/license.txt for a description.
9 */
10 package edu.uci.ics.jung.utils;
11  
12 /*====================================================================
13   * The Apache Software License, Version 1.1
14   *
15   * Copyright (c) 2001 The Apache Software Foundation. All rights
16   * reserved.
17   *
18   * Redistribution and use in source and binary forms, with or without
19   * modification, are permitted provided that the following conditions
20   * are met:
21   *
22   * 1. Redistributions of source code must retain the above copyright
23   * notice, this list of conditions and the following disclaimer.
24   *
25   * 2. Redistributions in binary form must reproduce the above copyright
26   * notice, this list of conditions and the following disclaimer in
27   * the documentation and/or other materials provided with the
28   * distribution.
29   *
30   * 3. The end-user documentation included with the redistribution,
31   * if any, must include the following acknowledgment:
32   * "This product includes software developed by the
33   * Apache Software Foundation (http://www.apache.org/)."
34   * Alternately, this acknowledgment may appear in the software itself,
35   * if and wherever such third-party acknowledgments normally appear.
36   *
37   * 4. The names "Apache" and "Apache Software Foundation" and
38   * "Apache Maven" must not be used to endorse or promote products
39   * derived from this software without prior written permission. For
40   * written permission, please contact apache@apache.org.
41   *
42   * 5. Products derived from this software may not be called "Apache",
43   * "Apache Maven", nor may "Apache" appear in their name, without
44   * prior written permission of the Apache Software Foundation.
45   *
46   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
47   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
48   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
49   * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
50   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
51   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
52   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
53   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
54   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
56   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57   * SUCH DAMAGE.
58   * ====================================================================
59   *
60   * This software consists of voluntary contributions made by many
61   * individuals on behalf of the Apache Software Foundation. For more
62   * information on the Apache Software Foundation, please see
63   * <http://www.apache.org/>;.
64   *
65   * ====================================================================
66   */
67  
68  import java.io.IOException;
69  import java.io.InputStream;
70  import java.io.StringReader;
71  
72  /***
73   * Wraps a String as an InputStream. Note that data will be lost for
74   * characters not in ISO Latin 1, as a simple char->byte mapping is assumed.
75   *
76   * This file is (c) The Apache Software Foundation, and is released under
77   * the Apache Software License, Version 1.1, and is part of the apache ANT
78   * project (<a href="http://ant.apache.com">http://ant.apache.com</a>
79   *
80   * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
81   * @deprecated As of JUNG version 1.5.2. Use <code>java.io.StringReader</code> instead.
82   */
83  public class StringInputStream
84      extends InputStream
85  {
86      /*** Source string, stored as a StringReader */
87      private StringReader in;
88  
89      /***
90       * Composes a stream from a String
91       *
92       * @param source The string to read from. Must not be <code>null</code>.
93       */
94      public StringInputStream( String source )
950     {
960         in = new StringReader( source );
970     }
98  
99      /***
100       * Reads from the Stringreader, returning the same value. Note that
101       * data will be lost for characters not in ISO Latin 1. Clients
102       * assuming a return value in the range -1 to 255 may even fail on
103       * such input.
104       *
105       * @return the value of the next character in the StringReader
106       *
107       * @exception IOException if the original StringReader fails to be read
108       */
109      public int read() throws IOException
110      {
1110         return in.read();
112      }
113  
114      /***
115       * Closes the Stringreader.
116       *
117       * @exception IOException if the original StringReader fails to be closed
118       */
119      public void close() throws IOException
120      {
1210         in.close();
1220     }
123  
124      /***
125       * Marks the read limit of the StringReader.
126       *
127       * @param limit the maximum limit of bytes that can be read before the
128       * mark position becomes invalid
129       */
130      public synchronized void mark( final int limit )
131      {
132          try
133          {
1340             in.mark( limit );
135          }
1360         catch ( IOException ioe )
137          {
1380             throw new RuntimeException( ioe.getMessage() );
1390         }
1400     }
141  
142      /***
143       * Resets the StringReader.
144       *
145       * @exception IOException if the StringReader fails to be reset
146       */
147      public synchronized void reset() throws IOException
148      {
1490         in.reset();
1500     }
151  
152      /***
153       * @see InputStream#markSupported
154       */
155      public boolean markSupported()
156      {
1570         return in.markSupported();
158      }
159  }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.