Java 类org.eclipse.core.runtime.content.ITextContentDescriber 实例源码

项目:data-mapper    文件:DozerConfigContentTypeDescriber.java   
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.core.runtime.content.ITextContentDescriber#describe(java.io.Reader,
 *      org.eclipse.core.runtime.content.IContentDescription)
 */
@Override
public int describe(final Reader contents,
        final IContentDescription description) throws IOException {
    final char[] buf = new char[200];
    contents.read(buf);
    final String text = String.valueOf(buf).replaceAll("\\s", "");
    final int ndx = text.indexOf(ROOT_ELEMENT);
    return ndx > 0 && text.indexOf(XMLNS) > ndx ? ITextContentDescriber.VALID
            : ITextContentDescriber.INVALID;
}