Java Code Examples for org.apache.commons.vfs2.FileType#equals()
The following examples show how to use
org.apache.commons.vfs2.FileType#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GoogleDriveFileObject.java From hop with Apache License 2.0 | 6 votes |
private void resolveFileMetadata() throws Exception { String parentId = null; if ( getName().getParent() != null ) { File parent = searchFile( getName().getParent().getBaseName(), null ); if ( parent != null ) { FileType mime = MIME_TYPES.get( parent.getMimeType() ); if ( mime.equals( FileType.FOLDER ) ) { parentId = parent.getId(); } } } String fileName = getName().getBaseName(); File file = searchFile( fileName, parentId ); if ( file != null ) { mimeType = MIME_TYPES.get( file.getMimeType() ); id = file.getId(); } else { if ( getName().getURI().equals( GoogleDriveFileProvider.SCHEME + ":///" ) ) { mimeType = FileType.FOLDER; } } }
Example 2
Source File: AbstractFileObject.java From commons-vfs with Apache License 2.0 | 6 votes |
/** * Notifies the file that its children have changed. * * @param childName The name of the child. * @param newType The type of the child. * @throws Exception if an error occurs. */ protected void childrenChanged(final FileName childName, final FileType newType) throws Exception { // TODO - this may be called when not attached if (children != null && childName != null && newType != null) { // TODO - figure out if children[] can be replaced by list final ArrayList<FileName> list = new ArrayList<>(Arrays.asList(children)); if (newType.equals(FileType.IMAGINARY)) { list.remove(childName); } else { list.add(childName); } children = new FileName[list.size()]; list.toArray(children); } // removeChildrenCache(); onChildrenChanged(childName, newType); }
Example 3
Source File: GoogleDriveFileObject.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private void resolveFileMetadata() throws Exception { String parentId = null; if ( getName().getParent() != null ) { File parent = searchFile( getName().getParent().getBaseName(), null ); if ( parent != null ) { FileType mime = MIME_TYPES.get( parent.getMimeType() ); if ( mime.equals( FileType.FOLDER ) ) { parentId = parent.getId(); } } } String fileName = getName().getBaseName(); File file = searchFile( fileName, parentId ); if ( file != null ) { mimeType = MIME_TYPES.get( file.getMimeType() ); id = file.getId(); } else { if ( getName().getURI().equals( GoogleDriveFileProvider.SCHEME + ":///" ) ) { mimeType = FileType.FOLDER; } } }
Example 4
Source File: S3NFileName.java From hop with Apache License 2.0 | 5 votes |
public S3NFileName( String scheme, String bucketId, String path, FileType type ) { super( scheme, path, type ); this.bucketId = bucketId; if ( path.length() > 1 ) { this.bucketRelativePath = path.substring( 1 ); if ( type.equals( FileType.FOLDER ) ) { this.bucketRelativePath += DELIMITER; } } else { this.bucketRelativePath = ""; } }
Example 5
Source File: S3FileName.java From hop with Apache License 2.0 | 5 votes |
public S3FileName( String scheme, String bucketId, String path, FileType type ) { super( scheme, path, type ); this.bucketId = bucketId; if ( path.length() > 1 ) { this.bucketRelativePath = path.substring( 1 ); if ( type.equals( FileType.FOLDER ) ) { this.bucketRelativePath += DELIMITER; } } else { this.bucketRelativePath = ""; } }
Example 6
Source File: S3AFileName.java From hop with Apache License 2.0 | 5 votes |
public S3AFileName( String scheme, String bucketId, String path, FileType type ) { super( scheme, path, type ); this.bucketId = bucketId; if ( path.length() > 1 ) { this.bucketRelativePath = path.substring( 1 ); if ( type.equals( FileType.FOLDER ) ) { this.bucketRelativePath += DELIMITER; } } else { this.bucketRelativePath = ""; } }
Example 7
Source File: FileObjectComparator.java From otroslogviewer with Apache License 2.0 | 5 votes |
private int compareTypes(FileType type1, FileType type2) { if (type1.equals(FileType.FILE) && !type2.equals(FileType.FILE)) { return 1; } else if (!type1.equals(FileType.FILE) && type2.equals(FileType.FILE)) { return -1; } return 0; }
Example 8
Source File: FtpFileObject.java From commons-vfs with Apache License 2.0 | 5 votes |
/** * Called when the children of this file change. */ @Override protected void onChildrenChanged(final FileName child, final FileType newType) { if (children != null && newType.equals(FileType.IMAGINARY)) { try { children.remove(UriParser.decode(child.getBaseName())); } catch (final FileSystemException e) { throw new RuntimeException(e.getMessage()); } } else { // if child was added we have to rescan the children // TODO - get rid of this children = null; } }