RE.java, [...]: Made 'inner' classes real public static inner classes...
2005-02-20 Dalibor Topic <robilad@kaffe.org> * libraries/javalib/gnu/regexp/RE.java, libraries/javalib/java/io/ObjectInputStream.java, libraries/javalib/java/security/AllPermission.java, libraries/javalib/java/security/BasicPermission.java, libraries/javalib/java/security/Permissions.java, libraries/javalib/java/text/MessageFormat.java: Made 'inner' classes real public static inner classes, and made them final where possible, or removed them where unused. From-SVN: r95310
This commit is contained in:
parent
237eaf79a5
commit
7d651220a3
7 changed files with 371 additions and 358 deletions
|
@ -1,3 +1,15 @@
|
||||||
|
2005-02-20 Dalibor Topic <robilad@kaffe.org>
|
||||||
|
|
||||||
|
* libraries/javalib/gnu/regexp/RE.java,
|
||||||
|
libraries/javalib/java/io/ObjectInputStream.java,
|
||||||
|
libraries/javalib/java/security/AllPermission.java,
|
||||||
|
libraries/javalib/java/security/BasicPermission.java,
|
||||||
|
libraries/javalib/java/security/Permissions.java,
|
||||||
|
libraries/javalib/java/text/MessageFormat.java:
|
||||||
|
Made 'inner' classes real public static inner classes,
|
||||||
|
and made them final where possible, or removed them
|
||||||
|
where unused.
|
||||||
|
|
||||||
2005-02-20 Michael Koch <konqueror@gmx.de>
|
2005-02-20 Michael Koch <konqueror@gmx.de>
|
||||||
|
|
||||||
* gnu/java/text/FormatCharacterIterator.java:
|
* gnu/java/text/FormatCharacterIterator.java:
|
||||||
|
|
|
@ -43,15 +43,6 @@ import java.util.PropertyResourceBundle;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
class IntPair implements Serializable {
|
|
||||||
public int first, second;
|
|
||||||
}
|
|
||||||
|
|
||||||
class CharUnit implements Serializable {
|
|
||||||
public char ch;
|
|
||||||
public boolean bk;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RE provides the user interface for compiling and matching regular
|
* RE provides the user interface for compiling and matching regular
|
||||||
* expressions.
|
* expressions.
|
||||||
|
@ -119,6 +110,16 @@ class CharUnit implements Serializable {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class RE extends REToken {
|
public class RE extends REToken {
|
||||||
|
|
||||||
|
private static final class IntPair implements Serializable {
|
||||||
|
public int first, second;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class CharUnit implements Serializable {
|
||||||
|
public char ch;
|
||||||
|
public boolean bk;
|
||||||
|
}
|
||||||
|
|
||||||
// This String will be returned by getVersion()
|
// This String will be returned by getVersion()
|
||||||
private static final String VERSION = "1.1.5-dev";
|
private static final String VERSION = "1.1.5-dev";
|
||||||
|
|
||||||
|
|
|
@ -1809,7 +1809,6 @@ public class ObjectInputStream extends InputStream
|
||||||
* @param sm SecurityManager instance which should be called.
|
* @param sm SecurityManager instance which should be called.
|
||||||
* @return The current class loader in the calling stack.
|
* @return The current class loader in the calling stack.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private static native ClassLoader currentClassLoader (SecurityManager sm);
|
private static native ClassLoader currentClassLoader (SecurityManager sm);
|
||||||
|
|
||||||
private native ClassLoader getCallersClassLoader();
|
private native ClassLoader getCallersClassLoader();
|
||||||
|
@ -1879,7 +1878,7 @@ public class ObjectInputStream extends InputStream
|
||||||
private int depth = 0;
|
private int depth = 0;
|
||||||
|
|
||||||
private void dumpElement (String msg)
|
private void dumpElement (String msg)
|
||||||
{
|
{
|
||||||
System.out.print(msg);
|
System.out.print(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1898,24 +1897,24 @@ public class ObjectInputStream extends InputStream
|
||||||
System.loadLibrary ("javaio");
|
System.loadLibrary ("javaio");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
// used to keep a prioritized list of object validators
|
||||||
// used to keep a prioritized list of object validators
|
private static final class ValidatorAndPriority implements Comparable
|
||||||
class ValidatorAndPriority implements Comparable
|
|
||||||
{
|
|
||||||
int priority;
|
|
||||||
ObjectInputValidation validator;
|
|
||||||
|
|
||||||
ValidatorAndPriority (ObjectInputValidation validator, int priority)
|
|
||||||
{
|
{
|
||||||
this.priority = priority;
|
int priority;
|
||||||
this.validator = validator;
|
ObjectInputValidation validator;
|
||||||
}
|
|
||||||
|
|
||||||
public int compareTo (Object o)
|
ValidatorAndPriority (ObjectInputValidation validator, int priority)
|
||||||
{
|
{
|
||||||
ValidatorAndPriority vap = (ValidatorAndPriority)o;
|
this.priority = priority;
|
||||||
return this.priority - vap.priority;
|
this.validator = validator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compareTo (Object o)
|
||||||
|
{
|
||||||
|
ValidatorAndPriority vap = (ValidatorAndPriority)o;
|
||||||
|
return this.priority - vap.priority;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* AllPermission.java -- Permission to do anything
|
/* AllPermission.java -- Permission to do anything
|
||||||
Copyright (C) 1998, 2001, 2002, 2004 Free Software Foundation, Inc.
|
Copyright (C) 1998, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GNU Classpath.
|
This file is part of GNU Classpath.
|
||||||
|
|
||||||
|
@ -135,64 +135,64 @@ public final class AllPermission extends Permission
|
||||||
{
|
{
|
||||||
return new AllPermissionCollection();
|
return new AllPermissionCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements AllPermission.newPermissionCollection, and obeys serialization
|
||||||
|
* of JDK.
|
||||||
|
*
|
||||||
|
* @author Eric Blake (ebb9@email.byu.edu)
|
||||||
|
*/
|
||||||
|
private static final class AllPermissionCollection extends PermissionCollection
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Compatible with JDK 1.1+.
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -4023755556366636806L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether an AllPermission has been added to the collection.
|
||||||
|
*
|
||||||
|
* @serial if all permission is in the collection yet
|
||||||
|
*/
|
||||||
|
private boolean all_allowed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an AllPermission.
|
||||||
|
*
|
||||||
|
* @param perm the permission to add
|
||||||
|
* @throws IllegalArgumentException if perm is not an AllPermission
|
||||||
|
* @throws SecurityException if the collection is read-only
|
||||||
|
*/
|
||||||
|
public void add(Permission perm)
|
||||||
|
{
|
||||||
|
if (isReadOnly())
|
||||||
|
throw new SecurityException();
|
||||||
|
if (! (perm instanceof AllPermission))
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
all_allowed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this collection implies a permission.
|
||||||
|
*
|
||||||
|
* @param perm the permission to check
|
||||||
|
* @return true if this collection contains an AllPermission
|
||||||
|
*/
|
||||||
|
public boolean implies(Permission perm)
|
||||||
|
{
|
||||||
|
return all_allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an enumeration of the elements in the collection.
|
||||||
|
*
|
||||||
|
* @return the elements in the collection
|
||||||
|
*/
|
||||||
|
public Enumeration elements()
|
||||||
|
{
|
||||||
|
return all_allowed
|
||||||
|
? Collections.enumeration(Collections.singleton(new AllPermission()))
|
||||||
|
: EmptyEnumeration.getInstance();
|
||||||
|
}
|
||||||
|
} // class AllPermissionCollection
|
||||||
} // class AllPermission
|
} // class AllPermission
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements AllPermission.newPermissionCollection, and obeys serialization
|
|
||||||
* of JDK.
|
|
||||||
*
|
|
||||||
* @author Eric Blake <ebb9@email.byu.edu>
|
|
||||||
*/
|
|
||||||
final class AllPermissionCollection extends PermissionCollection
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Compatible with JDK 1.1+.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -4023755556366636806L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether an AllPermission has been added to the collection.
|
|
||||||
*
|
|
||||||
* @serial if all permission is in the collection yet
|
|
||||||
*/
|
|
||||||
private boolean all_allowed;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add an AllPermission.
|
|
||||||
*
|
|
||||||
* @param perm the permission to add
|
|
||||||
* @throws IllegalArgumentException if perm is not an AllPermission
|
|
||||||
* @throws SecurityException if the collection is read-only
|
|
||||||
*/
|
|
||||||
public void add(Permission perm)
|
|
||||||
{
|
|
||||||
if (isReadOnly())
|
|
||||||
throw new SecurityException();
|
|
||||||
if (! (perm instanceof AllPermission))
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
all_allowed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if this collection implies a permission.
|
|
||||||
*
|
|
||||||
* @param perm the permission to check
|
|
||||||
* @return true if this collection contains an AllPermission
|
|
||||||
*/
|
|
||||||
public boolean implies(Permission perm)
|
|
||||||
{
|
|
||||||
return all_allowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an enumeration of the elements in the collection.
|
|
||||||
*
|
|
||||||
* @return the elements in the collection
|
|
||||||
*/
|
|
||||||
public Enumeration elements()
|
|
||||||
{
|
|
||||||
return all_allowed
|
|
||||||
? Collections.enumeration(Collections.singleton(new AllPermission()))
|
|
||||||
: EmptyEnumeration.getInstance();
|
|
||||||
}
|
|
||||||
} // class AllPermissionCollection
|
|
||||||
|
|
|
@ -72,8 +72,9 @@ import java.util.Hashtable;
|
||||||
* @since 1.1
|
* @since 1.1
|
||||||
* @status updated to 1.4
|
* @status updated to 1.4
|
||||||
*/
|
*/
|
||||||
public abstract class BasicPermission extends Permission
|
public abstract class BasicPermission extends java.security.Permission
|
||||||
implements Serializable
|
implements Serializable
|
||||||
|
// FIXME extends with fully qualified classname as workaround for gcj 3.3.
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Compatible with JDK 1.1+.
|
* Compatible with JDK 1.1+.
|
||||||
|
@ -197,111 +198,111 @@ public abstract class BasicPermission extends Permission
|
||||||
{
|
{
|
||||||
return new BasicPermissionCollection(getClass());
|
return new BasicPermissionCollection(getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements AllPermission.newPermissionCollection, and obeys serialization
|
||||||
|
* of JDK.
|
||||||
|
*
|
||||||
|
* @author Eric Blake (ebb9@email.byu.edu)
|
||||||
|
*/
|
||||||
|
private static final class BasicPermissionCollection extends PermissionCollection
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Compatible with JDK 1.1+.
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 739301742472979399L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The permissions in the collection.
|
||||||
|
*
|
||||||
|
* @serial a hash mapping name to permissions, all of type permClass
|
||||||
|
*/
|
||||||
|
private final Hashtable permissions = new Hashtable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If "*" is in the collection.
|
||||||
|
*
|
||||||
|
* @serial true if a permission named "*" is in the collection
|
||||||
|
*/
|
||||||
|
private boolean all_allowed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The runtime class which all entries in the table must belong to.
|
||||||
|
*
|
||||||
|
* @serial the limiting subclass of this collection
|
||||||
|
*/
|
||||||
|
private final Class permClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a collection over the given runtime class.
|
||||||
|
*
|
||||||
|
* @param c the class
|
||||||
|
*/
|
||||||
|
BasicPermissionCollection(Class c)
|
||||||
|
{
|
||||||
|
permClass = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a Permission. It must be of the same type as the permission which
|
||||||
|
* created this collection.
|
||||||
|
*
|
||||||
|
* @param perm the permission to add
|
||||||
|
* @throws IllegalArgumentException if perm is not the correct type
|
||||||
|
* @throws SecurityException if the collection is read-only
|
||||||
|
*/
|
||||||
|
public void add(Permission perm)
|
||||||
|
{
|
||||||
|
if (isReadOnly())
|
||||||
|
throw new SecurityException("readonly");
|
||||||
|
if (! permClass.isInstance(perm))
|
||||||
|
throw new IllegalArgumentException("Expecting instance of " + permClass);
|
||||||
|
BasicPermission bp = (BasicPermission) perm;
|
||||||
|
String name = bp.getName();
|
||||||
|
if (name.equals("*"))
|
||||||
|
all_allowed = true;
|
||||||
|
permissions.put(name, bp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this collection implies the given permission.
|
||||||
|
*
|
||||||
|
* @param permission the permission to check
|
||||||
|
* @return true if it is implied by this
|
||||||
|
*/
|
||||||
|
public boolean implies(Permission permission)
|
||||||
|
{
|
||||||
|
if (! permClass.isInstance(permission))
|
||||||
|
return false;
|
||||||
|
if (all_allowed)
|
||||||
|
return true;
|
||||||
|
BasicPermission toImply = (BasicPermission) permission;
|
||||||
|
String name = toImply.getName();
|
||||||
|
if (name.equals("*"))
|
||||||
|
return false;
|
||||||
|
int prefixLength = name.length();
|
||||||
|
if (name.endsWith("*"))
|
||||||
|
prefixLength -= 2;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (permissions.get(name) != null)
|
||||||
|
return true;
|
||||||
|
prefixLength = name.lastIndexOf('.', prefixLength);
|
||||||
|
if (prefixLength < 0)
|
||||||
|
return false;
|
||||||
|
name = name.substring(0, prefixLength + 1) + '*';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumerate over the collection.
|
||||||
|
*
|
||||||
|
* @return an enumeration of the collection contents
|
||||||
|
*/
|
||||||
|
public Enumeration elements()
|
||||||
|
{
|
||||||
|
return permissions.elements();
|
||||||
|
}
|
||||||
|
} // class BasicPermissionCollection
|
||||||
} // class BasicPermission
|
} // class BasicPermission
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements AllPermission.newPermissionCollection, and obeys serialization
|
|
||||||
* of JDK.
|
|
||||||
*
|
|
||||||
* @author Eric Blake <ebb9@email.byu.edu>
|
|
||||||
*/
|
|
||||||
final class BasicPermissionCollection extends PermissionCollection
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Compatible with JDK 1.1+.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 739301742472979399L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The permissions in the collection.
|
|
||||||
*
|
|
||||||
* @serial a hash mapping name to permissions, all of type permClass
|
|
||||||
*/
|
|
||||||
private final Hashtable permissions = new Hashtable();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If "*" is in the collection.
|
|
||||||
*
|
|
||||||
* @serial true if a permission named "*" is in the collection
|
|
||||||
*/
|
|
||||||
private boolean all_allowed;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The runtime class which all entries in the table must belong to.
|
|
||||||
*
|
|
||||||
* @serial the limiting subclass of this collection
|
|
||||||
*/
|
|
||||||
private final Class permClass;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a collection over the given runtime class.
|
|
||||||
*
|
|
||||||
* @param c the class
|
|
||||||
*/
|
|
||||||
BasicPermissionCollection(Class c)
|
|
||||||
{
|
|
||||||
permClass = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a Permission. It must be of the same type as the permission which
|
|
||||||
* created this collection.
|
|
||||||
*
|
|
||||||
* @param perm the permission to add
|
|
||||||
* @throws IllegalArgumentException if perm is not the correct type
|
|
||||||
* @throws SecurityException if the collection is read-only
|
|
||||||
*/
|
|
||||||
public void add(Permission perm)
|
|
||||||
{
|
|
||||||
if (isReadOnly())
|
|
||||||
throw new SecurityException("readonly");
|
|
||||||
if (! permClass.isInstance(perm))
|
|
||||||
throw new IllegalArgumentException("Expecting instance of " + permClass);
|
|
||||||
BasicPermission bp = (BasicPermission) perm;
|
|
||||||
String name = bp.getName();
|
|
||||||
if (name.equals("*"))
|
|
||||||
all_allowed = true;
|
|
||||||
permissions.put(name, bp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if this collection implies the given permission.
|
|
||||||
*
|
|
||||||
* @param permission the permission to check
|
|
||||||
* @return true if it is implied by this
|
|
||||||
*/
|
|
||||||
public boolean implies(Permission permission)
|
|
||||||
{
|
|
||||||
if (! permClass.isInstance(permission))
|
|
||||||
return false;
|
|
||||||
if (all_allowed)
|
|
||||||
return true;
|
|
||||||
BasicPermission toImply = (BasicPermission) permission;
|
|
||||||
String name = toImply.getName();
|
|
||||||
if (name.equals("*"))
|
|
||||||
return false;
|
|
||||||
int prefixLength = name.length();
|
|
||||||
if (name.endsWith("*"))
|
|
||||||
prefixLength -= 2;
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
if (permissions.get(name) != null)
|
|
||||||
return true;
|
|
||||||
prefixLength = name.lastIndexOf('.', prefixLength);
|
|
||||||
if (prefixLength < 0)
|
|
||||||
return false;
|
|
||||||
name = name.substring(0, prefixLength + 1) + '*';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enumerate over the collection.
|
|
||||||
*
|
|
||||||
* @return an enumeration of the collection contents
|
|
||||||
*/
|
|
||||||
public Enumeration elements()
|
|
||||||
{
|
|
||||||
return permissions.elements();
|
|
||||||
}
|
|
||||||
} // class BasicPermissionCollection
|
|
||||||
|
|
|
@ -188,67 +188,67 @@ public final class Permissions extends PermissionCollection
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // class Permissions
|
|
||||||
|
/**
|
||||||
/**
|
* Implements the permission collection for all permissions without one of
|
||||||
* Implements the permission collection for all permissions without one of
|
* their own, and obeys serialization of JDK.
|
||||||
* their own, and obeys serialization of JDK.
|
*
|
||||||
*
|
* @author Eric Blake (ebb9@email.byu.edu)
|
||||||
* @author Eric Blake <ebb9@email.byu.edu>
|
*/
|
||||||
*/
|
private static final class PermissionsHash extends PermissionCollection
|
||||||
class PermissionsHash extends PermissionCollection
|
{
|
||||||
{
|
/**
|
||||||
/**
|
* Compatible with JDK 1.1+.
|
||||||
* Compatible with JDK 1.1+.
|
*/
|
||||||
*/
|
private static final long serialVersionUID = -8491988220802933440L;
|
||||||
private static final long serialVersionUID = -8491988220802933440L;
|
|
||||||
|
/**
|
||||||
/**
|
* Hashtable where we store permissions.
|
||||||
* Hashtable where we store permissions.
|
*
|
||||||
*
|
* @serial the stored permissions, both as key and value
|
||||||
* @serial the stored permissions, both as key and value
|
*/
|
||||||
*/
|
private final Hashtable perms = new Hashtable();
|
||||||
private final Hashtable perms = new Hashtable();
|
|
||||||
|
/**
|
||||||
/**
|
* Add a permission. We don't need to check for read-only, as this
|
||||||
* Add a permission. We don't need to check for read-only, as this
|
* collection is never exposed outside of Permissions, which has already
|
||||||
* collection is never exposed outside of Permissions, which has already
|
* done that check.
|
||||||
* done that check.
|
*
|
||||||
*
|
* @param perm the permission to add
|
||||||
* @param perm the permission to add
|
*/
|
||||||
*/
|
public void add(Permission perm)
|
||||||
public void add(Permission perm)
|
{
|
||||||
{
|
perms.put(perm, perm);
|
||||||
perms.put(perm, perm);
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Returns true if perm is in the collection.
|
||||||
* Returns true if perm is in the collection.
|
*
|
||||||
*
|
* @param perm the permission to check
|
||||||
* @param perm the permission to check
|
* @return true if it is implied
|
||||||
* @return true if it is implied
|
*/
|
||||||
*/
|
// FIXME: Should this method be synchronized?
|
||||||
// FIXME: Should this method be synchronized?
|
public boolean implies(Permission perm)
|
||||||
public boolean implies(Permission perm)
|
{
|
||||||
{
|
Enumeration elements = elements();
|
||||||
Enumeration elements = elements();
|
|
||||||
|
while (elements.hasMoreElements())
|
||||||
while (elements.hasMoreElements())
|
{
|
||||||
{
|
Permission p = (Permission)elements.nextElement();
|
||||||
Permission p = (Permission)elements.nextElement();
|
if (p.implies(perm))
|
||||||
if (p.implies(perm))
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Return the elements.
|
||||||
* Return the elements.
|
*
|
||||||
*
|
* @return the elements
|
||||||
* @return the elements
|
*/
|
||||||
*/
|
public Enumeration elements()
|
||||||
public Enumeration elements()
|
{
|
||||||
{
|
return perms.elements();
|
||||||
return perms.elements();
|
}
|
||||||
}
|
} // class PermissionsHash
|
||||||
} // class Permissions
|
} // class Permissions
|
||||||
|
|
|
@ -46,107 +46,107 @@ import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Tom Tromey <tromey@cygnus.com>
|
|
||||||
* @author Jorge Aliss <jaliss@hotmail.com>
|
|
||||||
* @date March 3, 1999
|
|
||||||
*/
|
|
||||||
/* 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 to 1.2, except serialization.
|
|
||||||
* and parsing.
|
|
||||||
*/
|
|
||||||
final class MessageFormatElement
|
|
||||||
{
|
|
||||||
// Argument number.
|
|
||||||
int argNumber;
|
|
||||||
// Formatter to be used. This is the format set by setFormat.
|
|
||||||
Format setFormat;
|
|
||||||
// Formatter to be used based on the type.
|
|
||||||
Format format;
|
|
||||||
|
|
||||||
// Argument will be checked to make sure it is an instance of this
|
|
||||||
// class.
|
|
||||||
Class formatClass;
|
|
||||||
|
|
||||||
// Formatter type.
|
|
||||||
String type;
|
|
||||||
// Formatter style.
|
|
||||||
String style;
|
|
||||||
|
|
||||||
// Text to follow this element.
|
|
||||||
String trailer;
|
|
||||||
|
|
||||||
// Recompute the locale-based formatter.
|
|
||||||
void setLocale (Locale loc)
|
|
||||||
{
|
|
||||||
if (type == null)
|
|
||||||
;
|
|
||||||
else if (type.equals("number"))
|
|
||||||
{
|
|
||||||
formatClass = java.lang.Number.class;
|
|
||||||
|
|
||||||
if (style == null)
|
|
||||||
format = NumberFormat.getInstance(loc);
|
|
||||||
else if (style.equals("currency"))
|
|
||||||
format = NumberFormat.getCurrencyInstance(loc);
|
|
||||||
else if (style.equals("percent"))
|
|
||||||
format = NumberFormat.getPercentInstance(loc);
|
|
||||||
else if (style.equals("integer"))
|
|
||||||
{
|
|
||||||
NumberFormat nf = NumberFormat.getNumberInstance(loc);
|
|
||||||
nf.setMaximumFractionDigits(0);
|
|
||||||
nf.setGroupingUsed(false);
|
|
||||||
format = nf;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
format = NumberFormat.getNumberInstance(loc);
|
|
||||||
DecimalFormat df = (DecimalFormat) format;
|
|
||||||
df.applyPattern(style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (type.equals("time") || type.equals("date"))
|
|
||||||
{
|
|
||||||
formatClass = java.util.Date.class;
|
|
||||||
|
|
||||||
int val = DateFormat.DEFAULT;
|
|
||||||
if (style == null)
|
|
||||||
;
|
|
||||||
else if (style.equals("short"))
|
|
||||||
val = DateFormat.SHORT;
|
|
||||||
else if (style.equals("medium"))
|
|
||||||
val = DateFormat.MEDIUM;
|
|
||||||
else if (style.equals("long"))
|
|
||||||
val = DateFormat.LONG;
|
|
||||||
else if (style.equals("full"))
|
|
||||||
val = DateFormat.FULL;
|
|
||||||
|
|
||||||
if (type.equals("time"))
|
|
||||||
format = DateFormat.getTimeInstance(val, loc);
|
|
||||||
else
|
|
||||||
format = DateFormat.getDateInstance(val, loc);
|
|
||||||
|
|
||||||
if (style != null && val == DateFormat.DEFAULT)
|
|
||||||
{
|
|
||||||
SimpleDateFormat sdf = (SimpleDateFormat) format;
|
|
||||||
sdf.applyPattern(style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (type.equals("choice"))
|
|
||||||
{
|
|
||||||
formatClass = java.lang.Number.class;
|
|
||||||
|
|
||||||
if (style == null)
|
|
||||||
throw new
|
|
||||||
IllegalArgumentException ("style required for choice format");
|
|
||||||
format = new ChoiceFormat (style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MessageFormat extends Format
|
public class MessageFormat extends Format
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @author Tom Tromey (tromey@cygnus.com)
|
||||||
|
* @author Jorge Aliss (jaliss@hotmail.com)
|
||||||
|
* @date March 3, 1999
|
||||||
|
*/
|
||||||
|
/* 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 to 1.2, except serialization.
|
||||||
|
* and parsing.
|
||||||
|
*/
|
||||||
|
private static final class MessageFormatElement
|
||||||
|
{
|
||||||
|
// Argument number.
|
||||||
|
int argNumber;
|
||||||
|
// Formatter to be used. This is the format set by setFormat.
|
||||||
|
Format setFormat;
|
||||||
|
// Formatter to be used based on the type.
|
||||||
|
Format format;
|
||||||
|
|
||||||
|
// Argument will be checked to make sure it is an instance of this
|
||||||
|
// class.
|
||||||
|
Class formatClass;
|
||||||
|
|
||||||
|
// Formatter type.
|
||||||
|
String type;
|
||||||
|
// Formatter style.
|
||||||
|
String style;
|
||||||
|
|
||||||
|
// Text to follow this element.
|
||||||
|
String trailer;
|
||||||
|
|
||||||
|
// Recompute the locale-based formatter.
|
||||||
|
void setLocale (Locale loc)
|
||||||
|
{
|
||||||
|
if (type == null)
|
||||||
|
;
|
||||||
|
else if (type.equals("number"))
|
||||||
|
{
|
||||||
|
formatClass = java.lang.Number.class;
|
||||||
|
|
||||||
|
if (style == null)
|
||||||
|
format = NumberFormat.getInstance(loc);
|
||||||
|
else if (style.equals("currency"))
|
||||||
|
format = NumberFormat.getCurrencyInstance(loc);
|
||||||
|
else if (style.equals("percent"))
|
||||||
|
format = NumberFormat.getPercentInstance(loc);
|
||||||
|
else if (style.equals("integer"))
|
||||||
|
{
|
||||||
|
NumberFormat nf = NumberFormat.getNumberInstance(loc);
|
||||||
|
nf.setMaximumFractionDigits(0);
|
||||||
|
nf.setGroupingUsed(false);
|
||||||
|
format = nf;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
format = NumberFormat.getNumberInstance(loc);
|
||||||
|
DecimalFormat df = (DecimalFormat) format;
|
||||||
|
df.applyPattern(style);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type.equals("time") || type.equals("date"))
|
||||||
|
{
|
||||||
|
formatClass = java.util.Date.class;
|
||||||
|
|
||||||
|
int val = DateFormat.DEFAULT;
|
||||||
|
if (style == null)
|
||||||
|
;
|
||||||
|
else if (style.equals("short"))
|
||||||
|
val = DateFormat.SHORT;
|
||||||
|
else if (style.equals("medium"))
|
||||||
|
val = DateFormat.MEDIUM;
|
||||||
|
else if (style.equals("long"))
|
||||||
|
val = DateFormat.LONG;
|
||||||
|
else if (style.equals("full"))
|
||||||
|
val = DateFormat.FULL;
|
||||||
|
|
||||||
|
if (type.equals("time"))
|
||||||
|
format = DateFormat.getTimeInstance(val, loc);
|
||||||
|
else
|
||||||
|
format = DateFormat.getDateInstance(val, loc);
|
||||||
|
|
||||||
|
if (style != null && val == DateFormat.DEFAULT)
|
||||||
|
{
|
||||||
|
SimpleDateFormat sdf = (SimpleDateFormat) format;
|
||||||
|
sdf.applyPattern(style);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type.equals("choice"))
|
||||||
|
{
|
||||||
|
formatClass = java.lang.Number.class;
|
||||||
|
|
||||||
|
if (style == null)
|
||||||
|
throw new
|
||||||
|
IllegalArgumentException ("style required for choice format");
|
||||||
|
format = new ChoiceFormat (style);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static final long serialVersionUID = 6479157306784022952L;
|
private static final long serialVersionUID = 6479157306784022952L;
|
||||||
|
|
||||||
public static class Field extends Format.Field
|
public static class Field extends Format.Field
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue