Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions src/main/java/net/sf/jsqlparser/statement/CastSignature.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*-
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2026 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement;

import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
import net.sf.jsqlparser.statement.create.table.ColDataType;

/**
* A PostgreSQL cast, named by the types it converts between: {@code (source_type AS target_type)},
* as in {@code DROP CAST (text AS integer)}.
*/
public class CastSignature extends ASTNodeAccessImpl {

private ColDataType sourceType;
private ColDataType targetType;

public CastSignature() {
// the types are set by the parser or the setters
}

public CastSignature(ColDataType sourceType, ColDataType targetType) {
this.sourceType = sourceType;
this.targetType = targetType;
}

public ColDataType getSourceType() {
return sourceType;
}

public void setSourceType(ColDataType sourceType) {
this.sourceType = sourceType;
}

public CastSignature withSourceType(ColDataType sourceType) {
setSourceType(sourceType);
return this;
}

public ColDataType getTargetType() {
return targetType;
}

public void setTargetType(ColDataType targetType) {
this.targetType = targetType;
}

public CastSignature withTargetType(ColDataType targetType) {
setTargetType(targetType);
return this;
}

@Override
public StringBuilder appendTo(StringBuilder builder) {
return builder.append('(').append(sourceType).append(" AS ").append(targetType)
.append(')');
}

@Override
public String toString() {
return appendTo(new StringBuilder()).toString();
}
}
95 changes: 95 additions & 0 deletions src/main/java/net/sf/jsqlparser/statement/OperatorSignature.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*-
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2026 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement;

import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
import net.sf.jsqlparser.statement.create.table.ColDataType;
import net.sf.jsqlparser.statement.create.table.ExclusionOperator;

/**
* A PostgreSQL operator, named by its possibly schema-qualified symbol and its operand types:
* {@code [schema.]op ({left_type | NONE}, {right_type | NONE})}, as in
* {@code DROP OPERATOR ~ (NONE, bigint)}. A null operand type is the NONE marker of a missing
* operand, and is rendered as {@code NONE}.
*/
public class OperatorSignature extends ASTNodeAccessImpl {

private ExclusionOperator operator;
private ColDataType leftType;
private ColDataType rightType;

public OperatorSignature() {
// the operator and its operand types are set by the parser or the setters
}

public OperatorSignature(ExclusionOperator operator, ColDataType leftType,
ColDataType rightType) {
this.operator = operator;
this.leftType = leftType;
this.rightType = rightType;
}

/** The operator symbol and its schema, read by the reference COMMENT ON OPERATOR uses. */
public ExclusionOperator getOperator() {
return operator;
}

public void setOperator(ExclusionOperator operator) {
this.operator = operator;
}

public OperatorSignature withOperator(ExclusionOperator operator) {
setOperator(operator);
return this;
}

/** The left operand type, or null for NONE, the missing left operand of a prefix operator. */
public ColDataType getLeftType() {
return leftType;
}

public void setLeftType(ColDataType leftType) {
this.leftType = leftType;
}

public OperatorSignature withLeftType(ColDataType leftType) {
setLeftType(leftType);
return this;
}

/** The right operand type, or null for NONE. */
public ColDataType getRightType() {
return rightType;
}

public void setRightType(ColDataType rightType) {
this.rightType = rightType;
}

public OperatorSignature withRightType(ColDataType rightType) {
setRightType(rightType);
return this;
}

@Override
public StringBuilder appendTo(StringBuilder builder) {
return builder.append(operator).append(" (").append(operand(leftType)).append(", ")
.append(operand(rightType)).append(')');
}

private static Object operand(ColDataType type) {
return type == null ? "NONE" : type;
}

@Override
public String toString() {
return appendTo(new StringBuilder()).toString();
}
}
69 changes: 69 additions & 0 deletions src/main/java/net/sf/jsqlparser/statement/TransformSignature.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*-
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2026 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement;

import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
import net.sf.jsqlparser.statement.create.table.ColDataType;

/**
* A PostgreSQL transform, named by the data type and the procedural language it connects:
* {@code FOR type_name LANGUAGE lang_name}, as in
* {@code DROP TRANSFORM FOR hstore LANGUAGE plpython3u}.
*/
public class TransformSignature extends ASTNodeAccessImpl {

private ColDataType dataType;
private String language;

public TransformSignature() {
// the type and language are set by the parser or the setters
}

public TransformSignature(ColDataType dataType, String language) {
this.dataType = dataType;
this.language = language;
}

public ColDataType getDataType() {
return dataType;
}

public void setDataType(ColDataType dataType) {
this.dataType = dataType;
}

public TransformSignature withDataType(ColDataType dataType) {
setDataType(dataType);
return this;
}

public String getLanguage() {
return language;
}

public void setLanguage(String language) {
this.language = language;
}

public TransformSignature withLanguage(String language) {
setLanguage(language);
return this;
}

@Override
public StringBuilder appendTo(StringBuilder builder) {
return builder.append("FOR ").append(dataType).append(" LANGUAGE ").append(language);
}

@Override
public String toString() {
return appendTo(new StringBuilder()).toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/**
* An exclusion operator, optionally qualified and enclosed in PostgreSQL OPERATOR(...). COMMENT ON
* OPERATOR uses the same reference without the OPERATOR keyword.
* OPERATOR and DROP OPERATOR use the same reference without the OPERATOR keyword.
*/
public class ExclusionOperator implements Serializable {
private String schemaName;
Expand Down
Loading
Loading