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:
Tom Tromey 2005-09-23 21:31:04 +00:00
parent 9b044d1951
commit 1ea63ef8be
544 changed files with 34724 additions and 14512 deletions

View file

@ -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