/[alph]/alph/org/nongnu/alph/impl/PermanentTextScroll.java
ViewVC logotype

Diff of /alph/org/nongnu/alph/impl/PermanentTextScroll.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by tjl, Sun Apr 20 08:50:02 2003 UTC revision 1.4 by tjl, Mon Apr 21 16:31:23 2003 UTC
# Line 43  String rcsid = "$Id$"; Line 43  String rcsid = "$Id$";
43      char[] chars;      char[] chars;
44      boolean loadingFailed;      boolean loadingFailed;
45    
46      public PermanentTextScroll(StormPool ms, BlockId msid) {      public PermanentTextScroll(Alph alph, Object blockId, String contentType) {
47          super(ms, msid);          super(alph, blockId, contentType);
         this.ms = ms;  
         this.msid = msid;  
48      }      }
49    
50      public boolean equals(Object o) {      public boolean equals(Object o) {
# Line 57  String rcsid = "$Id$"; Line 55  String rcsid = "$Id$";
55    
56      protected final void load() {      protected final void load() {
57          if(chars != null || loadingFailed) return;          if(chars != null || loadingFailed) return;
58            loadingFailed = true;
         Block block ;  
         String ct;  
         try {  
             block = ms.request(msid, null);  
             ct = msid.getContentType();  
         } catch(IOException e) {  
             loadingFailed = true;  
             e.printStackTrace();  
             throw new Error("Couldn't load block: "+e);  
         }  
59    
60          // Note: for the legacy string content to work, we need to be able          // Note: for the legacy string content to work, we need to be able
61          // to load GZZ1 diffs as text blocks (see GZZ1Handler.LegacyContent          // to load GZZ1 diffs as text blocks (see GZZ1Handler.LegacyContent
62          // javadoc for more info).          // javadoc for more info).
63          if(!ct.equals("text/plain; charset=UTF-8") &&          if(!contentType.equals("text/plain; charset=UTF-8") &&
64             !ct.equals("application/x-gzigzag-GZZ1") &&             !contentType.equals("application/x-gzigzag-GZZ1") &&
65             !ct.equals("message/rfc822")) {             !contentType.equals("message/rfc822")) {
66              loadingFailed = true;              throw new Error("Unknown text block content type '"+
67              throw new Error("Unknown text block '"+ct+"'");                          contentType+"'");
68          }          }
69    
70          String string;          String string;
71          try {          try {
72              string = new String(SlurpStream.slurp(block.getInputStream()), "UTF8");              BlockFile f = getBlockFile();
73                string = new String(SlurpStream.slurp(
74                            new FileInputStream(f.getFile())), "UTF8");
75                f.close();
76          } catch(Exception e) {          } catch(Exception e) {
77              loadingFailed = true;              loadingFailed = true;
78              e.printStackTrace();              e.printStackTrace();
# Line 89  String rcsid = "$Id$"; Line 80  String rcsid = "$Id$";
80          }          }
81    
82          this.chars = string.toCharArray();          this.chars = string.toCharArray();
83            loadingFailed = false;
84      }      }
85    
86      public TextSpan append(char ch) throws ImmutableException {      public TextSpan append(char ch) throws ImmutableException {

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26