Example usage for org.apache.hadoop.fs GlobPattern matches

List of usage examples for org.apache.hadoop.fs GlobPattern matches

Introduction

In this page you can find the example usage for org.apache.hadoop.fs GlobPattern matches.

Prototype

public boolean matches(CharSequence s) 

Source Link

Document

Match input against the compiled glob pattern

Usage

From source file:de.tiqsolutions.hdfs.HadoopFileSystem.java

License:Apache License

@Override
public PathMatcher getPathMatcher(String syntaxAndPattern) {
    String syntax = "glob";
    String pattern = syntaxAndPattern;
    String[] sp = syntaxAndPattern.split(":", 2);
    if (sp.length == 2) {
        syntax = sp[0];//from w  ww .  j a  va2 s  .  c o  m
        pattern = sp[1];
    }
    if (!"glob".equals(syntax))
        throw new UnsupportedOperationException();

    final GlobPattern globPattern = new GlobPattern(pattern);
    return new PathMatcher() {
        @Override
        public boolean matches(Path path) {
            return globPattern.matches(path.toString());
        }
    };
}

From source file:org.apache.gobblin.service.modules.dataset.FSDatasetDescriptor.java

License:Apache License

/**
 * A helper to determine if the path description of this {@link DatasetDescriptor} is a superset of paths
 * accepted by the other {@link DatasetDescriptor}. If the path description of the other {@link DatasetDescriptor}
 * is a glob pattern, we return false.// w  ww  .ja  v a  2  s .c  om
 *
 * @param otherPath a glob pattern that describes a set of paths.
 * @return true if the glob pattern described by the otherPath matches the path in this {@link DatasetDescriptor}.
 */
protected boolean isPathContaining(String otherPath) {
    if (otherPath == null) {
        return false;
    }
    if (DatasetDescriptorConfigKeys.DATASET_DESCRIPTOR_CONFIG_ANY.equals(this.getPath())) {
        return true;
    }
    if (PathUtils.isGlob(new Path(otherPath))) {
        return false;
    }
    GlobPattern globPattern = new GlobPattern(this.getPath());
    return globPattern.matches(otherPath);
}