X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.application%2Fsrc%2Forg%2Fsimantics%2Fapplication%2Farguments%2FApplicationUtils.java;h=217e4b24f9db5902c8821133b745e55877f7a127;hb=1f6e700b53b8be20d7048aaeb3621be1dcd9ffd8;hp=43460fd420807dff33c5fa7f1a42c025b0a7bc33;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git
diff --git a/bundles/org.simantics.application/src/org/simantics/application/arguments/ApplicationUtils.java b/bundles/org.simantics.application/src/org/simantics/application/arguments/ApplicationUtils.java
index 43460fd42..217e4b24f 100644
--- a/bundles/org.simantics.application/src/org/simantics/application/arguments/ApplicationUtils.java
+++ b/bundles/org.simantics.application/src/org/simantics/application/arguments/ApplicationUtils.java
@@ -1,153 +1,153 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management
- * in Industry THTH ry.
- * 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:
- * VTT Technical Research Centre of Finland - initial API and implementation
- *******************************************************************************/
-package org.simantics.application.arguments;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.simantics.application.internal.Activator;
-
-/**
- * Simple utilities for IApplication implementation.
- */
-public class ApplicationUtils {
-
- /**
- * Appends properties from the specified URL to system properties which are
- * available through {@link System#getProperties()}.
- *
- * @param props a valid URL or null
for no operation.
- */
- public static void loadSystemProperties(URL props) {
- if (props != null) {
- InputStream in = null;
- try {
- in = props.openStream();
- System.getProperties().load(in);
- } catch (IOException e) {
- Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Failed to load system properties: " + props, e));
- } finally {
- try {
- if (in != null)
- in.close();
- } catch (IOException e) {
- Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Failed to close system properties: " + props, e));
- }
- }
- }
- }
-
- /**
- * Decodes a dot ('.') -separated path into the path elements. The '\'
- * character is used for escaping dots themselves.
- *
- *
Examples of the results:
- *
- * String encoded with this method can be decoded with
- * {@link #decodePath(String)}.
- *
- * @param namePath a path of names
- * @return the path encoded into a single string
- */
- public static String encodePath(String[] namePath) {
- StringBuilder b = new StringBuilder();
- boolean first = true;
- for (String s : namePath) {
- if (!first)
- b.append('.');
- first = false;
- b.append(s.replace(".", "\\."));
- }
- return b.toString();
- }
-
- /**
- * Parse the arguments received by the application (available through
- * {@link Platform#getApplicationArgs()}) for instances of the specified
- * arguments. Found matches are contained in the resulting IArguments
- * instance.
- *
- * @param accepted the arguments that should be parsed
- * @return the argument matches that were found
- */
- public static IArguments parseApplicationArguments(IArgumentFactory>... accepted) {
- return Arguments.parse(Platform.getApplicationArgs(), accepted);
- }
-
-// public static void main(String[] args) {
-// System.out.println(Arrays.toString(decodePath("abc")));
-// System.out.println(Arrays.toString(decodePath("abc.def.efg")));
-// System.out.println(Arrays.toString(decodePath("abc\\..def\\..ghi.jkl")));
-// System.out.println(Arrays.toString(decodePath("abc\\..def\\..ghi.jkl\\.")));
-// System.out.println(Arrays.toString(decodePath("abc\\..def\\..ghi.jkl\\..")));
-// System.out.println(Arrays.toString(decodePath("abc\\..def.ghi\\.jkl")));
-// System.out.println(Arrays.toString(decodePath("abc\\..def.ghi\\.jkl.")));
-// System.out.println(Arrays.toString(decodePath("abc\\..def.ghi\\.jkl\\..")));
-// }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * 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:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.application.arguments;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.simantics.application.internal.Activator;
+
+/**
+ * Simple utilities for IApplication implementation.
+ */
+public class ApplicationUtils {
+
+ /**
+ * Appends properties from the specified URL to system properties which are
+ * available through {@link System#getProperties()}.
+ *
+ * @param props a valid URL or null
for no operation.
+ */
+ public static void loadSystemProperties(URL props) {
+ if (props != null) {
+ InputStream in = null;
+ try {
+ in = props.openStream();
+ System.getProperties().load(in);
+ } catch (IOException e) {
+ Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Failed to load system properties: " + props, e));
+ } finally {
+ try {
+ if (in != null)
+ in.close();
+ } catch (IOException e) {
+ Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Failed to close system properties: " + props, e));
+ }
+ }
+ }
+ }
+
+ /**
+ * Decodes a dot ('.') -separated path into the path elements. The '\'
+ * character is used for escaping dots themselves.
+ *
+ *
Examples of the results:
+ *+ * String encoded with this method can be decoded with + * {@link #decodePath(String)}. + * + * @param namePath a path of names + * @return the path encoded into a single string + */ + public static String encodePath(String[] namePath) { + StringBuilder b = new StringBuilder(); + boolean first = true; + for (String s : namePath) { + if (!first) + b.append('.'); + first = false; + b.append(s.replace(".", "\\.")); + } + return b.toString(); + } + + /** + * Parse the arguments received by the application (available through + * {@link Platform#getApplicationArgs()}) for instances of the specified + * arguments. Found matches are contained in the resulting IArguments + * instance. + * + * @param accepted the arguments that should be parsed + * @return the argument matches that were found + */ + public static IArguments parseApplicationArguments(IArgumentFactory>... accepted) { + return Arguments.parse(Platform.getApplicationArgs(), accepted); + } + +// public static void main(String[] args) { +// System.out.println(Arrays.toString(decodePath("abc"))); +// System.out.println(Arrays.toString(decodePath("abc.def.efg"))); +// System.out.println(Arrays.toString(decodePath("abc\\..def\\..ghi.jkl"))); +// System.out.println(Arrays.toString(decodePath("abc\\..def\\..ghi.jkl\\."))); +// System.out.println(Arrays.toString(decodePath("abc\\..def\\..ghi.jkl\\.."))); +// System.out.println(Arrays.toString(decodePath("abc\\..def.ghi\\.jkl"))); +// System.out.println(Arrays.toString(decodePath("abc\\..def.ghi\\.jkl."))); +// System.out.println(Arrays.toString(decodePath("abc\\..def.ghi\\.jkl\\.."))); +// } + +}