/* * Decompiled with CFR 0.152. */ package com.tridium.util; import com.tridium.sys.schema.SimpleType; import java.util.HashMap; import java.util.Map; import javax.baja.io.BIContextEncodable; import javax.baja.log.Log; import javax.baja.sys.BSimple; import javax.baja.sys.Context; import javax.baja.sys.Type; /* * Illegal identifiers - consider using --renameillegalidents true */ public class SimpleFactory { static Log log = Log.getLog("sys.schema"); private Map pool; static /* synthetic */ Class class$javax$baja$sys$BSimple; public BSimple make(Type type, String string) throws Exception { return this.make(type, string, null); } public BSimple make(Type type, String string, Context context) throws Exception { Class clazz = class$javax$baja$sys$BSimple; if (clazz == null) { clazz = class$javax$baja$sys$BSimple = SimpleFactory.class("[Ljavax.baja.sys.BSimple;", false); } if (!clazz.isAssignableFrom(type.getTypeClass())) { throw new IllegalStateException(type.toString() + " is not a BSimple."); } String string2 = type.toString(); Entry entry = (Entry)this.pool.get(string2); if (entry == null) { boolean bl; HashMap hashMap; BSimple bSimple; BSimple bSimple2; block14: { bSimple2 = type.getInstance().asSimple(); bSimple = null; bSimple = bSimple instanceof BIContextEncodable ? (BSimple)((BIContextEncodable)((Object)bSimple2)).decodeFromString(string, context) : (BSimple)bSimple2.decodeFromString(string); hashMap = null; bl = false; try { bl = ((SimpleType)type).interningEnabled(); if (bl) { bSimple = bSimple.intern(); } } catch (Exception exception) { bl = false; if (!log.isTraceOn()) break block14; log.trace("Could not intern type " + bSimple.getType() + ". Make sure hashCode() method is overridden."); } } if (!bl) { hashMap = new HashMap(); hashMap.put(string, bSimple); } this.pool.put(string2, new Entry(hashMap, bSimple2, 1)); return bSimple; } ++entry.requests; BSimple bSimple = null; if (entry.typeMap != null) { bSimple = (BSimple)entry.typeMap.get(string); if (bSimple == null) { bSimple = entry.decoder instanceof BIContextEncodable ? (BSimple)((BIContextEncodable)((Object)entry.decoder)).decodeFromString(string, context) : (BSimple)entry.decoder.decodeFromString(string); entry.typeMap.put(string, bSimple); } } else { bSimple = entry.decoder instanceof BIContextEncodable ? (BSimple)((BIContextEncodable)((Object)entry.decoder)).decodeFromString(string, context) : (BSimple)entry.decoder.decodeFromString(string); try { bSimple = bSimple.intern(); } catch (Exception exception) { try { log.warning("Failed to intern type " + bSimple.getType() + " for instance " + bSimple.toString(null), exception); } catch (Exception exception2) {} } } return bSimple; } 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.pool = new HashMap(); } public SimpleFactory() { this.this(); } static class Entry { Map typeMap; BSimple decoder; int requests; Entry(Map map, BSimple bSimple, int n) { this.typeMap = map; this.decoder = bSimple; this.requests = n; } } }