|
Search this API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecty.io.graphml.output.AbstractOutputHandler
public abstract class AbstractOutputHandler
Convenience abstract base implementation of the OutputHandler interface.
Since this class also implements the OutputHandlerProvider interface, it can be registered directly with
GraphMLHandler.addOutputHandlerProvider(y.io.graphml.output.OutputHandlerProvider)
![]() |
![]() |
![]() |
![]() |
| Constructor Summary | |
|---|---|
protected |
AbstractOutputHandler()
Initializes a new instance of the AbstractOutputHandler class. |
protected |
AbstractOutputHandler(java.lang.String name,
KeyScope scope,
KeyType type)
Initializes a new instance of the AbstractOutputHandler class |
| Method Summary | |
|---|---|
void |
addNameToKeyDefinition(java.lang.String name)
Adds the name to the key definition. |
void |
addScopeToKeyDefinition(KeyScope scope)
Adds the scope to the key definition. |
void |
addTypeToKeyDefinition(KeyType type)
Adds the key type to the key definition. |
void |
addUriToKeyDefinition(java.lang.String uri)
Adds an optional uri to the key definition. |
java.util.Collection |
getDataTagAttributes()
Returns XML all attributes of the data element. |
java.lang.Object |
getDefaultValue()
Gets the default value. |
java.util.Collection |
getKeyDefinitionAttributes()
Returns all XML attributes of the key element. |
WritePrecedence |
getPrecedence()
Gets the write precedence for the handler. |
KeyScope |
getScope()
Gets the KeyScope where this handler should register itself. |
java.util.Set |
getValidScopes()
Allows to restrict the scopes where the handler is used, if the handler is registered to KeyScope.ALL. |
protected abstract java.lang.Object |
getValue(GraphMLWriteContext context,
java.lang.Object key)
Callback method that obtains the data for the given key. |
boolean |
hasDefaultValueAssigned()
Gets a value indicating whether a default value has been assigned. |
boolean |
isDefaultValue(GraphMLWriteContext ctx)
Determines whether in the current context, the value is the default value and therefore no data element needs to be written. |
protected boolean |
isValidScope(GraphMLWriteContext ctx)
Checks whether the current handler is called in a scope that is valid. wrt getValidScopes() |
boolean |
isWriteKeyDefault()
Gets a value indicating whether to write the key default. |
void |
onQueryOutputHandler(QueryOutputHandlersEvent event)
Allows this instance to register itself as an OutputHandler. |
void |
setDefaultValue(java.lang.Object value)
Sets the default value. |
protected void |
setDefaultValueAssigned(boolean value)
Sets a value indicating whether a default value has been assigned. |
void |
setPrecedence(WritePrecedence value)
Sets the write precedence for the handler. |
void |
setScope(KeyScope scope)
Sets the KeyScope where this handler should register itself. |
void |
setValidScopes(java.util.Set value)
Allows to restrict the scopes where the handler is used, if the handler is registered to KeyScope.ALL. |
void |
setWriteKeyDefault(boolean value)
Sets a value indicating whether to write the key default. |
void |
writeKeyDefinitionContent(GraphMLWriteContext ctx)
Writes the contents of the key definition. |
void |
writeValue(GraphMLWriteContext ctx)
Actually writes the value for the current context. |
protected abstract void |
writeValueCore(GraphMLWriteContext context,
java.lang.Object data)
Core write that performs the actual writing of the data. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected AbstractOutputHandler()
AbstractOutputHandler class.
protected AbstractOutputHandler(java.lang.String name,
KeyScope scope,
KeyType type)
AbstractOutputHandler class
name - The name to use for the key definition.scope - The scope, if this is KeyScope.GRAPHML, the getValidScopes()
property is initialized to contain exactly that scope.type - The type to use for the key definition.| Method Detail |
|---|
public KeyScope getScope()
onQueryOutputHandler(QueryOutputHandlersEvent),
setScope(y.io.graphml.KeyScope)public void setScope(KeyScope scope)
scope - the KeyScope where this handler should register itself.onQueryOutputHandler(QueryOutputHandlersEvent),
getScope()
public void onQueryOutputHandler(QueryOutputHandlersEvent event)
throws GraphMLWriteException
This implementation registers the current instance on event if a KeyScope has been specified either
with AbstractOutputHandler(String, y.io.graphml.KeyScope, y.io.graphml.KeyType) or
setScope(y.io.graphml.KeyScope)
onQueryOutputHandler in interface OutputHandlerProviderevent - Event that contains all data relevant for handler setup.
GraphMLWriteException - if a problem occurs during serialization.public void addNameToKeyDefinition(java.lang.String name)
name - The name of the key element.public void addUriToKeyDefinition(java.lang.String uri)
By default, no URI is set.
uri - The uri of the key element.public void addTypeToKeyDefinition(KeyType type)
type - The type of the key element.public void addScopeToKeyDefinition(KeyScope scope)
Note that the official graphml schema does not support the KeyScope.GRAPHML
so this implementation will silently ignore this which will result in KeyScope.ALL
implicitly being defined.
scope - The scope of the key element.public java.lang.Object getDefaultValue()
setDefaultValue(Object)public void setDefaultValue(java.lang.Object value)
Setting this value also sets the hasDefaultValueAssigned() property.
value - The default value of the attribute.getDefaultValue()public boolean hasDefaultValueAssigned()
true if a default value has been assigned;
false otherwise.setDefaultValueAssigned(boolean)protected void setDefaultValueAssigned(boolean value)
value - true if a default value has been assigned;
false otherwise.setDefaultValueAssigned(boolean)public WritePrecedence getPrecedence()
getPrecedence in interface OutputHandlersetPrecedence(WritePrecedence)public void setPrecedence(WritePrecedence value)
value - The write precedence.getPrecedence()public java.util.Collection getKeyDefinitionAttributes()
key element.
getKeyDefinitionAttributes in interface OutputHandlerkey element.addNameToKeyDefinition(String),
addScopeToKeyDefinition(y.io.graphml.KeyScope),
addTypeToKeyDefinition(y.io.graphml.KeyType),
addUriToKeyDefinition(String)public java.util.Collection getDataTagAttributes()
data element.
By default, this collection is empty.
getDataTagAttributes in interface OutputHandlerdata element.
public boolean isDefaultValue(GraphMLWriteContext ctx)
throws GraphMLWriteException
This implementation will return false if no hasDefaultValueAssigned().
Otherwise it will use getValue(y.io.graphml.output.GraphMLWriteContext,Object) and compare the result with the getDefaultValue()
to determine whether they are equal and therefore no data needs to be written.
isDefaultValue in interface OutputHandlerctx - The context.
true if for the current context the default value applies and therefore no data element needs to be written.
GraphMLWriteExceptionhasDefaultValueAssigned(),
getDefaultValue()protected boolean isValidScope(GraphMLWriteContext ctx)
getValidScopes()
ctx - The current write context.
true iff the current scope in which the handler is called is valid wrt getValidScopes().getValidScopes(),
SerializationProperties.CURRENT_KEY_SCOPEpublic java.util.Set getValidScopes()
KeyScope.ALL.
By default the collection contains KeyScope.ALL, which means the set of valid scopes is not restricted further.
KeyScope.ALLisValidScope(GraphMLWriteContext),
setValidScopes(java.util.Set)public void setValidScopes(java.util.Set value)
KeyScope.ALL.
By default the collection contains the KeyScope.ALL, which means the set of valid scopes is not restricted further.
value - A set of actually valid scopes for KeyScope.ALLisValidScope(GraphMLWriteContext),
getValidScopes()
public void writeValue(GraphMLWriteContext ctx)
throws GraphMLWriteException
This method will use getValue(y.io.graphml.output.GraphMLWriteContext,Object) to obtain the data and
delegate to writeValueCore(y.io.graphml.output.GraphMLWriteContext,Object) to perform the actual serialization.
writeValue in interface OutputHandlerctx - The context.
GraphMLWriteException
public void writeKeyDefinitionContent(GraphMLWriteContext ctx)
throws GraphMLWriteException
Depending on whether setWriteKeyDefault(boolean) is enabled and hasDefaultValueAssigned()
is true, this method will write the GraphML 'default' element and use writeValueCore(y.io.graphml.output.GraphMLWriteContext,Object)
to serialize the getDefaultValue().
writeKeyDefinitionContent in interface OutputHandlerctx - The context.
GraphMLWriteExceptionpublic void setWriteKeyDefault(boolean value)
value - true if the key default should be written at all.- See Also:
isWriteKeyDefault(),
writeKeyDefinitionContent(GraphMLWriteContext)public boolean isWriteKeyDefault()
true if the key default should be written;
false otherwise.setWriteKeyDefault(boolean),
writeKeyDefinitionContent(GraphMLWriteContext)
protected abstract void writeValueCore(GraphMLWriteContext context,
java.lang.Object data)
throws GraphMLWriteException
context - The context.data - The data.
GraphMLWriteException
protected abstract java.lang.Object getValue(GraphMLWriteContext context,
java.lang.Object key)
throws GraphMLWriteException
context - The context.key - The key.
GraphMLWriteException
|
© Copyright 2000-2025, yWorks GmbH. All rights reserved. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||