-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPeopleCodeContainer.java
135 lines (126 loc) · 3.54 KB
/
PeopleCodeContainer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package decodepcode;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringWriter;
import java.util.Date;
import java.util.logging.Logger;
public abstract class PeopleCodeContainer implements PeopleCodeObject
{
int pos;
byte[] bytes;
String lastChangedBy, source;
Date lastChangedDtTm;
public boolean hasPlainPeopleCode()
{
return peopleCodeText != null;
}
abstract String getReference( int nameNum);
byte read() { return bytes[pos]; }
byte get() { return bytes[pos++]; }
byte readAhead()
{
if (pos >= bytes.length - 1)
return -1;
else
return bytes[pos];
}
String peopleCodeText;
Logger logger = Logger.getLogger(getClass().getName());
public abstract String getCompositeKey();
public abstract String[] getKeys();
public abstract int getPeopleCodeType();
void writeBytesToStream( OutputStream os) throws IOException
{
os.write(bytes);
os.flush();
}
void writeBytesToFile(File f) throws IOException
{
FileOutputStream fo = new FileOutputStream(f);
writeBytesToStream(fo);
fo.close();
}
abstract void writeReferencesInDirectory( File f) throws IOException;
void writeInDirectory(File f) throws IOException
{
if (!f.isDirectory())
throw new IllegalArgumentException(""+ f + " is not a directory");
File binFile = new File(f, getCompositeKey() + ".bin");
if (binFile.exists())
logger.warning("Overwriting " + binFile);
writeBytesToFile(binFile);
writeReferencesInDirectory( f);
}
public String getPeopleCodeText()
{
if (peopleCodeText == null)
throw new IllegalArgumentException("Text PeopleCode has not been set");
return peopleCodeText;
}
public void setPeopleCodeText(String _PeopleCodeText)
{
this.peopleCodeText = _PeopleCodeText;
}
public void readPeopleCodeTextFromFile( File f) throws IOException
{
StringWriter sw = new StringWriter();
String line;
BufferedReader br = new BufferedReader(new FileReader(f));
while ((line = br.readLine()) != null)
{
sw.write(line);
sw.write(PeopleCodeParser.eol);
}
br.close();
setPeopleCodeText(sw.toString());
}
public static String objectTypeStr( int objType)
{
switch (objType) {
case 8 : return "Record_PeopleCode";
case 9 : return "Menu_PeopleCode";
case 39 : return "Message_PeopleCode";
case 40 : return "Subscription_PeopleCode";
case 42 : return "Component_Interface_PeopleCode";
case 43 : return "Application_Engine_PeopleCode";
case 44 : return "Page_PeopleCode";
case 46 : return "Component_PeopleCode";
case 47 : return "Component_Record_PeopleCode";
case 48 : return "Component_Record_Field_PeopleCode";
case 58 : return "App_Package_PeopleCode";
default :
return "objecttype_" + objType ;
}
}
final static int[] objTypes={ 8 , 9 , 39 , 40 , 42 , 43 , 44 , 46 , 47 , 48 , 58} ;
public static int objectTypeFromString( String s)
{
if (s == null) return -1;
for (int i: objTypes)
if (s.equals(objectTypeStr(i)))
return i;
return -1;
}
public String getLastChangedBy() {
return lastChangedBy;
}
public void setLastChangedBy(String lastChangedBy) {
this.lastChangedBy = lastChangedBy;
}
public Date getLastChangedDtTm() {
return lastChangedDtTm;
}
public void setLastChangedDtTm(Date lastChangedDtTm) {
this.lastChangedDtTm = lastChangedDtTm;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
}