1 28 29 package com.opencms.template.cache; 30 31 import java.io.UnsupportedEncodingException ; 32 import java.util.Vector ; 33 34 44 public class CmsElementVariant { 45 46 50 Vector m_content; 51 52 57 Vector m_dependencies; 58 59 62 private long m_nextTimeout = 0; 63 64 67 private boolean m_exported = false; 68 69 72 public CmsElementVariant() { 73 m_content = new Vector (); 74 } 75 76 81 public void add(String staticContent) { 82 m_content.add(staticContent); 83 } 84 85 90 public void add(byte[] staticContent) { 91 m_content.add(staticContent); 92 } 93 94 99 public void add(byte[] staticContent, String encoding) { 100 try { 101 m_content.add(new String (staticContent, encoding)); 102 } catch (UnsupportedEncodingException uee) { 103 m_content.add(staticContent); 104 } 105 } 106 107 111 public void add(CmsElementLink elementLink) { 112 m_content.add(elementLink); 113 } 114 115 119 public void add(CmsMethodLink methodLink) { 120 m_content.add(methodLink); 121 } 122 123 126 public int size() { 127 return m_content.size(); 128 } 129 130 135 public Object get(int i) { 136 return m_content.get(i); 137 } 138 139 143 public void setDependencies(Vector dependencies){ 144 m_dependencies = dependencies; 145 } 146 147 150 public boolean wasExported(){ 151 return m_exported; 152 } 153 154 158 public void setExported(){ 159 m_exported = true; 160 } 161 162 167 public Vector getDependencies(){ 168 return m_dependencies; 169 } 170 171 176 public void addDependencies(Vector depVariant){ 177 if(m_dependencies == null){ 178 m_dependencies = depVariant; 179 }else if (depVariant != null){ 180 for (int i = 0; i < depVariant.size(); i++){ 182 m_dependencies.add(depVariant.elementAt(i)); 183 } 184 } 185 } 186 187 191 public String toString() { 192 int len = m_content.size(); 193 StringBuffer result = new StringBuffer ("[CmsElementVariant] (" + len + ") :"); 194 for(int i=0; i<len; i++) { 195 Object o = m_content.elementAt(i); 196 if(o instanceof byte[] || o instanceof String ) { 197 result.append("TXT"); 198 } else { 199 result.append("("); 200 result.append(o.toString()); 201 result.append(")"); 202 } 203 if(i < len-1) result.append("-"); 204 } 205 return result.toString(); 206 } 207 208 213 public void mergeNextTimeout(long timeout){ 214 215 if(m_nextTimeout == 0 || timeout == 0){ 216 if(m_nextTimeout < timeout){ 217 m_nextTimeout = timeout; 218 } 219 }else{ 220 if(m_nextTimeout > timeout){ 221 m_nextTimeout = timeout; 222 } 223 } 224 } 225 229 public long getNextTimeout(){ 230 return m_nextTimeout; 231 } 232 235 public boolean isTimeCritical(){ 236 return m_nextTimeout != 0; 237 } 238 } | Popular Tags |