Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 4 package org.openedit.repository.filesystem; 5 6 import java.io.ByteArrayInputStream ; 7 import java.io.InputStream ; 8 import java.util.Date ; 9 10 import org.apache.commons.logging.Log; 11 import org.apache.commons.logging.LogFactory; 12 import org.openedit.repository.ContentItem; 13 import org.openedit.repository.RepositoryException; 14 15 16 19 public class StringItem extends ContentItem 20 { 21 protected String fieldContent; 22 protected String fieldOutputEncoding; 23 protected boolean fieldWritable = true; 24 private static final Log log = LogFactory.getLog(StringItem.class); 25 26 public StringItem( String inPath, String inContent, String inEncoding ) 27 { 28 if ( inContent == null) 30 { 31 inContent = ""; 32 } 33 fieldContent = inContent; 34 fieldPath = inPath; 35 fieldOutputEncoding = inEncoding; 36 } 37 40 public StringItem() 41 { 42 } 43 public void setLastModified(Date inDate) 44 { 45 super.setLastModified(inDate); 46 } 47 48 public InputStream getInputStream() throws RepositoryException 49 { 50 if ( getOutputEncoding() == null) 51 { 52 log.error("Encoding not defined"); 53 return new ByteArrayInputStream (getContent().getBytes()); 54 } 55 try 56 { 57 return new ByteArrayInputStream (getContent().getBytes(getOutputEncoding())); 58 } catch ( Exception ex) 59 { 60 log.error(ex); 61 throw new RepositoryException(ex); 62 } 63 } 64 65 public boolean exists() 66 { 67 return getContent() != null; 68 } 69 70 public boolean isFolder() 71 { 72 return false; 73 } 74 77 public boolean isWritable() 78 { 79 return fieldWritable; 80 } 81 82 83 public String getContent() 84 { 85 return fieldContent; 86 } 87 public void setContent( String content ) 88 { 89 fieldContent = content; 90 } 91 protected void setWritable(boolean inWritable) 92 { 93 fieldWritable = inWritable; 94 } 95 public String getOutputEncoding() 96 { 97 return fieldOutputEncoding; 98 } 99 public void setOutputEncoding(String inOutputEncoding) 100 { 101 fieldOutputEncoding = inOutputEncoding; 102 } 103 } 104
| Popular Tags
|