⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jahiadomobject.java

📁 java 写的一个新闻发布系统
💻 JAVA
字号:
////                                   ____.//                       __/\ ______|    |__/\.     _______//            __   .____|    |       \   |    +----+       \//    _______|  /--|    |    |    -   \  _    |    :    -   \_________//   \\______: :---|    :    :           |    :    |         \________>//           |__\---\_____________:______:    :____|____:_____\//                                      /_____|////                 . . . i n   j a h i a   w e   t r u s t . . .////////  JahiaDOMObject////  NK      25.07.2001//package org.jahia.data;import java.io.*;import java.util.*;import org.w3c.dom.*;import org.xml.sax.*;import javax.xml.parsers.SAXParser;import javax.xml.parsers.DocumentBuilder;import javax.xml.parsers.DocumentBuilderFactory;import javax.xml.parsers.ParserConfigurationException;import org.xml.sax.InputSource;import org.xml.sax.SAXException;import org.xml.sax.SAXParseException;import javax.xml.transform.*;import javax.xml.transform.sax.*;import javax.xml.transform.dom.*;import javax.xml.transform.stream.*;import org.jahia.exceptions.*;import org.jahia.utils.*;               // JahiaConsole/** * A DOM Object typically contains a DOM Document * * @author Khue Nguyen * @version 1.0 */public abstract class JahiaDOMObject {		protected Document xmlDoc = null;		   	//--------------------------------------------------------------------------	/**	 * save the document to a file	 *	 * @param String destFileName	 */	public void save (String destFileName) throws JahiaException{		saveFile(destFileName);	}	   	//--------------------------------------------------------------------------	/**	 * return a reference to the DOM Document	 *	 * @return Document the DOM Document	 */	public Document getDocument () {		return xmlDoc;	}	   	//--------------------------------------------------------------------------	/**	 * return a DOM as string	 *	 * @return Document the DOM Document	 */	public String toString () {		Element el = (Element)xmlDoc.getDocumentElement();		if (  el != null ){			return el.toString();		}		return null;	}	    //--------------------------------------------------------------------------	private void saveFile(String destinationFileName)    throws JahiaException {		try {        	xmlDoc.normalize(); // cleanup DOM tree a little        	TransformerFactory tfactory = TransformerFactory.newInstance();        	// This creates a transformer that does a simple identity transform,        	// and thus can be used for all intents and purposes as a serializer.        	Transformer serializer = tfactory.newTransformer();        	Properties oprops = new Properties();        	oprops.put("method", "html");        	oprops.put("indent-amount", "2");        	serializer.setOutputProperties(oprops);        	FileOutputStream fileStream = new FileOutputStream(destinationFileName);        	serializer.transform(new DOMSource(xmlDoc),                             new StreamResult(fileStream));		} catch ( Throwable t ){	   		throw new JahiaException(  "XMLPortlets",                                        "Exception " + t.getMessage(),                                        JahiaException.ERROR,                                        JahiaException.SERVICE_ERROR);		}		    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -