|
| 1 | +// BSONObject.java |
| 2 | + |
| 3 | +/** |
| 4 | + * Copyright (C) 2008 10gen Inc. |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +package org.bson; |
| 20 | + |
| 21 | +import java.util.*; |
| 22 | + |
| 23 | +/** A key-value map that can be saved to the database. */ |
| 24 | +public interface BSONObject { |
| 25 | + |
| 26 | + /** Sets a name/value pair in this object. |
| 27 | + * @param key Name to set |
| 28 | + * @param v Corresponding value |
| 29 | + * @return <tt>v</tt> |
| 30 | + */ |
| 31 | + public Object put( String key , Object v ); |
| 32 | + |
| 33 | + public void putAll( BSONObject o ); |
| 34 | + public void putAll( Map m ); |
| 35 | + |
| 36 | + /** Gets a field from this object by a given name. |
| 37 | + * @param key The name of the field fetch |
| 38 | + * @return The field, if found |
| 39 | + */ |
| 40 | + public Object get( String key ); |
| 41 | + |
| 42 | + /** |
| 43 | + * Returns a map representing this BSONObject. |
| 44 | + * @return the map |
| 45 | + */ |
| 46 | + public Map toMap(); |
| 47 | + |
| 48 | + /** Remove a field with a given name from this object. |
| 49 | + * @param key The name of the field to remove |
| 50 | + * @return The value removed from this object |
| 51 | + */ |
| 52 | + public Object removeField( String key ); |
| 53 | + |
| 54 | + /** |
| 55 | + * @deprecated |
| 56 | + */ |
| 57 | + public boolean containsKey( String s ); |
| 58 | + |
| 59 | + /** Checks if this object contains a field with the given name. |
| 60 | + * @param s Field name for which to check |
| 61 | + * @return if this object contains a field with the given name |
| 62 | + */ |
| 63 | + public boolean containsField(String s); |
| 64 | + |
| 65 | + /** Returns this object's fields' names |
| 66 | + * @return The names of the fields in this object |
| 67 | + */ |
| 68 | + public Set<String> keySet(); |
| 69 | + |
| 70 | +} |
0 commit comments