net.dpml.lang
Class Part

java.lang.Object
  extended bynet.dpml.lang.Part
Direct Known Subclasses:
Composition, Plugin, Resource

public abstract class Part
extends Object

Part datastructure.

Version:
1.0.1
Author:
Digital Product Meta Library

Field Summary
protected static String PART_FOOTER
          Part footer.
protected static String PART_HEADER
          Part header.
protected static String PART_SCHEMA_URN
          Part schema URN.
protected static ValueEncoder VALUE_ENCODER
          A value encoder.
protected static String XML_HEADER
          Default XML header.
 
Constructor Summary
Part(Logger logger, Info info, Classpath classpath)
          Creation of a new part datastructure.
Part(Logger logger, Info info, Classpath classpath, String label)
          Creation of a new part datastructure.
 
Method Summary
 void encode(OutputStream output)
          Externalize the part to XML.
protected abstract  void encodeStrategy(Writer writer, String pad)
          Encode this part strategy to XML.
 boolean equals(Object other)
          Test is this part is equiovalent to the supplied part.
 ClassLoader getClassLoader()
          Get the implementation classloader.
 Classpath getClasspath()
          Get the part classpath definition.
 Object getContent()
          Return the default part content.
protected  Object getContent(Class c)
          Return the part content or null if the result type is unresolvable relative to the supplied classes argument.
 Object getContent(Class[] classes)
          Return the part content or null if the result type is unresolvable relative to the supplied classes argument.
 Info getInfo()
          Get the part info descriptor.
protected  Logger getLogger()
          Get the assigned logging channel.
 int hashCode()
          Get the part hashcode.
abstract  Object instantiate(Object[] args)
          Instantiate a value.
static Part load(URI uri)
          Load a part from an external XML source with part caching.
static Part load(URI uri, boolean cache)
          Load a part from an external XML source.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALUE_ENCODER

protected static final ValueEncoder VALUE_ENCODER
A value encoder.


XML_HEADER

protected static final String XML_HEADER
Default XML header.

See Also:
Constant Field Values

PART_SCHEMA_URN

protected static final String PART_SCHEMA_URN
Part schema URN.

See Also:
Constant Field Values

PART_HEADER

protected static final String PART_HEADER
Part header.

See Also:
Constant Field Values

PART_FOOTER

protected static final String PART_FOOTER
Part footer.

See Also:
Constant Field Values
Constructor Detail

Part

public Part(Logger logger,
            Info info,
            Classpath classpath)
     throws IOException
Creation of a new part datastructure.

Parameters:
logger - the logging channel
info - the info descriptor
classpath - the part classpath definition
Throws:
IOException - if an I/O error occurs

Part

public Part(Logger logger,
            Info info,
            Classpath classpath,
            String label)
     throws IOException
Creation of a new part datastructure.

Parameters:
logger - the logging channel
info - the info descriptor
classpath - the part classpath definition
label - debug label
Throws:
IOException - if an I/O error occurs
Method Detail

load

public static Part load(URI uri)
                 throws IOException
Load a part from an external XML source with part caching.

Parameters:
uri - the external part source
Returns:
the resolved part
Throws:
IOException - of an I/O error occurs

load

public static Part load(URI uri,
                        boolean cache)
                 throws IOException
Load a part from an external XML source.

Parameters:
uri - the external part source
cache - the cache policy
Returns:
the resolved part
Throws:
IOException - of an I/O error occurs

getContent

public Object getContent()
                  throws IOException
Return the default part content.

Returns:
the result of part instantiation
Throws:
IOException - if an IO error occurs

getContent

public Object getContent(Class[] classes)
                  throws IOException
Return the part content or null if the result type is unresolvable relative to the supplied classes argument.

Parameters:
classes - the content type selection classes
Returns:
the content
Throws:
IOException - if an IO error occurs

getContent

protected Object getContent(Class c)
                     throws IOException
Return the part content or null if the result type is unresolvable relative to the supplied classes argument. Recognized class arguments include Info, Classpath, Part, ClassLoader, and Object.

Parameters:
c - the content type class
Returns:
the content
Throws:
IOException - if an IO error occurs

getInfo

public Info getInfo()
Get the part info descriptor.

Returns:
the part info datastructure

getClasspath

public Classpath getClasspath()
Get the part classpath definition.

Returns:
the classpath definition

instantiate

public abstract Object instantiate(Object[] args)
                            throws Exception
Instantiate a value.

Parameters:
args - supplimentary arguments
Returns:
the resolved instance
Throws:
Exception - if a deployment error occurs

encode

public void encode(OutputStream output)
            throws IOException
Externalize the part to XML.

Parameters:
output - the output stream
Throws:
IOException - if an I/O error occurs

equals

public boolean equals(Object other)
Test is this part is equiovalent to the supplied part.

Parameters:
other - the other object
Returns:
true if the parts are equivalent

hashCode

public int hashCode()
Get the part hashcode.

Returns:
the hash value

encodeStrategy

protected abstract void encodeStrategy(Writer writer,
                                       String pad)
                                throws IOException
Encode this part strategy to XML.

Parameters:
writer - the output stream writer
pad - the character offset
Throws:
IOException - if an I/O error occurs during part externalization

getClassLoader

public ClassLoader getClassLoader()
Get the implementation classloader.

Returns:
the resolved classloader

getLogger

protected Logger getLogger()
Get the assigned logging channel.

Returns:
the logging channel