- All Known Implementing Classes:
AbstractFigureFactory,DefaultFigureFactory
- Author:
- Werner Randelshofer
-
Method Summary
Modifier and TypeMethodDescriptioncreateFigureByElementName(String elementName) Creates a new figure given the name of an XML element.Set<MapAccessor<?>> Returns all keys for the specified figure which should be converted into element attributes.Set<MapAccessor<?>> Returns all keys for the specified figure which should be converted into a node list.default DrawingfromExternalDrawing(Drawing external) Creates an internal representation of the drawing.getAttributeNameByKey(Figure f, MapAccessor<?> key) Maps a key to a XML attribute name.<T> @Nullable TgetDefaultValue(Figure f, MapAccessor<T> key) Returns the default for the key.@Nullable StringMaps a figure to an XML element name.getElementNameByKey(Figure f, MapAccessor<?> key) Maps a key to a XML element name.@Nullable MapAccessor<?> getKeyByAttributeName(Figure f, String name) Maps an XML attribute name to a key.MapAccessor<?> getKeyByElementName(Figure f, String name) Maps an XML element name to a key.Returns the name of the object id attribute.default MapAccessor<ImmutableList<URI>> Returns the stylesheets keys.default <T> booleanisDefaultValue(Figure f, MapAccessor<T> key, @Nullable T value) Returns true if the specified value is the default for the given key.<T> booleanneedsIdResolver(MapAccessor<T> key) <T> @Nullable TnodeListToValue(MapAccessor<T> key, List<Node> nodeList) Maps a XML node list to a value.<T> @Nullable TstringToValue(MapAccessor<T> key, String cdata) Maps an XML attribute value to a value.default DrawingtoExternalDrawing(Drawing internal) Creates an external representation of the drawing.voidvalueToNodeList(MapAccessor<?> key, Object value, XMLStreamWriter w) Maps a value to a XML node list.<T> StringvalueToString(MapAccessor<T> key, T value) Maps a value to an XML attribute value.
-
Method Details
-
getElementNameByFigure
Maps a figure to an XML element name.- Parameters:
f- the figure- Returns:
- the name
- Throws:
IOException- if the factory does not support this figure
-
createFigureByElementName
Creates a new figure given the name of an XML element.- Parameters:
elementName- the name- Returns:
- the figure
- Throws:
IOException- if the factory does not support this name
-
getAttributeNameByKey
Maps a key to a XML attribute name. The name used for persistent storage may be different from the name defined in the key.- Parameters:
f- the figurekey- the key- Returns:
- The name.
- Throws:
IOException- if the factory does not support the key for the specified figure
-
getKeyByAttributeName
Maps an XML attribute name to a key.- Parameters:
f- the figurename- the name- Returns:
- the key
-
getElementNameByKey
Maps a key to a XML element name. The name used for persistent storage may be different from the name defined in the key.The name can be an empty String
""for the key returned byfigureNodeListKeys(org.jhotdraw8.draw.figure.Figure)if the figure has exactly one node list key. In this case, the node list will be added directly as children to the figure. The name of a node list key must not be equal to the name of a figure, because child figure elements are also added as child elements.- Parameters:
f- the figurekey- the key- Returns:
- The name.
- Throws:
IOException- if the factory does not support the key for the specified figure
-
getKeyByElementName
Maps an XML element name to a key.- Parameters:
f- the figurename- the name- Returns:
- the key
- Throws:
IOException- if the factory does not support the name for the specified figure
-
valueToString
Maps a value to an XML attribute value.- Type Parameters:
T- the type of the value- Parameters:
key- the keyvalue- the value- Returns:
- the mapped attribute value
- Throws:
IOException- if the factory does not support a mapping for the specified key
-
valueToNodeList
Maps a value to a XML node list.The node list may not contain elements with a name that conflicts with the names returned by
getElementNameByFigure(org.jhotdraw8.draw.figure.Figure).- Parameters:
key- the keyvalue- the valuew- the writer for creating the node list.- Throws:
XMLStreamException
-
nodeListToValue
Maps a XML node list to a value.The node list does not contain elements with a name that conflicts with the names returned by
getElementNameByFigure(org.jhotdraw8.draw.figure.Figure).- Type Parameters:
T- the type of the value- Parameters:
key- the keynodeList- the nodeList- Returns:
- the mapped attribute value.
-
stringToValue
Maps an XML attribute value to a value.- Type Parameters:
T- the type of the value- Parameters:
key- the keycdata- the XML attribute value- Returns:
- the mapped value
- Throws:
IOException- if the factory does not support a mapping for the specified key
-
needsIdResolver
- Throws:
IOException
-
getDefaultValue
Returns the default for the key. The default value used for persistent storage may be different from the default value defined in the key.- Type Parameters:
T- The type of the value- Parameters:
f- The figurekey- The key- Returns:
- the default value
-
isDefaultValue
Returns true if the specified value is the default for the given key.- Type Parameters:
T- The type of the value- Parameters:
f- The figurekey- The keyvalue- the value- Returns:
- true if the value is the default value
-
figureAttributeKeys
Returns all keys for the specified figure which should be converted into element attributes.- Parameters:
f- The figure- Returns:
- an immutable set
-
figureNodeListKeys
Returns all keys for the specified figure which should be converted into a node list.- Parameters:
f- The figure- Returns:
- an immutable set
-
toExternalDrawing
Creates an external representation of the drawing.Note: this method must not change the provided internal drawing.
The default implementation returns the same drawing.
- Parameters:
internal- an internal representation of the drawing- Returns:
- An external representation of the drawing.
-
fromExternalDrawing
Creates an internal representation of the drawing.Note: this method may change the provided external drawing.
The default implementation returns the same drawing.
- Parameters:
external- an external representation of the drawing- Returns:
- An internal representation of the drawing.
-
getStylesheetsKey
Returns the stylesheets keys.- Returns:
- The stylesheets key of the Drawing object. Return null if
stylesheets shall not be supported. The default implementation returns
Drawing.AUTHOR_STYLESHEETS.
-
getObjectIdAttribute
String getObjectIdAttribute()Returns the name of the object id attribute. The object id attribute is used for referencing other objects in the XML file.- Returns:
- name of the object id attribute
-