cz.cuni.amis.pogamut.unreal.t3dgenerator
Class DefaultT3dGenerator

Package class diagram package DefaultT3dGenerator
java.lang.Object
  extended by cz.cuni.amis.pogamut.unreal.t3dgenerator.AbstractT3dGenerator
      extended by cz.cuni.amis.pogamut.unreal.t3dgenerator.DefaultT3dGenerator
All Implemented Interfaces:
IT3dGenerator

public class DefaultT3dGenerator
extends AbstractT3dGenerator

Default implementation of IT3dGenerator. Reads annotations from package cz.cuni.amis.pogamut.unreal.t3dgenerator.annotations present on classes that are to be serialized. Every unannotated, non-static, non-transient member of a serialized object is treated as a property of this object. Objects that are descendants of IUnrealReferencableByName and have no name specified get their names autogenerated. Properties and child objects with null values are not exported (so that defaults from archetype are applied in editor).

Author:
Martin Cerny

Constructor Summary
DefaultT3dGenerator()
           
 
Method Summary
protected  void generateHeaderProperties(Object object, OutputStreamWriter out)
          Generates a single line string of header properties of an object to an OutputStreamWriter.
protected  void generateProperties(Object object, OutputStreamWriter out, int indent)
          Generates properties of an object to an OutputStreamWriter.
protected  void generateProperty(OutputStreamWriter out, String indentString, String propertyName, Object propertyValue)
          Generates a text for specified property to an OutputStreamWriter.
protected  void generateStaticText(Object object, OutputStreamWriter out, int indent)
          Gathers all static text properties of an object and outputs them to a specified OutputStreamWriter
 void generateT3d(List elements, OutputStreamWriter out)
          Creates T3D for all specified objects.
protected  void generateT3dFromDynamicObject(DynamicT3DObject object, OutputStreamWriter out, int indent)
           
protected  void generateT3dInternal(Object object, OutputStreamWriter out, int indent)
          Generates T3D for an object and all it's child objects.
protected  List<Object> getChildren(Object unrealObject)
          Gets a list of all child objects of a specified object.
protected  String getElementType(Object unrealObject)
          Gets an element type (e.g.
protected  Map<String,Object> getProperties(Object object)
          Gets a map of properties of an object.
protected  String getPropertyNameForField(Field f, String annotationValue)
          Returns a name for property in a field.
protected  String getPropertyString(String key, Object value)
          Returns a string for property with name Unreal name key and specified value.
protected  String getPropertyString(String key, Object value, boolean escapeStrings)
          Returns a string for property with name Unreal name key and specified value.
protected  String getPropertyValueString(Object value)
          Transforms a value of a property into it's string representation, strings are escaped with single quote.
protected  String getPropertyValueString(Object value, boolean escapeStrings)
          Transforms a value of a property into it's string representation.
 String getTranslatedName(Field f)
          Translates a name of a field from Java naming convention to UDK naming convention.
protected static String indentString(int indent)
          Create a string of tabs...
protected  void preProcess(Object unrealObject, IT3dGeneratorContext context)
          Preprocesses an object before serializing it.
 
Methods inherited from class cz.cuni.amis.pogamut.unreal.t3dgenerator.AbstractT3dGenerator
generateT3d
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultT3dGenerator

public DefaultT3dGenerator()
Method Detail

indentString

protected static String indentString(int indent)
Create a string of tabs...

Parameters:
indent -
Returns:

getPropertyNameForField

protected String getPropertyNameForField(Field f,
                                         String annotationValue)
Returns a name for property in a field.

Parameters:
f -
annotationValue - the name specified in annotation or null/empty string if there is not any
Returns:

getTranslatedName

public String getTranslatedName(Field f)
Translates a name of a field from Java naming convention to UDK naming convention.

Parameters:
f -
Returns:

preProcess

protected void preProcess(Object unrealObject,
                          IT3dGeneratorContext context)
Preprocesses an object before serializing it. This implementation only assigns a generated name of form "ClasName_XX" to every object that is IUnrealReferencableByName and does not have a name.

Parameters:
unrealObject -
context -

getPropertyValueString

protected String getPropertyValueString(Object value,
                                        boolean escapeStrings)
Transforms a value of a property into it's string representation.

Parameters:
value -
escapeStrings - true, if strings should be escaped with single quote. Should be false for header fields.
Returns:

getPropertyValueString

protected String getPropertyValueString(Object value)
Transforms a value of a property into it's string representation, strings are escaped with single quote.

Parameters:
value -
Returns:

getPropertyString

protected String getPropertyString(String key,
                                   Object value,
                                   boolean escapeStrings)
Returns a string for property with name Unreal name key and specified value.

Parameters:
key -
value -
escapeStrings - true, if strings should be escaped with single quote. Should be false for header fields.
Returns:

getPropertyString

protected String getPropertyString(String key,
                                   Object value)
Returns a string for property with name Unreal name key and specified value. Strings are escaped with single quote.

Parameters:
key -
value -
Returns:

generateProperty

protected void generateProperty(OutputStreamWriter out,
                                String indentString,
                                String propertyName,
                                Object propertyValue)
                         throws IOException
Generates a text for specified property to an OutputStreamWriter.

Parameters:
out -
indentString - String of tabs that should be prepended to the property string.
propertyName -
propertyValue -
Throws:
IOException

getProperties

protected Map<String,Object> getProperties(Object object)
Gets a map of properties of an object. The keys of object are translated (Unreal) names of properties, values are not yet translated - they are still regular java objects.

Parameters:
object -
Returns:
See Also:
UnrealProperty

generateProperties

protected void generateProperties(Object object,
                                  OutputStreamWriter out,
                                  int indent)
                           throws IOException
Generates properties of an object to an OutputStreamWriter.

Parameters:
object -
out -
indent -
Throws:
IOException

generateHeaderProperties

protected void generateHeaderProperties(Object object,
                                        OutputStreamWriter out)
                                 throws IOException
Generates a single line string of header properties of an object to an OutputStreamWriter.

Throws:
IOException
See Also:
UnrealHeaderField

getChildren

protected List<Object> getChildren(Object unrealObject)
Gets a list of all child objects of a specified object.

Parameters:
unrealObject -
Returns:
See Also:
UnrealChild, UnrealChildCollection

generateStaticText

protected void generateStaticText(Object object,
                                  OutputStreamWriter out,
                                  int indent)
                           throws IOException
Gathers all static text properties of an object and outputs them to a specified OutputStreamWriter

Parameters:
object -
out -
indent -
Throws:
IOException
See Also:
StaticText

getElementType

protected String getElementType(Object unrealObject)
Gets an element type (e.g. Actor, Object, Map,...) of an object. Type is read from annotations.

Parameters:
unrealObject -
Returns:
See Also:
UnrealBean

generateT3dFromDynamicObject

protected void generateT3dFromDynamicObject(DynamicT3DObject object,
                                            OutputStreamWriter out,
                                            int indent)
                                     throws IOException
Throws:
IOException

generateT3dInternal

protected void generateT3dInternal(Object object,
                                   OutputStreamWriter out,
                                   int indent)
                            throws IOException
Generates T3D for an object and all it's child objects.

Parameters:
object -
out -
indent -
Throws:
IOException

generateT3d

public void generateT3d(List elements,
                        OutputStreamWriter out)
                 throws IOException
Creates T3D for all specified objects.

Parameters:
elements -
out -
Throws:
IOException


Copyright © 2014 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.