Class StringUtils


  • public class StringUtils
    extends java.lang.Object
    Deals with strings (probably need to elaborate some more).
    Author:
    Matthew J. Duftler, Christopher Mindus
    • Constructor Summary

      Constructors 
      Constructor Description
      StringUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String cleanString​(java.lang.String str)  
      static java.lang.String getClassName​(java.lang.Class targetClass)
      This method will return the correct name for a class object representing a primitive, a single instance of a class, as well as n-dimensional arrays of primitives or instances.
      static java.io.InputStream getContentAsInputStream​(java.net.URL url)
      Returns an InputStream for reading from the specified resource, if the resource points to a stream.
      static java.lang.String getNMTokens​(java.util.List<java.lang.String> list)  
      static java.net.URL getURL​(java.net.URL contextURL, java.lang.String spec)
      Effectively a document base.
      static java.util.List<java.lang.String> parseNMTokens​(java.lang.String nmTokens)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • lineSeparator

        public static final java.lang.String lineSeparator
      • lineSeparatorStr

        public static final java.lang.String lineSeparatorStr
    • Constructor Detail

      • StringUtils

        public StringUtils()
    • Method Detail

      • cleanString

        public static java.lang.String cleanString​(java.lang.String str)
      • getClassName

        public static java.lang.String getClassName​(java.lang.Class targetClass)
        This method will return the correct name for a class object representing a primitive, a single instance of a class, as well as n-dimensional arrays of primitives or instances. This logic is needed to handle the string returned from Class.getName(). If the class object represents a single instance (or a primitive), Class.getName() returns the fully-qualified name of the class and no further work is needed. However, if the class object represents an array (of n dimensions), Class.getName() returns a Descriptor (the Descriptor grammar is defined in section 4.3 of the Java VM Spec). This method will parse the Descriptor if necessary.
        Parameters:
        targetClass - The class.
        Returns:
        A parsed class name.
      • getURL

        public static java.net.URL getURL​(java.net.URL contextURL,
                                          java.lang.String spec)
                                   throws java.net.MalformedURLException
        Effectively a document base.
        Parameters:
        contextURL - the context in which to attempt to resolve the spec.
        Returns:
        The URL.
        Throws:
        java.net.MalformedURLException
      • getContentAsInputStream

        public static java.io.InputStream getContentAsInputStream​(java.net.URL url)
                                                           throws java.lang.SecurityException,
                                                                  java.lang.IllegalArgumentException,
                                                                  java.io.IOException
        Returns an InputStream for reading from the specified resource, if the resource points to a stream.
        Parameters:
        url - The URL.
        Returns:
        The opened InputStream instance if there were any contents.
        Throws:
        java.lang.IllegalArgumentException - If there is no contents.
        java.lang.SecurityException
        java.io.IOException
      • parseNMTokens

        public static java.util.List<java.lang.String> parseNMTokens​(java.lang.String nmTokens)
      • getNMTokens

        public static java.lang.String getNMTokens​(java.util.List<java.lang.String> list)