示例#1
0
 /**
  * ** Returns an I18N.Text instance used for lazy localization.<br>
  * ** (use in XML loaders to avoid expression matches when auto-updating
  * 'LocalStrings_XX.properties') ** @param pkg The package name ** @param key The localization key
  * ** @param dft The default localized text ** @param showError If true, a stacktrace will be
  * display if the key is invalid. ** @return An I18N.Text instance used for lazy localization
  */
 public static I18N.Text parseText(String pkg, String key, String dft, boolean showError) {
   if (dft == null) {
     Print.logStackTrace("Default value is null!");
     return new I18N.Text(pkg, key, "");
   } else if (!StringTools.isBlank(key)) {
     return new I18N.Text(pkg, key, dft);
   } else if (!StringTools.startsWithIgnoreCase(dft, I18N_KEY_STARTE)
       && !StringTools.startsWithIgnoreCase(dft, I18N_KEY_STARTC)) {
     if (showError) {
       Print.logStackTrace(
           "Invalid/missing key definition!\n"
               + "Package: "
               + pkg
               + "\n"
               + "Key    : "
               + key
               + "\n"
               + "Default: "
               + dft);
     }
     return new I18N.Text(pkg, null, dft);
   } else {
     int ks = I18N_KEY_STARTE.length();
     int ke = dft.indexOf(I18N_KEY_END, ks);
     if (ke < ks) {
       return new I18N.Text(pkg, null, dft); // ']' is missing, return string as-is
     }
     String k = dft.substring(ks, ke).trim();
     String v = dft.substring(ke + I18N_KEY_END.length()).trim();
     return new I18N.Text(pkg, k, v);
   }
 }
示例#2
0
 public Entry getReferencedEntry() {
   Entry entry = getRuntimeEntry(this.getKey());
   if (entry == null) {
     Print.logStackTrace("Entry reference not found: " + this.getKey());
   }
   return entry;
 }
示例#3
0
 public BodyColumnTemplate getBodyColumnTemplate(DataColumnTemplate dct) {
   if (dct != null) {
     String keyName = dct.getKeyName();
     if (this.bodyColumnMap.containsKey(keyName)) {
       return this.bodyColumnMap.get(keyName);
     } else {
       BodyColumnTemplate bct = this._createBodyColumnTemplate(dct);
       this.bodyColumnMap.put(keyName, bct);
       return bct;
     }
   } else {
     Print.logStackTrace("DataColumnTemplate is null!");
     return null;
   }
 }
示例#4
0
 public HeaderColumnTemplate getHeaderColumnTemplate(DataColumnTemplate dct) {
   if (dct != null) {
     String keyName = dct.getKeyName();
     if (this.headerColumnMap.containsKey(keyName)) {
       return this.headerColumnMap.get(keyName);
     } else {
       HeaderColumnTemplate hct = this._createHeaderColumnTemplate(dct);
       this.headerColumnMap.put(keyName, hct);
       return hct;
     }
   } else {
     Print.logStackTrace("DataColumnTemplate is null!");
     return null;
   }
 }
示例#5
0
 public Entry getRealEntry() {
   if (this.dft instanceof EntryReference) {
     Entry entry = null;
     if (this.ref > 0) {
       Print.logStackTrace("Cyclical EntryReference: " + this.getKey());
       entry = NullEntry;
     } else {
       this.ref++;
       try {
         EntryReference entryRef = (EntryReference) this.dft;
         Entry nextEntry = entryRef.getReferencedEntry(); // <-- will display error, if not found
         entry = (nextEntry != null) ? nextEntry.getRealEntry() : NullEntry;
       } finally {
         this.ref--;
       }
     }
     return entry;
   } else {
     return this;
   }
 }
示例#6
0
  /**
   * ** Gets the DBRecord associated with this key ** @param reload If the record should be reloaded
   * before it is returned ** @return The DBRecord associated with this key
   */
  public gDBR getDBRecord(boolean reload) {
    // returns null if there is an error

    /* create record */
    if (this.record == null) {
      try {
        this.record = DBRecord._createDBRecord(this);
      } catch (DBException dbe) {
        // Implementation error (this should never occur)
        // an NPE will likely follow
        Print.logStackTrace("Implementation error - cant' create DB record", dbe);
        return null;
      }
    }

    /* reload */
    if (reload) {
      // 'reload' is ignored if key does not exist
      this.record.reload();
    }

    /* return record (never null) */
    return this.record;
  }