📄 redirectorelement.java
字号:
throw tooManyAttributes(); } if (error == null) { throw new IllegalArgumentException("error file specified as null"); } usingError = true; errorMapper = createMergeMapper(error); } /** * Property name whose value should be set to the output of * the process. * @param outputProperty the name of the property to be set with the * task's output. */ public void setOutputProperty(String outputProperty) { if (isReference()) { throw tooManyAttributes(); } this.outputProperty = outputProperty; } /** * Whether output should be appended to or overwrite an existing file. * Defaults to false. * @param append if true output and error streams are appended to their * respective files, if specified. */ public void setAppend(boolean append) { if (isReference()) { throw tooManyAttributes(); } this.append = ((append) ? Boolean.TRUE : Boolean.FALSE); } /** * If true, (error and non-error) output will be "teed", redirected * as specified while being sent to Ant's logging mechanism as if no * redirection had taken place. Defaults to false. * @param alwaysLog <code>boolean</code> * @since Ant 1.6.3 */ public void setAlwaysLog(boolean alwaysLog) { if (isReference()) { throw tooManyAttributes(); } this.alwaysLog = ((alwaysLog) ? Boolean.TRUE : Boolean.FALSE); } /** * Whether output and error files should be created even when empty. * Defaults to true. * @param createEmptyFiles <code>boolean</code>. */ public void setCreateEmptyFiles(boolean createEmptyFiles) { if (isReference()) { throw tooManyAttributes(); } this.createEmptyFiles = ((createEmptyFiles) ? Boolean.TRUE : Boolean.FALSE); } /** * Property name whose value should be set to the error of * the process. * @param errorProperty the name of the property to be set * with the error output. */ public void setErrorProperty(String errorProperty) { if (isReference()) { throw tooManyAttributes(); } this.errorProperty = errorProperty; } /** * Create a nested input <code>FilterChain</code>. * @return <code>FilterChain</code>. */ public FilterChain createInputFilterChain() { if (isReference()) { throw noChildrenAllowed(); } FilterChain result = new FilterChain(); result.setProject(getProject()); inputFilterChains.add(result); return result; } /** * Create a nested output <code>FilterChain</code>. * @return <code>FilterChain</code>. */ public FilterChain createOutputFilterChain() { if (isReference()) { throw noChildrenAllowed(); } FilterChain result = new FilterChain(); result.setProject(getProject()); outputFilterChains.add(result); return result; } /** * Create a nested error <code>FilterChain</code>. * @return <code>FilterChain</code>. */ public FilterChain createErrorFilterChain() { if (isReference()) { throw noChildrenAllowed(); } FilterChain result = new FilterChain(); result.setProject(getProject()); errorFilterChains.add(result); return result; } /** * Configure the specified <code>Redirector</code>. * @param redirector <code>Redirector</code>. */ public void configure(Redirector redirector) { configure(redirector, null); } /** * Configure the specified <code>Redirector</code> * for the specified sourcefile. * @param redirector <code>Redirector</code>. * @param sourcefile <code>String</code>. */ public void configure(Redirector redirector, String sourcefile) { if (isReference()) { getRef().configure(redirector, sourcefile); return; } if (alwaysLog != null) { redirector.setAlwaysLog(alwaysLog.booleanValue()); } if (logError != null) { redirector.setLogError(logError.booleanValue()); } if (append != null) { redirector.setAppend(append.booleanValue()); } if (createEmptyFiles != null) { redirector.setCreateEmptyFiles(createEmptyFiles.booleanValue()); } if (outputProperty != null) { redirector.setOutputProperty(outputProperty); } if (errorProperty != null) { redirector.setErrorProperty(errorProperty); } if (inputString != null) { redirector.setInputString(inputString); } if (logInputString != null) { redirector.setLogInputString(logInputString.booleanValue()); } if (inputMapper != null) { String[] inputTargets = null; try { inputTargets = inputMapper.getImplementation().mapFileName(sourcefile); } catch (NullPointerException enPeaEx) { if (sourcefile != null) { throw enPeaEx; } } if (inputTargets != null && inputTargets.length > 0) { redirector.setInput(toFileArray(inputTargets)); } } if (outputMapper != null) { String[] outputTargets = null; try { outputTargets = outputMapper.getImplementation().mapFileName(sourcefile); } catch (NullPointerException enPeaEx) { if (sourcefile != null) { throw enPeaEx; } } if (outputTargets != null && outputTargets.length > 0) { redirector.setOutput(toFileArray(outputTargets)); } } if (errorMapper != null) { String[] errorTargets = null; try { errorTargets = errorMapper.getImplementation().mapFileName(sourcefile); } catch (NullPointerException enPeaEx) { if (sourcefile != null) { throw enPeaEx; } } if (errorTargets != null && errorTargets.length > 0) { redirector.setError(toFileArray(errorTargets)); } } if (inputFilterChains.size() > 0) { redirector.setInputFilterChains(inputFilterChains); } if (outputFilterChains.size() > 0) { redirector.setOutputFilterChains(outputFilterChains); } if (errorFilterChains.size() > 0) { redirector.setErrorFilterChains(errorFilterChains); } if (inputEncoding != null) { redirector.setInputEncoding(inputEncoding); } if (outputEncoding != null) { redirector.setOutputEncoding(outputEncoding); } if (errorEncoding != null) { redirector.setErrorEncoding(errorEncoding); } } /** * Create a merge mapper pointing to the specified destination file. * @param destfile <code>File</code> * @return <code>Mapper</code>. */ protected Mapper createMergeMapper(File destfile) { Mapper result = new Mapper(getProject()); result.setClassname( org.apache.tools.ant.util.MergingMapper.class.getName()); result.setTo(destfile.getAbsolutePath()); return result; } /** * Return a <code>File[]</code> from the specified set of filenames. * @param name <code>String[]</code> * @return <code>File[]</code>. */ protected File[] toFileArray(String[] name) { if (name == null) { return null; } //remove any null elements ArrayList list = new ArrayList(name.length); for (int i = 0; i < name.length; i++) { if (name[i] != null) { list.add(getProject().resolveFile(name[i])); } } return (File[]) (list.toArray(new File[list.size()])); } /** * Overrides the version of DataType to recurse on all DataType * child elements that may have been added. * @param stk the stack of data types to use (recursively). * @param p the project to use to dereference the references. * @throws BuildException on error. */ protected void dieOnCircularReference(Stack stk, Project p) throws BuildException { if (isChecked()) { return; } if (isReference()) { super.dieOnCircularReference(stk, p); } else { Mapper[] m = new Mapper[] {inputMapper, outputMapper, errorMapper}; for (int i = 0; i < m.length; i++) { if (m[i] != null) { stk.push(m[i]); m[i].dieOnCircularReference(stk, p); stk.pop(); } } Vector[] v = new Vector[] {inputFilterChains, outputFilterChains, errorFilterChains}; for (int i = 0; i < v.length; i++) { if (v[i] != null) { for (Iterator fci = v[i].iterator(); fci.hasNext();) { FilterChain fc = (FilterChain) fci.next(); stk.push(fc); fc.dieOnCircularReference(stk, p); stk.pop(); } } } setChecked(true); } } /** * Perform the check for circular references, returning the * referenced RedirectorElement. * @return the referenced RedirectorElement. */ private RedirectorElement getRef() { return (RedirectorElement) getCheckedRef(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -