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) { |
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(); |
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 { |