|
jInfer | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.cuni.mff.ksi.jinfer.base.utils.CloneHelper
public class CloneHelper
Utilities for cloning. Note that this class uses an inner cache of already cloned elements to deal with cyclic dependencies, and should be used to clone at most one full grammar. If not sure, create a new instance of this class to clone something.
Constructor Summary | |
---|---|
CloneHelper()
|
Method Summary | |
---|---|
Element |
cloneElement(Element e)
Clones a single element. |
Element |
cloneElement(Element e,
List<String> contextPrefix)
Clones a single element. |
List<Element> |
cloneGrammar(List<Element> grammar)
Clones the whole grammar at once. |
Regexp<AbstractStructuralNode> |
cloneRegexp(Regexp<AbstractStructuralNode> r,
List<String> contextPrefix)
Clones a regular expression. |
static List<String> |
getPrefixedContext(NamedNode node,
List<String> contextPrefix)
Concatenate context from contextPrefix and the context of node
When contextPrefix is {"X","Y"} and the context of node is {"A", "B"},
method returns {"X","Y","A","B"}. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CloneHelper()
Method Detail |
---|
public List<Element> cloneGrammar(List<Element> grammar)
grammar
- Grammar to be cloned.
public Element cloneElement(Element e)
e
- Element to be cloned.
cloneElement(cz.cuni.mff.ksi.jinfer.base.objects.nodes.Element, java.util.List)
public Element cloneElement(Element e, List<String> contextPrefix)
contextPrefix
.
For example: if element A has children B,C and contextPrefix
is null
or empty, the contexts are
contentPrefix
contains strings "X","Y","Z", the final contexts of the elements are
e
- Element to be cloned.contextPrefix
- Context to be used as prefix.
public Regexp<AbstractStructuralNode> cloneRegexp(Regexp<AbstractStructuralNode> r, List<String> contextPrefix)
contextPrefix
as in cloneElement(cz.cuni.mff.ksi.jinfer.base.objects.nodes.Element, java.util.List)
.
r
- Regexp to be cloned.contextPrefix
- Context to be used as prefix.
public static List<String> getPrefixedContext(NamedNode node, List<String> contextPrefix)
contextPrefix
and the context of node
When contextPrefix
is {"X","Y"} and the context of node
is {"A", "B"},
method returns {"X","Y","A","B"}.
node
- Node from which the context is retrieved.contextPrefix
- Context that should be appended before the node
context.
node
when contextPrefix
is empty or null
.
Result will be equal to contextPrefix
if the context of node
is empty or null
.
Result will be null
if both arguments are null
.
|
jInfer | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |