org.yaml.snakeyaml.constructor.Construct Java Examples

The following examples show how to use org.yaml.snakeyaml.constructor.Construct. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChangeRuntimeClassTest.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
private Construct getConstructor(Node node) {
    Class<?> cl = getClassForNode(node);
    if (cl.equals(Entity.class) && true) {
        // today's temperature is high :)
        cl = EntityLoadingProxy.class;
    }
    node.setType(cl);
    // call the constructor as if the runtime class is defined
    Construct constructor = yamlClassConstructors.get(node.getNodeId());
    return constructor;
}
 
Example #2
Source File: BundleCacher.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object construct(Node node)
{
	node.setType(SnippetElement.class);
	String path = getPath(node);
	SnippetElement be = new SnippetElement(path);
	Construct mappingConstruct = yamlClassConstructors.get(NodeId.mapping);
	mappingConstruct.construct2ndStep(node, be);
	be.setPath(path);
	setPrefixTriggers(node, be);
	return be;
}
 
Example #3
Source File: BundleCacher.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object construct(Node node)
{
	node.setType(CommandElement.class);
	String path = getPath(node);
	CommandElement be = new LazyCommandElement(path);
	Construct mappingConstruct = yamlClassConstructors.get(NodeId.mapping);
	mappingConstruct.construct2ndStep(node, be);
	be.setPath(path);
	setPrefixTriggers(node, be);
	return be;
}
 
Example #4
Source File: BundleCacher.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object construct(Node node)
{
	node.setType(BundleElement.class);
	String path = getPath(node);
	BundleElement be = new BundleElement(path);
	Construct mappingConstruct = yamlClassConstructors.get(NodeId.mapping);
	mappingConstruct.construct2ndStep(node, be);
	be.setPath(path);
	return be;
}
 
Example #5
Source File: BundleCacher.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object construct(Node node)
{
	node.setType(BuildPathElement.class);

	String path = getPath(node);
	String buildPath = getPath(node, "buildPath"); //$NON-NLS-1$
	BuildPathElement bpe = new BuildPathElement(path);
	Construct mappingConstruct = yamlClassConstructors.get(NodeId.mapping);
	mappingConstruct.construct2ndStep(node, bpe);
	bpe.setPath(path);
	bpe.setBuildPath(buildPath);
	return bpe;
}
 
Example #6
Source File: BundleCacher.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object construct(Node node)
{
	node.setType(SnippetCategoryElement.class);
	String path = getPath(node);
	SnippetCategoryElement sce = new SnippetCategoryElement(path);
	Construct mappingConstruct = yamlClassConstructors.get(NodeId.mapping);
	mappingConstruct.construct2ndStep(node, sce);
	sce.setPath(path);
	return sce;
}
 
Example #7
Source File: BundleCacher.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object construct(Node node)
{
	node.setType(MenuElement.class);
	String path = getPath(node);
	MenuElement be = new MenuElement(path);
	Construct mappingConstruct = yamlClassConstructors.get(NodeId.mapping);
	mappingConstruct.construct2ndStep(node, be);
	be.setPath(path);
	forcePathsOfChildren(be.getChildren());
	return be;
}
 
Example #8
Source File: BundleCacher.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object construct(Node node)
{
	node.setType(ProjectTemplateElement.class);
	String path = getPath(node);
	ProjectTemplateElement be = new ProjectTemplateElement(path);
	Construct mappingConstruct = yamlClassConstructors.get(NodeId.mapping);
	mappingConstruct.construct2ndStep(node, be);
	be.setPath(path);
	return be;
}
 
Example #9
Source File: BundleCacher.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object construct(Node node)
{
	node.setType(ProjectSampleElement.class);
	String path = getPath(node);
	ProjectSampleElement be = new ProjectSampleElement(path);
	Construct mappingConstruct = yamlClassConstructors.get(NodeId.mapping);
	mappingConstruct.construct2ndStep(node, be);
	be.setPath(path);
	return be;
}
 
Example #10
Source File: PerlTest.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
protected Construct getConstructor(Node node) {
    if (node.getTag().equals(new Tag("!de.oddb.org,2007/ODDB::Util::Code"))) {
        node.setUseClassConstructor(true);
        node.setType(CodeBean.class);
    }
    return super.getConstructor(node);
}
 
Example #11
Source File: JodaTimeFlowStylesTest.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
@Override
public Object construct(Node nnode) {
    if (nnode.getTag().equals(new Tag("tag:yaml.org,2002:timestamp"))) {
        Construct dateConstructor = yamlConstructors.get(Tag.TIMESTAMP);
        Date date = (Date) dateConstructor.construct(nnode);
        return new DateTime(date, DateTimeZone.UTC);
    } else {
        return super.construct(nnode);
    }
}
 
Example #12
Source File: JodaTimeExampleTest.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
@Override
public Object construct(Node nnode) {
    if (nnode.getTag().equals("tag:yaml.org,2002:timestamp")) {
        Construct dateConstructor = yamlConstructors.get(Tag.TIMESTAMP);
        Date date = (Date) dateConstructor.construct(nnode);
        return new DateTime(date, DateTimeZone.UTC);
    } else {
        return super.construct(nnode);
    }
}
 
Example #13
Source File: BundleCacher.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object construct(Node node)
{
	node.setType(EnvironmentElement.class);
	String path = getPath(node);
	EnvironmentElement be = new LazyEnvironmentElement(path);
	Construct mappingConstruct = yamlClassConstructors.get(NodeId.mapping);
	mappingConstruct.construct2ndStep(node, be);
	be.setPath(path);
	return be;
}
 
Example #14
Source File: BundleCacher.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object construct(Node node)
{
	node.setType(TemplateElement.class);
	String path = getPath(node);
	TemplateElement be = new LazyTemplateElement(path);
	Construct mappingConstruct = yamlClassConstructors.get(NodeId.mapping);
	mappingConstruct.construct2ndStep(node, be);
	be.setPath(path);
	setPrefixTriggers(node, be);
	return be;
}
 
Example #15
Source File: BundleCacher.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object construct(Node node)
{
	node.setType(ContentAssistElement.class);
	String path = getPath(node);
	ContentAssistElement be = new LazyContentAssistElement(path);
	Construct mappingConstruct = yamlClassConstructors.get(NodeId.mapping);
	mappingConstruct.construct2ndStep(node, be);
	be.setPath(path);
	setPrefixTriggers(node, be);
	return be;
}
 
Example #16
Source File: YamlParser.java    From nexus-repository-helm with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object construct(Node nnode) {
  if (nnode.getTag().toString().equals("tag:yaml.org,2002:timestamp")) {
    Construct dateConstructor = yamlConstructors.get(Tag.TIMESTAMP);
    Date date = (Date) dateConstructor.construct(nnode);
    return new DateTime(date, DateTimeZone.UTC);
  }
  else {
    return super.construct(nnode);
  }
}
 
Example #17
Source File: CompactConstructor.java    From orion.server with Eclipse Public License 1.0 4 votes vote down vote up
private Construct getCompactConstruct() {
    if (compactConstruct == null) {
        compactConstruct = createCompactConstruct();
    }
    return compactConstruct;
}
 
Example #18
Source File: YamlConstructor.java    From Diorite with MIT License 4 votes vote down vote up
public void addConstruct(Class<?> type, Construct construct)
{
    this.yamlConstructors.put(new Tag(type), construct);
}
 
Example #19
Source File: ShardingSphereYamlConstructor.java    From shardingsphere with Apache License 2.0 4 votes vote down vote up
@Override
protected Construct getConstructor(final Node node) {
    return typeConstructs.getOrDefault(node.getType(), super.getConstructor(node));
}
 
Example #20
Source File: ImplicitResolverTest.java    From snake-yaml with Apache License 2.0 4 votes vote down vote up
protected Construct getConstructor(Node node) {
    if (CFG.equals(node.getTag())) {
        node.setUseClassConstructor(false);
    }
    return super.getConstructor(node);
}
 
Example #21
Source File: CompactConstructor.java    From snake-yaml with Apache License 2.0 4 votes vote down vote up
protected Construct createCompactConstruct() {
    return new ConstructCompactObject();
}
 
Example #22
Source File: CompactConstructor.java    From snake-yaml with Apache License 2.0 4 votes vote down vote up
private Construct getCompactConstruct() {
    if (compactConstruct == null) {
        compactConstruct = createCompactConstruct();
    }
    return compactConstruct;
}
 
Example #23
Source File: CompactConstructor.java    From orion.server with Eclipse Public License 1.0 4 votes vote down vote up
protected Construct createCompactConstruct() {
    return new ConstructCompactObject();
}
 
Example #24
Source File: YamlConstructor.java    From Diorite with MIT License 2 votes vote down vote up
/**
 * Get the constructor to construct the Node. For implicit tags if the
 * runtime class is known a dedicated Construct implementation is used.
 * Otherwise the constructor is chosen by the tag.
 *
 * @param node
 *         Node to be constructed
 *
 * @return Construct implementation for the specified node
 */
@Override
public Construct getConstructor(Node node)
{
    return super.getConstructor(node);
}