Class sunsoft.jws.visual.rt.type.Converter
All Packages Class Hierarchy This Package Previous Next Index
Class sunsoft.jws.visual.rt.type.Converter
java.lang.Object
|
+----sunsoft.jws.visual.rt.type.Converter
- public class Converter
- extends Object
Base class for all converters. Converts a type of object to a string
and back again.
-
converterType
- The name of the type being edited.
-
Converter()
-
-
addConverter(String, String)
- Adds a new type converter to the global table of converters.
-
addTypeEditor(String, String)
- Registers a type editor for a type.
-
convertFromString(String)
- Returns a new instance of the type this converter converts, as
specified by the string given.
-
convertToCode(Object)
- Converts an instance of the type converted into a line of code.
-
convertToCodeBlock(String, Attribute, int, StringBuffer)
- Converts an instance of the type into a block of code.
-
convertToString(Object)
- Returns the string representation for an instance of the type this
converter converts.
-
convertToString(Object, StringBuffer)
- Places a string representation of an instance of the type this
converter converts into a string buffer.
-
decrIndent()
- Decrements the indent level.
-
displayString(Object)
- Returns the string that should be displayed in the attribute
editor.
-
editableAsString()
- Returns true if this type is simple enough to be edited as a string
in an editor.
-
getConverter(String)
- Returns an existing converter for the given type.
-
getConverterType()
- Returns the type of object converted by this converter.
-
hasConverter(String)
- Returns true if there is a converter for the given type.
-
hasTypeEditor()
- Returns whether a converter instance has an associated type editor.
-
hasTypeEditor(String)
- Returns true if there is an editor for the given type.
-
incrIndent()
- Increments the indent level.
-
indent(StringBuffer)
- Appends spaces to "buf" based on the current indent level.
-
indent(StringBuffer, int)
- Appends spaces to "buf" based on the given indent level.
-
indentLevel()
- Returns the current indent level.
-
newline()
- Returns a string that can be used as a newline.
-
newline(StringBuffer)
- Appends a newline to buf.
-
newTypeEditor()
- Returns a new instance of the type editor associated with this
converter.
-
newTypeEditor(String)
- Returns a new instance of a type editor.
-
setConverterType(String)
- An interface that can be overridden in sub-classes to whom the type
converted is important.
-
shortClassName(String)
- Returns the last token in a class name.
-
viewableAsString()
- Returns true if this type should be displayed in an editor.
converterType
protected String converterType
- The name of the type being edited.
Converter
public Converter()
addConverter
public static void addConverter(String typeName,
String converterClassName)
- Adds a new type converter to the global table of converters. A
converter must be listed for this table in order for the search
for a converter for that particular type to be successful.
- Parameters:
- typeName - the name of the type (what is returned by a call to getClass().getType() for an instance of that type)
- converterClassName - the full name of the converter class
getConverter
public static Converter getConverter(String typeName)
- Returns an existing converter for the given type. Creates a new
converter only if necessary (typically the first time one is asked for.)
hasConverter
public static boolean hasConverter(String typeName)
- Returns true if there is a converter for the given type.
addTypeEditor
public static void addTypeEditor(String typeName,
String editorClassName)
- Registers a type editor for a type. At run-time (in generated
applications) there will typically be no editors, but they are
needed for the attribute editor in the designer. The designer
will set up all the standard ones.
- See Also:
- TypeEditor
hasTypeEditor
public static boolean hasTypeEditor(String typeName)
- Returns true if there is an editor for the given type.
- See Also:
- TypeEditor
newTypeEditor
public static TypeEditor newTypeEditor(String typeName)
- Returns a new instance of a type editor. The caller (typically the
Designer) gets a new one of these every time, one for each
attribute being edited, even if they are the same type. Caching
instances of these type editors is up to the caller.
hasTypeEditor
public boolean hasTypeEditor()
- Returns whether a converter instance has an associated type editor.
- See Also:
- TypeEditor
newTypeEditor
public TypeEditor newTypeEditor()
- Returns a new instance of the type editor associated with this
converter.
setConverterType
protected void setConverterType(String type)
- An interface that can be overridden in sub-classes to whom the type
converted is important.
- See Also:
- BaseEnumConverter
getConverterType
public String getConverterType()
- Returns the type of object converted by this converter.
convertToString
public String convertToString(Object obj)
- Returns the string representation for an instance of the type this
converter converts. Must be declared in subclasses to convert an
object of the type specific to that subclass of Converter.
One of the two "convertToString" methods must be overridden in
the converter sub-class. The overridden "convertToString" method
should NOT call "super.convertToString". It is preferrable to
override the StringBuffer version (the other one) because this
will result in better performance.
convertToString
public void convertToString(Object obj,
StringBuffer buf)
- Places a string representation of an instance of the type this
converter converts into a string buffer.
convertFromString
public abstract Object convertFromString(String s)
- Returns a new instance of the type this converter converts, as
specified by the string given. Must be declared in subclasses of
Converter to convert a string representation into an object of
the type converted by the subclass.
convertToCodeBlock
public void convertToCodeBlock(String amName,
Attribute a,
int indent,
StringBuffer buf)
- Converts an instance of the type into a block of code.
convertToCode
public String convertToCode(Object obj)
- Converts an instance of the type converted into a line of code.
This method provides a default way for any type to get a
convertToCode method into it. It generates code that will feed
the string representation of the object into the appropriate type
converter. The performance isn't as good as customized
convertToCode functions in subclasses since more classes have to
be loaded at runtime.
displayString
public String displayString(Object obj)
- Returns the string that should be displayed in the attribute
editor. Subclassers that want something displayed other than
what is returned from convertToString should override this
method to return that.
viewableAsString
public boolean viewableAsString()
- Returns true if this type should be displayed in an editor.
For the attribute editor, a return value of false means that the
the textfield will be hidden.
- Returns:
- true
editableAsString
public boolean editableAsString()
- Returns true if this type is simple enough to be edited as a string
in an editor.
Sub-classers that represent type too complex for this should override
this function to return false. For the attribute editor, this means
that the textfield will be read-only.
- Returns:
- same as viewableAsString
- See Also:
- viewableAsString
newline
public static String newline()
- Returns a string that can be used as a newline. This string includes
a carriage return if we are running on Windows.
newline
public static void newline(StringBuffer buf)
- Appends a newline to buf. This also appends a carriage return
if we are running on Windows.
indent
protected static void indent(StringBuffer buf)
- Appends spaces to "buf" based on the current indent level.
indent
protected static void indent(StringBuffer buf,
int indentLevel)
- Appends spaces to "buf" based on the given indent level.
incrIndent
protected static void incrIndent()
- Increments the indent level.
decrIndent
protected static void decrIndent()
- Decrements the indent level.
indentLevel
protected static int indentLevel()
- Returns the current indent level.
shortClassName
public static String shortClassName(String className)
- Returns the last token in a class name. i.e. the name that you
can use for a class when you've imported the class already.
All Packages Class Hierarchy This Package Previous Next Index