/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// XML Implementation packages:
/**
* A kit of methods and classes useful for manipulating XML trees in
* memory. They are very compact and easy to use. An XML element
* occupies six pointers of overhead (like two arrays) plus a pointer
* for its name, each attribute name and value, and each sub-element.
* Many useful XML operations (or Lisp-like calls) can be accomplished
* with a single method call on an element itself.
* <p>
* There is strong integration with the Java collection classes.
* There are viewing and conversion operators to and from various
* collection types. Elements directly support list iterators.
* Most <tt>List</tt> methods work analogously on elements.
* <p>
* Because of implementation compromises, these XML trees are less
* functional than many standard XML classes.
* <ul>
* <li>There are no parent or sibling pointers in the tree.</li>
* <li>Attribute names are simple strings, with no namespaces.</li>
* <li>There is no internal support for schemas or validation.</li>
* </ul>
* <p>
* Here is a summary of functionality in <tt>XMLKit</tt>.
* (Overloaded groups of methods are summarized by marking some
* arguments optional with their default values. Some overloaded
* arguments are marked with their alternative types separated by
* a bar "|". Arguments or return values for which a null is
* specially significant are marked by an alternative "|null".
* Accessors which have corresponding setters are marked
* by "/set". Removers which have corresponding retainers are marked
* by "/retain".)
* <pre>
* --- element construction
* new Element(int elemCapacity=4), String name=""
* new Element(String name, String[] attrs={}, Element[] elems={}, int elemCapacity=4)
* new Element(String name, String[] attrs, Object[] elems, int elemCapacity=4)
* new Element(Element original) // shallow copy
* new Element(String name="", Collection elems) // coercion
*
* Element shallowCopy()
* Element shallowFreeze() // side-effecting
* Element deepCopy()
* Element deepFreeze() // not side-effecting
*
* EMPTY // frozen empty anonymous element
* void ensureExtraCapacity(int)
* void trimToSize()
* void sortAttrs() // sort by key
*
* --- field accessors
* String getName()/set
* int size()
* boolean isEmpty()
* boolean isFrozen()
* boolean isAnonymous()
* int getExtraCapacity()/set
* int attrSize()
*
* --- attribute accessors
* String getAttr(int i)/set
* String getAttrName(int i)
*
* String getAttr(String key)/set
* List getAttrList(String key)/set
* Number getAttrNumber(String key)/set
* long getAttrLong(String key)/set
* double getAttrDouble(String key)/set
*
* String getAttr(String key, String dflt=null)
* long getAttrLong(String key, long dflt=0)
* double getAttrDouble(String key, double dflt=0)
*
* Element copyAttrsOnly()
* Element getAttrs()/set => <em><><key>value</key>...</></em>
* void addAttrs(Element attrs)
*
* void removeAttr(int i)
* void clearAttrs()
*
* --- element accessors
* Object get(int i)/set
* Object getLast() | null
* Object[] toArray()
* Element copyContentOnly()
*
* void add(int i=0, Object subElem)
* int addAll(int i=0, Collection | Element elems)
* int addContent(int i=0, TokenList|Element|Object|null)
* void XMLKit.addContent(TokenList|Element|Object|null, Collection sink|null)
*
* void clear(int beg=0, int end=size)
* void sort(Comparator=contentOrder())
* void reverse()
* void shuffle(Random rnd=(anonymous))
* void rotate(int distance)
*
* --- text accessors
* CharSequence getText()/set
* CharSequence getUnmarkedText()
* int addText(int i=size, CharSequence)
* void trimText();
*
* --- views
* List asList() // element view
* ListIterator iterator()
* PrintWriter asWriter()
* Map asAttrMap()
* Iterable<CharSequence> texts()
* Iterable<Element> elements()
* Iterable<T> partsOnly(Class<T>)
* String[] toStrings()
*
* --- queries
* boolean equals(Element | Object)
* int compareTo(Element | Object)
* boolean equalAttrs(Element)
* int hashCode()
* boolean isText() // every sub-elem is CharSequence
* boolean hasText() // some sub-elem is CharSequence
*
* boolean contains(Object)
* boolean containsAttr(String)
*
* int indexOf(Object)
* int indexOf(Filter, int fromIndex=0)
* int lastIndexOf(Object)
* int lastIndexOf(Filter, int fromIndex=size-1)
*
* int indexOfAttr(String)
*
* // finders, removers, and replacers do addContent of each filtered value
* // (i.e., TokenLists and anonymous Elements are broken out into their parts)
* boolean matches(Filter)
*
* Object find(Filter, int fromIndex=0)
* Object findLast(Filter, int fromIndex=size-1)
* Element findAll(Filter, int fromIndex=0 & int toIndex=size)
* int findAll(Filter, Collection sink | null, int fromIndex=0 & int toIndex=size)
*
* Element removeAllInTree(Filter)/retain
* int findAllInTree(Filter, Collection sink | null)
* int countAllInTree(Filter)
* Element removeAllInTree(Filter)/retain
* int removeAllInTree(Filter, Collection sink | null)/retain
* void replaceAllInTree(Filter)
*
* Element findElement(String name=any)
* Element findAllElements(String name=any)
*
* Element findWithAttr(String key, String value=any)
* Element findAllWithAttr(String key, String value=any)
*
* Element removeElement(String name=any)
* Element removeAllElements(String name=any)/retain
*
* Element removeWithAttr(String key, String value=any)
* Element removeAllWithAttr(String key, String value=any)/retain
*
* //countAll is the same as findAll but with null sink
* int countAll(Filter)
* int countAllElements(String name=any)
* int countAllWithAttr(String key, String value=any)
*
* void replaceAll(Filter, int fromIndex=0 & int toIndex=size)
* void replaceAllInTree(Filter)
* void XMLKit.replaceAll(Filter, List target) //if(fx){remove x;addContent fx}
*
* --- element mutators
* boolean remove(Object)
* Object remove(int)
* Object removeLast() | null
*
* Object remove(Filter, int fromIndex=0)
* Object removeLast(Filter, int fromIndex=size-1)
* Element sink = removeAll(Filter, int fromIndex=0 & int toIndex=size)/retain
* int count = removeAll(Filter, int fromIndex=0 & int toIndex=size, Collection sink | null)/retain
*
* Element removeAllElements(String name=any)
*
* --- attribute mutators
* ??int addAllAttrsFrom(Element attrSource)
*
* --- parsing and printing
* void tokenize(String delims=whitespace, returnDelims=false)
* void writeTo(Writer)
* void writePrettyTo(Writer)
* String prettyString()
* String toString()
*
* ContentHandler XMLKit.makeBuilder(Collection sink, tokenizing=false, makeFrozen=false) // for standard XML parser
* Element XMLKit.readFrom(Reader, tokenizing=false, makeFrozen=false)
* void XMLKit.prettyPrintTo(Writer | OutputStream, Element)
* void XMLKit.output(Object elem, ContentHandler, LexicalHandler=null)
* void XMLKit.writeToken(String, char quote, Writer)
* void XMLKit.writeCData(String, Writer)
* Number XMLKit.convertToNumber(String, Number dflt=null)
* long XMLKit.convertToLong(String, long dflt=0)
* double XMLKit.convertToDouble(String, double dflt=0)
*
* --- filters
* XMLKit.ElementFilter { Element filter(Element) }
* XMLKit.elementFilter(String name=any | Collection nameSet)
* XMLKit.AttrFilter(String key) { boolean test(String value) }
* XMLKit.attrFilter(String key, String value=any)
* XMLKit.attrFilter(Element matchThis, String key)
* XMLKit.classFilter(Class)
* XMLKit.textFilter() // matches any CharSequence
* XMLKit.specialFilter() // matches any Special element
* XMLKit.methodFilter(Method m, Object[] args=null, falseResult=null)
* XMLKit.testMethodFilter(Method m, Object[] args=null)
* XMLKit.not(Filter) // inverts sense of Filter
* XMLKit.and(Filter&Filter | Filter[])
* XMLKit.or(Filter&Filter | Filter[])
* XMLKit.stack(Filter&Filter | Filter[]) // result is (fx && g(fx))
* XMLKit.content(Filter, Collection sink) // copies content to sink
* XMLKit.replaceInTree(Filter pre, Filter post=null) // pre-replace else recur
* XMLKit.findInTree(Filter pre, Collection sink=null) // pre-find else recur
* XMLKit.nullFilter() // ignores input, always returns null (i.e., false)
* XMLKit.selfFilter( ) // always returns input (i.e., true)
* XMLKit.emptyFilter() // ignores input, always returns EMPTY
* XMLKit.constantFilter(Object) // ignores input, always returns constant
*
* --- misc
* Method XMLKit.Element.method(String name) // returns Element method
* </pre>
*
* @author jrose
*/
public abstract class XMLKit {
private XMLKit() {
}
// We need at least this much slop if the element is to stay unfrozen.
// Note: Does not implement List, because it has more
// significant parts besides its sub-elements. Therefore,
// hashCode and equals must be more distinctive than Lists.
// <name> of element
// number of child elements, in parts[0..size-1]
int size;
// The parts start with child elements:: {e0, e1, e2, ...}.
// Following that are optional filler elements, all null.
// They are in reverse: {...key2, val2, key1, val1, key0, val0}.
// Child elements and attr keys and values are never null.
// Build a partially-constructed node.
// Caller is responsible for initializing promised attributes.
}
/** An anonymous, empty element.
* Optional elemCapacity argument is expected number of sub-elements.
*/
public Element() {
}
}
/** An empty element with the given name.
* Optional extraCapacity argument is expected number of sub-elements.
*/
}
}
/** An empty element with the given name and attributes.
* Optional extraCapacity argument is expected number of sub-elements.
*/
}
}
/** An empty element with the given name and sub-elements.
* Optional extraCapacity argument is expected extra sub-elements.
*/
}
}
/** An empty element with the given name, attributes, and sub-elements.
* Optional extraCapacity argument is expected extra sub-elements.
*/
}
this(name, 0,
int fillp = 0;
for (int i = 0; i < ne; i++) {
}
}
}
}
this(c.size());
addAll(c);
}
addAll(c);
}
/** Shallow copy. Same as old.shallowCopy().
* Optional extraCapacity argument is expected extra sub-elements.
*/
this(old, 0);
}
+ old.attrLength());
// copy sub-elements
// copy attributes
alen);
assert (!isFrozen());
}
/** Shallow copy. Same as new Element(this). */
return new Element(this);
}
if (makeFrozen && isFrozen()) {
return this; // no need to copy it
}
int alen = attrLength();
// copy attributes
// copy sub-elements
for (int i = 0; i < size; i++) {
if (e instanceof Element) { // recursion is common case
} else if (makeFrozen) {
// Freeze StringBuffers, etc.
e = fixupString(e);
}
}
return copy;
}
/** Returns new Element(this), and also recursively copies sub-elements. */
return deepFreezeOrCopy(false);
}
/** Returns frozen version of deepCopy. */
return deepFreezeOrCopy(true);
}
/** Freeze this element.
* Throw an IllegalArgumentException if any sub-element is not already frozen.
* (Use deepFreeze() to make a frozen copy of an entire element tree.)
*/
public void shallowFreeze() {
if (isFrozen()) {
return;
}
int alen = attrLength();
// copy attributes
// copy sub-elements
for (int i = 0; i < size; i++) {
if (e instanceof Element) { // recursion is common case
throw new IllegalArgumentException("Sub-element must be frozen.");
}
} else {
// Freeze StringBuffers, etc.
e = fixupString(e);
}
nparts[i] = e;
}
assert (isFrozen());
}
/** Return the name of this element. */
return name;
}
/** Change the name of this element. */
}
/** Reports if the element's name is a particular string (spelled "*").
* Such elements are created by the nullary Element constructor,
* and by query functions which return multiple values,
* such as <tt>findAll</tt>.
*/
public boolean isAnonymous() {
}
/** Return number of elements. (Does not include attributes.) */
public int size() {
return size;
}
/** True if no elements. (Does not consider attributes.) */
public boolean isEmpty() {
return size == 0;
}
/** True if this element does not allow modification. */
public boolean isFrozen() {
// It is frozen iff there is no slop space.
}
void checkNotFrozen() {
if (isFrozen()) {
throw new UnsupportedOperationException("cannot modify frozen element");
}
}
/** Remove specified elements. (Does not affect attributes.) */
public void clear() {
}
}
}
}
return;
}
if (beg == 0
// If no attributes, free the parts array.
size = 0;
} else {
}
} else {
}
}
}
}
/** True if name, attributes, and elements are the same. */
return false;
}
return false;
}
// elements must be equal and ordered
for (int i = 0; i < size; i++) {
return false;
}
} else {
// If either is a non-string char sequence, normalize it.
return false;
}
}
}
// finally, attributes must be equal (unordered)
return this.equalAttrs(that);
}
// bridge method
if (!(o instanceof Element)) {
return false;
}
}
public int hashCode() {
int hc = 0;
int alen = attrLength();
}
for (int i = 0; i < size; i++) {
if (p instanceof Element) {
} else {
}
}
return hc;
}
/** Compare lexicographically. Earlier-spelled attrs are more sigificant. */
int r;
// Primary key is element name.
if (r != 0) {
return r;
}
// Secondary key is attributes, as if in normal key order.
int thisAlen = this.attrLength();
assert (assertAttrCompareOK(r, that));
if (r != 0) {
return r;
}
}
// Finally, elements should be equal and ordered,
// and the first difference rules.
}
for (int i = 0; i < minSize; i++) {
if (r != 0) {
return r;
}
}
//if (this.size < that.size) return -1;
}
int r2;
for (int k = 0;; k++) {
if (!con0) {
break;
}
if (!con1) {
break;
}
}
if (!con0) {
r2 = 0;
break;
}
if (r2 != 0) {
break;
}
if (r2 != 0) {
break;
}
}
if (r != 0) {
r = (r > 0) ? 1 : -1;
}
if (r2 != 0) {
}
if (r != r2) {
}
return r == r2;
}
private void badIndex(int i) {
}
if (i >= size) {
badIndex(i);
}
return parts[i];
}
if (i >= size) {
badIndex(i);
}
e.getClass(); // null check
setRaw(i, e);
return old;
}
parts[i] = e;
}
int i = indexOf(e);
if (i < 0) {
return false;
}
close(i, 1);
return true;
}
if (i >= size) {
badIndex(i);
}
close(i, 1);
return e;
}
if (size == 0) {
return null;
}
}
/** Remove the first element matching the given filter.
* Return the filtered value.
*/
return findOrRemove(f, 0, true);
}
if (fromIndex < 0) {
fromIndex = 0;
}
return findOrRemove(f, fromIndex, true);
}
/** Remove the last element matching the given filter.
* Return the filtered value.
*/
}
}
return findOrRemoveLast(f, fromIndex, true);
}
/** Remove all elements matching the given filter.
* If there is a non-null collection given as a sink,
* transfer removed elements to the given collection.
* The int result is the number of removed elements.
* If there is a null sink given, the removed elements
* are discarded. If there is no sink given, the removed
* elements are returned in an anonymous container element.
*/
return result;
}
return result;
}
}
}
/** Remove all elements not matching the given filter.
* If there is a non-null collection given as a sink,
* transfer removed elements to the given collection.
* The int result is the number of removed elements.
* If there is a null sink given, the removed elements
* are discarded. If there is no sink given, the removed
* elements are returned in an anonymous container element.
*/
return result;
}
return result;
}
}
}
// (The shape of this method is tweaked for common cases.)
e.getClass(); // force a null check on e
// Common case: Have some slop space.
if (i == size) {
// Most common case: Append.
setRaw(i, e);
size++;
return;
}
if (i > size) {
badIndex(i);
}
// Second most common case: Shift right by one.
open(i, 1);
setRaw(i, e);
return;
}
// Ran out of space. Do something complicated.
setRaw(i, e);
}
return true;
}
}
/** Returns the text of this Element.
* All sub-elements of this Element must be of type CharSequence.
* A ClassCastException is raised if there are non-character sub-elements.
* If there is one sub-element, return it.
* Otherwise, returns a TokenList of all sub-elements.
* This results in a space being placed between each adjacent pair of sub-elements.
*/
if (size == 1) {
} else {
}
}
/** Provides an iterable view of this object as a series of texts.
* All sub-elements of this Element must be of type CharSequence.
* A ClassCastException is raised if there are non-character sub-elements.
*/
}
/** Returns an array of strings derived from the sub-elements of this object.
* All sub-elements of this Element must be of type CharSequence.
* A ClassCastException is raised if there are non-character sub-elements.
*/
//checkTextOnly();
for (int i = 0; i < size; i++) {
}
return result;
}
/** Like getText, except that it disregards non-text elements.
* Non-text elements are replaced by their textual contents, if any.
* Text elements which were separated only by non-text element
* boundaries are merged into single tokens.
* <p>
* There is no corresponding setter, since this accessor does
* not report the full state of the element.
*/
if (size == 1) {
// Simple cases.
} else {
return new TokenList();
}
}
if (isText()) {
return getText();
}
// Filter and merge.
boolean merge = false;
for (int i = 0; i < size; i++) {
if (!(text instanceof CharSequence)) {
// Skip, but erase this boundary.
}
}
merge = true;
continue;
}
if (merge) {
// Merge w/ previous token.
merge = false;
} else {
}
}
} else {
}
}
/** Return true if all sub-elements are of type CharSequence. */
public boolean isText() {
for (int i = 0; i < size; i++) {
if (!(parts[i] instanceof CharSequence)) {
return false;
}
}
return true;
}
/** Return true if at least one sub-element is of type CharSequence. */
public boolean hasText() {
for (int i = 0; i < size; i++) {
if (parts[i] instanceof CharSequence) {
return true;
}
}
return false;
}
/** Raise a ClassCastException if !isText. */
public void checkTextOnly() {
for (int i = 0; i < size; i++) {
}
}
/** Clears out all sub-elements, and replaces them by the given text.
* A ClassCastException is raised if there are non-character sub-elements,
* either before or after the change.
*/
clear();
// TL's contain only strings
} else {
}
}
/** Add text at the given position, merging with any previous
* text element, but preserving token boundaries where possible.
* <p>
* In all cases, the new value of getText() is the string
* concatenation of the old value of getText() plus the new text.
* <p>
* The total effect is to concatenate the given text to any
* pre-existing text, and to do so efficiently even if there
* are many such concatenations. Also, getText calls which
* return multiple tokens (in a TokenList) are respected.
* For example, if x is empty, x.addText(y.getText()) puts
* an exact structural copy of y's text into x.
* <p>
* Internal token boundaries in the original text, and in the new
* text (i.e., if it is a TokenList), are preserved. However,
* at the point where new text joins old text, a StringBuffer
* or new String may be created to join the last old and first
* new token.
* <p>
* If the given text is a TokenList, add the tokens as
* separate sub-elements, possibly merging the first token to
* a previous text item (to avoid making a new token boundary).
* <p>
* If the element preceding position i is a StringBuffer,
* append the first new token to it.
* <p>
* If the preceding element is a CharSequence, replace it by a
* StringBuffer containing both its and the first new token.
* <p>
* If tokens are added after a StringBuffer, freeze it into a String.
* <p>
* Every token not merged into a previous CharSequence is added
* as a new sub-element, starting at position i.
* <p>
* Returns the number of elements added, which is useful
* for further calls to addText. This number is zero
* if the input string was null, or was successfully
* merged into a StringBuffer at position i-1.
* <p>
* By contrast, calling add(text) always adds a new sub-element.
* In that case, if there is a previous string, a separating
* space is virtually present also, and will be observed if
* getText() is used to return all the text together.
*/
// Text is a list of tokens.
if (tlsize == 0) {
return 0;
}
if (tlsize == 1) {
}
if (mergeWithPrev(i, token0, false)) {
// Add the n-1 remaining tokens.
return tlsize - 1;
} else {
return tlsize;
}
} else {
}
}
}
private // no reason to make this helper public
return 0; // Trivial success.
}
if (mergeWithPrev(i, text, true)) {
return 0; // Merged with previous token.
}
// No previous token.
return 1;
}
// Tries to merge token with previous contents.
// Returns true if token is successfully disposed of.
// If keepSB is false, any previous StringBuffer is frozen.
// If keepSB is true, a StringBuffer may be created to hold
// the merged token.
if (i == 0) // Trivial success if the token is length zero.
{
}
if (prev instanceof StringBuffer) {
if (!keepSB) {
}
return true;
}
return true; // Trivial success.
}
if (prev instanceof CharSequence) {
// Must concatenate.
if (keepSB) {
} else {
}
return true;
}
return false;
}
/** Trim all strings, using String.trim().
* Remove empty strings.
* Normalize CharSequences to Strings.
*/
public void trimText() {
int fillp = 0;
for (int i = 0; i < size; i++) {
if (e instanceof CharSequence) {
continue;
}
e = tt;
}
}
}
}
/** Add one or more subelements at the given position.
* If the object reference is null, nothing happens.
* If the object is an anonymous Element, addAll is called.
* If the object is a TokenList, addAll is called (to add the tokens).
* Otherwise, add is called, adding a single subelement or string.
* The net effect is to add zero or more tokens.
* The returned value is the number of added elements.
* <p>
* Note that getText() can return a TokenList which preserves
* token boundaries in the text source. Such a text will be
* added as multiple text sub-elements.
* <p>
* If a text string is added adjacent to an immediately
* preceding string, there will be a token boundary between
* the strings, which will print as an extra space.
*/
if (e == null) {
return 0;
} else if (e instanceof TokenList) {
return addAll(i, (Collection) e);
} else if (e instanceof Element
&& ((Element) e).isAnonymous()) {
} else {
add(i, e);
return 1;
}
}
return addContent(size, e);
}
return result;
}
return content;
}
}
public void sort() {
}
/** Equivalent to Collections.reverse(this.asList()). */
public void reverse() {
parts[j] = p;
}
}
/** Equivalent to Collections.shuffle(this.asList() [, rnd]). */
public void shuffle() {
}
}
/** Equivalent to Collections.rotate(this.asList(), dist). */
}
/** Equivalent to Collections.min(this.asList(), c). */
}
return min(CONTENT_ORDER);
}
/** Equivalent to Collections.max(this.asList(), c). */
}
return max(CONTENT_ORDER);
}
if (c instanceof LView) {
} else {
if (csize == 0) {
return 0;
}
openOrExpand(i, csize);
int fill = i;
}
return csize;
}
}
if (esize == 0) {
return 0;
}
openOrExpand(i, esize);
return esize;
}
}
}
int added = 0;
for (int k = 0; e.containsAttr(k); k++) {
added += 1;
}
}
// Return number of added (not merely changed) attrs.
return added;
}
// Search.
}
return findOrRemove(f, 0, false);
}
if (fromIndex < 0) {
fromIndex = 0;
}
return findOrRemove(f, fromIndex, false);
}
/** Find the last element matching the given filter.
* Return the filtered value.
*/
}
}
return findOrRemoveLast(f, fromIndex, false);
}
/** Find all elements matching the given filter.
* If there is a non-null collection given as a sink,
* transfer matching elements to the given collection.
* The int result is the number of matching elements.
* If there is a null sink given, the matching elements are
* not collected. If there is no sink given, the matching
* elements are returned in an anonymous container element.
* In no case is the receiver element changed.
* <p>
* Note that a simple count of matching elements can be
* obtained by passing a null collection argument.
*/
return result;
}
return result;
}
}
}
/// Driver routines.
if (x != null) {
if (remove) {
close(i, 1);
}
return x;
}
}
return null;
}
for (int i = fromIndex; i >= 0; i--) {
if (x != null) {
if (remove) {
close(i, 1);
}
return x;
}
}
return null;
}
if (fromIndex < 0) {
}
}
int found = 0;
if (remove) {
close(i--, 1);
toIndex--;
}
}
}
return found;
}
}
}
/// Recursive walks.
// findAllInTree(f) == findAll(findInTree(f,S)), S.toElement
// findAllInTree(f,S) == findAll(findInTree(content(f,S)))
// removeAllInTree(f) == replaceAll(replaceInTree(and(f,emptyF)))
// removeAllInTree(f,S) == replaceAll(replaceInTree(and(content(f,S),emptyF)))
// retainAllInTree(f) == removeAllInTree(not(f))
// replaceAllInTree(f) == replaceAll(replaceInTree(f))
return result;
}
int found = 0;
for (int i = 0; i < size; i++) {
if (x != null) {
} else if (p instanceof Element) {
}
}
return found;
}
return findAllInTree(f, null);
}
sink = newCounterColl();
}
}
return result;
}
}
return result;
}
replaceAll(replaceInTree(f));
}
/** Raise a ClassCastException if any subelements are the wrong type. */
for (int i = 0; i < size; i++) {
}
}
/** Return true if all sub-elements are of the given type. */
for (int i = 0; i < size; i++) {
return false;
}
}
return true;
}
/** Provides an iterable view of this object as a series of elements.
* All sub-elements of this Element must be of type Element.
* A ClassCastException is raised if there are non-Element sub-elements.
*/
}
}
/// Useful shorthands.
// Finding or removing elements w/o regard to their type or content.
}
return findAll(elementFilter());
}
}
}
// Finding or removing by element tag or selected attribute,
// as if by elementFilter(name) or attrFilter(name, value).
// Roughly akin to Common Lisp ASSOC.
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
public int countAllElements() {
return countAll(elementFilter());
}
}
}
}
for (int i = 0; i < size; i++) {
return i;
}
}
return -1;
}
return i;
}
}
return -1;
}
/** Remove the first element matching the given filter.
* Return the filtered value.
*/
return indexOf(f, 0);
}
if (fromIndex < 0) {
fromIndex = 0;
}
if (x != null) {
return i;
}
}
return -1;
}
/** Remove the last element matching the given filter.
* Return the filtered value.
*/
}
}
for (int i = fromIndex; i >= 0; i--) {
if (x != null) {
return i;
}
}
return -1;
}
return indexOf(e) >= 0;
}
// attributes
if (!create) {
return -1;
}
if (i == size) {
break; // NEED_SLOP
}
//parts[i+1] = ""; //caller responsibility
return i;
}
attrBase = i;
return i;
}
}
// If we fell through, we ran into an element part.
// Therefore we have run out of empty slots.
if (!create) {
return -1;
}
assert (!isFrozen());
// since there was a reallocation, the garbage slots are really null
alen += 2;
//parts[i+1] = ""; //caller responsibility
return i;
}
public int attrSize() {
return attrLength() >>> 1;
}
return findOrCreateAttr(key, false);
}
}
}
int i = findOrCreateAttr(key, false);
}
}
}
}
}
}
}
int indexAttr(int k) {
return -2; // always oob
}
return i;
}
public boolean containsAttr(int k) {
return indexAttr(k) >= 0;
}
}
}
//return asAttrMap().keySet();
return new ANItr();
}
};
}
// Hand-inlined replacement for asAttrMap().keySet().iterator():
boolean lastRet;
public boolean hasNext() {
}
Object x;
nsee();
return null;
}
cursor -= 2;
lastRet = true;
return (String) x;
}
public void remove() {
if (!lastRet) {
throw new IllegalStateException();
}
cursor += 2;
lastRet = false;
}
}
}
/** Return an anonymous copy of self, but only with attributes.
*/
int alen = attrLength();
alen);
return attrs;
}
/** Get all attributes, represented as an element with sub-elements.
* The name of each sub-element is the attribute key, and the text
* This is a fresh copy, and can be updated with affecting the original.
* of each sub-element is the corresponding attribute value.
* See also asAttrMap() for a "live" view of all the attributes as a Map.
*/
for (int i = 0; i < asize; i++) {
// %%% normalize attrs to token lists?
}
return attrs;
}
int alen = attrLength();
}
}
}
}
public void removeAttr(int i) {
while ((i -= 2) >= size) {
if (k == null) {
break;
}
parts[i + 2] = k;
parts[i + 3] = v;
}
}
public void clearAttrs() {
return; // no attrs to clear
}
if (size == 0) {
// If no elements, free the parts array.
return;
}
assert (i >= size);
}
}
int i = findOrCreateAttr(key, false);
if (i >= 0) {
removeAttr(i);
} else {
}
} else {
int i = findOrCreateAttr(key, true);
}
return old;
}
if (l == null) {
}
if (!(l instanceof TokenList)) {
l = new TokenList(l);
}
}
}
}
}
int i = indexAttr(k);
removeAttr(i);
} else {
}
return old;
}
int attrLength() {
}
/** Are the attributes of the two two elements equal?
* Disregards name, sub-elements, and ordering of attributes.
*/
int alen = this.attrLength();
return false;
}
if (alen == 0) {
return true;
}
}
boolean fullCompare) {
// search indexes into unmatched parts of this.attrs:
int firstI = 0;
// search indexes into unmatched parts of that.attrs:
int firstJ = 0;
// try to find the mismatch with the first key:
int firstKeyValCmp = 0;
int foundKeys = 0;
foundKeys += 1;
// Optimization: Narrow subsequent searches when easy.
if (j == lastJ) {
lastJ -= 2;
} else if (j == firstJ) {
firstJ += 2;
}
if (i == firstI) {
firstI += 2;
}
break;
}
}
int valCmp;
// The key was found.
if (!fullCompare) {
return 1 - 0; //arb.
}
continue;
}
} else {
// Found the key in this but not that.
// Such a mismatch puts the guy missing the key last.
}
if (valCmp != 0) {
// found a mismatch, key present in both elems
// found a better key
}
}
}
// We have located the first mismatch of all keys in this.attrs.
// In general we must also look for keys in that.attrs but missing
// from this.attrs; such missing keys, if earlier than firstKey,
// rule the comparison.
// We can sometimes prove quickly there is no missing key.
// Exhausted all keys in that.attrs.
return firstKeyValCmp;
}
// Search for a missing key in that.attrs earlier than firstKey.
// Found a better key; is it missing?
continue findMissingKey;
}
}
// If we get here, there was no match in this.attrs.
return 1 - 0;
}
}
// No missing key. Previous comparison value rules.
return firstKeyValCmp;
}
// Binary search looking for first non-null after size.
int attrBase() {
// Smallest & largest possible attribute indexes:
int kmin = 0;
// earlist possible attribute position:
// binary search using scaled indexes:
} else {
}
}
}
/** Sort attributes by name. */
public void sortAttrs() {
// collect keys
}
// collect values
}
// reorder keys and values
fillp -= 2;
}
}
/*
Notes on whitespace and tokenization.
On input, never split CDATA blocks. They remain single tokens.
?Try to treat encoded characters as CDATA-quoted, also?
Internally, each String sub-element is logically a token.
However, if there was no token-splitting on input,
consecutive strings are merged by the parser.
Internally, we need addToken (intervening blank) and addText
(hard concatenation).
Optionally on input, tokenize unquoted text into words.
Between each adjacent word pair, elide either one space
or all space.
On output, we always add spaces between tokens.
The Element("a", {"b", "c", Element("d"), "e f"})
outputs as "<a>b c<d/>e f</a>"
*/
/** Split strings into tokens, using a StringTokenizer. */
}
for (int i = 0; i < size; i++) {
if (!(parts[i] instanceof CharSequence)) {
continue;
}
switch (nstrs) {
case 0:
close(i--, 1);
break;
case 1:
break;
default:
for (int j = 0; j < nstrs; j++) {
}
i += nstrs - 1;
break;
}
}
}
}
public void tokenize() {
}
// views
return Element.this;
}
public int size() {
}
}
}
}
}
return Element.this.lastIndexOf(e);
}
++modCount;
}
++modCount;
}
++modCount;
}
++modCount;
}
++modCount;
}
public void clear() {
++modCount;
}
// Others: toArray(Object[]), containsAll, removeAll, retainAll
}
/** Produce a list view of sub-elements.
* (The list view does not provide access to the element's
* name or attributes.)
* Changes to this view are immediately reflected in the
* element itself.
*/
return new LView();
}
/** Produce a list iterator on all sub-elements. */
//return asList().listIterator();
return new Itr();
}
// Hand-inlined replacement for LView.listIterator():
public boolean hasNext() {
}
public boolean hasPrevious() {
}
if (!hasNext()) {
nsee();
}
}
if (!hasPrevious()) {
nsee();
}
}
public int nextIndex() {
return cursor;
}
public int previousIndex() {
return cursor - 1;
}
}
lastRet = -1;
}
public void remove() {
if (lastRet < 0) {
throw new IllegalStateException();
}
--cursor;
}
lastRet = -1;
}
void nsee() {
}
}
/** A PrintWriter which always appends as if by addText.
* Use of this stream may insert a StringBuffer at the end
* of the Element. The user must not directly modify this
* StringBuffer, or use it in other data structures.
* From time to time, the StringBuffer may be replaced by a
* constant string as a result of using the PrintWriter.
*/
return new ElemW();
}
ElemW() {
super(new StringWriter());
}
{
} // synchronize on this buffer
public void println() {
synchronized (buf) {
ensureCursor();
super.println();
}
}
synchronized (buf) {
ensureCursor();
//buf.append(ch);
}
}
synchronized (buf) {
ensureCursor();
}
}
synchronized (buf) {
ensureCursor();
//buf.append(s.substring(off, off+len));
}
}
synchronized (buf) {
ensureCursor();
//buf.append(s);
super.write(s);
}
}
private void ensureCursor() {
if (pos >= 0) {
// Freeze the pre-existing use of buf.
}
}
}
}
/** Produce a map view of attributes, in which the attribute
* name strings are the keys.
* (The map view does not provide access to the element's
* name or sub-elements.)
* Changes to this view are immediately reflected in the
* element itself.
*/
final int k;
Entry(int k) {
this.k = k;
}
return Element.this.getAttrName(k);
}
}
}
return false;
}
}
public int hashCode() {
}
}
int k = 0; // index of pending next() attribute
public boolean hasNext() {
return Element.this.containsAttr(k);
}
return new Entry(k++);
}
public void remove() {
Element.this.removeAttr(--k);
}
}
public int size() {
}
return new EIter();
}
public void clear() {
Element.this.clearAttrs();
}
}
}
return eSet;
}
public int size() {
}
public boolean containsKey(String k) {
return Element.this.containsAttr(k);
}
}
}
}
}
return new AView();
}
/** Reports number of additional elements this object can accommodate
* without reallocation.
*/
public int getExtraCapacity() {
}
/** Ensures that at least the given number of additional elements
* can be added to this object without reallocation.
*/
return;
}
}
/**
* Trim excess capacity to zero, or do nothing if frozen.
* This minimizes the space occupied by this Element,
* at the expense of a reallocation if sub-elements or attributes
* are added later.
*/
public void trimToSize() {
if (isFrozen()) {
return;
}
setExtraCapacity(0);
}
/** Changes the number of additional elements this object can accommodate
* without reallocation.
*/
// copy attributes
// copy sub-elements
}
assert (cap == getExtraCapacity());
}
// Return true if there are at least len nulls of slop available.
if (len == 0) {
return true;
}
return false;
}
}
// Opens up parts array at pos by len spaces.
}
// Reallocate and open up at parts[pos] to at least len empty places.
// Shift anything after pos right by len. Reallocate if necessary.
// If pos < size, caller must fill it in with non-null values.
// Returns incremented size; caller is responsible for storing it
// down, if desired.
// There must be at least len nulls between elems and attrs.
// copy head of sub-elements
// copy tail of sub-elements
// copy attributes
// update self
//assert(hasNulls(len)); <- not yet true, since size != nsize
return nsize;
}
// Open or expand at the given position, as appropriate.
}
} else {
}
return false;
} else {
return true;
}
}
// Close up at parts[pos] len old places.
// Shift anything after pos left by len.
// Fill unused end of parts with null.
assert (len > 0);
// reinitialize the unoccupied slots to null
// update self
}
}
prettyPrintTo(w, this);
}
try {
} catch (IOException ee) {
}
}
try {
} catch (IOException ee) {
}
}
// For debugging only. Reveals internal layout.
if (p == null) {
} else {
}
}
}
}
allM = makeAllMethods();
}
throw new IllegalArgumentException(name);
}
return res;
}
if (allMethods != null) {
return allMethods;
}
continue;
}
{
continue;
}
{
continue;
}
}
}
}
// Delete ambiguous methods.
//System.out.println("ambig: "+pm);
//System.out.println(" with: "+m);
//ambig: int addAll(int,Element)
// with: int addAll(int,Collection)
}
}
//System.out.println("allM: "+allM);
return allMethods = allM;
}
}
} else {
return part;
}
}
}
return kind;
}
return value;
}
if (!(o instanceof Special)) {
return false;
}
}
public int hashCode() {
}
if (r != 0) {
return r;
}
}
}
}
/** Supports sorting of mixed content. Sorts strings first,
* then Elements, then everything else (as Comparable).
*/
return CONTENT_ORDER;
}
}
if (cs1) {
return 0 - 1;
}
if (cs2) {
return 1 - 0;
}
}
if (el1) {
return 0 - 1;
}
if (el2) {
return 1 - 0;
}
}
}
/** Used to find, filter, or transform sub-elements.
* When used as a predicate, the filter returns a null
* value for false, and the original object value for true.
* When used as a transformer, the filter may return
* null, for no values, the original object, a new object,
* or an anonymous Element (meaning multiple results).
*/
public interface Filter {
}
/** Use this to find an element, perhaps with a given name. */
/** Subclasses may override this to implement better value tests.
* By default, it returns the element itself, thus recognizing
* all elements, regardless of name.
*/
return elem; // override this
}
return null;
}
}
return "<ElementFilter name='*'/>";
}
}
}
return new ElementFilter() {
}
}
};
}
return new ElementFilter() {
}
}
};
}
}
return elementFilter(ncoll);
}
/** Use this to find an element with a named attribute,
* possibly with a particular value.
* (Note that an attribute is missing if and only if its value is null.)
*/
}
/** Subclasses may override this to implement better value tests.
* By default, it returns true for any non-null value, thus
* recognizing any attribute of the given name, regardless of value.
*/
}
}
}
}
return new AttrFilter(attrName);
}
}
return new AttrFilter(attrName) {
}
}
};
}
}
/** Use this to find a sub-element of a given class. */
return new Filter() {
}
}
};
}
}
}
/** This filter always returns its own argument. */
if (selfFilter != null) {
return selfFilter;
}
return selfFilter = new Filter() {
return value;
}
return "<Self/>";
}
};
}
/** This filter always returns a fixed value, regardless of argument. */
return new Filter() {
return value;
}
}
};
}
}
}
/** Use this to invert the logical sense of the given filter. */
return new Filter() {
}
return "<Not>" + f + "</Not>";
}
};
}
/** Use this to combine several filters with logical AND.
* Returns either the first null or the last non-null value.
*/
}
case 0:
return selfFilter(); // always true (on non-null inputs)
case 1:
return fs[0];
}
return new Filter() {
}
}
return res;
}
}
};
}
/** Use this to combine several filters with logical OR.
* Returns either the first non-null or the last null value.
*/
}
case 0:
return nullFilter();
case 1:
return fs[0];
}
return new Filter() {
}
}
return res;
}
}
};
}
/** Use this to combine several filters with logical AND,
* and where each non-null result is passed as the argument
* to the next filter.
* Returns either the first null or the last non-null value.
*/
}
case 0:
return nullFilter();
case 1:
return fs[0];
}
return new Filter() {
}
}
return res;
}
}
};
}
/** Copy everything produced by f to sink, using addContent. */
return new Filter() {
return res;
}
"</addContent>");
}
};
}
/** Look down the tree using f, collecting fx, else recursing into x.
* Identities:
* <code>
* findInTree(f, s) == findInTree(content(f, s))
* findInTree(f) == replaceInTree(and(f, selfFilter())).
* </code>
*/
}
return findInTree(f);
}
/** Look down the tree using f, recursing into x unless fx. */
return new Filter() {
return res;
}
// recurse
}
return null;
}
"</FindInTree>");
}
};
}
/** Look down the tree using f. Replace each x with fx, else recurse.
* If post filter g is given, optionally replace with gx after recursion.
*/
return new Filter() {
return res;
}
// recurse
// Optional postorder traversal:
if (g != null) {
}
}
return res; // usually null, meaning no replacement
}
return opToString("<ReplaceInTree>",
new Object[]{f, g},
"</ReplaceInTree>");
}
};
}
f.getClass(); // null check
return replaceInTree(f, null);
}
/** Make a filter which calls this method on the given element.
* If the method is static, the first argument is passed the
* the subtree value being filtered.
* If the method is non-static, the receiver is the subtree value itself.
* <p>
* Optionally, additional arguments may be specified.
* <p>
* If the filtered value does not match the receiver class
* (or else the first argument type, if the method is static),
* the filter returns null without invoking the method.
* <p>
* The returned filter value is the result returned from the method.
* Optionally, a non-null special false result value may be specified.
* If the result returned from the method is equal to that false value,
* the filter will return null.
*/
}
}
}
}
}
}
final boolean isTest,
throw new IllegalArgumentException("too many arguments");
}
if (valueType.isPrimitive()) {
throw new IllegalArgumentException("filtered value must be reference type");
}
}
}
}
}
return null; // filter fails quickly
}
if (isStatic) {
{
}
}
try {
if (ee instanceof RuntimeException) {
throw (RuntimeException) ee;
}
}
} catch (IllegalAccessException ee) {
}
// Void methods return self by convention.
// (But void "tests" always return false.)
}
} else {
} else if (isTest) {
// Tests return self by convention.
}
}
return res;
}
return "<Method>" + m + "</Method>";
}
}
return new MFilt();
}
static {
}
}
}
}
/** Call the filter on each list element x, and replace x with the
* resulting filter value e, or its parts.
* If e is null, keep x. (This eases use of partial-domain filters.)
* If e is a TokenList or an anonymous Element, add e's parts
* to the list instead of x.
* Otherwise, replace x by e.
* <p>
* The effect at each list position <code>n</code> may be expressed
* in terms of XMLKit.addContent as follows:
* <pre>
* Object e = f.filter(target.get(n));
* if (e != null) {
* target.remove(n);
* addContent(e, target.subList(n,n));
* }
* </pre>
* <p>
* Note: To force deletion of x, simply have the filter return
* Element.EMPTY or TokenList.EMPTY.
* To force null filter values to have this effect,
* use the expression: <code>or(f, emptyFilter())</code>.
*/
// Unliked addContent, a null is a no-op here.
// i.remove();
} else {
i.remove();
}
}
} else {
i.remove();
}
}
} else if (x != fx) {
}
}
}
/** If e is null, return zero.
* If e is a TokenList or an anonymous Element, add e's parts
* to the collection, and return the number of parts.
* Otherwise, add e to the collection, and return one.
* If the collection reference is null, the result is as if
* a throwaway collection were used.
*/
if (e == null) {
return 0;
} else if (e instanceof TokenList) {
}
} else if (e instanceof Element
&& ((Element) e).isAnonymous()) {
}
} else {
}
return 1;
}
}
return new AbstractCollection<Object>() {
int size;
public int size() {
return size;
}
++size;
return true;
}
throw new UnsupportedOperationException();
}
};
}
/** SAX2 document handler for building Element trees. */
/*, EntityResolver, DTDHandler, ErrorHandler*/
boolean makeFrozen;
boolean tokenizing;
this.tokenizing = tokenizing;
this.makeFrozen = makeFrozen;
}
// Parts is organized this way:
// | name0 | akey aval ... | subelem ... | name1 | ... |
// The position of the first "akey" after name0 is attrBases[0].
// The position of the first "subelem" after name0 is elemBases[0].
// The position after the last part is always nparts.
boolean inCData = false;
//System.out.println("addPart "+x);
}
}
} else {
return null;
}
}
void clearMergeableToken() {
if (mergeableToken >= 0) {
// Freeze temporary StringBuffers into strings.
mergeableToken = -1;
}
}
void setMergeableToken() {
}
}
// ContentHandler callbacks
++depth;
}
// Collect attributes.
for (int k = 0; k < na; k++) {
}
// Get ready to collect elements.
}
assert (depth >= 0);
// Set up attributes.
}
// Set up sub-elements.
// Back out of this level.
--depth;
assert (e.isFrozen() == makeFrozen);
if (depth >= 0) {
addPart(e);
} else {
}
}
public void startCDATA() {
inCData = true;
}
public void endCDATA() {
inCData = false;
}
boolean headSpace = false;
boolean tailSpace = false;
int firstLen;
if (tokenizing && !inCData) {
// Strip unquoted blanks.
headSpace = true;
++off;
--len;
}
if (len == 0) {
tailSpace = true; // it is all space
}
tailSpace = true;
--len;
}
firstLen = 0;
++firstLen;
}
} else {
}
if (headSpace) {
}
boolean mergeAtEnd = !tailSpace;
// If buffer was empty, or had only ignorable blanks, do nothing.
if (len == 0) {
return;
}
// Decide whether to merge some of these chars into a previous token.
if (prev instanceof StringBuffer) {
} else {
// Merge two strings.
// Replace previous string with new StringBuffer.
} else {
// Freeze it now.
}
}
if (len > 0) {
// Appended only the first token.
// Add the rest as separate parts.
while (len > 0) {
++off;
--len;
}
int nextLen = 0;
++nextLen;
}
assert (nextLen > 0);
}
}
if (mergeAtEnd) {
}
}
if (false) {
}
}
}
}
}
}
public void endDTD() {
}
}
}
}
public void startDocument() {
}
public void endDocument() {
}
}
}
}
/** Produce a ContentHandler for use with an XML parser.
* The object is <em>also</em> a LexicalHandler.
* Every top-level Element produced will get added to sink.
* All elements will be frozen iff makeFrozen is true.
*/
public static ContentHandler makeBuilder(Collection<Object> sink, boolean tokenizing, boolean makeFrozen) {
}
}
return makeBuilder(sink, false, false);
}
public static Element readFrom(Reader in, boolean tokenizing, boolean makeFrozen) throws IOException {
try {
} catch (SAXException ee) {
}
//parser.setFastStandalone(true);
try {
(LexicalHandler) b);
} catch (SAXException ee) {
// Ignore. We will miss the comments and whitespace.
}
try {
} catch (SAXParseException ee) {
throw new RuntimeException("line " + ee.getLineNumber() + " col " + ee.getColumnNumber() + ": ", ee);
} catch (SAXException ee) {
throw new RuntimeException(ee);
}
case 0:
return null;
case 1:
}
// fall through
default:
if (makeFrozen) {
}
return sink;
}
}
}
}
}
}
static class Outputter {
}
if (x instanceof Element) {
}
for (int i = 0; i < e.size(); i++) {
}
} else if (x instanceof Special) {
} else {
// drop silently
}
} else {
}
}
}
public static class Printer {
public Writer w;
public boolean tokenizing;
public boolean pretty;
boolean prevStr;
this.w = w;
}
public Printer() {
this.w = sw;
}
return next;
}
if (depth > 0) {
w.write("\n");
}
while (nsp > 0) {
String s = " ";
w.write(t);
}
}
if (e.isAnonymous()) {
printParts(e);
return;
}
printRecursive(e);
}
print(e);
w.write("\n");
w.flush();
}
boolean indented = false;
indented = true;
}
w.write("<");
w.write(" ");
w.write("=");
w.write("\"");
w.write("\"");
} else {
w.write("'");
w.write("'");
}
}
if (e.size() == 0) {
w.write("/>");
} else {
++depth;
if (abbreviated) {
w.write("/");
} else {
w.write(">");
}
prevStr = false;
printParts(e);
if (abbreviated) {
w.write(">");
} else {
}
w.write("</");
w.write(">");
}
prevStr = false;
--depth;
}
}
for (int i = 0; i < e.size(); i++) {
if (x instanceof Element) {
printRecursive((Element) x);
prevStr = false;
} else if (x instanceof Special) {
prevStr = false;
} else {
if (pretty) {
s = s.trim();
if (s.length() == 0) {
continue;
}
}
if (prevStr) {
w.write(' ');
}
prevStr = true;
}
w.write("\n");
prevStr = false;
}
}
}
}
}
if (ch instanceof LexicalHandler) {
} else {
}
}
int vpos = 0;
for (int i = 0; i < len; i++) {
if (canUseCData) {
assert (vpos == 0);
writeCData(val, w);
return;
} else {
if (vpos < i) {
}
switch (ch) {
case '&':
esc = "&";
break;
case '<':
esc = "<";
break;
case '\'':
esc = "'";
break;
case '"':
esc = """;
break;
case '>':
esc = ">";
break;
default:
break;
}
}
}
}
// write the unquoted tail
}
if (split < 0) {
return;
}
}
}
return null;
}
}
/** If str is null, empty, or blank, returns null.
* Otherwise, return a Double if str spells a double value and contains '.' or 'e'.
* Otherwise, return an Integer if str spells an int value.
* Otherwise, return a Long if str spells a long value.
* Otherwise, return a BigInteger for the string.
* Otherwise, throw NumberFormatException.
*/
return null;
}
return null;
}
}
try {
// Narrow to Integer, if possible.
}
} catch (NumberFormatException ee) {
// Could not represent it as a long.
}
}
}
}
}
}
}
// Testing:
//new org.jdom.input.SAXBuilder().build(file).getRootElement();
//Document build(InputSource in) throws JDOMException
int reps = 0;
boolean tokenizing = false;
boolean makeFrozen = false;
tokenizing = true;
try {
} catch (NumberFormatException ee) {
}
}
if (reps > 1) {
char[] cbuf = new char[1024];
}
}
long tm0 = 0;
int warmup = 10;
for (int i = 1; i < reps; i++) {
if (i == warmup) {
}
}
if (tm0 != 0) {
}
}
e = e.deepCopy();
}
e2.shallowFreeze();
}
if (false) {
} else {
}
{
}
{
}
{
}
{
//System.out.println(ru);
}
}
static boolean isWhitespace(char c) {
switch (c) {
case 0x20:
case 0x09:
case 0x0D:
case 0x0A:
return true;
}
return false;
}
}