<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FReflection%2FIdentifier</id>
		<title>Java/Reflection/Identifier - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FReflection%2FIdentifier"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Reflection/Identifier&amp;action=history"/>
		<updated>2026-04-23T09:16:08Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Reflection/Identifier&amp;diff=6097&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Reflection/Identifier&amp;diff=6097&amp;oldid=prev"/>
				<updated>2010-06-01T06:02:08Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 06:02, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Reflection/Identifier&amp;diff=6096&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Reflection/Identifier&amp;diff=6096&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:43Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Check whether the given String is a valid identifier according to the Java Language specifications. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.UnsupportedEncodingException;&lt;br /&gt;
import java.net.MalformedURLException;&lt;br /&gt;
import java.net.URI;&lt;br /&gt;
import java.net.URISyntaxException;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import java.net.URLDecoder;&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
  * JBoss, Home of Professional Open Source&lt;br /&gt;
  * Copyright 2005, JBoss Inc., and individual contributors as indicated&lt;br /&gt;
  * by the @authors tag. See the copyright.txt in the distribution for a&lt;br /&gt;
  * full listing of individual contributors.&lt;br /&gt;
  *&lt;br /&gt;
  * This is free software; you can redistribute it and/or modify it&lt;br /&gt;
  * under the terms of the GNU Lesser General Public License as&lt;br /&gt;
  * published by the Free Software Foundation; either version 2.1 of&lt;br /&gt;
  * the License, or (at your option) any later version.&lt;br /&gt;
  *&lt;br /&gt;
  * This software is distributed in the hope that it will be useful,&lt;br /&gt;
  * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU&lt;br /&gt;
  * Lesser General Public License for more details.&lt;br /&gt;
  *&lt;br /&gt;
  * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
  * License along with this software; if not, write to the Free&lt;br /&gt;
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA&lt;br /&gt;
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.&lt;br /&gt;
  */&lt;br /&gt;
&lt;br /&gt;
public class Main{&lt;br /&gt;
  /**&lt;br /&gt;
   * Check whether the given String is a valid identifier according&lt;br /&gt;
   * to the Java Language specifications.&lt;br /&gt;
   *&lt;br /&gt;
   * See The Java Language Specification Second Edition, Section 3.8&lt;br /&gt;
   * for the definition of what is a valid identifier.&lt;br /&gt;
   *&lt;br /&gt;
   * @param s String to check&lt;br /&gt;
   *&lt;br /&gt;
   * @return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the given String is a valid Java&lt;br /&gt;
   *         identifier, &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
   */&lt;br /&gt;
  public final static boolean isValidJavaIdentifier(String s)&lt;br /&gt;
  {&lt;br /&gt;
     // an empty or null string cannot be a valid identifier&lt;br /&gt;
     if (s == null || s.length() == 0)&lt;br /&gt;
     {&lt;br /&gt;
        return false;&lt;br /&gt;
     }&lt;br /&gt;
     char[] c = s.toCharArray();&lt;br /&gt;
     if (!Character.isJavaIdentifierStart(c[0]))&lt;br /&gt;
     {&lt;br /&gt;
        return false;&lt;br /&gt;
     }&lt;br /&gt;
     for (int i = 1; i &amp;lt; c.length; i++)&lt;br /&gt;
     {&lt;br /&gt;
        if (!Character.isJavaIdentifierPart(c[i]))&lt;br /&gt;
        {&lt;br /&gt;
           return false;&lt;br /&gt;
        }&lt;br /&gt;
     }&lt;br /&gt;
     return true;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Determines if the specified string is permissible as a Java identifier. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright 2005 Joe Walker&lt;br /&gt;
 *&lt;br /&gt;
 * Licensed under the Apache License, Version 2.0 (the &amp;quot;License&amp;quot;);&lt;br /&gt;
 * you may not use this file except in compliance with the License.&lt;br /&gt;
 * You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 *     http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
 * distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
 * See the License for the specific language governing permissions and&lt;br /&gt;
 * limitations under the License.&lt;br /&gt;
 */&lt;br /&gt;
import java.io.ByteArrayInputStream;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.ObjectInputStream;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * @author Joe Walker [joe at getahead dot ltd dot uk]&lt;br /&gt;
 */&lt;br /&gt;
public class Main {&lt;br /&gt;
  /**&lt;br /&gt;
   * Determines if the specified string is permissible as a Java identifier.&lt;br /&gt;
   * Returns true if the string is non-null, non-zero length with a Java&lt;br /&gt;
   * identifier start as the first character and Java identifier parts in all&lt;br /&gt;
   * remaining characters.&lt;br /&gt;
   * @param test the string to be tested.&lt;br /&gt;
   * @return true if the string is a Java identifier, false otherwise.&lt;br /&gt;
   * @see java.lang.Character#isJavaIdentifierPart(char)&lt;br /&gt;
   * @see java.lang.Character#isJavaIdentifierStart(char)&lt;br /&gt;
   */&lt;br /&gt;
  public static boolean isJavaIdentifier(String test)&lt;br /&gt;
  {&lt;br /&gt;
      if (test == null || test.length() == 0)&lt;br /&gt;
      {&lt;br /&gt;
          return false;&lt;br /&gt;
      }&lt;br /&gt;
      if (!Character.isJavaIdentifierStart(test.charAt(0)) &amp;amp;&amp;amp; test.charAt(0) != &amp;quot;_&amp;quot;)&lt;br /&gt;
      {&lt;br /&gt;
          return false;&lt;br /&gt;
      }&lt;br /&gt;
      for (int i = 1; i &amp;lt; test.length(); i++)&lt;br /&gt;
      {&lt;br /&gt;
          if (!Character.isJavaIdentifierPart(test.charAt(i)) &amp;amp;&amp;amp; test.charAt(i) != &amp;quot;_&amp;quot;)&lt;br /&gt;
          {&lt;br /&gt;
              return false;&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
      return true;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Determine whether the supplied string represents a well-formed fully-qualified Java classname. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * JBoss DNA (http://www.jboss.org/dna)&lt;br /&gt;
 * See the COPYRIGHT.txt file distributed with this work for information&lt;br /&gt;
 * regarding copyright ownership.  Some portions may be licensed&lt;br /&gt;
 * to Red Hat, Inc. under one or more contributor license agreements.&lt;br /&gt;
 * See the AUTHORS.txt file in the distribution for a full listing of &lt;br /&gt;
 * individual contributors. &lt;br /&gt;
 *&lt;br /&gt;
 * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA&lt;br /&gt;
 * is licensed to you under the terms of the GNU Lesser General Public License as&lt;br /&gt;
 * published by the Free Software Foundation; either version 2.1 of&lt;br /&gt;
 * the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * JBoss DNA is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU&lt;br /&gt;
 * Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this software; if not, write to the Free&lt;br /&gt;
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA&lt;br /&gt;
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.&lt;br /&gt;
 */&lt;br /&gt;
import java.text.CharacterIterator;&lt;br /&gt;
import java.text.StringCharacterIterator;&lt;br /&gt;
&lt;br /&gt;
public class Utils {&lt;br /&gt;
  /**&lt;br /&gt;
   * Determine whether the supplied string represents a well-formed fully-qualified Java classname. This utility method enforces&lt;br /&gt;
   * no conventions (e.g., packages are all lowercase) nor checks whether the class is available on the classpath.&lt;br /&gt;
   * &lt;br /&gt;
   * @param classname&lt;br /&gt;
   * @return true if the string is a fully-qualified class name&lt;br /&gt;
   */&lt;br /&gt;
  public static boolean isFullyQualifiedClassname( String classname ) {&lt;br /&gt;
      if (classname == null) return false;&lt;br /&gt;
      String[] parts = classname.split(&amp;quot;[\\.]&amp;quot;);&lt;br /&gt;
      if (parts.length == 0) return false;&lt;br /&gt;
      for (String part : parts) {&lt;br /&gt;
          CharacterIterator iter = new StringCharacterIterator(part);&lt;br /&gt;
          // Check first character (there should at least be one character for each part) ...&lt;br /&gt;
          char c = iter.first();&lt;br /&gt;
          if (c == CharacterIterator.DONE) return false;&lt;br /&gt;
          if (!Character.isJavaIdentifierStart(c) &amp;amp;&amp;amp; !Character.isIdentifierIgnorable(c)) return false;&lt;br /&gt;
          c = iter.next();&lt;br /&gt;
          // Check the remaining characters, if there are any ...&lt;br /&gt;
          while (c != CharacterIterator.DONE) {&lt;br /&gt;
              if (!Character.isJavaIdentifierPart(c) &amp;amp;&amp;amp; !Character.isIdentifierIgnorable(c)) return false;&lt;br /&gt;
              c = iter.next();&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
      return true;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Escape Java Literal ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
/*&lt;br /&gt;
 * Static String formatting and query routines.&lt;br /&gt;
 * Copyright (C) 2001-2005 Stephen Ostermiller&lt;br /&gt;
 * http://ostermiller.org/contact.pl?regarding=Java+Utilities&lt;br /&gt;
 *&lt;br /&gt;
 * This program is free software; you can redistribute it and/or modify&lt;br /&gt;
 * it under the terms of the GNU General Public License as published by&lt;br /&gt;
 * the Free Software Foundation; either version 2 of the License, or&lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This program is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
 * GNU General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * See COPYING.TXT for details.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.util.HashMap;&lt;br /&gt;
import java.util.regex.Pattern;&lt;br /&gt;
/**&lt;br /&gt;
 * Utilities for String formatting, manipulation, and queries.&lt;br /&gt;
 * More information about this class is available from .&lt;br /&gt;
 *&lt;br /&gt;
 * @author Stephen Ostermiller http://ostermiller.org/contact.pl?regarding=Java+Utilities&lt;br /&gt;
 * @since ostermillerutils 1.00.00&lt;br /&gt;
 */&lt;br /&gt;
public class StringHelper {&lt;br /&gt;
  /**&lt;br /&gt;
   * Replaces characters that are not allowed in a Java style&lt;br /&gt;
   * string literal with their escape characters.  Specifically&lt;br /&gt;
   * quote (&amp;quot;), single quote (&amp;quot;), new line (\n), carriage return (\r),&lt;br /&gt;
   * and backslash (\), and tab (\t) are escaped.&lt;br /&gt;
   *&lt;br /&gt;
   * @param s String to be escaped&lt;br /&gt;
   * @return escaped String&lt;br /&gt;
   * @throws NullPointerException if s is null.&lt;br /&gt;
   *&lt;br /&gt;
   * @since ostermillerutils 1.00.00&lt;br /&gt;
   */&lt;br /&gt;
  public static String escapeJavaLiteral(String s){&lt;br /&gt;
    int length = s.length();&lt;br /&gt;
    int newLength = length;&lt;br /&gt;
    // first check for characters that might&lt;br /&gt;
    // be dangerous and calculate a length&lt;br /&gt;
    // of the string that has escapes.&lt;br /&gt;
    for (int i=0; i&amp;lt;length; i++){&lt;br /&gt;
      char c = s.charAt(i);&lt;br /&gt;
      switch(c){&lt;br /&gt;
        case &amp;quot;\&amp;quot;&amp;quot;:&lt;br /&gt;
        case &amp;quot;\&amp;quot;&amp;quot;:&lt;br /&gt;
        case &amp;quot;\n&amp;quot;:&lt;br /&gt;
        case &amp;quot;\r&amp;quot;:&lt;br /&gt;
        case &amp;quot;\t&amp;quot;:&lt;br /&gt;
        case &amp;quot;\\&amp;quot;:{&lt;br /&gt;
          newLength += 1;&lt;br /&gt;
        } break;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    if (length == newLength){&lt;br /&gt;
      // nothing to escape in the string&lt;br /&gt;
      return s;&lt;br /&gt;
    }&lt;br /&gt;
    StringBuffer sb = new StringBuffer(newLength);&lt;br /&gt;
    for (int i=0; i&amp;lt;length; i++){&lt;br /&gt;
      char c = s.charAt(i);&lt;br /&gt;
      switch(c){&lt;br /&gt;
        case &amp;quot;\&amp;quot;&amp;quot;:{&lt;br /&gt;
          sb.append(&amp;quot;\\\&amp;quot;&amp;quot;);&lt;br /&gt;
        } break;&lt;br /&gt;
        case &amp;quot;\&amp;quot;&amp;quot;:{&lt;br /&gt;
          sb.append(&amp;quot;\\\&amp;quot;&amp;quot;);&lt;br /&gt;
        } break;&lt;br /&gt;
        case &amp;quot;\n&amp;quot;:{&lt;br /&gt;
          sb.append(&amp;quot;\\n&amp;quot;);&lt;br /&gt;
        } break;&lt;br /&gt;
        case &amp;quot;\r&amp;quot;:{&lt;br /&gt;
          sb.append(&amp;quot;\\r&amp;quot;);&lt;br /&gt;
        } break;&lt;br /&gt;
        case &amp;quot;\t&amp;quot;:{&lt;br /&gt;
          sb.append(&amp;quot;\\t&amp;quot;);&lt;br /&gt;
        } break;&lt;br /&gt;
        case &amp;quot;\\&amp;quot;:{&lt;br /&gt;
          sb.append(&amp;quot;\\\\&amp;quot;);&lt;br /&gt;
        } break;&lt;br /&gt;
        default: {&lt;br /&gt;
          sb.append(c);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return sb.toString();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Is Java Identifier and get Java Identifier ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
/*&lt;br /&gt;
    GNU LESSER GENERAL PUBLIC LICENSE&lt;br /&gt;
    Copyright (C) 2006 The Lobo Project&lt;br /&gt;
    This library is free software; you can redistribute it and/or&lt;br /&gt;
    modify it under the terms of the GNU Lesser General Public&lt;br /&gt;
    License as published by the Free Software Foundation; either&lt;br /&gt;
    version 2.1 of the License, or (at your option) any later version.&lt;br /&gt;
    This library is distributed in the hope that it will be useful,&lt;br /&gt;
    but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&lt;br /&gt;
    Lesser General Public License for more details.&lt;br /&gt;
    You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
    License along with this library; if not, write to the Free Software&lt;br /&gt;
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA&lt;br /&gt;
    Contact info: lobochief@users.sourceforge.net&lt;br /&gt;
*/&lt;br /&gt;
import java.io.UnsupportedEncodingException;&lt;br /&gt;
import java.security.MessageDigest;&lt;br /&gt;
import java.security.NoSuchAlgorithmException;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
public class Strings&lt;br /&gt;
{&lt;br /&gt;
  private static final MessageDigest MESSAGE_DIGEST;&lt;br /&gt;
  public static final String[] EMPTY_ARRAY = new String[0];&lt;br /&gt;
  static {&lt;br /&gt;
      MessageDigest md;&lt;br /&gt;
      try {&lt;br /&gt;
          md = MessageDigest.getInstance(&amp;quot;MD5&amp;quot;);&lt;br /&gt;
      } catch(NoSuchAlgorithmException err) {&lt;br /&gt;
        throw new IllegalStateException();&lt;br /&gt;
      }&lt;br /&gt;
      MESSAGE_DIGEST = md;&lt;br /&gt;
  }&lt;br /&gt;
  public static boolean isBlank(String text) {&lt;br /&gt;
      return text == null || &amp;quot;&amp;quot;.equals(text);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  public static int countLines(String text) &lt;br /&gt;
  {&lt;br /&gt;
    int startIdx = 0;&lt;br /&gt;
    int lineCount = 1;&lt;br /&gt;
    for(;;) &lt;br /&gt;
    {&lt;br /&gt;
      int lbIdx = text.indexOf(&amp;quot;\n&amp;quot;, startIdx);&lt;br /&gt;
      if(lbIdx == -1) &lt;br /&gt;
      {&lt;br /&gt;
        break;&lt;br /&gt;
      }&lt;br /&gt;
      lineCount++;&lt;br /&gt;
      startIdx = lbIdx + 1;&lt;br /&gt;
    }&lt;br /&gt;
    return lineCount;&lt;br /&gt;
  }&lt;br /&gt;
  public static boolean isJavaIdentifier(String id) &lt;br /&gt;
  {&lt;br /&gt;
    if(id == null) &lt;br /&gt;
    {&lt;br /&gt;
      return false;&lt;br /&gt;
    }&lt;br /&gt;
    int len = id.length();&lt;br /&gt;
    if(len == 0) &lt;br /&gt;
    {&lt;br /&gt;
      return false;&lt;br /&gt;
    }&lt;br /&gt;
    if(!Character.isJavaIdentifierStart(id.charAt(0))) &lt;br /&gt;
    {&lt;br /&gt;
      return false;&lt;br /&gt;
    }&lt;br /&gt;
    for(int i = 1; i &amp;lt; len; i++) &lt;br /&gt;
    {&lt;br /&gt;
      if(!Character.isJavaIdentifierPart(id.charAt(i))) &lt;br /&gt;
      {&lt;br /&gt;
        return false;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return true;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  public static String getJavaStringLiteral(String text) {&lt;br /&gt;
      StringBuffer buf = new StringBuffer();&lt;br /&gt;
      buf.append(&amp;quot;&amp;quot;&amp;quot;);&lt;br /&gt;
      int len = text.length();&lt;br /&gt;
      for(int i = 0; i &amp;lt; len; i++) {&lt;br /&gt;
          char ch = text.charAt(i);&lt;br /&gt;
          switch(ch) {&lt;br /&gt;
          case &amp;quot;\\&amp;quot;:&lt;br /&gt;
              buf.append(&amp;quot;\\\\&amp;quot;);&lt;br /&gt;
              break;&lt;br /&gt;
          case &amp;quot;\n&amp;quot;:&lt;br /&gt;
              buf.append(&amp;quot;\\n&amp;quot;);&lt;br /&gt;
              break;&lt;br /&gt;
          case &amp;quot;\r&amp;quot;:&lt;br /&gt;
              buf.append(&amp;quot;\\r&amp;quot;);&lt;br /&gt;
              break;&lt;br /&gt;
          case &amp;quot;\t&amp;quot;:&lt;br /&gt;
              buf.append(&amp;quot;\\t&amp;quot;);&lt;br /&gt;
              break;&lt;br /&gt;
          case &amp;quot;&amp;quot;&amp;quot;:&lt;br /&gt;
              buf.append(&amp;quot;\\\&amp;quot;&amp;quot;);&lt;br /&gt;
              break;&lt;br /&gt;
          default:&lt;br /&gt;
              buf.append(ch);&lt;br /&gt;
            break;&lt;br /&gt;
          }&lt;br /&gt;
      }&lt;br /&gt;
      buf.append(&amp;quot;&amp;quot;&amp;quot;);&lt;br /&gt;
      return buf.toString();&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  public static String getJavaIdentifier(String candidateID) {&lt;br /&gt;
    int len = candidateID.length();&lt;br /&gt;
    StringBuffer buf = new StringBuffer();&lt;br /&gt;
    for(int i = 0; i &amp;lt; len; i++) &lt;br /&gt;
    {&lt;br /&gt;
        char ch = candidateID.charAt(i);&lt;br /&gt;
      boolean good = i == 0 ? Character.isJavaIdentifierStart(ch) : Character.isJavaIdentifierPart(ch);&lt;br /&gt;
      if(good) &lt;br /&gt;
      {&lt;br /&gt;
          buf.append(ch);&lt;br /&gt;
      }&lt;br /&gt;
      else {&lt;br /&gt;
          buf.append(&amp;quot;_&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return buf.toString();      &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== To Identifier String ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright 2000,2005 wingS development team.&lt;br /&gt;
 *&lt;br /&gt;
 * This file is part of wingS (http://wingsframework.org).&lt;br /&gt;
 *&lt;br /&gt;
 * wingS is free software; you can redistribute it and/or modify&lt;br /&gt;
 * it under the terms of the GNU Lesser General Public License&lt;br /&gt;
 * as published by the Free Software Foundation; either version 2.1&lt;br /&gt;
 * of the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * Please see COPYING for the complete licence.&lt;br /&gt;
 */&lt;br /&gt;
import java.util.StringTokenizer;&lt;br /&gt;
/**&lt;br /&gt;
 * Some string manipulation utilities.&lt;br /&gt;
 *&lt;br /&gt;
 * @author &lt;br /&gt;
 */&lt;br /&gt;
public class StringUtil {&lt;br /&gt;
  private final static char[] ALPHAS = {&lt;br /&gt;
      &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;,&lt;br /&gt;
      &amp;quot;c&amp;quot;, &amp;quot;d&amp;quot;, &amp;quot;e&amp;quot;, &amp;quot;f&amp;quot;, &amp;quot;g&amp;quot;, &amp;quot;h&amp;quot;,&lt;br /&gt;
      &amp;quot;i&amp;quot;, &amp;quot;j&amp;quot;, &amp;quot;k&amp;quot;, &amp;quot;l&amp;quot;, &amp;quot;m&amp;quot;, &amp;quot;n&amp;quot;,&lt;br /&gt;
      &amp;quot;o&amp;quot;, &amp;quot;p&amp;quot;, &amp;quot;q&amp;quot;, &amp;quot;r&amp;quot;, &amp;quot;s&amp;quot;, &amp;quot;t&amp;quot;,&lt;br /&gt;
      &amp;quot;u&amp;quot;, &amp;quot;v&amp;quot;, &amp;quot;w&amp;quot;, &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot;,&lt;br /&gt;
  };&lt;br /&gt;
  /**&lt;br /&gt;
   * All possible digits for representing a number as a String&lt;br /&gt;
   * This is conservative and does not include &amp;quot;special&amp;quot;&lt;br /&gt;
   * characters since some browsers don&amp;quot;t handle them right.&lt;br /&gt;
   * The IE for instance seems to be case insensitive in class&lt;br /&gt;
   * names for CSSs. Grrr.&lt;br /&gt;
   */&lt;br /&gt;
  private final static char[] DIGITS = {&lt;br /&gt;
      &amp;quot;0&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;3&amp;quot;, &amp;quot;4&amp;quot;, &amp;quot;5&amp;quot;,&lt;br /&gt;
      &amp;quot;6&amp;quot;, &amp;quot;7&amp;quot;, &amp;quot;8&amp;quot;, &amp;quot;9&amp;quot;, &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;,&lt;br /&gt;
      &amp;quot;c&amp;quot;, &amp;quot;d&amp;quot;, &amp;quot;e&amp;quot;, &amp;quot;f&amp;quot;, &amp;quot;g&amp;quot;, &amp;quot;h&amp;quot;,&lt;br /&gt;
      &amp;quot;i&amp;quot;, &amp;quot;j&amp;quot;, &amp;quot;k&amp;quot;, &amp;quot;l&amp;quot;, &amp;quot;m&amp;quot;, &amp;quot;n&amp;quot;,&lt;br /&gt;
      &amp;quot;o&amp;quot;, &amp;quot;p&amp;quot;, &amp;quot;q&amp;quot;, &amp;quot;r&amp;quot;, &amp;quot;s&amp;quot;, &amp;quot;t&amp;quot;,&lt;br /&gt;
      &amp;quot;u&amp;quot;, &amp;quot;v&amp;quot;, &amp;quot;w&amp;quot;, &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, &amp;quot;z&amp;quot;,&lt;br /&gt;
      /* This %@&amp;amp;!-IE is case insensitive for certain&lt;br /&gt;
       * URLs and IDs&lt;br /&gt;
       * &amp;quot;A&amp;quot; , &amp;quot;B&amp;quot; ,&lt;br /&gt;
       * &amp;quot;C&amp;quot; , &amp;quot;D&amp;quot; , &amp;quot;E&amp;quot; , &amp;quot;F&amp;quot; , &amp;quot;G&amp;quot; , &amp;quot;H&amp;quot; ,&lt;br /&gt;
       * &amp;quot;I&amp;quot; , &amp;quot;J&amp;quot; , &amp;quot;K&amp;quot; , &amp;quot;L&amp;quot; , &amp;quot;M&amp;quot; , &amp;quot;N&amp;quot; ,&lt;br /&gt;
       * &amp;quot;O&amp;quot; , &amp;quot;P&amp;quot; , &amp;quot;Q&amp;quot; , &amp;quot;R&amp;quot; , &amp;quot;S&amp;quot; , &amp;quot;T&amp;quot; ,&lt;br /&gt;
       * &amp;quot;U&amp;quot; , &amp;quot;V&amp;quot; , &amp;quot;W&amp;quot; , &amp;quot;X&amp;quot; , &amp;quot;Y&amp;quot; , &amp;quot;Z&amp;quot;&lt;br /&gt;
       */&lt;br /&gt;
  };&lt;br /&gt;
  public static final int MAX_RADIX = DIGITS.length;&lt;br /&gt;
  /**&lt;br /&gt;
   * creates a shortest possible string representation of the given&lt;br /&gt;
   * long number that qualifies as an identifier in common programming&lt;br /&gt;
   * languages (and HTML-id&amp;quot;s :-)&lt;br /&gt;
   * That is, it must start with a letter.&lt;br /&gt;
   *&lt;br /&gt;
   * @param val the long value to be encoded&lt;br /&gt;
   * @return a string represantation of the given value that qualifies&lt;br /&gt;
   *         as an identifier.&lt;br /&gt;
   */&lt;br /&gt;
  public static String toIdentifierString(long val) {&lt;br /&gt;
      char buf[] = new char[14];&lt;br /&gt;
      int i = 0;&lt;br /&gt;
      if (val &amp;lt; 0) {&lt;br /&gt;
          buf[i++] = &amp;quot;_&amp;quot;;&lt;br /&gt;
          val = -(val + 1);&lt;br /&gt;
      }&lt;br /&gt;
      buf[i++] = ALPHAS[(int) (val % ALPHAS.length)];&lt;br /&gt;
      val /= ALPHAS.length;&lt;br /&gt;
      while (val != 0 &amp;amp;&amp;amp; i &amp;lt; buf.length) {&lt;br /&gt;
          buf[i++] = DIGITS[(int) (val % DIGITS.length)];&lt;br /&gt;
          val /= DIGITS.length;&lt;br /&gt;
      }&lt;br /&gt;
      return new String(buf, 0, i);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>