/** * Removes any specified filter */ public void removeFilter(){ setFilter(null); } /**
/** * Getter for the base mappings used by this Cache. Modifications on the * returned object do not have any influence on the mappings, because this * method returns a clone. Use {@link #setBaseMappings(FieldMapper)} to * change the used base mappings. However make sure you understand the * implications of changing the base mappings as described in the * documentation of the setter method * * @return A clone of the base mappings or <code>null</code> if no base * mappings are defined */ @Override public final FieldMapper getBaseMappings() { return baseMapper == null ? null : baseMapper.clone(); }
@Override public int compare(FieldMapping fm17, FieldMapping fm33) { //in my company's QM 9000 system // ... fm17 stands for critical deviation and // ... fm33 stands for suggestion for improvement // and the nested in-line if are good for code quality! // ... sorry for the comments ^^ return fm17.usesWildcard() == fm33.usesWildcard()? //both same Wildcard fm17.ignoreField() == fm17.ignoreField()? // both same ignore state fm33.getFieldPattern().length()-fm17.getFieldPattern().length(): //longer field pattern fm17.ignoreField()?-1:1: //that with ignore field=true !fm17.usesWildcard()?-1:1; //that without wildcard }
@Override public Representation process(Representation source) { if(mapper == null){ throw new IllegalStateException("The mapper is not initialised. One must call setConfiguration to configure the FieldMapper!"); } if(source == null){ return null; } else { return mapper.applyMappings(source, vf.createRepresentation(source.getId()), vf); } } /**
public FiledMapperProcessor(FieldMapper mapper, NamespacePrefixService nps, ValueFactory vf){ this(nps,vf); if(mapper == null){ throw new IllegalArgumentException("The parsed FieldMapper MUST NOT be NULL!"); } else if(mapper.getMappings().isEmpty()){ throw new IllegalStateException("The parsed field mappings MUST contain at least a single valid mapping!"); } this.mapper = mapper; } public FiledMapperProcessor(Iterator<String> mappings, NamespacePrefixService nps, ValueFactory vf){
/** * Creates an FieldMapper instance by using the {@link DefaultFieldMapperImpl} * and the default instance if the {@link ValueConverterFactory} and configure * it with {@link FieldMapping}s * @param mappings The mappings or <code>null</code> if none * @return A new and configured FieldMapper instance. */ public static FieldMapper createDefaultFieldMapper(Iterable<FieldMapping> mappings){ FieldMapper mapper = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance()); if(mappings != null){ for(FieldMapping mapping : mappings){ mapper.addMapping(mapping); } } return mapper; }
@Override public Representation process(Representation source) { if(mapper == null){ throw new IllegalStateException("The mapper is not initialised. One must call setConfiguration to configure the FieldMapper!"); } if(source == null){ return null; } else { return mapper.applyMappings(source, vf.createRepresentation(source.getId()), vf); } } /**
public FiledMapperProcessor(FieldMapper mapper, NamespacePrefixService nps, ValueFactory vf){ this(nps,vf); if(mapper == null){ throw new IllegalArgumentException("The parsed FieldMapper MUST NOT be NULL!"); } else if(mapper.getMappings().isEmpty()){ throw new IllegalStateException("The parsed field mappings MUST contain at least a single valid mapping!"); } this.mapper = mapper; } public FiledMapperProcessor(Iterator<String> mappings, NamespacePrefixService nps, ValueFactory vf){
/** * Creates an FieldMapper instance by using the {@link DefaultFieldMapperImpl} * and the default instance if the {@link ValueConverterFactory} and configure * it with {@link FieldMapping}s * @param mappings The mappings or <code>null</code> if none * @return A new and configured FieldMapper instance. */ public static FieldMapper createDefaultFieldMapper(Iterable<FieldMapping> mappings){ FieldMapper mapper = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance()); if(mappings != null){ for(FieldMapping mapping : mappings){ mapper.addMapping(mapping); } } return mapper; }
@Override public int compare(FieldMapping fm17, FieldMapping fm33) { //in my company's QM 9000 system // ... fm17 stands for critical deviation and // ... fm33 stands for suggestion for improvement // and the nested in-line if are good for code quality! // ... sorry for the comments ^^ return fm17.usesWildcard() == fm33.usesWildcard()? //both same Wildcard fm17.ignoreField() == fm17.ignoreField()? // both same ignore state fm33.getFieldPattern().length()-fm17.getFieldPattern().length(): //longer field pattern fm17.ignoreField()?-1:1: //that with ignore field=true !fm17.usesWildcard()?-1:1; //that without wildcard }
/** * Getter for the base mappings used by this Cache. Modifications on the * returned object do not have any influence on the mappings, because this * method returns a clone. Use {@link #setBaseMappings(FieldMapper)} to * change the used base mappings. However make sure you understand the * implications of changing the base mappings as described in the * documentation of the setter method * * @return A clone of the base mappings or <code>null</code> if no base * mappings are defined */ @Override public final FieldMapper getBaseMappings() { return baseMapper == null ? null : baseMapper.clone(); }
/** * Removes any specified filter */ public void removeFilter(){ setFilter(null); } /**
public static String[] serialiseFieldMapper(FieldMapper mapper){ if(mapper == null){ return null; } else { Collection<FieldMapping> mappings = mapper.getMappings(); String[] mappingStrings = new String[mappings.size()]; int index=0; for(Iterator<FieldMapping> it = mappings.iterator();it.hasNext();index++){ mappingStrings[index] = serialiseFieldMapping(it.next()); } return mappingStrings; } }
/** * Creates an FieldMapper instance by using the {@link DefaultFieldMapperImpl} * and the default instance if the {@link ValueConverterFactory} and configure * it with {@link FieldMapping}s parsed form the list of string parsed as * argument to this method. * @param mappings The mappings or <code>null</code> if none * @return A new and configured FieldMapper instance. */ public static FieldMapper createDefaultFieldMapper(Iterator<String> mappings, NamespacePrefixService nps){ FieldMapper mapper = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance()); if(mappings != null){ for(FieldMapping mapping : parseFieldMappings(mappings,nps)){ mapper.addMapping(mapping); } } return mapper; } /**
/** * Getter for the additional mappings used by this Cache. Modifications on the * returned object do not have any influence on the mappings, because this * method returns a clone. Use {@link #setAdditionalMappings(FieldMapper)} to * change the used additional mappings. However make sure you understand the * implications of changing the base mappings as described in the * documentation of the setter method * * @return A clone of the additional mappings or <code>null</code> if no * additional mappings are defined */ @Override public final FieldMapper getAdditionalMappings() { return additionalMapper == null ? null : additionalMapper.clone(); }
public static String[] serialiseFieldMapper(FieldMapper mapper){ if(mapper == null){ return null; } else { Collection<FieldMapping> mappings = mapper.getMappings(); String[] mappingStrings = new String[mappings.size()]; int index=0; for(Iterator<FieldMapping> it = mappings.iterator();it.hasNext();index++){ mappingStrings[index] = serialiseFieldMapping(it.next()); } return mappingStrings; } }
/** * Getter for the additional mappings used by this Cache. Modifications on the * returned object do not have any influence on the mappings, because this * method returns a clone. Use {@link #setAdditionalMappings(FieldMapper)} to * change the used additional mappings. However make sure you understand the * implications of changing the base mappings as described in the * documentation of the setter method * * @return A clone of the additional mappings or <code>null</code> if no * additional mappings are defined */ @Override public final FieldMapper getAdditionalMappings() { return additionalMapper == null ? null : additionalMapper.clone(); }
public FiledMapperProcessor(Iterator<String> mappings, NamespacePrefixService nps, ValueFactory vf){ this(nps, vf); if(mappings == null){ throw new IllegalArgumentException("The parsed field mappings MUST NOT be NULL!"); } mapper = FieldMappingUtils.createDefaultFieldMapper(mappings,nsPrefixService); if(mapper.getMappings().isEmpty()){ throw new IllegalStateException("The parsed field mappings MUST contain at least a single valid mapping!"); } } public FiledMapperProcessor(InputStream mappings, NamespacePrefixService nps, ValueFactory vf) throws IOException{
public FiledMapperProcessor(Iterator<String> mappings, NamespacePrefixService nps, ValueFactory vf){ this(nps, vf); if(mappings == null){ throw new IllegalArgumentException("The parsed field mappings MUST NOT be NULL!"); } mapper = FieldMappingUtils.createDefaultFieldMapper(mappings,nsPrefixService); if(mapper.getMappings().isEmpty()){ throw new IllegalStateException("The parsed field mappings MUST contain at least a single valid mapping!"); } } public FiledMapperProcessor(InputStream mappings, NamespacePrefixService nps, ValueFactory vf) throws IOException{
/** * Serialises all {@link FieldMapping}s of the parsed {@link FieldMapper} * and stores them in the {@value Cache#FIELD_MAPPING_CONFIG_FIELD} of the * parsed {@link Representation} * @param config the representation to store the field mapping configuration * @param mapper the field mapper with the configuration to store */ private static void writeFieldConfig(Representation config, FieldMapper mapper){ StringBuilder builder = new StringBuilder(); for(FieldMapping mapping : mapper.getMappings()){ builder.append(FieldMappingUtils.serialiseFieldMapping(mapping)); builder.append('\n'); } config.set(Cache.FIELD_MAPPING_CONFIG_FIELD, builder.toString()); } }