當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。