Examples of BasicFileAttributes


Examples of org.uberfire.java.nio.file.attribute.BasicFileAttributes

    public DublinCoreView( final AbstractPath path ) {
        super( path );
        final Map<String, Object> content = path.getAttrStorage().getContent();

        final BasicFileAttributes fileAttrs = path.getFileSystem().provider().getFileAttributeView( path, BasicFileAttributeView.class ).readAttributes();

        final Map<String, List<String>> dcore = new HashMap<String, List<String>>() {{
            for ( final String property : PROPERTIES ) {
                put( property, new ArrayList<String>() );
            }
        }};

        for ( final Map.Entry<String, Object> entry : content.entrySet() ) {
            if ( entry.getKey().startsWith( TITLE ) ) {
                final Pair<Integer, String> result = extractValue( entry );
                dcore.get( TITLE ).add( result.getK1(), result.getK2() );
            } else if ( entry.getKey().startsWith( CREATOR ) ) {
                final Pair<Integer, String> result = extractValue( entry );
                dcore.get( CREATOR ).add( result.getK1(), result.getK2() );
            } else if ( entry.getKey().startsWith( SUBJECT ) ) {
                final Pair<Integer, String> result = extractValue( entry );
                dcore.get( SUBJECT ).add( result.getK1(), result.getK2() );
            } else if ( entry.getKey().startsWith( DESCRIPTION ) ) {
                final Pair<Integer, String> result = extractValue( entry );
                dcore.get( DESCRIPTION ).add( result.getK1(), result.getK2() );
            } else if ( entry.getKey().startsWith( PUBLISHER ) ) {
                final Pair<Integer, String> result = extractValue( entry );
                dcore.get( PUBLISHER ).add( result.getK1(), result.getK2() );
            } else if ( entry.getKey().startsWith( CONTRIBUTOR ) ) {
                final Pair<Integer, String> result = extractValue( entry );
                dcore.get( CONTRIBUTOR ).add( result.getK1(), result.getK2() );
            } else if ( entry.getKey().startsWith( TYPE ) ) {
                final Pair<Integer, String> result = extractValue( entry );
                dcore.get( TYPE ).add( result.getK1(), result.getK2() );
            } else if ( entry.getKey().startsWith( FORMAT ) ) {
                final Pair<Integer, String> result = extractValue( entry );
                dcore.get( FORMAT ).add( result.getK1(), result.getK2() );
            } else if ( entry.getKey().startsWith( IDENTIFIER ) ) {
                final Pair<Integer, String> result = extractValue( entry );
                dcore.get( IDENTIFIER ).add( result.getK1(), result.getK2() );
            } else if ( entry.getKey().startsWith( SOURCE ) ) {
                final Pair<Integer, String> result = extractValue( entry );
                dcore.get( SOURCE ).add( result.getK1(), result.getK2() );
            } else if ( entry.getKey().startsWith( LANGUAGE ) ) {
                final Pair<Integer, String> result = extractValue( entry );
                dcore.get( LANGUAGE ).add( result.getK1(), result.getK2() );
            } else if ( entry.getKey().startsWith( RELATION ) ) {
                final Pair<Integer, String> result = extractValue( entry );
                dcore.get( RELATION ).add( result.getK1(), result.getK2() );
            } else if ( entry.getKey().startsWith( COVERAGE ) ) {
                final Pair<Integer, String> result = extractValue( entry );
                dcore.get( COVERAGE ).add( result.getK1(), result.getK2() );
            } else if ( entry.getKey().startsWith( RIGHTS ) ) {
                final Pair<Integer, String> result = extractValue( entry );
                dcore.get( RIGHTS ).add( result.getK1(), result.getK2() );
            }
        }

        this.attrs = new DublinCoreAttributes() {
            @Override
            public List<String> titles() {
                return dcore.get( TITLE );
            }

            @Override
            public List<String> creators() {
                return dcore.get( CREATOR );
            }

            @Override
            public List<String> subjects() {
                return dcore.get( SUBJECT );
            }

            @Override
            public List<String> descriptions() {
                return dcore.get( DESCRIPTION );
            }

            @Override
            public List<String> publishers() {
                return dcore.get( PUBLISHER );
            }

            @Override
            public List<String> contributors() {
                return dcore.get( CONTRIBUTOR );
            }

            @Override
            public List<String> types() {
                return dcore.get( TYPE );
            }

            @Override
            public List<String> formats() {
                return dcore.get( FORMAT );
            }

            @Override
            public List<String> identifiers() {
                return dcore.get( IDENTIFIER );
            }

            @Override
            public List<String> sources() {
                return dcore.get( SOURCE );
            }

            @Override
            public List<String> languages() {
                return dcore.get( LANGUAGE );
            }

            @Override
            public List<String> relations() {
                return dcore.get( RELATION );
            }

            @Override
            public List<String> coverages() {
                return dcore.get( COVERAGE );
            }

            @Override
            public List<String> rights() {
                return dcore.get( RIGHTS );
            }

            @Override
            public FileTime lastModifiedTime() {
                return fileAttrs.lastModifiedTime();
            }

            @Override
            public FileTime lastAccessTime() {
                return fileAttrs.lastAccessTime();
            }

            @Override
            public FileTime creationTime() {
                return fileAttrs.creationTime();
            }

            @Override
            public boolean isRegularFile() {
                return fileAttrs.isRegularFile();
            }

            @Override
            public boolean isDirectory() {
                return fileAttrs.isDirectory();
            }

            @Override
            public boolean isSymbolicLink() {
                return fileAttrs.isSymbolicLink();
            }

            @Override
            public boolean isOther() {
                return fileAttrs.isOther();
            }

            @Override
            public long size() {
                return fileAttrs.size();
            }

            @Override
            public Object fileKey() {
                return fileAttrs.fileKey();
            }
        };
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.