001: /*
002: * ClipboardFile.java
003: *
004: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
005: *
006: * Copyright 2002-2008, Thomas Kellerer
007: * No part of this code maybe reused without the permission of the author
008: *
009: * To contact the author please send an email to: support@sql-workbench.net
010: *
011: */
012: package workbench.util;
013:
014: import java.io.File;
015: import java.io.IOException;
016:
017: /**
018: * @author support@sql-workbench.net
019: */
020: public class ClipboardFile extends File {
021:
022: private String buffer;
023:
024: public ClipboardFile(String contents) {
025: super ("Clipboard");
026: buffer = contents;
027: }
028:
029: public String getContents() {
030: return this .buffer;
031: }
032:
033: public boolean canRead() {
034: return true;
035: }
036:
037: public boolean canWrite() {
038: return false;
039: }
040:
041: public boolean delete() {
042: return false;
043: }
044:
045: public String getAbsolutePath() {
046: return "Clipboard";
047: }
048:
049: public File getAbsoluteFile() {
050: return this ;
051: }
052:
053: public String getName() {
054: return "Clipboard";
055: }
056:
057: public boolean isDirectory() {
058: return false;
059: }
060:
061: public boolean isHidden() {
062: return false;
063: }
064:
065: public boolean exists() {
066: return true;
067: }
068:
069: public String getParent() {
070: return null;
071: }
072:
073: public File getParentFile() {
074: return null;
075: }
076:
077: public String getPath() {
078: return getAbsolutePath();
079: }
080:
081: public String getCanonicalPath() throws IOException {
082: return getAbsolutePath();
083: }
084:
085: public File getCanonicalFile() throws IOException {
086: return this ;
087: }
088:
089: public boolean createNewFile() throws IOException {
090: return false;
091: }
092:
093: public int compareTo(File pathname) {
094: return -1;
095: }
096:
097: public boolean equals(Object obj) {
098: return false;
099: }
100:
101: public long length() {
102: if (this .buffer == null)
103: return 0;
104: return this .buffer.length();
105: }
106:
107: public int hashCode() {
108: if (buffer == null)
109: return 0;
110: return buffer.hashCode();
111: }
112:
113: public static void main(String[] args) {
114: try {
115: ClipboardFile f = new ClipboardFile("Bla");
116: ZipUtil.isZipFile(f);
117: } catch (Exception e) {
118: e.printStackTrace();
119: }
120: }
121: }
|