/**
   * Set the value of the field at the given index as an integer. This would be used to set SFInt32
   * field types.
   *
   * @param index The index of destination field to set
   * @param value The new value to use for the node
   * @throws InvalidFieldException The field index is not know
   */
  public void setValue(int index, int value)
      throws InvalidFieldException, InvalidFieldValueException {

    switch (index) {
      case FIELD_BOUNDARY_WIDTH:
        if (!inSetup) throw new InvalidFieldAccessException("Cannot set boundaryWidth field.");

        vfBoundaryWidth = value;
        break;

      default:
        super.setValue(index, value);
    }
  }
  /**
   * Set the value of the field at the given index as an boolean. This would be used to set SFBool
   * field types headlight and bind.
   *
   * @param index The index of destination field to set
   * @param value The new value to use for the node
   * @throws InvalidFieldException The field index is not know
   */
  public void setValue(int index, boolean value)
      throws InvalidFieldException, InvalidFieldValueException {

    switch (index) {
      case FIELD_GENERATE_MIPMAPS:
        if (!inSetup) throw new InvalidFieldAccessException("Cannot set generateMipMaps field.");

        vfGenerateMipMaps = value;
        break;

      default:
        super.setValue(index, value);
    }
  }
  /**
   * Set the value of the field at the given index as an array of floats. This would be used to set
   * MFFloat, SFVec2f, SFVec3f and SFRotation field types.
   *
   * @param index The index of destination field to set
   * @param value The new value to use for the node
   * @param numValid The number of valid values to copy from the array
   * @throws InvalidFieldException The field index is not known
   * @throws InvalidFieldValueException The value provided is out of range for the field type.
   */
  public void setValue(int index, float[] value, int numValid)
      throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException {

    switch (index) {
      case FIELD_BBOX_CENTER:
        setBboxCenter(value);
        break;

      case FIELD_BBOX_SIZE:
        setBboxSize(value);
        break;
      default:
        super.setValue(index, value, numValid);
    }
  }
  /**
   * Set the value of the field at the given index as a float. This would be used to set SFFloat
   * field types speed and visibilityLimit.
   *
   * @param index The index of destination field to set
   * @param value The new value to use for the node
   * @throws InvalidFieldException The field index is not know
   */
  public void setValue(int index, float value)
      throws InvalidFieldException, InvalidFieldValueException {

    switch (index) {
      case FIELD_ANISOTROPIC_FILTER_DEGREE:
        if (!inSetup)
          throw new InvalidFieldAccessException("Cannot set anistropicFilterDegree field.");

        vfAnisotropicFilterDegree = value;
        break;

      default:
        super.setValue(index, value);
    }
  }
  /**
   * Set the value of the field at the given index as a node. This would be used to set SFNode field
   * types.
   *
   * @param index The index of destination field to set
   * @param value The new value to use for the node
   * @throws InvalidFieldException The index does not match a known field
   */
  public void setValue(int index, VRMLNodeType child) throws InvalidFieldException {

    VRMLNodeType node = (VRMLNodeType) child;
    switch (index) {
      case FIELD_CHILDREN:
        if (!inSetup) clearChildren();

        if (child != null) addChildNode(node);

        hasChanged[FIELD_CHILDREN] = true;
        break;

      default:
        super.setValue(index, child);
    }
  }
  /**
   * Set the value of the field at the given index as a String. This would be used to set SFString
   * field types.
   *
   * @param index The index of destination field to set
   * @param value The new value to use for the node
   */
  public void setValue(int index, String value)
      throws InvalidFieldException, InvalidFieldValueException {

    switch (index) {
      case FIELD_NAME:
        vfName = value;
        if (!inSetup) {
          hasChanged[FIELD_NAME] = true;
          fireFieldChanged(FIELD_NAME);
        }
        break;

      default:
        super.setValue(index, value);
    }
  }
  /**
   * Set the value of the field at the given index as an array of floats. This would be used to set
   * MFFloat field type avatarSize.
   *
   * @param index The index of destination field to set
   * @param value The new value to use for the node
   * @param numValid The number of valid values to copy from the array
   * @throws InvalidFieldException The field index is not known
   */
  public void setValue(int index, float[] value, int numValid)
      throws InvalidFieldException, InvalidFieldValueException {

    switch (index) {
      case FIELD_BOUNDARY_COLOR:
        if (!inSetup) throw new InvalidFieldAccessException("Cannot set boundaryColor field.");

        vfBoundaryColor[0] = value[0];
        vfBoundaryColor[1] = value[1];
        vfBoundaryColor[2] = value[2];
        vfBoundaryColor[3] = value[3];
        break;

      default:
        super.setValue(index, value, numValid);
    }
  }
  /**
   * Set the value of the field at the given index as a node. This would be used to set SFNode field
   * types.
   *
   * @param index The index of destination field to set
   * @param value The new value to use for the node
   * @throws InvalidFieldValueException The node does not match the required type.
   */
  public void setValue(int index, VRMLNodeType child)
      throws InvalidFieldException, InvalidFieldValueException {

    VRMLNodeType node = child;

    switch (index) {
      case FIELD_SHAPE:
        setShape(node);
        break;

      default:
        super.setValue(index, child);
    }

    if (!inSetup) {
      hasChanged[index] = true;
      fireFieldChanged(index);
    }
  }
  /**
   * Set the value of the field at the given index as an array of nodes. This would be used to set
   * MFNode field types.
   *
   * @param index The index of destination field to set
   * @param children The new nodes to use for the children
   * @throws InvalidFieldException The index does not match a known field
   */
  public void setValue(int index, VRMLNodeType[] children, int numValid)
      throws InvalidFieldException {

    switch (index) {
      case FIELD_CHILDREN:
        if (!inSetup) clearChildren();

        // Only add non-null nodes here. This is different to the
        // normal grouping node where a null is a significant item
        // in a child list. For the world root, there is no such
        // value.
        for (int i = 0; i < numValid; i++) if (children[i] != null) addChildNode(children[i]);

        hasChanged[FIELD_CHILDREN] = true;
        break;

      default:
        super.setValue(index, children, numValid);
    }
  }
  /**
   * Set the value of the field at the given index as a string. This would be used to set the
   * SFString field type "type".
   *
   * @param index The index of destination field to set
   * @param value The new value to use for the node
   * @throws InvalidFieldException The field index is not know
   */
  public void setValue(int index, String value)
      throws InvalidFieldException, InvalidFieldValueException {

    switch (index) {
      case FIELD_BOUNDARY_MODE_S:
        if (!inSetup) throw new InvalidFieldAccessException("Cannot set boundaryModeS field.");

        vfBoundaryModeS = value;
        break;

      case FIELD_BOUNDARY_MODE_T:
        if (!inSetup) throw new InvalidFieldAccessException("Cannot set boundaryModeT field.");

        vfBoundaryModeT = value;
        break;

      case FIELD_MAGNIFICATION_FILTER:
        if (!inSetup)
          throw new InvalidFieldAccessException("Cannot set magnificationFilter field.");

        vfMagnificationFilter = value;
        break;

      case FIELD_MINIFICATION_FILTER:
        if (!inSetup) throw new InvalidFieldAccessException("Cannot set minificationFilter field.");

        vfMinificationFilter = value;
        break;

      case FIELD_ANISOTROPIC_MODE:
        if (!inSetup) throw new InvalidFieldAccessException("Cannot set anistropicMode field.");

        vfAnisotropicMode = value;
        break;

      default:
        super.setValue(index, value);
    }
  }