Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *  Copyright 2005 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  *  Unless required by applicable law or agreed to in writing, software
  *  distributed under the License is distributed on an "AS IS" BASIS,
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
 package org.apache.ibatis.ibator.api.dom.java;
 
 import java.util.List;

Author(s):
Jeff Butler
 
     private static FullyQualifiedJavaType intInstance = null;
     private static FullyQualifiedJavaType stringInstance = null;
     private static FullyQualifiedJavaType booleanPrimitiveInstance = null;
     private static FullyQualifiedJavaType objectInstance = null;
     private static FullyQualifiedJavaType dateInstance = null;
     private static FullyQualifiedJavaType criteriaInstance = null;
     
     private String baseShortName;
     
     //  this is the short name including the parameterized types and wildcards
     private String calculatedShortName;
     
     private String fullyQualifiedName;
     private boolean explicitlyImported;
     private String packageName;
     private boolean primitive;
     private List<FullyQualifiedJavaTypetypeArguments;
    
    
Use this constructor to construct a generic type with the specified type parameters

Parameters:
fullyQualifiedName
 
     public FullyQualifiedJavaType(String fullyQualifiedName) {
         super();
          = new ArrayList<FullyQualifiedJavaType>();
         this. = fullyQualifiedName;
         
         int lastIndex = fullyQualifiedName.lastIndexOf('.');
         if (lastIndex == -1) {
              = fullyQualifiedName;
              = false;
              = ""//$NON-NLS-1$
             
             if ("byte".equals(fullyQualifiedName)) { //$NON-NLS-1$
                  = true;
                  = PrimitiveTypeWrapper.getByteInstance();
             } else if ("short".equals(fullyQualifiedName)) { //$NON-NLS-1$
                  = true;
                  = PrimitiveTypeWrapper.getShortInstance();
             } else if ("int".equals(fullyQualifiedName)) { //$NON-NLS-1$
                  = true;
                  = PrimitiveTypeWrapper.getIntegerInstance();
             } else if ("long".equals(fullyQualifiedName)) { //$NON-NLS-1$
                  = true;
                  = PrimitiveTypeWrapper.getLongInstance();
             } else if ("char".equals(fullyQualifiedName)) { //$NON-NLS-1$
                  = true;
                  = PrimitiveTypeWrapper.getCharacterInstance();
             } else if ("float".equals(fullyQualifiedName)) { //$NON-NLS-1$
                  = true;
                  = PrimitiveTypeWrapper.getFloatInstance();
             } else if ("double".equals(fullyQualifiedName)) { //$NON-NLS-1$
                  = true;
                  = PrimitiveTypeWrapper.getDoubleInstance();
             } else if ("boolean".equals(fullyQualifiedName)) { //$NON-NLS-1$
                  = true;
                  = PrimitiveTypeWrapper.getBooleanInstance();
             } else {
                  = false;
                  = null;
             }
         } else {
              = fullyQualifiedName.substring(lastIndex + 1);
              = fullyQualifiedName.substring(0, lastIndex);
             if ("java.lang".equals()) { //$NON-NLS-1$
                  = false;
             } else {
                  = true;
             }
         }
         
          = ;
    }
    
    

Returns:
Returns the explicitlyImported.
    public boolean isExplicitlyImported() {
        return ;
    }
    
This method returns the fully qualified name that is suitable for an import statement (i.e. - without the generics specified)

Returns:
Returns the fullyQualifiedName.
    public String getFullyQualifiedName() {
        return ;
    }
    

Returns:
Returns the packageName.
    public String getPackageName() {
        return ;
    }
    

Returns:
Returns the shortName.
    public String getShortName() {
        return ;
    }
    
    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (!(obj instanceof FullyQualifiedJavaType)) {
			return false;
		}
        return .equals(other.fullyQualifiedName);
    }
    
    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    public int hashCode() {
        return .hashCode();
    }
    
    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    public String toString() {
        return ;
    }
    
    

Returns:
Returns the primitive.
    public boolean isPrimitive() {
        return ;
    }
    
    

Returns:
Returns the wrapperClass.
        return ;
    }
    
    public static final FullyQualifiedJavaType getIntInstance() {
        if ( == null) {
             = new FullyQualifiedJavaType("int"); //$NON-NLS-1$
        }
        
        return ;
    }
    public static final FullyQualifiedJavaType getNewMapInstance() {
        // always return a new instance because the type may be parameterized
        return new FullyQualifiedJavaType("java.util.Map"); //$NON-NLS-1$
    }
    public static final FullyQualifiedJavaType getNewListInstance() {
        // always return a new instance because the type may be parameterized
        return new FullyQualifiedJavaType("java.util.List"); //$NON-NLS-1$
    }
    public static final FullyQualifiedJavaType getNewHashMapInstance() {
        // always return a new instance because the type may be parameterized
        return new FullyQualifiedJavaType("java.util.HashMap"); //$NON-NLS-1$
    }
    public static final FullyQualifiedJavaType getNewArrayListInstance() {
        // always return a new instance because the type may be parameterized
        return new FullyQualifiedJavaType("java.util.ArrayList"); //$NON-NLS-1$
    }
    public static final FullyQualifiedJavaType getNewIteratorInstance() {
        // always return a new instance because the type may be parameterized
        return new FullyQualifiedJavaType("java.util.Iterator"); //$NON-NLS-1$
    }
    public static final FullyQualifiedJavaType getStringInstance() {
        if ( == null) {
             = new FullyQualifiedJavaType("java.lang.String"); //$NON-NLS-1$
        }
        
        return ;
    }
    
    public static final FullyQualifiedJavaType getBooleanPrimitiveInstance() {
        if ( == null) {
             = new FullyQualifiedJavaType("boolean"); //$NON-NLS-1$
        }
        
        return ;
    }
    
    public static final FullyQualifiedJavaType getObjectInstance() {
        if ( == null) {
             = new FullyQualifiedJavaType("java.lang.Object"); //$NON-NLS-1$
        }
        
        return ;
    }
    public static final FullyQualifiedJavaType getDateInstance() {
        if ( == null) {
             = new FullyQualifiedJavaType("java.util.Date"); //$NON-NLS-1$
        }
        
        return ;
    }
    public static final FullyQualifiedJavaType getCriteriaInstance() {
        if ( == null) {
             = new FullyQualifiedJavaType("Criteria"); //$NON-NLS-1$
        }
        
        return ;
    }
    
    /* (non-Javadoc)
     * @see java.lang.Comparable#compareTo(java.lang.Object)
     */
    public int compareTo(FullyQualifiedJavaType other) {
        return .compareTo(other.fullyQualifiedName);
    }
    
    public void addTypeArgument(FullyQualifiedJavaType type) {
        .add(type);
        
        StringBuilder sb = new StringBuilder();
        sb.append();
        sb.append('<');
        
        boolean comma = false;
        for (FullyQualifiedJavaType fqjt : ) {
            if (comma) {
                sb.append(", "); //$NON-NLS-1$
            } else {
                comma = true;
            }
            sb.append(fqjt.getShortName());
        }
        sb.append('>');
         = sb.toString();
    }
New to GrepCode? Check out our FAQ X