eu.monnetproject.lemon.impl
Class LemonElementImpl<Elem extends LemonElement>

java.lang.Object
  extended by eu.monnetproject.lemon.URIValue
      extended by eu.monnetproject.lemon.URIElement
          extended by eu.monnetproject.lemon.impl.LemonElementImpl<Elem>
All Implemented Interfaces:
IntrospectableElement, ReaderAccepter, LemonElement, LemonElementOrPredicate, Serializable
Direct Known Subclasses:
ArgumentImpl, ComponentImpl, ConditionImpl, ConstituentImpl, ContextImpl, DefinitionImpl, ExampleImpl, FormImpl, FrameImpl, LexicalEntryImpl, LexicalSenseImpl, LexiconImpl, MorphPatternImpl, MorphTransformImpl, NodeImpl, PrototypeImpl, TopicImpl

public abstract class LemonElementImpl<Elem extends LemonElement>
extends URIElement
implements LemonElement, ReaderAccepter, IntrospectableElement, Serializable

Base class for element implementations

Author:
John McCrae
See Also:
Serialized Form

Field Summary
protected  boolean checkRemote
           
protected  LemonModelImpl model
           
static URI RDF_TYPE
           
protected  List<LemonElementImpl<?>> referencers
           
 
Constructor Summary
protected LemonElementImpl(String id, String type, LemonModelImpl model)
           
protected LemonElementImpl(URI uri, String type, LemonModelImpl model)
           
 
Method Summary
 void accept(ElementVisitor visitor)
           
protected  boolean acceptProperties(URI pred, URI value, LinguisticOntology lingOnto)
           
 boolean addAnnotation(URI uri, Object o)
          Add an annotation to this element
protected  boolean addPredElem(LemonPredicate p, LemonElement e)
           
protected  boolean addPredElemDirect(LemonPredicate p, LemonElement e)
           
 boolean addProperty(Property property, PropertyValue propertyVal)
          Add a property to this element
protected  void addReference(LemonElementImpl<?> element)
           
protected  boolean addStrElem(String p, LemonElement e)
           
protected  boolean addStrElemDirect(String p, LemonElement e)
           
 void addType(URI uri)
          Add a type to this element
protected  void addTypeDirect(URI uri)
           
 void clearAll()
           
protected  ReaderAccepter defaultAccept(URI pred, String value)
           
protected  void defaultAccept(URI pred, String val, String lang)
           
protected  ReaderAccepter defaultAccept(URI pred, URI value, LinguisticOntology lingOnto)
           
protected  void defaultMerge(ReaderAccepter accepter, LinguisticOntology lingOnto, AccepterFactory factory)
           
protected  void doAccept(ElementVisitor visitor)
           
protected  boolean follow(LemonPredicate predicate)
           
protected  boolean follow(String predName)
           
 Map<URI,Collection<Object>> getAnnotations()
          Get any annotations for this element
 Collection<Object> getAnnotations(URI uri)
          Get the set of annotations for this property
 Map<URI,Collection<Object>> getElements()
           
 String getModelName()
           
protected  Collection<LemonElement> getPredElem(LemonPredicate p)
           
protected
<Pred extends LemonPredicate>
Map<Pred,Collection<LemonElement>>
getPredElems(Class<Pred> clazz)
           
 Collection<PropertyValue> getProperty(Property property)
          Get the set of values for a property
 Map<Property,Collection<PropertyValue>> getPropertys()
          Get any properties of this element
protected  LemonElement getStrElem(String name)
           
protected  Collection<LemonElement> getStrElems(String name)
           
protected  Text getStrText(String name)
           
 Collection<URI> getTypes()
          Get any types of the element
 boolean isMultiReferenced()
           
protected
<X> void
merge(Collection<X> list1, Collection<X> list2)
           
protected
<X,Y> void
merge(Map<X,Collection<Y>> map1, Map<X,Collection<Y>> map2)
           
protected  void mergeIn(Elem elem)
           
protected  void printAsBlankNode(PrintWriter stream, SerializationState state)
           
protected  void printAsBlankNode(PrintWriter stream, SerializationState state, boolean first)
           
protected  void printURI(URI uri, PrintWriter stream)
           
protected  boolean refers()
           
 boolean removeAnnotation(URI uri, Object o)
          Remove an annotation from this element
protected  boolean removePredElem(LemonPredicate p, LemonElement e)
           
 boolean removeProperty(Property property, PropertyValue propertyVal)
          Remove a property from this element
protected  void removeReference(LemonElementImpl<?> element)
           
protected  boolean removeStrElem(String p, LemonElement e)
           
 void removeType(URI uri)
          Remove a type from this element
protected  void resolveRemote()
           
protected  void setStrElem(String name, LemonElement elem)
           
protected  void setStrElemDirect(String name, LemonElement elem)
           
protected  void setStrText(String name, Text txt)
           
protected  void setStrTextDirect(String name, Text txt)
           
protected  void updateAddPredElem(LemonElement e, LemonPredicate p)
           
protected  void updateReference(LemonElement from, LemonElement to)
           
 void visit(PrintWriter stream, SerializationState state)
           
 void write(PrintWriter stream, SerializationState state)
           
 
Methods inherited from class eu.monnetproject.lemon.URIElement
equals, getID, hashCode, toString
 
Methods inherited from class eu.monnetproject.lemon.URIValue
getInfHash, getURI
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface eu.monnetproject.lemon.model.LemonElement
getID
 
Methods inherited from interface eu.monnetproject.lemon.model.LemonElementOrPredicate
getURI
 
Methods inherited from interface eu.monnetproject.lemon.impl.io.ReaderAccepter
accept, accept, accept, merge
 

Field Detail

RDF_TYPE

public static final URI RDF_TYPE

referencers

protected List<LemonElementImpl<?>> referencers

model

protected final LemonModelImpl model

checkRemote

protected boolean checkRemote
Constructor Detail

LemonElementImpl

protected LemonElementImpl(URI uri,
                           String type,
                           LemonModelImpl model)

LemonElementImpl

protected LemonElementImpl(String id,
                           String type,
                           LemonModelImpl model)
Method Detail

getPropertys

public Map<Property,Collection<PropertyValue>> getPropertys()
Description copied from interface: LemonElement
Get any properties of this element

Specified by:
getPropertys in interface LemonElement
Overrides:
getPropertys in class URIElement

getProperty

public Collection<PropertyValue> getProperty(Property property)
Description copied from interface: LemonElement
Get the set of values for a property

Specified by:
getProperty in interface LemonElement
Overrides:
getProperty in class URIElement

addProperty

public boolean addProperty(Property property,
                           PropertyValue propertyVal)
Description copied from interface: LemonElement
Add a property to this element

Specified by:
addProperty in interface LemonElement
Overrides:
addProperty in class URIElement

removeProperty

public boolean removeProperty(Property property,
                              PropertyValue propertyVal)
Description copied from interface: LemonElement
Remove a property from this element

Specified by:
removeProperty in interface LemonElement
Overrides:
removeProperty in class URIElement

getTypes

public Collection<URI> getTypes()
Description copied from interface: LemonElement
Get any types of the element

Specified by:
getTypes in interface LemonElement
Overrides:
getTypes in class URIElement

addType

public void addType(URI uri)
Description copied from interface: LemonElement
Add a type to this element

Specified by:
addType in interface LemonElement
Overrides:
addType in class URIElement

addStrElemDirect

protected boolean addStrElemDirect(String p,
                                   LemonElement e)

addTypeDirect

protected void addTypeDirect(URI uri)

removeType

public void removeType(URI uri)
Description copied from interface: LemonElement
Remove a type from this element

Specified by:
removeType in interface LemonElement
Overrides:
removeType in class URIElement

getAnnotations

public Map<URI,Collection<Object>> getAnnotations()
Description copied from interface: LemonElement
Get any annotations for this element

Specified by:
getAnnotations in interface LemonElement
Overrides:
getAnnotations in class URIElement
Returns:
A map where the value is a collection of either java.net.URI, java.lang.String (blank nodes) or eu.monnetproject.lemon.model.Text

getAnnotations

public Collection<Object> getAnnotations(URI uri)
Description copied from interface: LemonElement
Get the set of annotations for this property

Specified by:
getAnnotations in interface LemonElement
Overrides:
getAnnotations in class URIElement
Returns:
A collection of either java.net.URI, java.lang.String (blank nodes) or eu.monnetproject.lemon.model.Text

addAnnotation

public boolean addAnnotation(URI uri,
                             Object o)
Description copied from interface: LemonElement
Add an annotation to this element

Specified by:
addAnnotation in interface LemonElement
Overrides:
addAnnotation in class URIElement
Parameters:
uri - The annotation property
o - Either a java.net.URI, java.lang.String (blank nodes) or eu.monnetproject.lemon.model.Text
Returns:
true if the element changed

removeAnnotation

public boolean removeAnnotation(URI uri,
                                Object o)
Description copied from interface: LemonElement
Remove an annotation from this element

Specified by:
removeAnnotation in interface LemonElement
Overrides:
removeAnnotation in class URIElement
Parameters:
uri - The annotation property
o - Either a java.net.URI, java.lang.String (blank nodes) or eu.monnetproject.lemon.model.Text
Returns:
true if the element changed

getStrElem

protected LemonElement getStrElem(String name)

setStrElemDirect

protected void setStrElemDirect(String name,
                                LemonElement elem)

setStrElem

protected void setStrElem(String name,
                          LemonElement elem)

getStrText

protected Text getStrText(String name)

setStrText

protected void setStrText(String name,
                          Text txt)

setStrTextDirect

protected void setStrTextDirect(String name,
                                Text txt)

getPredElems

protected <Pred extends LemonPredicate> Map<Pred,Collection<LemonElement>> getPredElems(Class<Pred> clazz)

getPredElem

protected Collection<LemonElement> getPredElem(LemonPredicate p)

addPredElem

protected boolean addPredElem(LemonPredicate p,
                              LemonElement e)

addPredElemDirect

protected boolean addPredElemDirect(LemonPredicate p,
                                    LemonElement e)

updateAddPredElem

protected void updateAddPredElem(LemonElement e,
                                 LemonPredicate p)

removePredElem

protected boolean removePredElem(LemonPredicate p,
                                 LemonElement e)

getStrElems

protected Collection<LemonElement> getStrElems(String name)

addStrElem

protected boolean addStrElem(String p,
                             LemonElement e)

removeStrElem

protected boolean removeStrElem(String p,
                                LemonElement e)

addReference

protected void addReference(LemonElementImpl<?> element)

removeReference

protected void removeReference(LemonElementImpl<?> element)

updateReference

protected void updateReference(LemonElement from,
                               LemonElement to)

mergeIn

protected void mergeIn(Elem elem)

refers

protected boolean refers()

visit

public void visit(PrintWriter stream,
                  SerializationState state)

printAsBlankNode

protected void printAsBlankNode(PrintWriter stream,
                                SerializationState state)

printURI

protected void printURI(URI uri,
                        PrintWriter stream)

printAsBlankNode

protected void printAsBlankNode(PrintWriter stream,
                                SerializationState state,
                                boolean first)

write

public void write(PrintWriter stream,
                  SerializationState state)

follow

protected boolean follow(LemonPredicate predicate)

follow

protected boolean follow(String predName)

doAccept

protected void doAccept(ElementVisitor visitor)

accept

public final void accept(ElementVisitor visitor)

clearAll

public void clearAll()

defaultAccept

protected ReaderAccepter defaultAccept(URI pred,
                                       URI value,
                                       LinguisticOntology lingOnto)

defaultAccept

protected ReaderAccepter defaultAccept(URI pred,
                                       String value)

defaultAccept

protected void defaultAccept(URI pred,
                             String val,
                             String lang)

merge

protected <X,Y> void merge(Map<X,Collection<Y>> map1,
                           Map<X,Collection<Y>> map2)

merge

protected <X> void merge(Collection<X> list1,
                         Collection<X> list2)

defaultMerge

protected void defaultMerge(ReaderAccepter accepter,
                            LinguisticOntology lingOnto,
                            AccepterFactory factory)

acceptProperties

protected boolean acceptProperties(URI pred,
                                   URI value,
                                   LinguisticOntology lingOnto)

getElements

public Map<URI,Collection<Object>> getElements()
Specified by:
getElements in interface IntrospectableElement

getModelName

public String getModelName()
Specified by:
getModelName in interface IntrospectableElement

isMultiReferenced

public boolean isMultiReferenced()

resolveRemote

protected void resolveRemote()


Copyright © 2012. All Rights Reserved.