All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.persistence.jpa.jpql.tools.model.query.UpdateStatementStateObject Maven / Gradle / Ivy

/*
 * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0,
 * or the Eclipse Distribution License v. 1.0 which is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
 */

// Contributors:
//     Oracle - initial API and implementation
//
package org.eclipse.persistence.jpa.jpql.tools.model.query;

import org.eclipse.persistence.jpa.jpql.parser.UpdateStatement;

/**
 * The UPDATE clause of a query consists of a conditional expression used to
 * select objects or values that satisfy the expression. The UPDATE clause
 * restricts the result of a select statement or the scope of an update operation.
 *
 * 
BNF: update_statement ::= update_clause [where_clause]

* * @see UpdateStatement * * @version 2.4 * @since 2.4 * @author Pascal Filion */ public class UpdateStatementStateObject extends AbstractModifyStatementStateObject { /** * Creates a new UpdateStatementStateObject. * * @param parent The parent of this state object, which cannot be null * @exception NullPointerException The given parent cannot be null */ public UpdateStatementStateObject(JPQLQueryStateObject parent) { super(parent); } /** * {@inheritDoc} */ public void accept(StateObjectVisitor visitor) { visitor.visit(this); } /** * Adds a new item to the UPDATE clause. * * @param path The path of the value to update * @return The newly added {@link UpdateItemStateObject} */ public UpdateItemStateObject addItem(String path) { return getModifyClause().addItem(path); } /** * Adds a new item to the UPDATE clause. * * @param path The path of the value to update * @param newValue The {@link StateObject} representation of the new value * @return The newly added {@link UpdateItemStateObject} */ public UpdateItemStateObject addItem(String path, StateObject newValue) { return getModifyClause().addItem(path, newValue); } /** * Adds a new item to the UPDATE clause. * * @param path The path of the value to update * @param newValue The string representation of the new value to parse and to convert into a * {@link StateObject} representation * @return The newly added {@link UpdateItemStateObject} */ public UpdateItemStateObject addItem(String path, String newValue) { return getModifyClause().addItem(path, newValue); } /** * {@inheritDoc} */ @Override protected AbstractModifyClauseStateObject buildModifyClause() { return new UpdateClauseStateObject(this); } /** * {@inheritDoc} */ @Override public UpdateStatement getExpression() { return (UpdateStatement) super.getExpression(); } /** * Returns the state object representing the UPDATE clause. * * @return The state object representing the UPDATE clause, which is never * null */ @Override public UpdateClauseStateObject getModifyClause() { return (UpdateClauseStateObject) super.getModifyClause(); } /** * Keeps a reference of the {@link UpdateStatement parsed object} object, which should only be * done when this object is instantiated during the conversion of a parsed JPQL query into * {@link StateObject StateObjects}. * * @param expression The {@link UpdateStatement parsed object} representing an UpdateStatement * statement */ public void setExpression(UpdateStatement expression) { super.setExpression(expression); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy