MCPcopy Index your code
hub / github.com/boazy/TWEditorEnhanced / getString

Method getString

src/main/java/StringsDatabase.java:62–95  ·  view source on GitHub ↗
(int stringRef)

Source from the content-addressed store, hash-verified

60 }
61
62 public String getString(int stringRef)
63 {
64 String string = null;
65 try
66 {
67 int refid = stringRef & 0xFFFFFF;
68 if (refid < this.stringCount) {
69 byte[] buffer = new byte[40];
70 this.in.seek(this.entryOffset + refid * 40);
71 int count = this.in.read(buffer);
72 if (count != buffer.length) {
73 throw new DBException(new StringBuilder().append("String entry truncated for reference ").append(refid).toString());
74 }
75
76 if ((buffer[0] & 0x1) != 0) {
77 int offset = getInteger(buffer, 28);
78 int length = getInteger(buffer, 32);
79 byte[] data = new byte[length];
80 this.in.seek(this.stringOffset + offset);
81 count = this.in.read(data);
82 if (count != length) {
83 throw new DBException(new StringBuilder().append("String data truncated for reference ").append(refid).toString());
84 }
85 string = new String(data, "UTF-8");
86 }
87 }
88 } catch (DBException exc) {
89 Main.logException("String database format error", exc);
90 } catch (IOException exc) {
91 Main.logException("Unable to read string database", exc);
92 }
93
94 return string != null ? string : new String();
95 }
96
97 public String getLabel(int stringRef)
98 {

Callers 2

getLabelMethod · 0.95
getHeadingMethod · 0.95

Calls 4

getIntegerMethod · 0.95
logExceptionMethod · 0.95
readMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected