Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.port80.util.attr
Class AttrTable  view AttrTable download AttrTable.java

java.lang.Object
  extended bycom.port80.util.attr.AttrTable
All Implemented Interfaces:
IAttrTable

public class AttrTable
extends java.lang.Object
implements IAttrTable

A base class to access an attribute table. . Attribute table always store attributes in their native format, eg. color as Color object. Clients accessing the attribute table should knows the attribute type it is accessing. . For convenient, attributes can always be get/store through a String representation. attrString() always return the String representation of the attribute object and createAttr() method converts the String to the appropriate object type by consulting the AttrRegistry.


Field Summary
private  IAttrRegistry attrRegistry
           
private  java.util.Map attrTable
           
private static java.lang.String CLASSNAME
           
private static boolean DEBUG
           
private static java.lang.String NAME
           
private static java.lang.String PACKAGENAME
           
protected  IAttrTable parentAttrTable
           
private static int VERSION
           
private static java.lang.String VERSIONNAME
           
 
Constructor Summary
AttrTable(IAttrTable parent)
           
AttrTable(IAttrTable parent, IAttrRegistry r)
           
 
Method Summary
 java.util.Set attrKeySet()
          All local attribute names (include value==null).
private  void checkOverwritting(java.lang.String methodname, java.lang.String attrname, java.lang.Object oldfactory, IAttrFactory newfactory)
           
 void clearAttrs()
          Remove all local attributes.
 java.lang.Object getAttr(java.lang.String name)
          Get attribute.
 java.lang.String getAttrAsString(java.lang.String name)
          Return a String representation of the specified attribute object.
 boolean getAttrBool(java.lang.String name)
           
 boolean getAttrBool(java.lang.String name, boolean def)
           
 java.lang.Object getAttrCached(java.lang.String name)
          Get and cache an object attribute from a string attribute, eg.
 double getAttrDouble(java.lang.String name)
           
 double getAttrDouble(java.lang.String name, double def)
           
 float getAttrFloat(java.lang.String name)
           
 float getAttrFloat(java.lang.String name, float def)
           
 int getAttrInt(java.lang.String name)
           
 int getAttrInt(java.lang.String name, int def)
           
 long getAttrLong(java.lang.String name)
           
 long getAttrLong(java.lang.String name, long def)
           
 IAttrRegistry getAttrRegistry()
           
 java.lang.String getAttrString(java.lang.String name)
           
 boolean hasAttr(java.lang.String name)
          Check if given attribute is defined locally.
 void initAttr(java.lang.String name, boolean value)
           
 void initAttr(java.lang.String name, double value)
           
 void initAttr(java.lang.String name, float value)
           
 void initAttr(java.lang.String name, IAttrFactory factory)
           
 void initAttr(java.lang.String name, IAttrFactory factory, java.lang.Object value)
           
 void initAttr(java.lang.String name, int value)
           
 void initAttr(java.lang.String name, long value)
           
 void initAttr(java.lang.String name, java.lang.String value)
           
 java.lang.Object removeAttr(java.lang.String name)
          Remove a local attribute.
 void removeUnregisteredAttrs()
          Remove all unregistered attributes.
 java.lang.Object setAttr(java.lang.String name, boolean value)
           
 java.lang.Object setAttr(java.lang.String name, double value)
           
 java.lang.Object setAttr(java.lang.String name, float value)
           
 java.lang.Object setAttr(java.lang.String name, int value)
           
 java.lang.Object setAttr(java.lang.String name, long value)
           
 java.lang.Object setAttr(java.lang.String name, java.lang.Object value)
          Setting attributes always affect the local table only.
 java.lang.Object setAttrFromString(java.lang.String name, java.lang.String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

private static final java.lang.String NAME
See Also:
Constant Field Values

PACKAGENAME

private static final java.lang.String PACKAGENAME
See Also:
Constant Field Values

CLASSNAME

private static final java.lang.String CLASSNAME
See Also:
Constant Field Values

VERSION

private static final int VERSION
See Also:
Constant Field Values

VERSIONNAME

private static final java.lang.String VERSIONNAME
See Also:
Constant Field Values

DEBUG

private static boolean DEBUG

parentAttrTable

protected IAttrTable parentAttrTable

attrRegistry

private IAttrRegistry attrRegistry

attrTable

private java.util.Map attrTable
Constructor Detail

AttrTable

public AttrTable(IAttrTable parent)

AttrTable

public AttrTable(IAttrTable parent,
                 IAttrRegistry r)
Method Detail

getAttrRegistry

public IAttrRegistry getAttrRegistry()
Specified by:
getAttrRegistry in interface IAttrTable

getAttr

public java.lang.Object getAttr(java.lang.String name)
Get attribute. Automatically get the default attribute if local attribute is not defined.

Specified by:
getAttr in interface IAttrTable

getAttrString

public java.lang.String getAttrString(java.lang.String name)
Specified by:
getAttrString in interface IAttrTable

getAttrBool

public boolean getAttrBool(java.lang.String name)
Specified by:
getAttrBool in interface IAttrTable

getAttrInt

public int getAttrInt(java.lang.String name)
Specified by:
getAttrInt in interface IAttrTable

getAttrLong

public long getAttrLong(java.lang.String name)
Specified by:
getAttrLong in interface IAttrTable

getAttrFloat

public float getAttrFloat(java.lang.String name)
Specified by:
getAttrFloat in interface IAttrTable

getAttrDouble

public double getAttrDouble(java.lang.String name)
Specified by:
getAttrDouble in interface IAttrTable

getAttrBool

public boolean getAttrBool(java.lang.String name,
                           boolean def)
Specified by:
getAttrBool in interface IAttrTable

getAttrInt

public int getAttrInt(java.lang.String name,
                      int def)
Specified by:
getAttrInt in interface IAttrTable

getAttrLong

public long getAttrLong(java.lang.String name,
                        long def)
Specified by:
getAttrLong in interface IAttrTable

getAttrFloat

public float getAttrFloat(java.lang.String name,
                          float def)
Specified by:
getAttrFloat in interface IAttrTable

getAttrDouble

public double getAttrDouble(java.lang.String name,
                            double def)
Specified by:
getAttrDouble in interface IAttrTable

setAttr

public java.lang.Object setAttr(java.lang.String name,
                                java.lang.Object value)
Setting attributes always affect the local table only. If attribute name is registered, attribute value must match the registered type. Unregistered attribute values can be any type.

Specified by:
setAttr in interface IAttrTable

setAttr

public java.lang.Object setAttr(java.lang.String name,
                                boolean value)
Specified by:
setAttr in interface IAttrTable

setAttr

public java.lang.Object setAttr(java.lang.String name,
                                int value)
Specified by:
setAttr in interface IAttrTable

setAttr

public java.lang.Object setAttr(java.lang.String name,
                                long value)
Specified by:
setAttr in interface IAttrTable

setAttr

public java.lang.Object setAttr(java.lang.String name,
                                float value)
Specified by:
setAttr in interface IAttrTable

setAttr

public java.lang.Object setAttr(java.lang.String name,
                                double value)
Specified by:
setAttr in interface IAttrTable

hasAttr

public boolean hasAttr(java.lang.String name)
Description copied from interface: IAttrTable
Check if given attribute is defined locally. @return true if exists locally (include value==null).

Specified by:
hasAttr in interface IAttrTable

attrKeySet

public java.util.Set attrKeySet()
Description copied from interface: IAttrTable
All local attribute names (include value==null).

Specified by:
attrKeySet in interface IAttrTable

removeAttr

public java.lang.Object removeAttr(java.lang.String name)
Description copied from interface: IAttrTable
Remove a local attribute. @return attribute removed.

Specified by:
removeAttr in interface IAttrTable

removeUnregisteredAttrs

public void removeUnregisteredAttrs()
Remove all unregistered attributes. Remove everything if no attribute registry defined.

Specified by:
removeUnregisteredAttrs in interface IAttrTable

clearAttrs

public void clearAttrs()
Description copied from interface: IAttrTable
Remove all local attributes.

Specified by:
clearAttrs in interface IAttrTable

getAttrCached

public java.lang.Object getAttrCached(java.lang.String name)
Get and cache an object attribute from a string attribute, eg. -pos and pos.

Specified by:
getAttrCached in interface IAttrTable

getAttrAsString

public java.lang.String getAttrAsString(java.lang.String name)
Return a String representation of the specified attribute object.

Specified by:
getAttrAsString in interface IAttrTable

setAttrFromString

public java.lang.Object setAttrFromString(java.lang.String name,
                                          java.lang.String value)
Specified by:
setAttrFromString in interface IAttrTable

initAttr

public void initAttr(java.lang.String name,
                     IAttrFactory factory)

initAttr

public void initAttr(java.lang.String name,
                     IAttrFactory factory,
                     java.lang.Object value)

initAttr

public void initAttr(java.lang.String name,
                     java.lang.String value)

initAttr

public void initAttr(java.lang.String name,
                     boolean value)

initAttr

public void initAttr(java.lang.String name,
                     int value)

initAttr

public void initAttr(java.lang.String name,
                     long value)

initAttr

public void initAttr(java.lang.String name,
                     float value)

initAttr

public void initAttr(java.lang.String name,
                     double value)

checkOverwritting

private void checkOverwritting(java.lang.String methodname,
                               java.lang.String attrname,
                               java.lang.Object oldfactory,
                               IAttrFactory newfactory)