001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.commons.io.res.type.datasource; 020 021import lucee.commons.io.res.type.datasource.core.CoreSupport; 022 023 024public class Attr { 025 026 027 028 public static final int TYPE_DIRECTORY = 0; 029 public static final int TYPE_FILE = 1; 030 public static final int TYPE_LINK = 2; 031 public static final int TYPE_UNDEFINED = 3; 032 033 private boolean exists=true; 034 private int size=0; 035 private short mode; 036 private short attributes; 037 private String name; 038 private String parent; 039 private int id; 040 private long lastModified; 041 private int type; 042 private int data; 043 private boolean isFile; 044 private boolean isDirectory; 045 046 private long created=System.currentTimeMillis(); 047 048 049 public Attr(int id,String name, String parent, boolean exists, int type, 050 int size, long lastModified, short mode, short attributes, int data) { 051 //if(mode==0)print.dumpStack(); 052 this.id = id; 053 this.name = name; 054 this.parent = parent; 055 this.exists = exists; 056 this.type = type; 057 this.size = size; 058 this.lastModified = lastModified; 059 this.mode = mode; 060 this.attributes = attributes; 061 this.data = data; 062 063 this.isDirectory=CoreSupport.isDirectory(type); 064 this.isFile=CoreSupport.isFile(type); 065 } 066 067 /** 068 * @return the data 069 */ 070 public int getData() { 071 return data; 072 } 073 074 public static Attr notExists(String name, String parent) { 075 return new Attr(0,name,parent,false,Attr.TYPE_UNDEFINED,0,0,(short)0,(short)0,0); 076 } 077 078 079 /** 080 * @return the lastModified 081 */ 082 public long getLastModified() { 083 return lastModified; 084 } 085 086 /** 087 * @return the id 088 */ 089 public int getId() { 090 return id; 091 } 092 093 /** 094 * @return the name 095 */ 096 public String getName() { 097 return name; 098 } 099 100 /** 101 * @return the parent 102 */ 103 public String getParent() { 104 return parent; 105 } 106 107 /** 108 * @return the mode 109 */ 110 public short getMode() { 111 return mode; 112 } 113 /** 114 * @return the attributes 115 */ 116 public short getAttributes() { 117 return attributes; 118 } 119 public boolean exists() { 120 return exists; 121 } 122 public boolean isFile() { 123 return isFile; 124 } 125 public boolean isDirectory() { 126 return isDirectory; 127 } 128 public int size() { 129 return size; 130 } 131 132 133 public long timestamp() { 134 return created; 135 } 136 137 /** 138 * @return the type 139 */ 140 public int getType() { 141 return type; 142 } 143 144 }