Author: timotei
Date: Tue Jul 26 17:36:15 2011
New Revision: 50440

URL: http://svn.gna.org/viewcvs/wesnoth?rev=50440&view=rev
Log:
eclipse plugin: Trim the quotes when adding a new primitive

Modified:
    trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/schema/SchemaParser.java
    trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/StringUtils.java

Modified: 
trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/schema/SchemaParser.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/schema/SchemaParser.java?rev=50440&r1=50439&r2=50440&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/schema/SchemaParser.java 
(original)
+++ trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/schema/SchemaParser.java 
Tue Jul 26 17:36:15 2011
@@ -192,7 +192,9 @@
                                                                "Error. invalid 
primitive on line :" + index); //$NON-NLS-1$
                                                continue;
                                        }
-                                       primitives_.put(tokens[0].trim(), 
tokens[1].trim());
+
+                                       primitives_.put(tokens[0].trim(),
+                                               StringUtils.trimQuotes( 
tokens[1].trim( ) ) );
                                }
                                else if (tagStack.peek().equals("description")) 
//$NON-NLS-1$
                                {

Modified: trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/StringUtils.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/StringUtils.java?rev=50440&r1=50439&r2=50440&view=diff
==============================================================================
--- trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/StringUtils.java 
(original)
+++ trunk/utils/umc_dev/org.wesnoth/src/org/wesnoth/utils/StringUtils.java Tue 
Jul 26 17:36:15 2011
@@ -144,9 +144,9 @@
         * @param string The string to trim
         * @return A new string that doesn't have any trailling separators
         */
-       public static String trimPathSeparators(String string)
-       {
-               if (string == null || string.isEmpty())
+       public static String trimEndPathSeparators(String string)
+       {
+               if ( isNullOrEmpty( string ) )
                        return ""; //$NON-NLS-1$
 
                while (string.charAt(string.length() - 1) == '/' ||
@@ -156,6 +156,28 @@
        }
 
        /**
+        * Trims any quotes " of the specified string
+        * @param string The string to trim
+        * @return A new string with the quotes trimmed
+        */
+       public static String trimQuotes( String string )
+       {
+           if ( isNullOrEmpty( string ) )
+               return "";
+
+           while ( string.charAt( 0 ) == '"' )
+               string = string.substring( 1 );
+
+           int strSize = string.length( ) - 1;
+           while ( strSize >= 0 && string.charAt( strSize ) == '"' ){
+               string = string.substring( 0, strSize );
+               -- strSize;
+           }
+
+           return string;
+       }
+
+       /**
         * Normalizez the path given by the string, removing repeated separators
         * and replacing them by '|'
         *
@@ -167,7 +189,7 @@
                if (path == null)
                        return ""; //$NON-NLS-1$
 
-               String str = StringUtils.trimPathSeparators(path);
+               String str = StringUtils.trimEndPathSeparators(path);
                StringBuilder sb = new StringBuilder(str.length());
 
                // normalize strings - remove repeating separators and replace 
them by |


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to