diff options
author | Mazen Faraj | 2005-11-28 03:51:41 +0000 |
---|---|---|
committer | Mazen Faraj | 2005-11-28 03:51:41 +0000 |
commit | 706e525b8e37001625b5f2c2847cabc907bcbed9 (patch) | |
tree | 2472ae54098adc82c82c7002a65987d92de45e89 | |
parent | bf6812771b88137366f8f40045b3b64c1a87beb9 (diff) | |
download | eclipse.platform.ua-706e525b8e37001625b5f2c2847cabc907bcbed9.tar.gz eclipse.platform.ua-706e525b8e37001625b5f2c2847cabc907bcbed9.tar.xz eclipse.platform.ua-706e525b8e37001625b5f2c2847cabc907bcbed9.zip |
*** empty log message ***
4 files changed, 28 insertions, 46 deletions
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/util/URLCoder.java b/org.eclipse.help/src/org/eclipse/help/internal/util/URLCoder.java index d978443b9..70bfd9d5c 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/util/URLCoder.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/util/URLCoder.java @@ -1,17 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 +/*************************************************************************************************** + * Copyright (c) 2000, 2004 IBM Corporation and others. All rights reserved. This program and the + * accompanying materials are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ + * Contributors: IBM Corporation - initial API and implementation + **************************************************************************************************/ package org.eclipse.help.internal.util; -import java.io.*; + +import java.io.ByteArrayOutputStream; +import java.io.UnsupportedEncodingException; public class URLCoder { + public static String encode(String s) { try { return urlEncode(s.getBytes("UTF8")); //$NON-NLS-1$ @@ -19,6 +20,7 @@ public class URLCoder { return null; } } + public static String decode(String s) { try { return new String(urlDecode(s), "UTF8"); //$NON-NLS-1$ @@ -26,6 +28,7 @@ public class URLCoder { return null; } } + private static String urlEncode(byte[] data) { StringBuffer buf = new StringBuffer(data.length); for (int i = 0; i < data.length; i++) { @@ -35,25 +38,25 @@ public class URLCoder { } return buf.toString(); } + private static byte[] urlDecode(String encodedURL) { int len = encodedURL.length(); ByteArrayOutputStream os = new ByteArrayOutputStream(len); for (int i = 0; i < len;) { switch (encodedURL.charAt(i)) { - case '%' : - if (len >= i + 3) { - os.write(Integer.parseInt(encodedURL.substring(i + 1, - i + 3), 16)); - } - i += 3; - break; - case '+' : //exception from standard - os.write(' '); - i++; - break; - default : - os.write(encodedURL.charAt(i++)); - break; + case '%': + if (len >= i + 3) { + os.write(Integer.parseInt(encodedURL.substring(i + 1, i + 3), 16)); + } + i += 3; + break; + case '+': // exception from standard + os.write(' '); + i++; + break; + default: + os.write(encodedURL.charAt(i++)); + break; } } diff --git a/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentFilterProcessor.java b/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentFilterProcessor.java index 809b7c535..23b3d0793 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentFilterProcessor.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentFilterProcessor.java @@ -25,7 +25,6 @@ public class UAContentFilterProcessor { Element body = DOMUtil.getBodyElement(dom); NodeList allChildElements = body.getChildNodes(); for (int i = 0; i < allChildElements.getLength(); i++) { - // not all nodes are Elements. Node node = (Node) allChildElements.item(i); if (!(node instanceof Element)) continue; @@ -40,13 +39,11 @@ public class UAContentFilterProcessor { boolean filteredIn = false; filteredIn = processFilterAttribute(element); if (!filteredIn) - // element failed filter, and is filtered out. return; } NodeList allChildElements = element.getChildNodes(); for (int i = 0; i < allChildElements.getLength(); i++) { - // not all nodes are Elements. Node node = (Node) allChildElements.item(i); if (!(node instanceof Element)) continue; @@ -56,7 +53,6 @@ public class UAContentFilterProcessor { } private static boolean hasFilterAttribute(Element element) { - // getAttribute returns an empty string if att is not defined. if (element.getAttribute(DOMUtil.ATT_FILTER).equals("")) return false; return true; diff --git a/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentParser.java b/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentParser.java index d86e0b48e..954bf0be6 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentParser.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentParser.java @@ -123,12 +123,7 @@ public class UAContentParser { } - /** - * General parser method that can accept both String and InputStream for parsing. - * - * @param fileObject - * @return - */ + private Document doParse(Object fileObject) { Document document = null; try { diff --git a/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UATransformManager.java b/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UATransformManager.java index 76f421793..fc98314c5 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UATransformManager.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UATransformManager.java @@ -43,41 +43,32 @@ public class UATransformManager { DocumentType docType = document.getDoctype(); if (docType != null) { String value = docType.getSystemId(); - // transformer.clearParameters(); transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, value); value = document.getDoctype().getPublicId(); transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, value); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$ - // transformer.setOutputProperty(OutputKeys.MEDIA_TYPE, - // "text/html"); - // transformer - // .setOutputProperty(OutputKeys.ENCODING, "iso-8859-1"); + } else ; return transformer; } catch (TransformerConfigurationException tce) { - // Error generated by the parser HelpPlugin.logError("Transformer Config error: " + tce.getMessage(), null); //$NON-NLS-1$ - // Use the contained exception, if any + Throwable x = tce; if (tce.getException() != null) x = tce.getException(); HelpPlugin.logError("Transformer Stack trace: ", x); //$NON-NLS-1$ - System.out.println(x); } return null; } public static String convertToString(Document document) { try { - // identity xslt. Transformer transformer = createTransformer(document); - DOMSource source = new DOMSource(document); - StringWriter stringBuffer = new StringWriter(); StreamResult result = new StreamResult(stringBuffer); @@ -85,14 +76,11 @@ public class UATransformManager { return stringBuffer.toString(); } catch (TransformerException te) { - // Error generated by the parser HelpPlugin.logError("Transformer error: " + te.getMessage(), te); //$NON-NLS-1$ - // Use the contained exception, if any Throwable x = te; if (te.getException() != null) x = te.getException(); HelpPlugin.logError("Transformer Stack trace: ", x); //$NON-NLS-1$ - System.out.println(x); } return null; |