public Object getElement(String path, String element, String value, Object parent) {
		if (map.containsKey(path)) {
			return map.get(path);
		} else {
			Matcher matcherElement = patternElement.matcher(element);
			if (matcherElement.matches()) {					
				String elementName = matcherElement.group(1);
				String nameAttribute = matcherElement.group(3);

				if (nameAttribute != null) {

					if (elementName.equals("variables")) {
						NVPairs gvs = null;
						if (parent.getClass().equals(Bw.class) || parent.getClass().equals(Adapter.class)) {
							ServiceType service = (ServiceType) parent;
							for (NVPairs nvPairs : service.getNVPairs()) {
								if (nvPairs.getName().equals(nameAttribute)) {
									gvs = nvPairs;
									break;
								}
							}
							if (gvs == null) {
								gvs = new NVPairs();
								service.getNVPairs().add(gvs);
							}
						} else if (parent.getClass().equals(Binding.class)) {
							gvs = new NVPairs();
							gvs.setName(nameAttribute);
							((Binding) parent).setNVPairs(gvs);
						}
						map.put(path, gvs);
						return gvs;
					} else if (elementName.equals("variable")) {
						NameValuePair simpleGV = new NameValuePair();
						simpleGV.setName(nameAttribute);
						simpleGV.setValue(value);

						QName name = new QName(APPLICATION_MANAGEMENT_NAMESPACE, "NameValuePair");
						JAXBElement<NameValuePair> _simpleGV = new JAXBElement<NameValuePair>(name, NameValuePair.class, simpleGV);
						boolean found = false;
						for (JAXBElement<? extends NVPairType> nvPair : ((NVPairs) parent).getNVPair()) {
							if (nameAttribute.equals(nvPair.getValue().getName())) {
								nvPair.getValue().setValue(value);
								found = true;
							}
						}
						if (!found) {
							((NVPairs) parent).getNVPair().add(_simpleGV);
						}

						return simpleGV;
					} else if (elementName.equals("bw")) {
						Bw service = this.getBw(nameAttribute);
						map.put(path, service);
						return service;
					} else if (elementName.equals("adapter")) {
						Adapter service = this.getAdapter(nameAttribute);
						map.put(path, service);
						return service;
					} else if (elementName.equals("binding")) {
						Binding binding = null;
						if (parent.getClass().equals(Bw.class)) {
							binding = this.getBinding(nameAttribute, (Bw) parent);
						} else if (parent.getClass().equals(Adapter.class)) {
							binding = this.getBinding(nameAttribute, (Adapter) parent);
						} else {
							// throw ?
						}
						map.put(path, binding);
						return binding;
					} else if (elementName.equals("bwprocess")) {
						Bwprocess bwProcess = this.getBWProcess(nameAttribute, (Bw) parent);
						map.put(path, bwProcess);
						return bwProcess;
					} else if (elementName.equals("checkpoint")) {
						Checkpoints checkpoints = (Checkpoints) parent;
						if (!checkpoints.getCheckpoint().contains(nameAttribute)) {
							checkpoints.getCheckpoint().add(nameAttribute);
						}
						if ("true".equals(value)) {
							checkpoints.setSelected(nameAttribute);
						}
					}
				} else {
					if (elementName.equals("variables")) {
						NVPairs gvs = null;
						if (parent.getClass().equals(Bw.class) || parent.getClass().equals(Adapter.class)) {
							ServiceType service = (ServiceType) parent;
							for (NVPairs nvPairs : service.getNVPairs()) {
								if (nvPairs.getName().equals("Runtime Variables")) {
									gvs = nvPairs;
									break;
								}
							}
							if (gvs == null) {
								gvs = new NVPairs();
								service.getNVPairs().add(gvs);
							}
						} else if (parent.getClass().equals(Binding.class)) {
							gvs = new NVPairs();
							gvs.setName("Runtime Variables");
							((Binding) parent).setNVPairs(gvs);
						}
						map.put(path, gvs);
						return gvs;
					} else if (elementName.equals("checkpoints")) {
						Checkpoints checkpoints = this.getBWCheckpoints((Bw) parent);
						map.put(path, checkpoints);
						return checkpoints;
					} else if (elementName.equals("tablePrefix")) {
						Checkpoints checkpoints = (Checkpoints) parent;
						checkpoints.setTablePrefix(value);
					// Binding children
					} else if (parent.getClass().equals(Binding.class)) {
						return addBindingParameter((Binding) parent, elementName, value);
					} else if (parent.getClass().equals(Product.class)) {
						return addProductParameter((Product) parent, elementName, value);
					} else if (parent.getClass().equals(Setting.class)) {
						return addSettingParameter((Setting) parent, elementName, value);
					} else if (parent.getClass().equals(NTService.class)) {
						return addNTServiceParameter((NTService) parent, elementName, value);
					} else if (parent.getClass().equals(Java.class)) {
						return addJavaParameter((Java) parent, elementName, value);
					} else if (parent.getClass().equals(Shutdown.class)) {
						return addShutdownParameter((Shutdown) parent, elementName, value);
					//
					// Bwprocess children
					} else if (parent.getClass().equals(Bwprocess.class)) {
						addBWProcessParameter((Bwprocess) parent, elementName, value);
					} else if (parent.getClass().equals(FaultTolerant.class)) {
						addFaultTolerantParameter((FaultTolerant) parent, elementName, value);
					} else if (parent.getClass().equals(Checkpoints.class)) {
						addCheckpointsParameter((Checkpoints) parent, elementName, value);
					// Bw chidren (direct children)
					} else if (parent.getClass().equals(Bw.class)) {
						return addBwParameter((Bw) parent, elementName, value);
					} else if (parent.getClass().equals(Adapter.class)) {
						return addAdapterParameter((Adapter) parent, elementName, value);
					}
				}

			}
			return parent;
		}
	}
public Object getElement(String path, String element, String value, Object parent) {
		if (map.containsKey(path)) {
			return map.get(path);
		} else {
			Matcher matcherElement = patternElement.matcher(element);
			if (matcherElement.matches()) {					
				String elementName = matcherElement.group(1);
				String nameAttribute = matcherElement.group(3);

				if (nameAttribute != null) {

					if (elementName.equals("variables")) {
						NVPairs gvs = null;
						if (parent.getClass().equals(Bw.class) || parent.getClass().equals(Adapter.class)) {
							ServiceType service = (ServiceType) parent;
							for (NVPairs nvPairs : service.getNVPairs()) {
								if (nvPairs.getName().equals(nameAttribute)) {
									gvs = nvPairs;
									break;
								}
							}
							if (gvs == null) {
								gvs = new NVPairs();
								service.getNVPairs().add(gvs);
							}
						} else if (parent.getClass().equals(Binding.class)) {
							gvs = new NVPairs();
							gvs.setName(nameAttribute);
							((Binding) parent).setNVPairs(gvs);
						}
						map.put(path, gvs);
						return gvs;
					} else if (elementName.equals("variable")) {
						NameValuePair simpleGV = new NameValuePair();
						simpleGV.setName(nameAttribute);
						simpleGV.setValue(value);

						QName name = new QName(APPLICATION_MANAGEMENT_NAMESPACE, "NameValuePair");
						JAXBElement<NameValuePair> _simpleGV = new JAXBElement<NameValuePair>(name, NameValuePair.class, simpleGV);
						boolean found = false;
						for (JAXBElement<? extends NVPairType> nvPair : ((NVPairs) parent).getNVPair()) {
							if (nameAttribute.equals(nvPair.getValue().getName())) {
								nvPair.getValue().setValue(value);
								found = true;
							}
						}
						if (!found) {
							((NVPairs) parent).getNVPair().add(_simpleGV);
						}

						return simpleGV;
					} else if (elementName.equals("bw")) {
						Bw service = this.getBw(nameAttribute);
						map.put(path, service);
						return service;
					} else if (elementName.equals("adapter")) {
						Adapter service = this.getAdapter(nameAttribute);
						map.put(path, service);
						return service;
					} else if (elementName.equals("binding")) {
						Binding binding = null;
						if (parent.getClass().equals(Bw.class)) {
							binding = this.getBinding(nameAttribute, (Bw) parent);
						} else if (parent.getClass().equals(Adapter.class)) {
							binding = this.getBinding(nameAttribute, (Adapter) parent);
						} else {
							
						}
						map.put(path, binding);
						return binding;
					} else if (elementName.equals("bwprocess")) {
						Bwprocess bwProcess = this.getBWProcess(nameAttribute, (Bw) parent);
						map.put(path, bwProcess);
						return bwProcess;
					} else if (elementName.equals("checkpoint")) {
						Checkpoints checkpoints = (Checkpoints) parent;
						if (!checkpoints.getCheckpoint().contains(nameAttribute)) {
							checkpoints.getCheckpoint().add(nameAttribute);
						}
						if ("true".equals(value)) {
							checkpoints.setSelected(nameAttribute);
						}
					}
				} else {
					if (elementName.equals("variables")) {
						NVPairs gvs = null;
						if (parent.getClass().equals(Bw.class) || parent.getClass().equals(Adapter.class)) {
							ServiceType service = (ServiceType) parent;
							for (NVPairs nvPairs : service.getNVPairs()) {
								if (nvPairs.getName().equals("Runtime Variables")) {
									gvs = nvPairs;
									break;
								}
							}
							if (gvs == null) {
								gvs = new NVPairs();
								service.getNVPairs().add(gvs);
							}
						} else if (parent.getClass().equals(Binding.class)) {
							gvs = new NVPairs();
							gvs.setName("Runtime Variables");
							((Binding) parent).setNVPairs(gvs);
						}
						map.put(path, gvs);
						return gvs;
					} else if (elementName.equals("checkpoints")) {
						Checkpoints checkpoints = this.getBWCheckpoints((Bw) parent);
						map.put(path, checkpoints);
						return checkpoints;
					} else if (elementName.equals("tablePrefix")) {
						Checkpoints checkpoints = (Checkpoints) parent;
						checkpoints.setTablePrefix(value);
					
					} else if (parent.getClass().equals(Binding.class)) {
						return addBindingParameter((Binding) parent, elementName, value);
					} else if (parent.getClass().equals(Product.class)) {
						return addProductParameter((Product) parent, elementName, value);
					} else if (parent.getClass().equals(Setting.class)) {
						return addSettingParameter((Setting) parent, elementName, value);
					} else if (parent.getClass().equals(NTService.class)) {
						return addNTServiceParameter((NTService) parent, elementName, value);
					} else if (parent.getClass().equals(Java.class)) {
						return addJavaParameter((Java) parent, elementName, value);
					} else if (parent.getClass().equals(Shutdown.class)) {
						return addShutdownParameter((Shutdown) parent, elementName, value);
					
					
					} else if (parent.getClass().equals(Bwprocess.class)) {
						addBWProcessParameter((Bwprocess) parent, elementName, value);
					} else if (parent.getClass().equals(FaultTolerant.class)) {
						addFaultTolerantParameter((FaultTolerant) parent, elementName, value);
					} else if (parent.getClass().equals(Checkpoints.class)) {
						addCheckpointsParameter((Checkpoints) parent, elementName, value);
					
					} else if (parent.getClass().equals(Bw.class)) {
						return addBwParameter((Bw) parent, elementName, value);
					} else if (parent.getClass().equals(Adapter.class)) {
						return addAdapterParameter((Adapter) parent, elementName, value);
					}
				}

			}
			return parent;
		}
	}
public Object getElement ( String path , String element , String value , Object parent ) { if ( map . containsKey ( path ) ) { return map . get ( path ) ; } else { Matcher matcherElement = patternElement . matcher ( element ) ; if ( matcherElement . matches ( ) ) { String elementName = matcherElement . group ( 1 ) ; String nameAttribute = matcherElement . group ( 3 ) ; if ( nameAttribute != null ) { if ( elementName . equals ( "variables" ) ) { NVPairs gvs = null ; if ( parent . getClass ( ) . equals ( Bw . class ) || parent . getClass ( ) . equals ( Adapter . class ) ) { ServiceType service = ( ServiceType ) parent ; for ( NVPairs nvPairs : service . getNVPairs ( ) ) { if ( nvPairs . getName ( ) . equals ( nameAttribute ) ) { gvs = nvPairs ; break ; } } if ( gvs == null ) { gvs = new NVPairs ( ) ; service . getNVPairs ( ) . add ( gvs ) ; } } else if ( parent . getClass ( ) . equals ( Binding . class ) ) { gvs = new NVPairs ( ) ; gvs . setName ( nameAttribute ) ; ( ( Binding ) parent ) . setNVPairs ( gvs ) ; } map . put ( path , gvs ) ; return gvs ; } else if ( elementName . equals ( "variable" ) ) { NameValuePair simpleGV = new NameValuePair ( ) ; simpleGV . setName ( nameAttribute ) ; simpleGV . setValue ( value ) ; QName name = new QName ( APPLICATION_MANAGEMENT_NAMESPACE , "NameValuePair" ) ; JAXBElement < NameValuePair > _simpleGV = new JAXBElement < NameValuePair > ( name , NameValuePair . class , simpleGV ) ; boolean found = false ; for ( JAXBElement < ? extends NVPairType > nvPair : ( ( NVPairs ) parent ) . getNVPair ( ) ) { if ( nameAttribute . equals ( nvPair . getValue ( ) . getName ( ) ) ) { nvPair . getValue ( ) . setValue ( value ) ; found = true ; } } if ( ! found ) { ( ( NVPairs ) parent ) . getNVPair ( ) . add ( _simpleGV ) ; } return simpleGV ; } else if ( elementName . equals ( "bw" ) ) { Bw service = this . getBw ( nameAttribute ) ; map . put ( path , service ) ; return service ; } else if ( elementName . equals ( "adapter" ) ) { Adapter service = this . getAdapter ( nameAttribute ) ; map . put ( path , service ) ; return service ; } else if ( elementName . equals ( "binding" ) ) { Binding binding = null ; if ( parent . getClass ( ) . equals ( Bw . class ) ) { binding = this . getBinding ( nameAttribute , ( Bw ) parent ) ; } else if ( parent . getClass ( ) . equals ( Adapter . class ) ) { binding = this . getBinding ( nameAttribute , ( Adapter ) parent ) ; } else { // throw ? } map . put ( path , binding ) ; return binding ; } else if ( elementName . equals ( "bwprocess" ) ) { Bwprocess bwProcess = this . getBWProcess ( nameAttribute , ( Bw ) parent ) ; map . put ( path , bwProcess ) ; return bwProcess ; } else if ( elementName . equals ( "checkpoint" ) ) { Checkpoints checkpoints = ( Checkpoints ) parent ; if ( ! checkpoints . getCheckpoint ( ) . contains ( nameAttribute ) ) { checkpoints . getCheckpoint ( ) . add ( nameAttribute ) ; } if ( "true" . equals ( value ) ) { checkpoints . setSelected ( nameAttribute ) ; } } } else { if ( elementName . equals ( "variables" ) ) { NVPairs gvs = null ; if ( parent . getClass ( ) . equals ( Bw . class ) || parent . getClass ( ) . equals ( Adapter . class ) ) { ServiceType service = ( ServiceType ) parent ; for ( NVPairs nvPairs : service . getNVPairs ( ) ) { if ( nvPairs . getName ( ) . equals ( "Runtime Variables" ) ) { gvs = nvPairs ; break ; } } if ( gvs == null ) { gvs = new NVPairs ( ) ; service . getNVPairs ( ) . add ( gvs ) ; } } else if ( parent . getClass ( ) . equals ( Binding . class ) ) { gvs = new NVPairs ( ) ; gvs . setName ( "Runtime Variables" ) ; ( ( Binding ) parent ) . setNVPairs ( gvs ) ; } map . put ( path , gvs ) ; return gvs ; } else if ( elementName . equals ( "checkpoints" ) ) { Checkpoints checkpoints = this . getBWCheckpoints ( ( Bw ) parent ) ; map . put ( path , checkpoints ) ; return checkpoints ; } else if ( elementName . equals ( "tablePrefix" ) ) { Checkpoints checkpoints = ( Checkpoints ) parent ; checkpoints . setTablePrefix ( value ) ; // Binding children } else if ( parent . getClass ( ) . equals ( Binding . class ) ) { return addBindingParameter ( ( Binding ) parent , elementName , value ) ; } else if ( parent . getClass ( ) . equals ( Product . class ) ) { return addProductParameter ( ( Product ) parent , elementName , value ) ; } else if ( parent . getClass ( ) . equals ( Setting . class ) ) { return addSettingParameter ( ( Setting ) parent , elementName , value ) ; } else if ( parent . getClass ( ) . equals ( NTService . class ) ) { return addNTServiceParameter ( ( NTService ) parent , elementName , value ) ; } else if ( parent . getClass ( ) . equals ( Java . class ) ) { return addJavaParameter ( ( Java ) parent , elementName , value ) ; } else if ( parent . getClass ( ) . equals ( Shutdown . class ) ) { return addShutdownParameter ( ( Shutdown ) parent , elementName , value ) ; // // Bwprocess children } else if ( parent . getClass ( ) . equals ( Bwprocess . class ) ) { addBWProcessParameter ( ( Bwprocess ) parent , elementName , value ) ; } else if ( parent . getClass ( ) . equals ( FaultTolerant . class ) ) { addFaultTolerantParameter ( ( FaultTolerant ) parent , elementName , value ) ; } else if ( parent . getClass ( ) . equals ( Checkpoints . class ) ) { addCheckpointsParameter ( ( Checkpoints ) parent , elementName , value ) ; // Bw chidren (direct children) } else if ( parent . getClass ( ) . equals ( Bw . class ) ) { return addBwParameter ( ( Bw ) parent , elementName , value ) ; } else if ( parent . getClass ( ) . equals ( Adapter . class ) ) { return addAdapterParameter ( ( Adapter ) parent , elementName , value ) ; } } } return parent ; } }
<p>
This method will create JAXB objects from Properties through recursive
calls.
Each property has a path. The last part of a path (after last /) is the
element.
</p>
<p > This method will create JAXB objects from Properties through recursive calls . Each property has a path . The last part of a path ( after last / ) is the element . < / p >