jpos.config.simple
Class SimpleEntry

java.lang.Object
  |
  +--jpos.config.simple.SimpleEntry
All Implemented Interfaces:
java.lang.Comparable, JposEntry, java.io.Serializable

public class SimpleEntry
extends java.lang.Object
implements JposEntry, java.io.Serializable, java.lang.Comparable

This is a simple implementation of the JposEntry interface using a Hashtable to collect the properties

Since:
0.1 (Philly 99 meeting)
Author:
E. Michael Maximilien (maxim@us.ibm.com)
See Also:
Serialized Form

Inner Class Summary
static class SimpleEntry.Prop
          Inner class to represent a property of a JposEntry
 
Inner classes inherited from class jpos.config.JposEntry
JposEntry.Prop
 
Field Summary
static long serialVersionUID
          serialVersionUID constant to maintain serialization compatibility between releases
 
Fields inherited from interface jpos.config.JposEntry
DEVICE_CATEGORY_PROP_NAME, JPOS_VERSION_PROP_NAME, LOGICAL_NAME_PROP_NAME, PRODUCT_DESCRIPTION_PROP_NAME, PRODUCT_NAME_PROP_NAME, PRODUCT_URL_PROP_NAME, SERVICE_CLASS_PROP_NAME, SI_FACTORY_CLASS_PROP_NAME, VENDOR_NAME_PROP_NAME, VENDOR_URL_PROP_NAME
 
Constructor Summary
  SimpleEntry()
          Default ctor (sets the JposRegPopulator to null)
  SimpleEntry(JposRegPopulator populator)
          One argument ctor taking the JposRegPopulator for this entry
(package private) SimpleEntry(java.lang.String logicalName)
          One argument ctor taking the LogicalName this entry
  SimpleEntry(java.lang.String logicalName, JposRegPopulator populator)
          One argument ctor taking the JposRegPopulator for this entry
 
Method Summary
 void add(JposEntry.Prop prop)
          Adds a new property
 java.lang.Object addProperty(java.lang.String propName, java.lang.Object propValue)
          Adds a property to the JposEntry object.
protected static void checkNull(java.lang.Object object)
          Checks that the Object argument is not null and if it is throw a IllegalArgumentException
 int compareTo(java.lang.Object other)
           
 JposEntry copy()
           
 JposEntry.Prop createProp(java.lang.String propName, java.lang.Object propValue, java.lang.Class propType)
           
 boolean equals(JposEntry otherEntry)
           
 boolean equals(java.lang.Object object)
           
 java.lang.String getLogicalName()
           
 JposEntry.Prop getProp(java.lang.String propName)
          Returns a JposEntry.Prop with name specified.
 int getPropertyCount()
           
 java.util.Enumeration getPropertyNames()
           
 java.lang.Class getPropertyType(java.lang.String propName)
           
 java.lang.Object getPropertyValue(java.lang.String propName)
           
 java.util.Iterator getProps()
          Returns an Iterator of JposEntry.Prop in this entry
 JposRegPopulator getRegPopulator()
           
 boolean hasProp(JposEntry.Prop prop)
           
 boolean hasPropertyWithName(java.lang.String propName)
           
 boolean hasPropertyWithValue(java.lang.Object propValue)
           
 void modify(JposEntry.Prop prop)
          Modifies the property with name of property passed with the new value if that property currently exist in the entry otherwise does nothing
 java.lang.Object modifyPropertyValue(java.lang.String propName, java.lang.Object propValue)
          Modifies the property value of the property passed
 void remove(JposEntry.Prop prop)
          Removes the property
 java.lang.Object removeProperty(java.lang.String propName)
          Looks for a property with name specified and removes it.
(package private)  void setRegPopulator(JposRegPopulator populator)
          Sets the JposRegPopulator that loads/saves this entry.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
serialVersionUID constant to maintain serialization compatibility between releases
Since:
1.3 (SF 2K meeting)
Constructor Detail

SimpleEntry

public SimpleEntry()
Default ctor (sets the JposRegPopulator to null)
Since:
1.3 (Washington DC 2001 meeting)

SimpleEntry

public SimpleEntry(JposRegPopulator populator)
One argument ctor taking the JposRegPopulator for this entry
Parameters:
populator - the JposRegPopulator for this entry
Since:
1.3 (Washington DC 2001 meeting)

SimpleEntry

public SimpleEntry(java.lang.String logicalName,
                   JposRegPopulator populator)
One argument ctor taking the JposRegPopulator for this entry
Parameters:
logicalName - the logical name for this entry
populator - the JposRegPopulator for this entry
Since:
1.3 (Washington DC 2001 meeting)

SimpleEntry

SimpleEntry(java.lang.String logicalName)
One argument ctor taking the LogicalName this entry
Parameters:
logicalName - the logical name string for this entry
Since:
2.0.0
Method Detail

getPropertyCount

public int getPropertyCount()
Specified by:
getPropertyCount in interface JposEntry
Returns:
count of number of properties
Since:
0.1 (Philly 99 meeting)

getPropertyNames

public java.util.Enumeration getPropertyNames()
Specified by:
getPropertyNames in interface JposEntry
Returns:
an enumerator for the properties names
Since:
0.1 (Philly 99 meeting)

hasPropertyWithName

public boolean hasPropertyWithName(java.lang.String propName)
Specified by:
hasPropertyWithName in interface JposEntry
Parameters:
propName - the property name String
Returns:
true if there is a property by the name specified
Since:
0.1 (Philly 99 meeting)

hasPropertyWithValue

public boolean hasPropertyWithValue(java.lang.Object propValue)
Specified by:
hasPropertyWithValue in interface JposEntry
Parameters:
propValue - the property's value Object
Returns:
true if there is a property by the value specified NOTE: Object.equals method will be used to compare
Since:
0.1 (Philly 99 meeting)

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.String propName)
Specified by:
getPropertyValue in interface JposEntry
Parameters:
propName - the property's propName String
Returns:
the property's value Object
Since:
0.1 (Philly 99 meeting)

getPropertyType

public java.lang.Class getPropertyType(java.lang.String propName)
Specified by:
getPropertyType in interface JposEntry
Parameters:
propName - the property's name String
Returns:
the property's type
Since:
2.0.0

modifyPropertyValue

public java.lang.Object modifyPropertyValue(java.lang.String propName,
                                            java.lang.Object propValue)
                                     throws java.lang.IllegalArgumentException
Modifies the property value of the property passed
Specified by:
modifyPropertyValue in interface JposEntry
Parameters:
propName - the property name
propValue - the new property value
Returns:
the oldPropValue or null if this property does not exist
Throws:
java.lang.IllegalArgumentException - if the propName or propValue is null
Since:
1.3 (Tokyo 2001 meeting)

addProperty

public java.lang.Object addProperty(java.lang.String propName,
                                    java.lang.Object propValue)
                             throws java.lang.IllegalArgumentException
Adds a property to the JposEntry object. NOTE: any property with the same name gets overlaid
Specified by:
addProperty in interface JposEntry
Parameters:
propName - the name of this property (should be unique per property)
propValue - the properties value Object
Throws:
java.lang.IllegalArgumentException - if the propName or propValue is null
Since:
0.1 (Philly 99 meeting)

removeProperty

public java.lang.Object removeProperty(java.lang.String propName)
Looks for a property with name specified and removes it. If none exist then does nothing and return null
Specified by:
removeProperty in interface JposEntry
Parameters:
propName - the name String of the property to remove
Returns:
the value for the name passed
Since:
0.1 (Philly 99 meeting)

equals

public boolean equals(JposEntry otherEntry)
Specified by:
equals in interface JposEntry
Returns:
true if the two JposEntries have the same properties
Since:
0.1 (Philly 99 meeting)

copy

public JposEntry copy()
Returns:
a copy of this JposEntry object
Since:
1.3 (Tokyo 2001 meeting)

getRegPopulator

public JposRegPopulator getRegPopulator()
Specified by:
getRegPopulator in interface JposEntry
Returns:
the JposRegPopulator that loads/saves this entry. If null the default populator is used
Since:
1.3 (Washington DC 2001 meeting)

getLogicalName

public java.lang.String getLogicalName()
Specified by:
getLogicalName in interface JposEntry
Returns:
the logical name for this JposEntry. This is a shortcut for easily getting the logical name vs getting a property and passing the logical name constant
Since:
1.3 (Washington DC 2001 meeting)
See Also:
JposEntry.getPropertyValue(java.lang.String), JposEntry.LOGICAL_NAME_PROP_NAME

getProp

public JposEntry.Prop getProp(java.lang.String propName)
Description copied from interface: JposEntry
Returns a JposEntry.Prop with name specified.

Changes to that property object are not reflected in this entry. You must apply the changes to the property to the entry by calling modifyProp() method

Specified by:
getProp in interface JposEntry
Parameters:
propName - the property name
Returns:
the JposEntry.Prop with name specified or null if no such property exist
Since:
2.0.0

getProps

public java.util.Iterator getProps()
Description copied from interface: JposEntry
Returns an Iterator of JposEntry.Prop in this entry

Changes to any of the returned property object are not reflected in this entry. You must apply the changes to the property to the entry by calling modifyProp() method

Specified by:
getProps in interface JposEntry
Returns:
an Iterator over the properties in this JposEntry as JposEntry.Prop objects
Since:
1.3 (Washington DC 2001)

add

public void add(JposEntry.Prop prop)
         throws java.lang.IllegalArgumentException
Adds a new property
Specified by:
add in interface JposEntry
Parameters:
prop - the JposEntry.Prop to add
Throws:
java.lang.IllegalArgumentException - if the argument is null
Since:
1.3 (Washington DC 2001 meeting)

remove

public void remove(JposEntry.Prop prop)
Removes the property
Specified by:
remove in interface JposEntry
Parameters:
prop - the JposEntry.Prop to remove
Since:
1.3 (Washington DC 2001 meeting)

modify

public void modify(JposEntry.Prop prop)
            throws java.lang.IllegalArgumentException
Modifies the property with name of property passed with the new value if that property currently exist in the entry otherwise does nothing
Specified by:
modify in interface JposEntry
Parameters:
prop - the JposEntry.Prop to modify
Throws:
java.lang.IllegalArgumentException - if the prop is null
Since:
2.0.0

hasProp

public boolean hasProp(JposEntry.Prop prop)
Specified by:
hasProp in interface JposEntry
Parameters:
prop - the JposEntry.Prop to check for
Returns:
true if this entry has the property passed
Since:
1.3 (Washington DC 2001 meeting)

createProp

public JposEntry.Prop createProp(java.lang.String propName,
                                 java.lang.Object propValue,
                                 java.lang.Class propType)
                          throws JposConfigException
Specified by:
createProp in interface JposEntry
Parameters:
propName - the property name
propValue - the property value
propType - the property type (valid for this value)
Returns:
a JposEntry.Prop object created with the tripplet passed as arguments
Throws:
JposConfigException - if any of the argument is null or the property value and type mismatch or this is not a valid property type
Since:
2.0.0
See Also:
JposEntryConst.PROP_TYPES

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object
Returns:
true if the two JposEntries have the same properties
Since:
1.3 (SF 2K meeting)

compareTo

public int compareTo(java.lang.Object other)
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
otherEntry - the other JposEntry
Returns:
0 if two entries are the same -1 if this is less or 1 of more than other the comparison for > and < uses the logicalName of the entry to decide

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a String representation of this entry
Since:
1.3 (SF 2K meeting)

setRegPopulator

void setRegPopulator(JposRegPopulator populator)
Sets the JposRegPopulator that loads/saves this entry. If null the default populator is used
Since:
1.3 (Washington DC 2001 meeting)

checkNull

protected static void checkNull(java.lang.Object object)
                         throws java.lang.IllegalArgumentException
Checks that the Object argument is not null and if it is throw a IllegalArgumentException
Parameters:
object - the Object argument
Throws:
java.lang.IllegalArgumentException - if the object is null


This API and code belongs to the JavaPOS committee please see LISCENCE file for details