[85142] BIDI support
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/ClasspathRuntimeTargetHandler.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/ClasspathRuntimeTargetHandler.java
index d81451c..98d6152 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/ClasspathRuntimeTargetHandler.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/ClasspathRuntimeTargetHandler.java
@@ -17,16 +17,9 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.*;
-import org.eclipse.jdt.core.IClasspathContainer;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.*;
import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.jst.server.core.internal.IMemento;
-import org.eclipse.jst.server.core.internal.JavaServerPlugin;
-import org.eclipse.jst.server.core.internal.RuntimeClasspathContainer;
-import org.eclipse.jst.server.core.internal.Trace;
-import org.eclipse.jst.server.core.internal.XMLMemento;
+import org.eclipse.jst.server.core.internal.*;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.model.RuntimeTargetHandlerDelegate;
/**
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/XMLMemento.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/XMLMemento.java
index a35ea43..d354553 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/XMLMemento.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/XMLMemento.java
@@ -12,7 +12,6 @@
import java.io.*;
import java.util.*;
-import java.net.URL;
import org.w3c.dom.*;
import org.xml.sax.*;
@@ -45,7 +44,7 @@
* you should use createReadRoot and createWriteRoot to create the initial
* mementos on a document.
*/
- public XMLMemento(Document doc, Element el) {
+ private XMLMemento(Document doc, Element el) {
factory = doc;
element = el;
}
@@ -73,12 +72,12 @@
* Create a Document from a Reader and answer a root memento for reading
* a document.
*/
- protected static XMLMemento createReadRoot(Reader reader) {
+ protected static XMLMemento createReadRoot(InputStream in) {
Document document = null;
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = factory.newDocumentBuilder();
- document = parser.parse(new InputSource(reader));
+ document = parser.parse(new InputSource(in));
Node node = document.getFirstChild();
if (node instanceof Element)
return new XMLMemento(document, (Element) node);
@@ -86,7 +85,7 @@
// ignore
} finally {
try {
- reader.close();
+ in.close();
} catch (Exception e) {
// ignore
}
@@ -254,62 +253,12 @@
/**
* Loads a memento from the given filename.
*
- * @param in java.io.InputStream
- * @return org.eclipse.ui.IMemento
- * @exception java.io.IOException
- */
- public static IMemento loadMemento(InputStream in) {
- return createReadRoot(new InputStreamReader(in));
- }
-
- /**
- * Loads a memento from the given filename.
- *
- * @param in java.io.InputStream
- * @return org.eclipse.ui.IMemento
- * @exception java.io.IOException
- */
- public static IMemento loadCorruptMemento(InputStream in) {
- Document document = null;
- try {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder parser = factory.newDocumentBuilder();
- document = parser.parse(in);
- Node node = document.getFirstChild();
- if (node instanceof Element)
- return new XMLMemento(document, (Element) node);
- } catch (Exception e) {
- // ignore
- } finally {
- try {
- in.close();
- } catch (Exception e) {
- // ignore
- }
- }
- return null;
- }
-
- /**
- * Loads a memento from the given filename.
- *
* @param filename java.lang.String
* @return org.eclipse.ui.IMemento
* @exception java.io.IOException
*/
public static IMemento loadMemento(String filename) throws IOException {
- return XMLMemento.createReadRoot(new FileReader(filename));
- }
-
- /**
- * Loads a memento from the given filename.
- *
- * @param url java.net.URL
- * @return org.eclipse.ui.IMemento
- * @exception java.io.IOException
- */
- public static IMemento loadMemento(URL url) throws IOException {
- return XMLMemento.createReadRoot(new InputStreamReader(url.openStream()));
+ return XMLMemento.createReadRoot(new FileInputStream(filename));
}
/*
@@ -364,23 +313,6 @@
return;
element.setAttribute(key, value);
}
-
- /**
- * Save this Memento to a Writer.
- */
- public void save(Writer writer) throws IOException {
- Result result = new StreamResult(writer);
- Source source = new DOMSource(factory);
- try {
- Transformer transformer = TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- transformer.setOutputProperty(OutputKeys.METHOD, "xml");
- transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "2");
- transformer.transform(source, result);
- } catch (Exception e) {
- throw (IOException) (new IOException().initCause(e));
- }
- }
/**
* Save this Memento to a Writer.
@@ -392,6 +324,7 @@
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "2");
transformer.transform(source, result);
} catch (Exception e) {
@@ -406,9 +339,9 @@
* @exception java.io.IOException
*/
public void saveToFile(String filename) throws IOException {
- Writer w = null;
+ FileOutputStream w = null;
try {
- w = new FileWriter(filename);
+ w = new FileOutputStream(filename);
save(w);
} catch (IOException e) {
throw e;
@@ -425,12 +358,6 @@
}
}
- public String saveToString() throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- save(out);
- return out.toString("UTF-8");
- }
-
/*
* @see IMemento#getBoolean(String)
*/
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/Factory.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/Factory.java
index 1e59666..27007aa 100644
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/Factory.java
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/Factory.java
@@ -67,15 +67,14 @@
public Document getDocument() {
return document;
}
-
+
public String getPackageName() {
return packageName;
}
-
+
public XMLElement loadDocument(InputStream in) throws IOException {
try {
- InputStreamReader reader = new InputStreamReader(in);
- document = XMLUtil.getDocumentBuilder().parse(new InputSource(reader));
+ document = XMLUtil.getDocumentBuilder().parse(new InputSource(in));
Element element = document.getDocumentElement();
return newInstance(element);
} catch (Exception exception) {
@@ -83,7 +82,7 @@
throw new IOException("Could not load document");
}
}
-
+
protected XMLElement newInstance(Element element) {
String s = element.getNodeName();
try {
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/XMLUtil.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/XMLUtil.java
index 4610ba1..aab9c4a 100644
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/XMLUtil.java
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/xml/XMLUtil.java
@@ -104,7 +104,7 @@
public static byte[] getContents(Document document) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
- print(new PrintWriter(out), document);
+ print(new PrintStream(out, true, "UTF-8"), document);
return out.toByteArray();
} catch (Exception ex) {
throw new IOException(ex.getLocalizedMessage());
@@ -219,14 +219,14 @@
return stringbuffer.toString();
}
- protected static void print(PrintWriter out, Node node) {
+ protected static void print(PrintStream out, Node node) {
if (node == null)
return;
short type = node.getNodeType();
switch (type) {
case Node.DOCUMENT_NODE: {
- //out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n");
+ out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ //out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n");
NodeList nodelist = node.getChildNodes();
int size = nodelist.getLength();
for (int i = 0; i < size; i++)
@@ -321,9 +321,9 @@
}
public static void save(String filename, Document document) throws IOException {
- PrintWriter out = null;
+ PrintStream out = null;
try {
- out = new PrintWriter(new BufferedWriter(new FileWriter(filename)));
+ out = new PrintStream(new BufferedOutputStream(new FileOutputStream(filename)), true, "UTF-8");
//traceNode(document, "");
print(out, document);
} catch (Exception ex) {
@@ -362,12 +362,12 @@
}
public static String toString(Document document) {
- PrintWriter out = null;
+ PrintStream out = null;
try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
- out = new PrintWriter(baos);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
+ out = new PrintStream(baos);
print(out, document);
- return new String(baos.toByteArray());
+ return new String(baos.toByteArray(), "UTF-8");
} catch (Exception ex) {
// ignore
} finally {
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/MonitorManager.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/MonitorManager.java
index 5e2fed4..0fe190d 100644
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/MonitorManager.java
+++ b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/MonitorManager.java
@@ -184,7 +184,7 @@
String xmlString = prefs.getString("monitors");
if (xmlString != null && xmlString.length() > 0) {
try {
- ByteArrayInputStream in = new ByteArrayInputStream(xmlString.getBytes());
+ ByteArrayInputStream in = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
IMemento memento = XMLMemento.loadMemento(in);
IMemento[] children = memento.getChildren("monitor");
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/XMLMemento.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/XMLMemento.java
index fee2ce3..5f6c615 100644
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/XMLMemento.java
+++ b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/XMLMemento.java
@@ -12,7 +12,6 @@
import java.io.*;
import java.util.*;
-import java.net.URL;
import org.w3c.dom.*;
import org.xml.sax.*;
@@ -45,7 +44,7 @@
* you should use createReadRoot and createWriteRoot to create the initial
* mementos on a document.
*/
- public XMLMemento(Document doc, Element el) {
+ private XMLMemento(Document doc, Element el) {
factory = doc;
element = el;
}
@@ -73,12 +72,12 @@
* Create a Document from a Reader and answer a root memento for reading
* a document.
*/
- protected static XMLMemento createReadRoot(Reader reader) {
+ protected static XMLMemento createReadRoot(InputStream in) {
Document document = null;
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = factory.newDocumentBuilder();
- document = parser.parse(new InputSource(reader));
+ document = parser.parse(new InputSource(in));
Node node = document.getFirstChild();
if (node instanceof Element)
return new XMLMemento(document, (Element) node);
@@ -90,7 +89,7 @@
// ignore
} finally {
try {
- reader.close();
+ in.close();
} catch (Exception e) {
// ignore
}
@@ -168,17 +167,6 @@
}
/**
- * Return the contents of this memento as a byte array.
- *
- * @return byte[]
- */
- public byte[] getContents() throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- save(out);
- return out.toByteArray();
- }
-
- /**
* Returns an input stream for writing to the disk with a local locale.
*
* @return the input stream
@@ -263,61 +251,7 @@
* @exception java.io.IOException
*/
public static IMemento loadMemento(InputStream in) {
- return createReadRoot(new InputStreamReader(in));
- }
-
- /**
- * Loads a memento from the given filename.
- *
- * @param in the input stream
- * @return a memento
- * @exception java.io.IOException
- */
- public static IMemento loadCorruptMemento(InputStream in) {
- Document document = null;
- try {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder parser = factory.newDocumentBuilder();
- document = parser.parse(in);
- Node node = document.getFirstChild();
- if (node instanceof Element)
- return new XMLMemento(document, (Element) node);
- } catch (ParserConfigurationException e) {
- // ignore
- } catch (IOException e) {
- // ignore
- } catch (SAXException e) {
- // ignore
- } finally {
- try {
- in.close();
- } catch (Exception e) {
- // ignore
- }
- }
- return null;
- }
-
- /**
- * Loads a memento from the given filename.
- *
- * @param filename java.lang.String
- * @return a memento
- * @exception java.io.IOException
- */
- public static IMemento loadMemento(String filename) throws IOException {
- return XMLMemento.createReadRoot(new FileReader(filename));
- }
-
- /**
- * Loads a memento from the given filename.
- *
- * @param url java.net.URL
- * @return a memento
- * @exception java.io.IOException
- */
- public static IMemento loadMemento(URL url) throws IOException {
- return XMLMemento.createReadRoot(new InputStreamReader(url.openStream()));
+ return createReadRoot(in);
}
/*
@@ -372,25 +306,9 @@
return;
element.setAttribute(key, value);
}
-
- /**
- * Save this Memento to a Writer.
- */
- public void save(Writer writer) throws IOException {
- Result result = new StreamResult(writer);
- Source source = new DOMSource(factory);
- try {
- Transformer transformer = TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
- transformer.transform(source, result);
- } catch (Exception e) {
- throw (IOException) (new IOException().initCause(e));
- }
- }
/**
- * Save this Memento to a Writer.
+ * Save this Memento to an output stream.
*/
public void save(OutputStream os) throws IOException {
Result result = new StreamResult(os);
@@ -399,44 +317,19 @@
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
transformer.transform(source, result);
} catch (Exception e) {
throw (IOException) (new IOException().initCause(e));
}
}
- /**
- * Saves the memento to the given file.
- *
- * @param filename java.lang.String
- * @exception java.io.IOException
- */
- public void saveToFile(String filename) throws IOException {
- Writer w = null;
- try {
- w = new FileWriter(filename);
- save(w);
- } catch (IOException e) {
- throw e;
- } catch (Exception e) {
- throw new IOException(e.getLocalizedMessage());
- } finally {
- if (w != null) {
- try {
- w.close();
- } catch (Exception e) {
- // ignore
- }
- }
- }
- }
-
public String saveToString() throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
save(out);
return out.toString("UTF-8");
}
-
+
/*
* @see IMemento#getBoolean(String)
*/
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ResourceManager.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ResourceManager.java
index 3961b59..7f4e68a 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ResourceManager.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ResourceManager.java
@@ -553,7 +553,7 @@
runtimes = new ArrayList();
if (xmlString != null && xmlString.length() > 0) {
try {
- ByteArrayInputStream in = new ByteArrayInputStream(xmlString.getBytes());
+ ByteArrayInputStream in = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
IMemento memento = XMLMemento.loadMemento(in);
IMemento[] children = memento.getChildren("runtime");
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/XMLMemento.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/XMLMemento.java
index e92b3de..a88d617 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/XMLMemento.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/XMLMemento.java
@@ -12,7 +12,6 @@
import java.io.*;
import java.util.*;
-import java.net.URL;
import org.w3c.dom.*;
import org.xml.sax.*;
@@ -45,7 +44,7 @@
* you should use createReadRoot and createWriteRoot to create the initial
* mementos on a document.
*/
- public XMLMemento(Document doc, Element el) {
+ private XMLMemento(Document doc, Element el) {
factory = doc;
element = el;
}
@@ -73,12 +72,12 @@
* Create a Document from a Reader and answer a root memento for reading
* a document.
*/
- protected static XMLMemento createReadRoot(Reader reader) {
+ protected static XMLMemento createReadRoot(InputStream in) {
Document document = null;
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = factory.newDocumentBuilder();
- document = parser.parse(new InputSource(reader));
+ document = parser.parse(new InputSource(in));
Node node = document.getFirstChild();
if (node instanceof Element)
return new XMLMemento(document, (Element) node);
@@ -86,7 +85,7 @@
// ignore
} finally {
try {
- reader.close();
+ in.close();
} catch (Exception e) {
// ignore
}
@@ -259,35 +258,7 @@
* @exception java.io.IOException
*/
public static IMemento loadMemento(InputStream in) {
- return createReadRoot(new InputStreamReader(in));
- }
-
- /**
- * Loads a memento from the given filename.
- *
- * @param in java.io.InputStream
- * @return org.eclipse.ui.IMemento
- * @exception java.io.IOException
- */
- public static IMemento loadCorruptMemento(InputStream in) {
- Document document = null;
- try {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder parser = factory.newDocumentBuilder();
- document = parser.parse(in);
- Node node = document.getFirstChild();
- if (node instanceof Element)
- return new XMLMemento(document, (Element) node);
- } catch (Exception e) {
- // ignore
- } finally {
- try {
- in.close();
- } catch (Exception e) {
- // ignore
- }
- }
- return null;
+ return createReadRoot(in);
}
/**
@@ -298,18 +269,7 @@
* @exception java.io.IOException
*/
public static IMemento loadMemento(String filename) throws IOException {
- return XMLMemento.createReadRoot(new FileReader(filename));
- }
-
- /**
- * Loads a memento from the given filename.
- *
- * @param url java.net.URL
- * @return org.eclipse.ui.IMemento
- * @exception java.io.IOException
- */
- public static IMemento loadMemento(URL url) throws IOException {
- return XMLMemento.createReadRoot(new InputStreamReader(url.openStream()));
+ return XMLMemento.createReadRoot(new FileInputStream(filename));
}
/*
@@ -364,34 +324,18 @@
return;
element.setAttribute(key, value);
}
-
- /**
- * Save this Memento to a Writer.
- */
- public void save(Writer writer) throws IOException {
- Result result = new StreamResult(writer);
- Source source = new DOMSource(factory);
- try {
- Transformer transformer = TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- transformer.setOutputProperty(OutputKeys.METHOD, "xml");
- transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "2");
- transformer.transform(source, result);
- } catch (Exception e) {
- throw (IOException) (new IOException().initCause(e));
- }
- }
/**
* Save this Memento to a Writer.
*/
- public void save(OutputStream os) throws IOException {
+ protected void save(OutputStream os) throws IOException {
Result result = new StreamResult(os);
Source source = new DOMSource(factory);
try {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "2");
transformer.transform(source, result);
} catch (Exception e) {
@@ -406,9 +350,9 @@
* @exception java.io.IOException
*/
public void saveToFile(String filename) throws IOException {
- Writer w = null;
+ FileOutputStream w = null;
try {
- w = new FileWriter(filename);
+ w = new FileOutputStream(filename);
save(w);
} catch (IOException e) {
throw e;