Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/neuron/jaffer/AFP_CNode.java


1   /* 
2    * Copyright (c) 2003 Stewart Allen <stewart@neuron.com>. All rights reserved.
3    * This program is free software. See the 'License' file for details.
4    */
5   
6   package com.neuron.jaffer;
7   
8   import java.io.*;
9   import java.net.*;
10  import java.util.*;
11  
12  public abstract class AFP_CNode extends Utility implements AFP_Constants
13  {
14    public final static int NODE_UNKNOWN    = 0x00;
15    public final static int NODE_FILE       = 0x01;
16    public final static int NODE_DIRECTORY  = 0x02;
17                                             
18    public final static int MODE_READ       = 0x01; // bit 1
19    public final static int MODE_WRITE      = 0x02; // bit 2
20    public final static int MODE_READ_LOCK  = 0x08; // bit 4
21    public final static int MODE_WRITE_LOCK = 0x10; // bit 5
22  
23    // -----------------------------------------------------------------------
24  
25    private int id;
26  
27    AFP_CNode(int id)
28    {
29      this.id = id;
30    }
31  
32    // -----------------------------------------------------------------------
33  
34    public boolean isFile()
35    {
36      return getNodeType() == NODE_FILE;
37    }
38  
39    public boolean isDirectory()
40    {
41      return getNodeType() == NODE_DIRECTORY;
42    }
43  
44    public final byte[] unixPrivs()
45    {
46       return bounded(getUnixPrivs(),16);
47    }
48  
49    public final byte[] finderInfo()
50    {
51       return bounded(getFinderInfo(),32);
52    }
53  
54    private byte[] bounded(byte b[], int len)
55    {
56      if (b == null)
57      {
58        return new byte[len];
59      }
60      if (b.length == len)
61      {
62        return b;
63      }
64      byte nb[] = new byte[len];
65      System.arraycopy(b,0,nb,0,Math.min(len,b.length));
66      return nb;
67    }
68  
69    public String longName()
70    {
71      String nm = getLongName();
72      if (nm.length() > 31)
73      {
74        return nm.substring(0,31);
75      }
76      return nm;
77    }
78  
79    public String shortName()
80    {
81      String nm = getLongName();
82      if (nm.length() > 12)
83      {
84        return nm.substring(0,12);
85      }
86      return nm;
87    }
88  
89    // -----------------------------------------------------------------------
90  
91    public int getNodeID()
92    {
93      return id;
94    }
95  
96    public abstract int getNodeType()
97      ;
98    
99    public abstract int getParentNodeID()
100     ;
101 
102   public abstract int getAttributes()
103     ;
104 
105   public abstract void setAttributes(int att)
106     ;
107 
108   public abstract int getCreateDate()
109     ;
110 
111   public abstract void setCreateDate(int date)
112     ;
113 
114   public abstract int getModifiedDate()
115     ;
116 
117   public abstract void setModifiedDate(int date)
118     ;
119 
120   public abstract int getBackupDate()
121     ;
122 
123   public abstract void setBackupDate(int date)
124     ;
125 
126   public abstract byte[] getFinderInfo()
127     ;
128 
129   public abstract void setFinderInfo(byte info[])
130     ;
131 
132   public abstract String getLongName()
133     ;
134 
135   public abstract String getShortName()
136     ;
137 
138   public abstract String getUTF8Name()
139     ;
140 
141   public abstract boolean delete()
142     ;
143 
144   // dir MUST be a directory, newName can be null in which case
145   // the file or directory retains it's original name
146   public abstract boolean moveTo(AFP_CNode dir, String newName)
147     ;
148 
149   // see AFP3.1 p. 36
150   public abstract byte[] getUnixPrivs()
151     ;
152 
153   public abstract void setUnixPrivs(byte privs[])
154     ;
155 
156   // files only
157   public abstract int getLaunchLimit()
158     ;
159 
160   public abstract int getDataForkLen()
161     ;
162 
163   public abstract int getResourceForkLen()
164     ;
165 
166   public abstract long getExtDataForkLen()
167     ;
168 
169   public abstract long getExtResourceForkLen()
170     ;
171 
172   public abstract AFP_Fork openFileFork(int flags)
173     ;
174 
175   public abstract AFP_Fork openResourceFork(int flags)
176     ;
177 
178   // directory only
179   public abstract int getAccessRights()
180     ;
181 
182   public abstract int getOwnerID()
183     ;
184 
185   public abstract int getGroupID()
186     ;
187 
188   public abstract int getOffspringCount()
189     ;
190 
191   public abstract AFP_CNode createFile(String name)
192     ;
193 
194   public abstract AFP_CNode createDirectory(String name)
195     ;
196 
197   public abstract AFP_CNode getOffspringByName(String name)
198     ;
199 
200   public abstract Enumeration getOffspringEnumeration()
201     ;
202 }
203