Example #1
0
 /**
  * Set up the default screen control for this field.
  *
  * @param itsLocation Location of this component on screen (ie., GridBagConstraint).
  * @param targetScreen Where to place this component (ie., Parent screen or GridBagLayout).
  * @param converter The converter to set the screenfield to.
  * @param iDisplayFieldDesc Display the label? (optional).
  * @param properties Extra properties
  * @return Return the component or ScreenField that is created for this field.
  */
 public ScreenComponent setupDefaultView(
     ScreenLoc itsLocation,
     ComponentParent targetScreen,
     Convert converter,
     int iDisplayFieldDesc,
     Map<String, Object> properties) {
   if (targetScreen != null) {
     Record recCurrencys =
         (Record) Utility.getRecordOwner(targetScreen).getRecord(Currencys.CURRENCYS_FILE);
     if (recCurrencys != null) {
       BaseField fldCurrencyCode = recCurrencys.getField(Currencys.CURRENCY_CODE);
       Converter conv =
           new FieldDescConverter(
               fldCurrencyCode, (Converter) converter); // Use the description for this field
       ScreenComponent sfCurrency =
           createScreenComponent(
               ScreenModel.EDIT_TEXT,
               itsLocation,
               targetScreen,
               conv,
               iDisplayFieldDesc,
               properties);
       sfCurrency.setEnabled(false);
       itsLocation =
           targetScreen.getNextLocation(
               ScreenConstants.RIGHT_OF_LAST, ScreenConstants.DONT_SET_ANCHOR);
       iDisplayFieldDesc = ScreenConstants.DONT_DISPLAY_DESC; // Display it only once
     }
   }
   return super.setupDefaultView(
       itsLocation, targetScreen, converter, iDisplayFieldDesc, properties);
 }
Example #2
0
 /** Make a default screen. */
 public ScreenParent makeScreen(
     ScreenLoc itsLocation,
     ComponentParent parentScreen,
     int iDocMode,
     Map<String, Object> properties) {
   ScreenParent screen = null;
   if ((iDocMode & ScreenConstants.MAINT_MODE) == ScreenConstants.MAINT_MODE)
     screen =
         Record.makeNewScreen(
             COUNTRY_SCREEN_CLASS,
             itsLocation,
             parentScreen,
             iDocMode | ScreenConstants.DONT_DISPLAY_FIELD_DESC,
             properties,
             this,
             true);
   else if ((iDocMode & ScreenConstants.DISPLAY_MODE) == ScreenConstants.DISPLAY_MODE)
     screen =
         Record.makeNewScreen(
             COUNTRY_GRID_SCREEN_CLASS,
             itsLocation,
             parentScreen,
             iDocMode | ScreenConstants.DONT_DISPLAY_FIELD_DESC,
             properties,
             this,
             true);
   else screen = super.makeScreen(itsLocation, parentScreen, iDocMode, properties);
   return screen;
 }
Example #3
0
 /**
  * Adds a record to the Zone
  *
  * @param r The record to be added
  * @see Record
  */
 public void addRecord(Record r) {
   Name name = r.getName();
   short type = r.getRRsetType();
   RRset rrset = (RRset) findExactSet(name, type);
   if (rrset == null) addSet(name, type, rrset = new RRset());
   rrset.addRR(r);
 }
  /**
   * Builds a new Record from its textual representation
   *
   * @param name The owner name of the record.
   * @param type The record's type.
   * @param dclass The record's class.
   * @param ttl The record's time to live.
   * @param st A tokenizer containing the textual representation of the rdata.
   * @param origin The default origin to be appended to relative domain names.
   * @return The new record
   * @throws IOException The text format was invalid.
   */
  public static Record fromString(
      Name name, int type, int dclass, long ttl, Tokenizer st, Name origin) throws IOException {
    Record rec;

    if (!name.isAbsolute()) throw new RelativeNameException(name);
    Type.check(type);
    DClass.check(dclass);
    TTL.check(ttl);

    Tokenizer.Token t = st.get();
    if (t.type == Tokenizer.IDENTIFIER && t.value.equals("\\#")) {
      int length = st.getUInt16();
      byte[] data = st.getHex();
      if (data == null) {
        data = new byte[0];
      }
      if (length != data.length)
        throw st.exception("invalid unknown RR encoding: " + "length mismatch");
      DNSInput in = new DNSInput(data);
      return newRecord(name, type, dclass, ttl, length, in);
    }
    st.unget();
    rec = getEmptyRecord(name, type, dclass, ttl, true);
    rec.rdataFromString(st, origin);
    t = st.get();
    if (t.type != Tokenizer.EOL && t.type != Tokenizer.EOF) {
      throw st.exception("unexpected tokens at end of record");
    }
    return rec;
  }
  // FIXME: fails!  needs MarcCombiningReader for mhld or at least a diff version of RawRecordReader
  @Test
  public void testMultMHLDsWithSameID() throws IOException {
    // bib134, multMhlds1
    String bibFilePath = testDataParentPath + File.separator + "mhldMergeBibs134.mrc";
    String mhldFilePath = testDataParentPath + File.separator + "mhldMergeMhlds1Mult.mrc";
    Map<String, Record> mergedRecs =
        MergeSummaryHoldings.mergeMhldsIntoBibRecordsAsMap(bibFilePath, mhldFilePath);

    Record mergedRec = mergedRecs.get("a1");
    assertEquals("Expected three 852", 3, mergedRec.getVariableFields("852").size());
    Set<String> expectedVals = new HashSet<String>();
    expectedVals.add("Location1");
    expectedVals.add("Location2");
    RecordTestingUtils.assertSubfieldHasExpectedValues(mergedRec, "852", 'b', expectedVals);

    expectedVals.clear();
    expectedVals.add("(month)");
    expectedVals.add("(season)");
    RecordTestingUtils.assertSubfieldHasExpectedValues(mergedRec, "853", 'b', expectedVals);

    assertEquals("Expected one 863", 2, mergedRec.getVariableFields("863").size());
    assertEquals("Expected one 866", 1, mergedRec.getVariableFields("866").size());
    // fail("Implement me");
    System.out.println("Test testMultMHLDsWithSameID() successful");
  }
Example #6
0
  /* Returns the number of records not successfully rendered. */
  private int sectionToWire(DNSOutput out, int section, Compression c, int maxLength) {
    int n = sections[section].size();
    int pos = out.current();
    int rendered = 0;
    int skipped = 0;
    Record lastrec = null;

    for (int i = 0; i < n; i++) {
      Record rec = (Record) sections[section].get(i);
      if (section == Section.ADDITIONAL && rec instanceof OPTRecord) {
        skipped++;
        continue;
      }

      if (lastrec != null && !sameSet(rec, lastrec)) {
        pos = out.current();
        rendered = i;
      }
      lastrec = rec;
      rec.toWire(out, section, c);
      if (out.current() > maxLength) {
        out.jump(pos);
        return n - rendered + skipped;
      }
    }
    return skipped;
  }
Example #7
0
  private Record parseRR(MyStringTokenizer st, boolean useLast, Record last, Name origin)
      throws IOException {
    Name name;
    int ttl;
    short type, dclass;

    if (!useLast) name = new Name(st.nextToken(), origin);
    else name = last.getName();

    String s = st.nextToken();

    try {
      ttl = TTL.parseTTL(s);
      s = st.nextToken();
    } catch (NumberFormatException e) {
      if (!useLast || last == null) ttl = defaultTTL;
      else ttl = last.getTTL();
    }

    if ((dclass = DClass.value(s)) > 0) s = st.nextToken();
    else dclass = DClass.IN;

    if ((type = Type.value(s)) < 0) throw new IOException("Parse error");

    return Record.fromString(name, type, dclass, ttl, st, origin);
  }
Example #8
0
 Message(DNSInput in) throws IOException {
   this(new Header(in));
   boolean isUpdate = (header.getOpcode() == Opcode.UPDATE);
   boolean truncated = header.getFlag(Flags.TC);
   try {
     for (int i = 0; i < 4; i++) {
       int count = header.getCount(i);
       if (count > 0) sections[i] = new ArrayList(count);
       for (int j = 0; j < count; j++) {
         int pos = in.current();
         Record rec = Record.fromWire(in, i, isUpdate);
         sections[i].add(rec);
         if (i == Section.ADDITIONAL) {
           if (rec.getType() == Type.TSIG) tsigstart = pos;
           if (rec.getType() == Type.SIG) {
             SIGRecord sig = (SIGRecord) rec;
             if (sig.getTypeCovered() == 0) sig0start = pos;
           }
         }
       }
     }
   } catch (WireParseException e) {
     if (!truncated) throw e;
   }
   size = in.current();
 }
  public ArrayList<Integer> postorderTraversal(TreeNode root) {
    ArrayList<Integer> result = new ArrayList<Integer>();
    Stack<Record> stk = new Stack<Record>();
    if (root == null) return result;

    TreeNode n_cur = root;
    while (n_cur != null) {
      stk.push(new Record(n_cur));
      n_cur = n_cur.left;
    }

    while (!stk.isEmpty()) {
      Record rec = stk.pop();
      if (rec.tag == 0) {
        rec.tag = 1;
        stk.push(rec);
        n_cur = rec.node.right;
        while (n_cur != null) {
          stk.push(new Record(n_cur));
          n_cur = n_cur.left;
        }
      } else result.add(rec.node.val);
    }
    return result;
  }
  static {
    String bibFilePath = testDataParentPath + File.separator + "mhldMergeBibs1346.mrc";
    try {
      RawRecordReader rawRecRdr = new RawRecordReader(new FileInputStream(new File(bibFilePath)));
      while (rawRecRdr.hasNext()) {
        RawRecord rawRec = rawRecRdr.next();
        Record rec = rawRec.getAsRecord(true, false, "999", "MARC8");
        String id = rec.getControlNumber();
        // String id = RecordTestingUtils.getRecordIdFrom001(rec);
        ALL_UNMERGED_BIBS.put(id, rec);
      }
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }

    bibFilePath = testDataParentPath + File.separator + "mhldMerged1346.mrc";
    try {
      RawRecordReader rawRecRdr = new RawRecordReader(new FileInputStream(new File(bibFilePath)));
      while (rawRecRdr.hasNext()) {
        RawRecord rawRec = rawRecRdr.next();
        Record rec = rawRec.getAsRecord(true, false, "999", "MARC8");
        String id = rec.getControlNumber();
        // String id = RecordTestingUtils.getRecordIdFrom001(rec);
        ALL_MERGED_BIB_RESULTS.put(id, rec);
      }
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
  }
Example #11
0
 /** funkcja dodajÄ…ca wyniki do listy najlepszych */
 public static void addBest() {
   Record rec = new Record(Player.getPlayerName(), Player.getScore());
   if (best.size() < MAX) best.add(rec);
   else if (returnMin() < rec.getScore()) {
     best.remove(MAX - 1);
     best.add(rec);
   }
 }
Example #12
0
  /**
   * @param columnIdx
   * @param obj
   * @roseuid 3E5D8981013E
   */
  public void setObject(int columnIdx, Object obj) {
    if (columnIdx < 0 || columnIdx > fieldCount || currentNo < 0 || currentNo > recordCount) return;

    String name = (String) fieldNames.get(columnIdx);
    RecordMetaData rmd = (RecordMetaData) metadata.get(name);
    Record record = (Record) records.get(currentNo);
    record.set(columnIdx, obj);
  }
Example #13
0
 /**
  * Determines if an RRset with the given name and type is already present in the given section.
  *
  * @see RRset
  * @see Section
  */
 public boolean findRRset(Name name, int type, int section) {
   if (sections[section] == null) return false;
   for (int i = 0; i < sections[section].size(); i++) {
     Record r = (Record) sections[section].get(i);
     if (r.getType() == type && name.equals(r.getName())) return true;
   }
   return false;
 }
 /**
  * Determines if two Records are identical. This compares the name, type, class, and rdata (with
  * names canonicalized). The TTLs are not compared.
  *
  * @param arg The record to compare to
  * @return true if the records are equal, false otherwise.
  */
 public boolean equals(Object arg) {
   if (arg == null || !(arg instanceof Record)) return false;
   Record r = (Record) arg;
   if (type != r.type || dclass != r.dclass || !name.equals(r.name)) return false;
   byte[] array1 = rdataToWireCanonical();
   byte[] array2 = r.rdataToWireCanonical();
   return Arrays.equals(array1, array2);
 }
Example #15
0
 public void addDeath(Player owner) {
   if (m_records.containsKey(owner)) {
     m_records.get(owner).m_deaths += 1;
   } else {
     Record r = new Record(owner);
     r.m_deaths += 1;
     m_records.put(owner, r);
   }
 }
Example #16
0
  public void readOrbitData() throws IOException {

    if (_productFile instanceof DorisOrbitProductFile) {

      final DorisOrbitProductFile dorisProdFile = (DorisOrbitProductFile) _productFile;
      final Record orbitRecord = dorisProdFile.readOrbitData();

      OrbitVector orb = null;
      final SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss.SSSSSS");
      final ArrayList<OrbitVector> orbitVectorList = new ArrayList<OrbitVector>();

      final int numFields = orbitRecord.getNumFields();
      for (int i = 0; i < numFields; ++i) {

        final Field f = orbitRecord.getFieldAt(i);

        final String fieldName = f.getName();
        if (fieldName.contains("blank")) {
          continue;
        } else if (fieldName.contains("utc_time")) {
          orb = new OrbitVector();
          try {
            orb.utcTime = ProductData.UTC.parse(f.getData().getElemString()).getMJD();
          } catch (ParseException e) {
            throw new IllegalFileFormatException("Failed to parse UTC time " + e.getMessage());
          }
        } else if (fieldName.contains("delta_ut1")) {
          if (orb != null) orb.delta_ut1 = Double.parseDouble(f.getData().getElemString());
        } else if (fieldName.contains("abs_orbit")) {
          if (orb != null)
            orb.absOrbit = Integer.parseInt(f.getData().getElemString().replace("+", ""));
        } else if (fieldName.contains("x_pos")) {
          if (orb != null) orb.xPos = Double.parseDouble(f.getData().getElemString());
        } else if (fieldName.contains("y_pos")) {
          if (orb != null) orb.yPos = Double.parseDouble(f.getData().getElemString());
        } else if (fieldName.contains("z_pos")) {
          if (orb != null) orb.zPos = Double.parseDouble(f.getData().getElemString());
        } else if (fieldName.contains("x_vel")) {
          if (orb != null) orb.xVel = Double.parseDouble(f.getData().getElemString());
        } else if (fieldName.contains("y_vel")) {
          if (orb != null) orb.yVel = Double.parseDouble(f.getData().getElemString());
        } else if (fieldName.contains("z_vel")) {
          if (orb != null) orb.zVel = Double.parseDouble(f.getData().getElemString());
        } else if (fieldName.contains("qual_flags")) {
          if (orb != null) orb.qualFlags = f.getData().getElemString();
          orbitVectorList.add(orb);
        }
      }

      dataRecords = orbitVectorList.toArray(new OrbitVector[orbitVectorList.size()]);

      recordTimes = new double[dataRecords.length];
      for (int i = 0; i < dataRecords.length; i++) {
        recordTimes[i] = dataRecords[i].utcTime;
      }
    }
  }
Example #17
0
 public void addHit(Player owner) {
   if (m_records.containsKey(owner)) {
     m_records.get(owner).m_shotsHit += 1;
   } else {
     Record r = new Record(owner);
     r.m_shotsHit += 1;
     m_records.put(owner, r);
   }
 }
Example #18
0
  private final void maybeAddRecord(Record record) throws IOException {
    int rtype = record.getType();
    Name name = record.getName();

    if (rtype == Type.SOA && !name.equals(origin)) {
      throw new IOException("SOA owner " + name + " does not match zone origin " + origin);
    }
    if (name.subdomain(origin)) addRecord(record);
  }
Example #19
0
 /**
  * Removes a record from the Zone
  *
  * @param r The record to be removed
  * @see Record
  */
 public void removeRecord(Record r) {
   Name name = r.getName();
   short type = r.getRRsetType();
   RRset rrset = (RRset) findExactSet(name, type);
   if (rrset != null) {
     rrset.deleteRR(r);
     if (rrset.size() == 0) removeSet(name, type, rrset);
   }
 }
Example #20
0
  /**
   * @param columnIdx
   * @return Object
   * @roseuid 3E5D894200B1
   */
  public Object getObject(int columnIdx) {
    if (columnIdx < 0 || columnIdx > fieldCount || currentNo < 0 || currentNo > recordCount)
      return null;

    String name = (String) fieldNames.get(columnIdx);
    RecordMetaData rmd = (RecordMetaData) metadata.get(name);
    Record record = (Record) records.get(currentNo);
    Object value = record.get(columnIdx);
    return value;
  }
Example #21
0
 /**
  * Removes a record from the Zone
  *
  * @param r The record to be removed
  * @see Record
  */
 public void removeRecord(Record r) {
   Name name = r.getName();
   int rtype = r.getRRsetType();
   synchronized (this) {
     RRset rrset = findRRset(name, rtype);
     if (rrset == null) return;
     rrset.deleteRR(r);
     if (rrset.size() == 0) removeRRset(name, rtype);
   }
 }
Example #22
0
 /**
  * Called when a valid record is read from the table/query.
  *
  * @param bDisplayOption If true, display any changes.
  */
 public void doValidRecord(boolean bDisplayOption) {
   super.doValidRecord(bDisplayOption);
   Record recApTrx = this.getOwner();
   if (m_iDepartureEstimate == -1) {
     TrxStatus recTrxStatus =
         new TrxStatus(
             this.getOwner()
                 .findRecordOwner()); // Rarely, but if it doesn't exist in the screen, add it!
     m_iDepartureEstimate =
         recTrxStatus.getTrxStatusID(
             TransactionType.ACCTPAY, ApTrx.AP_TRX_FILE, ApTrx.DEP_ESTIMATE);
     m_iDepartureEstimateManual =
         recTrxStatus.getTrxStatusID(
             TransactionType.ACCTPAY, ApTrx.AP_TRX_FILE, ApTrx.DEPARTURE_EST_MANUAL);
     recTrxStatus.free();
   }
   if ((recApTrx.getField(ApTrx.TRX_STATUS_ID).getValue() == m_iDepartureEstimate)
       || (recApTrx.getField(ApTrx.TRX_STATUS_ID).getValue() == m_iDepartureEstimateManual)) {
     recApTrx
         .getField(ApTrx.INVOICE_AMOUNT)
         .moveFieldToThis(recApTrx.getField(ApTrx.DEPARTURE_ESTIMATE));
     recApTrx
         .getField(ApTrx.INVOICE_BALANCE)
         .moveFieldToThis(recApTrx.getField(ApTrx.DEPARTURE_ESTIMATE));
     recApTrx
         .getField(ApTrx.INVOICE_BALANCE_LOCAL)
         .moveFieldToThis(recApTrx.getField(ApTrx.DEPARTURE_ESTIMATE_LOCAL));
   }
 }
  public void testStackContainerPolicy() {
    DataReadQuery query = this.buildNewQuery();
    query.useCollectionClass(Stack.class);

    stack = (Stack) getSession().executeQuery(query);
    // if we get here, we must not have generated a ClassCastException
    Record row = (Record) stack.peek();
    if (row.get("CUSTNAME") == null) {
      throw new TestErrorException("missing data");
    }
  }
 private static final Record getEmptyRecord(
     Name name, int type, int dclass, long ttl, boolean hasData) {
   Record rec;
   if (hasData) rec = getTypedObject(type).getObject();
   else rec = new EmptyRecord();
   rec.name = name;
   rec.type = type;
   rec.dclass = dclass;
   rec.ttl = ttl;
   return rec;
 }
Example #25
0
  /**
   * Insert the method's description here. Creation date: (28.1.2001 13:12:23)
   *
   * @param field com.cosylab.vdct.vdb.VDBFieldData
   */
  public void fieldValueChanged(VDBFieldData field) {
    Record visualRecord = (Record) Group.getRoot().findObject(getName(), true);
    if (visualRecord == null) {
      // com.cosylab.vdct.Console.getInstance().println("o) Internal error: no visual representation
      // of record "+getName()+" found.");
      return;
    }

    com.cosylab.vdct.inspector.InspectorManager.getInstance().updateProperty(visualRecord, field);
    visualRecord.fieldChanged(field);
  }
Example #26
0
 void toWire(DNSOutput out) {
   header.toWire(out);
   Compression c = new Compression();
   for (int i = 0; i < 4; i++) {
     if (sections[i] == null) continue;
     for (int j = 0; j < sections[i].size(); j++) {
       Record rec = (Record) sections[i].get(j);
       rec.toWire(out, i, c);
     }
   }
 }
Example #27
0
  public String getTimeString(int columnIdx) {
    if (columnIdx < 0 || columnIdx > fieldCount || currentNo < 0 || currentNo > recordCount)
      return null;

    String name = (String) fieldNames.get(columnIdx);
    RecordMetaData rmd = (RecordMetaData) metadata.get(name);
    Record record = (Record) records.get(currentNo);
    Object value = record.get(columnIdx);
    if (value == null) return null;

    return value.toString().trim().split("\\.")[0];
  }
Example #28
0
 /**
  * Adds a Record to the Zone
  *
  * @param r The record to be added
  * @see Record
  */
 public void addRecord(Record r) {
   Name name = r.getName();
   int rtype = r.getRRsetType();
   synchronized (this) {
     RRset rrset = findRRset(name, rtype);
     if (rrset == null) {
       rrset = new RRset(r);
       addRRset(name, rrset);
     } else {
       rrset.addRR(r);
     }
   }
 }
Example #29
0
 /**
  * Asynchronously sends a message to a single server, registering a listener to receive a callback
  * on success or exception. Multiple asynchronous lookups can be performed in parallel. Since the
  * callback may be invoked before the function returns, external synchronization is necessary.
  *
  * @param query The query to send
  * @param listener The object containing the callbacks.
  * @return An identifier, which is also a parameter in the callback
  */
 public Object sendAsync(final Message query, final ResolverListener listener) {
   final Object id;
   synchronized (this) {
     id = new Integer(uniqueID++);
   }
   Record question = query.getQuestion();
   String qname;
   if (question != null) qname = question.getName().toString();
   else qname = "(none)";
   String name = this.getClass() + ": " + qname;
   Thread thread = new ResolveThread(this, query, id, listener);
   thread.setName(name);
   thread.setDaemon(true);
   thread.start();
   return id;
 }
  private static Record newRecord(
      Name name, int type, int dclass, long ttl, int length, DNSInput in) throws IOException {
    Record rec;
    int recstart;
    rec = getEmptyRecord(name, type, dclass, ttl, in != null);
    if (in != null) {
      if (in.remaining() < length) throw new WireParseException("truncated record");
      in.setActive(length);

      rec.rrFromWire(in);

      if (in.remaining() > 0) throw new WireParseException("invalid record length");
      in.clearActive();
    }
    return rec;
  }