当前位置: 首页>>代码示例>>Java>>正文


Java Node类代码示例

本文整理汇总了Java中org.raml.yagi.framework.nodes.Node的典型用法代码示例。如果您正苦于以下问题:Java Node类的具体用法?Java Node怎么用?Java Node使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Node类属于org.raml.yagi.framework.nodes包,在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleSafely

import org.raml.yagi.framework.nodes.Node; //导入依赖的package包/类
@Override
public boolean handleSafely(ObjectNode node, YamlEmitter emitter) throws IOException {

    for (Node child : node.getChildren()) {

        String scalar = isScalar(node.getChildren().get(0));
        if ( scalar != null ) {

            emitter.writeObjectValue(scalar);
        } else {

            handlerList.handle(child, emitter);
        }
    }

    return true;
}
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:18,代码来源:ObjectNodeHandler.java

示例2: getIs

import org.raml.yagi.framework.nodes.Node; //导入依赖的package包/类
@Override
public ArrayList<String> getIs() {
	ArrayList<String>traits=new ArrayList<>();
	Node childNodeWithKey = this.getChildNodeWithKey("is");
	if (childNodeWithKey instanceof ArrayNode){
		ArrayNode rr=(ArrayNode) childNodeWithKey;
		
		for (Node n:rr.getChildren()){
			if (n instanceof TraitRefNode){
				TraitRefNode tr=(TraitRefNode) n;
				String value = tr.getValue();
				traits.add(value);
			}
		}
	}
	return traits;
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:18,代码来源:MethodImpl.java

示例3: annotations

import org.raml.yagi.framework.nodes.Node; //导入依赖的package包/类
@Override
public List<Annotation> annotations() {
	ArrayList<Annotation>results=new ArrayList<>();
	
	Node node=this.original;
	if (node==null){
		return Collections.emptyList();
	}
	if (node instanceof KeyValueNode){
		KeyValueNode kv=(KeyValueNode) node;
		node=kv.getValue();
	}
	for (Node n:node.getChildren()){
		if (n instanceof AnnotationNode){
			AnnotationNode mn=(AnnotationNode) n;
			Object val=TopLevelRamlModelBuilder.toObject(mn.getValue());
			String literalValue = mn.getKey().getLiteralValue();
			Annotation as = new Annotation(literalValue.substring(1, literalValue.length() - 1), val, null);
			TopLevelRamlModelBuilder.bindAnnotation(this.getTopLevel(), as);
			results.add(as);
		}
	}
	return results;
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:25,代码来源:AnnotableImpl.java

示例4: getStringList

import org.raml.yagi.framework.nodes.Node; //导入依赖的package包/类
public List<String> getStringList(String key) {
	Node childNodeWithKey = this.getChildNodeWithKey(key);
	ArrayList<String>results=new ArrayList<>();
	if (childNodeWithKey!=null){
		if (childNodeWithKey instanceof SYStringNode){
			results.add(((SYStringNode) childNodeWithKey).getLiteralValue());
		}
		else for (Node n:childNodeWithKey.getChildren()){
			if (n instanceof SimpleTypeNode){
				SimpleTypeNode<?>tn=(SimpleTypeNode<?>) n;
				results.add(tn.getLiteralValue());
			}
			
		}
	}
	return results;
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:18,代码来源:AnnotableImpl.java

示例5: getChildNodeWithKey

import org.raml.yagi.framework.nodes.Node; //导入依赖的package包/类
protected Node getChildNodeWithKey(String key) {
	Node nodeo=this.original;
	if (nodeo==null){
		return null;
	}
	if (nodeo instanceof KeyValueNode){
		KeyValueNode kv=(KeyValueNode) nodeo;
		nodeo=kv.getValue();
	}
	for (Node n:nodeo.getChildren()){
		if (n instanceof KeyValueNode){
			KeyValueNode node=(KeyValueNode) n;
			if (node.getKey() instanceof StringNode){
				StringNode nnm=(StringNode) node.getKey();
				if (nnm.getValue().equals(key)){
					Node value = node.getValue();
					return value;
				}
			}
		}
	}
	return null;
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:24,代码来源:AnnotableImpl.java

示例6: securedBy

import org.raml.yagi.framework.nodes.Node; //导入依赖的package包/类
public ArrayList<SecuredByConfig> securedBy() {
	ArrayList<SecuredByConfig> results = new ArrayList<>();
	Node childNodeWithKey = this.getChildNodeWithKey("securedBy");
	if (childNodeWithKey != null) {
		for (Node n : childNodeWithKey.getChildren()) {
			if (n instanceof ErrorNode) {
				ErrorNode zz = (ErrorNode) n;
				Node source = zz.getSource();
				if (source instanceof org.raml.v2.internal.impl.commons.nodes.ParametrizedSecuritySchemeRefNode) {
					n = source;
				}
			}
			results.add(new SecuredByImpl(mdl, this, n));
		}
	}
	return results;
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:18,代码来源:AbstractWrappedNodeImpl.java

示例7: parseProperties

import org.raml.yagi.framework.nodes.Node; //导入依赖的package包/类
private void parseProperties(TopLevelRamlImpl topLevelRamlImpl, boolean register, AbstractType result,
		List<Node> ps, boolean useNames) {
	for (Node p : ps) {
		KeyValueNode pn = (KeyValueNode) p;
		Node value = pn.getValue();
		String name = getPropertyName(pn);
		AbstractType buildType = buildType(topLevelRamlImpl, useNames ? name : "", value, register);
		boolean required = isRequired(pn);

		if (name.startsWith("/") && name.endsWith("/") && name.length() != 1) {
			if (name.length() != 2) {
				result.declareMapProperty(name.substring(1, name.length() - 1), buildType);
			} else {
				result.declareAdditionalProperty(buildType);
			}
		} else {
			result.declareProperty(name, buildType, !required);
		}
	}
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:21,代码来源:TopLevelRamlModelBuilder.java

示例8: getUsesLocations

import org.raml.yagi.framework.nodes.Node; //导入依赖的package包/类
public LinkedHashMap<String, String> getUsesLocations() {
	LinkedHashMap<String, String> results = new LinkedHashMap<>();
	Node childNodeWithKey = getChildNodeWithKey("uses");
	if (childNodeWithKey != null) {
		for (Node ch : childNodeWithKey.getChildren()) {
			if (ch instanceof LibraryNode) {
				LibraryNode ln = (LibraryNode) ch;
				LibraryLinkNode lnv = (LibraryLinkNode) ln.getValue();
				if (lnv != null) {
					String path = lnv.getRefName();
					String key =( (SYStringNode) ln.getKey()).getLiteralValue();
					results.put(key, path);
				}
			}				
		}
	}
	return results;
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:19,代码来源:TopLevelRamlImpl.java

示例9: pojoToRamlTypeBuilder

import org.raml.yagi.framework.nodes.Node; //导入依赖的package包/类
@Test
public void pojoToRamlTypeBuilder() throws Exception {

    PojoToRamlImpl pojoToRaml = new PojoToRamlImpl(FieldClassParser.factory(), RamlAdjuster.NULL_ADJUSTER);
    Result types =  pojoToRaml.classToRaml(Fun.class);

    RamlDocumentBuilder ramlDocumentBuilder = RamlDocumentBuilder
            .document()
            .baseUri("http://google.com")
            .title("hello")
            .version("1")
            .withTypes(types.allTypes().toArray(new TypeDeclarationBuilder[0]));

    Api api = ramlDocumentBuilder.buildModel();

    final GrammarPhase grammarPhase = new GrammarPhase(RamlHeader.getFragmentRule(new RamlHeader(RAML_10, Default).getFragment()));
    Node node = ((NodeModel) api).getNode();
    Node checked = grammarPhase.apply(node);
    List<ErrorNode> errors = checked.findDescendantsWith(ErrorNode.class);
    for (ErrorNode error : errors) {
        System.err.println("error: " + error.getErrorMessage());
    }

    List<TypeDeclaration> buildTypes = api.types();

    assertEquals(2, buildTypes.size());
    assertEquals("Fun", buildTypes.get(0).name());
    assertEquals("SubFun", buildTypes.get(1).name());

}
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:31,代码来源:PojoToRamlImplTest.java

示例10: property

import org.raml.yagi.framework.nodes.Node; //导入依赖的package包/类
public static NodeBuilder property(final String key, final String value) {

        return new NodeBuilder() {
            @Override
            public Node buildNode() {
                return new KeyValueNodeImpl(new StringNodeImpl(key), new StringNodeImpl(value));
            }
        };
    }
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:10,代码来源:NodeBuilders.java

示例11: arrayProperty

import org.raml.yagi.framework.nodes.Node; //导入依赖的package包/类
public static NodeBuilder arrayProperty(final String name, final String... values) {

        return new NodeBuilder() {
            @Override
            public Node buildNode() {
                SimpleArrayNode san = new SimpleArrayNode();
                for (String value : values) {
                    san.addChild(new StringNodeImpl(value));
                }
                return new KeyValueNodeImpl(new StringNodeImpl(name), san);
            }
        };
    }
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:14,代码来源:NodeBuilders.java

示例12: createValueNode

import org.raml.yagi.framework.nodes.Node; //导入依赖的package包/类
@Override
protected Node createValueNode() {
    if ( types != null ) {

        return types.buildNode();
    } else {

        return super.createValueNode();
    }
}
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:11,代码来源:TypeDeclarationBuilder.java

示例13: buildModel

import org.raml.yagi.framework.nodes.Node; //导入依赖的package包/类
public Api buildModel() {

        NodeModelFactory fac = binding.bindingOf(Api.class);
        Node node = buildNode();
        NodeModel model = fac.create(node);
        return  ModelProxyBuilder.createModel(Api.class, model, binding);
    }
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:8,代码来源:RamlDocumentBuilder.java

示例14: createValueNode

import org.raml.yagi.framework.nodes.Node; //导入依赖的package包/类
@Override
protected Node createValueNode() {

    if ( string != null ) {

        return new StringNodeImpl(string);
    } else {
        return new NumberNode(number);
    }
}
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:11,代码来源:FacetBuilder.java

示例15: buildModel

import org.raml.yagi.framework.nodes.Node; //导入依赖的package包/类
public static<T> T buildModel(ModelBindingConfiguration binding, Node node, Class<T> cls) {
    NodeModelFactory fac = binding.bindingOf(cls);
    NodeModel model = fac.create(node);
    T m =  ModelProxyBuilder.createModel(cls, model, binding);

    final GrammarPhase grammarPhase = new GrammarPhase(RamlHeader.getFragmentRule(new RamlHeader(RAML_10, Default).getFragment()));
    Node newNode = ((NodeModel) m).getNode().copy();
    grammarPhase.apply(newNode);

    return m;

}
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:13,代码来源:Util.java


注:本文中的org.raml.yagi.framework.nodes.Node类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。