@Override
	public void write(JustClass justClass) {
		
		DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
		DocumentBuilder db;
		try {
			db = dbFactory.newDocumentBuilder();
			doc = db.newDocument();
			
			Element rootElement = doc.createElement(CLASS_ELEMENT);
			
			// constants
			Element constantPool = doc.createElement(CONSTANT_POOL);
			rootElement.appendChild(constantPool);
			
			for (Reference ref : justClass.getReferences().values()) {
				constantPool.appendChild(getElementOfReference(ref));
			}
			Element thisClass = doc.createElement(THIS);
			thisClass.appendChild(doc.createTextNode(justClass.getClassReference().getIndex() + ""));
			rootElement.appendChild(thisClass);
			
			
			// fields
			Element fieldInfo = doc.createElement(FIELD_INFO);
			rootElement.appendChild(fieldInfo);
			
			for(Field field : justClass.getFields()) {
				fieldInfo.appendChild(getElementOfField(field));
			}
			
			
			// methods
			Element methodInfo = doc.createElement(METHOD_INFO);
			rootElement.appendChild(methodInfo);

			for (Method method : justClass.getMethods()) {
				methodInfo.appendChild(getElementOfMethod(method));
			}
			
			// output DOM XML to console
			TransformerFactory transformerFactory = TransformerFactory
					.newInstance();
			transformerFactory.setAttribute("indent-number", 4);
			Transformer transformer = transformerFactory.newTransformer();

			transformer.setOutputProperty(OutputKeys.INDENT, "yes");
			// initialize StreamResult with File object to save to file
			StreamResult result = new StreamResult(new StringWriter());
			DOMSource source = new DOMSource(doc);
			transformer.transform(source, result);
			String xmlString = result.getWriter().toString();
			System.out.println(xmlString);

			PrintWriter out = new PrintWriter(PATH + "class.jcl");
			out.println(xmlString);
			out.flush();
			out.close();

			System.out.println("\nXML DOM Created Successfully..");
			
		} catch(DOMException e) {
			System.out.println("Error during class-generation " + e.getLocalizedMessage());  
		} catch (ParserConfigurationException e) {
			System.out.println("Error during class-generation " + e.getLocalizedMessage());  
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (TransformerException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}