Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
Source Code for Connector/J 8.0.31 - User Impl
Where to get the Java source code for Connector/J 8.0 User Impl module?
✍: FYIcenter.com
Java source code files for Connector/J 8.0 User Impl module are:
⏎ com/mysql/cj/xdevapi/ExprUtil.java
/* * Copyright (c) 2015, 2020, Oracle and/or its affiliates. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License, version 2.0, as published by the * Free Software Foundation. * * This program is also distributed with certain software (including but not * limited to OpenSSL) that is licensed under separate terms, as designated in a * particular file or component or in included license documentation. The * authors of MySQL hereby grant you an additional permission to link the * program and your derivative works with the separately licensed software that * they have included with MySQL. * * Without limiting anything contained in the foregoing, this file, which is * part of MySQL Connector/J, is also subject to the Universal FOSS Exception, * version 1.0, a copy of which can be found at * http://oss.oracle.com/licenses/universal-foss-exception. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, * for more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.mysql.cj.xdevapi; import java.math.BigDecimal; import java.math.BigInteger; import java.sql.Date; import java.sql.Time; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.stream.Collectors; import com.google.protobuf.ByteString; import com.mysql.cj.exceptions.FeatureNotAvailableException; import com.mysql.cj.exceptions.WrongArgumentException; import com.mysql.cj.util.TimeUtil; import com.mysql.cj.x.protobuf.MysqlxCrud.Collection; import com.mysql.cj.x.protobuf.MysqlxDatatypes.Any; import com.mysql.cj.x.protobuf.MysqlxDatatypes.Scalar; import com.mysql.cj.x.protobuf.MysqlxDatatypes.Scalar.Octets; import com.mysql.cj.x.protobuf.MysqlxExpr.Expr; /** * Utilities to deal with Expr (and related) structures. */ public class ExprUtil { // Date formats for sending dates and times to the server as strings. private static SimpleDateFormat javaSqlDateFormat = TimeUtil.getSimpleDateFormat(null, "yyyy-MM-dd", null); private static SimpleDateFormat javaSqlTimestampFormat = TimeUtil.getSimpleDateFormat(null, "yyyy-MM-dd'T'HH:mm:ss.S", null); private static SimpleDateFormat javaSqlTimeFormat = TimeUtil.getSimpleDateFormat(null, "HH:mm:ss.S", null); private static SimpleDateFormat javaUtilDateFormat = TimeUtil.getSimpleDateFormat(null, "yyyy-MM-dd'T'HH:mm:ss.S", null); /** * Protocol buffers helper to build a LITERAL Expr with a Scalar NULL type. * * @return {@link Expr} */ public static Expr buildLiteralNullScalar() { return buildLiteralExpr(nullScalar()); } /** * Protocol buffers helper to build a LITERAL Expr with a Scalar DOUBLE type. * * @param d * value * @return {@link Expr} */ public static Expr buildLiteralScalar(double d) { return buildLiteralExpr(scalarOf(d)); } /** * Protocol buffers helper to build a LITERAL Expr with a Scalar SINT (signed int) type. * * @param l * value * @return {@link Expr} */ public static Expr buildLiteralScalar(long l) { return buildLiteralExpr(scalarOf(l)); } /** * Protocol buffers helper to build a LITERAL Expr with a Scalar STRING type. * * @param str * value * @return {@link Expr} */ public static Expr buildLiteralScalar(String str) { return buildLiteralExpr(scalarOf(str)); } /** * Protocol buffers helper to build a LITERAL Expr with a Scalar OCTETS type. * * @param bytes * value * @return {@link Expr} */ public static Expr buildLiteralScalar(byte[] bytes) { return buildLiteralExpr(scalarOf(bytes)); } /** * Protocol buffers helper to build a LITERAL Expr with a Scalar BOOL type. * * @param b * value * @return {@link Expr} */ public static Expr buildLiteralScalar(boolean b) { return buildLiteralExpr(scalarOf(b)); } /** * Wrap an Any value in a LITERAL expression. * * @param scalar * {@link Scalar} * @return {@link Expr} */ public static Expr buildLiteralExpr(Scalar scalar) { return Expr.newBuilder().setType(Expr.Type.LITERAL).setLiteral(scalar).build(); } /** * Creates a placeholder expression for the given position in the <code>args</code> array * * @param pos * the position of the placeholder in the <code>args</code> array * @return {@link Expr} */ public static Expr buildPlaceholderExpr(int pos) { return Expr.newBuilder().setType(Expr.Type.PLACEHOLDER).setPosition(pos).build(); } /** * Protocol buffers helper to build a Scalar NULL type. * * @return {@link Scalar} */ public static Scalar nullScalar() { return Scalar.newBuilder().setType(Scalar.Type.V_NULL).build(); } /** * Protocol buffers helper to build a Scalar DOUBLE type. * * @param d * value * @return {@link Scalar} */ public static Scalar scalarOf(double d) { return Scalar.newBuilder().setType(Scalar.Type.V_DOUBLE).setVDouble(d).build(); } /** * Protocol buffers helper to build a Scalar SINT (signed int) type. * * @param l * value * @return {@link Scalar} */ public static Scalar scalarOf(long l) { return Scalar.newBuilder().setType(Scalar.Type.V_SINT).setVSignedInt(l).build(); } /** * Protocol buffers helper to build a Scalar STRING type. * * @param str * value * @return {@link Scalar} */ public static Scalar scalarOf(String str) { Scalar.String sstr = Scalar.String.newBuilder().setValue(ByteString.copyFromUtf8(str)).build(); return Scalar.newBuilder().setType(Scalar.Type.V_STRING).setVString(sstr).build(); } /** * Protocol buffers helper to build a Scalar OCTETS type. * * @param bytes * value * @return {@link Scalar} */ public static Scalar scalarOf(byte[] bytes) { Octets.Builder o = Octets.newBuilder().setValue(ByteString.copyFrom(bytes)); return Scalar.newBuilder().setType(Scalar.Type.V_OCTETS).setVOctets(o).build(); } /** * Protocol buffers helper to build a Scalar BOOL type. * * @param b * value * @return {@link Scalar} */ public static Scalar scalarOf(boolean b) { return Scalar.newBuilder().setType(Scalar.Type.V_BOOL).setVBool(b).build(); } /** * Protocol buffers helper to build an Any Scalar type. * * @param s * value * @return {@link Any} */ public static Any anyOf(Scalar s) { return Any.newBuilder().setType(Any.Type.SCALAR).setScalar(s).build(); } /** * Build a Protocol buffers Any with a string value. * * @param str * value * @return {@link Any} */ public static Any buildAny(String str) { // same as Expr Scalar.String sstr = Scalar.String.newBuilder().setValue(ByteString.copyFromUtf8(str)).build(); Scalar s = Scalar.newBuilder().setType(Scalar.Type.V_STRING).setVString(sstr).build(); return anyOf(s); } /** * Build a Protocol buffers Any with a boolean value. * * @param b * value * @return {@link Any} */ public static Any buildAny(boolean b) { return Any.newBuilder().setType(Any.Type.SCALAR).setScalar(scalarOf(b)).build(); } /** * Build a Protocol buffers Collection. * * @param schemaName * schema name * @param collectionName * collection name * @return {@link Collection} */ public static Collection buildCollection(String schemaName, String collectionName) { return Collection.newBuilder().setSchema(schemaName).setName(collectionName).build(); } /** * Protocol buffers helper to build a Scalar type with any object. * * @param value * value * @return {@link Scalar} */ public static Scalar argObjectToScalar(Object value) { Expr e = argObjectToExpr(value, false); if (!e.hasLiteral()) { throw new WrongArgumentException("No literal interpretation of argument: " + value); } return e.getLiteral(); } /** * Protocol buffers helper to build an Any type with any object. * * @param value * value * @return {@link Any} */ public static Any argObjectToScalarAny(Object value) { Scalar s = argObjectToScalar(value); return Any.newBuilder().setType(Any.Type.SCALAR).setScalar(s).build(); } /** * Protocol buffers helper to build Expr with any object. * * @param value * value * @param allowRelationalColumns * Are relational columns identifiers allowed? * @return {@link Expr} */ public static Expr argObjectToExpr(Object value, boolean allowRelationalColumns) { if (value == null) { return buildLiteralNullScalar(); } Class<? extends Object> cls = value.getClass(); if (cls == Boolean.class) { return buildLiteralScalar((boolean) value); } else if (cls == Byte.class || cls == Short.class || cls == Integer.class || cls == Long.class || cls == BigInteger.class) { return buildLiteralScalar(((Number) value).longValue()); } else if (cls == Float.class || cls == Double.class || cls == BigDecimal.class) { return buildLiteralScalar(((Number) value).doubleValue()); } else if (cls == String.class) { return buildLiteralScalar((String) value); } else if (cls == Character.class) { return buildLiteralScalar(((Character) value).toString()); } else if (cls == Expression.class) { return new ExprParser(((Expression) value).getExpressionString(), allowRelationalColumns).parse(); } else if (cls == Date.class) { return buildLiteralScalar(javaSqlDateFormat.format((java.util.Date) value)); } else if (cls == Time.class) { return buildLiteralScalar(javaSqlTimeFormat.format((java.util.Date) value)); } else if (cls == Timestamp.class) { return buildLiteralScalar(javaSqlTimestampFormat.format((java.util.Date) value)); } else if (cls == java.util.Date.class) { return buildLiteralScalar(javaUtilDateFormat.format((java.util.Date) value)); } else if (DbDoc.class.isAssignableFrom(cls)) { return (new ExprParser(((DbDoc) value).toString())).parse(); } else if (cls == JsonArray.class) { return Expr.newBuilder().setType(Expr.Type.ARRAY).setArray(Expr.newBuilder().setType(Expr.Type.ARRAY).getArrayBuilder() .addAllValue(((JsonArray) value).stream().map(f -> ExprUtil.argObjectToExpr(f, true)).collect(Collectors.toList()))).build(); } else if (cls == JsonString.class) { return buildLiteralScalar(((JsonString) value).getString()); } else if (cls == JsonNumber.class) { return buildLiteralScalar(((JsonNumber) value).getInteger()); } // TODO other types: LocalDate... throw new FeatureNotAvailableException("Can not create an expression from " + cls); } }
⏎ com/mysql/cj/xdevapi/ExprUtil.java
Or download all of them as a single archive file:
File name: mysql-connector-java-user-impl-8.0.31.zip File size: 429580 bytes Release date: 2022-09-03 Download
⇒ Downloading mysql-connector-java-5.1.40.zip
⇐ Source Code for Connector/J 8.0.31 - User API
2023-05-09, 7702👍, 0💬
Popular Posts:
JDK 11 java.compiler.jmod is the JMOD file for JDK 11 Compiler module. JDK 11 Compiler module compil...
What Is mail.jar of JavaMail 1.4.2? I got the JAR file from javamail-1.4.2.zip. mail.jar in javamail...
What is jxl.jar 2.6.12? jxl.jar 2.6.12 is the JAR file for Java Excel API 2.6.12, which is a Java li...
JDK 11 java.sql.jmod is the JMOD file for JDK 11 SQL (Structured Query Language) module. JDK 11 SQL ...
JDK 11 jdk.scripting.nashorn.jm odis the JMOD file for JDK 11 Scripting Nashorn module. JDK 11 Scrip...