Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (c) 2011 Miyakawa Taku
   *
   * Permission is hereby granted, free of charge, to any person obtaining a copy
   * of this software and associated documentation files (the "Software"), to deal
   * in the Software without restriction, including without limitation the rights
   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   * copies of the Software, and to permit persons to whom the Software is
   * furnished to do so, subject to the following conditions:
  *
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
 
 package org.bitbucket.miyakawa_taku.hadoop_job_builder.internal;
 
 
 import  org.apache.hadoop.fs.Path;

Common methods.
 
 public final class Commons {


    
Returns an array of paths which represents the paths specified by pathNames.

Parameters:
pathNames Path names.
Returns:
Paths representing pathNames.
 
     public static Path[] pathsFromPathnamesString[] pathNames ) {
         Path[] paths = new Path[ pathNames.length ];
         for ( int index = 0 ; index < pathNames.length ; ++ index ) {
             pathsindex ] = new Path( pathNamesindex ] );
         }
         return paths;
     }


    
Returns the class which is top of the given stack trace, excluding exclude.

Parameters:
traces Stack trace elements on which this method search the class.
exclude The class specified by this parameter is ignored.
Returns:
The class on the top of the stack trace, except for exclude.
Throws:
IllegalStateException If no class is found.
 
     public static Class< ? > classOnTopOfStack(
             StackTraceElement[] traces , Class< ? > exclude ) {
         for ( StackTraceElement trace : traces ) {
             String className = trace.getClassName();
             if ( className != null && ! className.equalsexclude.getName() ) ) {
                 return Commons.findClassclassName );
             }
         }
         throw new IllegalStateException"Cannot find the calling class" );
     }


    
Finds the class associated with the given className.

If the class is not found, IllegalStateException is thrown.

 
     static Class< ? > findClassString className ) {
         try {
             return Class.forNameclassName );
         } catch ( ClassNotFoundException exception ) {
             throw new IllegalStateException"Cannot find " + className , exception );
         }
     }


    
Checks that type, which is referred from referer, is a class.

Parameters:
type Type to check.
description Description of type.
referer Class that refers to type.
Throws:
IllegalStateException If type is not a class.
    public static void checkClassType type , String description , Class< ? > referer ) {
        if ( ! ( type instanceof Class ) ) {
            throw new IllegalStateException(
                    "Cannot resolve " + description + " class from " + referer.getName() );
        }
    }


    
Returns true iff type is a parameterized type of superType.

Parameters:
type Type to test.
superType Supertype to test.
Returns:
true iff type is a parameterized type of superType.
    public static boolean isParameterizedTypeOfType type , Class< ? > superType ) {
        return type instanceof ParameterizedType
            && ( (ParameterizedTypetype ).getRawType().equalssuperType );
    }
// vim: et sw=4 sts=4
New to GrepCode? Check out our FAQ X