params.load(filter.getClass().getResourceAsStream(fc.parametersLocation), false); params.fromString(fc.parameters.toString()); } else { params.reset();
charsToCER = params.getString("escapeCharacters"); if (params.getBoolean(QUOTEMODEDEFINED)) { int q = params.getInteger(QUOTEMODE); quoteMode = QuoteMode.fromValue(params.getInteger(QUOTEMODE));
if ( params != null ) { escapeGT = params.getBoolean(ESCAPEGT); escapeNbsp = params.getBoolean(ESCAPENBSP); escapeLineBreak = params.getBoolean(ESCAPELINEBREAK); if ( params.getBoolean(QUOTEMODEDEFINED) ) { quoteMode = QuoteMode.fromValue(params.getInteger(QUOTEMODE));
/** * Gets the parameters for a given custom filter configuration. This * default implementation gets the custom data from a file located * in the current directory at the time the method is called. */ @Override public IParameters getCustomParameters (FilterConfiguration config, IFilter existingFilter) { // Instantiate a filter (or re-use one) IFilter filter = instantiateFilter(config, existingFilter); // Get the default parameters object IParameters params = filter.getParameters(); if ( params == null ) { return null; // This filter does not have parameters } // Load the provided parameter file // In this implementation the file is stored in a given directory if (config.parametersLocation != null) { File file = new File(customParmsDir + config.parametersLocation); params.load(Util.URItoURL(file.toURI()), false); } else if (config.parameters != null) { params.fromString(config.parameters.toString()); } return params; }
/** * Load the {@link IParameters} from the give {@link InputStream} * @param stream - stream of the parameter file. */ public void loadParametersFromStream(InputStream stream) { // stream parameters always overrides any other source parametersLocation = null; this.parameters.fromString(StreamUtil.streamUtf8AsString(stream)); } }
newParams.fromString(baseParams.toString()); newParams.setPath(null); return newConfig;
@Override protected Event handleStartDocument (Event event) { StartDocument sd = event.getStartDocument(); IParameters prm = sd.getFilterParameters(); String paramsData = null; if ( prm != null ) { paramsData = prm.toString(); } String relativeInput = new File(inputRootDir).toURI().relativize(inputURI).getPath(); String relativeOutput = new File(outputRootDir).toURI().relativize(outputURI).getPath(); writer.setDocumentInformation(relativeInput, filterConfigId, paramsData, sd.getEncoding(), relativeOutput, outputEncoding, sd.getFilterWriter().getSkeletonWriter()); return writer.handleEvent(event); }
public void setOptions (IParameters params, String encoding, String lineBreak) { chsEnc = Charset.forName(encoding).newEncoder(); this.lineBreak = lineBreak; this.encoding = encoding; this.params = params; // Get the output options if ( params != null ) { escapeExtendedChars = params.getBoolean("escapeExtendedChars"); escapeForwardSlashes = params.getBoolean("escapeForwardSlashes"); } }
private void processStartDocument (StartDocument resource) { // trgLoc was set before // fwOutputPath was set before create(fwOutputPath, null, resource.getLocale(), trgLoc, resource.getMimeType(), resource.getName(), null); // Additional variables specific to IFilterWriter mode fwInputEncoding = resource.getEncoding(); IParameters params = resource.getFilterParameters(); if ( params == null ) fwConfigId = null; else fwConfigId = params.getPath(); }
@Override public IParameters getParameters (FilterConfiguration config, IFilter existingFilter) { IFilter filter = instantiateFilter(config, existingFilter); IParameters params = filter.getParameters(); // No parameters for this filter if ( params == null ) { return null; } // Default parameters if ( config.parametersLocation == null && config.parameters == null ) { return params; } if ( config.custom ) { params = getCustomParameters(config, filter); } else if (config.parametersLocation != null) { // Note that we cannot assume the parameters are the same // if we re-used an existing filter, as we cannot compare the // configuration identifiers URL url = filter.getClass().getResource(config.parametersLocation); params.load(url, false); } else if (config.parameters != null) { params.fromString(config.parameters.toString()); } return params; }
private void instantiateConnector (int index) { try { if (infoList.get(index).classLoader == null) { currentConnector = (IQuery)Class.forName(infoList.get(index).connectorClass).newInstance(); } else { currentConnector = (IQuery)Class.forName(infoList.get(index).connectorClass, true, infoList.get(index).classLoader).newInstance(); } currentParams = currentConnector.getParameters(); if ( !Util.isEmpty(paramsList.get(index)) ) { // Set the current parameters if they exist currentParams.fromString(paramsList.get(index)); } // Otherwise use the defaults } catch ( InstantiationException e ) { throw new OkapiException("Error creating the connector. " + e.getMessage(), e); } catch ( IllegalAccessException e ) { throw new OkapiException("Error creating the connector. " + e.getMessage(), e); } catch ( ClassNotFoundException e ) { throw new OkapiException("Error creating the connector. " + e.getMessage(), e); } }
paramsList.set(n, currentParams.toString()); displayList.set(n, currentConnector.getSettingsDisplay());
@Override public void setOptions (IParameters params, String encoding, String lineBreak) { // lineBreak: They are converted to \n in this format chsEnc = Charset.forName(encoding).newEncoder(); this.lineBreak = lineBreak; this.encoding = encoding; this.params = params; // Get the output options if ( params != null ) { escapeExtendedChars = params.getBoolean("escapeExtendedChars"); } }
tmParams.fromString(connectorParams);
public JsonEventBuilder(String rootId, IFilter subFilter) { super(rootId, subFilter); codeFinder = null; // Get the output options if (subFilter.getParameters() != null ) { escapeForwardSlashes = subFilter.getParameters().getBoolean("escapeForwardSlashes"); } this.encoderManager = subFilter.getEncoderManager(); }
tmParams.fromString(connectorParams);
allowEmptyOutputTarget = prm.getBoolean(ALLOWEMPTYOUTPUTTARGET);
@Override protected Event handleStartBatch(Event event) { tuEventCount = 0; try { connector = (ITMQuery) Class.forName(params.getResourceClassName()).newInstance(); } catch (InstantiationException e) { throw new OkapiException("Error creating connector.", e); } catch (IllegalAccessException e) { throw new OkapiException("Error creating connector.", e); } catch (ClassNotFoundException e) { throw new OkapiException("Error creating connector.", e); } IParameters connectorParams = connector.getParameters(); if (connectorParams != null) { // Set the parameters only if the connector takes them connectorParams.fromString(params.getResourceParameters()); } connector.setRootDirectory(rootDir); // Before open() connector.setParameters(connectorParams); connector.open(); if ((sourceLocale != null) && (targetLocale != null)) { connector.setLanguages(sourceLocale, targetLocale); } connector.setThreshold(params.getThreshold()); connector.setMaximumHits(5); return event; }
fprm.fromString(info.getFilterParameters());