/** * Creates a template variable with multiple possible values. * * @param type the type of the variable * @param name the name of the variable * @param values the values available at this variable, non-empty * @param offsets the array of offsets of the variable */ public TemplateVariable(String type, String name, String[] values, int[] offsets) { this(new TemplateVariableType(type), name, values, offsets); }
/** * Creates a template variable with multiple possible values. * * @param type the type of the variable * @param name the name of the variable * @param values the values available at this variable, non-empty * @param offsets the array of offsets of the variable */ public TemplateVariable(String type, String name, String[] values, int[] offsets) { this(new TemplateVariableType(type), name, values, offsets); }
private TemplateVariableType createType(String typeName, String paramString) { if (typeName == null) return null; if (paramString == null) return new TemplateVariableType(typeName); final Matcher matcher= PARAM_PATTERN.matcher(paramString); List<String> params= new ArrayList<>(5); while (matcher.find()) { String argument= matcher.group(); if (argument.charAt(0) == '\'') { // argumentText argument= argument.substring(1, argument.length() - 1).replaceAll("''", "'"); //$NON-NLS-1$ //$NON-NLS-2$ } params.add(argument); } return new TemplateVariableType(typeName, params.toArray(new String[params.size()])); }
private TemplateVariableType createType(String typeName, String paramString) { if (typeName == null) return null; if (paramString == null) return new TemplateVariableType(typeName); final Matcher matcher= PARAM_PATTERN.matcher(paramString); List<String> params= new ArrayList<>(5); while (matcher.find()) { String argument= matcher.group(); if (argument.charAt(0) == '\'') { // argumentText argument= argument.substring(1, argument.length() - 1).replaceAll("''", "'"); //$NON-NLS-1$ //$NON-NLS-2$ } params.add(argument); } return new TemplateVariableType(typeName, params.toArray(new String[params.size()])); }
/** * 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; }