src/jdk/nashorn/internal/runtime/PropertyMap.java

Print this page




 366 
 367     /**
 368      * Find a property in the map.
 369      *
 370      * @param key Key to search for.
 371      *
 372      * @return {@link Property} matching key.
 373      */
 374     public Property findProperty(final String key) {
 375         return properties.find(key);
 376     }
 377 
 378     /**
 379      * Adds all map properties from another map.
 380      *
 381      * @param other The source of properties.
 382      *
 383      * @return New {@link PropertyMap} with added properties.
 384      */
 385     public PropertyMap addAll(final PropertyMap other) {

 386         final Property[] otherProperties = other.properties.getProperties();
 387         final PropertyHashMap newProperties = properties.immutableAdd(otherProperties);
 388 
 389         final PropertyMap newMap = new PropertyMap(this, newProperties);
 390         for (final Property property : otherProperties) {
 391             newMap.spillLength += property.getSpillCount();
 392         }
 393 
 394         return newMap;
 395     }
 396 
 397     /**
 398      * Return an array of all properties.
 399      *
 400      * @return Properties as an array.
 401      */
 402     public Property[] getProperties() {
 403         return properties.getProperties();
 404     }
 405 




 366 
 367     /**
 368      * Find a property in the map.
 369      *
 370      * @param key Key to search for.
 371      *
 372      * @return {@link Property} matching key.
 373      */
 374     public Property findProperty(final String key) {
 375         return properties.find(key);
 376     }
 377 
 378     /**
 379      * Adds all map properties from another map.
 380      *
 381      * @param other The source of properties.
 382      *
 383      * @return New {@link PropertyMap} with added properties.
 384      */
 385     public PropertyMap addAll(final PropertyMap other) {
 386         assert this != other : "adding property map to itself";
 387         final Property[] otherProperties = other.properties.getProperties();
 388         final PropertyHashMap newProperties = properties.immutableAdd(otherProperties);
 389 
 390         final PropertyMap newMap = new PropertyMap(this, newProperties);
 391         for (final Property property : otherProperties) {
 392             newMap.spillLength += property.getSpillCount();
 393         }
 394 
 395         return newMap;
 396     }
 397 
 398     /**
 399      * Return an array of all properties.
 400      *
 401      * @return Properties as an array.
 402      */
 403     public Property[] getProperties() {
 404         return properties.getProperties();
 405     }
 406