public class PipeFunctions extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,PipeFunction> |
exposedFunction |
| Constructor and Description |
|---|
PipeFunctions() |
| Modifier and Type | Method and Description |
|---|---|
Object |
array(Query query,
Object in,
Object... args)
Create string SQL Array representation of value, where each array item
is replace by '?'
|
Object |
collection(Query query,
Object in,
Object... args) |
Map<String,PipeFunction> |
getExposedFunction() |
protected String[] |
getFieldType(String field,
boolean appendDelim) |
protected boolean |
isRow(String fields)
try to match multiple fields with comma separator
ex: "bidulle.truc, bidulle.machin, bidulle.email[0]"
|
Object |
json(Query query,
Object in,
Object... args)
convert value to json and add it to query parameter
|
protected Object |
map(boolean forceCollection,
Object value,
org.nuiton.spgeed.PipeFunctions.MapFunction f)
Call f.map for each element in value.
|
Object |
map(Query query,
Object in,
Object... args)
Convert each value in parameter 'in'
|
Object |
row(Query query,
Object in,
Object... args) |
Object |
toParam(Query query,
Object in,
Object... args)
Add value to query parameter and return string substitution '?'
|
Object |
toString(Query query,
Object in,
Object... args)
convert value to string value and return it
|
Object |
values(Query query,
Object in,
Object... args)
create sql insert value string, support 'in' as object or collection
ex: "insert into mytable (id, myfield) values ${myobject |values('id', 'myfield)}"
return "insert into mytable (id, myfield) values (?
|
protected Map<String,PipeFunction> exposedFunction
public Map<String,PipeFunction> getExposedFunction()
protected Object map(boolean forceCollection, Object value, org.nuiton.spgeed.PipeFunctions.MapFunction f) throws Exception
forceCollection - if true result is always a collection.
if value is null return empty collection
if value is object return collection with one item
if value is array or collection return collection with same item numbervalue - Collection or Array or Objectf - function used to map objectExceptionprotected boolean isRow(String fields)
fields - protected String[] getFieldType(String field, boolean appendDelim)
field - appendDelim - if true, append "::" before typepublic Object toParam(Query query, Object in, Object... args) throws Exception
query - current queryin - value to convert to paramargs - only one argument. This argument must be cast per example
"::json", is used to add "::json" (type must be postgresql type)
you can specify field name before type, to extract only one field from in value
ex: birthdate::intExceptionpublic Object toString(Query query, Object in, Object... args)
query - current queryin - value to convert to stringargs - not usedpublic Object json(Query query, Object in, Object... args) throws com.fasterxml.jackson.core.JsonProcessingException, SQLException
query - current queryin - value to convert to jsonargs - not usedcom.fasterxml.jackson.core.JsonProcessingExceptionSQLExceptionpublic Object array(Query query, Object in, Object... args) throws Exception
query - current queryin - Must be Collection or Array, each element is one element in sql ARRAYargs - not usedExceptionpublic Object collection(Query query, Object in, Object... args) throws Exception
Exceptionpublic Object values(Query query, Object in, Object... args) throws Exception
query - current queryin - object or collection of object used to create valuesargs - list of field to extract as value parameterExceptionpublic Object map(Query query, Object in, Object... args) throws Exception
query - current queryin - Collection to convertargs - field to extract from each object in parameter 'in'ExceptionCopyright © 2017–2019 CodeLutin. All rights reserved.