import java.util.ArrayList;
-import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.NoSuchElementException;
/**
- * Return an Enumeration over the values of the specified Collection.
- *
- * @param collection Collection whose values should be enumerated
- */
- public Enumerator(Collection<T> collection) {
-
- this(collection.iterator());
-
- }
-
-
- /**
- * Return an Enumeration over the values of the specified Collection.
- *
- * @param collection Collection whose values should be enumerated
- * @param clone true to clone iterator
- */
- public Enumerator(Collection<T> collection, boolean clone) {
-
- this(collection.iterator(), clone);
-
- }
-
-
- /**
* Return an Enumeration over the values returned by the
* specified Iterator.
*
}
- /**
- * Return an Enumeration over the values of the specified Map.
- *
- * @param map Map whose values should be enumerated
- */
- public Enumerator(Map<?,T> map) {
-
- this(map.values().iterator());
-
- }
-
-
- /**
- * Return an Enumeration over the values of the specified Map.
- *
- * @param map Map whose values should be enumerated
- * @param clone true to clone iterator
- */
- public Enumerator(Map<?,T> map, boolean clone) {
-
- this(map.values().iterator(), clone);
-
- }
-
-
// ----------------------------------------------------- Instance Variables
*
* @version $Id$
*/
-public class ASCIIReader
- extends Reader {
-
- //
- // Constants
- //
-
- /** Default byte buffer size (2048). */
- public static final int DEFAULT_BUFFER_SIZE = 2048;
+public class ASCIIReader extends Reader {
//
// Data
/**
- * Construct a new node with no parent.
- *
- * @param name The name of this node
- */
- public TreeNode(String name) {
-
- this(name, null);
-
- }
-
-
- /**
* Construct a new node with the specified parent.
*
* @param name The name of this node
/**
- * Remove any existing value for the specified attribute name.
- *
- * @param name The attribute name to remove
- */
- public void removeAttribute(String name) {
-
- if (attributes != null)
- attributes.remove(name);
-
- }
-
-
- /**
- * Remove a child node from this node, if it is one.
- *
- * @param node The child node to remove
- */
- public void removeNode(TreeNode node) {
-
- if (children != null)
- children.remove(node);
-
- }
-
-
- /**
* Set the body text associated with this node (if any).
*
* @param body The body text (if any)
private final org.apache.juli.logging.Log log=
org.apache.juli.logging.LogFactory.getLog( UTF8Reader.class );
- //
- // Constants
- //
-
- /** Default byte buffer size (2048). */
- public static final int DEFAULT_BUFFER_SIZE = 2048;
-
// debugging
/** Debug read. */
private InputStream fInputStream;
private byte[] fData;
- private int fStartOffset;
private int fEndOffset;
private int fOffset;
private int fLength;
public RewindableInputStream(InputStream is) {
fData = new byte[DEFAULT_XMLDECL_BUFFER_SIZE];
fInputStream = is;
- fStartOffset = 0;
fEndOffset = -1;
fOffset = 0;
fLength = 0;
fMark = 0;
}
- public void setStartOffset(int offset) {
- fStartOffset = offset;
- }
-
- public void rewind() {
- fOffset = fStartOffset;
- }
-
@Override
public int read() throws IOException {
int b = 0;
}
@Override
- public void mark(int howMuch) {
+ public synchronized void mark(int howMuch) {
fMark = fOffset;
}
@Override
- public void reset() {
+ public synchronized void reset() {
fOffset = fMark;
}
public XMLString() {
} // <init>()
- /**
- * Constructs an XMLString structure preset with the specified
- * values.
- *
- * @param ch The character array.
- * @param offset The offset into the character array.
- * @param length The length of characters from the offset.
- */
- public XMLString(char[] ch, int offset, int length) {
- setValues(ch, offset, length);
- } // <init>(char[],int,int)
-
- /**
- * Constructs an XMLString structure with copies of the values in
- * the given structure.
- * <p>
- * <strong>Note:</strong> This does not copy the character array;
- * only the reference to the array is copied.
- *
- * @param string The XMLString to copy.
- */
- public XMLString(XMLString string) {
- setValues(string);
- } // <init>(XMLString)
-
//
// Public methods
//
this.length = -1;
} // clear()
- /**
- * Returns true if the contents of this XMLString structure and
- * the specified array are equal.
- *
- * @param ch The character array.
- * @param offset The offset into the character array.
- * @param length The length of characters from the offset.
- */
- public boolean equals(char[] ch, int offset, int length) {
- if (ch == null) {
- return false;
- }
- if (this.length != length) {
- return false;
- }
-
- for (int i=0; i<length; i++) {
- if (this.ch[this.offset+i] != ch[offset+i] ) {
- return false;
- }
- }
- return true;
- } // equals(char[],int,int):boolean
/**
* Returns true if the contents of this XMLString structure and
ch = new char[size];
} // <init>(int)
- /** Constructs a string buffer from a char. */
- public XMLStringBuffer(char c) {
- this(1);
- append(c);
- } // <init>(char)
-
- /** Constructs a string buffer from a String. */
- public XMLStringBuffer(String s) {
- this(s.length());
- append(s);
- } // <init>(String)
-
- /** Constructs a string buffer from the specified character array. */
- public XMLStringBuffer(char[] ch, int offset, int length) {
- this(length);
- append(ch, offset, length);
- } // <init>(char[],int,int)
-
- /** Constructs a string buffer from the specified XMLString. */
- public XMLStringBuffer(XMLString s) {
- this(s.length);
- append(s);
- } // <init>(XMLString)
-
//
// Public methods
//