Ejemplo n.º 1
0
  /**
   * Deletes this file from PDOM. Only uncommitted files can be safely deleted.
   *
   * @throws CoreException
   */
  public void delete() throws CoreException {
    Database db = fLinkage.getDB();
    long locRecord = db.getRecPtr(record + LOCATION_REPRESENTATION);
    if (locRecord != 0) db.getString(locRecord).delete();
    locRecord = db.getRecPtr(record + SIGNIFICANT_MACROS);
    if (locRecord != 0) db.getString(locRecord).delete();
    locRecord = db.getRecPtr(record + REPLACEMENT_HEADER);
    if (locRecord != 0) db.getString(locRecord).delete();

    db.free(record);
  }
Ejemplo n.º 2
0
 /**
  * Directly changes this record's internal location string. The format of this string is
  * unspecified in general and is determined by the associated IIndexLocationConverter. This method
  * should not be called on PDOMFile objects that are referenced by the file index.
  *
  * @param internalLocation
  * @throws CoreException
  */
 public void setInternalLocation(String internalLocation) throws CoreException {
   Database db = fLinkage.getDB();
   long oldRecord = db.getRecPtr(record + LOCATION_REPRESENTATION);
   if (oldRecord != 0) db.getString(oldRecord).delete();
   db.putRecPtr(record + LOCATION_REPRESENTATION, db.newString(internalLocation).getRecord());
   location = null;
 }
Ejemplo n.º 3
0
 @Override
 public void setReplacementHeader(String replacementHeader) throws CoreException {
   Database db = fLinkage.getDB();
   long oldRecord = db.getRecPtr(record + REPLACEMENT_HEADER);
   if (oldRecord != 0) db.getString(oldRecord).delete();
   long newRecord = replacementHeader == null ? 0 : db.newString(replacementHeader).getRecord();
   db.putRecPtr(record + REPLACEMENT_HEADER, newRecord);
 }
Ejemplo n.º 4
0
 @Override
 public ISignificantMacros getSignificantMacros() throws CoreException {
   if (sigMacros == null) {
     Database db = fLinkage.getDB();
     final IString encoded = db.getString(db.getRecPtr(record + SIGNIFICANT_MACROS));
     sigMacros =
         encoded == null ? ISignificantMacros.NONE : new SignificantMacros(encoded.getChars());
   }
   return sigMacros;
 }
Ejemplo n.º 5
0
 @Override
 public int compare(long record) throws CoreException {
   IString name = db.getString(db.getRecPtr(record + PDOMFile.LOCATION_REPRESENTATION));
   int cmp = name.compare(rawKey, true);
   if (cmp == 0 && linkageID >= 0) {
     cmp = db.get3ByteUnsignedInt(record + PDOMFile.LINKAGE_ID) - linkageID;
     if (cmp == 0 && rawSignificantMacros != null) {
       IString significantMacrosStr = getString(record + SIGNIFICANT_MACROS);
       if (significantMacrosStr != null) {
         cmp = significantMacrosStr.compare(rawSignificantMacros, true);
       } else {
         cmp = rawSignificantMacros.length > 0 ? -1 : 0;
       }
     }
   }
   return cmp;
 }
Ejemplo n.º 6
0
 @Override
 public IIndexFileLocation getLocation() throws CoreException {
   if (location == null) {
     Database db = fLinkage.getDB();
     String raw = db.getString(db.getRecPtr(record + LOCATION_REPRESENTATION)).getString();
     location = fLinkage.getPDOM().getLocationConverter().fromInternalFormat(raw);
     if (location == null) {
       URI uri;
       try {
         int idx = raw.lastIndexOf('>');
         uri = new URI("file", null, raw.substring(idx + 1), null); // $NON-NLS-1$
       } catch (URISyntaxException e) {
         uri = URI.create("file:/unknown-location"); // $NON-NLS-1$
       }
       location = new IndexFileLocation(uri, null);
     }
   }
   return location;
 }
Ejemplo n.º 7
0
 @Override
 public int compare(long record1, long record2) throws CoreException {
   IString name1 = db.getString(db.getRecPtr(record1 + LOCATION_REPRESENTATION));
   IString name2 = db.getString(db.getRecPtr(record2 + LOCATION_REPRESENTATION));
   int cmp = name1.compare(name2, true);
   if (cmp == 0) {
     cmp =
         db.get3ByteUnsignedInt(record1 + LINKAGE_ID)
             - db.get3ByteUnsignedInt(record2 + LINKAGE_ID);
     if (cmp == 0) {
       IString sm1 = getString(record1 + SIGNIFICANT_MACROS);
       IString sm2 = getString(record2 + SIGNIFICANT_MACROS);
       if (sm1 == null) {
         cmp = sm2 == null ? 0 : -1;
       } else if (sm2 == null) {
         cmp = 1;
       } else {
         cmp = sm1.compare(sm2, true);
       }
     }
   }
   return cmp;
 }
Ejemplo n.º 8
0
 @Override
 public String getReplacementHeader() throws CoreException {
   Database db = fLinkage.getDB();
   long rec = db.getRecPtr(record + REPLACEMENT_HEADER);
   return rec == 0 ? null : db.getString(rec).getString();
 }
Ejemplo n.º 9
0
 private IString getString(long offset) throws CoreException {
   long rec = db.getRecPtr(offset);
   return rec != 0 ? db.getString(rec) : null;
 }