24 |
package gzz.media.impl; |
package gzz.media.impl; |
25 |
import gzz.errors.*; |
import gzz.errors.*; |
26 |
import gzz.media.*; |
import gzz.media.*; |
27 |
|
import gzz.util.*; |
28 |
|
|
29 |
/** An object that behaves like a text span but is not really stable media. |
/** An object that behaves like a text span but is not stored in a real Storm block. |
30 |
* Used for things like coordinates or other computer-generated rapidly changing |
* Used for things like coordinates or other computer-generated rapidly changing |
31 |
* content. |
* content. Must be atomic: if you give one piece away, you give |
32 |
|
* the whole thing away. Must be short, because the whole thing |
33 |
|
* is repeated whereever one piece goes. See PEG miniblocks--benja. |
34 |
*/ |
*/ |
35 |
|
|
36 |
public class FakeTextSpan implements TextSpan, java.io.Serializable { |
public class FakeTextSpan implements TextSpan, java.io.Serializable { |
37 |
public static final String rcsid = "$Id$"; |
public static final String rcsid = "$Id$"; |
38 |
|
|
39 |
String text; |
String text; |
40 |
|
FakeTextScrollBlock sb; |
41 |
transient char[] textarr; |
transient char[] textarr; |
|
transient FakeTextScrollBlock sb; |
|
42 |
|
|
43 |
public FakeTextSpan(String s) { |
public FakeTextSpan(String s) { |
44 |
|
String id = URN5Namespace.instance.getStormDataBlockId(); |
45 |
|
id = id + "," + URIUtil.escapeUTF8(s); |
46 |
|
|
47 |
|
sb = new FakeTextScrollBlock(/*s, id*/); |
48 |
this.text = s; |
this.text = s; |
49 |
} |
} |
50 |
|
|
74 |
public String toString() { return "FAKESPAN "+text; } |
public String toString() { return "FAKESPAN "+text; } |
75 |
public boolean intersects(Span s) { return false; } |
public boolean intersects(Span s) { return false; } |
76 |
|
|
77 |
public class FakeTextScrollBlock implements TextScrollBlock { |
protected class FakeTextScrollBlock implements TextScrollBlock { |
78 |
public String getID() { return ""; } |
/* |
79 |
|
protected String str, id; |
80 |
|
|
81 |
|
protected FakeTextScrollBlock(String id) { |
82 |
|
if(!id.startsWith("storm:data:")) |
83 |
|
throw IllegalArgumentException("Cannot handle URI: "+id); |
84 |
|
|
85 |
|
// ignore everything between storm:data: and :[<mimetype>],<data> |
86 |
|
int j = id.indexOf(','); |
87 |
|
int i = id.lastIndexOf(':', j); |
88 |
|
String type = str.substring(i+1, j); |
89 |
|
if(!type.equals("") && !type.equals("text/plain;charset=UTF-8")) |
90 |
|
throw IllegalArgumentException("Cannot handle content type: "+type); |
91 |
|
|
92 |
|
this.str = URIUtil.unescapeUTF8(str.substring(j+1)); |
93 |
|
this.id = id; |
94 |
|
} |
95 |
|
*/ |
96 |
|
|
97 |
|
public String getID() { return "" /*id*/; } |
98 |
public Span getCurrent() { return FakeTextSpan.this; } |
public Span getCurrent() { return FakeTextSpan.this; } |
99 |
public boolean isFinalized() { return true; } |
public boolean isFinalized() { return true; } |
100 |
|
|