Java Code Examples for javax.xml.soap.Node#ELEMENT_NODE

The following examples show how to use javax.xml.soap.Node#ELEMENT_NODE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public ArrayList<T> load() throws ParserConfigurationException, SAXException, IOException {

		ArrayList<T> entities = new ArrayList<T>();

		File fXmlFile = new File(this.xmlFilename);
		DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
		DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
		Document doc = dBuilder.parse(fXmlFile);
		doc.getDocumentElement().normalize();

		NodeList nodeList = doc.getElementsByTagName(this.entityTag);

		for (int i = 0; i < nodeList.getLength(); i++) {
			org.w3c.dom.Node node = nodeList.item(i);
			if (node.getNodeType() == Node.ELEMENT_NODE) {
				Element element = (Element) node;
				entities.add(getEntityFromXmlElement(element));
			}
		}
		return entities;
	}
 
Example 2
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public ArrayList<T> load() throws Exception {
	ArrayList<T> entities = new ArrayList<T>();

	File fXmlFile = new File(this.xmlFilename);
	DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
	DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
	Document doc = dBuilder.parse(fXmlFile);
	doc.getDocumentElement().normalize();

	NodeList nodeList = doc.getElementsByTagName(this.entityTag);

	for (int i = 0; i < nodeList.getLength(); i++) {
		org.w3c.dom.Node node = nodeList.item(i);
		if (node.getNodeType() == Node.ELEMENT_NODE) {
			Element element = (Element) node;
			entities.add(getEntityFromXmlElement(element));
		}
	}
	return entities;
}
 
Example 3
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public ArrayList<T> load() throws Exception {
	ArrayList<T> entities = new ArrayList<T>();

	File fXmlFile = new File(this.xmlFilename);
	DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
	DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
	Document doc = dBuilder.parse(fXmlFile);
	doc.getDocumentElement().normalize();

	NodeList nodeList = doc.getElementsByTagName(this.entityTag);

	for (int i = 0; i < nodeList.getLength(); i++) {
		org.w3c.dom.Node node = nodeList.item(i);
		if (node.getNodeType() == Node.ELEMENT_NODE) {
			Element element = (Element) node;
			entities.add(getEntityFromXmlElement(element));
		}
	}
	return entities;
}
 
Example 4
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public ArrayList<T> load() throws Exception {
	ArrayList<T> entities = new ArrayList<T>();

	File fXmlFile = new File(this.xmlFilename);
	DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
	DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
	Document doc = dBuilder.parse(fXmlFile);
	doc.getDocumentElement().normalize();

	NodeList nodeList = doc.getElementsByTagName(this.entityTag);

	for (int i = 0; i < nodeList.getLength(); i++) {
		org.w3c.dom.Node node = nodeList.item(i);
		if (node.getNodeType() == Node.ELEMENT_NODE) {
			Element element = (Element) node;
			entities.add(getEntityFromXmlElement(element));
		}
	}
	return entities;
}
 
Example 5
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public ArrayList<T> load() throws Exception {
	ArrayList<T> entities = new ArrayList<T>();

	File fXmlFile = new File(this.xmlFilename);
	DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
	DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
	Document doc = dBuilder.parse(fXmlFile);
	doc.getDocumentElement().normalize();

	NodeList nodeList = doc.getElementsByTagName(this.entityTag);

	for (int i = 0; i < nodeList.getLength(); i++) {
		org.w3c.dom.Node node = nodeList.item(i);
		if (node.getNodeType() == Node.ELEMENT_NODE) {
			Element element = (Element) node;
			entities.add(getEntityFromXmlElement(element));
		}
	}
	return entities;
}
 
Example 6
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public ArrayList<T> load() throws ParserConfigurationException, SAXException, IOException {
ArrayList<T> entities = new ArrayList<T>();
File fXmlFile = new File(this.xmlFilename);
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = (Document) dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();
NodeList nodeList = doc.getElementsByTagName(Constants.XML_TAGS.ANIMAL);	
for (int i = 0; i < nodeList.getLength(); i++) {
	Node node = (Node) nodeList.item(i);
	if (node.getNodeType() == Node.ELEMENT_NODE) { 
		Element element = (Element) node;
		entities.add(getEntityFromXmlElement(element));
	}
}
return entities;
}
 
Example 7
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public ArrayList<T> load() throws ParserConfigurationException, SAXException, IOException {

		ArrayList<T> entities = new ArrayList<T>();

		File fXmlFile = new File(this.xmlFilename);
		DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
		DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
		Document doc = dBuilder.parse(fXmlFile);
		doc.getDocumentElement().normalize();

		NodeList nodeList = doc.getElementsByTagName(this.entityTag);

		for (int i = 0; i < nodeList.getLength(); i++) {
			org.w3c.dom.Node node = nodeList.item(i);
			if (node.getNodeType() == Node.ELEMENT_NODE) {
				Element element = (Element) node;
				entities.add(getEntityFromXmlElement(element));
			}
		}
		return entities;
	}
 
Example 8
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public ArrayList<T> load() throws ParserConfigurationException, SAXException, IOException {

		ArrayList<T> entities = new ArrayList<T>();

		File fXmlFile = new File(this.xmlFilename);
		DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
		DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
		Document doc = dBuilder.parse(fXmlFile);
		doc.getDocumentElement().normalize();

		NodeList nodeList = doc.getElementsByTagName(this.entityTag);

		for (int i = 0; i < nodeList.getLength(); i++) {
			org.w3c.dom.Node node = nodeList.item(i);
			if (node.getNodeType() == Node.ELEMENT_NODE) {
				Element element = (Element) node;
				entities.add(getEntityFromXmlElement(element));
			}
		}
		return entities;
	}
 
Example 9
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public ArrayList<T> load() throws ParserConfigurationException, SAXException, IOException {

		ArrayList<T> entities = new ArrayList<T>();

		File fXmlFile = new File(this.xmlFilename);
		DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
		DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
		Document doc = dBuilder.parse(fXmlFile);
		doc.getDocumentElement().normalize();

		NodeList nodeList = doc.getElementsByTagName(this.entityTag);

		for (int i = 0; i < nodeList.getLength(); i++) {
			org.w3c.dom.Node node = nodeList.item(i);
			if (node.getNodeType() == Node.ELEMENT_NODE) {
				Element element = (Element) node;
				entities.add(getEntityFromXmlElement(element));
			}
		}
		return entities;
	}
 
Example 10
Source File: EmployeeRepository.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public ArrayList<Employee> load() throws Exception {
	ArrayList<Employee> employees = new ArrayList<Employee>();
	File fXmlFile = new File(XML_FILENAME);
	DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
	DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
	Document doc = dBuilder.parse(fXmlFile);
	doc.getDocumentElement().normalize();
	NodeList nodeList = doc.getElementsByTagName(Constants.XML_TAGS.EMPLOYEE);
	for (int i = 0; i < nodeList.getLength(); i++) {
		org.w3c.dom.Node node =  nodeList.item(i);
		if (node.getNodeType() == Node.ELEMENT_NODE) {
			Element element = (Element) node;
			String discriminant = element.getElementsByTagName(Constants.XML_TAGS.DISCRIMINANT).item(0)
					.getTextContent();
			switch (discriminant) {
			case Constants.Employees.Employee.Caretaker:
				EmployeeAbstractFactory caretakers = new CaretakerFactory();
				Employee caretaker = (Caretaker) caretakers.getEmployee(Constants.Employees.Employee.Caretaker);
				caretaker.decodeFromXml(element);
				employees.add(caretaker);

			default:
				break;
			}
		}
	}
	return employees;
}
 
Example 11
Source File: EmployeeRepository.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public ArrayList<Employee> load() throws Exception {
	ArrayList<Employee> employees = new ArrayList<Employee>();
	File fXmlFile = new File(XML_FILENAME);
	DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
	DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
	Document doc = dBuilder.parse(fXmlFile);
	doc.getDocumentElement().normalize();
	NodeList nodeList = doc.getElementsByTagName(Constants.XML_TAGS.EMPLOYEE);
	for (int i = 0; i < nodeList.getLength(); i++) {
		org.w3c.dom.Node node =  nodeList.item(i);
		if (node.getNodeType() == Node.ELEMENT_NODE) {
			Element element = (Element) node;
			String discriminant = element.getElementsByTagName(Constants.XML_TAGS.DISCRIMINANT).item(0)
					.getTextContent();
			switch (discriminant) {
			case Constants.Employees.Employee.Caretaker:
				EmployeeAbstractFactory caretakers = new CaretakerFactory();
				Employee caretaker = (Caretaker) caretakers.getEmployee(Constants.Employees.Employee.Caretaker);
				caretaker.decodeFromXml(element);
				employees.add(caretaker);

			default:
				break;
			}
		}
	}
	return employees;
}
 
Example 12
Source File: EmployeeRepository.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public ArrayList<Employee> load() throws ParserConfigurationException, SAXException, IOException{
	ArrayList<Employee> employees = new ArrayList<Employee>();
	
	File fXmlFile = new File(XML_FILENAME);
	DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
	DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
	Document doc = (Document) dBuilder.parse(fXmlFile);
	doc.getDocumentElement().normalize();
	
	NodeList nodeList = doc.getElementsByTagName(Constants.XML_TAGS.EMPLOYEE);
	for (int i = 0; i < nodeList.getLength(); i++) {
		Node node = (Node) nodeList.item(i);
		if (node.getNodeType() == Node.ELEMENT_NODE) {
			Element element = (Element) node;
			String discriminant = element.getElementsByTagName(Constants.XML_TAGS.DISCRIMINANT).item(0).getTextContent();
			switch (discriminant) {
			case Constants.Employee.Caretaker:
				Employee caretaker = new Caretaker();
				caretaker.decodeFromXml(element);
				employees.add(caretaker);
			default:
				break;
			}
		}
}
	return employees;
}
 
Example 13
Source File: EmployeeRepository.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public ArrayList<Employee> load() throws ParserConfigurationException, SAXException, IOException {

		ArrayList<Employee> employees = new ArrayList<Employee>();

		File fXmlFile = new File(XML_FILENAME);
		DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
		DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
		Document doc = dBuilder.parse(fXmlFile);
		doc.getDocumentElement().normalize();

		NodeList nodeList = doc.getElementsByTagName(Constants.XML_TAGS.EMPLOYEE);

		for (int i = 0; i < nodeList.getLength(); i++) {
			org.w3c.dom.Node node = nodeList.item(i);
			if (node.getNodeType() == Node.ELEMENT_NODE) {
				Element element = (Element) node;
				String discriminant = element.getElementsByTagName(Constants.XML_TAGS.DISCRIMINANT).item(0)
						.getTextContent();

				switch (discriminant) {
				case Constants.Employees.Caretaker:
					String name = element.getElementsByTagName("name").item(0).getTextContent();
					BigDecimal salary = BigDecimal
							.valueOf(Double.valueOf(element.getElementsByTagName("salary").item(0).getTextContent()));
					long id = Long.valueOf(element.getElementsByTagName("id").item(0).getTextContent());
					Employee caretaker = new Caretaker(name, id, salary);
					caretaker.decodeFromXml(element);
					employees.add(caretaker);
					break;
				default:
					break;
				}
			}
		}
		return employees;
	}
 
Example 14
Source File: AnimalRepository.java    From JavaMainRepo with Apache License 2.0 4 votes vote down vote up
public ArrayList<Animal> load() throws ParserConfigurationException, SAXException, IOException {
	ArrayList<Animal> animals = new ArrayList<Animal>();
	
	File fXmlFile = new File(XML_FILENAME);
	DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
	DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
	Document doc = dBuilder.parse(fXmlFile);
	doc.getDocumentElement().normalize();
	
	NodeList nodeList = doc.getElementsByTagName(Constants.XML_TAGS.ANIMAL);
	
	for (int i = 0; i < nodeList.getLength(); i++) {
		org.w3c.dom.Node node =  nodeList.item(i);
		if (node.getNodeType() == Node.ELEMENT_NODE) {
			Element element = (Element) node;
			String discriminant = element.getElementsByTagName(Constants.XML_TAGS.DISCRIMINANT).item(0)
					.getTextContent();
			switch (discriminant) {
			case Constants.Animals.Insects.Butterfly:
				Animal butterfly = new Butterfly();
				butterfly.decodeFromXml(element);
				animals.add(butterfly);
			case Constants.Animals.Insects.Cockroach:
				Animal cockroach = new Cockroach();
				cockroach.decodeFromXml(element);
				animals.add(cockroach);
			case Constants.Animals.Insects.Spider:
				Animal spider = new Spider();
				spider.decodeFromXml(element);
				animals.add(spider);
			case Constants.Animals.Aquatics.Salmon:
				Animal salmon = new Salmon();
				salmon.decodeFromXml(element);
				animals.add(salmon);
			case Constants.Animals.Aquatics.SeaHorse:
				Animal seaHorse = new SeaHorse();
				seaHorse.decodeFromXml(element);
				animals.add(seaHorse);
			case Constants.Animals.Aquatics.Shark:
				Animal shark = new Shark();
				shark.decodeFromXml(element);
				animals.add(shark);
			case Constants.Animals.Mammals.Cow:
				Animal cow = new Cow();
				cow.decodeFromXml(element);
				animals.add(cow);
			case Constants.Animals.Mammals.Monkey:
				Animal monkey = new Monkey();
				monkey.decodeFromXml(element);
				animals.add(monkey);
			case Constants.Animals.Mammals.Tiger:
				Animal tiger = new Tiger();
				tiger.decodeFromXml(element);
				animals.add(tiger);
			case Constants.Animals.Birds.Albatross:
				Animal albatross = new Albatross();
				albatross.decodeFromXml(element);
				animals.add(albatross);
			case Constants.Animals.Birds.Flamingo:
				Animal flamingo = new Flamingo();
				flamingo.decodeFromXml(element);
				animals.add(flamingo);
			case Constants.Animals.Birds.Owl:
				Animal owl = new Owl();
				owl.decodeFromXml(element);
				animals.add(owl);
			case Constants.Animals.Birds.Penguin:
				Animal penguin = new Penguin();
				penguin.decodeFromXml(element);
				animals.add(penguin);
			case Constants.Animals.Reptiles.Amphisbaenian:
				Animal amphisbaenian = new Amphisbaenian();
				amphisbaenian.decodeFromXml(element);
				animals.add(amphisbaenian);
			case Constants.Animals.Reptiles.Chameleon:
				Animal chameleon = new Chameleon();
				chameleon.decodeFromXml(element);
				animals.add(chameleon);
			case Constants.Animals.Reptiles.Tuataras:
				Animal tuataras = new Tuataras();
				tuataras.decodeFromXml(element);
				animals.add(tuataras);
			default:
				break;
			}
		}
	}
	return animals;
}
 
Example 15
Source File: DockerContainerTypePlugin.java    From container with Apache License 2.0 4 votes vote down vote up
@Override
public boolean canHandleTerminate(AbstractNodeTemplate nodeTemplate) {
    if (nodeTemplate.getProperties() == null) {
        return false;
    }

    boolean correctNodeType = false;
    final List<QName> typeHierarchy = ModelUtils.getNodeTypeHierarchy(nodeTemplate.getType());

    if (typeHierarchy.contains(DockerContainerTypePluginPluginConstants.DOCKER_CONTAINER_NODETYPE)) {
        correctNodeType |= true;
    }

    if (typeHierarchy.contains(DockerContainerTypePluginPluginConstants.DOCKER_CONTAINER_NODETYPE2)) {
        correctNodeType |= true;
    }

    if (!correctNodeType) {
        return false;
    }

    final Element propertyElement = nodeTemplate.getProperties().getDOMElement();
    final NodeList childNodeList = propertyElement.getChildNodes();

    int check = 0;
    for (int index = 0; index < childNodeList.getLength(); index++) {
        if (childNodeList.item(index).getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }
        if (childNodeList.item(index).getLocalName().equals("ContainerID")) {
            check++;
        }
    }

    if (check != 1) {
        return false;
    }

    // minimum properties are available

    // check whether the nodeTemplate is connected to a DockerEngine Node

    return DockerContainerTypePlugin.isConnectedToDockerEnginerNode(nodeTemplate);
}
 
Example 16
Source File: DockerContainerTypePlugin.java    From container with Apache License 2.0 4 votes vote down vote up
@Override
public boolean canHandleCreate(final AbstractNodeTemplate nodeTemplate) {
    // for this plugin to handle the given NodeTemplate following statements
    // must hold:
    // 1. The NodeTemplate has the Properties "ContainerPort" and "Port"
    // 2. The NodeTemplate has either one DeploymentArtefact of the Type
    // {http://opentosca.org/artefacttypes}DockerContainer XOR a Property
    // "ContainerImage"
    // 3. Is connected to a {http://opentosca.org/nodetypes}DockerEngine
    // Node trough a path of hostedOn relations
    // Optional:
    // Has a "SSHPort" which can be used to further configure the
    // DockerContainer

    // check mandatory properties
    if (nodeTemplate.getProperties() == null) {
        return false;
    }

    boolean correctNodeType = false;
    final List<QName> typeHierarchy = ModelUtils.getNodeTypeHierarchy(nodeTemplate.getType());

    if (typeHierarchy.contains(DockerContainerTypePluginPluginConstants.DOCKER_CONTAINER_NODETYPE)) {
        correctNodeType |= true;
    }

    if (typeHierarchy.contains(DockerContainerTypePluginPluginConstants.DOCKER_CONTAINER_NODETYPE2)) {
        correctNodeType |= true;
    }

    if (!correctNodeType) {
        return false;
    }

    final Element propertyElement = nodeTemplate.getProperties().getDOMElement();
    final NodeList childNodeList = propertyElement.getChildNodes();

    int check = 0;
    boolean foundDockerImageProp = false;
    for (int index = 0; index < childNodeList.getLength(); index++) {
        if (childNodeList.item(index).getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }
        if (childNodeList.item(index).getLocalName().equals("ContainerPort")) {
            check++;
        } else if (childNodeList.item(index).getLocalName().equals("Port")) {
            check++;
        } else if (childNodeList.item(index).getLocalName().equals("ImageID")) {
            foundDockerImageProp = true;
        }
    }

    if (check != 2) {
        return false;
    }

    // minimum properties are available, now check for the container image
    // itself

    // if we didn't find a property to take an image from a public repo,
    // then we search for a DA
    if (!foundDockerImageProp) {

        if (DockerContainerTypePlugin.fetchFirstDockerContainerDA(nodeTemplate) == null) {
            return false;
        }
    }

    // check whether the nodeTemplate is connected to a DockerEngine Node

    return DockerContainerTypePlugin.isConnectedToDockerEnginerNode(nodeTemplate);
}