ctor creates new parameters bucket where
* its content is duplicated from XML node's content
*param node - source of content for parameters bucket
*/ParamsImpl (Node node) {= new DocumentImpl (); (node ??== null) {= document.createElement (PARAMETERS_ROOT_DEFAULT) ;. appendChild (root);
} else {.appendChild (document.importNode (node, true));=document.getDocumentElement ();
}
}
/**
* Default constructor. Creates empty parameters bucket
* with default root tag name
*/ParamsImpl () {= new DocumentImpl ();=document.createElement (PARAMETERS_ROOT_DEFAULT) ;. appendChild (root);
}
/**
* De-facto copy constructor. Creates new parameters bucket
* then fill it by duplicated content ofparam params argument
*/ParamsImpl (Params params) {= new DocumentImpl (); (params == null) {= document.createElement (PARAMETERS_ROOT_DEFAULT) ;. appendChild (root);
} else {.appendChild (document.importNode (params.getXmlContent (), true));=document.getDocumentElement ();
}
}
/**
* Sets name of root tag toparam name if it's not null,
* otherwise just ignores call
*/
@ Overridevoid setName (String name) {(name!=null) .renameNode (root, null, name);
}
/**
* Tries to get String value of parameter with specifiedparam name
*return String value if it exists in parameters bucket
*throws ParamsException if there is a corruption in wrapped
* XML document
*throws ParamsException if there are no parameters with specifiedparam name
*/
@ OverrideString getString (String name) throws ParamsException {(name == null) new ParamsException ( Invalid parameter name [ + name + ] );
//enumerate through all tags with endpoint parameterslist=root.getElementsByTagName (PARAMETER); (int index=0; index lt; list.getLength (); index ++) {attributes=list.item (index ) .getAttributes ();
//check only tags with existing attributes (attributes!=null) {
//try to find name attributenameAttribute=attributes.getNamedItem (PARAMETER_NAME); (nameAttribute == null) new ParamsException ( Missing parameter name ); nameString=nameAttribute.getNodeValue (); (nameString == null) new ParamsException ( Void parameter name ); (! nameString.equals (name));
//try to find value attributevalueAttribute=attributes.getNamedItem (PARAMETER_VALUE); (valueAttribute == null) new ParamsException ( Missing parameter value ); valueString=valueAttribute.getNodeValue (); (valueString == null) new ParamsException ( Void parameter value ); valueString;
}
} new ParamsException ( There is no parameter [ + name + ] );
}
/**
* Store string parameter into bucket
*param name - name to store parameter with
*param value - value of stored parameter
*/
@ Overridevoid putString (String name, String value) {(name == null || value == null) new IllegalArgumentException ( name [ + name +
] and value [ + value + ] are mandatory ); node=document.createElement (PARAMETER) ;. setAttribute (PARAMETER_NAME, name) ;. setAttribute (PARAMETER_VALUE, value ) ;. appendChild (node);
}
/**
* Stores parameters bucket as a parameter for another bucket.
* All nodes of stored bucket are duplicated
*param name - name to store parameter with
*param params - content of stored parameters bucket
*/
@ Overridevoid putParams (String name, Params params) {(name == null || params == null) new IllegalArgumentException ( name [ + name +
] and parameter [ + params + ] are mandatory ); node=document.createElement (name); xmlContent=params.getXmlContent (); list=xmlContent.getChildNodes ( ); (int nodeIndex=0; nodeIndex lt; list.getLength (); nodeIndex ++) {.appendChild (document.importNode (list.item (nodeIndex), true));
}. appendChi...