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,31 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.nre.util.IPAddressUtil
* javax.baja.sys.BSimple
* javax.baja.sys.Context
* javax.baja.sys.LocalizableRuntimeException
*/
package com.tridium.platform.hx.util;
import com.tridium.nre.util.IPAddressUtil;
import com.tridium.platform.hx.util.NotNullStringValidator;
import com.tridium.platform.hx.util.SimpleValidator;
import javax.baja.sys.BSimple;
import javax.baja.sys.Context;
import javax.baja.sys.LocalizableRuntimeException;
public class HostNameValidator
implements SimpleValidator {
public static HostNameValidator INSTANCE = new HostNameValidator();
public void checkValid(String string, BSimple bSimple, Context context) throws Exception {
NotNullStringValidator.INSTANCE.checkValid(string, bSimple, context);
String string2 = bSimple.toString();
if (string2.length() != 0 && !IPAddressUtil.isHostname((String)string2)) {
throw new LocalizableRuntimeException("platform", "validator.error.badHostName", (Object[])new String[]{string});
}
}
}
@@ -0,0 +1,114 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.hx.BHxFieldEditor
* javax.baja.hx.BHxView
* javax.baja.hx.HxOp
* javax.baja.io.HtmlWriter
* javax.baja.naming.OrdTarget
* javax.baja.sys.BBoolean
* javax.baja.sys.BFacets
* javax.baja.sys.BObject
* javax.baja.sys.BValue
* javax.baja.sys.Context
* javax.baja.util.BFormat
*/
package com.tridium.platform.hx.util;
import com.tridium.platform.hx.util.HxViewHelper;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.baja.hx.BHxFieldEditor;
import javax.baja.hx.BHxView;
import javax.baja.hx.HxOp;
import javax.baja.io.HtmlWriter;
import javax.baja.naming.OrdTarget;
import javax.baja.sys.BBoolean;
import javax.baja.sys.BFacets;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.Context;
import javax.baja.util.BFormat;
public class HxBooleanHelper
extends HxViewHelper {
private Map attrs;
public static HxViewHelper makeFE(String string, Context context) {
return HxBooleanHelper.makeFE(string, null, context);
}
public static HxViewHelper makeFE(String string, Map map, Context context) {
return new HxBooleanHelper(string, map == null ? new HashMap() : map, context == null ? BFacets.NULL : context.getFacets());
}
public static HxBooleanHelper makeFE(String string, BValue bValue, BFacets bFacets) {
return new HxBooleanHelper(string, (BHxView)BHxFieldEditor.makeFor((BObject)bValue, (Context)bFacets.getBase()), bFacets);
}
public void write(BObject bObject, HxOp hxOp) throws Exception {
HxOp hxOp2 = hxOp.make(this.fieldName, new OrdTarget((OrdTarget)hxOp, bObject));
hxOp2.mergeFacets(this.facets);
hxOp2.setReadonly(this.isReadonly());
BBoolean bBoolean = (BBoolean)bObject;
HtmlWriter htmlWriter = hxOp2.getHtmlWriter();
String string = BBoolean.toString((boolean)false, (Context)hxOp);
String string2 = BBoolean.toString((boolean)true, (Context)hxOp);
BObject bObject2 = hxOp2.getFacet("trueText");
BObject bObject3 = hxOp2.getFacet("falseText");
if (bObject2 != null) {
string2 = BFormat.format((String)bObject2.toString(), null, (Context)hxOp2);
}
if (bObject3 != null) {
string = BFormat.format((String)bObject3.toString(), null, (Context)hxOp2);
}
htmlWriter.w((Object)"<select ").attr("name", hxOp2.scope("value"));
if (!hxOp2.canWrite()) {
htmlWriter.w((Object)" disabled='disabled'");
}
Iterator iterator = this.attrs.keySet().iterator();
while (iterator.hasNext()) {
Object k = iterator.next();
htmlWriter.w((Object)" ").attr(k.toString(), this.attrs.get(k).toString());
}
htmlWriter.w((Object)">");
htmlWriter.w((Object)"<option value='false'");
if (!bBoolean.getBoolean()) {
htmlWriter.w((Object)" selected='selected'");
}
htmlWriter.w((Object)">").w((Object)string).w((Object)"</option>");
htmlWriter.w((Object)"<option value='true'");
if (bBoolean.getBoolean()) {
htmlWriter.w((Object)" selected='selected'");
}
htmlWriter.w((Object)">").w((Object)string2).w((Object)"</option>");
htmlWriter.w((Object)"</select>");
}
public BObject save(BObject bObject, HxOp hxOp) throws Exception {
HxOp hxOp2 = hxOp.make(this.fieldName, new OrdTarget((OrdTarget)hxOp, bObject));
String string = hxOp2.getFormValue("value");
return string.equals("true") ? BBoolean.TRUE : BBoolean.FALSE;
}
public boolean isFormValueAvailable(HxOp hxOp) {
boolean bl = false;
if (!this.isReadonly() && hxOp.make(this.fieldName, (OrdTarget)hxOp).getFormValue("value") != null) {
bl = true;
}
return bl;
}
protected HxBooleanHelper(String string, Map map, BFacets bFacets) {
super(string, null, bFacets);
this.attrs = map;
}
protected HxBooleanHelper(String string, BHxView bHxView, BFacets bFacets) {
super(string, bHxView, bFacets);
this.attrs = new HashMap();
}
}
@@ -0,0 +1,106 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.hx.HxOp
* javax.baja.io.HtmlWriter
* javax.baja.nre.util.TextUtil
* javax.baja.util.LexiconText
*/
package com.tridium.platform.hx.util;
import com.tridium.platform.hx.util.StringToObjectMap;
import java.util.Map;
import javax.baja.hx.HxOp;
import javax.baja.io.HtmlWriter;
import javax.baja.nre.util.TextUtil;
import javax.baja.util.LexiconText;
public class HxButtonHelper {
private boolean readonly;
private Map attrs;
public static HxButtonHelper makeRefresh() {
StringToObjectMap stringToObjectMap = new StringToObjectMap();
stringToObjectMap.put("onclick", "window.location.reload()");
stringToObjectMap.put("value", LexiconText.make((String)"platform", (String)"HxButtonHelper.refresh"));
stringToObjectMap.put("class", "button");
return new HxButtonHelper(stringToObjectMap);
}
public static HxButtonHelper makeSave() {
return HxButtonHelper.makeSave(null);
}
public static HxButtonHelper makeSave(Map map) {
StringToObjectMap stringToObjectMap = new StringToObjectMap();
stringToObjectMap.put("value", LexiconText.make((String)"platform", (String)"HxButtonHelper.save"));
stringToObjectMap.put("class", "button");
stringToObjectMap.put("type", "submit");
if (map != null) {
stringToObjectMap.putAll(map);
}
return new HxButtonHelper(stringToObjectMap);
}
public static HxButtonHelper make(LexiconText lexiconText) {
return HxButtonHelper.make(lexiconText, null);
}
public static HxButtonHelper make(LexiconText lexiconText, Map map) {
StringToObjectMap stringToObjectMap = new StringToObjectMap();
stringToObjectMap.put("value", lexiconText);
stringToObjectMap.put("class", "button");
if (map != null) {
stringToObjectMap.putAll(map);
}
return new HxButtonHelper(stringToObjectMap);
}
public void setReadonly(boolean bl) {
this.readonly = bl;
}
public boolean isReadonly() {
return this.readonly;
}
public void write(HxOp hxOp) throws Exception {
this.write(hxOp, null);
}
public void write(HxOp hxOp, Map map) throws Exception {
Object object;
HtmlWriter htmlWriter = hxOp.getHtmlWriter();
htmlWriter.w((Object)"<input ");
StringToObjectMap stringToObjectMap = new StringToObjectMap(this.attrs);
if (map != null) {
stringToObjectMap.putAll(map);
}
String string = stringToObjectMap.getString("class", "button");
htmlWriter.w((Object)"class='").w((Object)string).w((Object)"' ");
if (string.equals("button")) {
object = TextUtil.toLowerCase((String)stringToObjectMap.getString("type", "button"));
if (((String)object).equals("submit") && stringToObjectMap.containsKey("onclick")) {
object = "button";
}
htmlWriter.w((Object)"type='").w(object).w((Object)"' ");
}
object = stringToObjectMap.keySet().iterator();
while (object.hasNext()) {
String string2 = (String)object.next();
String string3 = TextUtil.toLowerCase((String)string2);
if (string3.equals("class") || string3.equals("disabled") || string3.equals("type")) continue;
htmlWriter.w((Object)string2).w((Object)"='").w((Object)stringToObjectMap.getString(string2, hxOp)).w((Object)"' ");
}
if (this.isReadonly()) {
htmlWriter.w((Object)"disabled='true' ");
}
htmlWriter.println("/>");
}
protected HxButtonHelper(Map map) {
this.attrs = map;
}
}
@@ -0,0 +1,74 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.gx.BColor
* javax.baja.hx.HxOp
* javax.baja.io.HtmlWriter
* javax.baja.sys.Context
* javax.baja.util.LexiconText
*/
package com.tridium.platform.hx.util;
import javax.baja.gx.BColor;
import javax.baja.hx.HxOp;
import javax.baja.io.HtmlWriter;
import javax.baja.sys.Context;
import javax.baja.util.LexiconText;
public class HxMessageHelper {
public static void addMessage(String string, LexiconText lexiconText, HxOp hxOp) {
HxMessageHelper.addMessage(string, null, lexiconText.getText((Context)hxOp), null, hxOp);
}
public static void appendMessage(String string, LexiconText lexiconText, HxOp hxOp) {
HxMessageHelper.appendMessage(string, lexiconText.getText((Context)hxOp), hxOp);
}
public static void addMessage(String string, String string2, LexiconText lexiconText, HxOp hxOp) {
HxMessageHelper.addMessage(string, string2, lexiconText.getText((Context)hxOp), null, hxOp);
}
public static void addMessage(String string, String string2, HxOp hxOp) {
HxMessageHelper.addMessage(string, null, string2, null, hxOp);
}
public static void appendMessage(String string, String string2, HxOp hxOp) {
String string3 = HxMessageHelper.getSessionAttribute(string, "message", null, hxOp);
string3 = string3 == null ? string2 : string3 + string2;
hxOp.getRequest().getSession().setAttribute(string + ".message", (Object)string3);
}
public static void addMessage(String string, String string2, String string3, BColor bColor, HxOp hxOp) {
hxOp.getRequest().getSession().setAttribute(string + ".message", (Object)string3);
if (string2 != null) {
hxOp.getRequest().getSession().setAttribute(string + ".icon", (Object)string2);
}
if (bColor != null) {
hxOp.getRequest().getSession().setAttribute(string + ".textColor", (Object)bColor.toHtmlString());
}
}
public static boolean writeMessage(String string, HxOp hxOp) throws Exception {
HtmlWriter htmlWriter = hxOp.getHtmlWriter();
String string2 = HxMessageHelper.getSessionAttribute(string, "message", null, hxOp);
String string3 = HxMessageHelper.getSessionAttribute(string, "icon", "local:|module://icons/x16/info.png", hxOp);
String string4 = HxMessageHelper.getSessionAttribute(string, "textColor", "#FF0000", hxOp);
if (string2 == null) {
return false;
}
htmlWriter.w((Object)"<div style='border-bottom: 1px solid black; padding:5px; background:#ccc; font-weight: bold; color:").w((Object)string4).w((Object)";'><img alt='' src='").w((Object)string3).w((Object)"'/>&nbsp;").w((Object)string2).w((Object)"</div>");
return true;
}
protected static String getSessionAttribute(String string, String string2, String string3, HxOp hxOp) {
String string4 = string + '.' + string2;
String string5 = (String)hxOp.getRequest().getSession().getAttribute(string4);
if (string5 == null) {
return string3;
}
hxOp.getRequest().getSession().removeAttribute(string4);
return string5;
}
}
@@ -0,0 +1,71 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.hx.BHxFieldEditor
* javax.baja.hx.BHxView
* javax.baja.hx.HxOp
* javax.baja.nre.util.Array
* javax.baja.sys.BFacets
* javax.baja.sys.BObject
* javax.baja.sys.BSimple
* javax.baja.sys.Context
*/
package com.tridium.platform.hx.util;
import com.tridium.platform.hx.util.HxViewHelper;
import com.tridium.platform.hx.util.SimpleValidator;
import javax.baja.hx.BHxFieldEditor;
import javax.baja.hx.BHxView;
import javax.baja.hx.HxOp;
import javax.baja.nre.util.Array;
import javax.baja.sys.BFacets;
import javax.baja.sys.BObject;
import javax.baja.sys.BSimple;
import javax.baja.sys.Context;
public class HxSimpleViewHelper
extends HxViewHelper {
protected Array validators;
public static HxSimpleViewHelper makeFE(String string, BSimple bSimple, SimpleValidator simpleValidator, Context context) {
return HxSimpleViewHelper.makeFE(string, bSimple, new SimpleValidator[]{simpleValidator}, context);
}
public static HxSimpleViewHelper makeFE(String string, BSimple bSimple, SimpleValidator[] simpleValidatorArray, Context context) {
return new HxSimpleViewHelper(string, (BHxView)BHxFieldEditor.makeFor((BObject)bSimple, (Context)context), simpleValidatorArray == null ? new SimpleValidator[]{} : simpleValidatorArray, context == null ? BFacets.NULL : context.getFacets());
}
public static HxSimpleViewHelper makeFE(String string, BSimple bSimple, Context context) {
return HxSimpleViewHelper.makeFE(string, bSimple, null, context);
}
public void addValidator(SimpleValidator simpleValidator) {
this.validators.add((Object)simpleValidator);
}
public BObject save(BObject bObject, HxOp hxOp) throws Exception {
BSimple bSimple = (BSimple)super.save(bObject, hxOp);
int n = 0;
while (n < this.validators.size()) {
((SimpleValidator)this.validators.get(n)).checkValid(this.fieldName, bSimple, (Context)hxOp);
++n;
}
return bSimple;
}
public void validate(BObject bObject, HxOp hxOp) throws Exception {
BSimple bSimple = (BSimple)super.save(bObject, hxOp);
int n = 0;
while (n < this.validators.size()) {
((SimpleValidator)this.validators.get(n)).checkValid(this.fieldName, bSimple, (Context)hxOp);
++n;
}
}
protected HxSimpleViewHelper(String string, BHxView bHxView, SimpleValidator[] simpleValidatorArray, BFacets bFacets) {
super(string, bHxView, bFacets);
this.validators = new Array((Object[])simpleValidatorArray);
}
}
@@ -0,0 +1,114 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.hx.HxOp
* javax.baja.io.HtmlWriter
* javax.baja.naming.OrdTarget
* javax.baja.sys.BFacets
* javax.baja.sys.BObject
* javax.baja.sys.BSimple
* javax.baja.sys.BString
* javax.baja.sys.Context
*/
package com.tridium.platform.hx.util;
import com.tridium.platform.hx.util.HxSimpleViewHelper;
import com.tridium.platform.hx.util.HxViewHelper;
import com.tridium.platform.hx.util.SimpleValidator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.baja.hx.HxOp;
import javax.baja.io.HtmlWriter;
import javax.baja.naming.OrdTarget;
import javax.baja.sys.BFacets;
import javax.baja.sys.BObject;
import javax.baja.sys.BSimple;
import javax.baja.sys.BString;
import javax.baja.sys.Context;
public class HxStringHelper
extends HxSimpleViewHelper {
private Map attrs;
public static HxViewHelper makeFE(String string, Context context) {
return HxStringHelper.makeFE(string, null, null, context);
}
public static HxViewHelper makeFE(String string, SimpleValidator simpleValidator, Context context) {
return HxStringHelper.makeFE(string, null, new SimpleValidator[]{simpleValidator}, context);
}
public static HxViewHelper makeFE(String string, SimpleValidator[] simpleValidatorArray, Context context) {
return HxStringHelper.makeFE(string, null, simpleValidatorArray, context);
}
public static HxViewHelper makeFE(String string, Map map, Context context) {
return HxStringHelper.makeFE(string, map, null, context);
}
public static HxViewHelper makeFE(String string, Map map, SimpleValidator simpleValidator, Context context) {
return HxStringHelper.makeFE(string, map, new SimpleValidator[]{simpleValidator}, context);
}
public static HxViewHelper makeFE(String string, Map map, SimpleValidator[] simpleValidatorArray, Context context) {
return new HxStringHelper(string, map == null ? new HashMap() : map, simpleValidatorArray == null ? new SimpleValidator[]{} : simpleValidatorArray, context == null ? BFacets.NULL : context.getFacets());
}
public void write(BObject bObject, HxOp hxOp) throws Exception {
HxOp hxOp2 = hxOp.make(this.fieldName, new OrdTarget((OrdTarget)hxOp, bObject));
hxOp2.mergeFacets(this.facets);
hxOp2.setReadonly(this.isReadonly());
BString bString = (BString)bObject;
HtmlWriter htmlWriter = hxOp2.getHtmlWriter();
int n = hxOp2.getFacets().geti("fieldWidth", 40);
htmlWriter.w((Object)"<input type='text' size='").w(n).w((Object)"'");
if (this.isReadonly() || !hxOp.canWrite()) {
htmlWriter.w((Object)" disabled='disabled'");
}
Iterator iterator = this.attrs.keySet().iterator();
while (iterator.hasNext()) {
Object k = iterator.next();
htmlWriter.w((Object)" ").attr(k.toString(), this.attrs.get(k).toString());
}
htmlWriter.w((Object)" ").attr("name", hxOp2.scope("value"));
htmlWriter.w((Object)" ").attr("value", bString.getString());
htmlWriter.w((Object)"/>");
}
public boolean isFormValueAvailable(HxOp hxOp) {
boolean bl = false;
if (!this.isReadonly() && hxOp.make(this.fieldName, (OrdTarget)hxOp).getFormValue("value") != null) {
bl = true;
}
return bl;
}
public BObject save(BObject bObject, HxOp hxOp) throws Exception {
HxOp hxOp2 = hxOp.make(this.fieldName, new OrdTarget((OrdTarget)hxOp, bObject));
BString bString = BString.make((String)hxOp2.getFormValue("value"));
int n = 0;
while (n < this.validators.size()) {
((SimpleValidator)this.validators.get(n)).checkValid(this.fieldName, (BSimple)bString, (Context)hxOp);
++n;
}
return bString;
}
public void validate(BObject bObject, HxOp hxOp) throws Exception {
HxOp hxOp2 = hxOp.make(this.fieldName, new OrdTarget((OrdTarget)hxOp, bObject));
BString bString = BString.make((String)hxOp2.getFormValue("value"));
int n = 0;
while (n < this.validators.size()) {
((SimpleValidator)this.validators.get(n)).checkValid(this.fieldName, (BSimple)bString, (Context)hxOp);
++n;
}
}
protected HxStringHelper(String string, Map map, SimpleValidator[] simpleValidatorArray, BFacets bFacets) {
super(string, null, simpleValidatorArray, bFacets);
this.attrs = map;
}
}
@@ -0,0 +1,120 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.hx.BHxFieldEditor
* javax.baja.hx.BHxView
* javax.baja.hx.HxOp
* javax.baja.naming.OrdTarget
* javax.baja.naming.SlotPath
* javax.baja.nre.util.Array
* javax.baja.nre.util.TextUtil
* javax.baja.sys.BComponent
* javax.baja.sys.BFacets
* javax.baja.sys.BObject
* javax.baja.sys.BSimple
* javax.baja.sys.BString
* javax.baja.sys.BValue
* javax.baja.sys.Context
* javax.baja.sys.SlotCursor
*/
package com.tridium.platform.hx.util;
import com.tridium.platform.hx.util.HxViewHelper;
import com.tridium.platform.hx.util.SimpleValidator;
import javax.baja.hx.BHxFieldEditor;
import javax.baja.hx.BHxView;
import javax.baja.hx.HxOp;
import javax.baja.naming.OrdTarget;
import javax.baja.naming.SlotPath;
import javax.baja.nre.util.Array;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.BComponent;
import javax.baja.sys.BFacets;
import javax.baja.sys.BObject;
import javax.baja.sys.BSimple;
import javax.baja.sys.BString;
import javax.baja.sys.BValue;
import javax.baja.sys.Context;
import javax.baja.sys.SlotCursor;
public class HxStringListHelper
extends HxViewHelper {
private Array itemValidators;
public static HxViewHelper makeFE(String string, Context context) {
return HxStringListHelper.makeFE(string, null, context);
}
public static HxViewHelper makeFE(String string, SimpleValidator simpleValidator, Context context) {
return HxStringListHelper.makeFE(string, new SimpleValidator[]{simpleValidator}, context);
}
public static HxViewHelper makeFE(String string, SimpleValidator[] simpleValidatorArray, Context context) {
return new HxStringListHelper(string, simpleValidatorArray == null ? new SimpleValidator[]{} : simpleValidatorArray, context);
}
public void addItemValidator(SimpleValidator simpleValidator) {
this.itemValidators.add((Object)simpleValidator);
}
public void write(BObject bObject, HxOp hxOp) throws Exception {
StringBuffer stringBuffer = new StringBuffer();
SlotCursor slotCursor = ((BComponent)bObject).loadSlots().getProperties();
while (slotCursor.next()) {
if (stringBuffer.length() > 0) {
stringBuffer.append(',');
}
stringBuffer.append(slotCursor.get().toString());
}
super.write((BObject)BString.make((String)stringBuffer.toString()), hxOp);
}
public BObject save(BObject bObject, HxOp hxOp) throws Exception {
BString bString = (BString)super.save(bObject, hxOp);
String[] stringArray = TextUtil.splitAndTrim((String)bString.toString(), (char)',');
BComponent bComponent = (BComponent)bObject;
bComponent.removeAll();
int n = 0;
while (n < stringArray.length) {
BString bString2 = BString.make((String)stringArray[n]);
int n2 = 0;
while (n2 < this.itemValidators.size()) {
((SimpleValidator)this.itemValidators.get(n2)).checkValid(this.fieldName, (BSimple)bString2, (Context)hxOp);
++n2;
}
bComponent.add(SlotPath.escape((String)stringArray[n]), (BValue)bString2);
++n;
}
return bComponent;
}
public boolean isFormValueAvailable(HxOp hxOp) {
boolean bl = false;
if (!this.isReadonly() && hxOp.make(this.fieldName, (OrdTarget)hxOp).getFormValue("value") != null) {
bl = true;
}
return bl;
}
public void validate(BObject bObject, HxOp hxOp) throws Exception {
BString bString = (BString)super.save(bObject, hxOp);
String[] stringArray = TextUtil.splitAndTrim((String)bString.toString(), (char)',');
int n = 0;
while (n < stringArray.length) {
BString bString2 = BString.make((String)stringArray[n]);
int n2 = 0;
while (n2 < this.itemValidators.size()) {
((SimpleValidator)this.itemValidators.get(n2)).checkValid(this.fieldName, (BSimple)bString2, (Context)hxOp);
++n2;
}
++n;
}
}
protected HxStringListHelper(String string, SimpleValidator[] simpleValidatorArray, Context context) {
super(string, (BHxView)BHxFieldEditor.makeFor((BObject)BString.DEFAULT, (Context)context), context == null ? BFacets.NULL : context.getFacets());
this.itemValidators = new Array((Object[])simpleValidatorArray);
}
}
@@ -0,0 +1,119 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.hx.HxOp
* javax.baja.io.HtmlWriter
* javax.baja.naming.OrdTarget
* javax.baja.nre.util.Array
* javax.baja.sys.BFacets
* javax.baja.sys.BObject
* javax.baja.sys.Context
* javax.baja.timezone.BTimeZone
* javax.baja.timezone.TimeZoneDatabase
*/
package com.tridium.platform.hx.util;
import com.tridium.platform.hx.util.HxViewHelper;
import com.tridium.platform.timezone.TimeZoneUtil;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.baja.hx.HxOp;
import javax.baja.io.HtmlWriter;
import javax.baja.naming.OrdTarget;
import javax.baja.nre.util.Array;
import javax.baja.sys.BFacets;
import javax.baja.sys.BObject;
import javax.baja.sys.Context;
import javax.baja.timezone.BTimeZone;
import javax.baja.timezone.TimeZoneDatabase;
public class HxTimeZoneHelper
extends HxViewHelper {
private static BTimeZone[] sortedTimeZones = null;
private BTimeZone[] zones;
private Map attrs;
public static HxViewHelper makeFE(String string, Map map, Context context) {
return HxTimeZoneHelper.makeFE(string, map, HxTimeZoneHelper.getSortedTimeZones(), context);
}
public static HxViewHelper makeFE(String string, Context context) {
return HxTimeZoneHelper.makeFE(string, new HashMap(), HxTimeZoneHelper.getSortedTimeZones(), context);
}
public static HxViewHelper makeFE(String string, BTimeZone[] bTimeZoneArray, Context context) {
return HxTimeZoneHelper.makeFE(string, new HashMap(), bTimeZoneArray, context);
}
public static HxViewHelper makeFE(String string, Map map, BTimeZone[] bTimeZoneArray, Context context) {
return new HxTimeZoneHelper(string, map, bTimeZoneArray, context == null ? BFacets.NULL : context.getFacets());
}
private static final BTimeZone[] getSortedTimeZones() {
if (sortedTimeZones == null) {
Object[] objectArray = TimeZoneDatabase.get().getTimeZones();
Array array = new Array(objectArray);
array = array.sort(TimeZoneUtil.TZ_COMPARATOR);
sortedTimeZones = (BTimeZone[])array.trim();
}
return sortedTimeZones;
}
public void write(BObject bObject, HxOp hxOp) throws Exception {
HtmlWriter htmlWriter = hxOp.getHtmlWriter();
htmlWriter.w((Object)"<select name='").w((Object)hxOp.scope(this.fieldName)).w((Object)"' ");
if (this.isReadonly()) {
htmlWriter.w((Object)" disabled='disabled'");
}
Iterator iterator = this.attrs.keySet().iterator();
while (iterator.hasNext()) {
Object k = iterator.next();
htmlWriter.w((Object)" ").attr(k.toString(), this.attrs.get(k).toString());
}
htmlWriter.w((Object)"'>");
int n = 0;
while (n < this.zones.length) {
htmlWriter.w((Object)"<option value='").w((Object)this.zones[n].getId()).w((Object)"'");
if (bObject.equals((Object)this.zones[n])) {
htmlWriter.w((Object)" selected='selected'");
}
if (this.isReadonly() || !hxOp.canWrite()) {
htmlWriter.w((Object)" disabled='disabled'");
}
htmlWriter.w((Object)">");
htmlWriter.w((Object)this.zones[n]);
htmlWriter.w((Object)"</option>");
++n;
}
htmlWriter.w((Object)"</select>");
}
public BObject save(BObject bObject, HxOp hxOp) throws Exception {
String string = hxOp.getFormValue(this.fieldName);
int n = 0;
while (n < this.zones.length) {
if (this.zones[n].getId().equals(string)) {
return this.zones[n];
}
++n;
}
return null;
}
public boolean isFormValueAvailable(HxOp hxOp) {
boolean bl = false;
if (!this.isReadonly() && hxOp.make(this.fieldName, (OrdTarget)hxOp).getFormValue("value") != null) {
bl = true;
}
return bl;
}
protected HxTimeZoneHelper(String string, Map map, BTimeZone[] bTimeZoneArray, BFacets bFacets) {
super(string, null, bFacets);
this.zones = bTimeZoneArray;
this.attrs = map;
}
}
@@ -0,0 +1,74 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.hx.BHxFieldEditor
* javax.baja.hx.BHxView
* javax.baja.hx.HxOp
* javax.baja.naming.OrdTarget
* javax.baja.sys.BFacets
* javax.baja.sys.BObject
* javax.baja.sys.Context
*/
package com.tridium.platform.hx.util;
import javax.baja.hx.BHxFieldEditor;
import javax.baja.hx.BHxView;
import javax.baja.hx.HxOp;
import javax.baja.naming.OrdTarget;
import javax.baja.sys.BFacets;
import javax.baja.sys.BObject;
import javax.baja.sys.Context;
public class HxViewHelper {
protected BHxView view;
protected String fieldName;
protected BFacets facets;
protected boolean readonly;
public static HxViewHelper make(String string, BHxView bHxView, Context context) {
return new HxViewHelper(string, bHxView, null);
}
public static HxViewHelper makeFE(String string, BObject bObject, Context context) {
return new HxViewHelper(string, (BHxView)BHxFieldEditor.makeFor((BObject)bObject, (Context)context), context == null ? BFacets.NULL : context.getFacets());
}
public void write(BObject bObject, HxOp hxOp) throws Exception {
HxOp hxOp2 = hxOp.make(this.fieldName, new OrdTarget((OrdTarget)hxOp, bObject));
hxOp2.mergeFacets(this.facets);
hxOp2.setReadonly(this.isReadonly());
this.view.write(hxOp2);
}
public BObject save(BObject bObject, HxOp hxOp) throws Exception {
HxOp hxOp2 = hxOp.make(this.fieldName, new OrdTarget((OrdTarget)hxOp, bObject));
return this.view.save(hxOp2);
}
public void validate(BObject bObject, HxOp hxOp) throws Exception {
}
public boolean isFormValueAvailable(HxOp hxOp) {
throw new UnsupportedOperationException(this.getClass().getName() + ".isFormValueAvailable(HxOp) " + this.fieldName);
}
public boolean isReadonly() {
return this.readonly;
}
public void setReadonly(boolean bl) {
this.readonly = bl;
}
public String getFieldName() {
return this.fieldName;
}
protected HxViewHelper(String string, BHxView bHxView, BFacets bFacets) {
this.fieldName = string;
this.view = bHxView;
this.facets = bFacets == null ? BFacets.NULL : bFacets;
}
}
@@ -0,0 +1,31 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.sys.BSimple
* javax.baja.sys.BString
* javax.baja.sys.Context
* javax.baja.sys.LocalizableRuntimeException
*/
package com.tridium.platform.hx.util;
import com.tridium.platform.hx.util.SimpleValidator;
import javax.baja.sys.BSimple;
import javax.baja.sys.BString;
import javax.baja.sys.Context;
import javax.baja.sys.LocalizableRuntimeException;
public class NotNullStringValidator
implements SimpleValidator {
public static NotNullStringValidator INSTANCE = new NotNullStringValidator();
public void checkValid(String string, BSimple bSimple, Context context) throws Exception {
if (bSimple == null || ((BString)bSimple).toString().trim().length() == 0) {
throw new LocalizableRuntimeException("platform", "validator.error.notNull", (Object[])new String[]{string});
}
}
private NotNullStringValidator() {
}
}
@@ -0,0 +1,16 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.sys.BSimple
* javax.baja.sys.Context
*/
package com.tridium.platform.hx.util;
import javax.baja.sys.BSimple;
import javax.baja.sys.Context;
public interface SimpleValidator {
public void checkValid(String var1, BSimple var2, Context var3) throws Exception;
}
@@ -0,0 +1,116 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
* javax.baja.sys.BObject
* javax.baja.sys.Context
* javax.baja.util.LexiconText
*/
package com.tridium.platform.hx.util;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.BObject;
import javax.baja.sys.Context;
import javax.baja.util.LexiconText;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class StringToObjectMap
extends HashMap {
private HashSet originalKeys;
public boolean containsKey(Object object) {
return super.containsKey(TextUtil.toLowerCase((String)((String)object)));
}
public Object get(Object object) {
return super.get(TextUtil.toLowerCase((String)((String)object)));
}
public Object put(Object object, Object object2) {
this.originalKeys.add((String)object);
return super.put(TextUtil.toLowerCase((String)((String)object)), object2);
}
public void putAll(Map map) {
if (map == null) {
return;
}
Iterator iterator = map.keySet().iterator();
while (iterator.hasNext()) {
String string = (String)iterator.next();
this.put(string, map.get(string));
}
}
public Set keySet() {
return (Set)this.originalKeys.clone();
}
public void clear() {
super.clear();
this.originalKeys.clear();
}
public Object remove(Object object) {
String string = TextUtil.toLowerCase((String)((String)object));
Iterator iterator = this.originalKeys.iterator();
while (iterator.hasNext()) {
String string2 = (String)iterator.next();
if (!string.equals(TextUtil.toLowerCase((String)string2))) continue;
this.originalKeys.remove(string2);
return super.remove(string);
}
return null;
}
public String getString(String string, Object object) {
return this.getString(string, object, null);
}
public String getString(String string, Object object, Context context) {
String string2 = TextUtil.toLowerCase((String)string);
return super.containsKey(string2) ? this.getString(super.get(string2), context) : this.getString(object, context);
}
private final String getString(Object object, Context context) {
if (object instanceof LexiconText) {
return ((LexiconText)object).getText(context);
}
if (object instanceof BObject) {
return ((BObject)object).toString(context);
}
return String.valueOf(object);
}
private final /* synthetic */ void this() {
this.originalKeys = new HashSet();
}
public StringToObjectMap() {
this.this();
}
public StringToObjectMap(int n) {
super(n);
this.this();
}
public StringToObjectMap(int n, float f) {
super(n, f);
this.this();
}
public StringToObjectMap(Map map) {
this.this();
this.putAll(map);
}
}
@@ -0,0 +1,75 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.nre.util.IPAddressUtil
* javax.baja.sys.BSimple
* javax.baja.sys.Context
* javax.baja.sys.LocalizableRuntimeException
*/
package com.tridium.platform.hx.util;
import com.tridium.nre.util.IPAddressUtil;
import com.tridium.platform.hx.util.NotNullStringValidator;
import com.tridium.platform.hx.util.SimpleValidator;
import javax.baja.sys.BSimple;
import javax.baja.sys.Context;
import javax.baja.sys.LocalizableRuntimeException;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class TcpIpAddressValidator
implements SimpleValidator {
public static TcpIpAddressValidator INSTANCE = new TcpIpAddressValidator(false, false);
public static TcpIpAddressValidator INSTANCE_SUBNET = new TcpIpAddressValidator(false, false, true);
public static TcpIpAddressValidator INSTANCEv6 = new TcpIpAddressValidator(true, false);
public static TcpIpAddressValidator INSTANCE_PERMIT_NULL = new TcpIpAddressValidator(false, true);
public static TcpIpAddressValidator INSTANCEv6_PERMIT_NULL = new TcpIpAddressValidator(true, true);
private boolean isIpv6;
private boolean allowNull;
private boolean isSubnet;
public void checkValid(String string, BSimple bSimple, Context context) throws Exception {
if (!this.allowNull) {
NotNullStringValidator.INSTANCE.checkValid(string, bSimple, context);
}
String string2 = bSimple.toString();
if (this.allowNull && string2.length() == 0) {
return;
}
if (!this.isIpv6) {
if (!this.isSubnet) {
if (!IPAddressUtil.isIpv4Address((String)string2)) {
throw new LocalizableRuntimeException("platform", "validator.error.badIpAddress", (Object[])new String[]{string});
}
} else if (!IPAddressUtil.isIpv4SubnetMask((String)string2)) {
throw new LocalizableRuntimeException("platform", "validator.error.badSubnetMask", (Object[])new String[]{string});
}
} else if (!IPAddressUtil.isIpv6Address((String)string2)) {
throw new LocalizableRuntimeException("platform", "validator.error.badIpv6Address", (Object[])new String[]{string});
}
}
private final /* synthetic */ void this() {
this.isIpv6 = false;
this.allowNull = false;
this.isSubnet = false;
}
private TcpIpAddressValidator() {
this(false, false);
}
private TcpIpAddressValidator(boolean bl, boolean bl2) {
this(bl, bl2, false);
}
private TcpIpAddressValidator(boolean bl, boolean bl2, boolean bl3) {
this.this();
this.isIpv6 = bl;
this.allowNull = bl2;
this.isSubnet = bl3;
}
}