Beispiel #1
0
 public void toggle(int key, boolean pressed) {
   if (key == KeyEvent.VK_UP) up.toggle(pressed);
   if (key == KeyEvent.VK_DOWN) down.toggle(pressed);
   if (key == KeyEvent.VK_RIGHT) right.toggle(pressed);
   if (key == KeyEvent.VK_LEFT) left.toggle(pressed);
   if (key == KeyEvent.VK_SPACE) space.toggle(pressed);
 }
 public Map<String, String> getValues() {
   Map<String, String> result = new HashMap<String, String>();
   for (Key key : valueByKey.keySet()) {
     result.put(key.getKey(), valueByKey.get(key));
   }
   return result;
 }
Beispiel #3
0
  /**
   * DOCUMENT ME!
   *
   * @param key DOCUMENT ME!
   * @return DOCUMENT ME!
   * @throws DatasetException DOCUMENT ME!
   */
  public RowSet locate(Key key) throws DatasetException {
    validate();

    RowSet rs = (RowSet) keysCache.get(key);

    if ((rs == null) && key.hasAll()) {
      int[] tempcols2 = new int[cols2.length];
      Object[] anykey = new Object[cols2.length];
      int t = 0;

      for (int i = 0; i < tempcols2.length; i++) {
        if (key.elements[i] == Key.ANY) {
          anykey[i] = Key.ANY;
        } else {
          anykey[i] = Key.UNKNOWN;
          tempcols2[t] = cols2[i];
          t++;
        }
      }

      Key ak = new Key(anykey);

      // [1,2,any,3] 检查是否以前已经计算过 [UNKNOWN,UNKONW,ANY,UNKNOWN] 分组
      if ((t > 0) && !this.keysCache.containsKey(ak)) {
        int[] newcols2 = new int[t];
        System.arraycopy(newcols2, 0, tempcols2, 0, t);

        Map newmap = new IndexBuilder(this, newcols2).build();

        for (Object k : newmap.keySet()) {
          if (k != Dataset.ANY) {
            Key k2 = (Key) k;
            Object[] tempkey = new Object[cols2.length];
            Arrays.fill(tempkey, Key.ANY);

            int n = 0;

            for (int i = 0; i < tempkey.length; i++) {
              if (key.elements[i] != Key.ANY) {
                tempkey[i] = k2.elements[n];
                n++;
              }
            }

            Object newrs = newmap.get(k2);

            k2.elements = tempkey;
            this.keysCache.put(k2, newrs);
          }
        }

        // [UNKNOWN,UNKONW,ANY,UNKNOWN] 打上此分组已计算标志
        this.keysCache.put(ak, ak);
      }

      rs = (RowSet) this.keysCache.get(key);
    }

    return rs;
  }
Beispiel #4
0
  private static void _removeFromValueList(String keyName, String item) {
    Key key = root.getSubKey(keyName);

    if (key == null) {
      key = root.createSubKey(keyName);
    }

    String oldValue = key.value;
    String[] oldValueList = _getValueList(keyName);
    fireChanging(keyName, _isList(keyName), oldValue, null, oldValueList, null);

    if (key.value != null) {
      key.value = null;
    }

    if (key.valueList == null) {
      key.valueList = new java.util.ArrayList();
    } else {
      if (item != null) {
        key.valueList.remove(item);
      }
    }

    fireChanged(keyName, _isList(keyName), oldValue, null, oldValueList, _getValueList(keyName));
  }
 public float getMix(Animation from, Animation to) {
   tempKey.a1 = from;
   tempKey.a2 = to;
   Float time = animationToMixTime.get(tempKey);
   if (time == null) return 0;
   return time;
 }
  public Key unmarshall(JsonUnmarshallerContext context) throws Exception {
    Key key = new Key();

    int originalDepth = context.getCurrentDepth();
    int targetDepth = originalDepth + 1;

    JsonToken token = context.currentToken;
    if (token == null) token = context.nextToken();

    while (true) {
      if (token == null) break;

      if (token == FIELD_NAME || token == START_OBJECT) {
        if (context.testExpression("HashKeyElement", targetDepth)) {
          context.nextToken();
          key.setHashKeyElement(AttributeValueJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("RangeKeyElement", targetDepth)) {
          context.nextToken();
          key.setRangeKeyElement(AttributeValueJsonUnmarshaller.getInstance().unmarshall(context));
        }
      } else if (token == END_ARRAY || token == END_OBJECT) {
        if (context.getCurrentDepth() <= originalDepth) break;
      }
      token = context.nextToken();
    }

    return key;
  }
Beispiel #7
0
  private static void _setValueList(String keyName, String[] values) {
    Key key = root.getSubKey(keyName);

    if (key == null) {
      key = root.createSubKey(keyName);
    }

    String oldValue = key.value;
    String[] oldValueList = _getValueList(keyName);
    fireChanging(keyName, _isList(keyName), oldValue, null, oldValueList, values);

    if (key.value != null) {
      key.value = null;
    }

    if (key.valueList == null) {
      key.valueList = new java.util.ArrayList((values == null) ? 0 : values.length);
    } else {
      key.valueList.clear();
    }
    if (values != null) {
      for (int i = 0; i < values.length; i++) {
        key.valueList.add(values[i]);
      }
    }

    fireChanged(keyName, _isList(keyName), oldValue, null, oldValueList, values);
  }
  /** Creates a non unique index for the given table. */
  private void createNonUnique(Table t) throws SQLException {
    boolean comma = false;
    int indexNumber = 1;

    Iterator<Key> j = t.getKeys().iterator();

    while (j.hasNext()) {
      Key key = j.next();
      if (key.getType() == Key.NonUnique) {
        String SQL = "CREATE INDEX " + t.getName() + "_" + indexNumber;
        SQL += " ON " + t.getSchema() + "." + t.getName() + "(";

        Iterator<Column> i = key.getColumns().iterator();
        comma = false;
        while (i.hasNext()) {
          Column c = i.next();
          SQL += (comma ? ", " : "") + c.getName();
          comma = true;
        }
        indexNumber++;
        SQL += ")";
        execute(SQL);
      }
    }
  }
Beispiel #9
0
 public static Key create(Long qtid) {
   Key key = new Key();
   key.setQtkey(Generator.generateNumberKey(8));
   key.setQtid(qtid);
   key.setState(KeyState.nouse);
   return key;
 }
Beispiel #10
0
  @Test
  public void testMarshall_Embedded() {
    RootEntity rootObject = new RootEntity(); // one entity
    ChildEntity childObject = new ChildEntity("Test City");
    ChildEntity embeddedObject = new ChildEntity("Old Test City");
    embeddedObject.setId(1L);
    embeddedObject.setType("EmbeddedType");
    rootObject.setId("TestUser");
    rootObject.setCount(25);
    childObject.setParent(rootObject);
    rootObject.setNewChildEntity(childObject); // one entity
    rootObject.setEmbeddedEntity(embeddedObject); // not included, @Embedded

    IdentityHashMap<Object, Entity> stack = testMarshaller.marshall(null, rootObject);

    Entity rootObjectEntity = stack.get(rootObject);
    Entity childObjectEntity = stack.get(childObject);

    EmbeddedEntity ee = (EmbeddedEntity) rootObjectEntity.getProperty("embeddedEntity");
    Key childKey = (Key) rootObjectEntity.getProperty("newChildEntity");
    Key parentKey = childKey.getParent();

    assertEquals(2, stack.size());
    assertNotNull(parentKey);
    assertEquals(EmbeddedEntity.class, ee.getClass());
    assertTrue(childKey instanceof Key);
    assertEquals(rootObjectEntity.getKey().getId(), parentKey.getId());
    assertEquals(rootObjectEntity.getKey().getName(), parentKey.getName());

    assertEquals(1L, ee.getProperties().get("id"));
    assertEquals("EmbeddedType", ee.getProperties().get("type"));
  }
  /**
   * Handle UTR joins
   *
   * @param feature
   * @param key
   * @param qualifiers
   * @return
   */
  private Location joinUtrs(Feature feature, Key key, QualifierVector qualifiers) {
    Location location = feature.getLocation();
    if (key.getKeyString().equals("5'UTR") || key.getKeyString().equals("3'UTR")) {
      ChadoCanonicalGene gene = ((GFFStreamFeature) feature).getChadoGene();
      String utrName = GeneUtils.getUniqueName(feature);
      String transcriptName = gene.getTranscriptFromName(utrName);
      List<Feature> utrs;

      if (key.getKeyString().equals("5'UTR")) utrs = gene.get5UtrOfTranscript(transcriptName);
      else utrs = gene.get3UtrOfTranscript(transcriptName);

      if (utrs.size() > 1) {
        int start = Integer.MAX_VALUE;
        RangeVector ranges = new RangeVector();
        for (int i = 0; i < utrs.size(); i++) {
          Feature utr = utrs.get(i);
          Range range = utr.getLocation().getTotalRange();
          if (start > range.getStart()) start = range.getStart();
          ranges.add(range);
        }

        if (start != feature.getLocation().getTotalRange().getStart()) return null;

        location = new Location(ranges, feature.getLocation().isComplement());
      }

      int ntranscripts = gene.getTranscripts().size();
      if (ntranscripts == 1) transcriptName = gene.getGeneUniqueName();
      qualifiers.setQualifier(new Qualifier("locus_tag", transcriptName));
      qualifiers.removeQualifierByName("ID");
    }
    return location;
  }
Beispiel #12
0
 /**
  * Assembly a reply from a decomp rule and the input. If the reassembly rule is goto, return null
  * and give the gotoKey to use. Otherwise return the response.
  */
 String assemble(Decomp d, String reply[], Key gotoKey) {
   String lines[] = new String[3];
   d.stepRule();
   String rule = d.nextRule();
   if (EString.match(rule, "goto *", lines)) {
     // goto rule -- set gotoKey and return false.
     gotoKey.copy(keys.getKey(lines[0]));
     if (gotoKey.key() != null) return null;
     System.out.println("Goto rule did not match key: " + lines[0]);
     return null;
   }
   String work = "";
   while (EString.match(rule, "* (#)*", lines)) {
     // reassembly rule with number substitution
     rule = lines[2]; // there might be more
     int n = 0;
     try {
       n = Integer.parseInt(lines[1]) - 1;
     } catch (NumberFormatException e) {
       System.out.println("Number is wrong in reassembly rule " + lines[1]);
     }
     if (n < 0 || n >= reply.length) {
       System.out.println("Substitution number is bad " + lines[1]);
       return null;
     }
     reply[n] = post.translate(reply[n]);
     work += lines[0] + " " + reply[n];
   }
   work += rule;
   if (d.mem()) {
     mem.save(work);
     return null;
   }
   return work;
 }
 protected final void computeNearestNeighbors() {
   // Round-up so we don't have any pixels outside the grid
   mCellWidth = (getMinWidth() + GRID_WIDTH - 1) / GRID_WIDTH;
   mCellHeight = (getHeight() + GRID_HEIGHT - 1) / GRID_HEIGHT;
   mGridNeighbors = new int[GRID_SIZE][];
   int[] indices = new int[mKeys.size()];
   final int gridWidth = GRID_WIDTH * mCellWidth;
   final int gridHeight = GRID_HEIGHT * mCellHeight;
   for (int x = 0; x < gridWidth; x += mCellWidth) {
     for (int y = 0; y < gridHeight; y += mCellHeight) {
       int count = 0;
       for (int i = 0; i < mKeys.size(); i++) {
         final Key key = mKeys.get(i);
         if (key.squaredDistanceFrom(x, y) < mProximityThreshold
             || key.squaredDistanceFrom(x + mCellWidth - 1, y) < mProximityThreshold
             || key.squaredDistanceFrom(x + mCellWidth - 1, y + mCellHeight - 1)
                 < mProximityThreshold
             || key.squaredDistanceFrom(x, y + mCellHeight - 1) < mProximityThreshold) {
           indices[count++] = i;
         }
       }
       int[] cell = new int[count];
       System.arraycopy(indices, 0, cell, 0, count);
       mGridNeighbors[(y / mCellHeight) * GRID_WIDTH + (x / mCellWidth)] = cell;
     }
   }
 }
Beispiel #14
0
  /**
   * Called just after the config has been loaded to check it is valid.
   *
   * @throws InvalidValueException When there is a problem
   */
  public void validate() {
    if (layouts == null) throw new InvalidValueException("layouts", "null");
    layouts.validate();

    if (dpis == null) throw new InvalidValueException("dpis", "null");
    if (dpis.size() < 1) throw new InvalidValueException("dpis", "[]");

    if (scales == null) throw new InvalidValueException("scales", "null");
    if (scales.size() < 1) throw new InvalidValueException("scales", "[]");

    if (hosts == null) throw new InvalidValueException("hosts", "null");
    if (hosts.size() < 1) throw new InvalidValueException("hosts", "[]");

    if (globalParallelFetches < 1) {
      throw new InvalidValueException("globalParallelFetches", globalParallelFetches);
    }
    if (perHostParallelFetches < 1) {
      throw new InvalidValueException("perHostParallelFetches", perHostParallelFetches);
    }

    if (socketTimeout < 0) {
      throw new InvalidValueException("socketTimeout", socketTimeout);
    }
    if (connectionTimeout < 0) {
      throw new InvalidValueException("connectionTimeout", connectionTimeout);
    }

    for (Key key : getKeys()) {
      key.validate();
    }
  }
Beispiel #15
0
  public void update(
      int x,
      int y,
      boolean b0,
      boolean b1,
      boolean b2,
      boolean onScreen,
      boolean[] keysDown,
      String typed) {
    b0Clicked = !this.b0 && b0;
    b1Clicked = !this.b1 && b1;
    b2Clicked = !this.b2 && b2;

    b0Released = this.b0 && !b0;
    b1Released = this.b1 && !b1;
    b2Released = this.b2 && !b2;

    this.x = x;
    this.y = y;
    this.b0 = b0;
    this.b1 = b1;
    this.b2 = b2;
    this.onScreen = onScreen;
    this.typed = "";

    for (Key key : keys) {
      key.tick(keysDown);
    }
  }
Beispiel #16
0
  static {
    root = new Key();
    root.name = "<root>";
    root.subKeys = new java.util.HashMap();
    java.io.File aliceHasNotExitedFile =
        new java.io.File(
            edu.cmu.cs.stage3.alice.authoringtool.JAlice.getAliceUserDirectory(),
            "aliceHasNotExited.txt");
    if (aliceHasNotExitedFile.canRead()) {
      try {
        storeConfig();
      } catch (java.io.IOException e2) {
        edu.cmu.cs.stage3.alice.authoringtool.AuthoringTool.showErrorDialog(
            java.util.ResourceBundle.getBundle(
                    "edu/cmu/cs/stage3/alice/authoringtool/util/Configuration")
                .getString("UNABLE_TO_CREATE_NEW_PREFERENCES_FILE."),
            e2);
      }
    } else {
      try {
        loadConfig(configLocation);
      } catch (Exception e) {

      }
    }
  }
Beispiel #17
0
 public void addAttachment(int slotIndex, String name, Attachment attachment) {
   if (attachment == null) throw new IllegalArgumentException("attachment cannot be null.");
   if (slotIndex < 0) throw new IllegalArgumentException("slotIndex must be >= 0.");
   Key key = new Key();
   key.set(slotIndex, name);
   attachments.put(key, attachment);
 }
    @Override
    protected void rehash(int newCapacity) {
      // rehash should discard gced keys
      // because otherwise there is a remote probability of
      // having two (Weak|Soft)Keys with accidentally equal hashCodes and different but gced key
      // values
      int oldCapacity = _set.length;
      Object[] oldKeys = _set;
      V[] oldVals = _values;

      _set = new Object[newCapacity];
      _values = (V[]) new Object[newCapacity];

      for (int i = oldCapacity; i-- > 0; ) {
        Object o = oldKeys[i];
        if (o == null || o == REMOVED) continue;
        Key<K> k = (Key<K>) o;
        K key = k.get();
        if (key == null) continue;
        int index = insertionIndex(k);
        if (index < 0) {
          // make 'key' alive till this point to not allow 'o.referent' to be gced
          throwObjectContractViolation(_set[-index - 1], o + "; key: " + key);
        }
        _set[index] = o;
        _values[index] = oldVals[i];
      }
    }
 /**
  * Method decrypts the data with the RSA private key corresponding to this certificate (which was
  * used to encrypt it). Decryption will be done with keystore
  *
  * @param data data to be decrypted.
  * @param token index of authentication token
  * @param pin PIN code
  * @return decrypted data.
  * @throws DigiDocException for all decryption errors
  */
 public byte[] decrypt(byte[] data, int token, String pin) throws DigiDocException {
   try {
     if (m_keyStore == null)
       throw new DigiDocException(
           DigiDocException.ERR_NOT_INITED, "Keystore not initialized", null);
     String alias = getTokenName(token);
     if (alias == null)
       throw new DigiDocException(
           DigiDocException.ERR_TOKEN_LOGIN, "Invalid token nr: " + token, null);
     // get key
     if (m_logger.isDebugEnabled())
       m_logger.debug(
           "loading key: " + alias + " passwd-len: " + ((pin != null) ? pin.length() : 0));
     Key key = m_keyStore.getKey(alias, pin.toCharArray());
     if (m_logger.isDebugEnabled())
       m_logger.debug("Key: " + ((key != null) ? "OK, algorithm: " + key.getAlgorithm() : "NULL"));
     if (key == null)
       throw new DigiDocException(
           DigiDocException.ERR_TOKEN_LOGIN, "Invalid password for token: " + alias, null);
     Cipher cipher = Cipher.getInstance("RSA");
     cipher.init(Cipher.DECRYPT_MODE, key);
     byte[] decdata = cipher.doFinal(data);
     if (m_logger.isDebugEnabled())
       m_logger.debug("Decrypted len: " + ((decdata != null) ? decdata.length : 0));
     return decdata;
   } catch (Exception ex) {
     m_logger.error("Error decrypting: " + ex);
   }
   return null;
 }
Beispiel #20
0
  private static Map<Key<?>, Object> checkForInvalidSeedsAndCopy(
      Map<Key<?>, Object> seededObjects) {
    for (Map.Entry<Key<?>, Object> entry : seededObjects.entrySet()) {
      Key<?> key = entry.getKey();
      Object value = entry.getValue();
      if (value == null) {
        throw new IllegalArgumentException("Seeded objects contains null key. Key: " + key);
      }
      Class<?> rawType = key.getTypeLiteral().getRawType();
      if (!rawType.isInstance(value)) {
        if (!(value instanceof Key)) {
          throw new IllegalArgumentException(
              "Seeded object is not instance of key type. " + "Key: " + key + ". Value: " + value);
        }
        Class<?> valueRawType = ((Key) value).getTypeLiteral().getRawType();
        if (!rawType.isAssignableFrom(valueRawType)) {
          throw new IllegalArgumentException(
              "Chained value key type does not extend the key type. "
                  + "Key Key: "
                  + key
                  + ". Value Key: "
                  + value);
        }
      }
    }

    return seededObjects
        .entrySet()
        .stream()
        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
  }
Beispiel #21
0
 /** Test key from kind and name. */
 public void testKeyFromKindAndName() {
   Key key = new Key(kind, name);
   assertEquals(kind, key.getKind());
   assertEquals(name, key.getName());
   assertNull(key.getParent());
   assertEquals(0L, key.getId());
 }
  public void remove(Key key) throws AgentStorageException {

    String keys = getKeys();
    int len = keys.length();

    // delete the resource from the resources list
    keys = StringUtil.replace(keys, key.getEntry(), "");

    if (len == keys.length()) {
      log.debug("Remove failed, key not found: " + key);
      return;
    }

    this.storage.setValue(this.keylistName, keys);

    // delete the resource properties from the agent DB
    Set<String> propertiesKeys = storage.getPropertiesKeys(key.getStoragePrefix());
    for (String propertiesKey : propertiesKeys) {
      this.storage.setValue(
          propertiesKey, null); // Sending null as Value parameter removes the property key
    }

    this.storage.flush();
    log.debug("Removed from storage: " + key);
  }
  @Override
  public void put(Key key, Value value) {
    // search for key, update value if found, grow table if new

    Node t = new Node(null, key, value);
    if (root == null) {
      root = t;
      return;
    }
    Node parent = null;
    Node x = root;
    while (x != null) {
      parent = x;
      int cmp = key.compareTo(x.key);
      compares++;
      if (cmp < 0) x = x.left;
      else if (cmp > 0) x = x.right;
      else {
        x.value = value;
        return;
      }
    }
    int cmp = key.compareTo(parent.key);
    compares++;
    if (cmp < 0) parent.left = t;
    else parent.right = t;
    t.parent = parent;
    // adjust tree sizes;
    while (parent != null) {
      parent.N += 1;
      parent = parent.parent;
    }
  }
Beispiel #24
0
  public Key remove() {
    if (size == 0) return null;
    // TODO to speed up: create array of counts but 128 times compressed

    //				int c = minimal >> CounterRange;
    //				if (counter[c] == 0) {
    //					final int m = c;
    //					do
    //						c++;
    //					while (counter[c] == 0);
    //					ups += c - m;
    //					minimal = c << CounterRange;
    //				}

    final int m = minimal;
    while (bucket[minimal] == null) minimal++;
    ups += minimal - m;

    counter[minimal >> CounterRange]++;
    size--;

    final Key e = bucket[minimal];
    bucket[minimal] = e.queueNext;
    e.queueNext = null;
    return e;
  }
Beispiel #25
0
  private void scanBindings() throws IOException {
    for (Map.Entry<Key<?>, Binding<?>> e : globalInjector.getAllBindings().entrySet()) {
      Key<?> bindingKey = e.getKey();
      Binding<?> binding = e.getValue();
      TypeLiteral boundTypeLiteral = bindingKey.getTypeLiteral();
      Type boundType = boundTypeLiteral.getType();
      if (boundType instanceof Class) {
        final Class boundClass = (Class) boundType;
        for (Method method : boundClass.getMethods()) {
          if ((method.getModifiers() & Modifier.STATIC) == 0) {
            for (Annotation annotation : method.getAnnotations()) {
              if (annotation instanceof Path) {
                Path pathSpec = (Path) annotation;
                RouteSpec routeIn = Routes.parse(pathSpec.value(), true);
                endPointMethods.add(new EndPointMethod(routeIn, bindingKey, boundClass, method));
              }
            }
          }
        }

        if (MessageBodyReader.class.isAssignableFrom(boundClass)) {
          messageBodyReaders.add(0, (MessageBodyReader) globalInjector.getInstance(bindingKey));
        }
        if (MessageBodyWriter.class.isAssignableFrom(boundClass)) {
          messageBodyWriters.add(0, (MessageBodyWriter) globalInjector.getInstance(bindingKey));
        }
      }
    }
  }
Beispiel #26
0
 @Override
 public void serializeContent(XmlSerializer serializer) throws IOException {
   if (isEmpty()) return;
   SerializerUtils.addTextTag(serializer, VCardProperty.FN.toString(), getFormattedName());
   serializer.startTag(null, N_NAME);
   for (Entry<NameProperty, String> entry : name.entrySet())
     SerializerUtils.addTextTag(serializer, entry.getKey().toString(), entry.getValue());
   serializer.endTag(null, N_NAME);
   for (Entry<VCardProperty, String> entry : properties.entrySet())
     if (entry.getKey() != VCardProperty.FN)
       SerializerUtils.addTextTag(serializer, entry.getKey().toString(), entry.getValue());
   for (Photo photo : photos) photo.serialize(serializer);
   for (Address address : addresses) address.serialize(serializer);
   for (Label label : labels) label.serialize(serializer);
   for (Telephone telephone : telephones) telephone.serialize(serializer);
   for (Email email : emails) email.serialize(serializer);
   for (Logo logo : logos) logo.serialize(serializer);
   for (Sound sound : sounds) sound.serialize(serializer);
   for (Geo geo : geos) geo.serialize(serializer);
   for (Organization organization : organizations) organization.serialize(serializer);
   if (!categories.isEmpty()) {
     serializer.startTag(null, CATEGORIES_NAME);
     for (String keyword : categories)
       SerializerUtils.addTextTag(serializer, KEYWORD_NAME, keyword);
     serializer.endTag(null, CATEGORIES_NAME);
   }
   if (classification != null)
     SerializerUtils.addTextTag(serializer, CLASS_NAME, classification.toString());
   for (Key key : keys) key.serialize(serializer);
 }
Beispiel #27
0
 /** Test key from kind, parent and name. */
 public void testKeyFromKindParentAndName() {
   Key parent = new Key(kind);
   Key key = new Key(kind, parent, name);
   assertEquals(kind, key.getKind());
   assertEquals(name, key.getName());
   assertEquals(parent, key.getParent());
   assertEquals(0L, key.getId());
 }
Beispiel #28
0
 /** Test key from kind, parent and id. */
 public void testKeyFromKindParentAndId() {
   Key parent = new Key(kind);
   Key key = new Key(kind, parent, id);
   assertEquals(kind, key.getKind());
   assertNull(key.getName());
   assertEquals(id, key.getId());
   assertEquals(parent, key.getParent());
 }
 private void keys(Node node, Queue<Key> queue, Key lo, Key hi) {
   if (node == null) return;
   int cmplo = lo.compareTo(node.key);
   int cmphi = hi.compareTo(node.key);
   if (cmplo < 0) keys(node.left, queue, lo, hi);
   if (cmplo <= 0 && cmphi >= 0) queue.add(node.key);
   if (cmphi > 0) keys(node.right, queue, lo, hi);
 }
Beispiel #30
0
 @Override
 public void remove(String contentUrl) {
   // Remove from the in-memory cache, but not from disk. Let the clean-up process do this
   // asynchronously.
   String path = getCacheFilePath(contentUrl);
   memoryStore.remove(Key.forUrl(contentUrl));
   memoryStore.remove(Key.forCacheFile(path));
 }