org.openptk.structure
Class Converter

java.lang.Object
  extended by org.openptk.structure.Converter
All Implemented Interfaces:
ConverterIF
Direct Known Subclasses:
HtmlConverter, JsonConverter, PlainConverter, XmlConverter

public abstract class Converter
extends java.lang.Object
implements ConverterIF

The abstract base class for a Converter. Provides core method implementations.

Author:
Scott Fehrman, Sun Microsystems, Inc.

Field Summary
protected static java.lang.String GT
           
protected static java.lang.String GTE
           
protected static java.lang.String KEYVALUE
           
protected static java.lang.String LT
           
protected static java.lang.String LTE
           
protected static java.lang.String NEWLINE
           
protected static java.lang.String PAD
           
protected static java.lang.String QUOTE
           
protected static java.lang.String SEPARATOR
           
 
Fields inherited from interface org.openptk.structure.ConverterIF
PROP_CHILDREN, PROP_NAMEVALUE, PROP_VALUE, VALUE_CHILDREN_DISCRETE, VALUE_CHILDREN_LIST, VALUE_NAMEVALUE_COLLAPSED, VALUE_NAMEVALUE_EXPANDED, VALUE_VALUE_MULTI, VALUE_VALUE_SINGLE
 
Constructor Summary
Converter(ConverterType type)
          Create a new Converter, set specified Type.
 
Method Summary
 StructureIF decode(java.lang.String string)
          Convert the String of encoded data into a StructureIF object.
 java.lang.String encode(StructureIF struct)
          Convert the Structure into a formated String.
 ElementIF getStructInfo(java.lang.String structId)
          Get Structure Information using provided Id.
 java.lang.String[] getStructInfoIds()
          Return Array of Structure Information Ids.
protected  java.lang.String getStructProperty(java.lang.String structName, java.lang.String propName)
          Get a property value from Structure Information.
 ConverterType getType()
          Return the Converter's Type.
protected  void handleError(java.lang.String msg)
          Standard error handling method.
protected  java.lang.String pad(int qty, java.lang.String chars)
          Returns a String built by repeating the String.
 void setStructInfo(java.lang.String structId, ElementIF element)
          Set Structure Information using the provided Id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GT

protected static java.lang.String GT

GTE

protected static java.lang.String GTE

KEYVALUE

protected static java.lang.String KEYVALUE

LT

protected static java.lang.String LT

LTE

protected static java.lang.String LTE

NEWLINE

protected static java.lang.String NEWLINE

PAD

protected static java.lang.String PAD

QUOTE

protected static java.lang.String QUOTE

SEPARATOR

protected static java.lang.String SEPARATOR
Constructor Detail

Converter

public Converter(ConverterType type)
Create a new Converter, set specified Type.

Parameters:
type - ConverterType
Method Detail

decode

public StructureIF decode(java.lang.String string)
                   throws ConverterException
Convert the String of encoded data into a StructureIF object.

Specified by:
decode in interface ConverterIF
Parameters:
string - Encoded representation of the data
Returns:
StructureIF Structure of the data
Throws:
ConverterException

encode

public java.lang.String encode(StructureIF struct)
                        throws ConverterException
Convert the Structure into a formated String.

Specified by:
encode in interface ConverterIF
Parameters:
struct - StructureIF of data
Returns:
String encoded representation of the data
Throws:
ConverterException

getStructInfo

public final ElementIF getStructInfo(java.lang.String structId)
Get Structure Information using provided Id.

Specified by:
getStructInfo in interface ConverterIF
Parameters:
structId - Structure Information Id
Returns:
ElementIF Information about the Structure

getStructInfoIds

public final java.lang.String[] getStructInfoIds()
Return Array of Structure Information Ids.

Specified by:
getStructInfoIds in interface ConverterIF
Returns:
String Array of Ids

getStructProperty

protected final java.lang.String getStructProperty(java.lang.String structName,
                                                   java.lang.String propName)
Get a property value from Structure Information.

Parameters:
structName - Structure name
propName - Property name
Returns:
String Structure / Property value

getType

public final ConverterType getType()
Return the Converter's Type.

Specified by:
getType in interface ConverterIF
Returns:
ConverterType

handleError

protected final void handleError(java.lang.String msg)
                          throws ConverterException
Standard error handling method.

Parameters:
msg - String message containing what happened.
Throws:
ConverterException

pad

protected final java.lang.String pad(int qty,
                                     java.lang.String chars)
Returns a String built by repeating the String.

Parameters:
qty - number of times to repeat the String
chars - String to repeat
Returns:
String the new concatinated value

setStructInfo

public final void setStructInfo(java.lang.String structId,
                                ElementIF element)
Set Structure Information using the provided Id.

Specified by:
setStructInfo in interface ConverterIF
Parameters:
structId - Structure Information Id
element - Structure Information


View/submit a bug or feature

For further API reference and developer documentation, see www.openptk.org. That documentation contains more detailed, developer-targeted descriptions, definitions of terms, workarounds, and working code examples.

Copyright (C) 2008-2012, Project OpenPTK. All Rights Reserved