/** * Hook method to create new variables. Subclasses may override to supply their custom variable * type. * <p> * Clients may replace this method. * </p> * * @param type the type of the new variable. * @param name the name of the new variable. * @param offsets the offsets where the variable occurs in the template * @return a new instance of <code>TemplateVariable</code> * @deprecated as of 3.3 use {@link #createVariable(TemplateVariableType, String, int[])} instead */ @Deprecated protected TemplateVariable createVariable(String type, String name, int[] offsets) { return createVariable(fCurrentType, name, offsets); }
/** * Hook method to create new variables. Subclasses may override to supply their custom variable * type. * <p> * Clients may replace this method. * </p> * * @param type the type of the new variable. * @param name the name of the new variable. * @param offsets the offsets where the variable occurs in the template * @return a new instance of <code>TemplateVariable</code> * @deprecated as of 3.3 use {@link #createVariable(TemplateVariableType, String, int[])} instead */ @Deprecated protected TemplateVariable createVariable(String type, String name, int[] offsets) { return createVariable(fCurrentType, name, offsets); }
/** * Creates proper {@link TemplateVariable}s from the variable descriptions. * * @param variables the variable descriptions by variable name * @return the corresponding variables * @since 3.3 */ private TemplateVariable[] createVariables(Map<String, VariableDescription> variables) { TemplateVariable[] result= new TemplateVariable[variables.size()]; int idx= 0; for (Iterator<VariableDescription> it= variables.values().iterator(); it.hasNext(); idx++) { VariableDescription desc= it.next(); TemplateVariableType type= desc.fType == null ? new TemplateVariableType(desc.fName) : desc.fType; int[] offsets= new int[desc.fOffsets.size()]; int i= 0; for (Iterator<Integer> intIt= desc.fOffsets.iterator(); intIt.hasNext(); i++) { Integer offset= intIt.next(); offsets[i]= offset.intValue(); } fCurrentType= type; /* * Call the deprecated version of createVariable. When not overridden, it will delegate * to the new version using fCurrentType. */ TemplateVariable var= createVariable(type.getName(), desc.fName, offsets); result[idx]= var; } fCurrentType= null; // avoid dangling reference return result; }
/** * Creates proper {@link TemplateVariable}s from the variable descriptions. * * @param variables the variable descriptions by variable name * @return the corresponding variables * @since 3.3 */ private TemplateVariable[] createVariables(Map<String, VariableDescription> variables) { TemplateVariable[] result= new TemplateVariable[variables.size()]; int idx= 0; for (Iterator<VariableDescription> it= variables.values().iterator(); it.hasNext(); idx++) { VariableDescription desc= it.next(); TemplateVariableType type= desc.fType == null ? new TemplateVariableType(desc.fName) : desc.fType; int[] offsets= new int[desc.fOffsets.size()]; int i= 0; for (Iterator<Integer> intIt= desc.fOffsets.iterator(); intIt.hasNext(); i++) { Integer offset= intIt.next(); offsets[i]= offset.intValue(); } fCurrentType= type; /* * Call the deprecated version of createVariable. When not overridden, it will delegate * to the new version using fCurrentType. */ TemplateVariable var= createVariable(type.getName(), desc.fName, offsets); result[idx]= var; } fCurrentType= null; // avoid dangling reference return result; }