import org.xml.sax.SAXException;
/**
- * <code>TemplateSet</code> manages a collection of templates and makes them
+ * <code>ObfuscatorIgnoreSet</code> manages a collection of templates and makes them
* persistent.
*/
public class TemplateSet {
private static void throwReadException(Throwable t) throws CoreException {
PHPeclipsePlugin.log(t);
// IStatus status= new JavaUIStatus(JavaStatusConstants.TEMPLATE_IO_EXCEPTION,
-// TemplateMessages.getString("TemplateSet.error.read"), t); //$NON-NLS-1$
+// ObfuscatorMessages.getString("TemplateSet.error.read"), t); //$NON-NLS-1$
// throw new JavaUIException(status);
}
private static void throwWriteException(Throwable t) throws CoreException {
PHPeclipsePlugin.log(t);
// IStatus status= new JavaUIStatus(JavaStatusConstants.TEMPLATE_IO_EXCEPTION,
-// TemplateMessages.getString("TemplateSet.error.write"), t); //$NON-NLS-1$
+// ObfuscatorMessages.getString("TemplateSet.error.write"), t); //$NON-NLS-1$
// throw new JavaUIException(status);
}
import org.eclipse.jface.dialogs.ErrorDialog;
/**
- * <code>Templates</code> gives access to the available templates.
+ * <code>ObfuscatorIgnores</code> gives access to the available templates.
*/
public class Templates extends TemplateSet {
fPatternViewer = createViewer(parent);
// fFormatButton= new Button(parent, SWT.CHECK);
- // fFormatButton.setText(TemplateMessages.getString("TemplatePreferencePage.use.code.formatter")); //$NON-NLS-1$
+ // fFormatButton.setText(ObfuscatorMessages.getString("TemplatePreferencePage.use.code.formatter")); //$NON-NLS-1$
// GridData gd1= new GridData();
// gd1.horizontalSpan= 2;
// fFormatButton.setLayoutData(gd1);
*/
public String getDisplayString() {
return fTemplate + TemplateMessages.getString("TemplateProposal.delimiter") + fTemplate; // $NON-NLS-1$ //$NON-NLS-1$
- // return fTemplate.getName() + TemplateMessages.getString("TemplateProposal.delimiter") + fTemplate.getDescription(); // $NON-NLS-1$ //$NON-NLS-1$
+ // return fTemplate.getName() + ObfuscatorMessages.getString("TemplateProposal.delimiter") + fTemplate.getDescription(); // $NON-NLS-1$ //$NON-NLS-1$
}
/*
private void handleException(CoreException e) {
Shell shell = fViewer.getTextWidget().getShell();
PHPeclipsePlugin.log(e);
- // ExceptionHandler.handle(e, shell, TemplateMessages.getString("TemplateEvaluator.error.title"), null); //$NON-NLS-1$
+ // ExceptionHandler.handle(e, shell, ObfuscatorMessages.getString("TemplateEvaluator.error.title"), null); //$NON-NLS-1$
}
/*
*/
public String getDisplayString() {
return fTemplate + TemplateMessages.getString("TemplateProposal.delimiter") + fTemplate; // $NON-NLS-1$ //$NON-NLS-1$
- // return fTemplate.getName() + TemplateMessages.getString("TemplateProposal.delimiter") + fTemplate.getDescription(); // $NON-NLS-1$ //$NON-NLS-1$
+ // return fTemplate.getName() + ObfuscatorMessages.getString("TemplateProposal.delimiter") + fTemplate.getDescription(); // $NON-NLS-1$ //$NON-NLS-1$
}
/*
private void handleException(CoreException e) {
Shell shell = fViewer.getTextWidget().getShell();
PHPeclipsePlugin.log(e);
- // ExceptionHandler.handle(e, shell, TemplateMessages.getString("TemplateEvaluator.error.title"), null); //$NON-NLS-1$
+ // ExceptionHandler.handle(e, shell, ObfuscatorMessages.getString("TemplateEvaluator.error.title"), null); //$NON-NLS-1$
}
/*
private void handleException(CoreException e) {
Shell shell= fViewer.getTextWidget().getShell();
PHPeclipsePlugin.log(e);
-// ExceptionHandler.handle(e, shell, TemplateMessages.getString("TemplateEvaluator.error.title"), null); //$NON-NLS-1$
+// ExceptionHandler.handle(e, shell, ObfuscatorMessages.getString("TemplateEvaluator.error.title"), null); //$NON-NLS-1$
}
/*
import net.sourceforge.phpeclipse.mover.DirectoryWalker;
import net.sourceforge.phpeclipse.mover.IFilter;
import net.sourceforge.phpeclipse.mover.IMover;
+import net.sourceforge.phpeclipse.mover.obfuscator.ObfuscatorIgnores;
import net.sourceforge.phpeclipse.mover.obfuscator.PHPAnalyzer;
-import net.sourceforge.phpeclipse.mover.obfuscator.PHPIdentifier;
import net.sourceforge.phpeclipse.mover.obfuscator.PHPObfuscatorMover;
-import net.sourceforge.phpeclipse.preferences.IObfuscatorPreferences;
+import net.sourceforge.phpeclipse.preferences.ProjectProperties;
import net.sourceforge.phpeclipse.views.PHPConsole;
import org.eclipse.core.resources.IFile;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
+/**
+ *
+ * @author khartlage
+ *
+ * Run the PHP Obfuscator
+ */
public class PHPObfuscatorAction implements IObjectActionDelegate {
- private static String[] PREDEFINED_PHP_VARIABLES =
- {
- "$this",
- "$AUTH_TYPE",
- "$CONTENT_LENGTH",
- "$CONTENT_TYPE",
- "$GATEWAY_INTERFACE",
- "$GLOBALS",
- "$HTTP_ACCEPT",
- "$HTTP_COOKIE",
- "$HTTP_COOKIE_VARS",
- "$HTTP_POST_VARS",
- "$HTTP_REFERER",
- "$HTTP_USER_AGENT",
- "$PATH_INFO",
- "$PATH_TRANSLATED",
- "$PHP_AUTH_PW",
- "$PHP_AUTH_USER",
- "$PHP_ERRORMSG",
- "$PHP_SELF",
- "$QUERY_STRING",
- "$REMOTE_ADDR",
- "$REMOTE_HOST",
- "$REMOTE_IDENT",
- "$REMOTE_USER",
- "$REQUEST_METHOD",
- "$SCRIPT_NAME",
- "$SERVER_NAME",
- "$SERVER_PORT",
- "$SERVER_PROTOCOL",
- "$SERVER_SOFTWARE"
- };
+
private IWorkbenchPart workbenchPart;
/**
- * Constructor for Action1.
+ * Constructor for PHPObfuscatorAction.
*/
public PHPObfuscatorAction() {
super();
}
- /**
- * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
- */
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- workbenchPart = targetPart;
- }
-
public void run(IAction action) {
ISelectionProvider selectionProvider = null;
selectionProvider = workbenchPart.getSite().getSelectionProvider();
selection = (StructuredSelection) selectionProvider.getSelection();
PHPConsole console = PHPConsole.getInstance();
- IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
+ // HashMap identifierMap = new HashMap(8096);
+ // for (int i=0;i<PREDEFINED_PHP_VARIABLES.length;i++) {
+ // identifierMap.put(PREDEFINED_PHP_VARIABLES[i], new PHPIdentifier(PREDEFINED_PHP_VARIABLES[i],PHPIdentifier.VARIABLE) );
+ // }
+ HashMap identifierMap = null;
Shell shell = null;
Iterator iterator = null;
// is it a resource
if (obj instanceof IResource) {
+
IResource resource = (IResource) obj;
IProject proj = resource.getProject();
String sourcePath;
- // String publishPath = "c:\\temp";
+
+ if (identifierMap == null) {
+ IPreferenceStore store =
+ PHPeclipsePlugin.getDefault().getPreferenceStore();
+ ObfuscatorIgnores ignore = new ObfuscatorIgnores(proj);
+ identifierMap = ignore.getIdentifierMap();
+ }
+
String publishPath;
try {
- publishPath = proj.getPersistentProperty(IObfuscatorPreferences.PUBLISH_PROPERTY_NAME);
- } catch (CoreException e) {
+ ProjectProperties properties = new ProjectProperties(proj);
+ publishPath = properties.getPublish();
+ } catch (CoreException e1) {
return;
+ // e1.printStackTrace();
}
- HashMap identifierMap = new HashMap(8096);
- for (int i=0;i<PREDEFINED_PHP_VARIABLES.length;i++) {
- identifierMap.put(PREDEFINED_PHP_VARIABLES[i], new PHPIdentifier(PREDEFINED_PHP_VARIABLES[i],PHPIdentifier.VARIABLE) );
- }
- DefaultFilter[] filter = {
- IFilter.PHP_FILTER,
- IFilter.DEFAULT_FILTER,
- };
+ // try {
+ // publishPath = proj.getPersistentProperty(IObfuscatorPreferences.PUBLISH_PROPERTY_NAME);
+ // } catch (CoreException e) {
+ // return;
+ // }
+
+ DefaultFilter[] filter =
+ { IFilter.PHP_FILTER, IFilter.DEFAULT_FILTER, };
IMover[] mover =
{
- new PHPAnalyzer(PHPConsole.getInstance(), new Scanner(false, false), identifierMap),
- new PHPObfuscatorMover(PHPConsole.getInstance(), new Scanner(true, true), identifierMap)};
+ new PHPAnalyzer(
+ PHPConsole.getInstance(),
+ new Scanner(false, false),
+ identifierMap),
+ new PHPObfuscatorMover(
+ PHPConsole.getInstance(),
+ new Scanner(true, true),
+ identifierMap)};
DirectoryWalker walker = new DirectoryWalker(mover, filter);
switch (resource.getType()) {
case IResource.PROJECT :
public void selectionChanged(IAction action, ISelection selection) {
}
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ workbenchPart = targetPart;
+ }
+
}
* @author khartlage
*
* To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
+ * Window>Preferences>Java>ObfuscatorIgnores.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
--- /dev/null
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+package net.sourceforge.phpeclipse.mover.obfuscator;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.apache.xml.serialize.OutputFormat;
+import org.apache.xml.serialize.Serializer;
+import org.apache.xml.serialize.SerializerFactory;
+import org.eclipse.core.runtime.CoreException;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * <code>ObfuscatorIgnoreSet</code> manages a collection of templates and makes them
+ * persistent.
+ */
+public class ObfuscatorIgnoreSet {
+
+ // private static class TemplateComparator implements Comparator {
+ // public int compare(Object arg0, Object arg1) {
+ // if (arg0 == arg1)
+ // return 0;
+ //
+ // if (arg0 == null)
+ // return -1;
+ //
+ // Template template0= (Template) arg0;
+ // Template template1= (Template) arg1;
+ //
+ // return template0.getName().compareTo(template1.getName());
+ // }
+ // }
+
+ private static final String TEMPLATE_TAG = "ignore"; //$NON-NLS-1$
+ // private static final String NAME_ATTRIBUTE= "name"; //$NON-NLS-1$
+ // private static final String DESCRIPTION_ATTRIBUTE= "description"; //$NON-NLS-1$
+ // private static final String CONTEXT_ATTRIBUTE= "context"; //$NON-NLS-1$
+ // private static final String ENABLED_ATTRIBUTE= "enabled"; //$NON-NLS-1$
+
+ // private List fTemplates= new ArrayList();
+ private HashMap fIdentifierMap = new HashMap();
+ // private Comparator fTemplateComparator= new TemplateComparator();
+ // private Template[] fSortedTemplates= new Template[0];
+
+ /**
+ * Convenience method for reading templates from a file.
+ *
+ * @see #addFromStream(InputStream)
+ */
+ public void addFromFile(File file) throws CoreException {
+ InputStream stream = null;
+
+ try {
+ stream = new FileInputStream(file);
+ addFromStream(stream);
+
+ } catch (IOException e) {
+ throwReadException(e);
+
+ } finally {
+ try {
+ if (stream != null)
+ stream.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+
+ /**
+ * Reads templates from a XML stream and adds them to the template set.
+ */
+ public void addFromStream(InputStream stream) throws CoreException {
+ try {
+ DocumentBuilderFactory factory =
+ DocumentBuilderFactory.newInstance();
+ DocumentBuilder parser = factory.newDocumentBuilder();
+ Document document = parser.parse(new InputSource(stream));
+ NodeList elements = document.getElementsByTagName(TEMPLATE_TAG);
+
+ int count = elements.getLength();
+ for (int i = 0; i != count; i++) {
+ Node node = elements.item(i);
+ NamedNodeMap attributes = node.getAttributes();
+
+ if (attributes == null)
+ continue;
+
+ // String name= getAttributeValue(attributes, NAME_ATTRIBUTE);
+ // String description= getAttributeValue(attributes, DESCRIPTION_ATTRIBUTE);
+ // String context= getAttributeValue(attributes, CONTEXT_ATTRIBUTE);
+ // Node enabledNode= attributes.getNamedItem(ENABLED_ATTRIBUTE);
+
+ // if (name == null || description == null || context == null)
+ // throw new SAXException(ObfuscatorMessages.getString("TemplateSet.error.missing.attribute")); //$NON-NLS-1$
+
+ // boolean enabled= true; //(enabledNode == null) || (enabledNode.getNodeValue().equals("true")); //$NON-NLS-1$
+
+ StringBuffer buffer = new StringBuffer();
+ NodeList children = node.getChildNodes();
+ for (int j = 0; j != children.getLength(); j++) {
+ String value = children.item(j).getNodeValue();
+ if (value != null)
+ buffer.append(value);
+ }
+ String pattern = buffer.toString().trim();
+ fIdentifierMap.put(pattern, new PHPIdentifier(pattern, PHPIdentifier.VARIABLE) );
+ // Template template= new Template(name, description, context, pattern);
+ // template.setEnabled(enabled);
+ // add(template);
+ }
+
+ // sort();
+
+ } catch (ParserConfigurationException e) {
+ throwReadException(e);
+ } catch (IOException e) {
+ throwReadException(e);
+ } catch (SAXException e) {
+ throwReadException(e);
+ }
+ }
+
+ private String getAttributeValue(NamedNodeMap attributes, String name) {
+ Node node = attributes.getNamedItem(name);
+
+ return node == null ? null : node.getNodeValue();
+ }
+
+ /**
+ * Convenience method for saving to a file.
+ *
+ * @see #saveToStream(OutputStream)
+ */
+ public void saveToFile(File file) throws CoreException {
+ OutputStream stream = null;
+
+ try {
+ stream = new FileOutputStream(file);
+ saveToStream(stream);
+
+ } catch (IOException e) {
+ throwWriteException(e);
+
+ } finally {
+ try {
+ if (stream != null)
+ stream.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+
+ /**
+ * Saves the template set as XML.
+ */
+ public void saveToStream(OutputStream stream) throws CoreException {
+ try {
+ DocumentBuilderFactory factory =
+ DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document document = builder.newDocument();
+
+ Node root = document.createElement("obfuscator"); // $NON-NLS-1$ //$NON-NLS-1$
+ document.appendChild(root);
+ Iterator iter = fIdentifierMap.keySet().iterator();
+ while (iter.hasNext()) {
+ // for (int i= 0; i != fTemplates.size(); i++) {
+ // Template template= (Template) fTemplates.get(i);
+
+ Node node = document.createElement("ignore"); // $NON-NLS-1$ //$NON-NLS-1$
+ root.appendChild(node);
+
+ // NamedNodeMap attributes= node.getAttributes();
+ //
+ // Attr name= document.createAttribute(NAME_ATTRIBUTE);
+ // name.setValue(template.getName());
+ // attributes.setNamedItem(name);
+ //
+ // Attr description= document.createAttribute(DESCRIPTION_ATTRIBUTE);
+ // description.setValue(template.getDescription());
+ // attributes.setNamedItem(description);
+ //
+ // Attr context= document.createAttribute(CONTEXT_ATTRIBUTE);
+ // context.setValue(template.getContextTypeName());
+ // attributes.setNamedItem(context);
+ //
+ // Attr enabled= document.createAttribute(ENABLED_ATTRIBUTE);
+ // enabled.setValue(template.isEnabled() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
+ // attributes.setNamedItem(enabled);
+
+ Text pattern = document.createTextNode((String) iter.next());
+ node.appendChild(pattern);
+ }
+
+ OutputFormat format = new OutputFormat();
+ format.setPreserveSpace(true);
+ Serializer serializer = SerializerFactory.getSerializerFactory("xml").makeSerializer(stream, format); //$NON-NLS-1$
+ serializer.asDOMSerializer().serialize(document);
+
+ } catch (ParserConfigurationException e) {
+ throwWriteException(e);
+ } catch (IOException e) {
+ throwWriteException(e);
+ }
+ }
+
+ private static void throwReadException(Throwable t) throws CoreException {
+ PHPeclipsePlugin.log(t);
+ // IStatus status= new JavaUIStatus(JavaStatusConstants.TEMPLATE_IO_EXCEPTION,
+ // ObfuscatorMessages.getString("TemplateSet.error.read"), t); //$NON-NLS-1$
+ // throw new JavaUIException(status);
+ }
+
+ private static void throwWriteException(Throwable t) throws CoreException {
+ PHPeclipsePlugin.log(t);
+ // IStatus status= new JavaUIStatus(JavaStatusConstants.TEMPLATE_IO_EXCEPTION,
+ // ObfuscatorMessages.getString("TemplateSet.error.write"), t); //$NON-NLS-1$
+ // throw new JavaUIException(status);
+ }
+
+ /**
+ * Adds a template to the set.
+ */
+ // public void add(Template template) {
+ // if (exists(template))
+ // return; // ignore duplicate
+ //
+ // fTemplates.add(template);
+ // sort();
+ // }
+
+ // private boolean exists(Template template) {
+ // for (Iterator iterator = fTemplates.iterator(); iterator.hasNext();) {
+ // Template anotherTemplate = (Template) iterator.next();
+ //
+ // if (template.equals(anotherTemplate))
+ // return true;
+ // }
+ //
+ // return false;
+ // }
+ //
+ // /**
+ // * Removes a template to the set.
+ // */
+ // public void remove(Template template) {
+ // fTemplates.remove(template);
+ // sort();
+ // }
+ //
+ /**
+ * Empties the set.
+ */
+ public void clear() {
+ fIdentifierMap.clear();
+ // fTemplates.clear();
+ // sort();
+ }
+ //
+ // /**
+ // * Returns all templates.
+ // */
+ // public Template[] getTemplates() {
+ // return (Template[]) fTemplates.toArray(new Template[fTemplates.size()]);
+ // }
+
+ /**
+ * Returns all templates with a given name.
+ */
+ // public Template[] getTemplates(String name) {
+ // ArrayList res= new ArrayList();
+ // for (Iterator iterator= fTemplates.iterator(); iterator.hasNext();) {
+ // Template curr= (Template) iterator.next();
+ // if (curr.getName().equals(name)) {
+ // res.add(curr);
+ // }
+ // }
+ // return (Template[]) res.toArray(new Template[res.size()]);
+ // }
+ //
+ // private void sort() {
+ // fSortedTemplates= (Template[]) fTemplates.toArray(new Template[fTemplates.size()]);
+ // Arrays.sort(fSortedTemplates, fTemplateComparator);
+ // }
+
+ /**
+ * @return
+ */
+ public HashMap getIdentifierMap() {
+ return fIdentifierMap;
+ }
+
+}
--- /dev/null
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+package net.sourceforge.phpeclipse.mover.obfuscator;
+
+import java.io.File;
+import java.io.InputStream;
+
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.dialogs.ErrorDialog;
+
+/**
+ * <code>ObfuscatorIgnores</code> gives access to the available templates.
+ */
+public class ObfuscatorIgnores extends ObfuscatorIgnoreSet {
+
+ private static final String DEFAULT_FILE = "default-obfuscator.xml"; //$NON-NLS-1$
+ private static final String TEMPLATE_FILE = "obfuscator.xml"; //$NON-NLS-1$
+
+ /** Singleton. */
+ private static ObfuscatorIgnores fgIgnores;
+ private IProject fProject;
+
+ public ObfuscatorIgnores(IProject project) {
+ fProject = project;
+ try {
+ File templateFile = getTemplateFile();
+ if (templateFile.exists()) {
+ addFromFile(templateFile);
+ } else {
+ addFromStream(getDefaultsAsStream());
+ saveToFile(templateFile);
+ }
+
+ } catch (CoreException e) {
+ PHPeclipsePlugin.log(e);
+ ErrorDialog.openError(null, ObfuscatorMessages.getString("Templates.error.title"), //$NON-NLS-1$
+ e.getMessage(), e.getStatus());
+
+ clear();
+ }
+ }
+ /**
+ * Returns an instance of templates.
+ */
+// public static ObfuscatorIgnores getInstance() {
+// if (fgIgnores == null)
+// fgIgnores = create();
+//
+// return fgIgnores;
+// }
+//
+// private static ObfuscatorIgnores create() {
+// ObfuscatorIgnores templates = new ObfuscatorIgnores();
+//
+// try {
+// File templateFile = getTemplateFile();
+// if (templateFile.exists()) {
+// templates.addFromFile(templateFile);
+// } else {
+// templates.addFromStream(getDefaultsAsStream());
+// templates.saveToFile(templateFile);
+// }
+//
+// } catch (CoreException e) {
+// PHPeclipsePlugin.log(e);
+// ErrorDialog.openError(null, ObfuscatorMessages.getString("Templates.error.title"), //$NON-NLS-1$
+// e.getMessage(), e.getStatus());
+//
+// templates.clear();
+// }
+//
+// return templates;
+// }
+
+ /**
+ * Resets the template set.
+ */
+ public void reset() throws CoreException {
+ clear();
+ addFromFile(getTemplateFile());
+ }
+
+ /**
+ * Resets the template set with the default templates.
+ */
+ public void restoreDefaults() throws CoreException {
+ clear();
+ addFromStream(getDefaultsAsStream());
+ }
+
+ /**
+ * Saves the template set.
+ */
+ public void save() throws CoreException {
+ saveToFile(getTemplateFile());
+ }
+
+ private InputStream getDefaultsAsStream() {
+ return ObfuscatorIgnores.class.getResourceAsStream(DEFAULT_FILE);
+ }
+
+ private File getTemplateFile() {
+ IPath path = fProject.getLocation();
+ // PHPeclipsePlugin.getDefault().getStateLocation();
+ path = path.append(TEMPLATE_FILE);
+
+ return path.toFile();
+ }
+}
--- /dev/null
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+package net.sourceforge.phpeclipse.mover.obfuscator;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class ObfuscatorMessages {
+
+ private static final String RESOURCE_BUNDLE= ObfuscatorMessages.class.getName();
+ private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
+
+ private ObfuscatorMessages() {
+ }
+
+ public static String getString(String key) {
+ try {
+ return fgResourceBundle.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+
+ /**
+ * Gets a string from the resource bundle and formats it with the argument
+ *
+ * @param key the string used to get the bundle value, must not be null
+ */
+ public static String getFormattedString(String key, Object arg) {
+ return MessageFormat.format(getString(key), new Object[] { arg });
+ }
+
+
+ /**
+ * Gets a string from the resource bundle and formats it with arguments
+ */
+ public static String getFormattedString(String key, Object[] args) {
+ return MessageFormat.format(getString(key), args);
+ }
+}
--- /dev/null
+#########################################
+# (c) Copyright IBM Corp. 2000, 2001.
+# All Rights Reserved.
+#########################################
+
+# preference page
+TemplatePreferencePage.error.import=Failed to import templates.
+TemplatePreferencePage.error.export=Failed to export templates.
+TemplatePreferencePage.error.read.title=Reading Templates
+TemplatePreferencePage.error.write.title=Reading Templates
+TemplatePreferencePage.message=&Create, edit or remove templates:
+TemplatePreferencePage.title=Templates
+
+TemplatePreferencePage.new=&New...
+TemplatePreferencePage.edit=&Edit...
+TemplatePreferencePage.import=&Import...
+TemplatePreferencePage.export=E&xport...
+TemplatePreferencePage.export.all=Ex&port All...
+TemplatePreferencePage.remove=&Remove
+TemplatePreferencePage.enable.all=Ena&ble All
+TemplatePreferencePage.disable.all=Di&sable All
+TemplatePreferencePage.editor=Template
+
+TemplatePreferencePage.column.name=Name
+TemplatePreferencePage.column.context=Context
+TemplatePreferencePage.column.description=Description
+
+TemplatePreferencePage.use.code.formatter=Use Code &Formatter
+
+TemplatePreferencePage.import.title=Importing Templates
+TemplatePreferencePage.import.extension=*.xml
+
+TemplatePreferencePage.export.title=Exporting {0} Templates
+TemplatePreferencePage.export.filename=templates.xml
+TemplatePreferencePage.export.extension=*.xml
+
+TemplatePreferencePage.export.exists.title=Exporting Templates
+TemplatePreferencePage.export.exists.message={0} already exists.\nDo you want to replace it?
+
+TemplatePreferencePage.question.create.new.title=Edit Template
+TemplatePreferencePage.question.create.new.message=The name of the template was changed.\nDo you want to create a new template?
+
+TemplatePreferencePage.preview=Preview:
+
+# edit template dialog
+EditTemplateDialog.error.noname=Template name must not be empty.
+EditTemplateDialog.error.adjacent.variables=Template pattern has adjacent variables.
+EditTemplateDialog.title.new=New Template
+EditTemplateDialog.title.edit=Edit Template
+
+EditTemplateDialog.name=&Name:
+EditTemplateDialog.description=&Description:
+EditTemplateDialog.context=&Context:
+EditTemplateDialog.pattern=&Pattern:
+EditTemplateDialog.insert.variable=Insert &Variable...
+
+EditTemplateDialog.undo=&Undo@Ctrl+Z
+EditTemplateDialog.cut=Cu&t@Ctrl+X
+EditTemplateDialog.copy=&Copy@Ctrl+C
+EditTemplateDialog.paste=&Paste@Ctrl+V
+EditTemplateDialog.select.all=Select &All@Ctrl+A
+EditTemplateDialog.content.assist=Insert &Variable...@Ctrl+Space
+
+# template variable dialog
+TemplateVariableDialog.title=Select a template variable.
+TemplateVariableDialog.column.name=Name
+TemplateVariableDialog.column.description=Description
+TemplateVariableDialog.insert=&Insert
+
+TemplateVariableProposal.error.title=Error applying template variable proposal
+TemplateVariableProcessor.error.title=Error creating template variable proposals
+
+# template set
+TemplateSet.error.read=Error occurred while reading templates.
+TemplateSet.error.write=Error occurred while writing templates.
+
+# templates
+Templates.error.title=Error accessing templates.
+Templates.error.read=Error occurred while reading templates.
+Templates.error.write=Error occurred while writing templates.
+
+# template engine
+TemplateEngine.error.title=Could not create template proposals.
+
+# template proposal
+TemplateProposal.delimiter=\ -
+
+# template evaluator
+TemplateEvaluator.error.title=Template Evaluation Error
+
+# template translator
+TemplateTranslator.error.incomplete.variable=Template has incomplete variables.
+TemplateTranslator.error.invalid.identifier=Template has invalid variable identifiers.
+TemplateSet.error.missing.attribute=Missing required attribute
* @author khartlage
*
* To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
+ * Window>Preferences>Java>ObfuscatorIgnores.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
+//import java.security.MessageDigest;
+//import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;
private Scanner fScanner;
private int fToken;
- private MessageDigest fAlgorithm;
+ // private MessageDigest fAlgorithm;
private int fCounter;
protected HashMap fIdentifierMap;
this.fScanner = scanner;
this.fIdentifierMap = identifierMap;
this.fCounter = 0;
- try {
- this.fAlgorithm = MessageDigest.getInstance("MD5");
- } catch (NoSuchAlgorithmException e) {
- System.out.println(e.toString());
- }
+// try {
+// this.fAlgorithm = MessageDigest.getInstance("MD5");
+// } catch (NoSuchAlgorithmException e) {
+// System.out.println(e.toString());
+// }
}
/**
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<obfuscator>
+ <ignore>$this</ignore>
+ <ignore>$_SERVER</ignore>
+ <ignore>$AUTH_TYPE</ignore>
+ <ignore>$CONTENT_LENGTH</ignore>
+ <ignore>$CONTENT_TYPE</ignore>
+ <ignore>$GATEWAY_INTERFACE</ignore>
+ <ignore>$GLOBALS</ignore>
+ <ignore>$HTTP_ACCEPT</ignore>
+ <ignore>$HTTP_COOKIE</ignore>
+ <ignore>$HTTP_COOKIE_VARS</ignore>
+ <ignore>$HTTP_POST_VARS</ignore>
+ <ignore>$HTTP_REFERER</ignore>
+ <ignore>$HTTP_USER_AGENT</ignore>
+ <ignore>$PATH_INFO</ignore>
+ <ignore>$PATH_TRANSLATED</ignore>
+ <ignore>$PHP_AUTH_PW</ignore>
+ <ignore>$PHP_AUTH_USER</ignore>
+ <ignore>$PHP_ERRORMSG</ignore>
+ <ignore>$PHP_SELF</ignore>
+ <ignore>$QUERY_STRING</ignore>
+ <ignore>$REMOTE_ADDR</ignore>
+ <ignore>$REMOTE_HOST</ignore>
+ <ignore>$REMOTE_IDENT</ignore>
+ <ignore>$REMOTE_USER</ignore>
+ <ignore>$REQUEST_METHOD</ignore>
+ <ignore>$SCRIPT_NAME</ignore>
+ <ignore>$SERVER_NAME</ignore>
+ <ignore>$SERVER_PORT</ignore>
+ <ignore>$SERVER_PROTOCOL</ignore>
+ <ignore>$SERVER_SOFTWARE</ignore>
+</obfuscator>
\ No newline at end of file
private static void throwReadException(Throwable t) throws CoreException {
PHPeclipsePlugin.log(t);
// IStatus status= new JavaUIStatus(JavaStatusConstants.TEMPLATE_IO_EXCEPTION,
- // TemplateMessages.getString("TemplateSet.error.read"), t); //$NON-NLS-1$
+ // ObfuscatorMessages.getString("TemplateSet.error.read"), t); //$NON-NLS-1$
// throw new JavaUIException(status);
}
private static void throwWriteException(Throwable t) throws CoreException {
PHPeclipsePlugin.log(t);
// IStatus status= new JavaUIStatus(JavaStatusConstants.TEMPLATE_IO_EXCEPTION,
- // TemplateMessages.getString("TemplateSet.error.write"), t); //$NON-NLS-1$
+ // ObfuscatorMessages.getString("TemplateSet.error.write"), t); //$NON-NLS-1$
// throw new JavaUIException(status);
}
* @author chrisl
*
* To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
+ * Window>Preferences>Java>ObfuscatorIgnores.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
* @author Choochter
*
* To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
+ * Window>Preferences>Java>ObfuscatorIgnores.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
* @author Choochter
*
* To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
+ * Window>Preferences>Java>ObfuscatorIgnores.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
* @author Choochter
*
* To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
+ * Window>Preferences>Java>ObfuscatorIgnores.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
* @author Choochter
*
* To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
+ * Window>Preferences>Java>ObfuscatorIgnores.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/