Humboldt Alignment Editor 2.5.0

eu.esdihumboldt.hale.io.gml.writer.internal
Class GmlWriterUtil

java.lang.Object
  extended by eu.esdihumboldt.hale.io.gml.writer.internal.GmlWriterUtil

public abstract class GmlWriterUtil
extends Object

Utility methods used for the GML writer

Author:
Simon Templer
Partner:
01 / Fraunhofer Institute for Computer Graphics Research

Constructor Summary
GmlWriterUtil()
           
 
Method Summary
static void addNamespace(XMLStreamWriter writer, String namespace, String preferredPrefix)
          Add a namespace to the given XML stream writer
static Collection<DefinitionPath> collectPropertyPaths(Iterable<? extends ChildDefinition<?>> children, DefinitionPath basePath, boolean elementsOnly)
          Collect all the paths to all child properties, even those contained in groups.
static QName getElementName(TypeDefinition type)
          Get the element name from a type definition
static boolean isID(TypeDefinition type)
          Determines if the given type represents a XML ID
static void writeAttribute(XMLStreamWriter writer, Object value, PropertyDefinition propDef)
          Write a property attribute
static void writeEmptyElement(XMLStreamWriter writer, QName name)
          Write an empty element.
static void writeRequiredID(XMLStreamWriter writer, DefinitionGroup type, Group parent, boolean onlyIfNotSet)
          Write any required ID attribute, generating a random ID if needed
static void writeStartElement(XMLStreamWriter writer, QName name)
          Write a start element.
static void writeStartPathElement(XMLStreamWriter writer, PathElement step, boolean generateRequiredID)
          Write the opening element of a PathElement to the given stream writer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GmlWriterUtil

public GmlWriterUtil()
Method Detail

getElementName

public static QName getElementName(TypeDefinition type)
Get the element name from a type definition

Parameters:
type - the type definition
Returns:
the element name

addNamespace

public static void addNamespace(XMLStreamWriter writer,
                                String namespace,
                                String preferredPrefix)
                         throws XMLStreamException
Add a namespace to the given XML stream writer

Parameters:
writer - the XML stream writer
namespace - the namespace to add
preferredPrefix - the preferred prefix
Throws:
XMLStreamException - if setting a prefix for the namespace fails

isID

public static boolean isID(TypeDefinition type)
Determines if the given type represents a XML ID

Parameters:
type - the type definition
Returns:
if the type represents an ID

writeAttribute

public static void writeAttribute(XMLStreamWriter writer,
                                  Object value,
                                  PropertyDefinition propDef)
                           throws XMLStreamException
Write a property attribute

Parameters:
writer - the XML stream writer
value - the attribute value, may be null
propDef - the attribute definition
Throws:
XMLStreamException - if writing the attribute fails

writeRequiredID

public static void writeRequiredID(XMLStreamWriter writer,
                                   DefinitionGroup type,
                                   Group parent,
                                   boolean onlyIfNotSet)
                            throws XMLStreamException
Write any required ID attribute, generating a random ID if needed

Parameters:
writer - the XML stream writer
type - the type definition
parent - the parent object, may be null. If it is set the value for the ID will be tried to be retrieved from the parent object, otherwise a random ID will be generated
onlyIfNotSet - if the ID shall only be written if no value is set in the parent object
Throws:
XMLStreamException - if an error occurs writing the ID

writeStartPathElement

public static void writeStartPathElement(XMLStreamWriter writer,
                                         PathElement step,
                                         boolean generateRequiredID)
                                  throws XMLStreamException
Write the opening element of a PathElement to the given stream writer

Parameters:
writer - the stream writer
step - the path element
generateRequiredID - if required IDs shall be generated for the path element
Throws:
XMLStreamException - if writing to the stream writer fails

collectPropertyPaths

public static Collection<DefinitionPath> collectPropertyPaths(Iterable<? extends ChildDefinition<?>> children,
                                                              DefinitionPath basePath,
                                                              boolean elementsOnly)
Collect all the paths to all child properties, even those contained in groups.

Parameters:
children - the children
basePath - the base path
elementsOnly - if only properties representing an XML element should be considered
Returns:
the child paths, each ending with a property element

writeStartElement

public static void writeStartElement(XMLStreamWriter writer,
                                     QName name)
                              throws XMLStreamException
Write a start element.

Parameters:
writer - the writer
name - the element name
Throws:
XMLStreamException - if an error occurs writing the start element

writeEmptyElement

public static void writeEmptyElement(XMLStreamWriter writer,
                                     QName name)
                              throws XMLStreamException
Write an empty element.

Parameters:
writer - the writer
name - the element name
Throws:
XMLStreamException - if an error occurs writing the empty element

Humboldt Alignment Editor 2.5.0

Build 2012-12-03_12-30-59
Revision 9d2dd4b0318cda9f1393b1ddd390f7f792d70a2d