Import GNU Classpath (20121202).
2012-12-19 Matthias Klose <doko@ubuntu.com> Import GNU Classpath (20121202). * Regenerate class and header files. * Regenerate auto* files. * sources.am, gcj/javaprims.h: Regenerate. * gnu/java/nio/FileLockImpl.java (close): New override. From-SVN: r194618
This commit is contained in:
@@ -88,6 +88,11 @@ public final class FileLockImpl extends FileLock
|
||||
return valid;
|
||||
}
|
||||
|
||||
public void close() throws Exception
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases the lock if it is still valid. Marks this lock as invalid.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* AttributedFormatBuffer.java -- Implements an attributed FormatBuffer.
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004, 2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -41,6 +41,10 @@ import gnu.java.lang.CPStringBuilder;
|
||||
import java.text.AttributedCharacterIterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.text.AttributedCharacterIterator.Attribute;
|
||||
|
||||
/**
|
||||
* This class is an implementation of a FormatBuffer with attributes.
|
||||
@@ -53,12 +57,12 @@ import java.util.HashMap;
|
||||
public class AttributedFormatBuffer implements FormatBuffer
|
||||
{
|
||||
private final CPStringBuilder buffer;
|
||||
private final ArrayList ranges;
|
||||
private final ArrayList attributes;
|
||||
private int[] a_ranges;
|
||||
private HashMap[] a_attributes;
|
||||
private final ArrayList<Integer> ranges;
|
||||
private final ArrayList<Map<Attribute,Object>> attributes;
|
||||
private int[] aRanges;
|
||||
private List<Map<Attribute,Object>> aAttributes;
|
||||
private int startingRange;
|
||||
AttributedCharacterIterator.Attribute defaultAttr;
|
||||
Attribute defaultAttr;
|
||||
|
||||
/**
|
||||
* This constructor accepts a StringBuffer. If the buffer contains
|
||||
@@ -67,8 +71,8 @@ public class AttributedFormatBuffer implements FormatBuffer
|
||||
public AttributedFormatBuffer(CPStringBuilder buffer)
|
||||
{
|
||||
this.buffer = new CPStringBuilder(buffer);
|
||||
this.ranges = new ArrayList();
|
||||
this.attributes = new ArrayList();
|
||||
this.ranges = new ArrayList<Integer>();
|
||||
this.attributes = new ArrayList<Map<Attribute,Object>>();
|
||||
this.defaultAttr = null;
|
||||
if (buffer.length() != 0)
|
||||
{
|
||||
@@ -94,23 +98,23 @@ public class AttributedFormatBuffer implements FormatBuffer
|
||||
* and attributes it adds exactly one attribute for the range of characters
|
||||
* comprised between the last entry in 'ranges' and the specified new range.
|
||||
*
|
||||
* @param new_range A new range to insert in the list.
|
||||
* @param newRange A new range to insert in the list.
|
||||
* @param attr A new attribute to insert in the list.
|
||||
*/
|
||||
private final void addAttribute(int new_range, AttributedCharacterIterator.Attribute attr)
|
||||
private final void addAttribute(int newRange, Attribute attr)
|
||||
{
|
||||
HashMap map;
|
||||
Map<Attribute,Object> map;
|
||||
|
||||
if (attr != null)
|
||||
{
|
||||
map = new HashMap();
|
||||
map = new HashMap<Attribute,Object>();
|
||||
map.put(attr, attr);
|
||||
attributes.add(map);
|
||||
}
|
||||
else
|
||||
attributes.add(null);
|
||||
|
||||
ranges.add(new Integer(new_range));
|
||||
ranges.add(Integer.valueOf(newRange));
|
||||
}
|
||||
|
||||
public void append(String s)
|
||||
@@ -120,7 +124,7 @@ public class AttributedFormatBuffer implements FormatBuffer
|
||||
buffer.append(s);
|
||||
}
|
||||
|
||||
public void append(String s, AttributedCharacterIterator.Attribute attr)
|
||||
public void append(String s, Attribute attr)
|
||||
{
|
||||
setDefaultAttribute(attr);
|
||||
startingRange = buffer.length();
|
||||
@@ -128,7 +132,7 @@ public class AttributedFormatBuffer implements FormatBuffer
|
||||
setDefaultAttribute(null);
|
||||
}
|
||||
|
||||
public void append(String s, int[] ranges, HashMap[] attrs)
|
||||
public void append(String s, int[] ranges, List<Map<Attribute,Object>> attrs)
|
||||
{
|
||||
int curPos = buffer.length();
|
||||
|
||||
@@ -137,8 +141,8 @@ public class AttributedFormatBuffer implements FormatBuffer
|
||||
{
|
||||
for (int i = 0; i < ranges.length; i++)
|
||||
{
|
||||
this.ranges.add(new Integer(ranges[i] + curPos));
|
||||
this.attributes.add(attrs[i]);
|
||||
this.ranges.add(Integer.valueOf(ranges[i] + curPos));
|
||||
this.attributes.add(attrs.get(i));
|
||||
}
|
||||
}
|
||||
startingRange = buffer.length();
|
||||
@@ -152,14 +156,14 @@ public class AttributedFormatBuffer implements FormatBuffer
|
||||
buffer.append(c);
|
||||
}
|
||||
|
||||
public void append(char c, AttributedCharacterIterator.Attribute attr)
|
||||
public void append(char c, Attribute attr)
|
||||
{
|
||||
setDefaultAttribute(attr);
|
||||
buffer.append(c);
|
||||
setDefaultAttribute(null);
|
||||
}
|
||||
|
||||
public void setDefaultAttribute(AttributedCharacterIterator.Attribute attr)
|
||||
public void setDefaultAttribute(Attribute attr)
|
||||
{
|
||||
if (attr == defaultAttr)
|
||||
return;
|
||||
@@ -174,7 +178,7 @@ public class AttributedFormatBuffer implements FormatBuffer
|
||||
startingRange = currentPos;
|
||||
}
|
||||
|
||||
public AttributedCharacterIterator.Attribute getDefaultAttribute()
|
||||
public Attribute getDefaultAttribute()
|
||||
{
|
||||
return defaultAttr;
|
||||
}
|
||||
@@ -209,12 +213,11 @@ public class AttributedFormatBuffer implements FormatBuffer
|
||||
|
||||
addAttribute(buffer.length(), defaultAttr);
|
||||
|
||||
a_ranges = new int[ranges.size()];
|
||||
for (int i = 0; i < a_ranges.length; i++)
|
||||
a_ranges[i] = ((Integer)(ranges.get (i))).intValue();
|
||||
aRanges = new int[ranges.size()];
|
||||
for (int i = 0; i < aRanges.length; i++)
|
||||
aRanges[i] = ranges.get (i).intValue();
|
||||
|
||||
a_attributes = new HashMap[attributes.size()];
|
||||
System.arraycopy(attributes.toArray(), 0, a_attributes, 0, a_attributes.length);
|
||||
aAttributes = new ArrayList<Map<Attribute,Object>>(attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,17 +238,17 @@ public class AttributedFormatBuffer implements FormatBuffer
|
||||
*/
|
||||
public int[] getRanges()
|
||||
{
|
||||
return a_ranges;
|
||||
return aRanges;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the array containing the map on the
|
||||
* attributes.
|
||||
*
|
||||
* @return An array of {@link java.util.Map} containing the attributes.
|
||||
* @return A {@link java.util.List} of {@link java.util.Map}s containing the attributes.
|
||||
*/
|
||||
public HashMap[] getAttributes()
|
||||
public List<Map<Attribute,Object>> getAttributes()
|
||||
{
|
||||
return a_attributes;
|
||||
return aAttributes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* FormatBuffer.java -- General interface to build attributed strings.
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004, 2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -37,7 +37,10 @@ exception statement from your version. */
|
||||
package gnu.java.text;
|
||||
|
||||
import java.text.AttributedCharacterIterator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.text.AttributedCharacterIterator.Attribute;
|
||||
|
||||
/**
|
||||
* This interface describes a modifiable buffer which contains attributed
|
||||
@@ -67,7 +70,7 @@ public interface FormatBuffer
|
||||
* @param s The string to append to the buffer.
|
||||
* @param attr Attribute to use for the string in the buffer.
|
||||
*/
|
||||
public void append(String s, AttributedCharacterIterator.Attribute attr);
|
||||
public void append(String s, Attribute attr);
|
||||
|
||||
/**
|
||||
* This method appends a simple string to the buffer. This part of
|
||||
@@ -79,7 +82,7 @@ public interface FormatBuffer
|
||||
* to the string.
|
||||
* @param attrs The attributes of the string in the buffer.
|
||||
*/
|
||||
public void append(String s, int[] ranges, HashMap[] attrs);
|
||||
public void append(String s, int[] ranges, List<Map<Attribute,Object>> attrs);
|
||||
|
||||
/**
|
||||
* This method appends a simple char to the buffer. This part of
|
||||
@@ -97,7 +100,7 @@ public interface FormatBuffer
|
||||
* @param c The character to append to the buffer.
|
||||
* @param attr Attribute to use for the character in the buffer.
|
||||
*/
|
||||
public void append(char c, AttributedCharacterIterator.Attribute attr);
|
||||
public void append(char c, Attribute attr);
|
||||
|
||||
/**
|
||||
* This method changes the current default attribute for the next string
|
||||
@@ -105,14 +108,14 @@ public interface FormatBuffer
|
||||
*
|
||||
* @param attr The attribute which will be used by default.
|
||||
*/
|
||||
public void setDefaultAttribute(AttributedCharacterIterator.Attribute attr);
|
||||
public void setDefaultAttribute(Attribute attr);
|
||||
|
||||
/**
|
||||
* This method returns the current default attribute for the buffer.
|
||||
*
|
||||
* @return The default attribute for the buffer.
|
||||
*/
|
||||
public AttributedCharacterIterator.Attribute getDefaultAttribute();
|
||||
public Attribute getDefaultAttribute();
|
||||
|
||||
/**
|
||||
* This method cuts the last characters of the buffer. The number of
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* FormatCharacter.java -- Implementation of AttributedCharacterIterator for
|
||||
formatters.
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -38,12 +38,15 @@ exception statement from your version. */
|
||||
package gnu.java.text;
|
||||
|
||||
import java.text.AttributedCharacterIterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
|
||||
import static java.text.AttributedCharacterIterator.Attribute;
|
||||
|
||||
/**
|
||||
* This class should not be put public and it is only intended to the
|
||||
@@ -62,7 +65,7 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
|
||||
private int charIndex;
|
||||
private int attributeIndex;
|
||||
private int[] ranges;
|
||||
private HashMap[] attributes;
|
||||
private List<Map<Attribute,Object>> attributes;
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
/**
|
||||
@@ -74,7 +77,7 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
|
||||
{
|
||||
formattedString = "";
|
||||
ranges = new int[0];
|
||||
attributes = new HashMap[0];
|
||||
attributes = new ArrayList<Map<Attribute,Object>>(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,12 +90,13 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
|
||||
* <pre>
|
||||
* s = "hello";
|
||||
* ranges = new int[] { 2, 6 };
|
||||
* attributes = new HashMap[2];
|
||||
* attributes = new ArrayList<Map<Attribute,Object>>(2);
|
||||
* </pre>
|
||||
* <code>"he"</code> will have the attributes <code>attributes[0]</code>,
|
||||
* <code>"llo"</code> the <code>attributes[1]</code>.
|
||||
* <code>"he"</code> will have the attributes <code>attributes.get(0)</code>,
|
||||
* <code>"llo"</code> the <code>attributes.get(1)</code>.
|
||||
*/
|
||||
public FormatCharacterIterator (String s, int[] ranges, HashMap[] attributes)
|
||||
public FormatCharacterIterator (String s, int[] ranges,
|
||||
List<Map<Attribute,Object>> attributes)
|
||||
{
|
||||
formattedString = s;
|
||||
this.ranges = ranges;
|
||||
@@ -104,55 +108,57 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
|
||||
* and thus are already documented.
|
||||
*/
|
||||
|
||||
public Set getAllAttributeKeys()
|
||||
public Set<Attribute> getAllAttributeKeys()
|
||||
{
|
||||
if (attributes != null && attributes[attributeIndex] != null)
|
||||
return attributes[attributeIndex].keySet();
|
||||
if (attributes != null && attributes.get(attributeIndex) != null)
|
||||
return attributes.get(attributeIndex).keySet();
|
||||
else
|
||||
return new HashSet();
|
||||
return new HashSet<Attribute>();
|
||||
}
|
||||
|
||||
public Map getAttributes()
|
||||
public Map<Attribute,Object> getAttributes()
|
||||
{
|
||||
if (attributes != null && attributes[attributeIndex] != null)
|
||||
return attributes[attributeIndex];
|
||||
if (attributes != null && attributes.get(attributeIndex) != null)
|
||||
return attributes.get(attributeIndex);
|
||||
else
|
||||
return new HashMap();
|
||||
return new HashMap<Attribute,Object>();
|
||||
}
|
||||
|
||||
public Object getAttribute (AttributedCharacterIterator.Attribute attrib)
|
||||
public Object getAttribute (Attribute attrib)
|
||||
{
|
||||
if (attributes != null && attributes[attributeIndex] != null)
|
||||
return attributes[attributeIndex].get (attrib);
|
||||
if (attributes != null && attributes.get(attributeIndex) != null)
|
||||
return attributes.get(attributeIndex).get (attrib);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getRunLimit(Set reqAttrs)
|
||||
public int getRunLimit(Set<? extends Attribute> reqAttrs)
|
||||
{
|
||||
if (attributes == null)
|
||||
return formattedString.length();
|
||||
|
||||
int currentAttrIndex = attributeIndex;
|
||||
Set newKeys;
|
||||
Set<Attribute> newKeys;
|
||||
|
||||
do
|
||||
{
|
||||
currentAttrIndex++;
|
||||
if (currentAttrIndex == attributes.length)
|
||||
if (currentAttrIndex == attributes.size())
|
||||
return formattedString.length();
|
||||
if (attributes[currentAttrIndex] == null)
|
||||
Map<Attribute,Object> currentAttr =
|
||||
attributes.get(currentAttrIndex);
|
||||
if (currentAttr == null)
|
||||
break;
|
||||
newKeys = attributes[currentAttrIndex].keySet();
|
||||
newKeys = currentAttr.keySet();
|
||||
}
|
||||
while (newKeys.containsAll (reqAttrs));
|
||||
|
||||
return ranges[currentAttrIndex-1];
|
||||
}
|
||||
|
||||
public int getRunLimit (AttributedCharacterIterator.Attribute attribute)
|
||||
public int getRunLimit (Attribute attribute)
|
||||
{
|
||||
Set s = new HashSet();
|
||||
Set<Attribute> s = new HashSet<Attribute>();
|
||||
|
||||
s.add (attribute);
|
||||
return getRunLimit (s);
|
||||
@@ -162,24 +168,24 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
|
||||
{
|
||||
if (attributes == null)
|
||||
return formattedString.length();
|
||||
if (attributes[attributeIndex] == null)
|
||||
if (attributes.get(attributeIndex) == null)
|
||||
{
|
||||
for (int i=attributeIndex+1;i<attributes.length;i++)
|
||||
if (attributes[i] != null)
|
||||
for (int i=attributeIndex+1;i<attributes.size();i++)
|
||||
if (attributes.get(i) != null)
|
||||
return ranges[i-1];
|
||||
return formattedString.length();
|
||||
}
|
||||
|
||||
return getRunLimit (attributes[attributeIndex].keySet());
|
||||
return getRunLimit (attributes.get(attributeIndex).keySet());
|
||||
}
|
||||
|
||||
public int getRunStart (Set reqAttrs)
|
||||
public int getRunStart (Set<? extends Attribute> reqAttrs)
|
||||
{
|
||||
if (attributes == null)
|
||||
return formattedString.length();
|
||||
|
||||
int currentAttrIndex = attributeIndex;
|
||||
Set newKeys = null;
|
||||
Set<Attribute> newKeys = null;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -187,9 +193,11 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
|
||||
return 0;
|
||||
|
||||
currentAttrIndex--;
|
||||
if (attributes[currentAttrIndex] == null)
|
||||
Map<Attribute,Object> currentAttr =
|
||||
attributes.get(currentAttrIndex);
|
||||
if (currentAttr == null)
|
||||
break;
|
||||
newKeys = attributes[currentAttrIndex].keySet();
|
||||
newKeys = currentAttr.keySet();
|
||||
}
|
||||
while (newKeys.containsAll (reqAttrs));
|
||||
|
||||
@@ -201,20 +209,21 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
|
||||
if (attributes == null)
|
||||
return 0;
|
||||
|
||||
if (attributes[attributeIndex] == null)
|
||||
Map<Attribute,Object> attrib = attributes.get(attributeIndex);
|
||||
if (attrib == null)
|
||||
{
|
||||
for (int i=attributeIndex;i>0;i--)
|
||||
if (attributes[i] != null)
|
||||
if (attributes.get(i) != null)
|
||||
return ranges[attributeIndex-1];
|
||||
return 0;
|
||||
}
|
||||
|
||||
return getRunStart (attributes[attributeIndex].keySet());
|
||||
return getRunStart (attrib.keySet());
|
||||
}
|
||||
|
||||
public int getRunStart (AttributedCharacterIterator.Attribute attribute)
|
||||
public int getRunStart (Attribute attribute)
|
||||
{
|
||||
Set s = new HashSet();
|
||||
Set<Attribute> s = new HashSet<Attribute>();
|
||||
|
||||
s.add (attribute);
|
||||
return getRunStart (s);
|
||||
@@ -261,7 +270,7 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
|
||||
{
|
||||
charIndex = formattedString.length()-1;
|
||||
if (attributes != null)
|
||||
attributeIndex = attributes.length-1;
|
||||
attributeIndex = attributes.size()-1;
|
||||
return formattedString.charAt (charIndex);
|
||||
}
|
||||
|
||||
@@ -306,7 +315,7 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
|
||||
charIndex = position;
|
||||
if (attributes != null)
|
||||
{
|
||||
for (attributeIndex=0;attributeIndex<attributes.length;
|
||||
for (attributeIndex=0;attributeIndex<attributes.size();
|
||||
attributeIndex++)
|
||||
if (ranges[attributeIndex] > charIndex)
|
||||
break;
|
||||
@@ -327,40 +336,42 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
|
||||
*
|
||||
* @param attributes the new array attributes to apply to the string.
|
||||
*/
|
||||
public void mergeAttributes (HashMap[] attributes, int[] ranges)
|
||||
public void mergeAttributes (List<Map<Attribute,Object>> attributes,
|
||||
int[] ranges)
|
||||
{
|
||||
Vector new_ranges = new Vector();
|
||||
Vector new_attributes = new Vector();
|
||||
List<Integer> newRanges = new ArrayList<Integer>();
|
||||
List<Map<Attribute,Object>> newAttributes =
|
||||
new ArrayList<Map<Attribute,Object>>();
|
||||
int i = 0, j = 0;
|
||||
|
||||
debug("merging " + attributes.length + " attrs");
|
||||
debug("merging " + attributes.size() + " attrs");
|
||||
|
||||
while (i < this.ranges.length && j < ranges.length)
|
||||
{
|
||||
if (this.attributes[i] != null)
|
||||
if (this.attributes.get(i) != null)
|
||||
{
|
||||
new_attributes.add (this.attributes[i]);
|
||||
if (attributes[j] != null)
|
||||
this.attributes[i].putAll (attributes[j]);
|
||||
newAttributes.add (this.attributes.get(i));
|
||||
if (attributes.get(j) != null)
|
||||
this.attributes.get(i).putAll (attributes.get(j));
|
||||
}
|
||||
else
|
||||
{
|
||||
new_attributes.add (attributes[j]);
|
||||
newAttributes.add (attributes.get(j));
|
||||
}
|
||||
if (this.ranges[i] == ranges[j])
|
||||
{
|
||||
new_ranges.add (new Integer (ranges[j]));
|
||||
newRanges.add (Integer.valueOf (ranges[j]));
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
else if (this.ranges[i] < ranges[j])
|
||||
{
|
||||
new_ranges.add (new Integer (this.ranges[i]));
|
||||
newRanges.add (Integer.valueOf (this.ranges[i]));
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_ranges.add (new Integer (ranges[j]));
|
||||
newRanges.add (Integer.valueOf (ranges[j]));
|
||||
j++;
|
||||
}
|
||||
}
|
||||
@@ -369,27 +380,25 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
|
||||
{
|
||||
for (;i<this.ranges.length;i++)
|
||||
{
|
||||
new_attributes.add (this.attributes[i]);
|
||||
new_ranges.add (new Integer (this.ranges[i]));
|
||||
newAttributes.add (this.attributes.get(i));
|
||||
newRanges.add (Integer.valueOf (this.ranges[i]));
|
||||
}
|
||||
}
|
||||
if (j != ranges.length)
|
||||
{
|
||||
for (;j<ranges.length;j++)
|
||||
{
|
||||
new_attributes.add (attributes[j]);
|
||||
new_ranges.add (new Integer (ranges[j]));
|
||||
newAttributes.add (attributes.get(j));
|
||||
newRanges.add (Integer.valueOf (ranges[j]));
|
||||
}
|
||||
}
|
||||
|
||||
this.attributes = new HashMap[new_attributes.size()];
|
||||
this.ranges = new int[new_ranges.size()];
|
||||
System.arraycopy (new_attributes.toArray(), 0, this.attributes,
|
||||
0, this.attributes.length);
|
||||
this.attributes = newAttributes;
|
||||
this.ranges = new int[newRanges.size()];
|
||||
|
||||
for (i=0;i<new_ranges.size();i++)
|
||||
for (i=0;i<newRanges.size();i++)
|
||||
{
|
||||
this.ranges[i] = ((Integer)new_ranges.elementAt (i)).intValue();
|
||||
this.ranges[i] = newRanges.get (i).intValue();
|
||||
}
|
||||
|
||||
dumpTable();
|
||||
@@ -405,35 +414,35 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
|
||||
public void append (AttributedCharacterIterator iterator)
|
||||
{
|
||||
char c = iterator.first();
|
||||
Vector more_ranges = new Vector();
|
||||
Vector more_attributes = new Vector();
|
||||
List<Integer> moreRanges = new ArrayList<Integer>();
|
||||
List<Map<Attribute,Object>> moreAttributes =
|
||||
new ArrayList<Map<Attribute,Object>>();
|
||||
|
||||
do
|
||||
{
|
||||
formattedString = formattedString + String.valueOf (c);
|
||||
// TODO: Reduce the size of the output array.
|
||||
more_attributes.add (iterator.getAttributes());
|
||||
more_ranges.add (new Integer (formattedString.length()));
|
||||
moreAttributes.add (iterator.getAttributes());
|
||||
moreRanges.add (Integer.valueOf (formattedString.length()));
|
||||
// END TOOD
|
||||
c = iterator.next();
|
||||
}
|
||||
while (c != DONE);
|
||||
|
||||
HashMap[] new_attributes = new HashMap[attributes.length
|
||||
+ more_attributes.size()];
|
||||
int[] new_ranges = new int[ranges.length + more_ranges.size()];
|
||||
List<Map<Attribute,Object>> newAttributes =
|
||||
new ArrayList<Map<Attribute,Object>>(attributes.size() + moreAttributes.size());
|
||||
int[] newRanges = new int[ranges.length + moreRanges.size()];
|
||||
|
||||
System.arraycopy (attributes, 0, new_attributes, 0, attributes.length);
|
||||
System.arraycopy (more_attributes.toArray(), 0, new_attributes,
|
||||
attributes.length, more_attributes.size());
|
||||
newAttributes.addAll(attributes);
|
||||
newAttributes.addAll(moreAttributes);
|
||||
|
||||
System.arraycopy (ranges, 0, new_ranges, 0, ranges.length);
|
||||
Object[] new_ranges_array = more_ranges.toArray();
|
||||
for (int i = 0; i < more_ranges.size();i++)
|
||||
new_ranges[i+ranges.length] = ((Integer) new_ranges_array[i]).intValue();
|
||||
System.arraycopy (ranges, 0, newRanges, 0, ranges.length);
|
||||
Integer[] newRangesArray = moreRanges.toArray(new Integer[moreRanges.size()]);
|
||||
for (int i = 0; i < moreRanges.size();i++)
|
||||
newRanges[i+ranges.length] = newRangesArray[i].intValue();
|
||||
|
||||
attributes = new_attributes;
|
||||
ranges = new_ranges;
|
||||
attributes = newAttributes;
|
||||
ranges = newRanges;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -441,28 +450,29 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
|
||||
* directly in the calling parameters.
|
||||
*
|
||||
* @param text The string to append.
|
||||
* @param local_attributes The attributes to put on this string in the
|
||||
* @param localAttributes The attributes to put on this string in the
|
||||
* iterator. If it is <code>null</code> the string will simply have no
|
||||
* attributes.
|
||||
*/
|
||||
public void append (String text, HashMap local_attributes)
|
||||
public void append (String text, HashMap<? extends Attribute,? extends Object> localAttributes)
|
||||
{
|
||||
int[] new_ranges = new int[ranges.length+1];
|
||||
HashMap[] new_attributes = new HashMap[attributes.length+1];
|
||||
int[] newRanges = new int[ranges.length+1];
|
||||
List<Map<Attribute,Object>> newAttributes =
|
||||
new ArrayList<Map<Attribute,Object>>(attributes.size()+1);
|
||||
|
||||
formattedString += text;
|
||||
System.arraycopy (attributes, 0, new_attributes, 0, attributes.length);
|
||||
System.arraycopy (ranges, 0, new_ranges, 0, ranges.length);
|
||||
new_ranges[ranges.length] = formattedString.length();
|
||||
new_attributes[attributes.length] = local_attributes;
|
||||
newAttributes.addAll(attributes);
|
||||
System.arraycopy (ranges, 0, newRanges, 0, ranges.length);
|
||||
newRanges[ranges.length] = formattedString.length();
|
||||
newAttributes.add(new HashMap<Attribute,Object>(localAttributes));
|
||||
|
||||
ranges = new_ranges;
|
||||
attributes = new_attributes;
|
||||
ranges = newRanges;
|
||||
attributes = newAttributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method appends a string without attributes. It is completely
|
||||
* equivalent to call {@link #append(String,HashMap)} with local_attributes
|
||||
* equivalent to call {@link #append(String,HashMap)} with localAttributes
|
||||
* equal to <code>null</code>.
|
||||
*
|
||||
* @param text The string to append to the iterator.
|
||||
@@ -475,22 +485,31 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
|
||||
/**
|
||||
* This method adds a set of attributes to a range of character. The
|
||||
* bounds are always inclusive. In the case many attributes have to
|
||||
* be added it is advised to directly use {@link #mergeAttributes([Ljava.util.HashMap;[I}
|
||||
* be added it is advised to directly use {@link #mergeAttributes(java.util.List;[I}
|
||||
*
|
||||
* @param attributes Attributes to merge into the iterator.
|
||||
* @param range_start Lower bound of the range of characters which will receive the
|
||||
* @param rangeStart Lower bound of the range of characters which will receive the
|
||||
* attribute.
|
||||
* @param range_end Upper bound of the range of characters which will receive the
|
||||
* @param rangeEnd Upper bound of the range of characters which will receive the
|
||||
* attribute.
|
||||
*
|
||||
* @throws IllegalArgumentException if ranges are out of bounds.
|
||||
*/
|
||||
public void addAttributes(HashMap attributes, int range_start, int range_end)
|
||||
public void addAttributes(Map<? extends Attribute,? extends Object> attributes,
|
||||
int rangeStart, int rangeEnd)
|
||||
{
|
||||
if (range_start == 0)
|
||||
mergeAttributes(new HashMap[] { attributes }, new int[] { range_end });
|
||||
List<Map<Attribute,Object>> mergeAttribs = new ArrayList<Map<Attribute,Object>>();
|
||||
int[] mergeRanges;
|
||||
|
||||
if (rangeStart == 0)
|
||||
mergeRanges = new int[] { rangeEnd };
|
||||
else
|
||||
mergeAttributes(new HashMap[] { null, attributes }, new int[] { range_start, range_end });
|
||||
{
|
||||
mergeRanges = new int[] { rangeStart, rangeEnd };
|
||||
mergeAttribs.add(null);
|
||||
}
|
||||
mergeAttribs.add(new HashMap<Attribute,Object>(attributes));
|
||||
mergeAttributes(mergeAttribs, mergeRanges);
|
||||
}
|
||||
|
||||
private void debug(String s)
|
||||
@@ -501,7 +520,7 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
|
||||
|
||||
private void dumpTable()
|
||||
{
|
||||
int start_range = 0;
|
||||
int startRange = 0;
|
||||
|
||||
if (!DEBUG)
|
||||
return;
|
||||
@@ -509,15 +528,15 @@ public class FormatCharacterIterator implements AttributedCharacterIterator
|
||||
System.out.println("Dumping internal table:");
|
||||
for (int i = 0; i < ranges.length; i++)
|
||||
{
|
||||
System.out.print("\t" + start_range + " => " + ranges[i] + ":");
|
||||
if (attributes[i] == null)
|
||||
System.out.print("\t" + startRange + " => " + ranges[i] + ":");
|
||||
if (attributes.get(i) == null)
|
||||
System.out.println("null");
|
||||
else
|
||||
{
|
||||
Set keyset = attributes[i].keySet();
|
||||
Set<Attribute> keyset = attributes.get(i).keySet();
|
||||
if (keyset != null)
|
||||
{
|
||||
Iterator keys = keyset.iterator();
|
||||
Iterator<Attribute> keys = keyset.iterator();
|
||||
|
||||
while (keys.hasNext())
|
||||
System.out.print(" " + keys.next());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* StringFormatBuffer.java -- Implements FormatBuffer using StringBuffer.
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004, 2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -37,7 +37,10 @@ exception statement from your version. */
|
||||
package gnu.java.text;
|
||||
|
||||
import java.text.AttributedCharacterIterator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.text.AttributedCharacterIterator.Attribute;
|
||||
|
||||
/**
|
||||
* This class is an implementation of a FormatBuffer without attributes.
|
||||
@@ -48,7 +51,7 @@ import java.util.HashMap;
|
||||
public class StringFormatBuffer implements FormatBuffer
|
||||
{
|
||||
private final StringBuffer buffer;
|
||||
private AttributedCharacterIterator.Attribute defaultAttr;
|
||||
private Attribute defaultAttr;
|
||||
|
||||
public StringFormatBuffer(int prebuffer)
|
||||
{
|
||||
@@ -65,12 +68,12 @@ public class StringFormatBuffer implements FormatBuffer
|
||||
buffer.append(s);
|
||||
}
|
||||
|
||||
public void append(String s, AttributedCharacterIterator.Attribute attr)
|
||||
public void append(String s, Attribute attr)
|
||||
{
|
||||
buffer.append(s);
|
||||
}
|
||||
|
||||
public void append(String s, int[] ranges, HashMap[] attrs)
|
||||
public void append(String s, int[] ranges, List<Map<Attribute,Object>> attrs)
|
||||
{
|
||||
buffer.append(s);
|
||||
}
|
||||
@@ -80,17 +83,17 @@ public class StringFormatBuffer implements FormatBuffer
|
||||
buffer.append(c);
|
||||
}
|
||||
|
||||
public void append(char c, AttributedCharacterIterator.Attribute attr)
|
||||
public void append(char c, Attribute attr)
|
||||
{
|
||||
buffer.append(c);
|
||||
}
|
||||
|
||||
public void setDefaultAttribute(AttributedCharacterIterator.Attribute attr)
|
||||
public void setDefaultAttribute(Attribute attr)
|
||||
{
|
||||
defaultAttr = attr;
|
||||
}
|
||||
|
||||
public AttributedCharacterIterator.Attribute getDefaultAttribute()
|
||||
public Attribute getDefaultAttribute()
|
||||
{
|
||||
return defaultAttr;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* DSSIMidiDeviceProvider.java -- DSSI Device Provider
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -69,13 +69,16 @@ public class DSSIMidiDeviceProvider extends MidiDeviceProvider
|
||||
*/
|
||||
private static class DSSIInfo extends Info
|
||||
{
|
||||
String copyright;
|
||||
String soname;
|
||||
long index;
|
||||
|
||||
public DSSIInfo(String name, String vendor, String description,
|
||||
String version, String soname, long index)
|
||||
public DSSIInfo(String name, String vendor, String label,
|
||||
String copyright, String version,
|
||||
String soname, long index)
|
||||
{
|
||||
super(name, vendor, description, version);
|
||||
super(name, vendor, label, version);
|
||||
this.copyright = copyright;
|
||||
this.soname = soname;
|
||||
this.index = index;
|
||||
}
|
||||
@@ -89,9 +92,9 @@ public class DSSIMidiDeviceProvider extends MidiDeviceProvider
|
||||
static native String getDSSIVendor_(long handle);
|
||||
static native String getDSSILabel_(long handle);
|
||||
|
||||
private static List examineLibrary(String soname)
|
||||
private static List<DSSIInfo> examineLibrary(String soname)
|
||||
{
|
||||
List list = new ArrayList();
|
||||
List<DSSIInfo> list = new ArrayList<DSSIInfo>();
|
||||
long index = 0;
|
||||
long handle;
|
||||
|
||||
@@ -107,7 +110,7 @@ public class DSSIMidiDeviceProvider extends MidiDeviceProvider
|
||||
String copyright = getDSSICopyright_(handle);
|
||||
String label = getDSSIName_(handle);
|
||||
String vendor = getDSSIVendor_(handle);
|
||||
list.add(new DSSIInfo(name, vendor, label,
|
||||
list.add(new DSSIInfo(name, vendor, label, copyright,
|
||||
"DSSI-1", soname, index));
|
||||
index++;
|
||||
} while (true);
|
||||
@@ -133,10 +136,10 @@ public class DSSIMidiDeviceProvider extends MidiDeviceProvider
|
||||
return n.endsWith(".so");
|
||||
}
|
||||
});
|
||||
List ilist = new ArrayList();
|
||||
List<DSSIInfo> ilist = new ArrayList<DSSIInfo>();
|
||||
for (int i = 0; i < sofiles.length; i++)
|
||||
ilist.addAll(examineLibrary(new File(dssidir, sofiles[i]).getAbsolutePath()));
|
||||
infos = (DSSIInfo[]) ilist.toArray(new DSSIInfo[ilist.size()]);
|
||||
infos = ilist.toArray(new DSSIInfo[ilist.size()]);
|
||||
}
|
||||
|
||||
public DSSIMidiDeviceProvider()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* DSSISynthesizer.java -- DSSI Synthesizer Provider
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006, 2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -97,8 +97,8 @@ public class DSSISynthesizer implements Synthesizer
|
||||
{
|
||||
private String name;
|
||||
private String description;
|
||||
private List instruments = new ArrayList();
|
||||
private List resources = new ArrayList();
|
||||
private List<Instrument> instruments = new ArrayList<Instrument>();
|
||||
private List<SoundbankResource> resources = new ArrayList<SoundbankResource>();
|
||||
private String vendor;
|
||||
private String version;
|
||||
|
||||
@@ -147,27 +147,25 @@ public class DSSISynthesizer implements Synthesizer
|
||||
*/
|
||||
public SoundbankResource[] getResources()
|
||||
{
|
||||
return (SoundbankResource[])
|
||||
resources.toArray(new SoundbankResource[resources.size()]);
|
||||
return resources.toArray(new SoundbankResource[resources.size()]);
|
||||
}
|
||||
|
||||
/* @see javax.sound.midi.Soundbank#getInstruments()
|
||||
*/
|
||||
public Instrument[] getInstruments()
|
||||
{
|
||||
return (Instrument[])
|
||||
instruments.toArray(new Instrument[instruments.size()]);
|
||||
return instruments.toArray(new Instrument[instruments.size()]);
|
||||
}
|
||||
|
||||
/* @see javax.sound.midi.Soundbank#getInstrument(javax.sound.midi.Patch)
|
||||
*/
|
||||
public Instrument getInstrument(Patch patch)
|
||||
{
|
||||
Iterator itr = instruments.iterator();
|
||||
Iterator<Instrument> itr = instruments.iterator();
|
||||
|
||||
while (itr.hasNext())
|
||||
{
|
||||
Instrument i = (Instrument) itr.next();
|
||||
Instrument i = itr.next();
|
||||
if (i.getPatch().equals(patch))
|
||||
return i;
|
||||
}
|
||||
@@ -490,7 +488,7 @@ public class DSSISynthesizer implements Synthesizer
|
||||
MidiChannel channels[] = new MidiChannel[16];
|
||||
|
||||
// The list of known soundbanks, and the default one.
|
||||
List soundbanks = new ArrayList();
|
||||
List<Soundbank> soundbanks = new ArrayList<Soundbank>();
|
||||
DSSISoundbank defaultSoundbank;
|
||||
|
||||
/**
|
||||
@@ -616,17 +614,16 @@ public class DSSISynthesizer implements Synthesizer
|
||||
*/
|
||||
public Instrument[] getAvailableInstruments()
|
||||
{
|
||||
List instruments = new ArrayList();
|
||||
Iterator itr = soundbanks.iterator();
|
||||
List<Instrument> instruments = new ArrayList<Instrument>();
|
||||
Iterator<Soundbank> itr = soundbanks.iterator();
|
||||
while (itr.hasNext())
|
||||
{
|
||||
Soundbank sb = (Soundbank) itr.next();
|
||||
Soundbank sb = itr.next();
|
||||
Instrument ins[] = sb.getInstruments();
|
||||
for (int i = 0; i < ins.length; i++)
|
||||
instruments.add(ins[i]);
|
||||
}
|
||||
return (Instrument[])
|
||||
instruments.toArray(new Instrument[instruments.size()]);
|
||||
return instruments.toArray(new Instrument[instruments.size()]);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* MidiFileReader.java -- Read MIDI files.
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006, 2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -198,7 +198,7 @@ public class MidiFileReader extends javax.sound.midi.spi.MidiFileReader
|
||||
int Mtrk = din.readInt();
|
||||
if (Mtrk != 0x4d54726b)
|
||||
throw new InvalidMidiDataException("Invalid MIDI track header.");
|
||||
int length = din.readInt();
|
||||
din.readInt(); // length
|
||||
|
||||
int runningStatus = -1;
|
||||
int click = 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* MidiFileWriter.java -- Write MIDI files.
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006, 2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -118,7 +118,7 @@ public class MidiFileWriter
|
||||
*/
|
||||
private int computeTrackLength(Track track, MidiDataOutputStream dos)
|
||||
{
|
||||
int count = 0, length = 0, i = 0, eventCount = track.size();
|
||||
int length = 0, i = 0, eventCount = track.size();
|
||||
long ptick = 0;
|
||||
while (i < eventCount)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* WAVReader.java -- Read WAV files.
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006, 2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -128,7 +128,7 @@ public class WAVReader extends AudioFileReader
|
||||
boolean foundFmt = false;
|
||||
boolean foundData = false;
|
||||
|
||||
short compressionCode = 0, numberChannels = 0, blockAlign = 0, bitsPerSample = 0;
|
||||
short compressionCode = 0, numberChannels = 0, bitsPerSample = 0;
|
||||
long sampleRate = 0, bytesPerSecond = 0;
|
||||
long chunkLength = 0;
|
||||
|
||||
@@ -144,7 +144,7 @@ public class WAVReader extends AudioFileReader
|
||||
numberChannels = readUnsignedShortLE(din);
|
||||
sampleRate = readUnsignedIntLE(din);
|
||||
bytesPerSecond = readUnsignedIntLE(din);
|
||||
blockAlign = readUnsignedShortLE(din);
|
||||
readUnsignedShortLE(din); // blockAlign
|
||||
bitsPerSample = readUnsignedShortLE(din);
|
||||
din.skip(chunkLength - 16);
|
||||
break;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* GStreamerMixer.java -- Mixer implementation.
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007, 2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -92,7 +92,7 @@ public class GStreamerMixer
|
||||
// and see if there is one matching the given line
|
||||
// if the format comes from the gstreamer backend
|
||||
// gstreamer will be able to deal with it
|
||||
Class clazz = info.getLineClass();
|
||||
Class<?> clazz = info.getLineClass();
|
||||
DataLine.Info _info = (DataLine.Info) info;
|
||||
|
||||
if (clazz == SourceDataLine.class)
|
||||
|
||||
@@ -200,7 +200,8 @@ class SAXSerializer
|
||||
|
||||
public String getValue(String qName)
|
||||
{
|
||||
return attrs.getNamedItem(qName).getNodeValue();
|
||||
Attr attr = (Attr) attrs.getNamedItem(qName);
|
||||
return (attr == null) ? null : attr.getNodeValue();
|
||||
}
|
||||
|
||||
void serialize(Node node, ContentHandler ch, LexicalHandler lh)
|
||||
|
||||
Reference in New Issue
Block a user