wt.federation
Class DirectoryInputStream

java.lang.Object
  extended bywt.federation.DirectoryInputStream
All Implemented Interfaces:
PersistentRetrieveIfc, Serializable

public class DirectoryInputStream
extends Object
implements PersistentRetrieveIfc, Serializable

DirectoryInputStream reads entries from directory services and translates them to Windchill objects.

See Also:
Serialized Form

Field Summary
private static String BLOB
           
private  DirContext directoryContext
           
private  Hashtable directoryEntry
           
private  String distinguishedName
           
private  long expirationTime
           
private  Hashtable nameTranslationTable
           
private  String prefix
           
private  Hashtable referenceObject
           
private static String RESOURCE
           
private  FederatedDirectoryService service
           
private  ServiceIdentifier serviceId
           
private  DirectoryTranslationTable translationTable
           
private static boolean VERBOSE
           
private static boolean VERBOSE_CONTENT
           
private static String versionID
           
 
Constructor Summary
DirectoryInputStream(DirContext context, FederatedDirectoryService service)
          Create a DirectoryInputStream instance.
DirectoryInputStream(DirContext context, FederatedDirectoryService service, Persistable referenceObject)
          Create a DirectoryInputStream instance.
DirectoryInputStream(FederatedDirectoryService service)
          Create a DirectoryInputStream instance.
 
Method Summary
 void close()
          Close the directory input stream.
private  Object createObject()
          Create a Java object from the set of attributes previously read from a directory entry.
private  Object createObject(Class objectClass)
          Create a Java object from the set of attributes previously read from a directory entry.
 InputStream getAsciiStream(String attributeName)
          Get the value of a column in the current row as a stream of ASCII characters.
 Hashtable getAttributes()
          Return the attributes read from the directory entry.
private  Object getAttributeValue(String fieldName)
          Translate a field name to a directory attribute name and return the associated value from the directory entry previously read.
 BigDecimal getBigDecimal(String attributeName)
          Get the value of a column in the current row as a BigDecimal
 InputStream getBinaryStream(String attributeName)
          Get the value of a column in the current row as a stream of uninterpreted bytes.
 boolean getBoolean(String attributeName)
          Get the value of a column in the current row as a Java boolean.
 Boolean getBooleanObject(String attributeName)
          Get the value of a column in the current row as a Java boolean.
 byte getByte(String attributeName)
          Get the value of a column in the current row as a Java byte.
 Byte getByteObject(String attributeName)
          Get the value of a column in the current row as a Java byte.
 byte[] getBytes(String attributeName)
          Get the value of a column in the current row as a Java byte array.
 char getChar(String attributeName)
          Get the value of a column in the current row as a Java char.
 Character getCharObject(String attributeName)
          Get the value of a column in the current row as a Java char.
 String getContainer()
          Get the current container name.
 Date getDate(String attributeName)
          Get the value of a column in the current row as a java.sql.Date object.
private  Object getDirectoryAttributeValue(String attrName)
          Return the value associated with a specified directory attribute name.
 double getDouble(String attributeName)
          Get the value of a column in the current row as a Java double.
 Double getDoubleObject(String attributeName)
          Get the value of a column in the current row as a Java double.
 float getFloat(String attributeName)
          Get the value of a column in the current row as a Java float.
 Float getFloatObject(String attributeName)
          Get the value of a column in the current row as a Java float.
 Object getInlineObject(String attributeName, String blobAttributeName)
          Get the value of a blob column as a Java Object.
 int getInt(String attributeName)
          Get the value of a column in the current row as a Java int.
 Integer getIntObject(String attributeName)
          Get the value of a column in the current row as a Java int.
 LobLocator getLobLocator(String attributeName)
          Get a LobLocator for the given attribute.
 long getLong(String attributeName)
          Get the value of a column in the current row as a Java long.
 Long getLongObject(String attributeName)
          Get the value of a column in the current row as a Java long.
 Object getObject(String attributeName)
          Get the value of a column in the current row as a Java object.
 String getPrefix()
          Return the currently established field name prefix.
 ServiceIdentifier getServiceId()
          Return the currently established identifier of the service from which the object stream is originating.
 short getShort(String attributeName)
          Get the value of a column in the current row as a Java short.
 Short getShortObject(String attributeName)
          Get the value of a column in the current row as a Java short.
 Object getSmallObject(String attributeName)
          Get the value of a column in the current row as a Java object.
 String getString(String attributeName)
          Get the value of a column in the current row as a Java String.
 Time getTime(String attributeName)
          Get the value of a column in the current row as a java.sql.Time object.
 Timestamp getTimestamp(String attributeName)
          Get the value of a column in the current row as a java.sql.Timestamp object.
 InputStream getUnicodeStream(String attributeName)
          Get the value of a column in the current row as a stream of Unicode characters and then read in chunks.
private  void initialize(DirContext context, FederatedDirectoryService service, Persistable referenceObject)
          Initialize a DirectoryInputStream instance.
 boolean next()
          Satisfies the PersistentRetrieveIfc requirement for a method by this name.
 Hashtable readDirectoryEntry(String dn)
          Read a directory entry and return a Hashtable containing its attributes.
 Object readDirectoryObject(String dn)
          Read a directory entry and create a Java object from it.
 Object readDirectoryObject(String dn, Hashtable entry)
          Read a directory entry and create a Java object from it.
 ObjectMappable readObject(String attribute_name, ObjectMappable obj, Class concrete_class, boolean isRequired)
          Get the values corresponding to a nested ObjectMappable Object.
 void setPrefix(String prefix)
          Establish a field name prefix for all attribute name translations.
 void setServiceId(FederatedService service)
          Establish the identifier of the service from which the object stream is originating.
 boolean wasNull()
          A column may have the value of SQL NULL; wasNull reports whether the last column read had this special value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionID

private static final String versionID
See Also:
Constant Field Values

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

directoryContext

private DirContext directoryContext

directoryEntry

private Hashtable directoryEntry

distinguishedName

private String distinguishedName

expirationTime

private long expirationTime

nameTranslationTable

private Hashtable nameTranslationTable

prefix

private String prefix

referenceObject

private Hashtable referenceObject

service

private FederatedDirectoryService service

serviceId

private ServiceIdentifier serviceId

translationTable

private DirectoryTranslationTable translationTable

VERBOSE

private static boolean VERBOSE

VERBOSE_CONTENT

private static boolean VERBOSE_CONTENT

BLOB

private static final String BLOB
See Also:
Constant Field Values
Constructor Detail

DirectoryInputStream

public DirectoryInputStream(DirContext context,
                            FederatedDirectoryService service)
                     throws FederationServicesException
Create a DirectoryInputStream instance.

Parameters:
context - directory context
service - FederatedDirectoryService object from which the stream originates

DirectoryInputStream

public DirectoryInputStream(FederatedDirectoryService service)
                     throws FederationServicesException
Create a DirectoryInputStream instance.

Parameters:
service - FederatedDirectoryService object from which the stream originates

DirectoryInputStream

public DirectoryInputStream(DirContext context,
                            FederatedDirectoryService service,
                            Persistable referenceObject)
                     throws FederationServicesException
Create a DirectoryInputStream instance.

Parameters:
context - directory context
service - FederatedDirectoryService object from which the stream originates
Method Detail

initialize

private void initialize(DirContext context,
                        FederatedDirectoryService service,
                        Persistable referenceObject)
                 throws FederationServicesException
Initialize a DirectoryInputStream instance.

Parameters:
context - directory context
service - FederatedDirectoryService object from which the stream originates
Throws:
FederationServicesException

close

public void close()
Close the directory input stream.

Specified by:
close in interface PersistentRetrieveIfc

setServiceId

public void setServiceId(FederatedService service)
                  throws WTPropertyVetoException,
                         FederationServicesException
Establish the identifier of the service from which the object stream is originating.

Parameters:
service - FederatedService object from which the stream originates
Throws:
WTPropertyVetoException
FederationServicesException

getServiceId

public ServiceIdentifier getServiceId()
Return the currently established identifier of the service from which the object stream is originating.

Returns:
ServiceIdentifier identifier of FederatedService object

setPrefix

public void setPrefix(String prefix)
Establish a field name prefix for all attribute name translations.

Parameters:
prefix - string to preface to all field names used as attribute translation keys

getPrefix

public String getPrefix()
Return the currently established field name prefix.

Returns:
String currently established prefix

readDirectoryObject

public Object readDirectoryObject(String dn)
                           throws FederationServicesException
Read a directory entry and create a Java object from it.

Parameters:
dn - directory distinguished name of the entry to read
Returns:
Object next object read from input stream
Throws:
FederationServicesException

readDirectoryObject

public Object readDirectoryObject(String dn,
                                  Hashtable entry)
                           throws FederationServicesException
Read a directory entry and create a Java object from it.

Parameters:
dn - distinguished name of previously read directory entry
entry - Hashtable containining attributes of entry
Returns:
Object next object read from input stream
Throws:
FederationServicesException

readDirectoryEntry

public Hashtable readDirectoryEntry(String dn)
                             throws FederationServicesException
Read a directory entry and return a Hashtable containing its attributes.

Parameters:
dn - directory distinguished name of the entry to read
Returns:
Hashtable the directory entry represented as a Properties object
Throws:
FederationServicesException

getAttributes

public Hashtable getAttributes()
Return the attributes read from the directory entry.

Returns:
Hashtable the attributes read from the directory, keyed by directory attribute name

createObject

private Object createObject()
                     throws FederationServicesException
Create a Java object from the set of attributes previously read from a directory entry.

Returns:
Object
Throws:
FederationServicesException

createObject

private Object createObject(Class objectClass)
                     throws FederationServicesException
Create a Java object from the set of attributes previously read from a directory entry.

Parameters:
objectClass - the Java class for which to create an instance
Returns:
Object
Throws:
FederationServicesException

getAttributeValue

private Object getAttributeValue(String fieldName)
Translate a field name to a directory attribute name and return the associated value from the directory entry previously read.

Parameters:
fieldName - name of field in a Java object
Returns:
Object directory attribute value

getDirectoryAttributeValue

private Object getDirectoryAttributeValue(String attrName)
Return the value associated with a specified directory attribute name.

Parameters:
attrName - name of foreign attribute
Returns:
String foreign attribute value

getAsciiStream

public InputStream getAsciiStream(String attributeName)
                           throws SQLException
Get the value of a column in the current row as a stream of ASCII characters.

Specified by:
getAsciiStream in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is null
Throws:
SQLException - if a database-access error occurs.

getBigDecimal

public BigDecimal getBigDecimal(String attributeName)
                         throws SQLException
Get the value of a column in the current row as a BigDecimal

Specified by:
getBigDecimal in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is null
Throws:
SQLException - if a database-access error occurs.

getBinaryStream

public InputStream getBinaryStream(String attributeName)
                            throws SQLException
Get the value of a column in the current row as a stream of uninterpreted bytes.

Specified by:
getBinaryStream in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is null
Throws:
SQLException - if a database-access error occurs.

getBoolean

public boolean getBoolean(String attributeName)
                   throws SQLException
Get the value of a column in the current row as a Java boolean.

Specified by:
getBoolean in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is false
Throws:
SQLException - if a database-access error occurs.

getBooleanObject

public Boolean getBooleanObject(String attributeName)
                         throws SQLException
Get the value of a column in the current row as a Java boolean.

Specified by:
getBooleanObject in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is false
Throws:
SQLException - if a database-access error occurs.

getByte

public byte getByte(String attributeName)
             throws SQLException
Get the value of a column in the current row as a Java byte.

Specified by:
getByte in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is 0
Throws:
SQLException - if a database-access error occurs.

getByteObject

public Byte getByteObject(String attributeName)
                   throws SQLException
Get the value of a column in the current row as a Java byte.

Specified by:
getByteObject in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is 0
Throws:
SQLException - if a database-access error occurs.

getBytes

public byte[] getBytes(String attributeName)
                throws SQLException,
                       DatastoreException
Get the value of a column in the current row as a Java byte array.

Specified by:
getBytes in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is null
Throws:
SQLException - if a database-access error occurs.
DatastoreException

getChar

public char getChar(String attributeName)
             throws SQLException
Get the value of a column in the current row as a Java char.

Specified by:
getChar in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is 0
Throws:
SQLException - if a database-access error occurs.

getCharObject

public Character getCharObject(String attributeName)
                        throws SQLException
Get the value of a column in the current row as a Java char.

Specified by:
getCharObject in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is 0
Throws:
SQLException - if a database-access error occurs.

getDate

public Date getDate(String attributeName)
             throws SQLException
Get the value of a column in the current row as a java.sql.Date object.

Specified by:
getDate in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is null
Throws:
SQLException - if a database-access error occurs.

getDouble

public double getDouble(String attributeName)
                 throws SQLException
Get the value of a column in the current row as a Java double.

Specified by:
getDouble in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is 0
Throws:
SQLException - if a database-access error occurs.

getDoubleObject

public Double getDoubleObject(String attributeName)
                       throws SQLException
Get the value of a column in the current row as a Java double.

Specified by:
getDoubleObject in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is 0
Throws:
SQLException - if a database-access error occurs.

getFloat

public float getFloat(String attributeName)
               throws SQLException
Get the value of a column in the current row as a Java float.

Specified by:
getFloat in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is 0
Throws:
SQLException - if a database-access error occurs.

getFloatObject

public Float getFloatObject(String attributeName)
                     throws SQLException
Get the value of a column in the current row as a Java float.

Specified by:
getFloatObject in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is 0
Throws:
SQLException - if a database-access error occurs.

getInlineObject

public Object getInlineObject(String attributeName,
                              String blobAttributeName)
                       throws SQLException,
                              DatastoreException
Description copied from interface: PersistentRetrieveIfc
Get the value of a blob column as a Java Object.

Specified by:
getInlineObject in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
blobAttributeName - a blob attribute name
Throws:
SQLException - if a database-access error occurs.
DatastoreException

getInt

public int getInt(String attributeName)
           throws SQLException
Get the value of a column in the current row as a Java int.

Specified by:
getInt in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is 0
Throws:
SQLException - if a database-access error occurs.

getIntObject

public Integer getIntObject(String attributeName)
                     throws SQLException
Get the value of a column in the current row as a Java int.

Specified by:
getIntObject in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is 0
Throws:
SQLException - if a database-access error occurs.

getLong

public long getLong(String attributeName)
             throws SQLException
Get the value of a column in the current row as a Java long.

Specified by:
getLong in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is 0
Throws:
SQLException - if a database-access error occurs.

getLongObject

public Long getLongObject(String attributeName)
                   throws SQLException
Get the value of a column in the current row as a Java long.

Specified by:
getLongObject in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is 0
Throws:
SQLException - if a database-access error occurs.

getObject

public Object getObject(String attributeName)
                 throws SQLException,
                        DatastoreException
Get the value of a column in the current row as a Java object.

Specified by:
getObject in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is null
Throws:
SQLException - if a database-access error occurs.
DatastoreException

getSmallObject

public Object getSmallObject(String attributeName)
                      throws SQLException,
                             DatastoreException
Get the value of a column in the current row as a Java object.

Specified by:
getSmallObject in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is null
Throws:
SQLException - if a database-access error occurs.
DatastoreException

getShort

public short getShort(String attributeName)
               throws SQLException
Get the value of a column in the current row as a Java short.

Specified by:
getShort in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is 0
Throws:
SQLException - if a database-access error occurs.

getShortObject

public Short getShortObject(String attributeName)
                     throws SQLException
Get the value of a column in the current row as a Java short.

Specified by:
getShortObject in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is 0
Throws:
SQLException - if a database-access error occurs.

getString

public String getString(String attributeName)
                 throws SQLException
Get the value of a column in the current row as a Java String.

Specified by:
getString in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is null
Throws:
SQLException - if a database-access error occurs.

getTime

public Time getTime(String attributeName)
             throws SQLException
Get the value of a column in the current row as a java.sql.Time object.

Specified by:
getTime in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is null
Throws:
SQLException - if a database-access error occurs.

getTimestamp

public Timestamp getTimestamp(String attributeName)
                       throws SQLException
Get the value of a column in the current row as a java.sql.Timestamp object.

Specified by:
getTimestamp in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is null
Throws:
SQLException - if a database-access error occurs.

getUnicodeStream

public InputStream getUnicodeStream(String attributeName)
                             throws SQLException
Get the value of a column in the current row as a stream of Unicode characters and then read in chunks.

Specified by:
getUnicodeStream in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Returns:
the column value; if the value is SQL NULL, the result is null
Throws:
SQLException - if a database-access error occurs.

getLobLocator

public LobLocator getLobLocator(String attributeName)
                         throws SQLException,
                                DatastoreException
Get a LobLocator for the given attribute.

Specified by:
getLobLocator in interface PersistentRetrieveIfc
Parameters:
attributeName - a class attribute name
Throws:
SQLException - if a database-access error occurs.
DatastoreException

readObject

public ObjectMappable readObject(String attribute_name,
                                 ObjectMappable obj,
                                 Class concrete_class,
                                 boolean isRequired)
                          throws SQLException,
                                 DatastoreException
Get the values corresponding to a nested ObjectMappable Object. This results in a call to the nested object's readExternal method.

Specified by:
readObject in interface PersistentRetrieveIfc
Parameters:
attribute_name - a class attribute name
obj - the nested object
concrete_class - the class to instantiate if needed
Throws:
SQLException - if a database-access error occurs.
DatastoreException - if any other internal error occurs.

getContainer

public String getContainer()
Get the current container name. The container name is set by calls to readObject.

Specified by:
getContainer in interface PersistentRetrieveIfc
Returns:
the current container name

next

public boolean next()
             throws SQLException
Satisfies the PersistentRetrieveIfc requirement for a method by this name. Always returns true.

Specified by:
next in interface PersistentRetrieveIfc
Returns:
true if new row is valid, false if there are no more rows
Throws:
SQLException - if a database-access error occurs.

wasNull

public boolean wasNull()
                throws SQLException
A column may have the value of SQL NULL; wasNull reports whether the last column read had this special value. Note that you must first call getXXX on a column to try to read its value and then call wasNull() to find if the value was the SQL NULL.

Specified by:
wasNull in interface PersistentRetrieveIfc
Returns:
true if last column was a null value
Throws:
SQLException - if a database-access error occurs.