int nrComponents = Terser.numComponents( types[t] ); for ( int c = 1; c <= nrComponents; c++ ) { int nrSub = Terser.numSubComponents( types[t], c ); for ( int sc = 1; sc <= nrSub; sc++ ) { String string = Terser.get( segment, n, t, c, sc );
/** * Encodes the given Type, using the given encoding characters. * It is assumed that the Type represents a complete field rather than a component. */ public static String encode(Type source, EncodingCharacters encodingChars) { StringBuffer field = new StringBuffer(); for (int i = 1; i <= Terser.numComponents(source); i++) { StringBuffer comp = new StringBuffer(); for (int j = 1; j <= Terser.numSubComponents(source, i); j++) { Primitive p = Terser.getPrimitive(source, i, j); comp.append(encodePrimitive(p, encodingChars)); comp.append(encodingChars.getSubcomponentSeparator()); } field.append(stripExtraDelimiters(comp.toString(), encodingChars.getSubcomponentSeparator())); field.append(encodingChars.getComponentSeparator()); } return stripExtraDelimiters(field.toString(), encodingChars.getComponentSeparator()); //return encode(source, encodingChars, false); }
/** * Encodes the given Type, using the given encoding characters. * It is assumed that the Type represents a complete field rather than a component. */ public static String encode(Type source, EncodingCharacters encodingChars) { StringBuffer field = new StringBuffer(); for (int i = 1; i <= Terser.numComponents(source); i++) { StringBuffer comp = new StringBuffer(); for (int j = 1; j <= Terser.numSubComponents(source, i); j++) { Primitive p = Terser.getPrimitive(source, i, j); comp.append(encodePrimitive(p, encodingChars)); comp.append(encodingChars.getSubcomponentSeparator()); } field.append(stripExtraDelimiters(comp.toString(), encodingChars.getSubcomponentSeparator())); field.append(encodingChars.getComponentSeparator()); } return stripExtraDelimiters(field.toString(), encodingChars.getComponentSeparator()); //return encode(source, encodingChars, false); }
for (int i = 1; i <= Terser.numComponents(source); i++) { StringBuilder comp = new StringBuilder(); for (int j = 1; j <= Terser.numSubComponents(source, i); j++) { Primitive p = Terser.getPrimitive(source, i, j); comp.append(encodePrimitive(p, parserConfig.getEscaping(), encodingChars));
for (int i = 1; i <= Terser.numComponents(source); i++) { StringBuilder comp = new StringBuilder(); for (int j = 1; j <= Terser.numSubComponents(source, i); j++) { Primitive p = Terser.getPrimitive(source, i, j); comp.append(encodePrimitive(p, parserConfig.getEscaping(), encodingChars));
/** * Copies data from the "from" Type into the "to" Type. Either Type may be * a Primitive, Composite, or Varies. If a Varies is provided, the operation is * performed on the result of calling its getData() method. A Primitive may be * copied into a Composite, in which case the value is copied into the first * component of the Composite. A Composite may be copied into a Primitive, * in which case the first component is copied. Given Composites with different * numbers of components, the first components are copied, up to the length * of the smaller one. * * @param from type to copy from * @param to type to copy to * @throws DataTypeException if the types are not compatible */ public static void copy(Type from, Type to) throws DataTypeException { for (int i = 1; i <= Terser.numComponents(from); i++) { for (int j = 1; j <= Terser.numSubComponents(from, i); j++) { String val = Terser.getPrimitive(from, i, j).getValue(); Terser.getPrimitive(to, i, j).setValue(val); } } }
/** * Copies data from the "from" Type into the "to" Type. Either Type may be * a Primitive, Composite, or Varies. If a Varies is provided, the operation is * performed on the result of calling its getData() method. A Primitive may be * copied into a Composite, in which case the value is copied into the first * component of the Composite. A Composite may be copied into a Primitive, * in which case the first component is copied. Given Composites with different * numbers of components, the first components are copied, up to the length * of the smaller one. * * @param from type to copy from * @param to type to copy to * @throws DataTypeException if the types are not compatible */ public static void copy(Type from, Type to) throws DataTypeException { for (int i = 1; i <= Terser.numComponents(from); i++) { for (int j = 1; j <= Terser.numSubComponents(from, i); j++) { String val = Terser.getPrimitive(from, i, j).getValue(); Terser.getPrimitive(to, i, j).setValue(val); } } }