com.sun.jini.lookup.entry
Class LookupAttributes

java.lang.Object
  extended by com.sun.jini.lookup.entry.LookupAttributes

public class LookupAttributes
extends Object

Some simple utilities for manipulating lookup service attributes. These are not high-performance operations; it is expected that they are called relatively infrequently.

Author:
Sun Microsystems, Inc.

Nested Class Summary
private static class LookupAttributes.FieldComparator
          Comparator for sorting fields.
 
Field Summary
private static LookupAttributes.FieldComparator comparator
          Comparator for sorting fields
private static Class[] noArg
           
 
Constructor Summary
private LookupAttributes()
           
 
Method Summary
static Entry[] add(Entry[] attrSets, Entry[] addAttrSets)
          Returns a new array containing the elements of the addAttrSets parameter (that are not duplicates of any of the elements already in the attrSets parameter) added to the elements of attrSets.
static Entry[] add(Entry[] attrSets, Entry[] addAttrSets, boolean checkSC)
          Returns a new array containing the elements of the addAttrSets parameter (that are not duplicates of any of the elements already in the attrSets parameter) added to the elements of attrSets.
private static void check(Entry e)
          Throws a SecurityException if parameter e is instanceof ServiceControlled.
static void check(Entry[] attrs, boolean nullOK)
          Throws an IllegalArgumentException if any element of the array is not an instance of a valid Entry class (the class is not public, or does not have a no-arg constructor, or has primitive public non-static non-final fields).
private static Entry[] concat(Entry[] attrs1, Entry[] attrs2)
          Return a concatenation of the two arrays.
private static boolean contains(Entry[] eSet, Entry e)
          Returns true if the Entry parameter e is an element of the Entry[] array parameter eSet; returns false otherwise.
private static boolean contains(Entry[] eSet1, Entry[] eSet2)
          Returns true if the Entry[] array parameter eSet1 contains the Entry[] array parameter eSet2; returns false otherwise.
private static Entry[] delete(Entry[] attrs, int i)
          Return a new array containing all but the given element.
private static boolean equal(Class c1, Class c2)
          Tests if two classes are equal, using the class equivalence semantics of the lookup service: same name.
static boolean equal(Entry[] attrSet1, Entry[] attrSet2)
          Tests that two Entry[] arrays are the same.
static boolean equal(Entry e1, Entry e2)
          Test that two entries are the same type, with the same public fields.
private static boolean equal(Object o1, Object o2)
          Returns true if the two input objects are the same in MarshalledObject form, false otherwise.
private static Field[] getFields(Entry e)
          Returns public fields, in super to subclass order, sorted alphabetically within a given class.
private static Field[] getFields(Entry e, Entry oe, Field[] ofields)
          Returns the public fields of the parameter e.
private static boolean isAssignableFrom(Class c1, Class c2)
          Tests if class c1 is equal to, or a superclass of, class c2, using the class equivalence semantics of the lookup service: same name.
private static boolean isDup(Entry[] attrs, int index)
          Test if the set at the given index is equal to any other set earlier in the Entry[] array parameter.
static boolean matches(Entry tmpl, Entry e)
          Test if the parameter tmpl is the same class as, or a superclass of, the parameter e, and that every non-null public field of tmpl is the same as the corresponding field of e.
static Entry[] modify(Entry[] attrSets, Entry[] attrSetTmpls, Entry[] modAttrSets)
          Returns a new array that contains copies of the attributes in the attrSets parameter, modified according to the contents of both the attrSetTmpls parameter and the modAttrSets parameter.
static Entry[] modify(Entry[] attrSets, Entry[] attrSetTmpls, Entry[] modAttrSets, boolean checkSC)
          Returns a new array that contains copies of the attributes in the attrSets parameter, modified according to the contents of both the attrSetTmpls parameter and the modAttrSets parameter.
private static Entry update(Entry e, Entry mods)
          Return a new entry that, for each non-null field of the parameter mods, has the same field value as mods, else the same field value as the parameter e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

comparator

private static final LookupAttributes.FieldComparator comparator
Comparator for sorting fields


noArg

private static final Class[] noArg
Constructor Detail

LookupAttributes

private LookupAttributes()
Method Detail

add

public static Entry[] add(Entry[] attrSets,
                          Entry[] addAttrSets)
Returns a new array containing the elements of the addAttrSets parameter (that are not duplicates of any of the elements already in the attrSets parameter) added to the elements of attrSets. The parameter arrays are not modified.

Note that attribute equality is defined in terms of MarshalledObject.equals on field values. The parameter arrays are not modified.

Throws an IllegalArgumentException if any element of addAttrSets is not an instance of a valid Entry class (the class is not public, or does not have a no-arg constructor, or has primitive public non-static non-final fields).


add

public static Entry[] add(Entry[] attrSets,
                          Entry[] addAttrSets,
                          boolean checkSC)
Returns a new array containing the elements of the addAttrSets parameter (that are not duplicates of any of the elements already in the attrSets parameter) added to the elements of attrSets. The parameter arrays are not modified.

Note that attribute equality is defined in terms of MarshalledObject.equals on field values. The parameter arrays are not modified.

If the checkSC parameter is true, then a SecurityException is thrown if any elements of the addAttrSets parameter are instanceof ServiceControlled.

Throws an IllegalArgumentException if any element of addAttrSets is not an instance of a valid Entry class (the class is not public, or does not have a no-arg constructor, or has primitive public non-static non-final fields).


modify

public static Entry[] modify(Entry[] attrSets,
                             Entry[] attrSetTmpls,
                             Entry[] modAttrSets)
Returns a new array that contains copies of the attributes in the attrSets parameter, modified according to the contents of both the attrSetTmpls parameter and the modAttrSets parameter. The parameter arrays and their Entry instances are not modified.

Throws an IllegalArgumentException if any element of attrSetTmpls or modAttrSets is not an instance of a valid Entry class (the class is not public, or does not have a no-arg constructor, or has primitive public non-static non-final fields).


modify

public static Entry[] modify(Entry[] attrSets,
                             Entry[] attrSetTmpls,
                             Entry[] modAttrSets,
                             boolean checkSC)
Returns a new array that contains copies of the attributes in the attrSets parameter, modified according to the contents of both the attrSetTmpls parameter and the modAttrSets parameter. The parameter arrays and their Entry instances are not modified.

If the checkSC parameter is true, then a SecurityException is thrown if any elements of the attrSets parameter that would be deleted or modified are instanceof ServiceControlled.

Throws an IllegalArgumentException if any element of attrSetTmpls or modAttrSets is not an instance of a valid Entry class (the class is not public, or does not have a no-arg constructor, or has primitive public non-static non-final fields).


equal

public static boolean equal(Entry e1,
                            Entry e2)
Test that two entries are the same type, with the same public fields. Attribute equality is defined in terms of MarshalledObject.equals on field values.


equal

public static boolean equal(Entry[] attrSet1,
                            Entry[] attrSet2)
Tests that two Entry[] arrays are the same.


matches

public static boolean matches(Entry tmpl,
                              Entry e)
Test if the parameter tmpl is the same class as, or a superclass of, the parameter e, and that every non-null public field of tmpl is the same as the corresponding field of e. Attribute equality is defined in terms of MarshalledObject.equals on field values.


check

public static void check(Entry[] attrs,
                         boolean nullOK)
Throws an IllegalArgumentException if any element of the array is not an instance of a valid Entry class (the class is not public, or does not have a no-arg constructor, or has primitive public non-static non-final fields). If nullOK is false, and any element of the array is null, a NullPointerException is thrown.


check

private static void check(Entry e)
Throws a SecurityException if parameter e is instanceof ServiceControlled.


isDup

private static boolean isDup(Entry[] attrs,
                             int index)
Test if the set at the given index is equal to any other set earlier in the Entry[] array parameter.


update

private static Entry update(Entry e,
                            Entry mods)
Return a new entry that, for each non-null field of the parameter mods, has the same field value as mods, else the same field value as the parameter e.


equal

private static boolean equal(Object o1,
                             Object o2)
Returns true if the two input objects are the same in MarshalledObject form, false otherwise.


equal

private static boolean equal(Class c1,
                             Class c2)
Tests if two classes are equal, using the class equivalence semantics of the lookup service: same name.


isAssignableFrom

private static boolean isAssignableFrom(Class c1,
                                        Class c2)
Tests if class c1 is equal to, or a superclass of, class c2, using the class equivalence semantics of the lookup service: same name.


getFields

private static Field[] getFields(Entry e)
Returns public fields, in super to subclass order, sorted alphabetically within a given class.


getFields

private static Field[] getFields(Entry e,
                                 Entry oe,
                                 Field[] ofields)
Returns the public fields of the parameter e. If e and parameter oe have the same class, then returns parameter ofields, otherwise ensures that e has at least as many fields as does parameter ofields.


concat

private static Entry[] concat(Entry[] attrs1,
                              Entry[] attrs2)
Return a concatenation of the two arrays.


delete

private static Entry[] delete(Entry[] attrs,
                              int i)
Return a new array containing all but the given element.


contains

private static boolean contains(Entry[] eSet,
                                Entry e)
Returns true if the Entry parameter e is an element of the Entry[] array parameter eSet; returns false otherwise.


contains

private static boolean contains(Entry[] eSet1,
                                Entry[] eSet2)
Returns true if the Entry[] array parameter eSet1 contains the Entry[] array parameter eSet2; returns false otherwise. That is, this method determines if eSet2 is a subset of eSet1.



Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.