* the behavior is the same as it would be for a mutable descriptor: * either an exception is thrown because of illegal parameters, or * there is no effect. */ public final void setField(String fieldName, Object fieldValue) throws RuntimeOperationsException { checkIllegalFieldName(fieldName); int i = fieldIndex(fieldName); if (i < 0) unsupported(); Object value = values[i]; if ((value == null) ? (fieldValue != null) : !value.equals(fieldValue)) unsupported(); } /** * Removes a field from the descriptor. * * @param fieldName String name of the field to be removed. * If the field name is illegal or the field is not found, * no exception is thrown. * * @exception RuntimeOperationsException if a field of the given name * exists and the descriptor is immutable. The wrapped exception will * be an {@link UnsupportedOperationException}. */ public final void removeField(String fieldName) { if (fieldName != null && fieldIndex(fieldName) >= 0) unsupported(); } static Descriptor nonNullDescriptor(Descriptor d) { if (d == null) return EMPTY_DESCRIPTOR; else return d; } private static void checkIllegalFieldName(String name) { if (name == null || name.equals("")) illegal("Null or empty field name"); } private static void unsupported() { UnsupportedOperationException uoe = new UnsupportedOperationException("Descriptor is read-only"); throw new RuntimeOperationsException(uoe); } private static void illegal(String message) { IllegalArgumentException iae = new IllegalArgumentException(message); throw new RuntimeOperationsException(iae); }}Lines 501–556 of 556. Previous lines
* the behavior is the same as it would be for a mutable descriptor: * either an exception is thrown because of illegal parameters, or * there is no effect. */ public final void setField(String fieldName, Object fieldValue) throws RuntimeOperationsException { checkIllegalFieldName(fieldName); int i = fieldIndex(fieldName); if (i < 0) unsupported(); Object value = values[i]; if ((value == null) ? (fieldValue != null) : !value.equals(fieldValue)) unsupported(); } /** * Removes a field from the descriptor. * * @param fieldName String name of the field to be removed. * If the field name is illegal or the field is not found, * no exception is thrown. * * @exception RuntimeOperationsException if a field of the given name * exists and the descriptor is immutable. The wrapped exception will * be an {@link UnsupportedOperationException}. */ public final void removeField(String fieldName) { if (fieldName != null && fieldIndex(fieldName) >= 0) unsupported(); } static Descriptor nonNullDescriptor(Descriptor d) { if (d == null) return EMPTY_DESCRIPTOR; else return d; } private static void checkIllegalFieldName(String name) { if (name == null || name.equals("")) illegal("Null or empty field name"); } private static void unsupported() { UnsupportedOperationException uoe = new UnsupportedOperationException("Descriptor is read-only"); throw new RuntimeOperationsException(uoe); } private static void illegal(String message) { IllegalArgumentException iae = new IllegalArgumentException(message); throw new RuntimeOperationsException(iae); } }