001    package railo.commons.io.res.type.datasource;
002    
003    import railo.commons.io.res.type.datasource.core.CoreSupport;
004    
005    
006    public class Attr {
007    
008    
009    
010            public static final int TYPE_DIRECTORY = 0;
011            public static final int TYPE_FILE = 1;
012            public static final int TYPE_LINK = 2;
013            public static final int TYPE_UNDEFINED = 3;
014            
015                    private boolean exists=true;
016                    private int size=0;
017                    private short mode;
018                    private short attributes;
019                    private String name;
020                    private String parent;
021                    private int id;
022                    private long lastModified;
023                    private int type;
024                    private int data;
025                    private boolean isFile;
026                    private boolean isDirectory;
027                    
028                    private long created=System.currentTimeMillis();
029                    
030                    
031                    public Attr(int id,String name, String parent, boolean exists, int type, 
032                                    int size, long lastModified, short mode, short attributes, int data) {
033                            //if(mode==0)print.dumpStack();
034                            this.id = id;
035                            this.name = name;
036                            this.parent = parent;
037                            this.exists = exists;
038                            this.type = type;
039                            this.size = size;
040                            this.lastModified = lastModified;
041                            this.mode = mode;
042                            this.attributes = attributes;
043                            this.data = data;
044    
045                            this.isDirectory=CoreSupport.isDirectory(type);
046                            this.isFile=CoreSupport.isFile(type);
047                    }
048    
049                    /**
050                     * @return the data
051                     */
052                    public int getData() {
053                            return data;
054                    }
055    
056                    public static Attr notExists(String name, String parent) {
057                            return new Attr(0,name,parent,false,Attr.TYPE_UNDEFINED,0,0,(short)0,(short)0,0);
058                    }
059    
060    
061                    /**
062                     * @return the lastModified
063                     */
064                    public long getLastModified() {
065                            return lastModified;
066                    }
067    
068                    /**
069                     * @return the id
070                     */
071                    public int getId() {
072                            return id;
073                    }
074    
075                    /**
076                     * @return the name
077                     */
078                    public String getName() {
079                            return name;
080                    }
081    
082                    /**
083                     * @return the parent
084                     */
085                    public String getParent() {
086                            return parent;
087                    }
088    
089                    /**
090                     * @return the mode
091                     */
092                    public short getMode() {
093                            return mode;
094                    }
095                    /**
096                     * @return the attributes
097                     */
098                    public short getAttributes() {
099                            return attributes;
100                    }
101                    public boolean exists() {
102                            return exists;
103                    }
104                    public boolean isFile() {
105                            return isFile;
106                    }
107                    public boolean isDirectory() {
108                            return isDirectory;
109                    }
110                    public int size() {
111                            return size;
112                    }
113    
114    
115                    public long timestamp() {
116                            return created;
117                    }
118    
119                    /**
120                     * @return the type
121                     */
122                    public int getType() {
123                            return type;
124                    }
125    
126            }