Copyright (c) 2013 Lorenz Lehmann
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Sof...
If you think the Android project sodf listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package lal.sodf.framework.ontology;
/*www.java2s.com*//**
* A class that can be used to create a subtree of REST interactions.
* This node can be added to the {@link <code>FunctionsNode</code> } as interactions parameter
* @author Lorenz Lehmann
*
*/publicclass RestInteractionNode extends KeyNode {
/**
* Creates a new node with a rest interaction
* @param parent The parent of this node
* @param uri The REST URI
* @param parameters The parameters to be used
* @param restMethod The REST method, taken from {@link SodfVocabular.SodfVocabulary.SODF_HTTP_METHOD_*}
*/public RestInteractionNode(KeyNode parent, String uri, RestParameters[] parameters, String restMethod) {
super(parent, SodfVocabulary.SODF_INTERACTION);
buildChildren(uri, parameters, restMethod);
}
/**
* Creates a new node with a rest interaction
* @param uri The REST URI
* @param parameters The parameters to be used
* @param restMethod The REST method, taken from {@link SodfVocabular.SodfVocabulary.SODF_HTTP_METHOD_*}
*/public RestInteractionNode(String uri, RestParameters[] parameters, String restMethod) {
super(SodfVocabulary.SODF_INTERACTION);
buildChildren(uri, parameters, restMethod);
}
/** Build the children with the correct name */privatevoid buildChildren(String uri, RestParameters[] parameters, String restMethod){
//add the required children for the rest interaction
addChild(new KeyValueNode(SodfVocabulary.SODF_INTERACTION_TYPE, SodfVocabulary.SODF_REST));
//add the URI
if (uri != null && !uri.equals("")) addChild(new KeyValueNode(SodfVocabulary.SODF_URI, uri));
//add the parameters
if (parameters != null && parameters.length > 0){
//add a parameters node
KeyNode param = new KeyNode(SodfVocabulary.SODF_REST_PARAMETERS);
//add all parameters to this node
for (int i = 0; i < parameters.length; i++){
if (parameters[i] != null && parameters[i].key != null) {
KeyNode blankContainer = new KeyNode(param,parameters[i].key);
//add the name node if set
if (parameters[i].parametersName != null && !parameters[i].parametersName.equals("")){
blankContainer.addChild(new KeyValueNode(SodfVocabulary.SODF_REST_PARAMETERS_NAME, parameters[i].parametersName));
}
//add the description node if set
if (parameters[i].parametersDescription != null && !parameters[i].parametersDescription.equals("")){
blankContainer.addChild(new KeyValueNode(SodfVocabulary.SODF_REST_PARAMETERS_DESCRIPTION, parameters[i].parametersDescription));
}
}
}
//add the parameters to this node
addChild(param);
}
//add the rest method
if (restMethod != null && !restMethod.equals("")) addChild(new KeyValueNode(SodfVocabulary.SODF_REST_METHOD, restMethod));
}
}