Imported GNU Classpath 0.19 + gcj-import-20051115.

* sources.am: Regenerated.
       * Makefile.in: Likewise.
       * scripts/makemake.tcl: Use glob -nocomplain.

From-SVN: r107049
This commit is contained in:
Mark Wielaard 2005-11-15 23:20:01 +00:00
parent 02e549bfaa
commit 8f523f3a10
1241 changed files with 97711 additions and 25284 deletions

View file

@ -49,7 +49,7 @@ 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.
* information via the <code>AttributedCharacterIterator</code> interface.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
@ -166,16 +166,16 @@ public class AttributedString
*
* @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 begin The beginning index of the text subrange.
* @param end 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)
public AttributedString(AttributedCharacterIterator aci, int begin, int end,
AttributedCharacterIterator.Attribute[] attributes)
{
// Validate some arguments
if ((begin_index < 0) || (end_index < begin_index))
if ((begin < 0) || (end < begin) || end > aci.getEndIndex())
throw new IllegalArgumentException("Bad index values");
StringBuffer sb = new StringBuffer("");
@ -186,7 +186,7 @@ public class AttributedString
all_attribs.retainAll(Arrays.asList(attributes));
// Loop through and extract the attributes
char c = aci.setIndex(begin_index);
char c = aci.setIndex(begin);
ArrayList accum = new ArrayList();
do
@ -209,28 +209,28 @@ public class AttributedString
int rl = aci.getRunLimit(attrib);
if (rl == -1)
continue;
if (rl > end_index)
rl = end_index;
rl -= begin_index;
if (rl > end)
rl = end;
rl -= begin;
// Check to see if we already processed this one
int rs = aci.getRunStart(attrib);
if ((rs < aci.getIndex()) && (aci.getIndex() != begin_index))
if ((rs < aci.getIndex()) && (aci.getIndex() != begin))
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 (rs < begin)
{
if (attrib_obj instanceof Annotation)
continue;
rs = begin_index;
rs = begin;
}
else
{
rs -= begin_index;
rs -= begin;
}
// Create a map object. Yes this will only contain one attribute
@ -269,22 +269,23 @@ public class AttributedString
*
* @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.
* @param begin The beginning index of the subrange.
* @param end 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)
Object value, int begin, int end)
{
if (attrib == null)
throw new IllegalArgumentException("null attribute");
if (end <= begin)
throw new IllegalArgumentException("Requires end > begin");
HashMap hm = new HashMap();
hm.put(attrib, value);
addAttributes(hm, begin_index, end_index);
addAttributes(hm, begin, end);
}
/**
@ -295,16 +296,17 @@ public class AttributedString
* @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.
* @throws NullPointerException if <code>attributes</code> is
* <code>null</code>.
* @throws IllegalArgumentException if the subrange is not valid.
*/
public void addAttributes(Map attributes, int begin_index, int end_index)
{
if (attributes == null)
throw new IllegalArgumentException("null attribute");
throw new NullPointerException("null attribute");
if ((begin_index < 0) || (end_index > sci.getEndIndex()) ||
(end_index < begin_index))
(end_index <= begin_index))
throw new IllegalArgumentException("bad range");
AttributeRange[] new_list = new AttributeRange[attribs.length + 1];

View file

@ -188,30 +188,44 @@ class AttributedStringIterator implements AttributedCharacterIterator
return(getRunLimit(s));
}
public synchronized int getRunLimit(Set attribute_set)
public synchronized int getRunLimit(Set attributeSet)
{
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
if (attributeSet == null)
return ci.getEndIndex();
int current = ci.getIndex();
int end = ci.getEndIndex();
int limit = current;
if (current == end)
return end;
Map runValues = getAttributes();
while (limit < end)
{
Iterator iterator = attributeSet.iterator();
while (iterator.hasNext())
{
// Qualified name is a workaround for a gcj 4.0 bug.
AttributedCharacterIterator.Attribute attributeKey
= (AttributedCharacterIterator.Attribute) iterator.next();
Object v1 = runValues.get(attributeKey);
Object v2 = getAttribute(attributeKey, limit + 1);
boolean changed = false;
// check for equal or both null, if NO return start
if (v1 != null)
{
changed = !v1.equals(v2);
}
else
{
changed = (v2 != null);
}
if (changed)
return limit + 1;
}
// no differences, so increment limit and next and loop again
limit++;
}
return end;
}
/*************************************************************************/
@ -221,69 +235,128 @@ class AttributedStringIterator implements AttributedCharacterIterator
* attribute combinations.
*/
/**
* Returns the index of the first character in the run containing the current
* character and defined by all the attributes defined for that character
* position.
*
* @return The run start index.
*/
public int getRunStart()
{
return(getRunStart(getAttributes().keySet()));
}
/**
* Returns the index of the first character in the run, defined by the
* specified attribute, that contains the current character.
*
* @param attrib the attribute (<code>null</code> permitted).
*
* return The index of the first character in the run.
*/
public int getRunStart(AttributedCharacterIterator.Attribute attrib)
{
if (attrib == null)
return ci.getBeginIndex();
HashSet s = new HashSet();
s.add(attrib);
return(getRunStart(s));
}
public int getRunStart(Set attribute_set)
/**
* Returns the index of the first character in the run, defined by the
* specified attribute set, that contains the current character.
*
* @param attributeSet the attribute set (<code>null</code> permitted).
*
* return The index of the first character in the run.
*/
public int getRunStart(Set attributeSet)
{
boolean hit = false;
int runBegin = 0;
int pos = ci.getIndex();
for (int i = 0; i < attribs.length; ++i)
if (attributeSet == null)
return ci.getBeginIndex();
int current = ci.getIndex();
int begin = ci.getBeginIndex();
int start = current;
if (start == begin)
return begin;
Map runValues = getAttributes();
int prev = start - 1;
while (start > begin)
{
Iterator iterator = attributeSet.iterator();
while (iterator.hasNext())
{
if (pos >= attribs[i].begin_index &&
pos <= attribs[i].end_index)
// Qualified name is a workaround for a gcj 4.0 bug.
AttributedCharacterIterator.Attribute attributeKey
= (AttributedCharacterIterator.Attribute) iterator.next();
Object v1 = runValues.get(attributeKey);
Object v2 = getAttribute(attributeKey, prev);
boolean changed = false;
// check for equal or both null, if NO return start
if (v1 != null)
{
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);
}
changed = !v1.equals(v2);
}
else
{
changed = (v2 != null);
}
if (changed)
return start;
}
if (hit)
return runBegin;
else
return -1;
// no differences, so decrement start and prev and loop again
start--;
prev--;
}
return start;
}
/*************************************************************************/
public Object getAttribute(AttributedCharacterIterator.Attribute attrib)
/**
* Returns the value for an attribute at the specified position. If the
* attribute key (<code>key</code>) is <code>null</code>, the method returns
* <code>null</code>.
*
* @param key the key (<code>null</code> permitted).
* @param pos the character position.
*
* @return The attribute value (possibly <code>null</code>).
*/
private Object getAttribute(AttributedCharacterIterator.Attribute key,
int pos)
{
if (attribs == null)
return(null);
for (int i = 0; i < attribs.length; i++)
return null;
for (int i = attribs.length - 1; i >= 0; i--)
{
Set key_set = attribs[i].attribs.keySet();
Iterator iter = key_set.iterator();
while (iter.hasNext())
if (pos >= attribs[i].begin_index && pos < attribs[i].end_index)
{
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));
Set keys = attribs[i].attribs.keySet();
if (keys.contains(key))
{
return attribs[i].attribs.get(key);
}
}
}
return(null);
return null;
}
/**
* Returns the value for an attribute at the current position. If the
* attribute key (<code>key</code>) is <code>null</code>, the method returns
* <code>null</code>.
*
* @param key the key (<code>null</code> permitted).
*
* @return The attribute value (possibly <code>null</code>).
*/
public Object getAttribute(AttributedCharacterIterator.Attribute key)
{
return getAttribute(key, ci.getIndex());
}
/*************************************************************************/

View file

@ -68,7 +68,7 @@ public interface CharacterIterator extends Cloneable
* <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
* or {@link #DONE} if the index has reached getEndIndex() - 1
*/
char next();

View file

@ -58,6 +58,9 @@ import java.util.TimeZone;
public abstract class DateFormat extends Format implements Cloneable
{
private static final long serialVersionUID = 7218322306649953788L;
// Names fixed by serialization spec.
protected Calendar calendar;
protected NumberFormat numberFormat;

View file

@ -136,6 +136,15 @@ public class ParsePosition
ParsePosition other = (ParsePosition) obj;
return index == other.index && error_index == other.error_index;
}
/**
* Return the hash code for this object.
* @return the hash code
*/
public int hashCode()
{
return index ^ error_index;
}
/**
* This method returns a <code>String</code> representation of this

View file

@ -510,7 +510,7 @@ main_parse_loop:
int idx;
// Parse the subrules but do not iterate through all
// sublist. This is the priviledge of the first call.
// sublist. This is the privilege of the first call.
idx = subParseString(true, sorted_rules, base_offset+i, subrules);
// Merge new parsed rules into the list.

View file

@ -143,7 +143,7 @@ public final class StringCharacterIterator implements CharacterIterator
* an existing StringCharacterIterator and resets the beginning and
* ending index.
*
* @param scci The StringCharacterIterator to copy the info from
* @param sci The StringCharacterIterator to copy the info from
* @param begin The beginning index of the range we are interested in.
* @param end The ending index of the range we are interested in.
*/
@ -340,6 +340,16 @@ public final class StringCharacterIterator implements CharacterIterator
&& index == sci.index
&& text.equals (sci.text));
}
/**
* Return the hash code for this object.
* @return the hash code
*/
public int hashCode()
{
// Incorporate all the data in a goofy way.
return begin ^ end ^ index ^ text.hashCode();
}
/*************************************************************************/