link start!

This commit is contained in:
cherubin
2026-03-17 13:31:18 -07:00
commit 08abe87cfb
5910 changed files with 386288 additions and 0 deletions
@@ -0,0 +1,570 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.workbench.console.BConsole
* com.tridium.workbench.console.BConsole$ExecCallback
* com.tridium.workbench.shell.BNiagaraWbShell
* javax.baja.file.FileUtil
* javax.baja.nre.util.SortUtil
* javax.baja.nre.util.TextUtil
* javax.baja.registry.ModuleInfo
* javax.baja.sys.BAbsTime
* javax.baja.sys.BComponent
* javax.baja.sys.BFacets
* javax.baja.sys.BIcon
* javax.baja.sys.BValue
* javax.baja.sys.Property
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BWidget
* javax.baja.util.BFolder
* javax.baja.util.BNameMap
* javax.baja.util.Lexicon
* javax.baja.xml.XContent
* javax.baja.xml.XElem
* javax.baja.xml.XWriter
*/
package com.tridium.program.module;
import com.tridium.program.BProgram;
import com.tridium.program.module.BuildException;
import com.tridium.program.module.BuildStep;
import com.tridium.program.module.ComponentWriter;
import com.tridium.program.module.IBuildListener;
import com.tridium.program.module.ValidateModel;
import com.tridium.workbench.console.BConsole;
import com.tridium.workbench.shell.BNiagaraWbShell;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import javax.baja.file.FileUtil;
import javax.baja.nre.util.SortUtil;
import javax.baja.nre.util.TextUtil;
import javax.baja.registry.ModuleInfo;
import javax.baja.sys.BAbsTime;
import javax.baja.sys.BComponent;
import javax.baja.sys.BFacets;
import javax.baja.sys.BIcon;
import javax.baja.sys.BValue;
import javax.baja.sys.Property;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BWidget;
import javax.baja.util.BFolder;
import javax.baja.util.BNameMap;
import javax.baja.util.Lexicon;
import javax.baja.xml.XContent;
import javax.baja.xml.XElem;
import javax.baja.xml.XWriter;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public final class BProgramModule
extends BComponent {
public static final Property moduleName = BProgramModule.newProperty((int)8, (String)"", (BFacets)BFacets.make((String)"mustBeSlotName", (boolean)true));
public static final Property description = BProgramModule.newProperty((int)0, (String)"", (BFacets)BFacets.make((String)"max", (int)100));
public static final Property vendor = BProgramModule.newProperty((int)0, (String)"", null);
public static final Property vendorVersion = BProgramModule.newProperty((int)0, (String)"0", (BFacets)BFacets.make((String)"validator", (String)"baja:VersionValidator"));
public static final Property dependencies = BProgramModule.newProperty((int)4, (BValue)BNameMap.DEFAULT, null);
public static final Property programs = BProgramModule.newProperty((int)4, (BValue)new BFolder(), null);
public static final Type TYPE;
private static final BIcon icon;
private static final Lexicon lex;
private static final String packageName = "autogen";
private static BuildStep[] buildSteps;
private File buildRoot;
HashMap typeMap;
static /* synthetic */ Class class$com$tridium$program$module$BProgramModule;
static /* synthetic */ Class class$com$tridium$program$BProgram;
public final String getModuleName() {
return this.getString(moduleName);
}
public final void setModuleName(String string) {
this.setString(moduleName, string, null);
}
public final String getDescription() {
return this.getString(description);
}
public final void setDescription(String string) {
this.setString(description, string, null);
}
public final String getVendor() {
return this.getString(vendor);
}
public final void setVendor(String string) {
this.setString(vendor, string, null);
}
public final String getVendorVersion() {
return this.getString(vendorVersion);
}
public final void setVendorVersion(String string) {
this.setString(vendorVersion, string, null);
}
public final BNameMap getDependencies() {
return (BNameMap)this.get(dependencies);
}
public final void setDependencies(BNameMap bNameMap) {
this.set(dependencies, (BValue)bNameMap, null);
}
public final BFolder getPrograms() {
return (BFolder)this.get(programs);
}
public final void setPrograms(BFolder bFolder) {
this.set(programs, (BValue)bFolder, null);
}
public final Type getType() {
return TYPE;
}
public static final String toTypeName(BProgram bProgram) {
return bProgram.getDisplayName(null);
}
public static final String toComponentName(BProgram bProgram) {
if (bProgram.getParent() == null) {
throw new IllegalStateException("Must be parented.");
}
String string = BProgramModule.toTypeName(bProgram);
if (!Character.isUpperCase(string.charAt(0))) {
return null;
}
StringBuffer stringBuffer = new StringBuffer("B").append(string.charAt(0));
int n = 1;
while (n < string.length()) {
char c = string.charAt(n);
if (!Character.isLetterOrDigit(c)) {
return null;
}
stringBuffer.append(c);
++n;
}
return stringBuffer.toString();
}
public static final BNameMap rationalizeDependecies(BProgramModule bProgramModule) {
HashSet<String> hashSet = new HashSet<String>();
BNameMap bNameMap = bProgramModule.getDependencies();
String[] stringArray = bNameMap.list();
int n = 0;
while (n < stringArray.length) {
if (!BProgram.isSpecialModule(stringArray[n])) {
hashSet.add(stringArray[n]);
}
++n;
}
BProgram[] bProgramArray = bProgramModule.listPrograms();
int n2 = 0;
while (n2 < bProgramArray.length) {
String[] stringArray2 = TextUtil.split((String)bProgramArray[n2].getCode().getDependencies(), (char)';');
int n3 = 0;
while (n3 < stringArray2.length) {
String string = stringArray2[n3];
if (bNameMap.get(string) == null && !BProgram.isSpecialModule(string)) {
bNameMap = BNameMap.make((BNameMap)bNameMap, (String)string, (String)Sys.getRegistry().getModule(string).getVendorVersion().toString(2));
}
hashSet.remove(string);
++n3;
}
++n2;
}
Object[] objectArray = hashSet.toArray();
int n4 = 0;
while (n4 < objectArray.length) {
bNameMap = BNameMap.remove((BNameMap)bNameMap, (String)((String)objectArray[n4]));
++n4;
}
return bNameMap;
}
public final void buildModule(IBuildListener iBuildListener) throws BuildException {
if (iBuildListener == null) {
iBuildListener = new IBuildListener(){
public final void updateDesc(String string) {
}
public final void setNumBuildSteps(int n) {
}
public final void nextStep(String string) {
}
public final BWidget getOwner() {
return null;
}
};
}
iBuildListener.setNumBuildSteps(buildSteps.length + this.listPrograms().length);
iBuildListener.updateDesc(lex.getText("programModule.build", new Object[]{this.getModuleName()}));
int n = 0;
while (n < buildSteps.length) {
buildSteps[n].runStep(this, iBuildListener);
++n;
}
}
public final BProgram[] listPrograms() {
BFolder bFolder = this.getPrograms();
Class clazz = class$com$tridium$program$BProgram;
if (clazz == null) {
clazz = class$com$tridium$program$BProgram = BProgramModule.class("[Lcom.tridium.program.BProgram;", false);
}
return (BProgram[])bFolder.getChildren(clazz);
}
final File getBuildRoot() {
return this.buildRoot;
}
final void setBuildRoot(File file) {
this.buildRoot = file;
}
final String getPreferredSymbol() {
return this.getModuleName();
}
public final BIcon getIcon() {
return icon;
}
static final /* synthetic */ String access$1() {
return packageName;
}
static /* synthetic */ Class class(String string, boolean bl) {
try {
Class<?> clazz = Class.forName(string);
if (!bl) {
clazz = clazz.getComponentType();
}
return clazz;
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
static {
Class clazz = class$com$tridium$program$module$BProgramModule;
if (clazz == null) {
clazz = class$com$tridium$program$module$BProgramModule = BProgramModule.class("[Lcom.tridium.program.module.BProgramModule;", false);
}
TYPE = Sys.loadType((Class)clazz);
icon = BIcon.make((BIcon)BIcon.std((String)"module.png"), (BIcon)BIcon.std((String)"badges/script.png"));
Class clazz2 = class$com$tridium$program$module$BProgramModule;
if (clazz2 == null) {
clazz2 = class$com$tridium$program$module$BProgramModule = BProgramModule.class("[Lcom.tridium.program.module.BProgramModule;", false);
}
lex = Lexicon.make((Class)clazz2);
buildSteps = new BuildStep[]{new ValidateStep(), new InitStep(), new WriteComponentsStep(), new WriteBuildXmlStep(), new WriteModuleIncludeStep(), new WritePaletteStep(), new WriteLexiconStep(), new NiagaraBuildStep()};
}
static class ValidateStep
extends BuildStep {
private String modOrd;
public void doStep() throws Exception {
this.interest.nextStep(lex.getText("programModule.validate"));
this.modOrd = this.module.getNavOrd().toString();
boolean bl = false;
ValidateModel validateModel = ValidateModel.make(this.module);
if (validateModel.getErrCount() > 0) {
bl = true;
this.appendErrOrdLines(null, validateModel);
}
BProgram[] bProgramArray = this.module.listPrograms();
int n = 0;
while (n < bProgramArray.length) {
validateModel = ValidateModel.make(bProgramArray[n]);
if (validateModel.getErrCount() > 0) {
bl = true;
this.appendErrOrdLines(bProgramArray[n], validateModel);
}
++n;
}
if (bl) {
throw new BuildException(lex.getText("programModule.validate.failed"));
}
}
private final void appendErrOrdLines(BProgram bProgram, ValidateModel validateModel) {
StringBuffer stringBuffer = new StringBuffer().append(this.modOrd).append("|view:program:ProgramModuleBuilder");
if (bProgram != null) {
stringBuffer.append("?program=").append(BProgramModule.toTypeName(bProgram));
}
int n = validateModel.getErrCount();
String string = stringBuffer.toString();
int n2 = 0;
while (n2 < n) {
this.interest.updateDesc(string + "|| " + validateModel.getValueAt(n2, 0));
++n2;
}
}
ValidateStep() {
}
}
static class InitStep
extends BuildStep {
File temp;
File buildDir;
public void doStep() throws Exception {
this.interest.nextStep(lex.getText("programModule.init"));
this.temp = new File(Sys.getBajaHome(), "temp");
this.buildDir = new File(this.temp, this.module.getModuleName());
FileUtil.delete((File)this.buildDir);
this.buildDir.mkdirs();
this.module.setBuildRoot(this.buildDir);
this.module.typeMap = new HashMap();
}
InitStep() {
}
}
static class WriteComponentsStep
extends BuildStep {
File packageDir;
public void doStep() throws Exception {
this.interest.nextStep(lex.getText("programModule.convert"));
File file = new File(this.module.getBuildRoot(), "src");
this.packageDir = new File(file, BProgramModule.packageName);
if (!this.packageDir.mkdirs()) {
throw new BuildException(lex.getText("programModule.convert.failPkg", new Object[]{this.packageDir}));
}
BProgram[] bProgramArray = this.module.listPrograms();
int n = 0;
while (n < bProgramArray.length) {
String string = BProgramModule.toComponentName(bProgramArray[n]);
String string2 = string + ".java";
this.interest.nextStep(lex.getText("programModule.convert.write", new Object[]{string}));
this.module.typeMap.put(BProgramModule.toTypeName(bProgramArray[n]), "autogen." + string);
FileWriter fileWriter = new FileWriter(new File(this.packageDir, string2));
new ComponentWriter(fileWriter, bProgramArray[n], BProgramModule.packageName).generate();
++n;
}
}
WriteComponentsStep() {
}
}
static class WriteBuildXmlStep
extends BuildStep {
public void doStep() throws Exception {
this.interest.nextStep(lex.getText("programModule.buildXML"));
File file = new File(this.module.getBuildRoot(), "build.xml");
XWriter xWriter = new XWriter(file);
xWriter.prolog();
this.writeComments(xWriter);
this.writeModule(xWriter);
xWriter.close();
}
private final void writeComments(XWriter xWriter) throws IOException {
StringBuffer stringBuffer = new StringBuffer().append("<!--").append("\n").append(" - Module Build File").append("\n").append(" - Auto-generated by the Program Module-Builder.").append("\n").append(" - Date: ").append(BAbsTime.now()).append("\n").append(" -->").append("\n\n");
xWriter.write(stringBuffer.toString());
}
private final void writeModule(XWriter xWriter) throws IOException {
XElem xElem = new XElem("module");
String string = this.module.getVendorVersion();
if (string.length() == 0) {
string = "0";
}
xElem.addAttr("name", this.module.getModuleName()).addAttr("bajaVersion", "0").addAttr("preferredSymbol", this.module.getPreferredSymbol()).addAttr("description", this.module.getDescription()).addAttr("vendor", this.module.getVendor()).addAttr("vendorVersion", string);
this.addDependencies(xElem);
this.addPackages(xElem);
xElem.write(xWriter);
}
private final void addDependencies(XElem xElem) {
BNameMap bNameMap = BProgramModule.rationalizeDependecies(this.module);
this.module.setDependencies(bNameMap);
Object[] objectArray = bNameMap.list();
SortUtil.sort((Object[])objectArray);
int n = 0;
while (n < objectArray.length) {
Object object = objectArray[n];
String string = bNameMap.get((String)object).getFormat();
ModuleInfo moduleInfo = Sys.getRegistry().getModule((String)object);
xElem.addContent((XContent)new XElem("dependency").addAttr("name", (String)object).addAttr("vendor", moduleInfo.getVendor()).addAttr("vendorVersion", string));
++n;
}
}
private final void addPackages(XElem xElem) {
xElem.addContent((XContent)new XElem("package").addAttr("name", BProgramModule.packageName));
}
WriteBuildXmlStep() {
}
}
static class WriteModuleIncludeStep
extends BuildStep {
public void doStep() throws Exception {
this.interest.nextStep(lex.getText("programModule.include"));
File file = new File(this.module.getBuildRoot(), "module-include.xml");
try {
XWriter xWriter = new XWriter(file);
xWriter.prolog();
this.writeComments(xWriter);
this.writeTypes(xWriter);
xWriter.close();
}
catch (Exception exception) {
throw new BuildException(lex.getText("programModule.include.fail"), exception);
}
}
private final void writeComments(XWriter xWriter) throws IOException {
StringBuffer stringBuffer = new StringBuffer().append("<!--").append("\n").append(" - Module Include File").append("\n").append(" - Auto-generated by the Program Module-Builder.").append("\n").append(" - Date: ").append(BAbsTime.now()).append("\n").append(" -->").append("\n\n");
xWriter.write(stringBuffer.toString());
}
private final void writeTypes(XWriter xWriter) throws IOException {
XElem xElem = new XElem("types");
Iterator iterator = this.module.typeMap.keySet().iterator();
while (iterator.hasNext()) {
String string = (String)iterator.next();
String string2 = (String)this.module.typeMap.get(string);
XElem xElem2 = new XElem("type").addAttr("name", string).addAttr("class", string2);
xElem.addContent((XContent)xElem2);
}
xElem.write(xWriter);
}
WriteModuleIncludeStep() {
}
}
static class WritePaletteStep
extends BuildStep {
protected void doStep() throws Exception {
this.interest.nextStep(lex.getText("programModule.palette"));
File file = new File(this.module.getBuildRoot(), "module.palette");
XWriter xWriter = new XWriter(file);
xWriter.prolog();
XElem xElem = new XElem("bajaObjectGraph").addAttr("version", "1.0");
XElem xElem2 = new XElem("p").addAttr("m", "b=baja").addAttr("t", "b:UnrestrictedFolder");
BProgram[] bProgramArray = this.module.listPrograms();
SortUtil.sort((Object[])bProgramArray, (Object[])bProgramArray, (Comparator)new Comparator(){
public final int compare(Object object, Object object2) {
String string = BProgramModule.toTypeName((BProgram)((Object)object));
String string2 = BProgramModule.toTypeName((BProgram)((Object)object2));
return string.compareTo(string2);
}
});
int n = 0;
while (n < bProgramArray.length) {
xElem2.addContent((XContent)new XElem("p").addAttr("n", BProgramModule.toTypeName(bProgramArray[n])).addAttr("m", this.module.getPreferredSymbol() + '=' + this.module.getModuleName()).addAttr("t", this.module.getPreferredSymbol() + ':' + BProgramModule.toTypeName(bProgramArray[n])));
++n;
}
xElem.addContent((XContent)xElem2);
xElem.write(xWriter);
xWriter.close();
}
WritePaletteStep() {
}
}
static class WriteLexiconStep
extends BuildStep {
/*
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
protected void doStep() throws Exception {
this.interest.nextStep(lex.getText("programModule.lexicon"));
File file = new File(this.module.getBuildRoot(), "module.lexicon");
PrintStream printStream = new PrintStream(new FileOutputStream(file));
try {
printStream.println("#");
printStream.println("# Lexicon auto-generated by the Program Module-Builder");
printStream.println("#");
}
catch (Throwable throwable) {
Object var4_4 = null;
printStream.close();
throw throwable;
}
{
Object var4_5 = null;
printStream.close();
return;
}
}
WriteLexiconStep() {
}
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
static class NiagaraBuildStep
extends BuildStep
implements BConsole.ExecCallback {
String cmd;
int exitCode;
protected synchronized void doStep() throws Exception {
this.interest.nextStep(lex.getText("programModule.nbuild"));
this.cmd = "build \"" + this.module.getBuildRoot() + '\"';
BWidget bWidget = this.interest.getOwner();
if (bWidget != null) {
((BNiagaraWbShell)bWidget.getShell()).openConsole().exec(this.cmd, (BConsole.ExecCallback)this);
this.wait();
if (this.exitCode != 0) {
throw new BuildException(lex.getText("programModule.nbuild.fail"));
}
} else {
throw new IllegalStateException("must be in workbench.");
}
}
public synchronized void consoleExecDone(BConsole bConsole, int n) {
this.exitCode = n;
this.notify();
}
private final /* synthetic */ void this() {
this.exitCode = -1;
}
NiagaraBuildStep() {
this.this();
}
}
}
@@ -0,0 +1,28 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.sys.BajaRuntimeException
*/
package com.tridium.program.module;
import javax.baja.sys.BajaRuntimeException;
public class BuildException
extends BajaRuntimeException {
public BuildException() {
}
public BuildException(Throwable throwable) {
super(throwable);
}
public BuildException(String string) {
super(string);
}
public BuildException(String string, Throwable throwable) {
super(string, throwable);
}
}
@@ -0,0 +1,30 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.program.module;
import com.tridium.program.module.BProgramModule;
import com.tridium.program.module.BuildException;
import com.tridium.program.module.IBuildListener;
public abstract class BuildStep {
protected BProgramModule module;
protected IBuildListener interest;
public final void runStep(BProgramModule bProgramModule, IBuildListener iBuildListener) throws BuildException {
this.module = bProgramModule;
this.interest = iBuildListener;
try {
this.doStep();
}
catch (BuildException buildException) {
throw buildException;
}
catch (Exception exception) {
throw new BuildException("Build failed. " + exception.getMessage(), exception);
}
}
protected abstract void doStep() throws Exception;
}
@@ -0,0 +1,588 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
* javax.baja.sys.Action
* javax.baja.sys.BAction
* javax.baja.sys.BBoolean
* javax.baja.sys.BComplex
* javax.baja.sys.BDouble
* javax.baja.sys.BFloat
* javax.baja.sys.BInteger
* javax.baja.sys.BLink
* javax.baja.sys.BLong
* javax.baja.sys.BString
* javax.baja.sys.BTopic
* javax.baja.sys.BValue
* javax.baja.sys.BajaRuntimeException
* javax.baja.sys.Flags
* javax.baja.sys.Property
* javax.baja.sys.Slot
* javax.baja.sys.SlotCursor
* javax.baja.util.BWsAnnotation
* org.apache.oro.text.perl.Perl5Util
*/
package com.tridium.program.module;
import com.tridium.program.BProgram;
import com.tridium.program.module.BProgramModule;
import com.tridium.program.module.BuildException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.Writer;
import java.util.HashSet;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.Action;
import javax.baja.sys.BAction;
import javax.baja.sys.BBoolean;
import javax.baja.sys.BComplex;
import javax.baja.sys.BDouble;
import javax.baja.sys.BFloat;
import javax.baja.sys.BInteger;
import javax.baja.sys.BLink;
import javax.baja.sys.BLong;
import javax.baja.sys.BString;
import javax.baja.sys.BTopic;
import javax.baja.sys.BValue;
import javax.baja.sys.BajaRuntimeException;
import javax.baja.sys.Flags;
import javax.baja.sys.Property;
import javax.baja.sys.Slot;
import javax.baja.sys.SlotCursor;
import javax.baja.util.BWsAnnotation;
import org.apache.oro.text.perl.Perl5Util;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class ComponentWriter
extends PrintWriter {
private static final int tabWidth = 2;
private String[] predefinedImports;
private BProgram program;
private Class programClass;
private String packageName;
private String compName;
static /* synthetic */ Class class$java$lang$String;
private final void init(BProgram bProgram, String string) {
this.program = bProgram;
try {
this.programClass = bProgram.getCode().newInstance().getClass();
}
catch (Exception exception) {
exception.printStackTrace();
throw new BajaRuntimeException((Throwable)exception);
}
this.packageName = string;
this.compName = BProgramModule.toComponentName(bProgram);
}
public void generate() {
this.writeHeader();
this.writeImports();
this.writeClass();
this.flush();
this.close();
}
protected void writeHeader() {
this.wl("/* Auto-generated by the Program Module-Builder. */");
this.w("package ").w(this.packageName).wl(";");
this.nl();
}
protected void writeImports() {
Object object;
HashSet<String> hashSet = new HashSet<String>();
int n = 0;
while (n < this.predefinedImports.length) {
hashSet.add(this.predefinedImports[n]);
++n;
}
String string = this.program.getCode().getUserDefinedImports();
String[] stringArray = TextUtil.split((String)string, (char)';');
int n2 = 0;
while (n2 < stringArray.length) {
hashSet.add(TextUtil.split((String)stringArray[n2], (char)':')[1] + ".*;");
++n2;
}
SlotCursor slotCursor = this.program.getProperties();
while (slotCursor.next()) {
if (!slotCursor.property().isDynamic()) continue;
object = slotCursor.get().getClass();
hashSet.add(TextUtil.getPackageName((Class)object) + ".*;");
}
object = hashSet.toArray(new String[hashSet.size()]);
int n3 = 0;
while (n3 < ((String[])object).length) {
this.w("import ").wl(object[n3]);
++n3;
}
this.nl();
}
protected void writeClass() {
this.w("public class ").wl(this.compName);
this.tab().wl("extends BComponent implements Runnable");
this.wl("{");
this.writeProperties();
this.writeActions();
this.writeBComponentOverrides();
this.writeRunnable();
this.writeAccess();
this.writeUtils();
this.writeStubs();
this.writeCode();
this.writeType();
this.wl("}");
}
protected void writeType() {
this.section("Type");
this.tab().wl("public Type getType() { return TYPE; }");
this.tab().w("public static final Type TYPE = Sys.loadType(").w(this.compName).w(".class);");
this.nl().nl();
}
protected void writeProperties() {
SlotCursor slotCursor = this.program.getProperties();
while (slotCursor.next()) {
BValue bValue;
Property property = slotCursor.property();
if (property.isFrozen() || (bValue = slotCursor.get().asValue()) instanceof BWsAnnotation || bValue instanceof BLink || bValue instanceof BAction || bValue instanceof BTopic) continue;
if (bValue instanceof BDouble || bValue instanceof BLong) {
throw new BuildException("Property slot type not supported: " + bValue.getType());
}
this.section("Property \"" + property.getName() + '\"');
this.writeNewProperty(property, bValue.isSimple());
this.writeGetSet(property);
}
}
protected final void writeNewProperty(Property property, boolean bl) {
String string = "B" + property.getType().getTypeName();
String string2 = bl ? "(BValue)" + string + ".TYPE.getInstance()" : "new " + string + "()";
this.tab().w("public static final Property ").w(property.getName()).w(" = newProperty(").w(this.flags((Slot)property)).w(", ").w(string2).w(", ").w(this.facets((Slot)property)).w(");").nl().nl();
}
protected final void writeGetSet(Property property) {
CompProperty compProperty = new CompProperty(property);
this.tab().w("public ").w(compProperty.type).w(" ").w(compProperty.getter()).w("() ").w("{ return ").w(compProperty.cast).w("get" + compProperty.postfix).w("(" + compProperty.name() + "); }").nl().nl();
this.tab().w("public void ").w(compProperty.setter()).w("(" + compProperty.type + " v)").w(" { set" + compProperty.postfix + '(' + compProperty.name() + ", v, null); }").nl().nl();
}
protected void writeActions() {
SlotCursor slotCursor = this.program.getActions();
while (slotCursor.next()) {
Action action = slotCursor.action();
CompAction compAction = new CompAction(slotCursor.action());
if (action.isFrozen() && !compAction.name().equals("execute")) continue;
this.section("Action \"" + compAction.name() + '\"');
this.tab().w("public static final Action ").w(compAction.name()).w(" = newAction(").w(this.flags((Slot)action)).w(", ").w(compAction.paramDefault()).w(", ").w(this.facets((Slot)action)).w(");").nl().nl();
this.writeActionInvoke(action);
this.writeActionDelegate(action);
}
}
protected void writeActionInvoke(Action action) {
CompAction compAction = new CompAction(action);
StringBuffer stringBuffer = new StringBuffer().append("public ").append(compAction.returnType()).append(" ").append(compAction.name()).append("(").append(compAction.parameter()).append(")").append("{ ").append(compAction.returnStmt()).append("invoke(").append(compAction.name()).append(", ").append(compAction.invokeParam()).append(", null); }");
this.tab().wl(stringBuffer.toString()).nl();
}
protected void writeActionDelegate(Action action) {
CompAction compAction = new CompAction(action);
this.tab().wl("/** Autogenerated delegate for \"" + compAction.getOn() + "\" */");
this.tab().w("public ").w(compAction.returnType()).w(" " + compAction.getDo()).w("(" + compAction.parameter() + ") throws Exception").nl().tab().wl("{").tab(2).w("try { ").w(compAction.returnStmt()).w(compAction.getOn()).w("(" + compAction.actualParam() + "); }").nl().tab(2).w("catch (Throwable t) { throw new Exception(t); }").nl().tab().wl("}").nl();
}
protected void writeBComponentOverrides() {
this.section("BComponent Overrides");
this.tab().wl("public void started() throws Exception { try { onStart(); } catch(Throwable t) { throw new Exception(t); } }").nl();
this.tab().wl("public void stopped() throws Exception { try { onStop(); } catch(Throwable t) { throw new Exception(t); } }").nl();
this.writeChanged();
}
protected void writeChanged() {
this.tab(1).wl("public void changed(Property prop, Context cx)").tab(1).wl("{").tab(2).wl("super.changed(prop, cx);").tab(2).wl("if (!isRunning()) return;").tab(2).wl("if (Flags.isExecuteOnChange(this, prop)) execute();").tab(1).wl("}").nl();
}
protected final void writeRunnable() {
if (!this.programDeclares("run", null)) {
this.section("Runnable");
this.tab().wl("public void run() { System.out.println(\"Source BProgram did not override run(). Exiting thread.\"); }").nl();
}
}
protected final void writeAccess() {
this.section("Access");
this.tab().wl("public final BComponent getComponent() { return this; }").nl();
this.tab().wl("public final BComponent getProgram() { return this; }").nl();
}
protected final void writeUtils() {
String string = this.program.getCode().getSource();
this.section("Utils");
Class[] classArray = new Class[1];
Class clazz = class$java$lang$String;
if (clazz == null) {
clazz = classArray[0] = (class$java$lang$String = ComponentWriter.class("[Ljava.lang.String;", false));
}
if (!this.programDeclares("print", classArray)) {
this.tab().wl("/** Print a string to standard out without a trailing new-line. */");
this.tab().wl("public void print(String s) { System.out.print(s); System.out.flush(); }").nl();
} else {
this.tab().wl("// print(String s) is overridden by program source.").nl();
}
Class[] classArray2 = new Class[1];
Class clazz2 = class$java$lang$String;
if (clazz2 == null) {
clazz2 = classArray2[0] = (class$java$lang$String = ComponentWriter.class("[Ljava.lang.String;", false));
}
if (!this.programDeclares("println", classArray2)) {
this.tab().wl("/** Print a string to standard out with a trailing new-line. */");
this.tab().wl("public void println(String s) { System.out.println(s); }").nl();
} else {
this.tab().wl("// println(String s) is overridden by program souce.").nl();
}
}
protected final void writeStubs() {
String string = this.program.getCode().getSource();
this.section("ProgramBase Stubs");
if (!this.programDeclares("onStart", null)) {
this.tab().wl("public void onStart() throws Throwable {}").nl();
}
if (!this.programDeclares("onStop", null)) {
this.tab().wl("public void onStop() throws Throwable {}").nl();
}
if (!this.programDeclares("onExecute", null)) {
this.tab().wl("public void onExecute() throws Throwable {}").nl();
}
}
protected void writeCode() {
Perl5Util perl5Util = new Perl5Util();
String string = this.program.getCode().getSource();
StringBuffer stringBuffer = new StringBuffer();
string = perl5Util.substitute("s/BProgram\\./" + this.compName + "./g", string);
this.section("BProgram Source Code");
this.writeSourceLines(string);
}
protected boolean programDeclares(String string, Class[] classArray) {
try {
this.programClass.getDeclaredMethod(string, classArray);
return true;
}
catch (NoSuchMethodException noSuchMethodException) {
return false;
}
}
protected final void writeSourceLines(String string) {
try {
String string2;
BufferedReader bufferedReader = new BufferedReader(new StringReader(string));
while ((string2 = bufferedReader.readLine()) != null) {
this.tab().wl(string2);
}
this.nl();
}
catch (IOException iOException) {
throw new IllegalStateException();
}
}
protected void section(String string) {
this.nl();
this.wl("////////////////////////////////////////////////////////////////");
this.wl("// " + string);
this.wl("////////////////////////////////////////////////////////////////");
this.nl();
}
protected final String flags(Slot slot) {
StringBuffer stringBuffer = new StringBuffer("0");
if (Flags.isAsync((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.ASYNC");
}
if (Flags.isComposite((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.COMPOSITE");
}
if (Flags.isConfirmRequired((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.CONFIRM_REQUIRED");
}
if (Flags.isDefaultOnClone((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.DEFAULT_ON_CLONE");
}
if (Flags.isExecuteOnChange((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.EXECUTE_ON_CHANGE");
}
if (Flags.isFanIn((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.FAN_IN");
}
if (Flags.isHidden((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.HIDDEN");
}
if (Flags.isNoAudit((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.NO_AUDIT");
}
if (Flags.isNoRun((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.NO_RUN");
}
if (Flags.isOperator((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.OPERATOR");
}
if (Flags.isReadonly((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.READONLY");
}
if (Flags.isSummary((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.SUMMARY");
}
if (Flags.isTransient((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.TRANSIENT");
}
if (Flags.isUserDefined1((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.USER_DEFINED_1");
}
if (Flags.isUserDefined2((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.USER_DEFINED_2");
}
if (Flags.isUserDefined3((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.USER_DEFINED_3");
}
if (Flags.isUserDefined4((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.USER_DEFINED_4");
}
return stringBuffer.toString();
}
protected final String facets(Slot slot) {
try {
return slot.getFacets().isNull() ? "null" : "BFacets.tryMake(\"" + slot.getFacets().encodeToString() + "\")";
}
catch (Exception exception) {
throw new BuildException("Failed to create facets. ", exception);
}
}
protected ComponentWriter w(String string) {
this.print(string);
return this;
}
protected ComponentWriter wl(String string) {
this.print(string);
this.print('\n');
return this;
}
protected ComponentWriter nl() {
this.print('\n');
return this;
}
protected ComponentWriter tab() {
return this.tab(1);
}
protected ComponentWriter tab(int n) {
return this.w(TextUtil.getSpaces((int)(n * 2)));
}
protected ComponentWriter sp(int n) {
return this.w(TextUtil.getSpaces((int)n));
}
static /* synthetic */ Class class(String string, boolean bl) {
try {
Class<?> clazz = Class.forName(string);
if (!bl) {
clazz = clazz.getComponentType();
}
return clazz;
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
private final /* synthetic */ void this() {
this.predefinedImports = new String[]{"java.util.*;", "javax.baja.sys.*;", "javax.baja.status.*;", "javax.baja.util.*;", "javax.baja.security.*;"};
}
public ComponentWriter(Writer writer, BProgram bProgram, String string) {
super(writer);
this.this();
this.init(bProgram, string);
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public static class CompProperty {
public Property prop;
String cast;
String postfix;
String type;
String bname;
Class[] setParams;
static /* synthetic */ Class class$java$lang$String;
public String name() {
return this.prop.getName();
}
public String getter() {
return "get" + TextUtil.capitalize((String)this.name());
}
public String setter() {
return "set" + TextUtil.capitalize((String)this.name());
}
public String cast() {
return this.cast;
}
public String postfix() {
return this.postfix;
}
public String type() {
return this.type;
}
public String typeName() {
return this.bname;
}
static /* synthetic */ Class class(String string, boolean bl) {
try {
Class<?> clazz = Class.forName(string);
if (!bl) {
clazz = clazz.getComponentType();
}
return clazz;
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
private final /* synthetic */ void this() {
this.cast = "";
this.postfix = "";
}
public CompProperty(Property property) {
this.this();
this.prop = property;
BValue bValue = property.getDefaultValue();
this.type = this.bname = "B" + bValue.getType().getTypeName();
if (bValue.isSimple()) {
if (bValue instanceof BString) {
this.postfix = "String";
this.type = "String";
Class[] classArray = new Class[1];
Class clazz = class$java$lang$String;
if (clazz == null) {
clazz = class$java$lang$String = CompProperty.class("[Ljava.lang.String;", false);
}
classArray[0] = clazz;
this.setParams = classArray;
} else if (bValue instanceof BBoolean) {
this.type = "boolean";
this.postfix = "Boolean";
this.setParams = new Class[]{Boolean.TYPE};
} else if (bValue instanceof BInteger) {
this.type = "int";
this.postfix = "Int";
this.setParams = new Class[]{Integer.TYPE};
} else if (bValue instanceof BFloat) {
this.type = "float";
this.postfix = "Float";
this.setParams = new Class[]{Float.TYPE};
} else {
this.cast = "(" + this.type + ')';
this.setParams = new Class[]{bValue.getClass()};
}
} else if (bValue.isValue()) {
this.cast = "(" + this.type + ')';
this.setParams = new Class[]{bValue.getClass()};
} else {
throw new IllegalStateException(this.bname + ", " + bValue.getType());
}
}
}
public static class CompAction {
public static final String ACTUAL_PARAM_VAR = "v";
public Action action;
public String name() {
return this.action.getName();
}
public String returnType() {
return this.action.getReturnType() == null ? "void" : "B" + this.action.getReturnType().getTypeName();
}
public String parameter() {
return this.action.getParameterDefault() == null ? "" : this.paramType() + " v";
}
public String paramType() {
return this.action.getParameterType() == null ? null : "B" + this.action.getParameterType().getTypeName();
}
public Class[] paramTypeArray() {
if (this.action.getParameterType() == null) {
return null;
}
return new Class[]{this.action.getParameterType().getInstance().getClass()};
}
public String paramDefault() {
BValue bValue = this.action.getParameterDefault();
if (bValue == null) {
return "null";
}
String string = this.paramType();
if (bValue.isSimple()) {
return "(BValue)" + string + ".TYPE.getInstance()";
}
return "new " + string + "()";
}
public String returnStmt() {
return this.action.getReturnType() == null ? "" : "return (" + this.returnType() + ')';
}
public String invokeParam() {
return this.paramType() == null ? "null" : ACTUAL_PARAM_VAR;
}
public String actualParam() {
return this.action.getParameterType() == null ? "" : ACTUAL_PARAM_VAR;
}
public String getDo() {
return "do" + TextUtil.capitalize((String)this.name());
}
public String getOn() {
return "on" + TextUtil.capitalize((String)this.name());
}
public CompAction(Action action) {
this.action = action;
}
}
}
@@ -0,0 +1,20 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.ui.BWidget
*/
package com.tridium.program.module;
import javax.baja.ui.BWidget;
public interface IBuildListener {
public void setNumBuildSteps(int var1);
public void nextStep(String var1);
public void updateDesc(String var1);
public BWidget getOwner();
}
@@ -0,0 +1,141 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.sys.Property
*/
package com.tridium.program.module;
import com.tridium.program.module.ComponentWriter;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.HashSet;
import javax.baja.sys.Property;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class ReflectUtil {
public static final int OK = 0;
public static final int WARN = 1;
public static final int ERR = 2;
HashMap methodMap = new HashMap();
static /* synthetic */ Class class$javax$baja$sys$BComponent;
public static ReflectUtil getInstance() {
return ReflectUtilHolder.INSTANCE;
}
public int getOverrideStatus(Method method) {
if (!this.isAccessible(method)) {
return 0;
}
return this.getOverrideStatus(method.getName(), method.getParameterTypes());
}
public int getPropertyStatus(Property property) {
ComponentWriter.CompProperty compProperty = new ComponentWriter.CompProperty(property);
if (this.getOverrideStatus(compProperty.getter(), new Class[0]) != 0) {
return 2;
}
if (this.getOverrideStatus(compProperty.setter(), compProperty.setParams) != 0) {
return 2;
}
return 0;
}
public int getOverrideStatus(String string, Class[] classArray) {
HashSet hashSet = (HashSet)this.methodMap.get(string);
if (hashSet == null) {
return 0;
}
Method[] methodArray = hashSet.toArray(new Method[hashSet.size()]);
int n = 0;
while (n < methodArray.length) {
if (this.isSameParameters(classArray, methodArray[n].getParameterTypes())) {
return Modifier.isFinal(methodArray[n].getModifiers()) + 1;
}
++n;
}
return 0;
}
public Class getDeclaringClass(Method method) {
Class[] classArray = method.getParameterTypes();
HashSet hashSet = (HashSet)this.methodMap.get(method.getName());
Method[] methodArray = hashSet.toArray(new Method[hashSet.size()]);
int n = 0;
while (n < methodArray.length) {
if (this.isSameParameters(classArray, methodArray[n].getParameterTypes())) {
return methodArray[n].getDeclaringClass();
}
++n;
}
return null;
}
private final boolean isSameParameters(Class[] classArray, Class[] classArray2) {
if (classArray.length != classArray2.length) {
return false;
}
int n = 0;
while (n < classArray.length) {
if (!classArray[n].equals(classArray2[n])) {
return false;
}
++n;
}
return true;
}
private final boolean isAccessible(Method method) {
int n = method.getModifiers();
boolean bl = false;
if (!Modifier.isStatic(n) && (Modifier.isPublic(n) || Modifier.isProtected(n))) {
bl = true;
}
return bl;
}
static /* synthetic */ Class class(String string, boolean bl) {
try {
Class<?> clazz = Class.forName(string);
if (!bl) {
clazz = clazz.getComponentType();
}
return clazz;
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
protected ReflectUtil() {
Class clazz = class$javax$baja$sys$BComponent;
if (clazz == null) {
clazz = class$javax$baja$sys$BComponent = ReflectUtil.class("[Ljavax.baja.sys.BComponent;", false);
}
Method[] methodArray = clazz.getMethods();
int n = 0;
while (n < methodArray.length) {
String string = methodArray[n].getName();
if (this.isAccessible(methodArray[n])) {
if (this.methodMap.get(string) == null) {
this.methodMap.put(string, new HashSet());
}
HashSet hashSet = (HashSet)this.methodMap.get(string);
hashSet.add(methodArray[n]);
}
++n;
}
}
private static class ReflectUtilHolder {
private static final ReflectUtil INSTANCE = new ReflectUtil();
private ReflectUtilHolder() {
}
}
}
@@ -0,0 +1,329 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.gx.BImage
* javax.baja.naming.SlotPath
* javax.baja.nre.util.Array
* javax.baja.sys.Action
* javax.baja.sys.BDouble
* javax.baja.sys.BIcon
* javax.baja.sys.BLong
* javax.baja.sys.BObject
* javax.baja.sys.BValue
* javax.baja.sys.Property
* javax.baja.ui.table.TableModel
* javax.baja.util.Lexicon
* javax.baja.util.Version
*/
package com.tridium.program.module;
import com.tridium.program.BProgram;
import com.tridium.program.ProgramBase;
import com.tridium.program.module.BProgramModule;
import com.tridium.program.module.ComponentWriter;
import com.tridium.program.module.ReflectUtil;
import com.tridium.program.ui.BProgramEditor;
import java.lang.reflect.Method;
import javax.baja.gx.BImage;
import javax.baja.naming.SlotPath;
import javax.baja.nre.util.Array;
import javax.baja.sys.Action;
import javax.baja.sys.BDouble;
import javax.baja.sys.BIcon;
import javax.baja.sys.BLong;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.Property;
import javax.baja.ui.table.TableModel;
import javax.baja.util.Lexicon;
import javax.baja.util.Version;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public abstract class ValidateModel
extends TableModel {
protected static final Lexicon lex;
public static final BImage okProgramIcon;
public static final BImage errProgramIcon;
public static final BImage warnProgramIcon;
protected static final BImage errIcon;
protected static final BImage warnIcon;
protected Array errs = new Array();
protected Array warns = new Array();
static /* synthetic */ Class class$com$tridium$program$module$BProgramModule;
public static ValidateModel make(BProgram bProgram) {
ValidateProgram validateProgram = new ValidateProgram(bProgram);
((ValidateModel)validateProgram).validate();
return validateProgram;
}
public static ValidateModel make(BProgramModule bProgramModule) {
ValidateModule validateModule = new ValidateModule(bProgramModule);
((ValidateModel)validateModule).validate();
return validateModule;
}
public BImage getProgramStatusIcon() {
if (this.getErrCount() > 0) {
return errProgramIcon;
}
if (this.getWarnCount() > 0) {
return warnProgramIcon;
}
return okProgramIcon;
}
public final int getErrCount() {
return this.errs.size();
}
public final int getWarnCount() {
return this.warns.size();
}
protected abstract void validate();
public void err(String string) {
if (!this.errs.contains((Object)string)) {
this.errs.add((Object)string);
}
}
public void warn(String string) {
if (!this.warns.contains((Object)string)) {
this.warns.add((Object)string);
}
}
public int getColumnCount() {
return 1;
}
public int getRowCount() {
return this.errs.size() + this.warns.size();
}
public Object getValueAt(int n, int n2) {
int n3 = this.getErrCount();
if (n < n3) {
return this.errs.get(n);
}
return this.warns.get(n - n3);
}
public BImage getRowIcon(int n) {
return n < this.getErrCount() ? errIcon : warnIcon;
}
static /* synthetic */ Class class(String string, boolean bl) {
try {
Class<?> clazz = Class.forName(string);
if (!bl) {
clazz = clazz.getComponentType();
}
return clazz;
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
static {
Class clazz = class$com$tridium$program$module$BProgramModule;
if (clazz == null) {
clazz = class$com$tridium$program$module$BProgramModule = ValidateModel.class("[Lcom.tridium.program.module.BProgramModule;", false);
}
lex = Lexicon.make((Class)clazz);
okProgramIcon = BImage.make((BIcon)new BProgram().getIcon());
errProgramIcon = BImage.make((BIcon)BIcon.make((BIcon)new BProgram().getIcon(), (BIcon)BIcon.std((String)"badges/error.png")));
warnProgramIcon = BImage.make((BIcon)BIcon.make((BIcon)new BProgram().getIcon(), (BIcon)BIcon.std((String)"badges/warning.png")));
errIcon = BImage.make((BIcon)BIcon.std((String)"stop.png"));
warnIcon = BImage.make((BIcon)BIcon.std((String)"warning.png"));
}
private static class ValidateProgram
extends ValidateModel {
private static final BProgramEditor pe = new BProgramEditor();
BProgram program;
public String getColumnName(int n) {
return lex.getText("vprogram.col");
}
protected void validate() {
this.checkCompileStatus();
this.checkName();
this.checkLongAndDoubleSlots();
this.checkPropertySlots();
this.checkActionDelegates();
this.checkReflection();
}
public void err(String string) {
super.err("[" + BProgramModule.toTypeName(this.program) + "] " + string);
}
public void warn(String string) {
super.warn("[" + BProgramModule.toTypeName(this.program) + "] " + string);
}
private final void checkCompileStatus() {
pe.loadValue((BObject)this.program);
int n = this.program.getCode().getChecksum();
if (n == 0 || n != pe.computeChecksum(this.program.getCode().getSource())) {
this.err(lex.getText("vprogram.err.outofdate"));
}
}
private final void checkName() {
if (BProgramModule.toComponentName(this.program) == null) {
this.err(lex.getText("vprogram.err.name"));
}
}
private final void checkLongAndDoubleSlots() {
Property[] propertyArray = this.program.getPropertiesArray();
int n = 0;
while (n < propertyArray.length) {
BValue bValue = propertyArray[n].getDefaultValue();
if (bValue instanceof BDouble) {
this.err(lex.getText("vprogram.err.double", new Object[]{propertyArray[n].getName()}));
} else if (bValue instanceof BLong) {
this.err(lex.getText("vprogram.err.long", new Object[]{propertyArray[n].getName()}));
}
++n;
}
}
private final void checkPropertySlots() {
Property[] propertyArray = this.program.getPropertiesArray();
int n = 0;
while (n < propertyArray.length) {
if (ReflectUtil.getInstance().getPropertyStatus(propertyArray[n]) != 0) {
this.err(lex.getText("vprogram.err.getset", new Object[]{propertyArray[n].getName()}));
}
++n;
}
}
private final void checkActionDelegates() {
Class<?> clazz = null;
try {
clazz = this.program.getCode().newInstance().getClass();
}
catch (Exception exception) {
return;
}
Action[] actionArray = this.program.getActionsArray();
int n = 0;
while (n < actionArray.length) {
ComponentWriter.CompAction compAction = new ComponentWriter.CompAction(actionArray[n]);
if (!"onExecute".equals(compAction.getOn())) {
String string = compAction.paramType() == null ? "" : compAction.paramType();
String string2 = compAction.getOn() + '(' + string + ')';
Object[] objectArray = new Object[]{compAction.name(), string2};
try {
Method method = clazz.getDeclaredMethod(compAction.getOn(), compAction.paramTypeArray());
if ((method.getModifiers() & 1) == 0) {
this.err(lex.getText("vprogram.err.delegate.public", objectArray));
}
}
catch (NoSuchMethodException noSuchMethodException) {
this.err(lex.getText("vprogram.err.delegate", objectArray));
}
}
++n;
}
}
private final void checkReflection() {
ProgramBase programBase = this.program.getCode().newProgramInstance();
Method[] methodArray = programBase.getClass().getDeclaredMethods();
ReflectUtil reflectUtil = ReflectUtil.getInstance();
int n = 0;
while (n < methodArray.length) {
switch (reflectUtil.getOverrideStatus(methodArray[n])) {
case 2: {
this.err(lex.getText("vprogram.err.override", new Object[]{this.toMethodDef(methodArray[n])}));
break;
}
case 1: {
if ("toString".equals(methodArray[n].getName())) break;
this.warn(lex.getText("vprogram.warn.override", new Object[]{this.toMethodDef(methodArray[n])}));
break;
}
}
++n;
}
}
private final String toMethodDef(Method method) {
StringBuffer stringBuffer = new StringBuffer().append(ReflectUtil.getInstance().getDeclaringClass(method).getName()).append(".").append(method.getName()).append("(");
Class<?>[] classArray = method.getParameterTypes();
int n = 0;
while (n < classArray.length) {
if (n > 0) {
stringBuffer.append(",");
}
stringBuffer.append(classArray[n].getName());
++n;
}
stringBuffer.append(")");
return stringBuffer.toString();
}
public ValidateProgram(BProgram bProgram) {
this.program = bProgram;
}
}
private static class ValidateModule
extends ValidateModel {
BProgramModule module;
public String getColumnName(int n) {
return lex.getText("vmodule.col");
}
protected void validate() {
this.checkName();
this.checkVendor();
this.checkVersion();
if (this.module.listPrograms().length == 0) {
this.warn(lex.getText("vmodule.warn.noPrograms"));
}
}
private final void checkName() {
if (!SlotPath.isValidName((String)this.module.getModuleName())) {
this.err(lex.getText("vmodule.err.name", new Object[]{this.module.getModuleName()}));
}
}
private final void checkVendor() {
if (this.module.getVendor().length() == 0) {
this.err(lex.getText("vmodule.err.vendor"));
}
}
private final void checkVersion() {
try {
Version version = new Version(this.module.getVendorVersion());
if (version.toString().length() == 0) {
this.err(lex.getText("vmodule.err.verRequired"));
}
}
catch (Exception exception) {
this.err(lex.getText("vmodule.err.version", new Object[]{this.module.getVendorVersion()}));
}
}
public ValidateModule(BProgramModule bProgramModule) {
this.module = bProgramModule;
}
}
}