Imported Classpath 0.18.
* sources.am, Makefile.in: Updated. * Makefile.am (nat_source_files): Removed natProxy.cc. * java/lang/reflect/natProxy.cc: Removed. * gnu/classpath/jdwp/VMFrame.java, gnu/classpath/jdwp/VMIdManager.java, gnu/classpath/jdwp/VMVirtualMachine.java, java/lang/reflect/VMProxy.java: New files. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * scripts/makemake.tcl (verbose): Add gnu/java/awt/peer/qt to BC list. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * gnu/java/net/DefaultContentHandlerFactory.java (getContent): Remove ClasspathToolkit references. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * gnu/awt/xlib/XCanvasPeer.java: Add new peer methods. * gnu/awt/xlib/XFramePeer.java: Likewise. * gnu/awt/xlib/XGraphicsConfiguration.java: Likewise. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * Makefile.am (libgcjawt_la_SOURCES): Remove jawt.c. Add classpath/native/jawt/jawt.c. * Makefile.in: Regenerate. * jawt.c: Remove file. * include/Makefile.am (tool_include__HEADERS): Remove jawt.h and jawt_md.h. Add ../classpath/include/jawt.h and ../classpath/include/jawt_md.h. * include/Makefile.in: Regenerate. * include/jawt.h: Regenerate. * include/jawt_md.h: Regenerate. From-SVN: r104586
This commit is contained in:
parent
9b044d1951
commit
1ea63ef8be
544 changed files with 34724 additions and 14512 deletions
|
@ -58,7 +58,7 @@ import java.util.Set;
|
|||
public interface AttributedCharacterIterator extends CharacterIterator
|
||||
{
|
||||
/**
|
||||
* This class defines attribute keys that are used as text attributes.
|
||||
* Defines attribute keys that are used as text attributes.
|
||||
*/
|
||||
public static class Attribute implements Serializable
|
||||
{
|
||||
|
@ -74,7 +74,8 @@ public interface AttributedCharacterIterator extends CharacterIterator
|
|||
* This is the attribute for the reading form of text. This is used
|
||||
* for storing pronunciation along with the written text for languages
|
||||
* which need it. The value of attributes of this key type are
|
||||
* instances of <code>Annotation</code> which wrappers a <code>String</code>.
|
||||
* instances of <code>Annotation</code> which wrappers a
|
||||
* <code>String</code>.
|
||||
*/
|
||||
public static final Attribute READING = new Attribute ("READING");
|
||||
|
||||
|
@ -87,14 +88,13 @@ public interface AttributedCharacterIterator extends CharacterIterator
|
|||
new Attribute ("INPUT_METHOD_SEGMENT");
|
||||
|
||||
/**
|
||||
* This is the name of the attribute key
|
||||
* The name of the attribute key
|
||||
* @serial
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* This method initializes a new instance of this class with the specified
|
||||
* name.
|
||||
* Initializes a new instance of this class with the specified name.
|
||||
*
|
||||
* @param name The name of this attribute key.
|
||||
*/
|
||||
|
@ -104,7 +104,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
|
|||
}
|
||||
|
||||
/**
|
||||
* This method returns the name of this attribute.
|
||||
* Returns the name of this attribute.
|
||||
*
|
||||
* @return The attribute name
|
||||
*/
|
||||
|
@ -114,14 +114,16 @@ public interface AttributedCharacterIterator extends CharacterIterator
|
|||
}
|
||||
|
||||
/**
|
||||
* This method resolves an instance of <code>AttributedCharacterIterator.Attribute</code>
|
||||
* Resolves an instance of
|
||||
* <code>AttributedCharacterIterator.Attribute</code>
|
||||
* that is being deserialized to one of the three pre-defined attribute
|
||||
* constants. It does this by comparing the names of the attributes. The
|
||||
* constant that the deserialized object resolves to is returned.
|
||||
*
|
||||
* @return The resolved contant value
|
||||
*
|
||||
* @exception InvalidObjectException If the object being deserialized cannot be resolved.
|
||||
* @exception InvalidObjectException If the object being deserialized
|
||||
* cannot be resolved.
|
||||
*/
|
||||
protected Object readResolve() throws InvalidObjectException
|
||||
{
|
||||
|
@ -134,21 +136,25 @@ public interface AttributedCharacterIterator extends CharacterIterator
|
|||
if (this.equals (INPUT_METHOD_SEGMENT))
|
||||
return INPUT_METHOD_SEGMENT;
|
||||
|
||||
throw new InvalidObjectException ("Can't resolve Attribute: " + getName());
|
||||
throw new InvalidObjectException ("Can't resolve Attribute: "
|
||||
+ getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method tests this object for equality against the specified object.
|
||||
* Tests this object for equality against the specified object.
|
||||
* The two objects will be considered equal if and only if:
|
||||
* <ul>
|
||||
* <li>The specified object is not <code>null</code>.
|
||||
* <li>The specified object is an instance of <code>AttributedCharacterIterator.Attribute</code>.
|
||||
* <li>The specified object is an instance of
|
||||
* <code>AttributedCharacterIterator.Attribute</code>.
|
||||
* <li>The specified object has the same attribute name as this object.
|
||||
* </ul>
|
||||
*
|
||||
* @param The <code>Object</code> to test for equality against this object.
|
||||
* @param obj the <code>Object</code> to test for equality against this
|
||||
* object.
|
||||
*
|
||||
* @return <code>true</code> if the specified object is equal to this one, <code>false</code> otherwise.
|
||||
* @return <code>true</code> if the specified object is equal to this one,
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public final boolean equals (Object obj)
|
||||
{
|
||||
|
@ -159,7 +165,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
|
|||
}
|
||||
|
||||
/**
|
||||
* This method returns a hash value for this object.
|
||||
* Returns a hash value for this object.
|
||||
*
|
||||
* @return A hash value for this object.
|
||||
*/
|
||||
|
@ -169,7 +175,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
|
|||
}
|
||||
|
||||
/**
|
||||
* This method returns a <code>String</code> representation of this object.
|
||||
* Returns a <code>String</code> representation of this object.
|
||||
*
|
||||
* @return A <code>String</code> representation of this object.
|
||||
*/
|
||||
|
@ -181,7 +187,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
|
|||
} // Inner class Attribute
|
||||
|
||||
/**
|
||||
* This method returns a list of all keys that are defined for the
|
||||
* Returns a list of all keys that are defined for the
|
||||
* text range. This can be an empty list if no attributes are defined.
|
||||
*
|
||||
* @return A list of keys
|
||||
|
@ -189,15 +195,15 @@ public interface AttributedCharacterIterator extends CharacterIterator
|
|||
Set getAllAttributeKeys();
|
||||
|
||||
/**
|
||||
* This method returns a <code>Map</code> of the attributed defined for
|
||||
* the current character.
|
||||
* Returns a <code>Map</code> of the attributes defined for the current
|
||||
* character.
|
||||
*
|
||||
* @return A <code>Map</code> of the attributes for the current character.
|
||||
*/
|
||||
Map getAttributes();
|
||||
|
||||
/**
|
||||
* This method returns the value of the specified attribute for the
|
||||
* Returns the value of the specified attribute for the
|
||||
* current character. If the attribute is not defined for the current
|
||||
* character, <code>null</code> is returned.
|
||||
*
|
||||
|
@ -208,7 +214,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
|
|||
Object getAttribute (AttributedCharacterIterator.Attribute attrib);
|
||||
|
||||
/**
|
||||
* This method returns the index of the first character in the run that
|
||||
* Returns the index of the first character in the run that
|
||||
* contains all attributes defined for the current character.
|
||||
*
|
||||
* @return The start index of the run
|
||||
|
@ -216,7 +222,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
|
|||
int getRunStart();
|
||||
|
||||
/**
|
||||
* This method returns the index of the first character in the run that
|
||||
* Returns the index of the first character in the run that
|
||||
* contains all attributes in the specified <code>Set</code> defined for
|
||||
* the current character.
|
||||
*
|
||||
|
@ -227,7 +233,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
|
|||
int getRunStart (Set attribs);
|
||||
|
||||
/**
|
||||
* This method returns the index of the first character in the run that
|
||||
* Returns the index of the first character in the run that
|
||||
* contains the specified attribute defined for the current character.
|
||||
*
|
||||
* @param attrib The attribute.
|
||||
|
@ -237,15 +243,15 @@ public interface AttributedCharacterIterator extends CharacterIterator
|
|||
int getRunStart (AttributedCharacterIterator.Attribute attrib);
|
||||
|
||||
/**
|
||||
* This method returns the index of the character after the end of the run
|
||||
* that contains all attributed defined for the current character.
|
||||
* Returns the index of the character after the end of the run
|
||||
* that contains all attributes defined for the current character.
|
||||
*
|
||||
* @return The end index of the run.
|
||||
*/
|
||||
int getRunLimit();
|
||||
|
||||
/**
|
||||
* This method returns the index of the character after the end of the run
|
||||
* Returns the index of the character after the end of the run
|
||||
* that contains all attributes in the specified <code>Set</code> defined
|
||||
* for the current character.
|
||||
*
|
||||
|
@ -256,7 +262,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
|
|||
int getRunLimit (Set attribs);
|
||||
|
||||
/**
|
||||
* This methods returns the index of the character after the end of the run
|
||||
* Returns the index of the character after the end of the run
|
||||
* that contains the specified attribute defined for the current character.
|
||||
*
|
||||
* @param attrib The attribute.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* AttributedString.java -- Models text with attributes
|
||||
Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999, 2004, 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -47,379 +47,326 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* This class models a <code>String</code> with attributes over various
|
||||
* subranges of the string. It allows applications to access this
|
||||
* information via the <code>AttributedCharcterIterator</code> interface.
|
||||
*
|
||||
* @version 0.0
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
* This class models a <code>String</code> with attributes over various
|
||||
* subranges of the string. It allows applications to access this
|
||||
* information via the <code>AttributedCharcterIterator</code> interface.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
public class AttributedString
|
||||
{
|
||||
|
||||
/*************************************************************************/
|
||||
/**
|
||||
* The attributes and ranges of text over which those attributes apply.
|
||||
*/
|
||||
final class AttributeRange
|
||||
{
|
||||
|
||||
/*
|
||||
* Inner Classes
|
||||
*/
|
||||
/** A Map of the attributes */
|
||||
Map attribs;
|
||||
|
||||
/**
|
||||
* This class contains the attributes and ranges of text over which
|
||||
* that attributes apply.
|
||||
*/
|
||||
final class AttributeRange
|
||||
{
|
||||
/** The beginning index of the attributes */
|
||||
int begin_index;
|
||||
|
||||
/*
|
||||
* Instance Variables
|
||||
*/
|
||||
/** The ending index of the attributes */
|
||||
int end_index;
|
||||
|
||||
/**
|
||||
* A Map of the attributes
|
||||
*/
|
||||
Map attribs;
|
||||
|
||||
/**
|
||||
* The beginning index of the attributes
|
||||
*/
|
||||
int begin_index;
|
||||
|
||||
/**
|
||||
* The ending index of the attributes
|
||||
*/
|
||||
int end_index;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Constructors
|
||||
*/
|
||||
|
||||
AttributeRange(Map attribs, int begin_index, int end_index)
|
||||
{
|
||||
this.attribs = attribs;
|
||||
this.begin_index = begin_index;
|
||||
this.end_index = end_index;
|
||||
}
|
||||
|
||||
} // Inner class AttributeRange
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Instance Variables
|
||||
*/
|
||||
|
||||
/**
|
||||
* This object holds the string we are representing.
|
||||
*/
|
||||
private StringCharacterIterator sci;
|
||||
|
||||
/**
|
||||
* This is the attribute information
|
||||
*/
|
||||
private AttributeRange[] attribs;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Constructors
|
||||
*/
|
||||
|
||||
/**
|
||||
* This method initializes a new instance of <code>AttributedString</code>
|
||||
* that represents the specified <code>String</code> with no attributes.
|
||||
*
|
||||
* @param str The <code>String</code> to be attributed.
|
||||
*/
|
||||
public
|
||||
AttributedString(String str)
|
||||
{
|
||||
sci = new StringCharacterIterator(str);
|
||||
attribs = new AttributeRange[0];
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method initializes a new instance of <code>AttributedString</code>
|
||||
* that represents that specified <code>String</code> with the specified
|
||||
* attributes over the entire length of the <code>String</code>.
|
||||
*
|
||||
* @param str The <code>String</code> to be attributed.
|
||||
* @param attributes The attribute list.
|
||||
*/
|
||||
public
|
||||
AttributedString(String str, Map attributes)
|
||||
{
|
||||
this(str);
|
||||
|
||||
attribs = new AttributeRange[1];
|
||||
attribs[0] = new AttributeRange(attributes, 0, str.length());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method initializes a new instance of <code>AttributedString</code>
|
||||
* that will use the text and attribute information from the specified
|
||||
* <code>AttributedCharacterIterator</code>.
|
||||
*
|
||||
* @param aci The <code>AttributedCharacterIterator</code> containing the text and attribute information.
|
||||
*/
|
||||
public
|
||||
AttributedString(AttributedCharacterIterator aci)
|
||||
{
|
||||
this(aci, aci.getBeginIndex(), aci.getEndIndex(), null);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method initializes a new instance of <code>AttributedString</code>
|
||||
* that will use the text and attribute information from the specified
|
||||
* subrange of the specified <code>AttributedCharacterIterator</code>.
|
||||
*
|
||||
* @param aci The <code>AttributedCharacterIterator</code> containing the text and attribute information.
|
||||
* @param begin_index The beginning index of the text subrange.
|
||||
* @param end_index The ending index of the text subrange.
|
||||
*/
|
||||
public
|
||||
AttributedString(AttributedCharacterIterator aci, int begin_index,
|
||||
int end_index)
|
||||
{
|
||||
this(aci, begin_index, end_index, null);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method initializes a new instance of <code>AttributedString</code>
|
||||
* that will use the text and attribute information from the specified
|
||||
* subrange of the specified <code>AttributedCharacterIterator</code>.
|
||||
* Only attributes from the source iterator that are present in the
|
||||
* specified array of attributes will be included in the attribute list
|
||||
* for this object.
|
||||
*
|
||||
* @param aci The <code>AttributedCharacterIterator</code> containing the text and attribute information.
|
||||
* @param begin_index The beginning index of the text subrange.
|
||||
* @param end_index The ending index of the text subrange.
|
||||
* @param attributes A list of attributes to include from the iterator, or <code>null</code> to include all attributes.
|
||||
*/
|
||||
public
|
||||
AttributedString(AttributedCharacterIterator aci, int begin_index,
|
||||
int end_index, AttributedCharacterIterator.Attribute[] attributes)
|
||||
{
|
||||
// Validate some arguments
|
||||
if ((begin_index < 0) || (end_index < begin_index))
|
||||
throw new IllegalArgumentException("Bad index values");
|
||||
|
||||
StringBuffer sb = new StringBuffer("");
|
||||
|
||||
// Get the valid attribute list
|
||||
Set all_attribs = aci.getAllAttributeKeys();
|
||||
if (attributes != null)
|
||||
all_attribs.retainAll(Arrays.asList(attributes));
|
||||
|
||||
// Loop through and extract the attributes
|
||||
char c = aci.setIndex(begin_index);
|
||||
|
||||
ArrayList accum = new ArrayList();
|
||||
do
|
||||
{
|
||||
sb.append(c);
|
||||
|
||||
Iterator iter = all_attribs.iterator();
|
||||
while(iter.hasNext())
|
||||
{
|
||||
Object obj = iter.next();
|
||||
|
||||
// What should we do if this is not true?
|
||||
if (!(obj instanceof AttributedCharacterIterator.Attribute))
|
||||
continue;
|
||||
|
||||
AttributedCharacterIterator.Attribute attrib =
|
||||
(AttributedCharacterIterator.Attribute)obj;
|
||||
|
||||
// Make sure the attribute is defined.
|
||||
int rl = aci.getRunLimit(attrib);
|
||||
if (rl == -1)
|
||||
continue;
|
||||
if (rl > end_index)
|
||||
rl = end_index;
|
||||
rl -= begin_index;
|
||||
|
||||
// Check to see if we already processed this one
|
||||
int rs = aci.getRunStart(attrib);
|
||||
if ((rs < aci.getIndex()) && (aci.getIndex() != begin_index))
|
||||
continue;
|
||||
|
||||
// If the attribute run starts before the beginning index, we
|
||||
// need to junk it if it is an Annotation.
|
||||
Object attrib_obj = aci.getAttribute(attrib);
|
||||
if (rs < begin_index)
|
||||
{
|
||||
if (attrib_obj instanceof Annotation)
|
||||
continue;
|
||||
|
||||
rs = begin_index;
|
||||
}
|
||||
else
|
||||
{
|
||||
rs -= begin_index;
|
||||
}
|
||||
|
||||
// Create a map object. Yes this will only contain one attribute
|
||||
Map new_map = new Hashtable();
|
||||
new_map.put(attrib, attrib_obj);
|
||||
|
||||
// Add it to the attribute list.
|
||||
accum.add(new AttributeRange(new_map, rs, rl));
|
||||
}
|
||||
|
||||
c = aci.next();
|
||||
/**
|
||||
* Creates a new attribute range.
|
||||
*
|
||||
* @param attribs the attributes.
|
||||
* @param begin_index the start index.
|
||||
* @param end_index the end index.
|
||||
*/
|
||||
AttributeRange(Map attribs, int begin_index, int end_index)
|
||||
{
|
||||
this.attribs = attribs;
|
||||
this.begin_index = begin_index;
|
||||
this.end_index = end_index;
|
||||
}
|
||||
while(c != CharacterIterator.DONE);
|
||||
|
||||
attribs = new AttributeRange[accum.size()];
|
||||
attribs = (AttributeRange[]) accum.toArray(attribs);
|
||||
} // Inner class AttributeRange
|
||||
|
||||
sci = new StringCharacterIterator(sb.toString());
|
||||
}
|
||||
/** The string we are representing. */
|
||||
private StringCharacterIterator sci;
|
||||
|
||||
/*************************************************************************/
|
||||
/** The attribute information */
|
||||
private AttributeRange[] attribs;
|
||||
|
||||
/*
|
||||
* Instance Methods
|
||||
*/
|
||||
/**
|
||||
* Creates a new instance of <code>AttributedString</code>
|
||||
* that represents the specified <code>String</code> with no attributes.
|
||||
*
|
||||
* @param str The <code>String</code> to be attributed (<code>null</code> not
|
||||
* permitted).
|
||||
*
|
||||
* @throws NullPointerException if <code>str</code> is <code>null</code>.
|
||||
*/
|
||||
public AttributedString(String str)
|
||||
{
|
||||
sci = new StringCharacterIterator(str);
|
||||
attribs = new AttributeRange[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds a new attribute that will cover the entire string.
|
||||
*
|
||||
* @param attrib The attribute to add.
|
||||
* @param value The value of the attribute.
|
||||
*/
|
||||
public void
|
||||
addAttribute(AttributedCharacterIterator.Attribute attrib, Object value)
|
||||
{
|
||||
addAttribute(attrib, value, 0, sci.getEndIndex());
|
||||
}
|
||||
/**
|
||||
* Creates a new instance of <code>AttributedString</code>
|
||||
* that represents that specified <code>String</code> with the specified
|
||||
* attributes over the entire length of the <code>String</code>.
|
||||
*
|
||||
* @param str The <code>String</code> to be attributed.
|
||||
* @param attributes The attribute list.
|
||||
*/
|
||||
public AttributedString(String str, Map attributes)
|
||||
{
|
||||
this(str);
|
||||
|
||||
/*************************************************************************/
|
||||
attribs = new AttributeRange[1];
|
||||
attribs[0] = new AttributeRange(attributes, 0, str.length());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds a new attribute that will cover the specified subrange
|
||||
* of the string.
|
||||
*
|
||||
* @param attrib The attribute to add.
|
||||
* @param value The value of the attribute, which may be null.
|
||||
* @param begin_index The beginning index of the subrange.
|
||||
* @param end_index The ending index of the subrange.
|
||||
*
|
||||
* @exception IllegalArgumentException If attribute is <code>null</code> or the subrange is not valid.
|
||||
*/
|
||||
public void
|
||||
addAttribute(AttributedCharacterIterator.Attribute attrib, Object value,
|
||||
int begin_index, int end_index)
|
||||
{
|
||||
if (attrib == null)
|
||||
throw new IllegalArgumentException("null attribute");
|
||||
/**
|
||||
* Initializes a new instance of <code>AttributedString</code>
|
||||
* that will use the text and attribute information from the specified
|
||||
* <code>AttributedCharacterIterator</code>.
|
||||
*
|
||||
* @param aci The <code>AttributedCharacterIterator</code> containing the
|
||||
* text and attribute information (<code>null</code> not
|
||||
* permitted).
|
||||
*
|
||||
* @throws NullPointerException if <code>aci</code> is <code>null</code>.
|
||||
*/
|
||||
public AttributedString(AttributedCharacterIterator aci)
|
||||
{
|
||||
this(aci, aci.getBeginIndex(), aci.getEndIndex(), null);
|
||||
}
|
||||
|
||||
HashMap hm = new HashMap();
|
||||
hm.put(attrib, value);
|
||||
/**
|
||||
* Initializes a new instance of <code>AttributedString</code>
|
||||
* that will use the text and attribute information from the specified
|
||||
* subrange of the specified <code>AttributedCharacterIterator</code>.
|
||||
*
|
||||
* @param aci The <code>AttributedCharacterIterator</code> containing the
|
||||
* text and attribute information.
|
||||
* @param begin_index The beginning index of the text subrange.
|
||||
* @param end_index The ending index of the text subrange.
|
||||
*/
|
||||
public AttributedString(AttributedCharacterIterator aci, int begin_index,
|
||||
int end_index)
|
||||
{
|
||||
this(aci, begin_index, end_index, null);
|
||||
}
|
||||
|
||||
addAttributes(hm, begin_index, end_index);
|
||||
}
|
||||
/**
|
||||
* Initializes a new instance of <code>AttributedString</code>
|
||||
* that will use the text and attribute information from the specified
|
||||
* subrange of the specified <code>AttributedCharacterIterator</code>.
|
||||
* Only attributes from the source iterator that are present in the
|
||||
* specified array of attributes will be included in the attribute list
|
||||
* for this object.
|
||||
*
|
||||
* @param aci The <code>AttributedCharacterIterator</code> containing the
|
||||
* text and attribute information.
|
||||
* @param begin_index The beginning index of the text subrange.
|
||||
* @param end_index The ending index of the text subrange.
|
||||
* @param attributes A list of attributes to include from the iterator, or
|
||||
* <code>null</code> to include all attributes.
|
||||
*/
|
||||
public AttributedString(AttributedCharacterIterator aci, int begin_index,
|
||||
int end_index, AttributedCharacterIterator.Attribute[] attributes)
|
||||
{
|
||||
// Validate some arguments
|
||||
if ((begin_index < 0) || (end_index < begin_index))
|
||||
throw new IllegalArgumentException("Bad index values");
|
||||
|
||||
/*************************************************************************/
|
||||
StringBuffer sb = new StringBuffer("");
|
||||
|
||||
/**
|
||||
* This method adds all of the attributes in the specified list to the
|
||||
* specified subrange of the string.
|
||||
*
|
||||
* @param attributes The list of attributes.
|
||||
* @param begin_index The beginning index.
|
||||
* @param end_index The ending index
|
||||
*
|
||||
* @param IllegalArgumentException If the list is <code>null</code> or the subrange is not valid.
|
||||
*/
|
||||
public void
|
||||
addAttributes(Map attributes, int begin_index, int end_index)
|
||||
{
|
||||
if (attributes == null)
|
||||
throw new IllegalArgumentException("null attribute");
|
||||
// Get the valid attribute list
|
||||
Set all_attribs = aci.getAllAttributeKeys();
|
||||
if (attributes != null)
|
||||
all_attribs.retainAll(Arrays.asList(attributes));
|
||||
|
||||
if ((begin_index < 0) || (end_index > sci.getEndIndex()) ||
|
||||
(end_index < begin_index))
|
||||
throw new IllegalArgumentException("bad range");
|
||||
// Loop through and extract the attributes
|
||||
char c = aci.setIndex(begin_index);
|
||||
|
||||
AttributeRange[] new_list = new AttributeRange[attribs.length + 1];
|
||||
System.arraycopy(attribs, 0, new_list, 0, attribs.length);
|
||||
attribs = new_list;
|
||||
attribs[attribs.length - 1] = new AttributeRange(attributes, begin_index,
|
||||
end_index);
|
||||
}
|
||||
ArrayList accum = new ArrayList();
|
||||
do
|
||||
{
|
||||
sb.append(c);
|
||||
|
||||
/*************************************************************************/
|
||||
Iterator iter = all_attribs.iterator();
|
||||
while(iter.hasNext())
|
||||
{
|
||||
Object obj = iter.next();
|
||||
|
||||
/**
|
||||
* This method returns an <code>AttributedCharacterIterator</code> that
|
||||
* will iterate over the entire string.
|
||||
*
|
||||
* @return An <code>AttributedCharacterIterator</code> for the entire string.
|
||||
*/
|
||||
public AttributedCharacterIterator
|
||||
getIterator()
|
||||
{
|
||||
return(new AttributedStringIterator(sci, attribs, 0, sci.getEndIndex(), null));
|
||||
}
|
||||
// What should we do if this is not true?
|
||||
if (!(obj instanceof AttributedCharacterIterator.Attribute))
|
||||
continue;
|
||||
|
||||
/*************************************************************************/
|
||||
AttributedCharacterIterator.Attribute attrib =
|
||||
(AttributedCharacterIterator.Attribute)obj;
|
||||
|
||||
/**
|
||||
* This method returns an <code>AttributedCharacterIterator</code> that
|
||||
* will iterate over the entire string. This iterator will return information
|
||||
* about the list of attributes in the specified array. Attributes not in
|
||||
* the array may or may not be returned by the iterator. If the specified
|
||||
* array is <code>null</code>, all attributes will be returned.
|
||||
*
|
||||
* @param attributes A list of attributes to include in the returned iterator.
|
||||
*
|
||||
* @return An <code>AttributedCharacterIterator</code> for this string.
|
||||
*/
|
||||
public AttributedCharacterIterator
|
||||
getIterator(AttributedCharacterIterator.Attribute[] attributes)
|
||||
{
|
||||
return(getIterator(attributes, 0, sci.getEndIndex()));
|
||||
}
|
||||
// Make sure the attribute is defined.
|
||||
int rl = aci.getRunLimit(attrib);
|
||||
if (rl == -1)
|
||||
continue;
|
||||
if (rl > end_index)
|
||||
rl = end_index;
|
||||
rl -= begin_index;
|
||||
|
||||
/*************************************************************************/
|
||||
// Check to see if we already processed this one
|
||||
int rs = aci.getRunStart(attrib);
|
||||
if ((rs < aci.getIndex()) && (aci.getIndex() != begin_index))
|
||||
continue;
|
||||
|
||||
/**
|
||||
* This method returns an <code>AttributedCharacterIterator</code> that
|
||||
* will iterate over the specified subrange. This iterator will return information
|
||||
* about the list of attributes in the specified array. Attributes not in
|
||||
* the array may or may not be returned by the iterator. If the specified
|
||||
* array is <code>null</code>, all attributes will be returned.
|
||||
*
|
||||
* @param attributes A list of attributes to include in the returned iterator.
|
||||
* @param begin_index The beginning index of the subrange.
|
||||
* @param end_index The ending index of the subrange.
|
||||
*
|
||||
* @return An <code>AttributedCharacterIterator</code> for this string.
|
||||
*/
|
||||
public AttributedCharacterIterator
|
||||
getIterator(AttributedCharacterIterator.Attribute[] attributes,
|
||||
int begin_index, int end_index)
|
||||
{
|
||||
if ((begin_index < 0) || (end_index > sci.getEndIndex()) ||
|
||||
(end_index < begin_index))
|
||||
throw new IllegalArgumentException("bad range");
|
||||
// If the attribute run starts before the beginning index, we
|
||||
// need to junk it if it is an Annotation.
|
||||
Object attrib_obj = aci.getAttribute(attrib);
|
||||
if (rs < begin_index)
|
||||
{
|
||||
if (attrib_obj instanceof Annotation)
|
||||
continue;
|
||||
|
||||
return(new AttributedStringIterator(sci, attribs, begin_index, end_index,
|
||||
attributes));
|
||||
}
|
||||
rs = begin_index;
|
||||
}
|
||||
else
|
||||
{
|
||||
rs -= begin_index;
|
||||
}
|
||||
|
||||
// Create a map object. Yes this will only contain one attribute
|
||||
Map new_map = new Hashtable();
|
||||
new_map.put(attrib, attrib_obj);
|
||||
|
||||
// Add it to the attribute list.
|
||||
accum.add(new AttributeRange(new_map, rs, rl));
|
||||
}
|
||||
|
||||
c = aci.next();
|
||||
}
|
||||
while(c != CharacterIterator.DONE);
|
||||
|
||||
attribs = new AttributeRange[accum.size()];
|
||||
attribs = (AttributeRange[]) accum.toArray(attribs);
|
||||
|
||||
sci = new StringCharacterIterator(sb.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new attribute that will cover the entire string.
|
||||
*
|
||||
* @param attrib The attribute to add.
|
||||
* @param value The value of the attribute.
|
||||
*/
|
||||
public void addAttribute(AttributedCharacterIterator.Attribute attrib,
|
||||
Object value)
|
||||
{
|
||||
addAttribute(attrib, value, 0, sci.getEndIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new attribute that will cover the specified subrange
|
||||
* of the string.
|
||||
*
|
||||
* @param attrib The attribute to add.
|
||||
* @param value The value of the attribute, which may be <code>null</code>.
|
||||
* @param begin_index The beginning index of the subrange.
|
||||
* @param end_index The ending index of the subrange.
|
||||
*
|
||||
* @exception IllegalArgumentException If attribute is <code>null</code> or
|
||||
* the subrange is not valid.
|
||||
*/
|
||||
public void addAttribute(AttributedCharacterIterator.Attribute attrib,
|
||||
Object value, int begin_index, int end_index)
|
||||
{
|
||||
if (attrib == null)
|
||||
throw new IllegalArgumentException("null attribute");
|
||||
|
||||
HashMap hm = new HashMap();
|
||||
hm.put(attrib, value);
|
||||
|
||||
addAttributes(hm, begin_index, end_index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all of the attributes in the specified list to the
|
||||
* specified subrange of the string.
|
||||
*
|
||||
* @param attributes The list of attributes.
|
||||
* @param begin_index The beginning index.
|
||||
* @param end_index The ending index
|
||||
*
|
||||
* @throws IllegalArgumentException If the list is <code>null</code> or the
|
||||
* subrange is not valid.
|
||||
*/
|
||||
public void addAttributes(Map attributes, int begin_index, int end_index)
|
||||
{
|
||||
if (attributes == null)
|
||||
throw new IllegalArgumentException("null attribute");
|
||||
|
||||
if ((begin_index < 0) || (end_index > sci.getEndIndex()) ||
|
||||
(end_index < begin_index))
|
||||
throw new IllegalArgumentException("bad range");
|
||||
|
||||
AttributeRange[] new_list = new AttributeRange[attribs.length + 1];
|
||||
System.arraycopy(attribs, 0, new_list, 0, attribs.length);
|
||||
attribs = new_list;
|
||||
attribs[attribs.length - 1] = new AttributeRange(attributes, begin_index,
|
||||
end_index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an <code>AttributedCharacterIterator</code> that
|
||||
* will iterate over the entire string.
|
||||
*
|
||||
* @return An <code>AttributedCharacterIterator</code> for the entire string.
|
||||
*/
|
||||
public AttributedCharacterIterator getIterator()
|
||||
{
|
||||
return(new AttributedStringIterator(sci, attribs, 0, sci.getEndIndex(),
|
||||
null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an <code>AttributedCharacterIterator</code> that
|
||||
* will iterate over the entire string. This iterator will return information
|
||||
* about the list of attributes in the specified array. Attributes not in
|
||||
* the array may or may not be returned by the iterator. If the specified
|
||||
* array is <code>null</code>, all attributes will be returned.
|
||||
*
|
||||
* @param attributes A list of attributes to include in the returned iterator.
|
||||
*
|
||||
* @return An <code>AttributedCharacterIterator</code> for this string.
|
||||
*/
|
||||
public AttributedCharacterIterator getIterator(
|
||||
AttributedCharacterIterator.Attribute[] attributes)
|
||||
{
|
||||
return(getIterator(attributes, 0, sci.getEndIndex()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an <code>AttributedCharacterIterator</code> that
|
||||
* will iterate over the specified subrange. This iterator will return
|
||||
* information about the list of attributes in the specified array.
|
||||
* Attributes not in the array may or may not be returned by the iterator.
|
||||
* If the specified array is <code>null</code>, all attributes will be
|
||||
* returned.
|
||||
*
|
||||
* @param attributes A list of attributes to include in the returned iterator.
|
||||
* @param begin_index The beginning index of the subrange.
|
||||
* @param end_index The ending index of the subrange.
|
||||
*
|
||||
* @return An <code>AttributedCharacterIterator</code> for this string.
|
||||
*/
|
||||
public AttributedCharacterIterator getIterator(
|
||||
AttributedCharacterIterator.Attribute[] attributes,
|
||||
int begin_index, int end_index)
|
||||
{
|
||||
if ((begin_index < 0) || (end_index > sci.getEndIndex()) ||
|
||||
(end_index < begin_index))
|
||||
throw new IllegalArgumentException("bad range");
|
||||
|
||||
return(new AttributedStringIterator(sci, attribs, begin_index, end_index,
|
||||
attributes));
|
||||
}
|
||||
|
||||
} // class AttributedString
|
||||
|
||||
|
|
|
@ -55,129 +55,102 @@ import java.util.Set;
|
|||
class AttributedStringIterator implements AttributedCharacterIterator
|
||||
{
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Instance Variables
|
||||
*/
|
||||
/** The character iterator containing the text */
|
||||
private CharacterIterator ci;
|
||||
|
||||
/**
|
||||
* The character iterator containing the text
|
||||
*/
|
||||
private CharacterIterator ci;
|
||||
/** The list of attributes and ranges */
|
||||
private AttributedString.AttributeRange[] attribs;
|
||||
|
||||
/**
|
||||
* The list of attributes and ranges
|
||||
*/
|
||||
private AttributedString.AttributeRange[] attribs;
|
||||
/**
|
||||
* The list of attributes that the user is interested in. We may,
|
||||
* at our option, not return any other attributes.
|
||||
*/
|
||||
private AttributedCharacterIterator.Attribute[] restricts;
|
||||
|
||||
/**
|
||||
* The list of attributes that the user is interested in. We may,
|
||||
* at our option, not return any other attributes.
|
||||
*/
|
||||
private AttributedCharacterIterator.Attribute[] restricts;
|
||||
/*************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
AttributedStringIterator(StringCharacterIterator sci,
|
||||
AttributedString.AttributeRange[] attribs,
|
||||
int begin_index, int end_index,
|
||||
AttributedCharacterIterator.Attribute[] restricts)
|
||||
{
|
||||
this.ci = new StringCharacterIterator(sci, begin_index, end_index);
|
||||
this.attribs = attribs;
|
||||
this.restricts = restricts;
|
||||
}
|
||||
|
||||
/*
|
||||
* Constructors
|
||||
*/
|
||||
/*************************************************************************/
|
||||
|
||||
AttributedStringIterator(StringCharacterIterator sci,
|
||||
AttributedString.AttributeRange[] attribs,
|
||||
int begin_index, int end_index,
|
||||
AttributedCharacterIterator.Attribute[] restricts)
|
||||
{
|
||||
this.ci = new StringCharacterIterator(sci, begin_index, end_index);
|
||||
this.attribs = attribs;
|
||||
this.restricts = restricts;
|
||||
}
|
||||
// First we have a bunch of stupid redirects. If StringCharacterIterator
|
||||
// weren't final, I just would have extended that for this class. Alas, no.
|
||||
|
||||
/*************************************************************************/
|
||||
public Object clone()
|
||||
{
|
||||
return(ci.clone());
|
||||
}
|
||||
|
||||
/*
|
||||
* Instance Methods
|
||||
*/
|
||||
public char current()
|
||||
{
|
||||
return(ci.current());
|
||||
}
|
||||
|
||||
// First we have a bunch of stupid redirects. If StringCharacterIterator
|
||||
// weren't final, I just would have extended that for this class. Alas, no.
|
||||
public char next()
|
||||
{
|
||||
return(ci.next());
|
||||
}
|
||||
|
||||
public Object
|
||||
clone()
|
||||
{
|
||||
return(ci.clone());
|
||||
}
|
||||
public char previous()
|
||||
{
|
||||
return(ci.previous());
|
||||
}
|
||||
|
||||
public char
|
||||
current()
|
||||
{
|
||||
return(ci.current());
|
||||
}
|
||||
public char first()
|
||||
{
|
||||
return(ci.first());
|
||||
}
|
||||
|
||||
public char
|
||||
next()
|
||||
{
|
||||
return(ci.next());
|
||||
}
|
||||
public char last()
|
||||
{
|
||||
return(ci.last());
|
||||
}
|
||||
|
||||
public char
|
||||
previous()
|
||||
{
|
||||
return(ci.previous());
|
||||
}
|
||||
public int getIndex()
|
||||
{
|
||||
return(ci.getIndex());
|
||||
}
|
||||
|
||||
public char
|
||||
first()
|
||||
{
|
||||
return(ci.first());
|
||||
}
|
||||
public char setIndex(int index)
|
||||
{
|
||||
return(ci.setIndex(index));
|
||||
}
|
||||
|
||||
public char
|
||||
last()
|
||||
{
|
||||
return(ci.last());
|
||||
}
|
||||
public int getBeginIndex()
|
||||
{
|
||||
return(ci.getBeginIndex());
|
||||
}
|
||||
|
||||
public int
|
||||
getIndex()
|
||||
{
|
||||
return(ci.getIndex());
|
||||
}
|
||||
public int getEndIndex()
|
||||
{
|
||||
return(ci.getEndIndex());
|
||||
}
|
||||
|
||||
public char
|
||||
setIndex(int index)
|
||||
{
|
||||
return(ci.setIndex(index));
|
||||
}
|
||||
/*
|
||||
* Here is where the AttributedCharacterIterator methods start.
|
||||
*/
|
||||
|
||||
public int
|
||||
getBeginIndex()
|
||||
{
|
||||
return(ci.getBeginIndex());
|
||||
}
|
||||
/*************************************************************************/
|
||||
|
||||
public int
|
||||
getEndIndex()
|
||||
{
|
||||
return(ci.getEndIndex());
|
||||
}
|
||||
|
||||
/*
|
||||
* Here is where the AttributedCharacterIterator methods start.
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns a list of all the attribute keys that are defined anywhere
|
||||
* on this string.
|
||||
*/
|
||||
public Set
|
||||
getAllAttributeKeys()
|
||||
{
|
||||
HashSet s = new HashSet();
|
||||
if (attribs == null)
|
||||
return(s);
|
||||
/**
|
||||
* Returns a list of all the attribute keys that are defined anywhere
|
||||
* on this string.
|
||||
*/
|
||||
public Set getAllAttributeKeys()
|
||||
{
|
||||
HashSet s = new HashSet();
|
||||
if (attribs == null)
|
||||
return(s);
|
||||
|
||||
for (int i = 0; i < attribs.length; i++)
|
||||
{
|
||||
|
@ -193,156 +166,146 @@ getAllAttributeKeys()
|
|||
}
|
||||
}
|
||||
|
||||
return(s);
|
||||
}
|
||||
return(s);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Various methods that determine how far the run extends for various
|
||||
* attribute combinations.
|
||||
*/
|
||||
/**
|
||||
* Various methods that determine how far the run extends for various
|
||||
* attribute combinations.
|
||||
*/
|
||||
|
||||
public int
|
||||
getRunLimit()
|
||||
{
|
||||
return(getRunLimit(getAttributes().keySet()));
|
||||
}
|
||||
public int getRunLimit()
|
||||
{
|
||||
return(getRunLimit(getAttributes().keySet()));
|
||||
}
|
||||
|
||||
public int
|
||||
getRunLimit(AttributedCharacterIterator.Attribute attrib)
|
||||
{
|
||||
HashSet s = new HashSet();
|
||||
s.add(attrib);
|
||||
public int getRunLimit(AttributedCharacterIterator.Attribute attrib)
|
||||
{
|
||||
HashSet s = new HashSet();
|
||||
s.add(attrib);
|
||||
return(getRunLimit(s));
|
||||
}
|
||||
|
||||
return(getRunLimit(s));
|
||||
}
|
||||
public synchronized int getRunLimit(Set attribute_set)
|
||||
{
|
||||
boolean hit = false;
|
||||
int runLimit = ci.getEndIndex ();
|
||||
int pos = ci.getIndex ();
|
||||
|
||||
public synchronized int
|
||||
getRunLimit(Set attribute_set)
|
||||
{
|
||||
boolean hit = false;
|
||||
int runLimit = ci.getEndIndex ();
|
||||
int pos = ci.getIndex ();
|
||||
for (int i = 0; i < attribs.length; ++i)
|
||||
{
|
||||
if (pos >= attribs[i].begin_index &&
|
||||
pos < attribs[i].end_index)
|
||||
{
|
||||
Iterator iter = attribute_set.iterator();
|
||||
while(iter.hasNext())
|
||||
if (attribs[i].attribs.containsKey(iter.next()))
|
||||
{
|
||||
hit = true;
|
||||
runLimit = Math.min(runLimit, attribs[i].end_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hit)
|
||||
return runLimit;
|
||||
else
|
||||
return ci.getEndIndex();
|
||||
}
|
||||
|
||||
for (int i = 0; i < attribs.length; ++i)
|
||||
{
|
||||
if (pos >= attribs[i].begin_index &&
|
||||
pos < attribs[i].end_index)
|
||||
{
|
||||
Iterator iter = attribute_set.iterator();
|
||||
while(iter.hasNext())
|
||||
if (attribs[i].attribs.containsKey(iter.next()))
|
||||
{
|
||||
hit = true;
|
||||
runLimit = Math.min(runLimit, attribs[i].end_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hit)
|
||||
return runLimit;
|
||||
else
|
||||
return ci.getEndIndex();
|
||||
}
|
||||
/*************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/**
|
||||
* Various methods that determine where the run begins for various
|
||||
* attribute combinations.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Various methods that determine where the run begins for various
|
||||
* attribute combinations.
|
||||
*/
|
||||
public int getRunStart()
|
||||
{
|
||||
return(getRunStart(getAttributes().keySet()));
|
||||
}
|
||||
|
||||
public int
|
||||
getRunStart()
|
||||
{
|
||||
return(getRunStart(getAttributes().keySet()));
|
||||
}
|
||||
public int getRunStart(AttributedCharacterIterator.Attribute attrib)
|
||||
{
|
||||
HashSet s = new HashSet();
|
||||
s.add(attrib);
|
||||
|
||||
public int
|
||||
getRunStart(AttributedCharacterIterator.Attribute attrib)
|
||||
{
|
||||
HashSet s = new HashSet();
|
||||
s.add(attrib);
|
||||
return(getRunStart(s));
|
||||
}
|
||||
|
||||
return(getRunStart(s));
|
||||
}
|
||||
public int getRunStart(Set attribute_set)
|
||||
{
|
||||
boolean hit = false;
|
||||
int runBegin = 0;
|
||||
int pos = ci.getIndex();
|
||||
|
||||
public int
|
||||
getRunStart(Set attribute_set)
|
||||
{
|
||||
boolean hit = false;
|
||||
int runBegin = 0;
|
||||
int pos = ci.getIndex ();
|
||||
for (int i = 0; i < attribs.length; ++i)
|
||||
{
|
||||
if (pos >= attribs[i].begin_index &&
|
||||
pos <= attribs[i].end_index)
|
||||
{
|
||||
Iterator iter = attribute_set.iterator();
|
||||
while(iter.hasNext())
|
||||
if (attribs[i].attribs.containsKey(iter.next()))
|
||||
{
|
||||
hit = true;
|
||||
runBegin = Math.max(runBegin, attribs[i].begin_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hit)
|
||||
return runBegin;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < attribs.length; ++i)
|
||||
{
|
||||
if (pos >= attribs[i].begin_index &&
|
||||
pos <= attribs[i].end_index)
|
||||
{
|
||||
Iterator iter = attribute_set.iterator();
|
||||
while(iter.hasNext())
|
||||
if (attribs[i].attribs.containsKey(iter.next()))
|
||||
{
|
||||
hit = true;
|
||||
runBegin = Math.max(runBegin, attribs[i].begin_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hit)
|
||||
return runBegin;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
/*************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
public Object getAttribute(AttributedCharacterIterator.Attribute attrib)
|
||||
{
|
||||
if (attribs == null)
|
||||
return(null);
|
||||
|
||||
for (int i = 0; i < attribs.length; i++)
|
||||
{
|
||||
Set key_set = attribs[i].attribs.keySet();
|
||||
Iterator iter = key_set.iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
Object obj = iter.next();
|
||||
|
||||
// Check for attribute match and range match
|
||||
if (obj.equals(attrib))
|
||||
if ((ci.getIndex() >= attribs[i].begin_index) &&
|
||||
(ci.getIndex() < attribs[i].end_index))
|
||||
return(attribs[i].attribs.get(obj));
|
||||
}
|
||||
}
|
||||
|
||||
public Object
|
||||
getAttribute(AttributedCharacterIterator.Attribute attrib)
|
||||
{
|
||||
if (attribs == null)
|
||||
return(null);
|
||||
}
|
||||
|
||||
for (int i = 0; i < attribs.length; i++)
|
||||
{
|
||||
Set key_set = attribs[i].attribs.keySet();
|
||||
Iterator iter = key_set.iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
Object obj = iter.next();
|
||||
/*************************************************************************/
|
||||
|
||||
// Check for attribute match and range match
|
||||
if (obj.equals(attrib))
|
||||
if ((ci.getIndex() >= attribs[i].begin_index) &&
|
||||
(ci.getIndex() < attribs[i].end_index))
|
||||
return(attribs[i].attribs.get(obj));
|
||||
}
|
||||
}
|
||||
|
||||
return(null);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Return a list of all the attributes and values defined for this
|
||||
* character
|
||||
*/
|
||||
public Map
|
||||
getAttributes()
|
||||
{
|
||||
HashMap m = new HashMap();
|
||||
if (attribs == null)
|
||||
return(m);
|
||||
/**
|
||||
* Return a list of all the attributes and values defined for this
|
||||
* character
|
||||
*/
|
||||
public Map getAttributes()
|
||||
{
|
||||
HashMap m = new HashMap();
|
||||
if (attribs == null)
|
||||
return(m);
|
||||
|
||||
for (int i = 0; i < attribs.length; i++)
|
||||
{
|
||||
if ((ci.getIndex() >= attribs[i].begin_index) &&
|
||||
(ci.getIndex() < attribs[i].end_index))
|
||||
m.putAll(attribs[i].attribs);
|
||||
}
|
||||
for (int i = 0; i < attribs.length; i++)
|
||||
{
|
||||
if ((ci.getIndex() >= attribs[i].begin_index) &&
|
||||
(ci.getIndex() < attribs[i].end_index))
|
||||
m.putAll(attribs[i].attribs);
|
||||
}
|
||||
|
||||
return(m);
|
||||
}
|
||||
return(m);
|
||||
}
|
||||
|
||||
} // class AttributedStringIterator
|
||||
|
||||
|
|
|
@ -114,9 +114,9 @@ public abstract class BreakIterator implements Cloneable
|
|||
* This methdod returns the offset of the text element boundary following
|
||||
* the specified offset.
|
||||
*
|
||||
* @param offset The text index from which to find the next text boundary.
|
||||
* @param pos The text index from which to find the next text boundary.
|
||||
*
|
||||
* @param The next text boundary following the specified index.
|
||||
* @return The next text boundary following the specified index.
|
||||
*/
|
||||
public abstract int following (int pos);
|
||||
|
||||
|
@ -186,9 +186,9 @@ public abstract class BreakIterator implements Cloneable
|
|||
*
|
||||
* @return A <code>BreakIterator</code> instance for the default locale.
|
||||
*/
|
||||
public static BreakIterator getCharacterInstance (Locale loc)
|
||||
public static BreakIterator getCharacterInstance (Locale locale)
|
||||
{
|
||||
BreakIterator r = getInstance ("CharacterIterator", loc);
|
||||
BreakIterator r = getInstance ("CharacterIterator", locale);
|
||||
if (r == null)
|
||||
r = new gnu.java.text.CharacterBreakIterator ();
|
||||
return r;
|
||||
|
@ -214,9 +214,9 @@ public abstract class BreakIterator implements Cloneable
|
|||
*
|
||||
* @return A <code>BreakIterator</code> instance for the default locale.
|
||||
*/
|
||||
public static BreakIterator getLineInstance (Locale loc)
|
||||
public static BreakIterator getLineInstance (Locale locale)
|
||||
{
|
||||
BreakIterator r = getInstance ("LineIterator", loc);
|
||||
BreakIterator r = getInstance ("LineIterator", locale);
|
||||
if (r == null)
|
||||
r = new gnu.java.text.LineBreakIterator ();
|
||||
return r;
|
||||
|
@ -242,9 +242,9 @@ public abstract class BreakIterator implements Cloneable
|
|||
*
|
||||
* @return A <code>BreakIterator</code> instance for the default locale.
|
||||
*/
|
||||
public static BreakIterator getSentenceInstance (Locale loc)
|
||||
public static BreakIterator getSentenceInstance (Locale locale)
|
||||
{
|
||||
BreakIterator r = getInstance ("SentenceIterator", loc);
|
||||
BreakIterator r = getInstance ("SentenceIterator", locale);
|
||||
if (r == null)
|
||||
r = new gnu.java.text.SentenceBreakIterator ();
|
||||
return r;
|
||||
|
@ -254,7 +254,7 @@ public abstract class BreakIterator implements Cloneable
|
|||
* This method returns the text this object is iterating over as a
|
||||
* <code>CharacterIterator</code>.
|
||||
*
|
||||
* @param The text being iterated over.
|
||||
* @return The text being iterated over.
|
||||
*/
|
||||
public abstract CharacterIterator getText ();
|
||||
|
||||
|
@ -278,9 +278,9 @@ public abstract class BreakIterator implements Cloneable
|
|||
*
|
||||
* @return A <code>BreakIterator</code> instance for the default locale.
|
||||
*/
|
||||
public static BreakIterator getWordInstance (Locale loc)
|
||||
public static BreakIterator getWordInstance (Locale locale)
|
||||
{
|
||||
BreakIterator r = getInstance ("WordIterator", loc);
|
||||
BreakIterator r = getInstance ("WordIterator", locale);
|
||||
if (r == null)
|
||||
r = new gnu.java.text.WordBreakIterator ();
|
||||
return r;
|
||||
|
@ -290,7 +290,7 @@ public abstract class BreakIterator implements Cloneable
|
|||
* This method tests whether or not the specified position is a text
|
||||
* element boundary.
|
||||
*
|
||||
* @param offset The text position to test.
|
||||
* @param pos The text position to test.
|
||||
*
|
||||
* @return <code>true</code> if the position is a boundary,
|
||||
* <code>false</code> otherwise.
|
||||
|
@ -332,8 +332,7 @@ public abstract class BreakIterator implements Cloneable
|
|||
* This methdod returns the offset of the text element boundary preceding
|
||||
* the specified offset.
|
||||
*
|
||||
* @param offset The text index from which to find the preceding
|
||||
* text boundary.
|
||||
* @param pos The text index from which to find the preceding text boundary.
|
||||
*
|
||||
* @returns The next text boundary preceding the specified index.
|
||||
*/
|
||||
|
@ -357,7 +356,7 @@ public abstract class BreakIterator implements Cloneable
|
|||
/**
|
||||
* This method sets the text string to iterate over.
|
||||
*
|
||||
* @param str The <code>String</code> to iterate over.
|
||||
* @param newText The <code>String</code> to iterate over.
|
||||
*/
|
||||
public void setText (String newText)
|
||||
{
|
||||
|
@ -368,7 +367,7 @@ public abstract class BreakIterator implements Cloneable
|
|||
* This method sets the text to iterate over from the specified
|
||||
* <code>CharacterIterator</code>.
|
||||
*
|
||||
* @param ci The desired <code>CharacterIterator</code>.
|
||||
* @param newText The desired <code>CharacterIterator</code>.
|
||||
*/
|
||||
public abstract void setText (CharacterIterator newText);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* CharacterIterator.java -- Iterate over a character range
|
||||
Copyright (C) 1998, 2001 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 2001, 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -64,8 +64,8 @@ public interface CharacterIterator extends Cloneable
|
|||
|
||||
/**
|
||||
* This method increments the current index and then returns the character
|
||||
* at the new index value. If the index is already at <code>getEndIndex() - 1</code>,
|
||||
* it will not be incremented.
|
||||
* at the new index value. If the index is already at
|
||||
* <code>getEndIndex() - 1</code>, it will not be incremented.
|
||||
*
|
||||
* @return The character at the position of the incremented index value,
|
||||
* or <code>DONE</code> if the index has reached getEndIndex() - 1
|
||||
|
@ -78,7 +78,8 @@ public interface CharacterIterator extends Cloneable
|
|||
* index, it will not be decremented.
|
||||
*
|
||||
* @return The character at the position of the decremented index value,
|
||||
* or <code>DONE</code> if index was already equal to the beginning index value.
|
||||
* or {@link #DONE} if index was already equal to the beginning index
|
||||
* value.
|
||||
*/
|
||||
char previous();
|
||||
|
||||
|
@ -86,7 +87,8 @@ public interface CharacterIterator extends Cloneable
|
|||
* This method sets the index value to the beginning of the range and returns
|
||||
* the character there.
|
||||
*
|
||||
* @return The character at the beginning of the range, or <code>DONE</code> if the range is empty.
|
||||
* @return The character at the beginning of the range, or {@link #DONE} if
|
||||
* the range is empty.
|
||||
*/
|
||||
char first();
|
||||
|
||||
|
@ -95,7 +97,8 @@ public interface CharacterIterator extends Cloneable
|
|||
* returns the character there. If the range is empty, then the index value
|
||||
* will be set equal to the beginning index.
|
||||
*
|
||||
* @return The character at the end of the range, or <code>DONE</code> if the range is empty.
|
||||
* @return The character at the end of the range, or {@link #DONE} if the
|
||||
* range is empty.
|
||||
*/
|
||||
char last();
|
||||
|
||||
|
@ -112,7 +115,8 @@ public interface CharacterIterator extends Cloneable
|
|||
*
|
||||
* @param index The new index value.
|
||||
*
|
||||
* @return The character at the new index value or <code>DONE</code> if the index value is equal to <code>getEndIndex</code>.
|
||||
* @return The character at the new index value or {@link #DONE} if the index
|
||||
* value is equal to {@link #getEndIndex()}.
|
||||
*/
|
||||
char setIndex (int index) throws IllegalArgumentException;
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public class ChoiceFormat extends NumberFormat
|
|||
* object based on the specified pattern. This pattern is of the form
|
||||
* "term#string|term#string...". For example "1#Sunday|2#Monday|#Tuesday".
|
||||
*
|
||||
* @param pattern The pattern of terminators and format strings.
|
||||
* @param newPattern The pattern of terminators and format strings.
|
||||
*
|
||||
* @exception IllegalArgumentException If the pattern is not valid
|
||||
*/
|
||||
|
@ -170,7 +170,7 @@ public class ChoiceFormat extends NumberFormat
|
|||
* This is the same pattern type used by the <code>applyPattern</code>
|
||||
* method.
|
||||
*
|
||||
* @param pattern The pattern of terminators and format strings.
|
||||
* @param newPattern The pattern of terminators and format strings.
|
||||
*
|
||||
* @exception IllegalArgumentException If the pattern is not valid
|
||||
*/
|
||||
|
@ -229,10 +229,11 @@ public class ChoiceFormat extends NumberFormat
|
|||
* <code>StringBuffer</code> based on the supplied <code>long</code>
|
||||
* argument.
|
||||
*
|
||||
* @param number The number used for determine (based on the range
|
||||
* @param num The number used for determine (based on the range
|
||||
* terminators) which format string to append.
|
||||
* @param sb The <code>StringBuffer</code> to append the format string to.
|
||||
* @param status Unused.
|
||||
* @param appendBuf The <code>StringBuffer</code> to append the format string
|
||||
* to.
|
||||
* @param pos Unused.
|
||||
*
|
||||
* @return The <code>StringBuffer</code> with the format string appended.
|
||||
*/
|
||||
|
@ -247,10 +248,10 @@ public class ChoiceFormat extends NumberFormat
|
|||
* <code>StringBuffer</code> based on the supplied <code>double</code>
|
||||
* argument.
|
||||
*
|
||||
* @param number The number used for determine (based on the range
|
||||
* @param num The number used for determine (based on the range
|
||||
* terminators) which format string to append.
|
||||
* @param sb The <code>StringBuffer</code> to append the format string to.
|
||||
* @param status Unused.
|
||||
* @param appendBuf The <code>StringBuffer</code> to append the format string to.
|
||||
* @param pos Unused.
|
||||
*
|
||||
* @return The <code>StringBuffer</code> with the format string appended.
|
||||
*/
|
||||
|
@ -333,7 +334,7 @@ public class ChoiceFormat extends NumberFormat
|
|||
* double less than the specified double will be returned.
|
||||
*
|
||||
* @param d The specified double
|
||||
* @param positive <code>true</code> to return the next highest
|
||||
* @param next <code>true</code> to return the next highest
|
||||
* double, <code>false</code> otherwise.
|
||||
*
|
||||
* @return The next highest or lowest double value.
|
||||
|
|
|
@ -177,9 +177,11 @@ public final class CollationElementIterator
|
|||
* This method returns the primary order value for the given collation
|
||||
* value.
|
||||
*
|
||||
* @param value The collation value returned from <code>next()</code> or <code>previous()</code>.
|
||||
* @param order The collation value returned from <code>next()</code> or
|
||||
* <code>previous()</code>.
|
||||
*
|
||||
* @return The primary order value of the specified collation value. This is the high 16 bits.
|
||||
* @return The primary order value of the specified collation value. This is
|
||||
* the high 16 bits.
|
||||
*/
|
||||
public static int primaryOrder(int order)
|
||||
{
|
||||
|
@ -201,9 +203,11 @@ public final class CollationElementIterator
|
|||
* This method returns the secondary order value for the given collation
|
||||
* value.
|
||||
*
|
||||
* @param value The collation value returned from <code>next()</code> or <code>previous()</code>.
|
||||
* @param order The collation value returned from <code>next()</code> or
|
||||
* <code>previous()</code>.
|
||||
*
|
||||
* @return The secondary order value of the specified collation value. This is the bits 8-15.
|
||||
* @return The secondary order value of the specified collation value. This
|
||||
* is the bits 8-15.
|
||||
*/
|
||||
public static short secondaryOrder(int order)
|
||||
{
|
||||
|
@ -215,9 +219,11 @@ public final class CollationElementIterator
|
|||
* This method returns the tertiary order value for the given collation
|
||||
* value.
|
||||
*
|
||||
* @param value The collation value returned from <code>next()</code> or <code>previous()</code>.
|
||||
* @param order The collation value returned from <code>next()</code> or
|
||||
* <code>previous()</code>.
|
||||
*
|
||||
* @return The tertiary order value of the specified collation value. This is the low eight bits.
|
||||
* @return The tertiary order value of the specified collation value. This
|
||||
* is the low eight bits.
|
||||
*/
|
||||
public static short tertiaryOrder(int order)
|
||||
{
|
||||
|
@ -458,7 +464,7 @@ public final class CollationElementIterator
|
|||
*
|
||||
* @param value The collation order value
|
||||
*
|
||||
* @param The maximum length of an expansion sequence.
|
||||
* @return The maximum length of an expansion sequence.
|
||||
*/
|
||||
public int getMaxExpansion(int value)
|
||||
{
|
||||
|
|
|
@ -38,6 +38,8 @@ exception statement from your version. */
|
|||
|
||||
package java.text;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/* Written using "Java Class Libraries", 2nd edition, plus online
|
||||
* API docs for JDK 1.2 from http://www.javasoft.com.
|
||||
* Status: Believed complete and correct.
|
||||
|
@ -154,7 +156,7 @@ public final class CollationKey implements Comparable
|
|||
if (!ck.getSourceString ().equals (getSourceString ()))
|
||||
return false;
|
||||
|
||||
if (!ck.toByteArray ().equals (toByteArray ()))
|
||||
if (! Arrays.equals (ck.toByteArray (), toByteArray ()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -190,7 +192,7 @@ public final class CollationKey implements Comparable
|
|||
/**
|
||||
* This method returns the collation bit sequence as a byte array.
|
||||
*
|
||||
* @param A byte array containing the collation bit sequence.
|
||||
* @return A byte array containing the collation bit sequence.
|
||||
*/
|
||||
public byte[] toByteArray()
|
||||
{
|
||||
|
|
|
@ -150,8 +150,8 @@ public abstract class Collator implements Comparator, Cloneable
|
|||
* <code>Collator</code> and the strength and decomposition rules in
|
||||
* effect.
|
||||
*
|
||||
* @param str1 The first object to compare
|
||||
* @param str2 The second object to compare
|
||||
* @param source The first object to compare
|
||||
* @param target The second object to compare
|
||||
*
|
||||
* @return A negative integer if str1 < str2, 0 if str1 == str2, or
|
||||
* a positive integer if str1 > str2.
|
||||
|
@ -164,8 +164,8 @@ public abstract class Collator implements Comparator, Cloneable
|
|||
* equal to, or greater than the second argument. These two objects
|
||||
* must be <code>String</code>'s or an exception will be thrown.
|
||||
*
|
||||
* @param obj1 The first object to compare
|
||||
* @param obj2 The second object to compare
|
||||
* @param o1 The first object to compare
|
||||
* @param o2 The second object to compare
|
||||
*
|
||||
* @return A negative integer if obj1 < obj2, 0 if obj1 == obj2, or
|
||||
* a positive integer if obj1 > obj2.
|
||||
|
@ -208,8 +208,8 @@ public abstract class Collator implements Comparator, Cloneable
|
|||
* according to the collation rules for the locale of this object and
|
||||
* the current strength and decomposition settings.
|
||||
*
|
||||
* @param str1 The first <code>String</code> to compare
|
||||
* @param str2 The second <code>String</code> to compare
|
||||
* @param source The first <code>String</code> to compare
|
||||
* @param target The second <code>String</code> to compare
|
||||
*
|
||||
* @return <code>true</code> if the two strings are equal,
|
||||
* <code>false</code> otherwise.
|
||||
|
@ -256,7 +256,7 @@ public abstract class Collator implements Comparator, Cloneable
|
|||
* comparisons against a string might be performed multiple times, such
|
||||
* as during a sort operation.
|
||||
*
|
||||
* @param str The <code>String</code> to convert.
|
||||
* @param source The <code>String</code> to convert.
|
||||
*
|
||||
* @return A <code>CollationKey</code> for the specified <code>String</code>.
|
||||
*/
|
||||
|
@ -292,7 +292,7 @@ public abstract class Collator implements Comparator, Cloneable
|
|||
* specified locale. If no <code>Collator</code> exists for the desired
|
||||
* locale, a <code>Collator</code> for the default locale will be returned.
|
||||
*
|
||||
* @param locale The desired localed to load a <code>Collator</code> for.
|
||||
* @param loc The desired localed to load a <code>Collator</code> for.
|
||||
*
|
||||
* @return A <code>Collator</code> for the requested locale
|
||||
*/
|
||||
|
@ -347,7 +347,7 @@ public abstract class Collator implements Comparator, Cloneable
|
|||
* exception will be thrown. See the documentation for those
|
||||
* contants for an explanation of this setting.
|
||||
*
|
||||
* @param decmp The new decomposition setting.
|
||||
* @param mode The new decomposition setting.
|
||||
*
|
||||
* @exception IllegalArgumentException If the requested
|
||||
* decomposition setting is not valid.
|
||||
|
|
|
@ -405,8 +405,18 @@ public abstract class DateFormat extends Format implements Cloneable
|
|||
* <ul>
|
||||
* <li>Is not <code>null</code>.</li>
|
||||
* <li>Is an instance of <code>DateFormat</code>.</li>
|
||||
* <li>Has the same numberFormat field value as this object.</li>
|
||||
* <li>Has equal numberFormat field as this object.</li>
|
||||
* <li>Has equal (Calendar) TimeZone rules as this object.</li>
|
||||
* <li>Has equal (Calendar) isLenient results.</li>
|
||||
* <li>Has equal Calendar first day of week and minimal days in week
|
||||
* values.</li>
|
||||
* </ul>
|
||||
* Note that not all properties of the Calendar are relevant for a
|
||||
* DateFormat. For formatting only the fact whether or not the
|
||||
* TimeZone has the same rules and whether the calendar is lenient
|
||||
* and has the same week rules is compared for this implementation
|
||||
* of equals. Other properties of the Calendar (such as the time)
|
||||
* are not taken into account.
|
||||
*
|
||||
* @param obj The object to test for equality against.
|
||||
*
|
||||
|
@ -419,8 +429,24 @@ public abstract class DateFormat extends Format implements Cloneable
|
|||
return false;
|
||||
|
||||
DateFormat d = (DateFormat) obj;
|
||||
TimeZone tz = getTimeZone();
|
||||
TimeZone tzd = d.getTimeZone();
|
||||
if (tz.hasSameRules(tzd))
|
||||
if (isLenient() == d.isLenient())
|
||||
{
|
||||
Calendar c = getCalendar();
|
||||
Calendar cd = d.getCalendar();
|
||||
if ((c == null && cd == null)
|
||||
||
|
||||
(c.getFirstDayOfWeek() == cd.getFirstDayOfWeek()
|
||||
&&
|
||||
c.getMinimalDaysInFirstWeek()
|
||||
== cd.getMinimalDaysInFirstWeek()))
|
||||
return ((numberFormat == null && d.numberFormat == null)
|
||||
|| numberFormat.equals(d.numberFormat));
|
||||
}
|
||||
|
||||
return numberFormat.equals(d.numberFormat);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -442,9 +468,9 @@ public abstract class DateFormat extends Format implements Cloneable
|
|||
* thrown.
|
||||
*
|
||||
* @param obj The <code>Object</code> to format.
|
||||
* @param toAppendTo The <code>StringBuffer</code> to append the resultant
|
||||
* @param buf The <code>StringBuffer</code> to append the resultant
|
||||
* <code>String</code> to.
|
||||
* @param fieldPosition Is updated to the start and end index of the
|
||||
* @param pos Is updated to the start and end index of the
|
||||
* specified field.
|
||||
*
|
||||
* @return The <code>StringBuffer</code> supplied on input, with the
|
||||
|
@ -479,9 +505,9 @@ public abstract class DateFormat extends Format implements Cloneable
|
|||
* to the specified <code>StringBuffer</code>.
|
||||
*
|
||||
* @param date The <code>Date</code> value to format.
|
||||
* @param toAppendTo The <code>StringBuffer</code> to append the resultant
|
||||
* @param buf The <code>StringBuffer</code> to append the resultant
|
||||
* <code>String</code> to.
|
||||
* @param fieldPosition Is updated to the start and end index of the
|
||||
* @param pos Is updated to the start and end index of the
|
||||
* specified field.
|
||||
*
|
||||
* @return The <code>StringBuffer</code> supplied on input, with the
|
||||
|
@ -643,7 +669,7 @@ public abstract class DateFormat extends Format implements Cloneable
|
|||
* localed will be used in place of the default.
|
||||
*
|
||||
* @param style The type of formatting to perform.
|
||||
* @param aLocale The desired locale.
|
||||
* @param loc The desired locale.
|
||||
*
|
||||
* @return A new <code>DateFormat</code> instance.
|
||||
*/
|
||||
|
@ -744,7 +770,7 @@ public abstract class DateFormat extends Format implements Cloneable
|
|||
* localed will be used in place of the default.
|
||||
*
|
||||
* @param style The type of formatting to perform.
|
||||
* @param aLocale The desired locale.
|
||||
* @param loc The desired locale.
|
||||
*
|
||||
* @return A new <code>DateFormat</code> instance.
|
||||
*/
|
||||
|
@ -818,7 +844,7 @@ public abstract class DateFormat extends Format implements Cloneable
|
|||
* starting parse position on method entry and the ending parse
|
||||
* position on method exit.
|
||||
*
|
||||
* @param text The string to parse.
|
||||
* @param source The string to parse.
|
||||
* @param pos The starting parse position in entry, the ending parse
|
||||
* position on exit.
|
||||
*
|
||||
|
@ -848,7 +874,7 @@ public abstract class DateFormat extends Format implements Cloneable
|
|||
* This method specified the <code>Calendar</code> that should be used
|
||||
* by this object to parse/format datetimes.
|
||||
*
|
||||
* @param The new <code>Calendar</code> for this object.
|
||||
* @param calendar The new <code>Calendar</code> for this object.
|
||||
*
|
||||
* @see java.util.Calendar
|
||||
*/
|
||||
|
@ -873,7 +899,7 @@ public abstract class DateFormat extends Format implements Cloneable
|
|||
* This method specifies the <code>NumberFormat</code> object that should
|
||||
* be used by this object to parse/format times.
|
||||
*
|
||||
* @param The <code>NumberFormat</code> in use by this object.
|
||||
* @param numberFormat The <code>NumberFormat</code> in use by this object.
|
||||
*/
|
||||
public void setNumberFormat (NumberFormat numberFormat)
|
||||
{
|
||||
|
@ -883,7 +909,7 @@ public abstract class DateFormat extends Format implements Cloneable
|
|||
/**
|
||||
* This method sets the time zone that should be used by this object.
|
||||
*
|
||||
* @param The new time zone.
|
||||
* @param timeZone The new time zone.
|
||||
*/
|
||||
public void setTimeZone (TimeZone timeZone)
|
||||
{
|
||||
|
|
|
@ -41,7 +41,6 @@ package java.text;
|
|||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
* This class acts as container for locale specific date/time formatting
|
||||
|
@ -289,7 +288,7 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
|
|||
* This is a two element <code>String</code> array indexed by
|
||||
* <code>Calendar.AM</code> and <code>Calendar.PM</code>
|
||||
*
|
||||
* @param ampms The new list of AM/PM display strings.
|
||||
* @param value The new list of AM/PM display strings.
|
||||
*/
|
||||
public void setAmPmStrings (String[] value)
|
||||
{
|
||||
|
@ -302,11 +301,11 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
|
|||
* This is a two element <code>String</code>
|
||||
* array indexed by <code>Calendar.BC</code> and <code>Calendar.AD</code>.
|
||||
*
|
||||
* @param eras The new list of era disply strings.
|
||||
* @param labels The new list of era display strings.
|
||||
*/
|
||||
public void setEras (String[] value)
|
||||
public void setEras (String[] labels)
|
||||
{
|
||||
eras = value;
|
||||
eras = labels;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -340,11 +339,11 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
|
|||
* <li>17 - time zone (z)</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param localPatternChars The new format patter characters
|
||||
* @param chars The new format pattern characters
|
||||
*/
|
||||
public void setLocalPatternChars (String value)
|
||||
public void setLocalPatternChars (String chars)
|
||||
{
|
||||
localPatternChars = value;
|
||||
localPatternChars = chars;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -354,11 +353,11 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
|
|||
* <code>Calendar.UNDECEMBER</code>. Note that there are thirteen
|
||||
* elements because some calendars have thriteen months.
|
||||
*
|
||||
* @param months The list of month display strings.
|
||||
* @param labels The list of month display strings.
|
||||
*/
|
||||
public void setMonths (String[] value)
|
||||
public void setMonths (String[] labels)
|
||||
{
|
||||
months = value;
|
||||
months = labels;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -369,11 +368,11 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
|
|||
* through <code>Calendar.UNDECEMBER</code>. Note that there are thirteen
|
||||
* elements because some calendars have thirteen months.
|
||||
*
|
||||
* @param shortMonths The new list of abbreviated month display strings.
|
||||
* @param labels The new list of abbreviated month display strings.
|
||||
*/
|
||||
public void setShortMonths (String[] value)
|
||||
public void setShortMonths (String[] labels)
|
||||
{
|
||||
shortMonths = value;
|
||||
shortMonths = labels;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -384,11 +383,11 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
|
|||
* through <code>Calendar.SATURDAY</code>. Note that the first element
|
||||
* of this array is ignored.
|
||||
*
|
||||
* @param shortWeekdays This list of abbreviated weekday display strings.
|
||||
* @param labels This list of abbreviated weekday display strings.
|
||||
*/
|
||||
public void setShortWeekdays (String[] value)
|
||||
public void setShortWeekdays (String[] labels)
|
||||
{
|
||||
shortWeekdays = value;
|
||||
shortWeekdays = labels;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -398,11 +397,11 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
|
|||
* through <code>Calendar.SATURDAY</code>. Note that the first element
|
||||
* of this array is ignored.
|
||||
*
|
||||
* @param weekdays This list of weekday display strings.
|
||||
* @param labels This list of weekday display strings.
|
||||
*/
|
||||
public void setWeekdays (String[] value)
|
||||
public void setWeekdays (String[] labels)
|
||||
{
|
||||
weekdays = value;
|
||||
weekdays = labels;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -418,11 +417,11 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
|
|||
* <li>4 - the short name of the time zone (daylight savings time).</li>
|
||||
* </ul>
|
||||
*
|
||||
* @return The list of time zone display strings.
|
||||
* @params zones The list of time zone display strings.
|
||||
*/
|
||||
public void setZoneStrings (String[][] value)
|
||||
public void setZoneStrings (String[][] zones)
|
||||
{
|
||||
zoneStrings = value;
|
||||
zoneStrings = zones;
|
||||
}
|
||||
|
||||
/* Does a "deep" equality test - recurses into arrays. */
|
||||
|
@ -492,7 +491,7 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
|
|||
/**
|
||||
* Returns a new copy of this object.
|
||||
*
|
||||
* @param A copy of this object
|
||||
* @return A copy of this object
|
||||
*/
|
||||
public Object clone ()
|
||||
{
|
||||
|
|
|
@ -139,7 +139,7 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
|
|||
* locales (those with no specified country), such as
|
||||
* <code>Locale.ENGLISH</code>.
|
||||
*
|
||||
* @param locale The local to load symbols for.
|
||||
* @param loc The local to load symbols for.
|
||||
* @throws NullPointerException if the locale is null.
|
||||
*/
|
||||
public DecimalFormatSymbols (Locale loc)
|
||||
|
@ -422,7 +422,7 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
|
|||
/**
|
||||
* This method sets the currency symbol to the specified value.
|
||||
*
|
||||
* @param currencySymbol The new currency symbol
|
||||
* @param currency The new currency symbol
|
||||
*/
|
||||
public void setCurrencySymbol (String currency)
|
||||
{
|
||||
|
@ -432,7 +432,7 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
|
|||
/**
|
||||
* This method sets the decimal point character to the specified value.
|
||||
*
|
||||
* @param decimalSeparator The new decimal point character
|
||||
* @param decimalSep The new decimal point character
|
||||
*/
|
||||
public void setDecimalSeparator (char decimalSep)
|
||||
{
|
||||
|
@ -464,7 +464,7 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
|
|||
/**
|
||||
* This method sets the character used to separate groups of digits.
|
||||
*
|
||||
* @param groupingSeparator The character used to separate groups of digits.
|
||||
* @param groupSep The character used to separate groups of digits.
|
||||
*/
|
||||
public void setGroupingSeparator (char groupSep)
|
||||
{
|
||||
|
@ -523,8 +523,7 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
|
|||
* This method sets the character used for the decimal point in currency
|
||||
* values.
|
||||
*
|
||||
* @param monetarySeparator The decimal point character used in
|
||||
* currency values.
|
||||
* @param decimalSep The decimal point character used in currency values.
|
||||
*/
|
||||
public void setMonetaryDecimalSeparator (char decimalSep)
|
||||
{
|
||||
|
@ -535,7 +534,7 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
|
|||
* This method sets the string used to represent the NaN (not a
|
||||
* number) value.
|
||||
*
|
||||
* @param NaN The string used to represent NaN
|
||||
* @param nan The string used to represent NaN
|
||||
*/
|
||||
public void setNaN (String nan)
|
||||
{
|
||||
|
@ -546,7 +545,7 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
|
|||
* This method sets the character used to separate positive and negative
|
||||
* subpatterns in a format pattern.
|
||||
*
|
||||
* @param patternSeparator The character used to separate positive and
|
||||
* @param patternSep The character used to separate positive and
|
||||
* negative subpatterns in a format pattern.
|
||||
*/
|
||||
public void setPatternSeparator (char patternSep)
|
||||
|
|
|
@ -334,7 +334,7 @@ public class MessageFormat extends Format
|
|||
/**
|
||||
* Applies the specified pattern to this MessageFormat.
|
||||
*
|
||||
* @param aPattern The Pattern
|
||||
* @param newPattern The Pattern
|
||||
*/
|
||||
public void applyPattern (String newPattern)
|
||||
{
|
||||
|
@ -378,7 +378,6 @@ public class MessageFormat extends Format
|
|||
/**
|
||||
* A convinience method to format patterns.
|
||||
*
|
||||
* @param aPattern The pattern used when formatting.
|
||||
* @param arguments The array containing the objects to be formatted.
|
||||
*/
|
||||
public AttributedCharacterIterator formatToCharacterIterator (Object arguments)
|
||||
|
@ -394,7 +393,7 @@ public class MessageFormat extends Format
|
|||
/**
|
||||
* A convinience method to format patterns.
|
||||
*
|
||||
* @param aPattern The pattern used when formatting.
|
||||
* @param pattern The pattern used when formatting.
|
||||
* @param arguments The array containing the objects to be formatted.
|
||||
*/
|
||||
public static String format (String pattern, Object arguments[])
|
||||
|
@ -408,8 +407,8 @@ public class MessageFormat extends Format
|
|||
/**
|
||||
* Returns the pattern with the formatted objects.
|
||||
*
|
||||
* @param source The array containing the objects to be formatted.
|
||||
* @param result The StringBuffer where the text is appened.
|
||||
* @param arguments The array containing the objects to be formatted.
|
||||
* @param appendBuf The StringBuffer where the text is appened.
|
||||
* @param fp A FieldPosition object (it is ignored).
|
||||
*/
|
||||
public final StringBuffer format (Object arguments[], StringBuffer appendBuf,
|
||||
|
@ -709,8 +708,8 @@ public class MessageFormat extends Format
|
|||
* Sets the format for the argument at an specified
|
||||
* index.
|
||||
*
|
||||
* @param index The index.
|
||||
* @format The Format object.
|
||||
* @param variableNum The index.
|
||||
* @param newFormat The Format object.
|
||||
*/
|
||||
public void setFormat (int variableNum, Format newFormat)
|
||||
{
|
||||
|
@ -720,7 +719,7 @@ public class MessageFormat extends Format
|
|||
/**
|
||||
* Sets the formats for the arguments.
|
||||
*
|
||||
* @param formats An array of Format objects.
|
||||
* @param newFormats An array of Format objects.
|
||||
*/
|
||||
public void setFormats (Format[] newFormats)
|
||||
{
|
||||
|
@ -735,7 +734,7 @@ public class MessageFormat extends Format
|
|||
/**
|
||||
* Sets the locale.
|
||||
*
|
||||
* @param locale A Locale
|
||||
* @param loc A Locale
|
||||
*/
|
||||
public void setLocale (Locale loc)
|
||||
{
|
||||
|
|
|
@ -237,7 +237,8 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
* a <code>StringBuffer</code>.
|
||||
*
|
||||
* @param number The <code>double</code> to format.
|
||||
* @param sb The <code>StringBuffer</code> to append the formatted number to.
|
||||
* @param sbuf The <code>StringBuffer</code> to append the formatted number
|
||||
* to.
|
||||
* @param pos The desired <code>FieldPosition</code>.
|
||||
*
|
||||
* @return The <code>StringBuffer</code> with the appended number.
|
||||
|
@ -250,7 +251,8 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
* a <code>StringBuffer</code>.
|
||||
*
|
||||
* @param number The <code>long</code> to format.
|
||||
* @param sb The <code>StringBuffer</code> to append the formatted number to.
|
||||
* @param sbuf The <code>StringBuffer</code> to append the formatted number
|
||||
* to.
|
||||
* @param pos The desired <code>FieldPosition</code>.
|
||||
*
|
||||
* @return The <code>StringBuffer</code> with the appended number.
|
||||
|
@ -371,7 +373,7 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
* will be a concrete subclass of <code>NumberFormat</code>, but the
|
||||
* actual class returned is dependent on the locale.
|
||||
*
|
||||
* @param locale The desired locale.
|
||||
* @param loc The desired locale.
|
||||
*
|
||||
* @return An instance of the default <code>NumberFormat</code> class.
|
||||
*/
|
||||
|
@ -434,8 +436,6 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
* will be a concrete subclass of <code>NumberFormat</code>, but the
|
||||
* actual class returned is dependent on the locale.
|
||||
*
|
||||
* @param locale The desired locale.
|
||||
*
|
||||
* @return An instance of the default <code>NumberFormat</code> class.
|
||||
*/
|
||||
public static final NumberFormat getNumberInstance ()
|
||||
|
@ -502,7 +502,7 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
* This method returns an instance of <code>NumberFormat</code> suitable
|
||||
* for formatting and parsing percentage values in the specified locale.
|
||||
*
|
||||
* @param locale The desired locale.
|
||||
* @param loc The desired locale.
|
||||
*
|
||||
* @return An instance of <code>NumberFormat</code> for handling percentages.
|
||||
*/
|
||||
|
@ -571,8 +571,8 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
* <code>Double</code>. If no number can be parsed, no exception is
|
||||
* thrown. Instead, the parse position remains at its initial index.
|
||||
*
|
||||
* @param str The string to parse.
|
||||
* @param pp The desired <code>ParsePosition</code>.
|
||||
* @param sourceStr The string to parse.
|
||||
* @param pos The desired <code>ParsePosition</code>.
|
||||
*
|
||||
* @return The parsed <code>Number</code>
|
||||
*/
|
||||
|
@ -584,7 +584,7 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
* <code>Double</code>. If no number can be parsed, an exception will be
|
||||
* thrown.
|
||||
*
|
||||
* @param str The string to parse.
|
||||
* @param sourceStr The string to parse.
|
||||
*
|
||||
* @return The parsed <code>Number</code>
|
||||
*
|
||||
|
@ -610,8 +610,8 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
* <code>Double</code>. If no number can be parsed, no exception is
|
||||
* thrown. Instead, the parse position remains at its initial index.
|
||||
*
|
||||
* @param str The string to parse.
|
||||
* @param pp The desired <code>ParsePosition</code>.
|
||||
* @param sourceStr The string to parse.
|
||||
* @param pos The desired <code>ParsePosition</code>.
|
||||
*
|
||||
* @return The parsed <code>Object</code>
|
||||
*/
|
||||
|
@ -629,7 +629,7 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
* might appear as "1,000,000". (Both of these assume the US English
|
||||
* locale).
|
||||
*
|
||||
* @param groupingUsed <code>true</code> to enable grouping,
|
||||
* @param newValue <code>true</code> to enable grouping,
|
||||
* <code>false</code> to disable it.
|
||||
*/
|
||||
public void setGroupingUsed (boolean newValue)
|
||||
|
@ -643,11 +643,11 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
* current minimum allowed digits, the minimum allowed digits value will
|
||||
* be lowered to be equal to the new maximum allowed digits value.
|
||||
*
|
||||
* @param maximumFractionDigits The new maximum fraction digits value.
|
||||
* @param digits The new maximum fraction digits value.
|
||||
*/
|
||||
public void setMaximumFractionDigits (int newValue)
|
||||
public void setMaximumFractionDigits (int digits)
|
||||
{
|
||||
maximumFractionDigits = newValue;
|
||||
maximumFractionDigits = digits;
|
||||
if (getMinimumFractionDigits () > maximumFractionDigits)
|
||||
setMinimumFractionDigits (maximumFractionDigits);
|
||||
}
|
||||
|
@ -658,11 +658,11 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
* current minimum allowed digits, the minimum allowed digits value will
|
||||
* be lowered to be equal to the new maximum allowed digits value.
|
||||
*
|
||||
* @param maximumIntegerDigits The new maximum integer digits value.
|
||||
* @param digits The new maximum integer digits value.
|
||||
*/
|
||||
public void setMaximumIntegerDigits (int newValue)
|
||||
public void setMaximumIntegerDigits (int digits)
|
||||
{
|
||||
maximumIntegerDigits = newValue;
|
||||
maximumIntegerDigits = digits;
|
||||
if (getMinimumIntegerDigits () > maximumIntegerDigits)
|
||||
setMinimumIntegerDigits (maximumIntegerDigits);
|
||||
}
|
||||
|
@ -673,11 +673,11 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
* current maximum allowed digits, the maximum allowed digits value will
|
||||
* be raised to be equal to the new minimum allowed digits value.
|
||||
*
|
||||
* @param minimumFractionDigits The new minimum fraction digits value.
|
||||
* @param digits The new minimum fraction digits value.
|
||||
*/
|
||||
public void setMinimumFractionDigits (int newValue)
|
||||
public void setMinimumFractionDigits (int digits)
|
||||
{
|
||||
minimumFractionDigits = newValue;
|
||||
minimumFractionDigits = digits;
|
||||
if (getMaximumFractionDigits () < minimumFractionDigits)
|
||||
setMaximumFractionDigits (minimumFractionDigits);
|
||||
}
|
||||
|
@ -688,11 +688,11 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
* current maximum allowed digits, the maximum allowed digits value will
|
||||
* be raised to be equal to the new minimum allowed digits value.
|
||||
*
|
||||
* @param minimumIntegerDigits The new minimum integer digits value.
|
||||
* @param digits The new minimum integer digits value.
|
||||
*/
|
||||
public void setMinimumIntegerDigits (int newValue)
|
||||
public void setMinimumIntegerDigits (int digits)
|
||||
{
|
||||
minimumIntegerDigits = newValue;
|
||||
minimumIntegerDigits = digits;
|
||||
if (getMaximumIntegerDigits () < minimumIntegerDigits)
|
||||
setMaximumIntegerDigits (minimumIntegerDigits);
|
||||
}
|
||||
|
@ -701,7 +701,7 @@ public abstract class NumberFormat extends Format implements Cloneable
|
|||
* This method sets the parsing behavior of this object to parse only
|
||||
* integers or not.
|
||||
*
|
||||
* @param parseIntegerOnly <code>true</code> to parse only integers,
|
||||
* @param value <code>true</code> to parse only integers,
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public void setParseIntegerOnly (boolean value)
|
||||
|
|
|
@ -65,7 +65,7 @@ public class ParseException extends Exception
|
|||
* This method initializes a new instance of <code>ParseException</code>
|
||||
* with a detailed error message and a error position.
|
||||
*
|
||||
* @param msg the descriptive message describing the error
|
||||
* @param s the descriptive message describing the error
|
||||
* @param offset the position where the error was encountered
|
||||
*/
|
||||
public ParseException(String s, int offset)
|
||||
|
|
|
@ -180,8 +180,8 @@ public class SimpleDateFormat extends DateFormat
|
|||
* years to be interpreted as representing
|
||||
* the years between 2004 and 2104.
|
||||
*
|
||||
* @see get2DigitYearStart()
|
||||
* @see set2DigitYearStart(java.util.Date)
|
||||
* @see #get2DigitYearStart()
|
||||
* @see #set2DigitYearStart(java.util.Date)
|
||||
* @see Date
|
||||
* @serial The start date of the century for parsing two digit years.
|
||||
* May not be null.
|
||||
|
@ -192,8 +192,8 @@ public class SimpleDateFormat extends DateFormat
|
|||
* The year at which interpretation of two
|
||||
* digit years starts.
|
||||
*
|
||||
* @see get2DigitYearStart()
|
||||
* @see set2DigitYearStart(java.util.Date)
|
||||
* @see #get2DigitYearStart()
|
||||
* @see #set2DigitYearStart(java.util.Date)
|
||||
* @serial Ignored.
|
||||
*/
|
||||
private transient int defaultCentury;
|
||||
|
@ -204,10 +204,10 @@ public class SimpleDateFormat extends DateFormat
|
|||
* stored in standardChars. Localized patterns
|
||||
* are translated to this form.
|
||||
*
|
||||
* @see applyPattern(String)
|
||||
* @see applyLocalizedPattern(String)
|
||||
* @see toPattern()
|
||||
* @see toLocalizedPattern()
|
||||
* @see #applyPattern(String)
|
||||
* @see #applyLocalizedPattern(String)
|
||||
* @see #toPattern()
|
||||
* @see #toLocalizedPattern()
|
||||
* @serial The non-localized pattern string. May not be null.
|
||||
*/
|
||||
private String pattern;
|
||||
|
@ -294,44 +294,73 @@ public class SimpleDateFormat extends DateFormat
|
|||
int field;
|
||||
CompiledField current = null;
|
||||
|
||||
for (int i=0; i<pattern.length(); i++) {
|
||||
thisChar = pattern.charAt(i);
|
||||
field = standardChars.indexOf(thisChar);
|
||||
if (field == -1) {
|
||||
current = null;
|
||||
if ((thisChar >= 'A' && thisChar <= 'Z')
|
||||
|| (thisChar >= 'a' && thisChar <= 'z')) {
|
||||
// Not a valid letter
|
||||
throw new IllegalArgumentException("Invalid letter " + thisChar +
|
||||
"encountered at character " + i
|
||||
+ ".");
|
||||
} else if (thisChar == '\'') {
|
||||
// Quoted text section; skip to next single quote
|
||||
pos = pattern.indexOf('\'',i+1);
|
||||
if (pos == -1) {
|
||||
throw new IllegalArgumentException("Quotes starting at character "
|
||||
+ i + " not closed.");
|
||||
for (int i = 0; i < pattern.length(); i++)
|
||||
{
|
||||
thisChar = pattern.charAt(i);
|
||||
field = standardChars.indexOf(thisChar);
|
||||
if (field == -1)
|
||||
{
|
||||
current = null;
|
||||
if ((thisChar >= 'A' && thisChar <= 'Z')
|
||||
|| (thisChar >= 'a' && thisChar <= 'z'))
|
||||
{
|
||||
// Not a valid letter
|
||||
throw new IllegalArgumentException("Invalid letter "
|
||||
+ thisChar +
|
||||
"encountered at character "
|
||||
+ i + ".");
|
||||
}
|
||||
else if (thisChar == '\'')
|
||||
{
|
||||
// Quoted text section; skip to next single quote
|
||||
pos = pattern.indexOf('\'', i + 1);
|
||||
// First look for '' -- meaning a single quote.
|
||||
if (pos == i + 1)
|
||||
tokens.add("'");
|
||||
else
|
||||
{
|
||||
// Look for the terminating quote. However, if we
|
||||
// see a '', that represents a literal quote and
|
||||
// we must iterate.
|
||||
StringBuffer buf = new StringBuffer();
|
||||
int oldPos = i + 1;
|
||||
do
|
||||
{
|
||||
if (pos == -1)
|
||||
throw new IllegalArgumentException("Quotes starting at character "
|
||||
+ i +
|
||||
" not closed.");
|
||||
buf.append(pattern.substring(oldPos, pos));
|
||||
if (pos + 1 >= pattern.length()
|
||||
|| pattern.charAt(pos + 1) != '\'')
|
||||
break;
|
||||
buf.append('\'');
|
||||
oldPos = pos + 2;
|
||||
pos = pattern.indexOf('\'', pos + 2);
|
||||
}
|
||||
while (true);
|
||||
tokens.add(buf.toString());
|
||||
}
|
||||
i = pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
// A special character
|
||||
tokens.add(new Character(thisChar));
|
||||
}
|
||||
}
|
||||
if ((pos+1 < pattern.length()) && (pattern.charAt(pos+1) == '\'')) {
|
||||
tokens.add(pattern.substring(i+1,pos+1));
|
||||
} else {
|
||||
tokens.add(pattern.substring(i+1,pos));
|
||||
else
|
||||
{
|
||||
// A valid field
|
||||
if ((current != null) && (field == current.field))
|
||||
current.size++;
|
||||
else
|
||||
{
|
||||
current = new CompiledField(field, 1, thisChar);
|
||||
tokens.add(current);
|
||||
}
|
||||
}
|
||||
i = pos;
|
||||
} else {
|
||||
// A special character
|
||||
tokens.add(new Character(thisChar));
|
||||
}
|
||||
} else {
|
||||
// A valid field
|
||||
if ((current != null) && (field == current.field)) {
|
||||
current.size++;
|
||||
} else {
|
||||
current = new CompiledField(field,1,thisChar);
|
||||
tokens.add(current);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -611,7 +640,7 @@ public class SimpleDateFormat extends DateFormat
|
|||
* <li>Is using the same century for two digit years.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param obj The object to compare for equality against.
|
||||
* @param o The object to compare for equality against.
|
||||
*
|
||||
* @return <code>true</code> if the specified object is equal to this object,
|
||||
* <code>false</code> otherwise.
|
||||
|
|
|
@ -76,7 +76,10 @@ public final class StringCharacterIterator implements CharacterIterator
|
|||
* text of the specified <code>String</code>. The initial index
|
||||
* value will be set to the first character in the string.
|
||||
*
|
||||
* @param text The <code>String</code> to iterate through.
|
||||
* @param text The <code>String</code> to iterate through (<code>null</code>
|
||||
* not permitted).
|
||||
*
|
||||
* @throws NullPointerException if <code>text</code> is <code>null</code>.
|
||||
*/
|
||||
public StringCharacterIterator (String text)
|
||||
{
|
||||
|
@ -113,7 +116,7 @@ public final class StringCharacterIterator implements CharacterIterator
|
|||
* @param end The ending position in the character range.
|
||||
* @param index The initial index position.
|
||||
*
|
||||
* @param IllegalArgumentException If any of the range values are
|
||||
* @throws IllegalArgumentException If any of the range values are
|
||||
* invalid.
|
||||
*/
|
||||
public StringCharacterIterator (String text, int begin, int end, int index)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue