summaryrefslogtreecommitdiff
path: root/libjava/classpath/javax
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/javax')
-rw-r--r--libjava/classpath/javax/management/ObjectName.java94
-rw-r--r--libjava/classpath/javax/sound/sampled/AudioFormat.java33
-rw-r--r--libjava/classpath/javax/sound/sampled/DataLine.java62
-rw-r--r--libjava/classpath/javax/sound/sampled/spi/MixerProvider.java4
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java22
-rw-r--r--libjava/classpath/javax/swing/text/html/parser/AttributeList.java2
6 files changed, 158 insertions, 59 deletions
diff --git a/libjava/classpath/javax/management/ObjectName.java b/libjava/classpath/javax/management/ObjectName.java
index a3f30efffb4..4ea21cdc7ae 100644
--- a/libjava/classpath/javax/management/ObjectName.java
+++ b/libjava/classpath/javax/management/ObjectName.java
@@ -71,7 +71,7 @@ import java.io.ObjectOutputStream;
* is separated by commas, and largely consists of unordered key-value
* pairs, separated by an equals sign ('='). At most one element may
* be an asterisk ('*'), which turns the {@link ObjectName} instance
- * into a <emph>property pattern</emph>. In this situation, the pattern
+ * into a <emph>property list pattern</emph>. In this situation, the pattern
* matches a name if the name contains at least those key-value pairs
* given and has the same domain.
* </p>
@@ -89,6 +89,13 @@ import java.io.ObjectOutputStream;
* (after expansion) are considered part of the value.
* </p>
* <p>
+ * Both quoted and unquoted values may contain the wildcard characters
+ * '?' and '*'. A name with at least one value containing a wildcard
+ * character is known as a <emph>property value pattern</emph>. A
+ * name is generally a <emph>property pattern</emph> if it is either
+ * a <emph>property list pattern</emph> or <emph>property value pattern</emph>.
+ * </p>
+ * <p>
* Spaces are maintained within the different parts of the name. Thus,
* '<code>domain: key1 = value1 </code>' has a key ' key1 ' with value
* ' value1 '. Newlines are disallowed, except where escaped in quoted
@@ -127,9 +134,14 @@ public class ObjectName
private transient String propertyListString;
/**
- * True if this object name is a property pattern.
+ * True if this object name is a property list pattern.
*/
- private transient boolean propertyPattern;
+ private transient boolean propertyListPattern;
+
+ /**
+ * True if this object name is a property value pattern.
+ */
+ private transient boolean propertyValuePattern;
/**
* The management server associated with this object name.
@@ -202,10 +214,10 @@ public class ObjectName
{
if (pairs[a].equals("*"))
{
- if (propertyPattern)
+ if (propertyListPattern)
throw new MalformedObjectNameException("Multiple wildcards " +
"in properties.");
- propertyPattern = true;
+ propertyListPattern = true;
continue;
}
int sep = pairs[a].indexOf('=');
@@ -291,16 +303,17 @@ public class ObjectName
if (domain.indexOf('\n') != -1)
throw new MalformedObjectNameException("The domain includes a newline " +
"character.");
- char[] chars = new char[] { '\n', ':', ',', '*', '?', '=' };
+ char[] keychars = new char[] { '\n', ':', ',', '*', '?', '=' };
+ char[] valchars = new char[] { '\n', ':', ',', '=' };
Iterator i = properties.entrySet().iterator();
while (i.hasNext())
{
Map.Entry entry = (Map.Entry) i.next();
String key = (String) entry.getKey();
- for (int a = 0; a < chars.length; ++a)
- if (key.indexOf(chars[a]) != -1)
+ for (int a = 0; a < keychars.length; ++a)
+ if (key.indexOf(keychars[a]) != -1)
throw new MalformedObjectNameException("A key contains a '" +
- chars[a] + "' " +
+ keychars[a] + "' " +
"character.");
String value = (String) entry.getValue();
int quote = value.indexOf('"');
@@ -322,12 +335,15 @@ public class ObjectName
"a '\"' character.");
else
{
- for (int a = 0; a < chars.length; ++a)
- if (value.indexOf(chars[a]) != -1)
+ for (int a = 0; a < valchars.length; ++a)
+ if (value.indexOf(valchars[a]) != -1)
throw new MalformedObjectNameException("A value contains " +
- "a '" + chars[a] + "' " +
+ "a '" + valchars[a] + "' " +
"character.");
+
}
+ if (value.indexOf('*') != -1 || value.indexOf('?') != -1)
+ propertyValuePattern = true;
}
}
@@ -690,14 +706,60 @@ public class ObjectName
}
/**
- * Returns true if this object name is a property pattern. This is
- * the case if the list of properties contains an '*'.
+ * Returns true if this object name is a property list
+ * pattern, a property value pattern or both.
*
- * @return true if this is a property pattern.
+ * @return true if the properties of this name contain a pattern.
+ * @see #isPropertyListPattern
+ * @see #isPropertyValuePattern
*/
public boolean isPropertyPattern()
{
- return propertyPattern;
+ return propertyListPattern || propertyValuePattern;
+ }
+
+ /**
+ * Returns true if this object name is a property list pattern. This is
+ * the case if the list of properties contains an '*'.
+ *
+ * @return true if this is a property list pattern.
+ * @since 1.6
+ */
+ public boolean isPropertyListPattern()
+ {
+ return propertyListPattern;
+ }
+
+ /**
+ * Returns true if this object name is a property value pattern. This is
+ * the case if one of the values contains a wildcard character,
+ * '?' or '*'.
+ *
+ * @return true if this is a property value pattern.
+ * @since 1.6
+ */
+ public boolean isPropertyValuePattern()
+ {
+ return propertyValuePattern;
+ }
+
+ /**
+ * Returns true if the value of the given key is a pattern. This is
+ * the case if the value contains a wildcard character, '?' or '*'.
+ *
+ * @param key the key whose value should be checked.
+ * @return true if the value of the given key is a pattern.
+ * @since 1.6
+ * @throws NullPointerException if {@code key} is {@code null}.
+ * @throws IllegalArgumentException if {@code key} is not a valid
+ * property.
+ */
+ public boolean isPropertyValuePattern(String key)
+ {
+ String value = getKeyProperty(key);
+ if (value == null)
+ throw new IllegalArgumentException(key + " is not a valid property.");
+ return value.indexOf('?') != -1 || value.indexOf('*') != -1;
}
/**
diff --git a/libjava/classpath/javax/sound/sampled/AudioFormat.java b/libjava/classpath/javax/sound/sampled/AudioFormat.java
index 6296784426c..7b6ebc4b03b 100644
--- a/libjava/classpath/javax/sound/sampled/AudioFormat.java
+++ b/libjava/classpath/javax/sound/sampled/AudioFormat.java
@@ -330,16 +330,35 @@ public class AudioFormat
public String toString()
{
StringBuffer result = new StringBuffer();
+
+ // usually at least encoding should be somewhat specified
result.append(encoding);
- result.append(" ");
- result.append(sampleRate);
- result.append(" Hz ");
- result.append(sampleSizeInBits);
- result.append(" bits ");
- result.append(channels);
- result.append(" channels");
+
+ if (sampleRate != AudioSystem.NOT_SPECIFIED)
+ {
+ result.append(" ");
+ result.append(sampleRate);
+ result.append(" Hz");
+ }
+
+ if (sampleSizeInBits != AudioSystem.NOT_SPECIFIED)
+ {
+ result.append(" ");
+ result.append(sampleSizeInBits);
+ result.append(" bits");
+ }
+
+ if (channels != AudioSystem.NOT_SPECIFIED)
+ {
+ result.append(" ");
+ result.append(channels);
+ result.append(" channel");
+ if (channels > 1) result.append("s");
+ }
+
if (sampleSizeInBits > 8)
result.append(bigEndian ? " big endian" : " little endian");
+
return result.toString();
}
}
diff --git a/libjava/classpath/javax/sound/sampled/DataLine.java b/libjava/classpath/javax/sound/sampled/DataLine.java
index aa99a046ce4..b7cb70e4931 100644
--- a/libjava/classpath/javax/sound/sampled/DataLine.java
+++ b/libjava/classpath/javax/sound/sampled/DataLine.java
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005-2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,7 +35,6 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package javax.sound.sampled;
/**
@@ -138,10 +137,10 @@ public interface DataLine extends Line
public boolean isFormatSupported(AudioFormat fmt)
{
for (int i = 0; i < formats.length; ++i)
- {
- if (fmt.matches(formats[i]))
- return true;
- }
+ {
+ if (fmt.matches(formats[i]))
+ return true;
+ }
return false;
}
@@ -151,25 +150,28 @@ public interface DataLine extends Line
public boolean matches(Line.Info o)
{
if (! super.matches(o) || ! (o instanceof Info))
- return false;
+ return false;
+
Info other = (Info) o;
- if (minBufferSize < other.minBufferSize
- || maxBufferSize > other.maxBufferSize)
- return false;
+ if (minBufferSize < other.minBufferSize ||
+ maxBufferSize > other.maxBufferSize)
+ return false;
+
for (int i = 0; i < formats.length; ++i)
- {
- boolean ok = false;
- for (int j = 0; j < other.formats.length; ++j)
- {
- if (formats[i].matches(other.formats[j]))
- {
- ok = true;
- break;
- }
- }
- if (! ok)
- return false;
- }
+ {
+ boolean ok = false;
+ for (int j = 0; j < other.formats.length; ++j)
+ {
+ if (formats[i].matches(other.formats[j]))
+ {
+ ok = true;
+ break;
+ }
+ }
+ if (! ok)
+ return false;
+ }
+
return true;
}
@@ -181,18 +183,20 @@ public interface DataLine extends Line
StringBuffer result = new StringBuffer();
result.append("formats: [");
for (int i = 0; i < formats.length; ++i)
- {
- if (i > 0)
- result.append(", ");
- result.append(formats[i].toString());
- }
+ {
+ if (i > 0)
+ result.append(", ");
+ result.append(formats[i].toString());
+ }
+
result.append("]; minBufferSize: ");
result.append(minBufferSize);
result.append("; maxBufferSize: ");
result.append(maxBufferSize);
return result.toString();
}
- }
+
+ } // end class: Info
/**
* Return the number of bytes currently available on this DataLine.
diff --git a/libjava/classpath/javax/sound/sampled/spi/MixerProvider.java b/libjava/classpath/javax/sound/sampled/spi/MixerProvider.java
index 1ae7b3bb7d8..72b972497e1 100644
--- a/libjava/classpath/javax/sound/sampled/spi/MixerProvider.java
+++ b/libjava/classpath/javax/sound/sampled/spi/MixerProvider.java
@@ -78,8 +78,8 @@ public abstract class MixerProvider
Mixer.Info[] infos = getMixerInfo();
for (int i = 0; i < infos.length; ++i)
{
- if (info.equals(infos[i]))
- return true;
+ if (info.equals(infos[i]))
+ return true;
}
return false;
}
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java
index df4c3aebdfd..12bbe013c5e 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java
@@ -600,8 +600,13 @@ public class BasicProgressBarUI extends ProgressBarUI
int y, int width, int height)
{
Rectangle tr = new Rectangle();
- Rectangle vr = new Rectangle(x, y, width, height);
+ Rectangle vr = new Rectangle();
Rectangle ir = new Rectangle();
+
+ if (progressBar.getOrientation() == JProgressBar.HORIZONTAL)
+ vr.setBounds(x, y, width, height);
+ else
+ vr.setBounds(y, x, height, width);
Font f = g.getFont();
FontMetrics fm = g.getFontMetrics(f);
@@ -611,7 +616,11 @@ public class BasicProgressBarUI extends ProgressBarUI
SwingConstants.CENTER,
SwingConstants.CENTER,
SwingConstants.CENTER, vr, ir, tr, 0);
- return new Point(tr.x, tr.y);
+
+ if (progressBar.getOrientation() == JProgressBar.HORIZONTAL)
+ return new Point(tr.x, tr.y);
+ else
+ return new Point(tr.y, tr.x);
}
/**
@@ -741,14 +750,19 @@ public class BasicProgressBarUI extends ProgressBarUI
{
AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2);
g.setFont(progressBar.getFont().deriveFont(rotate));
+ placement.x = width - placement.x - fm.getAscent();
+ }
+ else
+ {
+ placement.y += fm.getAscent();
}
g.setColor(getSelectionForeground());
g.setClip(0, 0, full + b.left, height);
- g.drawString(str, placement.x, placement.y + fm.getAscent());
+ g.drawString(str, placement.x, placement.y);
g.setColor(getSelectionBackground());
g.setClip(full + b.left, 0, width - full, height);
- g.drawString(str, placement.x, placement.y + fm.getAscent());
+ g.drawString(str, placement.x, placement.y);
g.setClip(savedClip);
g.setColor(savedColor);
}
diff --git a/libjava/classpath/javax/swing/text/html/parser/AttributeList.java b/libjava/classpath/javax/swing/text/html/parser/AttributeList.java
index d48266d4730..a943f056de1 100644
--- a/libjava/classpath/javax/swing/text/html/parser/AttributeList.java
+++ b/libjava/classpath/javax/swing/text/html/parser/AttributeList.java
@@ -253,7 +253,7 @@ public final class AttributeList
*/
public Enumeration<?> getValues()
{
- return values.elements();
+ return (values != null) ? values.elements() : null;
}
/**