当前位置: 首页>>代码示例>>Java>>正文


Java FilterReader类代码示例

本文整理汇总了Java中java.io.FilterReader的典型用法代码示例。如果您正苦于以下问题:Java FilterReader类的具体用法?Java FilterReader怎么用?Java FilterReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FilterReader类属于java.io包,在下文中一共展示了FilterReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: add

import java.io.FilterReader; //导入依赖的package包/类
public void add(final Class<? extends FilterReader> filterType, final Map<String, ?> properties) {
    transformers.add(new Transformer<Reader, Reader>() {
        public Reader transform(Reader original) {
            try {
                Constructor<? extends FilterReader> constructor = filterType.getConstructor(Reader.class);
                FilterReader result = constructor.newInstance(original);

                if (properties != null) {
                    ConfigureUtil.configureByMap(properties, result);
                }
                return result;
            } catch (Throwable th) {
                throw new InvalidUserDataException("Error - Invalid filter specification for " + filterType.getName(), th);
            }
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:FilterChain.java

示例2: newNonBufferFillingReader

import java.io.FilterReader; //导入依赖的package包/类
/**
 * Returns a reader wrapping the given reader that only reads half of the maximum number of
 * characters that it could read in read(char[], int, int).
 */
private static Reader newNonBufferFillingReader(Reader reader) {
  return new FilterReader(reader) {
    @Override
    public int read(char[] cbuf, int off, int len) throws IOException {
      // if a buffer isn't being cleared correctly, this method will eventually start being called
      // with a len of 0 forever
      if (len <= 0) {
        fail("read called with a len of " + len);
      }
      // read fewer than the max number of chars to read
      // shouldn't be a problem unless the buffer is shrinking each call
      return in.read(cbuf, off, Math.max(len - 1024, 0));
    }
  };
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:20,代码来源:CharStreamsTest.java

示例3: testOnlyOneOpen

import java.io.FilterReader; //导入依赖的package包/类
public void testOnlyOneOpen() throws Exception {
  String testString = "abcdefgh";
  final CharSource source = newCharSource(testString);
  final int[] counter = new int[1];
  CharSource reader = new CharSource() {
    @Override
    public Reader openStream() throws IOException {
      if (counter[0]++ != 0) {
        throw new IllegalStateException("More than one source open");
      }
      return new FilterReader(source.openStream()) {
        @Override public void close() throws IOException {
          super.close();
          counter[0]--;
        }
      };
    }
  };
  Reader joinedReader = CharSource.concat(reader, reader, reader).openStream();
  String result = CharStreams.toString(joinedReader);
  assertEquals(testString.length() * 3, result.length());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:23,代码来源:MultiReaderTest.java

示例4: FilterReader

import java.io.FilterReader; //导入依赖的package包/类
/**
 * @tests java.io.FilterReader#FilterReader(java.io.Reader)
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "Verifies constructor FilterReader(java.io.Reader).",
    method = "FilterReader",
    args = {java.io.Reader.class}
)
public void test_ConstructorLjava_io_Reader() {

    FilterReader myReader = null;

    called = true;

    try {
        myReader = new MyFilterReader(null);
        fail("NullPointerException expected.");
    } catch (NullPointerException e) {
        // expected
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:23,代码来源:FilterReaderTest.java

示例5: testOnlyOneOpen

import java.io.FilterReader; //导入依赖的package包/类
public void testOnlyOneOpen() throws Exception {
  String testString = "abcdefgh";
  final CharSource source = newCharSource(testString);
  final int[] counter = new int[1];
  CharSource reader =
      new CharSource() {
        @Override
        public Reader openStream() throws IOException {
          if (counter[0]++ != 0) {
            throw new IllegalStateException("More than one source open");
          }
          return new FilterReader(source.openStream()) {
            @Override
            public void close() throws IOException {
              super.close();
              counter[0]--;
            }
          };
        }
      };
  Reader joinedReader = CharSource.concat(reader, reader, reader).openStream();
  String result = CharStreams.toString(joinedReader);
  assertEquals(testString.length() * 3, result.length());
}
 
开发者ID:google,项目名称:guava,代码行数:25,代码来源:MultiReaderTest.java

示例6: getInternalReader

import java.io.FilterReader; //导入依赖的package包/类
/**
 * @see #getReader
 */
public Reader getInternalReader(long characterPosition)
        throws IOException, SQLException {
    if (this.internalReader == null) {
        // getCSD obtains a descriptor for the stream to allow the reader
        // to configure itself.
        this.internalReader = new UTF8Reader(getCSD(), conChild,
                conChild.getConnectionSynchronization());
        this.unclosableInternalReader =
                new FilterReader(this.internalReader) {
                    public void close() {
                        // Do nothing.
                        // Stream will be closed when the Clob is released.
                    }
                };
    }
    try {
        this.internalReader.reposition(characterPosition);
    } catch (StandardException se) {
        throw Util.generateCsSQLException(se);
    }
    return this.unclosableInternalReader;
}
 
开发者ID:splicemachine,项目名称:spliceengine,代码行数:26,代码来源:TemporaryClob.java

示例7: filter

import java.io.FilterReader; //导入依赖的package包/类
public CopySpec filter(final Class<? extends FilterReader> filterType) {
    appendCopyAction(new Action<FileCopyDetails>() {
        public void execute(FileCopyDetails fileCopyDetails) {
            fileCopyDetails.filter(filterType);
        }
    });
    return this;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:DefaultCopySpec.java

示例8: getInputStream

import java.io.FilterReader; //导入依赖的package包/类
public InputStream getInputStream() throws IOException {
    if (inputOutput == null) {
        throw new IllegalStateException("not started");
    }
    return new ReaderInputStream(
            new FilterReader(inputOutput.getIn()) {
                @Override
                public void close() throws IOException {
                    // do not close the input, JShell may be reset.
                }
            }, "UTF-8" // NOI18N
    );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:JShellEnvironment.java

示例9: getChunkedReader

import java.io.FilterReader; //导入依赖的package包/类
private static Reader getChunkedReader(String input, final int chunk) {
  return new FilterReader(new StringReader(input)) {
    @Override public int read(char[] cbuf, int off, int len)
        throws IOException {
      return super.read(cbuf, off, Math.min(chunk, len));
    }
  };
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:9,代码来源:LineBufferTest.java

示例10: doTransform

import java.io.FilterReader; //导入依赖的package包/类
private Reader doTransform(ResourceRootFilter filter, Reader original) {
  if ("RenamingCopyFilter" .equals(filter.filterType)) {
    final Matcher matcher = (Matcher)filter.getProperties().get("matcher");
    final String replacement = (String)filter.getProperties().get("replacement");
    if (matcher == null || replacement == null) return original;

    matcher.reset(myOutputFileRef.get().getName());
    if (matcher.find()) {
      final String newFileName = matcher.replaceFirst(replacement);
      myOutputFileRef.set(new File(myOutputFileRef.get().getParentFile(), newFileName));
    }
    return original;
  }
  try {
    Class<?> clazz = Class.forName(filter.filterType);
    if (!FilterReader.class.isAssignableFrom(clazz)) {
      myContext.processMessage(
        new CompilerMessage(
          GradleResourcesBuilder.BUILDER_NAME, BuildMessage.Kind.WARNING,
          String.format("Error - Invalid filter specification for %s. It should extend java.io.FilterReader.", filter.filterType), null)
      );
    }
    Constructor constructor = clazz.getConstructor(Reader.class);
    FilterReader result = (FilterReader)constructor.newInstance(original);
    final Map<Object, Object> properties = filter.getProperties();
    if (!properties.isEmpty()) {
      ConfigureUtil.configureByMap(properties, result);
    }
    return result;
  }
  catch (Throwable th) {
    myContext.processMessage(new CompilerMessage(
                               GradleResourcesBuilder.BUILDER_NAME, BuildMessage.Kind.WARNING,
                               String.format("Error - Failed to apply filter(%s): %s", filter.filterType, th.getMessage()), null)
    );
  }
  return original;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:ChainingFilterTransformer.java

示例11: test_ConstructorLjava_io_Reader

import java.io.FilterReader; //导入依赖的package包/类
public void test_ConstructorLjava_io_Reader() {

        FilterReader myReader = null;

        called = true;

        try {
            myReader = new MyFilterReader(null);
            fail("NullPointerException expected.");
        } catch (NullPointerException e) {
            // expected
        }
    }
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:14,代码来源:OldFilterReaderTest.java

示例12: filter

import java.io.FilterReader; //导入依赖的package包/类
public CopySpec filter(final Class<? extends FilterReader> filterType) {
    copyActions.add(new Action<FileCopyDetails>() {
        public void execute(FileCopyDetails fileCopyDetails) {
            fileCopyDetails.filter(filterType);
        }
    });
    return this;
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:9,代码来源:DefaultCopySpec.java

示例13: filter

import java.io.FilterReader; //导入依赖的package包/类
public CopySpec filter(final Class<? extends FilterReader> filterType) {
    actions.add(new Action<FileCopyDetails>() {
        public void execute(FileCopyDetails fileCopyDetails) {
            fileCopyDetails.filter(filterType);
        }
    });
    return this;
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:9,代码来源:DefaultCopySpec.java

示例14: getChunkedReader

import java.io.FilterReader; //导入依赖的package包/类
private static Reader getChunkedReader(String input, final int chunk) {
  return new FilterReader(new StringReader(input)) {
    @Override
    public int read(char[] cbuf, int off, int len) throws IOException {
      return super.read(cbuf, off, Math.min(chunk, len));
    }
  };
}
 
开发者ID:google,项目名称:guava,代码行数:9,代码来源:LineBufferTest.java

示例15: unwrap

import java.io.FilterReader; //导入依赖的package包/类
public Reader unwrap(FilterReader originalReader) throws IllegalArgumentException {
    try {
        return (Reader) internalField.get(originalReader);
    } catch (Exception ex) {
        throw new IllegalArgumentException("Could not access private \"in\" field of the given FilterReader (actual class: " + originalReader.getClass().getCanonicalName() + ")", ex);
    }
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-german,代码行数:8,代码来源:FilterReaderUnwrapper.java


注:本文中的java.io.FilterReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。