repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
karsany/obridge
|
obridge-main/src/test/java/org/obridge/OBridgeTest.java
|
// Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java
// public class OBridgeConfiguration {
//
// public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false;
// public static final boolean ADD_ASSERT = false;
//
// private String jdbcUrl;
// private String sourceRoot;
// private String rootPackageName;
// private Packages packages;
// private Logging logging;
// private String packagesLike;
// private String sourceOwner;
// private String projectName;
// private String sourcesTableProc;
// private String sourcesTable;
//
// public String getPackagesLike() {
// if (packagesLike == null) {
// return "%";
// }
// return packagesLike;
// }
//
// public void setPackagesLike(String packagesLike) {
// this.packagesLike = packagesLike;
// }
//
// public String getSourceOwner() {
// return sourceOwner;
// }
//
// public void setSourceOwner(String sourceOwner) {
// this.sourceOwner = sourceOwner;
// }
//
// public String getJdbcUrl() {
// return jdbcUrl;
// }
//
// public void setJdbcUrl(String jdbcUrl) {
// this.jdbcUrl = jdbcUrl;
// }
//
// public String getSourceRoot() {
// return sourceRoot;
// }
//
// public void setSourceRoot(String sourceRoot) {
// this.sourceRoot = sourceRoot;
// }
//
// public String getRootPackageName() {
// return rootPackageName;
// }
//
// public void setRootPackageName(String rootPackageName) {
// this.rootPackageName = rootPackageName;
// }
//
// public Packages getPackages() {
// return packages;
// }
//
// public void setPackages(Packages packages) {
// this.packages = packages;
// }
//
// public Logging getLogging() {
// return logging;
// }
//
// public void setLogging(Logging logging) {
// this.logging = logging;
// }
//
// public String getSourcesTable() {
// return sourcesTable;
// }
//
// public void setSourcesTable(String sourcesTable) {
// this.sourcesTable = sourcesTable;
// }
//
// public String getSourcesTableProc() {
// return sourcesTableProc;
// }
//
// public String getProjectName() { return projectName == null ? "default": projectName; }
//
// public void setProjectName(String projectName) { this.projectName = projectName; }
// }
//
// Path: obridge-main/src/main/java/org/obridge/context/Packages.java
// public class Packages {
//
// private String entityObjects = "objects";
// private String converterObjects = "converters";
// private String procedureContextObjects = "context";
// private String packageObjects = "packages";
//
// public String getEntityObjects() {
// return entityObjects;
// }
//
// public void setEntityObjects(String entityObjects) {
// this.entityObjects = entityObjects;
// }
//
// public String getConverterObjects() {
// return converterObjects;
// }
//
// public void setConverterObjects(String converterObjects) {
// this.converterObjects = converterObjects;
// }
//
// public String getProcedureContextObjects() {
// return procedureContextObjects;
// }
//
// public void setProcedureContextObjects(String procedureContextObjects) {
// this.procedureContextObjects = procedureContextObjects;
// }
//
// public String getPackageObjects() {
// return packageObjects;
// }
//
// public void setPackageObjects(String packageObjects) {
// this.packageObjects = packageObjects;
// }
//
// }
|
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.obridge.context.OBridgeConfiguration;
import org.obridge.context.Packages;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.obridge;
/**
* @author fkarsany
*/
public class OBridgeTest {
@Rule
public TemporaryFolder tempdir = new TemporaryFolder();
public OBridgeTest() {
}
@Test
public void testMain() {
OBridge.main("-h");
OBridge.main("-v");
}
@Test
public void fullTest() throws IOException, InterruptedException {
Properties p = new Properties();
p.load(getClass().getClassLoader().getResourceAsStream("datasource.properties"));
OBridgeConfiguration oBridgeConfiguration = new OBridgeConfiguration();
oBridgeConfiguration.setJdbcUrl(p.getProperty("connectionString"));
|
// Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java
// public class OBridgeConfiguration {
//
// public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false;
// public static final boolean ADD_ASSERT = false;
//
// private String jdbcUrl;
// private String sourceRoot;
// private String rootPackageName;
// private Packages packages;
// private Logging logging;
// private String packagesLike;
// private String sourceOwner;
// private String projectName;
// private String sourcesTableProc;
// private String sourcesTable;
//
// public String getPackagesLike() {
// if (packagesLike == null) {
// return "%";
// }
// return packagesLike;
// }
//
// public void setPackagesLike(String packagesLike) {
// this.packagesLike = packagesLike;
// }
//
// public String getSourceOwner() {
// return sourceOwner;
// }
//
// public void setSourceOwner(String sourceOwner) {
// this.sourceOwner = sourceOwner;
// }
//
// public String getJdbcUrl() {
// return jdbcUrl;
// }
//
// public void setJdbcUrl(String jdbcUrl) {
// this.jdbcUrl = jdbcUrl;
// }
//
// public String getSourceRoot() {
// return sourceRoot;
// }
//
// public void setSourceRoot(String sourceRoot) {
// this.sourceRoot = sourceRoot;
// }
//
// public String getRootPackageName() {
// return rootPackageName;
// }
//
// public void setRootPackageName(String rootPackageName) {
// this.rootPackageName = rootPackageName;
// }
//
// public Packages getPackages() {
// return packages;
// }
//
// public void setPackages(Packages packages) {
// this.packages = packages;
// }
//
// public Logging getLogging() {
// return logging;
// }
//
// public void setLogging(Logging logging) {
// this.logging = logging;
// }
//
// public String getSourcesTable() {
// return sourcesTable;
// }
//
// public void setSourcesTable(String sourcesTable) {
// this.sourcesTable = sourcesTable;
// }
//
// public String getSourcesTableProc() {
// return sourcesTableProc;
// }
//
// public String getProjectName() { return projectName == null ? "default": projectName; }
//
// public void setProjectName(String projectName) { this.projectName = projectName; }
// }
//
// Path: obridge-main/src/main/java/org/obridge/context/Packages.java
// public class Packages {
//
// private String entityObjects = "objects";
// private String converterObjects = "converters";
// private String procedureContextObjects = "context";
// private String packageObjects = "packages";
//
// public String getEntityObjects() {
// return entityObjects;
// }
//
// public void setEntityObjects(String entityObjects) {
// this.entityObjects = entityObjects;
// }
//
// public String getConverterObjects() {
// return converterObjects;
// }
//
// public void setConverterObjects(String converterObjects) {
// this.converterObjects = converterObjects;
// }
//
// public String getProcedureContextObjects() {
// return procedureContextObjects;
// }
//
// public void setProcedureContextObjects(String procedureContextObjects) {
// this.procedureContextObjects = procedureContextObjects;
// }
//
// public String getPackageObjects() {
// return packageObjects;
// }
//
// public void setPackageObjects(String packageObjects) {
// this.packageObjects = packageObjects;
// }
//
// }
// Path: obridge-main/src/test/java/org/obridge/OBridgeTest.java
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.obridge.context.OBridgeConfiguration;
import org.obridge.context.Packages;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.obridge;
/**
* @author fkarsany
*/
public class OBridgeTest {
@Rule
public TemporaryFolder tempdir = new TemporaryFolder();
public OBridgeTest() {
}
@Test
public void testMain() {
OBridge.main("-h");
OBridge.main("-v");
}
@Test
public void fullTest() throws IOException, InterruptedException {
Properties p = new Properties();
p.load(getClass().getClassLoader().getResourceAsStream("datasource.properties"));
OBridgeConfiguration oBridgeConfiguration = new OBridgeConfiguration();
oBridgeConfiguration.setJdbcUrl(p.getProperty("connectionString"));
|
oBridgeConfiguration.setPackages(new Packages());
|
karsany/obridge
|
obridge-main/src/test/java/org/obridge/util/MustacheRunnerTest.java
|
// Path: obridge-main/src/main/java/org/obridge/model/generator/Pojo.java
// public class Pojo {
//
// private String packageName;
// private String className;
// private List<PojoField> fields;
// private String comment;
// private List<String> imports;
// private String generatorName;
//
// public List<String> getImports() {
// return imports;
// }
//
// public void setImports(List<String> imports) {
// this.imports = imports;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public List<PojoField> getFields() {
// return fields;
// }
//
// public void setFields(List<PojoField> fields) {
// this.fields = fields;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// public void setPackageName(String packageName) {
// this.packageName = packageName;
// }
//
// public String getGeneratorName() {
// return generatorName;
// }
//
// public void setGeneratorName(String generatorName) {
// this.generatorName = generatorName;
// }
// }
//
// Path: obridge-main/src/main/java/org/obridge/model/generator/PojoField.java
// public class PojoField {
//
// private String fieldName;
// private String fieldType;
// private boolean readonly;
//
// public String getFieldName() {
// return fieldName;
// }
//
// public void setFieldName(String fieldName) {
// this.fieldName = fieldName;
// }
//
// public String getFieldNameInitCap() {
// return fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
// }
//
// public String getFieldType() {
// return fieldType;
// }
//
// public void setFieldType(String fieldType) {
// this.fieldType = fieldType;
// }
//
// public boolean isReadonly() {
// return readonly;
// }
//
// public void setReadonly(boolean readonly) {
// this.readonly = readonly;
// }
//
// public boolean isSettable() {
// return !isReadonly();
// }
//
// }
|
import org.junit.Assert;
import org.junit.Test;
import org.obridge.model.generator.Pojo;
import org.obridge.model.generator.PojoField;
import java.util.ArrayList;
import java.util.logging.Logger;
|
package org.obridge.util;
public class MustacheRunnerTest {
public static final String COMMENT = "This is a comment";
public static final String PACKAGE_NAME = "hu.karsany.tesztpackage";
private final static String CLASS_NAME = "ExampleClass";
@Test
public void pojoMustacheTest() {
|
// Path: obridge-main/src/main/java/org/obridge/model/generator/Pojo.java
// public class Pojo {
//
// private String packageName;
// private String className;
// private List<PojoField> fields;
// private String comment;
// private List<String> imports;
// private String generatorName;
//
// public List<String> getImports() {
// return imports;
// }
//
// public void setImports(List<String> imports) {
// this.imports = imports;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public List<PojoField> getFields() {
// return fields;
// }
//
// public void setFields(List<PojoField> fields) {
// this.fields = fields;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// public void setPackageName(String packageName) {
// this.packageName = packageName;
// }
//
// public String getGeneratorName() {
// return generatorName;
// }
//
// public void setGeneratorName(String generatorName) {
// this.generatorName = generatorName;
// }
// }
//
// Path: obridge-main/src/main/java/org/obridge/model/generator/PojoField.java
// public class PojoField {
//
// private String fieldName;
// private String fieldType;
// private boolean readonly;
//
// public String getFieldName() {
// return fieldName;
// }
//
// public void setFieldName(String fieldName) {
// this.fieldName = fieldName;
// }
//
// public String getFieldNameInitCap() {
// return fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
// }
//
// public String getFieldType() {
// return fieldType;
// }
//
// public void setFieldType(String fieldType) {
// this.fieldType = fieldType;
// }
//
// public boolean isReadonly() {
// return readonly;
// }
//
// public void setReadonly(boolean readonly) {
// this.readonly = readonly;
// }
//
// public boolean isSettable() {
// return !isReadonly();
// }
//
// }
// Path: obridge-main/src/test/java/org/obridge/util/MustacheRunnerTest.java
import org.junit.Assert;
import org.junit.Test;
import org.obridge.model.generator.Pojo;
import org.obridge.model.generator.PojoField;
import java.util.ArrayList;
import java.util.logging.Logger;
package org.obridge.util;
public class MustacheRunnerTest {
public static final String COMMENT = "This is a comment";
public static final String PACKAGE_NAME = "hu.karsany.tesztpackage";
private final static String CLASS_NAME = "ExampleClass";
@Test
public void pojoMustacheTest() {
|
Pojo pojo = new Pojo();
|
karsany/obridge
|
obridge-main/src/test/java/org/obridge/util/MustacheRunnerTest.java
|
// Path: obridge-main/src/main/java/org/obridge/model/generator/Pojo.java
// public class Pojo {
//
// private String packageName;
// private String className;
// private List<PojoField> fields;
// private String comment;
// private List<String> imports;
// private String generatorName;
//
// public List<String> getImports() {
// return imports;
// }
//
// public void setImports(List<String> imports) {
// this.imports = imports;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public List<PojoField> getFields() {
// return fields;
// }
//
// public void setFields(List<PojoField> fields) {
// this.fields = fields;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// public void setPackageName(String packageName) {
// this.packageName = packageName;
// }
//
// public String getGeneratorName() {
// return generatorName;
// }
//
// public void setGeneratorName(String generatorName) {
// this.generatorName = generatorName;
// }
// }
//
// Path: obridge-main/src/main/java/org/obridge/model/generator/PojoField.java
// public class PojoField {
//
// private String fieldName;
// private String fieldType;
// private boolean readonly;
//
// public String getFieldName() {
// return fieldName;
// }
//
// public void setFieldName(String fieldName) {
// this.fieldName = fieldName;
// }
//
// public String getFieldNameInitCap() {
// return fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
// }
//
// public String getFieldType() {
// return fieldType;
// }
//
// public void setFieldType(String fieldType) {
// this.fieldType = fieldType;
// }
//
// public boolean isReadonly() {
// return readonly;
// }
//
// public void setReadonly(boolean readonly) {
// this.readonly = readonly;
// }
//
// public boolean isSettable() {
// return !isReadonly();
// }
//
// }
|
import org.junit.Assert;
import org.junit.Test;
import org.obridge.model.generator.Pojo;
import org.obridge.model.generator.PojoField;
import java.util.ArrayList;
import java.util.logging.Logger;
|
package org.obridge.util;
public class MustacheRunnerTest {
public static final String COMMENT = "This is a comment";
public static final String PACKAGE_NAME = "hu.karsany.tesztpackage";
private final static String CLASS_NAME = "ExampleClass";
@Test
public void pojoMustacheTest() {
Pojo pojo = new Pojo();
pojo.setClassName(CLASS_NAME);
pojo.setComment(COMMENT);
pojo.setPackageName(PACKAGE_NAME);
|
// Path: obridge-main/src/main/java/org/obridge/model/generator/Pojo.java
// public class Pojo {
//
// private String packageName;
// private String className;
// private List<PojoField> fields;
// private String comment;
// private List<String> imports;
// private String generatorName;
//
// public List<String> getImports() {
// return imports;
// }
//
// public void setImports(List<String> imports) {
// this.imports = imports;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public List<PojoField> getFields() {
// return fields;
// }
//
// public void setFields(List<PojoField> fields) {
// this.fields = fields;
// }
//
// public String getComment() {
// return comment;
// }
//
// public void setComment(String comment) {
// this.comment = comment;
// }
//
// public String getPackageName() {
// return packageName;
// }
//
// public void setPackageName(String packageName) {
// this.packageName = packageName;
// }
//
// public String getGeneratorName() {
// return generatorName;
// }
//
// public void setGeneratorName(String generatorName) {
// this.generatorName = generatorName;
// }
// }
//
// Path: obridge-main/src/main/java/org/obridge/model/generator/PojoField.java
// public class PojoField {
//
// private String fieldName;
// private String fieldType;
// private boolean readonly;
//
// public String getFieldName() {
// return fieldName;
// }
//
// public void setFieldName(String fieldName) {
// this.fieldName = fieldName;
// }
//
// public String getFieldNameInitCap() {
// return fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
// }
//
// public String getFieldType() {
// return fieldType;
// }
//
// public void setFieldType(String fieldType) {
// this.fieldType = fieldType;
// }
//
// public boolean isReadonly() {
// return readonly;
// }
//
// public void setReadonly(boolean readonly) {
// this.readonly = readonly;
// }
//
// public boolean isSettable() {
// return !isReadonly();
// }
//
// }
// Path: obridge-main/src/test/java/org/obridge/util/MustacheRunnerTest.java
import org.junit.Assert;
import org.junit.Test;
import org.obridge.model.generator.Pojo;
import org.obridge.model.generator.PojoField;
import java.util.ArrayList;
import java.util.logging.Logger;
package org.obridge.util;
public class MustacheRunnerTest {
public static final String COMMENT = "This is a comment";
public static final String PACKAGE_NAME = "hu.karsany.tesztpackage";
private final static String CLASS_NAME = "ExampleClass";
@Test
public void pojoMustacheTest() {
Pojo pojo = new Pojo();
pojo.setClassName(CLASS_NAME);
pojo.setComment(COMMENT);
pojo.setPackageName(PACKAGE_NAME);
|
pojo.setFields(new ArrayList<PojoField>());
|
karsany/obridge
|
obridge-main/src/main/java/org/obridge/util/XStreamFactory.java
|
// Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java
// public class OBridgeConfiguration {
//
// public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false;
// public static final boolean ADD_ASSERT = false;
//
// private String jdbcUrl;
// private String sourceRoot;
// private String rootPackageName;
// private Packages packages;
// private Logging logging;
// private String packagesLike;
// private String sourceOwner;
// private String projectName;
// private String sourcesTableProc;
// private String sourcesTable;
//
// public String getPackagesLike() {
// if (packagesLike == null) {
// return "%";
// }
// return packagesLike;
// }
//
// public void setPackagesLike(String packagesLike) {
// this.packagesLike = packagesLike;
// }
//
// public String getSourceOwner() {
// return sourceOwner;
// }
//
// public void setSourceOwner(String sourceOwner) {
// this.sourceOwner = sourceOwner;
// }
//
// public String getJdbcUrl() {
// return jdbcUrl;
// }
//
// public void setJdbcUrl(String jdbcUrl) {
// this.jdbcUrl = jdbcUrl;
// }
//
// public String getSourceRoot() {
// return sourceRoot;
// }
//
// public void setSourceRoot(String sourceRoot) {
// this.sourceRoot = sourceRoot;
// }
//
// public String getRootPackageName() {
// return rootPackageName;
// }
//
// public void setRootPackageName(String rootPackageName) {
// this.rootPackageName = rootPackageName;
// }
//
// public Packages getPackages() {
// return packages;
// }
//
// public void setPackages(Packages packages) {
// this.packages = packages;
// }
//
// public Logging getLogging() {
// return logging;
// }
//
// public void setLogging(Logging logging) {
// this.logging = logging;
// }
//
// public String getSourcesTable() {
// return sourcesTable;
// }
//
// public void setSourcesTable(String sourcesTable) {
// this.sourcesTable = sourcesTable;
// }
//
// public String getSourcesTableProc() {
// return sourcesTableProc;
// }
//
// public String getProjectName() { return projectName == null ? "default": projectName; }
//
// public void setProjectName(String projectName) { this.projectName = projectName; }
// }
|
import com.thoughtworks.xstream.XStream;
import org.obridge.context.OBridgeConfiguration;
|
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 Ferenc Karsany
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package org.obridge.util;
/**
* @author fkarsany
*/
public class XStreamFactory {
private XStreamFactory() {
}
public static XStream createXStream() {
XStream xStream = new XStream();
|
// Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java
// public class OBridgeConfiguration {
//
// public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false;
// public static final boolean ADD_ASSERT = false;
//
// private String jdbcUrl;
// private String sourceRoot;
// private String rootPackageName;
// private Packages packages;
// private Logging logging;
// private String packagesLike;
// private String sourceOwner;
// private String projectName;
// private String sourcesTableProc;
// private String sourcesTable;
//
// public String getPackagesLike() {
// if (packagesLike == null) {
// return "%";
// }
// return packagesLike;
// }
//
// public void setPackagesLike(String packagesLike) {
// this.packagesLike = packagesLike;
// }
//
// public String getSourceOwner() {
// return sourceOwner;
// }
//
// public void setSourceOwner(String sourceOwner) {
// this.sourceOwner = sourceOwner;
// }
//
// public String getJdbcUrl() {
// return jdbcUrl;
// }
//
// public void setJdbcUrl(String jdbcUrl) {
// this.jdbcUrl = jdbcUrl;
// }
//
// public String getSourceRoot() {
// return sourceRoot;
// }
//
// public void setSourceRoot(String sourceRoot) {
// this.sourceRoot = sourceRoot;
// }
//
// public String getRootPackageName() {
// return rootPackageName;
// }
//
// public void setRootPackageName(String rootPackageName) {
// this.rootPackageName = rootPackageName;
// }
//
// public Packages getPackages() {
// return packages;
// }
//
// public void setPackages(Packages packages) {
// this.packages = packages;
// }
//
// public Logging getLogging() {
// return logging;
// }
//
// public void setLogging(Logging logging) {
// this.logging = logging;
// }
//
// public String getSourcesTable() {
// return sourcesTable;
// }
//
// public void setSourcesTable(String sourcesTable) {
// this.sourcesTable = sourcesTable;
// }
//
// public String getSourcesTableProc() {
// return sourcesTableProc;
// }
//
// public String getProjectName() { return projectName == null ? "default": projectName; }
//
// public void setProjectName(String projectName) { this.projectName = projectName; }
// }
// Path: obridge-main/src/main/java/org/obridge/util/XStreamFactory.java
import com.thoughtworks.xstream.XStream;
import org.obridge.context.OBridgeConfiguration;
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 Ferenc Karsany
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package org.obridge.util;
/**
* @author fkarsany
*/
public class XStreamFactory {
private XStreamFactory() {
}
public static XStream createXStream() {
XStream xStream = new XStream();
|
xStream.alias("configuration", OBridgeConfiguration.class);
|
karsany/obridge
|
obridge-main/src/main/java/org/obridge/generators/PopulateObjectsTable.java
|
// Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java
// public class OBridgeConfiguration {
//
// public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false;
// public static final boolean ADD_ASSERT = false;
//
// private String jdbcUrl;
// private String sourceRoot;
// private String rootPackageName;
// private Packages packages;
// private Logging logging;
// private String packagesLike;
// private String sourceOwner;
// private String projectName;
// private String sourcesTableProc;
// private String sourcesTable;
//
// public String getPackagesLike() {
// if (packagesLike == null) {
// return "%";
// }
// return packagesLike;
// }
//
// public void setPackagesLike(String packagesLike) {
// this.packagesLike = packagesLike;
// }
//
// public String getSourceOwner() {
// return sourceOwner;
// }
//
// public void setSourceOwner(String sourceOwner) {
// this.sourceOwner = sourceOwner;
// }
//
// public String getJdbcUrl() {
// return jdbcUrl;
// }
//
// public void setJdbcUrl(String jdbcUrl) {
// this.jdbcUrl = jdbcUrl;
// }
//
// public String getSourceRoot() {
// return sourceRoot;
// }
//
// public void setSourceRoot(String sourceRoot) {
// this.sourceRoot = sourceRoot;
// }
//
// public String getRootPackageName() {
// return rootPackageName;
// }
//
// public void setRootPackageName(String rootPackageName) {
// this.rootPackageName = rootPackageName;
// }
//
// public Packages getPackages() {
// return packages;
// }
//
// public void setPackages(Packages packages) {
// this.packages = packages;
// }
//
// public Logging getLogging() {
// return logging;
// }
//
// public void setLogging(Logging logging) {
// this.logging = logging;
// }
//
// public String getSourcesTable() {
// return sourcesTable;
// }
//
// public void setSourcesTable(String sourcesTable) {
// this.sourcesTable = sourcesTable;
// }
//
// public String getSourcesTableProc() {
// return sourcesTableProc;
// }
//
// public String getProjectName() { return projectName == null ? "default": projectName; }
//
// public void setProjectName(String projectName) { this.projectName = projectName; }
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/DataSourceProvider.java
// public final class DataSourceProvider {
//
// private static Map<String, ComboPooledDataSource> dataSourcePool = null;
//
// private DataSourceProvider() {
// }
//
// public static DataSource getDataSource(String jdbcURL) throws PropertyVetoException {
//
// if (dataSourcePool == null) {
// dataSourcePool = new HashMap<>();
// }
//
// if (!dataSourcePool.containsKey(jdbcURL)) {
//
// ComboPooledDataSource dataSource = new ComboPooledDataSource();
// dataSource.setDriverClass("oracle.jdbc.OracleDriver");
// dataSource.setJdbcUrl(jdbcURL);
//
// dataSourcePool.put(jdbcURL, dataSource);
// }
//
// return dataSourcePool.get(jdbcURL);
// }
//
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/OBridgeException.java
// public class OBridgeException extends RuntimeException {
//
// public OBridgeException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public OBridgeException(Throwable cause) {
// super(cause);
// }
//
// public OBridgeException(String message) {
// super(message);
// }
// }
|
import org.obridge.context.OBridgeConfiguration;
import org.obridge.util.DataSourceProvider;
import org.obridge.util.OBridgeException;
import javax.sql.DataSource;
import java.beans.PropertyVetoException;
import java.io.IOException;
import java.sql.CallableStatement;
|
package org.obridge.generators;
public class PopulateObjectsTable {
public static void run(OBridgeConfiguration c) {
String sourcesTableProc = c.getSourcesTableProc();
String projectName = c.getProjectName();
if (sourcesTableProc == null) {
return;
}
sourcesTableProc = "begin " + sourcesTableProc + "(?); end;";
try {
|
// Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java
// public class OBridgeConfiguration {
//
// public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false;
// public static final boolean ADD_ASSERT = false;
//
// private String jdbcUrl;
// private String sourceRoot;
// private String rootPackageName;
// private Packages packages;
// private Logging logging;
// private String packagesLike;
// private String sourceOwner;
// private String projectName;
// private String sourcesTableProc;
// private String sourcesTable;
//
// public String getPackagesLike() {
// if (packagesLike == null) {
// return "%";
// }
// return packagesLike;
// }
//
// public void setPackagesLike(String packagesLike) {
// this.packagesLike = packagesLike;
// }
//
// public String getSourceOwner() {
// return sourceOwner;
// }
//
// public void setSourceOwner(String sourceOwner) {
// this.sourceOwner = sourceOwner;
// }
//
// public String getJdbcUrl() {
// return jdbcUrl;
// }
//
// public void setJdbcUrl(String jdbcUrl) {
// this.jdbcUrl = jdbcUrl;
// }
//
// public String getSourceRoot() {
// return sourceRoot;
// }
//
// public void setSourceRoot(String sourceRoot) {
// this.sourceRoot = sourceRoot;
// }
//
// public String getRootPackageName() {
// return rootPackageName;
// }
//
// public void setRootPackageName(String rootPackageName) {
// this.rootPackageName = rootPackageName;
// }
//
// public Packages getPackages() {
// return packages;
// }
//
// public void setPackages(Packages packages) {
// this.packages = packages;
// }
//
// public Logging getLogging() {
// return logging;
// }
//
// public void setLogging(Logging logging) {
// this.logging = logging;
// }
//
// public String getSourcesTable() {
// return sourcesTable;
// }
//
// public void setSourcesTable(String sourcesTable) {
// this.sourcesTable = sourcesTable;
// }
//
// public String getSourcesTableProc() {
// return sourcesTableProc;
// }
//
// public String getProjectName() { return projectName == null ? "default": projectName; }
//
// public void setProjectName(String projectName) { this.projectName = projectName; }
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/DataSourceProvider.java
// public final class DataSourceProvider {
//
// private static Map<String, ComboPooledDataSource> dataSourcePool = null;
//
// private DataSourceProvider() {
// }
//
// public static DataSource getDataSource(String jdbcURL) throws PropertyVetoException {
//
// if (dataSourcePool == null) {
// dataSourcePool = new HashMap<>();
// }
//
// if (!dataSourcePool.containsKey(jdbcURL)) {
//
// ComboPooledDataSource dataSource = new ComboPooledDataSource();
// dataSource.setDriverClass("oracle.jdbc.OracleDriver");
// dataSource.setJdbcUrl(jdbcURL);
//
// dataSourcePool.put(jdbcURL, dataSource);
// }
//
// return dataSourcePool.get(jdbcURL);
// }
//
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/OBridgeException.java
// public class OBridgeException extends RuntimeException {
//
// public OBridgeException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public OBridgeException(Throwable cause) {
// super(cause);
// }
//
// public OBridgeException(String message) {
// super(message);
// }
// }
// Path: obridge-main/src/main/java/org/obridge/generators/PopulateObjectsTable.java
import org.obridge.context.OBridgeConfiguration;
import org.obridge.util.DataSourceProvider;
import org.obridge.util.OBridgeException;
import javax.sql.DataSource;
import java.beans.PropertyVetoException;
import java.io.IOException;
import java.sql.CallableStatement;
package org.obridge.generators;
public class PopulateObjectsTable {
public static void run(OBridgeConfiguration c) {
String sourcesTableProc = c.getSourcesTableProc();
String projectName = c.getProjectName();
if (sourcesTableProc == null) {
return;
}
sourcesTableProc = "begin " + sourcesTableProc + "(?); end;";
try {
|
DataSource datasource = DataSourceProvider.getDataSource(c.getJdbcUrl());
|
karsany/obridge
|
obridge-main/src/main/java/org/obridge/generators/PopulateObjectsTable.java
|
// Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java
// public class OBridgeConfiguration {
//
// public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false;
// public static final boolean ADD_ASSERT = false;
//
// private String jdbcUrl;
// private String sourceRoot;
// private String rootPackageName;
// private Packages packages;
// private Logging logging;
// private String packagesLike;
// private String sourceOwner;
// private String projectName;
// private String sourcesTableProc;
// private String sourcesTable;
//
// public String getPackagesLike() {
// if (packagesLike == null) {
// return "%";
// }
// return packagesLike;
// }
//
// public void setPackagesLike(String packagesLike) {
// this.packagesLike = packagesLike;
// }
//
// public String getSourceOwner() {
// return sourceOwner;
// }
//
// public void setSourceOwner(String sourceOwner) {
// this.sourceOwner = sourceOwner;
// }
//
// public String getJdbcUrl() {
// return jdbcUrl;
// }
//
// public void setJdbcUrl(String jdbcUrl) {
// this.jdbcUrl = jdbcUrl;
// }
//
// public String getSourceRoot() {
// return sourceRoot;
// }
//
// public void setSourceRoot(String sourceRoot) {
// this.sourceRoot = sourceRoot;
// }
//
// public String getRootPackageName() {
// return rootPackageName;
// }
//
// public void setRootPackageName(String rootPackageName) {
// this.rootPackageName = rootPackageName;
// }
//
// public Packages getPackages() {
// return packages;
// }
//
// public void setPackages(Packages packages) {
// this.packages = packages;
// }
//
// public Logging getLogging() {
// return logging;
// }
//
// public void setLogging(Logging logging) {
// this.logging = logging;
// }
//
// public String getSourcesTable() {
// return sourcesTable;
// }
//
// public void setSourcesTable(String sourcesTable) {
// this.sourcesTable = sourcesTable;
// }
//
// public String getSourcesTableProc() {
// return sourcesTableProc;
// }
//
// public String getProjectName() { return projectName == null ? "default": projectName; }
//
// public void setProjectName(String projectName) { this.projectName = projectName; }
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/DataSourceProvider.java
// public final class DataSourceProvider {
//
// private static Map<String, ComboPooledDataSource> dataSourcePool = null;
//
// private DataSourceProvider() {
// }
//
// public static DataSource getDataSource(String jdbcURL) throws PropertyVetoException {
//
// if (dataSourcePool == null) {
// dataSourcePool = new HashMap<>();
// }
//
// if (!dataSourcePool.containsKey(jdbcURL)) {
//
// ComboPooledDataSource dataSource = new ComboPooledDataSource();
// dataSource.setDriverClass("oracle.jdbc.OracleDriver");
// dataSource.setJdbcUrl(jdbcURL);
//
// dataSourcePool.put(jdbcURL, dataSource);
// }
//
// return dataSourcePool.get(jdbcURL);
// }
//
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/OBridgeException.java
// public class OBridgeException extends RuntimeException {
//
// public OBridgeException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public OBridgeException(Throwable cause) {
// super(cause);
// }
//
// public OBridgeException(String message) {
// super(message);
// }
// }
|
import org.obridge.context.OBridgeConfiguration;
import org.obridge.util.DataSourceProvider;
import org.obridge.util.OBridgeException;
import javax.sql.DataSource;
import java.beans.PropertyVetoException;
import java.io.IOException;
import java.sql.CallableStatement;
|
package org.obridge.generators;
public class PopulateObjectsTable {
public static void run(OBridgeConfiguration c) {
String sourcesTableProc = c.getSourcesTableProc();
String projectName = c.getProjectName();
if (sourcesTableProc == null) {
return;
}
sourcesTableProc = "begin " + sourcesTableProc + "(?); end;";
try {
DataSource datasource = DataSourceProvider.getDataSource(c.getJdbcUrl());
CallableStatement statement = datasource.getConnection().prepareCall(sourcesTableProc);
statement.setString(1, projectName);
statement.execute();
} catch (Exception e) {
|
// Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java
// public class OBridgeConfiguration {
//
// public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false;
// public static final boolean ADD_ASSERT = false;
//
// private String jdbcUrl;
// private String sourceRoot;
// private String rootPackageName;
// private Packages packages;
// private Logging logging;
// private String packagesLike;
// private String sourceOwner;
// private String projectName;
// private String sourcesTableProc;
// private String sourcesTable;
//
// public String getPackagesLike() {
// if (packagesLike == null) {
// return "%";
// }
// return packagesLike;
// }
//
// public void setPackagesLike(String packagesLike) {
// this.packagesLike = packagesLike;
// }
//
// public String getSourceOwner() {
// return sourceOwner;
// }
//
// public void setSourceOwner(String sourceOwner) {
// this.sourceOwner = sourceOwner;
// }
//
// public String getJdbcUrl() {
// return jdbcUrl;
// }
//
// public void setJdbcUrl(String jdbcUrl) {
// this.jdbcUrl = jdbcUrl;
// }
//
// public String getSourceRoot() {
// return sourceRoot;
// }
//
// public void setSourceRoot(String sourceRoot) {
// this.sourceRoot = sourceRoot;
// }
//
// public String getRootPackageName() {
// return rootPackageName;
// }
//
// public void setRootPackageName(String rootPackageName) {
// this.rootPackageName = rootPackageName;
// }
//
// public Packages getPackages() {
// return packages;
// }
//
// public void setPackages(Packages packages) {
// this.packages = packages;
// }
//
// public Logging getLogging() {
// return logging;
// }
//
// public void setLogging(Logging logging) {
// this.logging = logging;
// }
//
// public String getSourcesTable() {
// return sourcesTable;
// }
//
// public void setSourcesTable(String sourcesTable) {
// this.sourcesTable = sourcesTable;
// }
//
// public String getSourcesTableProc() {
// return sourcesTableProc;
// }
//
// public String getProjectName() { return projectName == null ? "default": projectName; }
//
// public void setProjectName(String projectName) { this.projectName = projectName; }
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/DataSourceProvider.java
// public final class DataSourceProvider {
//
// private static Map<String, ComboPooledDataSource> dataSourcePool = null;
//
// private DataSourceProvider() {
// }
//
// public static DataSource getDataSource(String jdbcURL) throws PropertyVetoException {
//
// if (dataSourcePool == null) {
// dataSourcePool = new HashMap<>();
// }
//
// if (!dataSourcePool.containsKey(jdbcURL)) {
//
// ComboPooledDataSource dataSource = new ComboPooledDataSource();
// dataSource.setDriverClass("oracle.jdbc.OracleDriver");
// dataSource.setJdbcUrl(jdbcURL);
//
// dataSourcePool.put(jdbcURL, dataSource);
// }
//
// return dataSourcePool.get(jdbcURL);
// }
//
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/OBridgeException.java
// public class OBridgeException extends RuntimeException {
//
// public OBridgeException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public OBridgeException(Throwable cause) {
// super(cause);
// }
//
// public OBridgeException(String message) {
// super(message);
// }
// }
// Path: obridge-main/src/main/java/org/obridge/generators/PopulateObjectsTable.java
import org.obridge.context.OBridgeConfiguration;
import org.obridge.util.DataSourceProvider;
import org.obridge.util.OBridgeException;
import javax.sql.DataSource;
import java.beans.PropertyVetoException;
import java.io.IOException;
import java.sql.CallableStatement;
package org.obridge.generators;
public class PopulateObjectsTable {
public static void run(OBridgeConfiguration c) {
String sourcesTableProc = c.getSourcesTableProc();
String projectName = c.getProjectName();
if (sourcesTableProc == null) {
return;
}
sourcesTableProc = "begin " + sourcesTableProc + "(?); end;";
try {
DataSource datasource = DataSourceProvider.getDataSource(c.getJdbcUrl());
CallableStatement statement = datasource.getConnection().prepareCall(sourcesTableProc);
statement.setString(1, projectName);
statement.execute();
} catch (Exception e) {
|
throw new OBridgeException(e);
|
karsany/obridge
|
obridge-main/src/main/java/org/obridge/OBridge.java
|
// Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java
// public class OBridgeConfiguration {
//
// public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false;
// public static final boolean ADD_ASSERT = false;
//
// private String jdbcUrl;
// private String sourceRoot;
// private String rootPackageName;
// private Packages packages;
// private Logging logging;
// private String packagesLike;
// private String sourceOwner;
// private String projectName;
// private String sourcesTableProc;
// private String sourcesTable;
//
// public String getPackagesLike() {
// if (packagesLike == null) {
// return "%";
// }
// return packagesLike;
// }
//
// public void setPackagesLike(String packagesLike) {
// this.packagesLike = packagesLike;
// }
//
// public String getSourceOwner() {
// return sourceOwner;
// }
//
// public void setSourceOwner(String sourceOwner) {
// this.sourceOwner = sourceOwner;
// }
//
// public String getJdbcUrl() {
// return jdbcUrl;
// }
//
// public void setJdbcUrl(String jdbcUrl) {
// this.jdbcUrl = jdbcUrl;
// }
//
// public String getSourceRoot() {
// return sourceRoot;
// }
//
// public void setSourceRoot(String sourceRoot) {
// this.sourceRoot = sourceRoot;
// }
//
// public String getRootPackageName() {
// return rootPackageName;
// }
//
// public void setRootPackageName(String rootPackageName) {
// this.rootPackageName = rootPackageName;
// }
//
// public Packages getPackages() {
// return packages;
// }
//
// public void setPackages(Packages packages) {
// this.packages = packages;
// }
//
// public Logging getLogging() {
// return logging;
// }
//
// public void setLogging(Logging logging) {
// this.logging = logging;
// }
//
// public String getSourcesTable() {
// return sourcesTable;
// }
//
// public void setSourcesTable(String sourcesTable) {
// this.sourcesTable = sourcesTable;
// }
//
// public String getSourcesTableProc() {
// return sourcesTableProc;
// }
//
// public String getProjectName() { return projectName == null ? "default": projectName; }
//
// public void setProjectName(String projectName) { this.projectName = projectName; }
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/OBridgeException.java
// public class OBridgeException extends RuntimeException {
//
// public OBridgeException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public OBridgeException(Throwable cause) {
// super(cause);
// }
//
// public OBridgeException(String message) {
// super(message);
// }
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/XStreamFactory.java
// public class XStreamFactory {
//
// private XStreamFactory() {
// }
//
// public static XStream createXStream() {
// XStream xStream = new XStream();
//
// xStream.alias("configuration", OBridgeConfiguration.class);
//
// return xStream;
// }
//
// }
|
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import com.thoughtworks.xstream.XStream;
import org.apache.commons.cli.*;
import org.obridge.context.OBridgeConfiguration;
import org.obridge.generators.*;
import org.obridge.util.OBridgeException;
import org.obridge.util.XStreamFactory;
|
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 Ferenc Karsany
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package org.obridge;
public class OBridge {
public static void main(String... args) {
try {
Options o = new Options();
CommandLine cmd = getCommandLine(o, args);
if (cmd.hasOption("h")) {
printHelp(o);
return;
}
if (cmd.hasOption("v")) {
printVersion();
return;
}
if (cmd.hasOption("c")) {
new OBridge().generate(new File(cmd.getOptionValue("c")));
} else {
printHelp(o);
}
} catch (ParseException e) {
|
// Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java
// public class OBridgeConfiguration {
//
// public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false;
// public static final boolean ADD_ASSERT = false;
//
// private String jdbcUrl;
// private String sourceRoot;
// private String rootPackageName;
// private Packages packages;
// private Logging logging;
// private String packagesLike;
// private String sourceOwner;
// private String projectName;
// private String sourcesTableProc;
// private String sourcesTable;
//
// public String getPackagesLike() {
// if (packagesLike == null) {
// return "%";
// }
// return packagesLike;
// }
//
// public void setPackagesLike(String packagesLike) {
// this.packagesLike = packagesLike;
// }
//
// public String getSourceOwner() {
// return sourceOwner;
// }
//
// public void setSourceOwner(String sourceOwner) {
// this.sourceOwner = sourceOwner;
// }
//
// public String getJdbcUrl() {
// return jdbcUrl;
// }
//
// public void setJdbcUrl(String jdbcUrl) {
// this.jdbcUrl = jdbcUrl;
// }
//
// public String getSourceRoot() {
// return sourceRoot;
// }
//
// public void setSourceRoot(String sourceRoot) {
// this.sourceRoot = sourceRoot;
// }
//
// public String getRootPackageName() {
// return rootPackageName;
// }
//
// public void setRootPackageName(String rootPackageName) {
// this.rootPackageName = rootPackageName;
// }
//
// public Packages getPackages() {
// return packages;
// }
//
// public void setPackages(Packages packages) {
// this.packages = packages;
// }
//
// public Logging getLogging() {
// return logging;
// }
//
// public void setLogging(Logging logging) {
// this.logging = logging;
// }
//
// public String getSourcesTable() {
// return sourcesTable;
// }
//
// public void setSourcesTable(String sourcesTable) {
// this.sourcesTable = sourcesTable;
// }
//
// public String getSourcesTableProc() {
// return sourcesTableProc;
// }
//
// public String getProjectName() { return projectName == null ? "default": projectName; }
//
// public void setProjectName(String projectName) { this.projectName = projectName; }
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/OBridgeException.java
// public class OBridgeException extends RuntimeException {
//
// public OBridgeException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public OBridgeException(Throwable cause) {
// super(cause);
// }
//
// public OBridgeException(String message) {
// super(message);
// }
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/XStreamFactory.java
// public class XStreamFactory {
//
// private XStreamFactory() {
// }
//
// public static XStream createXStream() {
// XStream xStream = new XStream();
//
// xStream.alias("configuration", OBridgeConfiguration.class);
//
// return xStream;
// }
//
// }
// Path: obridge-main/src/main/java/org/obridge/OBridge.java
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import com.thoughtworks.xstream.XStream;
import org.apache.commons.cli.*;
import org.obridge.context.OBridgeConfiguration;
import org.obridge.generators.*;
import org.obridge.util.OBridgeException;
import org.obridge.util.XStreamFactory;
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 Ferenc Karsany
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package org.obridge;
public class OBridge {
public static void main(String... args) {
try {
Options o = new Options();
CommandLine cmd = getCommandLine(o, args);
if (cmd.hasOption("h")) {
printHelp(o);
return;
}
if (cmd.hasOption("v")) {
printVersion();
return;
}
if (cmd.hasOption("c")) {
new OBridge().generate(new File(cmd.getOptionValue("c")));
} else {
printHelp(o);
}
} catch (ParseException e) {
|
throw new OBridgeException("Exception in OBridge Main progam", e);
|
karsany/obridge
|
obridge-main/src/main/java/org/obridge/OBridge.java
|
// Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java
// public class OBridgeConfiguration {
//
// public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false;
// public static final boolean ADD_ASSERT = false;
//
// private String jdbcUrl;
// private String sourceRoot;
// private String rootPackageName;
// private Packages packages;
// private Logging logging;
// private String packagesLike;
// private String sourceOwner;
// private String projectName;
// private String sourcesTableProc;
// private String sourcesTable;
//
// public String getPackagesLike() {
// if (packagesLike == null) {
// return "%";
// }
// return packagesLike;
// }
//
// public void setPackagesLike(String packagesLike) {
// this.packagesLike = packagesLike;
// }
//
// public String getSourceOwner() {
// return sourceOwner;
// }
//
// public void setSourceOwner(String sourceOwner) {
// this.sourceOwner = sourceOwner;
// }
//
// public String getJdbcUrl() {
// return jdbcUrl;
// }
//
// public void setJdbcUrl(String jdbcUrl) {
// this.jdbcUrl = jdbcUrl;
// }
//
// public String getSourceRoot() {
// return sourceRoot;
// }
//
// public void setSourceRoot(String sourceRoot) {
// this.sourceRoot = sourceRoot;
// }
//
// public String getRootPackageName() {
// return rootPackageName;
// }
//
// public void setRootPackageName(String rootPackageName) {
// this.rootPackageName = rootPackageName;
// }
//
// public Packages getPackages() {
// return packages;
// }
//
// public void setPackages(Packages packages) {
// this.packages = packages;
// }
//
// public Logging getLogging() {
// return logging;
// }
//
// public void setLogging(Logging logging) {
// this.logging = logging;
// }
//
// public String getSourcesTable() {
// return sourcesTable;
// }
//
// public void setSourcesTable(String sourcesTable) {
// this.sourcesTable = sourcesTable;
// }
//
// public String getSourcesTableProc() {
// return sourcesTableProc;
// }
//
// public String getProjectName() { return projectName == null ? "default": projectName; }
//
// public void setProjectName(String projectName) { this.projectName = projectName; }
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/OBridgeException.java
// public class OBridgeException extends RuntimeException {
//
// public OBridgeException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public OBridgeException(Throwable cause) {
// super(cause);
// }
//
// public OBridgeException(String message) {
// super(message);
// }
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/XStreamFactory.java
// public class XStreamFactory {
//
// private XStreamFactory() {
// }
//
// public static XStream createXStream() {
// XStream xStream = new XStream();
//
// xStream.alias("configuration", OBridgeConfiguration.class);
//
// return xStream;
// }
//
// }
|
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import com.thoughtworks.xstream.XStream;
import org.apache.commons.cli.*;
import org.obridge.context.OBridgeConfiguration;
import org.obridge.generators.*;
import org.obridge.util.OBridgeException;
import org.obridge.util.XStreamFactory;
|
private static CommandLine getCommandLine(Options o, String[] args) throws ParseException {
o.addOption(
Option.builder("v")
.longOpt("version")
.desc("print version number")
.required(false)
.build()
);
o.addOption(
Option.builder("h")
.longOpt("help")
.desc("prints this help")
.required(false)
.build()
);
o.addOption(
Option.builder("c")
.desc("OBridge XML config file")
.longOpt("config")
.hasArg()
.argName("file")
.build()
);
CommandLineParser parser = new PosixParser();
return parser.parse(o, args);
}
|
// Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java
// public class OBridgeConfiguration {
//
// public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false;
// public static final boolean ADD_ASSERT = false;
//
// private String jdbcUrl;
// private String sourceRoot;
// private String rootPackageName;
// private Packages packages;
// private Logging logging;
// private String packagesLike;
// private String sourceOwner;
// private String projectName;
// private String sourcesTableProc;
// private String sourcesTable;
//
// public String getPackagesLike() {
// if (packagesLike == null) {
// return "%";
// }
// return packagesLike;
// }
//
// public void setPackagesLike(String packagesLike) {
// this.packagesLike = packagesLike;
// }
//
// public String getSourceOwner() {
// return sourceOwner;
// }
//
// public void setSourceOwner(String sourceOwner) {
// this.sourceOwner = sourceOwner;
// }
//
// public String getJdbcUrl() {
// return jdbcUrl;
// }
//
// public void setJdbcUrl(String jdbcUrl) {
// this.jdbcUrl = jdbcUrl;
// }
//
// public String getSourceRoot() {
// return sourceRoot;
// }
//
// public void setSourceRoot(String sourceRoot) {
// this.sourceRoot = sourceRoot;
// }
//
// public String getRootPackageName() {
// return rootPackageName;
// }
//
// public void setRootPackageName(String rootPackageName) {
// this.rootPackageName = rootPackageName;
// }
//
// public Packages getPackages() {
// return packages;
// }
//
// public void setPackages(Packages packages) {
// this.packages = packages;
// }
//
// public Logging getLogging() {
// return logging;
// }
//
// public void setLogging(Logging logging) {
// this.logging = logging;
// }
//
// public String getSourcesTable() {
// return sourcesTable;
// }
//
// public void setSourcesTable(String sourcesTable) {
// this.sourcesTable = sourcesTable;
// }
//
// public String getSourcesTableProc() {
// return sourcesTableProc;
// }
//
// public String getProjectName() { return projectName == null ? "default": projectName; }
//
// public void setProjectName(String projectName) { this.projectName = projectName; }
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/OBridgeException.java
// public class OBridgeException extends RuntimeException {
//
// public OBridgeException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public OBridgeException(Throwable cause) {
// super(cause);
// }
//
// public OBridgeException(String message) {
// super(message);
// }
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/XStreamFactory.java
// public class XStreamFactory {
//
// private XStreamFactory() {
// }
//
// public static XStream createXStream() {
// XStream xStream = new XStream();
//
// xStream.alias("configuration", OBridgeConfiguration.class);
//
// return xStream;
// }
//
// }
// Path: obridge-main/src/main/java/org/obridge/OBridge.java
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import com.thoughtworks.xstream.XStream;
import org.apache.commons.cli.*;
import org.obridge.context.OBridgeConfiguration;
import org.obridge.generators.*;
import org.obridge.util.OBridgeException;
import org.obridge.util.XStreamFactory;
private static CommandLine getCommandLine(Options o, String[] args) throws ParseException {
o.addOption(
Option.builder("v")
.longOpt("version")
.desc("print version number")
.required(false)
.build()
);
o.addOption(
Option.builder("h")
.longOpt("help")
.desc("prints this help")
.required(false)
.build()
);
o.addOption(
Option.builder("c")
.desc("OBridge XML config file")
.longOpt("config")
.hasArg()
.argName("file")
.build()
);
CommandLineParser parser = new PosixParser();
return parser.parse(o, args);
}
|
public void generate(OBridgeConfiguration c) {
|
karsany/obridge
|
obridge-main/src/main/java/org/obridge/OBridge.java
|
// Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java
// public class OBridgeConfiguration {
//
// public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false;
// public static final boolean ADD_ASSERT = false;
//
// private String jdbcUrl;
// private String sourceRoot;
// private String rootPackageName;
// private Packages packages;
// private Logging logging;
// private String packagesLike;
// private String sourceOwner;
// private String projectName;
// private String sourcesTableProc;
// private String sourcesTable;
//
// public String getPackagesLike() {
// if (packagesLike == null) {
// return "%";
// }
// return packagesLike;
// }
//
// public void setPackagesLike(String packagesLike) {
// this.packagesLike = packagesLike;
// }
//
// public String getSourceOwner() {
// return sourceOwner;
// }
//
// public void setSourceOwner(String sourceOwner) {
// this.sourceOwner = sourceOwner;
// }
//
// public String getJdbcUrl() {
// return jdbcUrl;
// }
//
// public void setJdbcUrl(String jdbcUrl) {
// this.jdbcUrl = jdbcUrl;
// }
//
// public String getSourceRoot() {
// return sourceRoot;
// }
//
// public void setSourceRoot(String sourceRoot) {
// this.sourceRoot = sourceRoot;
// }
//
// public String getRootPackageName() {
// return rootPackageName;
// }
//
// public void setRootPackageName(String rootPackageName) {
// this.rootPackageName = rootPackageName;
// }
//
// public Packages getPackages() {
// return packages;
// }
//
// public void setPackages(Packages packages) {
// this.packages = packages;
// }
//
// public Logging getLogging() {
// return logging;
// }
//
// public void setLogging(Logging logging) {
// this.logging = logging;
// }
//
// public String getSourcesTable() {
// return sourcesTable;
// }
//
// public void setSourcesTable(String sourcesTable) {
// this.sourcesTable = sourcesTable;
// }
//
// public String getSourcesTableProc() {
// return sourcesTableProc;
// }
//
// public String getProjectName() { return projectName == null ? "default": projectName; }
//
// public void setProjectName(String projectName) { this.projectName = projectName; }
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/OBridgeException.java
// public class OBridgeException extends RuntimeException {
//
// public OBridgeException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public OBridgeException(Throwable cause) {
// super(cause);
// }
//
// public OBridgeException(String message) {
// super(message);
// }
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/XStreamFactory.java
// public class XStreamFactory {
//
// private XStreamFactory() {
// }
//
// public static XStream createXStream() {
// XStream xStream = new XStream();
//
// xStream.alias("configuration", OBridgeConfiguration.class);
//
// return xStream;
// }
//
// }
|
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import com.thoughtworks.xstream.XStream;
import org.apache.commons.cli.*;
import org.obridge.context.OBridgeConfiguration;
import org.obridge.generators.*;
import org.obridge.util.OBridgeException;
import org.obridge.util.XStreamFactory;
|
Option.builder("c")
.desc("OBridge XML config file")
.longOpt("config")
.hasArg()
.argName("file")
.build()
);
CommandLineParser parser = new PosixParser();
return parser.parse(o, args);
}
public void generate(OBridgeConfiguration c) {
// populate objects table
PopulateObjectsTable.run(c);
// generate objects
EntityObjectGenerator.generate(c);
// generate converters
ConverterObjectGenerator.generate(c);
// generate contexts
ProcedureContextGenerator.generate(c);
// generate packages
PackageObjectGenerator.generate(c);
}
public OBridgeConfiguration loadConfiguration(File f) {
|
// Path: obridge-main/src/main/java/org/obridge/context/OBridgeConfiguration.java
// public class OBridgeConfiguration {
//
// public static final boolean GENERATE_SOURCE_FOR_PLSQL_TYPES = false;
// public static final boolean ADD_ASSERT = false;
//
// private String jdbcUrl;
// private String sourceRoot;
// private String rootPackageName;
// private Packages packages;
// private Logging logging;
// private String packagesLike;
// private String sourceOwner;
// private String projectName;
// private String sourcesTableProc;
// private String sourcesTable;
//
// public String getPackagesLike() {
// if (packagesLike == null) {
// return "%";
// }
// return packagesLike;
// }
//
// public void setPackagesLike(String packagesLike) {
// this.packagesLike = packagesLike;
// }
//
// public String getSourceOwner() {
// return sourceOwner;
// }
//
// public void setSourceOwner(String sourceOwner) {
// this.sourceOwner = sourceOwner;
// }
//
// public String getJdbcUrl() {
// return jdbcUrl;
// }
//
// public void setJdbcUrl(String jdbcUrl) {
// this.jdbcUrl = jdbcUrl;
// }
//
// public String getSourceRoot() {
// return sourceRoot;
// }
//
// public void setSourceRoot(String sourceRoot) {
// this.sourceRoot = sourceRoot;
// }
//
// public String getRootPackageName() {
// return rootPackageName;
// }
//
// public void setRootPackageName(String rootPackageName) {
// this.rootPackageName = rootPackageName;
// }
//
// public Packages getPackages() {
// return packages;
// }
//
// public void setPackages(Packages packages) {
// this.packages = packages;
// }
//
// public Logging getLogging() {
// return logging;
// }
//
// public void setLogging(Logging logging) {
// this.logging = logging;
// }
//
// public String getSourcesTable() {
// return sourcesTable;
// }
//
// public void setSourcesTable(String sourcesTable) {
// this.sourcesTable = sourcesTable;
// }
//
// public String getSourcesTableProc() {
// return sourcesTableProc;
// }
//
// public String getProjectName() { return projectName == null ? "default": projectName; }
//
// public void setProjectName(String projectName) { this.projectName = projectName; }
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/OBridgeException.java
// public class OBridgeException extends RuntimeException {
//
// public OBridgeException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public OBridgeException(Throwable cause) {
// super(cause);
// }
//
// public OBridgeException(String message) {
// super(message);
// }
// }
//
// Path: obridge-main/src/main/java/org/obridge/util/XStreamFactory.java
// public class XStreamFactory {
//
// private XStreamFactory() {
// }
//
// public static XStream createXStream() {
// XStream xStream = new XStream();
//
// xStream.alias("configuration", OBridgeConfiguration.class);
//
// return xStream;
// }
//
// }
// Path: obridge-main/src/main/java/org/obridge/OBridge.java
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import com.thoughtworks.xstream.XStream;
import org.apache.commons.cli.*;
import org.obridge.context.OBridgeConfiguration;
import org.obridge.generators.*;
import org.obridge.util.OBridgeException;
import org.obridge.util.XStreamFactory;
Option.builder("c")
.desc("OBridge XML config file")
.longOpt("config")
.hasArg()
.argName("file")
.build()
);
CommandLineParser parser = new PosixParser();
return parser.parse(o, args);
}
public void generate(OBridgeConfiguration c) {
// populate objects table
PopulateObjectsTable.run(c);
// generate objects
EntityObjectGenerator.generate(c);
// generate converters
ConverterObjectGenerator.generate(c);
// generate contexts
ProcedureContextGenerator.generate(c);
// generate packages
PackageObjectGenerator.generate(c);
}
public OBridgeConfiguration loadConfiguration(File f) {
|
XStream xs = XStreamFactory.createXStream();
|
JavaMoney/javamoney-shelter
|
retired/format/src/main/java/org/javamoney/format/IsoCurrencyFormatFactory.java
|
// Path: retired/format/src/main/java/org/javamoney/format/IsoCurrencyFormat.java
// public enum RenderedField {
// ID, CODE, SYMBOL, DISPLAYNAME, NUMERICCODE, OMIT
// }
//
// Path: retired/format/src/main/java/org/javamoney/format/spi/ItemFormatFactorySpi.java
// public interface ItemFormatFactorySpi<T>{
//
// /**
// * Return the target type the owning artifact can be applied to.
// *
// * @return the target type, never {@code null}.
// */
// public Class<T> getTargetClass();
//
// /**
// * Return the style id's supported by this {@link ItemFormatFactorySpi}
// * instance.
// *
// * @return the supported style identifiers, never {@code null}.
// * @see org.javamoney.format.LocalizationContext#getId()
// */
// public Collection<String> getSupportedStyleIds();
//
// /**
// * Access a configured default {@link org.javamoney.format.LocalizationContext} instance. If the
// * required styleId is part of the supported styles returned by this spi
// * implementation, then this method should return the according
// * {@link org.javamoney.format.LocalizationContext} instance.
// *
// * @param targetType The target type, not {@code null}.
// * @param styleId The style identifier, may be {@code null}, acquiring a
// * <i>default</i> style.
// * @return the style instance, or {@code null}.
// */
// public LocalizationContext getLocalizationStyle(Class<?> targetType, String styleId);
//
// /**
// * Method to check, if a style is available for the type this factory is
// * producing {@link ItemFormat}s.
// *
// * @param styleId the target style identifier.
// * @return {@code true}, if the style is available for the current target
// * type.
// * @see #getTargetClass()
// */
// public boolean isSupportedStyle(String styleId);
//
// /**
// * Creates a new instance of {@link ItemFormat} configured by the given
// * {@link org.javamoney.format.LocalizationContext} instance, if the style (style identifier, one
// * of the style's attributes) required are not supported by this factory,
// * {@code null} should be returned (different to the API, where an
// * {@link ItemFormatException} must be thrown.
// *
// * @param style the {@link org.javamoney.format.LocalizationContext} that configures this
// * {@link ItemFormat}, which also contains the {@link ItemFormat}
// * 's configuration attributes.
// * @return a {@link ItemFormat} instance configured with the given style, or
// * {@code null}.
// * @see #getTargetClass()
// */
// public ItemFormat<T> getItemFormat(LocalizationContext style) throws ItemFormatException;
//
// }
|
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import javax.inject.Singleton;
import javax.money.CurrencyUnit;
import org.javamoney.format.IsoCurrencyFormat.RenderedField;
import org.javamoney.format.spi.ItemFormatFactorySpi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
|
/*
* Copyright (c) 2012, 2013, Credit Suisse (Anatole Tresch), Werner Keil.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.javamoney.format;
@Singleton
public class IsoCurrencyFormatFactory implements
|
// Path: retired/format/src/main/java/org/javamoney/format/IsoCurrencyFormat.java
// public enum RenderedField {
// ID, CODE, SYMBOL, DISPLAYNAME, NUMERICCODE, OMIT
// }
//
// Path: retired/format/src/main/java/org/javamoney/format/spi/ItemFormatFactorySpi.java
// public interface ItemFormatFactorySpi<T>{
//
// /**
// * Return the target type the owning artifact can be applied to.
// *
// * @return the target type, never {@code null}.
// */
// public Class<T> getTargetClass();
//
// /**
// * Return the style id's supported by this {@link ItemFormatFactorySpi}
// * instance.
// *
// * @return the supported style identifiers, never {@code null}.
// * @see org.javamoney.format.LocalizationContext#getId()
// */
// public Collection<String> getSupportedStyleIds();
//
// /**
// * Access a configured default {@link org.javamoney.format.LocalizationContext} instance. If the
// * required styleId is part of the supported styles returned by this spi
// * implementation, then this method should return the according
// * {@link org.javamoney.format.LocalizationContext} instance.
// *
// * @param targetType The target type, not {@code null}.
// * @param styleId The style identifier, may be {@code null}, acquiring a
// * <i>default</i> style.
// * @return the style instance, or {@code null}.
// */
// public LocalizationContext getLocalizationStyle(Class<?> targetType, String styleId);
//
// /**
// * Method to check, if a style is available for the type this factory is
// * producing {@link ItemFormat}s.
// *
// * @param styleId the target style identifier.
// * @return {@code true}, if the style is available for the current target
// * type.
// * @see #getTargetClass()
// */
// public boolean isSupportedStyle(String styleId);
//
// /**
// * Creates a new instance of {@link ItemFormat} configured by the given
// * {@link org.javamoney.format.LocalizationContext} instance, if the style (style identifier, one
// * of the style's attributes) required are not supported by this factory,
// * {@code null} should be returned (different to the API, where an
// * {@link ItemFormatException} must be thrown.
// *
// * @param style the {@link org.javamoney.format.LocalizationContext} that configures this
// * {@link ItemFormat}, which also contains the {@link ItemFormat}
// * 's configuration attributes.
// * @return a {@link ItemFormat} instance configured with the given style, or
// * {@code null}.
// * @see #getTargetClass()
// */
// public ItemFormat<T> getItemFormat(LocalizationContext style) throws ItemFormatException;
//
// }
// Path: retired/format/src/main/java/org/javamoney/format/IsoCurrencyFormatFactory.java
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import javax.inject.Singleton;
import javax.money.CurrencyUnit;
import org.javamoney.format.IsoCurrencyFormat.RenderedField;
import org.javamoney.format.spi.ItemFormatFactorySpi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* Copyright (c) 2012, 2013, Credit Suisse (Anatole Tresch), Werner Keil.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.javamoney.format;
@Singleton
public class IsoCurrencyFormatFactory implements
|
ItemFormatFactorySpi<CurrencyUnit> {
|
JavaMoney/javamoney-shelter
|
retired/format/src/main/java/org/javamoney/format/IsoCurrencyFormatFactory.java
|
// Path: retired/format/src/main/java/org/javamoney/format/IsoCurrencyFormat.java
// public enum RenderedField {
// ID, CODE, SYMBOL, DISPLAYNAME, NUMERICCODE, OMIT
// }
//
// Path: retired/format/src/main/java/org/javamoney/format/spi/ItemFormatFactorySpi.java
// public interface ItemFormatFactorySpi<T>{
//
// /**
// * Return the target type the owning artifact can be applied to.
// *
// * @return the target type, never {@code null}.
// */
// public Class<T> getTargetClass();
//
// /**
// * Return the style id's supported by this {@link ItemFormatFactorySpi}
// * instance.
// *
// * @return the supported style identifiers, never {@code null}.
// * @see org.javamoney.format.LocalizationContext#getId()
// */
// public Collection<String> getSupportedStyleIds();
//
// /**
// * Access a configured default {@link org.javamoney.format.LocalizationContext} instance. If the
// * required styleId is part of the supported styles returned by this spi
// * implementation, then this method should return the according
// * {@link org.javamoney.format.LocalizationContext} instance.
// *
// * @param targetType The target type, not {@code null}.
// * @param styleId The style identifier, may be {@code null}, acquiring a
// * <i>default</i> style.
// * @return the style instance, or {@code null}.
// */
// public LocalizationContext getLocalizationStyle(Class<?> targetType, String styleId);
//
// /**
// * Method to check, if a style is available for the type this factory is
// * producing {@link ItemFormat}s.
// *
// * @param styleId the target style identifier.
// * @return {@code true}, if the style is available for the current target
// * type.
// * @see #getTargetClass()
// */
// public boolean isSupportedStyle(String styleId);
//
// /**
// * Creates a new instance of {@link ItemFormat} configured by the given
// * {@link org.javamoney.format.LocalizationContext} instance, if the style (style identifier, one
// * of the style's attributes) required are not supported by this factory,
// * {@code null} should be returned (different to the API, where an
// * {@link ItemFormatException} must be thrown.
// *
// * @param style the {@link org.javamoney.format.LocalizationContext} that configures this
// * {@link ItemFormat}, which also contains the {@link ItemFormat}
// * 's configuration attributes.
// * @return a {@link ItemFormat} instance configured with the given style, or
// * {@code null}.
// * @see #getTargetClass()
// */
// public ItemFormat<T> getItemFormat(LocalizationContext style) throws ItemFormatException;
//
// }
|
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import javax.inject.Singleton;
import javax.money.CurrencyUnit;
import org.javamoney.format.IsoCurrencyFormat.RenderedField;
import org.javamoney.format.spi.ItemFormatFactorySpi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
|
/*
* Copyright (c) 2012, 2013, Credit Suisse (Anatole Tresch), Werner Keil.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.javamoney.format;
@Singleton
public class IsoCurrencyFormatFactory implements
ItemFormatFactorySpi<CurrencyUnit> {
private static final Logger LOGGER = LoggerFactory
.getLogger(IsoCurrencyFormatFactory.class);
@Override
public Class<CurrencyUnit> getTargetClass() {
return CurrencyUnit.class;
}
@Override
public Collection<String> getSupportedStyleIds() {
Set<String> supportedRenderTypes = new HashSet<String>();
|
// Path: retired/format/src/main/java/org/javamoney/format/IsoCurrencyFormat.java
// public enum RenderedField {
// ID, CODE, SYMBOL, DISPLAYNAME, NUMERICCODE, OMIT
// }
//
// Path: retired/format/src/main/java/org/javamoney/format/spi/ItemFormatFactorySpi.java
// public interface ItemFormatFactorySpi<T>{
//
// /**
// * Return the target type the owning artifact can be applied to.
// *
// * @return the target type, never {@code null}.
// */
// public Class<T> getTargetClass();
//
// /**
// * Return the style id's supported by this {@link ItemFormatFactorySpi}
// * instance.
// *
// * @return the supported style identifiers, never {@code null}.
// * @see org.javamoney.format.LocalizationContext#getId()
// */
// public Collection<String> getSupportedStyleIds();
//
// /**
// * Access a configured default {@link org.javamoney.format.LocalizationContext} instance. If the
// * required styleId is part of the supported styles returned by this spi
// * implementation, then this method should return the according
// * {@link org.javamoney.format.LocalizationContext} instance.
// *
// * @param targetType The target type, not {@code null}.
// * @param styleId The style identifier, may be {@code null}, acquiring a
// * <i>default</i> style.
// * @return the style instance, or {@code null}.
// */
// public LocalizationContext getLocalizationStyle(Class<?> targetType, String styleId);
//
// /**
// * Method to check, if a style is available for the type this factory is
// * producing {@link ItemFormat}s.
// *
// * @param styleId the target style identifier.
// * @return {@code true}, if the style is available for the current target
// * type.
// * @see #getTargetClass()
// */
// public boolean isSupportedStyle(String styleId);
//
// /**
// * Creates a new instance of {@link ItemFormat} configured by the given
// * {@link org.javamoney.format.LocalizationContext} instance, if the style (style identifier, one
// * of the style's attributes) required are not supported by this factory,
// * {@code null} should be returned (different to the API, where an
// * {@link ItemFormatException} must be thrown.
// *
// * @param style the {@link org.javamoney.format.LocalizationContext} that configures this
// * {@link ItemFormat}, which also contains the {@link ItemFormat}
// * 's configuration attributes.
// * @return a {@link ItemFormat} instance configured with the given style, or
// * {@code null}.
// * @see #getTargetClass()
// */
// public ItemFormat<T> getItemFormat(LocalizationContext style) throws ItemFormatException;
//
// }
// Path: retired/format/src/main/java/org/javamoney/format/IsoCurrencyFormatFactory.java
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import javax.inject.Singleton;
import javax.money.CurrencyUnit;
import org.javamoney.format.IsoCurrencyFormat.RenderedField;
import org.javamoney.format.spi.ItemFormatFactorySpi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* Copyright (c) 2012, 2013, Credit Suisse (Anatole Tresch), Werner Keil.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.javamoney.format;
@Singleton
public class IsoCurrencyFormatFactory implements
ItemFormatFactorySpi<CurrencyUnit> {
private static final Logger LOGGER = LoggerFactory
.getLogger(IsoCurrencyFormatFactory.class);
@Override
public Class<CurrencyUnit> getTargetClass() {
return CurrencyUnit.class;
}
@Override
public Collection<String> getSupportedStyleIds() {
Set<String> supportedRenderTypes = new HashSet<String>();
|
for (IsoCurrencyFormat.RenderedField f : IsoCurrencyFormat.RenderedField
|
JavaMoney/javamoney-shelter
|
retired/format/src/main/java/org/javamoney/format/DefaultAmountFormatFactory.java
|
// Path: retired/format/src/main/java/org/javamoney/format/spi/ItemFormatFactorySpi.java
// public interface ItemFormatFactorySpi<T>{
//
// /**
// * Return the target type the owning artifact can be applied to.
// *
// * @return the target type, never {@code null}.
// */
// public Class<T> getTargetClass();
//
// /**
// * Return the style id's supported by this {@link ItemFormatFactorySpi}
// * instance.
// *
// * @return the supported style identifiers, never {@code null}.
// * @see org.javamoney.format.LocalizationContext#getId()
// */
// public Collection<String> getSupportedStyleIds();
//
// /**
// * Access a configured default {@link org.javamoney.format.LocalizationContext} instance. If the
// * required styleId is part of the supported styles returned by this spi
// * implementation, then this method should return the according
// * {@link org.javamoney.format.LocalizationContext} instance.
// *
// * @param targetType The target type, not {@code null}.
// * @param styleId The style identifier, may be {@code null}, acquiring a
// * <i>default</i> style.
// * @return the style instance, or {@code null}.
// */
// public LocalizationContext getLocalizationStyle(Class<?> targetType, String styleId);
//
// /**
// * Method to check, if a style is available for the type this factory is
// * producing {@link ItemFormat}s.
// *
// * @param styleId the target style identifier.
// * @return {@code true}, if the style is available for the current target
// * type.
// * @see #getTargetClass()
// */
// public boolean isSupportedStyle(String styleId);
//
// /**
// * Creates a new instance of {@link ItemFormat} configured by the given
// * {@link org.javamoney.format.LocalizationContext} instance, if the style (style identifier, one
// * of the style's attributes) required are not supported by this factory,
// * {@code null} should be returned (different to the API, where an
// * {@link ItemFormatException} must be thrown.
// *
// * @param style the {@link org.javamoney.format.LocalizationContext} that configures this
// * {@link ItemFormat}, which also contains the {@link ItemFormat}
// * 's configuration attributes.
// * @return a {@link ItemFormat} instance configured with the given style, or
// * {@code null}.
// * @see #getTargetClass()
// */
// public ItemFormat<T> getItemFormat(LocalizationContext style) throws ItemFormatException;
//
// }
|
import java.util.Collection;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import javax.inject.Singleton;
import javax.money.MonetaryAmount;
import org.javamoney.format.spi.ItemFormatFactorySpi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
|
/*
* Copyright (c) 2012, 2013, Credit Suisse (Anatole Tresch), Werner Keil.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.javamoney.format;
@Singleton
public class DefaultAmountFormatFactory implements
|
// Path: retired/format/src/main/java/org/javamoney/format/spi/ItemFormatFactorySpi.java
// public interface ItemFormatFactorySpi<T>{
//
// /**
// * Return the target type the owning artifact can be applied to.
// *
// * @return the target type, never {@code null}.
// */
// public Class<T> getTargetClass();
//
// /**
// * Return the style id's supported by this {@link ItemFormatFactorySpi}
// * instance.
// *
// * @return the supported style identifiers, never {@code null}.
// * @see org.javamoney.format.LocalizationContext#getId()
// */
// public Collection<String> getSupportedStyleIds();
//
// /**
// * Access a configured default {@link org.javamoney.format.LocalizationContext} instance. If the
// * required styleId is part of the supported styles returned by this spi
// * implementation, then this method should return the according
// * {@link org.javamoney.format.LocalizationContext} instance.
// *
// * @param targetType The target type, not {@code null}.
// * @param styleId The style identifier, may be {@code null}, acquiring a
// * <i>default</i> style.
// * @return the style instance, or {@code null}.
// */
// public LocalizationContext getLocalizationStyle(Class<?> targetType, String styleId);
//
// /**
// * Method to check, if a style is available for the type this factory is
// * producing {@link ItemFormat}s.
// *
// * @param styleId the target style identifier.
// * @return {@code true}, if the style is available for the current target
// * type.
// * @see #getTargetClass()
// */
// public boolean isSupportedStyle(String styleId);
//
// /**
// * Creates a new instance of {@link ItemFormat} configured by the given
// * {@link org.javamoney.format.LocalizationContext} instance, if the style (style identifier, one
// * of the style's attributes) required are not supported by this factory,
// * {@code null} should be returned (different to the API, where an
// * {@link ItemFormatException} must be thrown.
// *
// * @param style the {@link org.javamoney.format.LocalizationContext} that configures this
// * {@link ItemFormat}, which also contains the {@link ItemFormat}
// * 's configuration attributes.
// * @return a {@link ItemFormat} instance configured with the given style, or
// * {@code null}.
// * @see #getTargetClass()
// */
// public ItemFormat<T> getItemFormat(LocalizationContext style) throws ItemFormatException;
//
// }
// Path: retired/format/src/main/java/org/javamoney/format/DefaultAmountFormatFactory.java
import java.util.Collection;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import javax.inject.Singleton;
import javax.money.MonetaryAmount;
import org.javamoney.format.spi.ItemFormatFactorySpi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* Copyright (c) 2012, 2013, Credit Suisse (Anatole Tresch), Werner Keil.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.javamoney.format;
@Singleton
public class DefaultAmountFormatFactory implements
|
ItemFormatFactorySpi<MonetaryAmount> {
|
JavaMoney/javamoney-shelter
|
retired/currencies/src/main/java/org/javamoney/currencies/internal/DefaultCurrencyMappingsSingletonSpi.java
|
// Path: retired/currencies/src/main/java/org/javamoney/currencies/CurrencyMappingQuerySelector.java
// public enum CurrencyMappingQuerySelector {
// /**
// * This query type identifies queries to map from a currency to one or more oither currencies.
// */
// MAPPING,
// /**
// * This query type identifies queries to access all currencies beloging to a certain namespace.
// */
// NAMESPACE
// }
//
// Path: retired/currencies/src/main/java/org/javamoney/currencies/spi/CurrencyUnitNamespaceProviderSpi.java
// public interface CurrencyUnitNamespaceProviderSpi {
//
// /**
// * Access the namespaces this provider defines. An instance of
// * {@link CurrencyUnitNamespaceProviderSpi} may define multiple namespaces containing
// * {@link CurrencyUnit}. Nevertheless multiple implementations of
// * Additionally a {@link CurrencyUnit} may be part of multiple namespaces,
// * if they do not conflict related to their currency code or numericCode (if
// * defined).
// *
// * @return the namespaces that this provider defines, never {@code null}.
// */
// public Collection<String> getNamespaces();
//
// /**
// * Access all {@link CurrencyUnit} instances.
// *
// * @param namespace The target namespace, never {@code null}.
// * @return the {@link CurrencyUnit} instances known to this provider
// * instance, never {@code null}. If the provider can not provide a
// * full list of all currencies an empty {@link Collection} should be
// * returned.
// */
// public Collection<CurrencyUnit> getCurrencies(String namespace);
//
// /**
// * Checks if a given namespace is known to this provider.
// *
// * @param namespace the namespace id, not {@code null}.
// * @return {@code true} if the namespace is served by this provider.
// */
// public boolean isNamespaceAvailable(String namespace);
//
// /**
// * Reverse mapping of a currencyCode to its namespaces.
// *
// * @param currencyCode the currencyCode, not {@code null}
// * @return the set of namespaces for the given code, never {@code null}.
// */
// public Set<String> getNamespaces(String currencyCode);
//
// }
//
// Path: retired/currencies/src/main/java/org/javamoney/currencies/spi/CurrencyMappingsSingletonSpi.java
// public interface CurrencyMappingsSingletonSpi {
//
// /**
// * This method allows to evaluate, if the given currency namespace is
// * defined. {@code "ISO-4217"} should be defined in all environments
// * (default).
// *
// * @param namespace the required namespace
// * @return {@code true}, if the namespace exists.
// */
// public boolean isNamespaceAvailable(String namespace);
//
// /**
// * This method allows to access all namespaces currently defined.
// * {@code "ISO-4217"} should be defined in all environments (default).
// *
// * @return the array of currently defined namespace.
// */
// public Set<String> getNamespaces();
//
// /**
// * This method maps the given {@link CurrencyUnit} to another
// * {@link CurrencyUnit} with the given target namespace.
// *
// * @param currencyUnit The source {@link CurrencyUnit}, never {@code null}.
// * @param targetNamespace the target namespace, never {@code null}.
// * @return The mapped {@link CurrencyUnit}, or {@code null}.
// */
// public CurrencyQuery getMappingQuery(CurrencyUnit currencyUnit,
// String targetNamespace);
//
// /**
// * Access all currencies for a given namespace.
// *
// * @param namespace The target namespace, not {@code null}.
// * @return The currencies found, never {@code null}.
// * @throws javax.money.UnknownCurrencyException if the required namespace is not defined.
// * @see #getNamespaces()
// */
// public CurrencyQuery getNamespaceQuery(String namespace);
//
// /**
// * Evaluates the currency namespace of a currency code.
// *
// * @param code The currency code.
// * @return {@code true}, if the currency is defined.
// */
// public Set<String> getNamespaces(String code);
//
// /**
// * Evaluates the currency namespace of a currency code.
// *
// * @param currency The currency, not null.
// * @return {@code true}, if the currency is defined.
// */
// public Set<String> getNamespaces(CurrencyUnit currency);
//
// }
|
import java.util.HashSet;
import java.util.ServiceLoader;
import java.util.Set;
import javax.inject.Singleton;
import javax.money.CurrencyQuery;
import javax.money.CurrencyQueryBuilder;
import javax.money.CurrencyUnit;
import javax.money.spi.Bootstrap;
import org.javamoney.currencies.CurrencyMappingQuerySelector;
import org.javamoney.currencies.spi.CurrencyUnitNamespaceProviderSpi;
import org.javamoney.currencies.spi.CurrencyMappingsSingletonSpi;
|
package org.javamoney.currencies.internal;
/**
* Default implementation of {@link CurrencyMappingsSingletonSpi}, active
* if no instance of {@link CurrencyMappingsSingletonSpi} was registered
* using the {@link ServiceLoader}.
*
* @author Anatole Tresch
*/
@Singleton
public class DefaultCurrencyMappingsSingletonSpi implements CurrencyMappingsSingletonSpi {
/**
* This method allows to evaluate, if the given currency namespace is
* defined. {@code "ISO-4217"} should be defined in all environments
* (default).
*
* @param namespace the required namespace
* @return {@code true}, if the namespace exists.
*/
@Override
public boolean isNamespaceAvailable(String namespace){
|
// Path: retired/currencies/src/main/java/org/javamoney/currencies/CurrencyMappingQuerySelector.java
// public enum CurrencyMappingQuerySelector {
// /**
// * This query type identifies queries to map from a currency to one or more oither currencies.
// */
// MAPPING,
// /**
// * This query type identifies queries to access all currencies beloging to a certain namespace.
// */
// NAMESPACE
// }
//
// Path: retired/currencies/src/main/java/org/javamoney/currencies/spi/CurrencyUnitNamespaceProviderSpi.java
// public interface CurrencyUnitNamespaceProviderSpi {
//
// /**
// * Access the namespaces this provider defines. An instance of
// * {@link CurrencyUnitNamespaceProviderSpi} may define multiple namespaces containing
// * {@link CurrencyUnit}. Nevertheless multiple implementations of
// * Additionally a {@link CurrencyUnit} may be part of multiple namespaces,
// * if they do not conflict related to their currency code or numericCode (if
// * defined).
// *
// * @return the namespaces that this provider defines, never {@code null}.
// */
// public Collection<String> getNamespaces();
//
// /**
// * Access all {@link CurrencyUnit} instances.
// *
// * @param namespace The target namespace, never {@code null}.
// * @return the {@link CurrencyUnit} instances known to this provider
// * instance, never {@code null}. If the provider can not provide a
// * full list of all currencies an empty {@link Collection} should be
// * returned.
// */
// public Collection<CurrencyUnit> getCurrencies(String namespace);
//
// /**
// * Checks if a given namespace is known to this provider.
// *
// * @param namespace the namespace id, not {@code null}.
// * @return {@code true} if the namespace is served by this provider.
// */
// public boolean isNamespaceAvailable(String namespace);
//
// /**
// * Reverse mapping of a currencyCode to its namespaces.
// *
// * @param currencyCode the currencyCode, not {@code null}
// * @return the set of namespaces for the given code, never {@code null}.
// */
// public Set<String> getNamespaces(String currencyCode);
//
// }
//
// Path: retired/currencies/src/main/java/org/javamoney/currencies/spi/CurrencyMappingsSingletonSpi.java
// public interface CurrencyMappingsSingletonSpi {
//
// /**
// * This method allows to evaluate, if the given currency namespace is
// * defined. {@code "ISO-4217"} should be defined in all environments
// * (default).
// *
// * @param namespace the required namespace
// * @return {@code true}, if the namespace exists.
// */
// public boolean isNamespaceAvailable(String namespace);
//
// /**
// * This method allows to access all namespaces currently defined.
// * {@code "ISO-4217"} should be defined in all environments (default).
// *
// * @return the array of currently defined namespace.
// */
// public Set<String> getNamespaces();
//
// /**
// * This method maps the given {@link CurrencyUnit} to another
// * {@link CurrencyUnit} with the given target namespace.
// *
// * @param currencyUnit The source {@link CurrencyUnit}, never {@code null}.
// * @param targetNamespace the target namespace, never {@code null}.
// * @return The mapped {@link CurrencyUnit}, or {@code null}.
// */
// public CurrencyQuery getMappingQuery(CurrencyUnit currencyUnit,
// String targetNamespace);
//
// /**
// * Access all currencies for a given namespace.
// *
// * @param namespace The target namespace, not {@code null}.
// * @return The currencies found, never {@code null}.
// * @throws javax.money.UnknownCurrencyException if the required namespace is not defined.
// * @see #getNamespaces()
// */
// public CurrencyQuery getNamespaceQuery(String namespace);
//
// /**
// * Evaluates the currency namespace of a currency code.
// *
// * @param code The currency code.
// * @return {@code true}, if the currency is defined.
// */
// public Set<String> getNamespaces(String code);
//
// /**
// * Evaluates the currency namespace of a currency code.
// *
// * @param currency The currency, not null.
// * @return {@code true}, if the currency is defined.
// */
// public Set<String> getNamespaces(CurrencyUnit currency);
//
// }
// Path: retired/currencies/src/main/java/org/javamoney/currencies/internal/DefaultCurrencyMappingsSingletonSpi.java
import java.util.HashSet;
import java.util.ServiceLoader;
import java.util.Set;
import javax.inject.Singleton;
import javax.money.CurrencyQuery;
import javax.money.CurrencyQueryBuilder;
import javax.money.CurrencyUnit;
import javax.money.spi.Bootstrap;
import org.javamoney.currencies.CurrencyMappingQuerySelector;
import org.javamoney.currencies.spi.CurrencyUnitNamespaceProviderSpi;
import org.javamoney.currencies.spi.CurrencyMappingsSingletonSpi;
package org.javamoney.currencies.internal;
/**
* Default implementation of {@link CurrencyMappingsSingletonSpi}, active
* if no instance of {@link CurrencyMappingsSingletonSpi} was registered
* using the {@link ServiceLoader}.
*
* @author Anatole Tresch
*/
@Singleton
public class DefaultCurrencyMappingsSingletonSpi implements CurrencyMappingsSingletonSpi {
/**
* This method allows to evaluate, if the given currency namespace is
* defined. {@code "ISO-4217"} should be defined in all environments
* (default).
*
* @param namespace the required namespace
* @return {@code true}, if the namespace exists.
*/
@Override
public boolean isNamespaceAvailable(String namespace){
|
for(CurrencyUnitNamespaceProviderSpi spi : Bootstrap.getServices(CurrencyUnitNamespaceProviderSpi.class)){
|
JavaMoney/javamoney-shelter
|
retired/currencies/src/main/java/org/javamoney/currencies/internal/ISOCurrencyNamespaceProvider.java
|
// Path: retired/currencies/src/main/java/org/javamoney/currencies/spi/CurrencyUnitNamespaceProviderSpi.java
// public interface CurrencyUnitNamespaceProviderSpi {
//
// /**
// * Access the namespaces this provider defines. An instance of
// * {@link CurrencyUnitNamespaceProviderSpi} may define multiple namespaces containing
// * {@link CurrencyUnit}. Nevertheless multiple implementations of
// * Additionally a {@link CurrencyUnit} may be part of multiple namespaces,
// * if they do not conflict related to their currency code or numericCode (if
// * defined).
// *
// * @return the namespaces that this provider defines, never {@code null}.
// */
// public Collection<String> getNamespaces();
//
// /**
// * Access all {@link CurrencyUnit} instances.
// *
// * @param namespace The target namespace, never {@code null}.
// * @return the {@link CurrencyUnit} instances known to this provider
// * instance, never {@code null}. If the provider can not provide a
// * full list of all currencies an empty {@link Collection} should be
// * returned.
// */
// public Collection<CurrencyUnit> getCurrencies(String namespace);
//
// /**
// * Checks if a given namespace is known to this provider.
// *
// * @param namespace the namespace id, not {@code null}.
// * @return {@code true} if the namespace is served by this provider.
// */
// public boolean isNamespaceAvailable(String namespace);
//
// /**
// * Reverse mapping of a currencyCode to its namespaces.
// *
// * @param currencyCode the currencyCode, not {@code null}
// * @return the set of namespaces for the given code, never {@code null}.
// */
// public Set<String> getNamespaces(String currencyCode);
//
// }
//
// Path: retired/currencies/src/main/java/org/javamoney/currencies/spi/CurrencyMappingsSingletonSpi.java
// public interface CurrencyMappingsSingletonSpi {
//
// /**
// * This method allows to evaluate, if the given currency namespace is
// * defined. {@code "ISO-4217"} should be defined in all environments
// * (default).
// *
// * @param namespace the required namespace
// * @return {@code true}, if the namespace exists.
// */
// public boolean isNamespaceAvailable(String namespace);
//
// /**
// * This method allows to access all namespaces currently defined.
// * {@code "ISO-4217"} should be defined in all environments (default).
// *
// * @return the array of currently defined namespace.
// */
// public Set<String> getNamespaces();
//
// /**
// * This method maps the given {@link CurrencyUnit} to another
// * {@link CurrencyUnit} with the given target namespace.
// *
// * @param currencyUnit The source {@link CurrencyUnit}, never {@code null}.
// * @param targetNamespace the target namespace, never {@code null}.
// * @return The mapped {@link CurrencyUnit}, or {@code null}.
// */
// public CurrencyQuery getMappingQuery(CurrencyUnit currencyUnit,
// String targetNamespace);
//
// /**
// * Access all currencies for a given namespace.
// *
// * @param namespace The target namespace, not {@code null}.
// * @return The currencies found, never {@code null}.
// * @throws javax.money.UnknownCurrencyException if the required namespace is not defined.
// * @see #getNamespaces()
// */
// public CurrencyQuery getNamespaceQuery(String namespace);
//
// /**
// * Evaluates the currency namespace of a currency code.
// *
// * @param code The currency code.
// * @return {@code true}, if the currency is defined.
// */
// public Set<String> getNamespaces(String code);
//
// /**
// * Evaluates the currency namespace of a currency code.
// *
// * @param currency The currency, not null.
// * @return {@code true}, if the currency is defined.
// */
// public Set<String> getNamespaces(CurrencyUnit currency);
//
// }
|
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.ServiceLoader;
import java.util.Set;
import javax.inject.Singleton;
import javax.money.CurrencyUnit;
import javax.money.MonetaryCurrencies;
import org.javamoney.currencies.spi.CurrencyUnitNamespaceProviderSpi;
import org.javamoney.currencies.spi.CurrencyMappingsSingletonSpi;
import java.util.Currency;
|
package org.javamoney.currencies.internal;
/**
* Default implementation of {@link CurrencyMappingsSingletonSpi}, active
* if no instance of {@link CurrencyMappingsSingletonSpi} was registered
* using the {@link ServiceLoader}.
*
* @author Anatole Tresch
*/
@Singleton
public class ISOCurrencyNamespaceProvider implements
|
// Path: retired/currencies/src/main/java/org/javamoney/currencies/spi/CurrencyUnitNamespaceProviderSpi.java
// public interface CurrencyUnitNamespaceProviderSpi {
//
// /**
// * Access the namespaces this provider defines. An instance of
// * {@link CurrencyUnitNamespaceProviderSpi} may define multiple namespaces containing
// * {@link CurrencyUnit}. Nevertheless multiple implementations of
// * Additionally a {@link CurrencyUnit} may be part of multiple namespaces,
// * if they do not conflict related to their currency code or numericCode (if
// * defined).
// *
// * @return the namespaces that this provider defines, never {@code null}.
// */
// public Collection<String> getNamespaces();
//
// /**
// * Access all {@link CurrencyUnit} instances.
// *
// * @param namespace The target namespace, never {@code null}.
// * @return the {@link CurrencyUnit} instances known to this provider
// * instance, never {@code null}. If the provider can not provide a
// * full list of all currencies an empty {@link Collection} should be
// * returned.
// */
// public Collection<CurrencyUnit> getCurrencies(String namespace);
//
// /**
// * Checks if a given namespace is known to this provider.
// *
// * @param namespace the namespace id, not {@code null}.
// * @return {@code true} if the namespace is served by this provider.
// */
// public boolean isNamespaceAvailable(String namespace);
//
// /**
// * Reverse mapping of a currencyCode to its namespaces.
// *
// * @param currencyCode the currencyCode, not {@code null}
// * @return the set of namespaces for the given code, never {@code null}.
// */
// public Set<String> getNamespaces(String currencyCode);
//
// }
//
// Path: retired/currencies/src/main/java/org/javamoney/currencies/spi/CurrencyMappingsSingletonSpi.java
// public interface CurrencyMappingsSingletonSpi {
//
// /**
// * This method allows to evaluate, if the given currency namespace is
// * defined. {@code "ISO-4217"} should be defined in all environments
// * (default).
// *
// * @param namespace the required namespace
// * @return {@code true}, if the namespace exists.
// */
// public boolean isNamespaceAvailable(String namespace);
//
// /**
// * This method allows to access all namespaces currently defined.
// * {@code "ISO-4217"} should be defined in all environments (default).
// *
// * @return the array of currently defined namespace.
// */
// public Set<String> getNamespaces();
//
// /**
// * This method maps the given {@link CurrencyUnit} to another
// * {@link CurrencyUnit} with the given target namespace.
// *
// * @param currencyUnit The source {@link CurrencyUnit}, never {@code null}.
// * @param targetNamespace the target namespace, never {@code null}.
// * @return The mapped {@link CurrencyUnit}, or {@code null}.
// */
// public CurrencyQuery getMappingQuery(CurrencyUnit currencyUnit,
// String targetNamespace);
//
// /**
// * Access all currencies for a given namespace.
// *
// * @param namespace The target namespace, not {@code null}.
// * @return The currencies found, never {@code null}.
// * @throws javax.money.UnknownCurrencyException if the required namespace is not defined.
// * @see #getNamespaces()
// */
// public CurrencyQuery getNamespaceQuery(String namespace);
//
// /**
// * Evaluates the currency namespace of a currency code.
// *
// * @param code The currency code.
// * @return {@code true}, if the currency is defined.
// */
// public Set<String> getNamespaces(String code);
//
// /**
// * Evaluates the currency namespace of a currency code.
// *
// * @param currency The currency, not null.
// * @return {@code true}, if the currency is defined.
// */
// public Set<String> getNamespaces(CurrencyUnit currency);
//
// }
// Path: retired/currencies/src/main/java/org/javamoney/currencies/internal/ISOCurrencyNamespaceProvider.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.ServiceLoader;
import java.util.Set;
import javax.inject.Singleton;
import javax.money.CurrencyUnit;
import javax.money.MonetaryCurrencies;
import org.javamoney.currencies.spi.CurrencyUnitNamespaceProviderSpi;
import org.javamoney.currencies.spi.CurrencyMappingsSingletonSpi;
import java.util.Currency;
package org.javamoney.currencies.internal;
/**
* Default implementation of {@link CurrencyMappingsSingletonSpi}, active
* if no instance of {@link CurrencyMappingsSingletonSpi} was registered
* using the {@link ServiceLoader}.
*
* @author Anatole Tresch
*/
@Singleton
public class ISOCurrencyNamespaceProvider implements
|
CurrencyUnitNamespaceProviderSpi {
|
JavaMoney/javamoney-shelter
|
retired/regions/src/main/java/org/javamoney/regions/spi/AbstractRegionNode.java
|
// Path: retired/regions/src/main/java/org/javamoney/regions/Region.java
// public interface Region {
//
// /**
// * Get the region's type.
// *
// * @return the region's type, never {@code null}.
// */
// public RegionType getRegionType();
//
// /**
// * Access the region's code. The code is unique in combination with the
// * region type.
// *
// * @return the region's type, never {@code null}.
// */
// public String getRegionCode();
//
// /**
// * Get the region's numeric code. If not defined -1 is returned.
// *
// * @return the numeric region code, or {@code -1}.
// */
// public int getNumericRegionCode();
//
// /**
// * Return the time zones valid for this region (in the long form, e.g.
// * Europe/Berlin). If the region has subregions, by default, the timezones
// * returned should be the transitive closure of all timezones of all child
// * regions. Nevertheless there might be use cases were the child regions
// * must not transitively define the parents timezones, so transitivity is
// * not enforced by this JSR.<br/>
// * Additionally all ids returned should be known by {@link java.util.TimeZone}.
// *
// * @return the timezone ids of this region, never {@code null}.
// */
// public Collection<String> getTimezoneIds();
//
// /**
// * Return according {@link java.util.Locale}, if possible.
// *
// * @return the corresponding {@link java.util.Locale} for that {@link org.javamoney.regions.Region}, may
// * also return {@code null}.
// */
// public Locale getLocale();
//
// }
//
// Path: retired/regions/src/main/java/org/javamoney/regions/RegionTreeNode.java
// public interface RegionTreeNode {
//
// /**
// * Get the corresponding region.
// *
// * @return the region, never {@code null}.
// */
// public Region getRegion();
//
// /**
// * Get the direct parent region of this region.
// *
// * @return the parent region, or {@code null}, if this region has no parent
// * (is a root region).
// */
// public RegionTreeNode getParent();
//
// /**
// * Access all direct child regions.
// *
// * @return all direct child regions, never {@code null}.
// */
// public Collection<RegionTreeNode> getChildren();
//
// /**
// * Determines if the given region is contained within this region tree.
// *
// * @param region
// * the region being looked up, null hereby is never contained.
// * @return {@code true} if the given region is a direct or indirect child of
// * this region instance.
// */
// public boolean contains(Region region);
//
// /**
// * Select the parent region with the given type. This method will navigate
// * up the region tree and select the first parent encountered that has the
// * given region type.
// *
// * @param predicate
// * the selecting filter, {@code null} will return the direct
// * parent, if any.
// * @return the region found, or {@code null}.
// */
// public RegionTreeNode selectParent(MonetaryPredicate<Region> predicate);
//
// /**
// * Select a collection of regions selected by the given filter.
// *
// * @param predicate
// * the region selector, {@code null} will return all regions.
// * @return the regions selected.
// */
// public Collection<RegionTreeNode> select(MonetaryPredicate<Region> predicate);
//
// /**
// * Access a {@link Region} using the region path, which allows access of a
// * {@link Region} from the tree, e.g. {@code WORLD/EUROPE/GERMANY} or
// * {@code STANDARDS/ISO/GER}.
// *
// * @param path
// * the path to be accessed, not {@code null}.
// * @return the {@link Region} found, or {@code null}.
// */
// public RegionTreeNode getRegionTree(String path);
//
// }
|
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.javamoney.calc.function.MonetaryPredicate;
import org.javamoney.regions.Region;
import org.javamoney.regions.RegionTreeNode;
|
/*
* Copyright (c) 2012, 2013, Credit Suisse (Anatole Tresch), Werner Keil.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.javamoney.regions.spi;
/**
* Abstract base class for a {@link RegionTreeNode}.
*
* @author Anatole Tresch
*/
public abstract class AbstractRegionNode implements RegionTreeNode,
Comparable<RegionTreeNode> {
/** Corresponding region instance. */
|
// Path: retired/regions/src/main/java/org/javamoney/regions/Region.java
// public interface Region {
//
// /**
// * Get the region's type.
// *
// * @return the region's type, never {@code null}.
// */
// public RegionType getRegionType();
//
// /**
// * Access the region's code. The code is unique in combination with the
// * region type.
// *
// * @return the region's type, never {@code null}.
// */
// public String getRegionCode();
//
// /**
// * Get the region's numeric code. If not defined -1 is returned.
// *
// * @return the numeric region code, or {@code -1}.
// */
// public int getNumericRegionCode();
//
// /**
// * Return the time zones valid for this region (in the long form, e.g.
// * Europe/Berlin). If the region has subregions, by default, the timezones
// * returned should be the transitive closure of all timezones of all child
// * regions. Nevertheless there might be use cases were the child regions
// * must not transitively define the parents timezones, so transitivity is
// * not enforced by this JSR.<br/>
// * Additionally all ids returned should be known by {@link java.util.TimeZone}.
// *
// * @return the timezone ids of this region, never {@code null}.
// */
// public Collection<String> getTimezoneIds();
//
// /**
// * Return according {@link java.util.Locale}, if possible.
// *
// * @return the corresponding {@link java.util.Locale} for that {@link org.javamoney.regions.Region}, may
// * also return {@code null}.
// */
// public Locale getLocale();
//
// }
//
// Path: retired/regions/src/main/java/org/javamoney/regions/RegionTreeNode.java
// public interface RegionTreeNode {
//
// /**
// * Get the corresponding region.
// *
// * @return the region, never {@code null}.
// */
// public Region getRegion();
//
// /**
// * Get the direct parent region of this region.
// *
// * @return the parent region, or {@code null}, if this region has no parent
// * (is a root region).
// */
// public RegionTreeNode getParent();
//
// /**
// * Access all direct child regions.
// *
// * @return all direct child regions, never {@code null}.
// */
// public Collection<RegionTreeNode> getChildren();
//
// /**
// * Determines if the given region is contained within this region tree.
// *
// * @param region
// * the region being looked up, null hereby is never contained.
// * @return {@code true} if the given region is a direct or indirect child of
// * this region instance.
// */
// public boolean contains(Region region);
//
// /**
// * Select the parent region with the given type. This method will navigate
// * up the region tree and select the first parent encountered that has the
// * given region type.
// *
// * @param predicate
// * the selecting filter, {@code null} will return the direct
// * parent, if any.
// * @return the region found, or {@code null}.
// */
// public RegionTreeNode selectParent(MonetaryPredicate<Region> predicate);
//
// /**
// * Select a collection of regions selected by the given filter.
// *
// * @param predicate
// * the region selector, {@code null} will return all regions.
// * @return the regions selected.
// */
// public Collection<RegionTreeNode> select(MonetaryPredicate<Region> predicate);
//
// /**
// * Access a {@link Region} using the region path, which allows access of a
// * {@link Region} from the tree, e.g. {@code WORLD/EUROPE/GERMANY} or
// * {@code STANDARDS/ISO/GER}.
// *
// * @param path
// * the path to be accessed, not {@code null}.
// * @return the {@link Region} found, or {@code null}.
// */
// public RegionTreeNode getRegionTree(String path);
//
// }
// Path: retired/regions/src/main/java/org/javamoney/regions/spi/AbstractRegionNode.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.javamoney.calc.function.MonetaryPredicate;
import org.javamoney.regions.Region;
import org.javamoney.regions.RegionTreeNode;
/*
* Copyright (c) 2012, 2013, Credit Suisse (Anatole Tresch), Werner Keil.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.javamoney.regions.spi;
/**
* Abstract base class for a {@link RegionTreeNode}.
*
* @author Anatole Tresch
*/
public abstract class AbstractRegionNode implements RegionTreeNode,
Comparable<RegionTreeNode> {
/** Corresponding region instance. */
|
private Region region;
|
JavaMoney/javamoney-shelter
|
retired/format/src/main/java/org/javamoney/format/ItemFormatBuilder.java
|
// Path: retired/format/src/main/java/org/javamoney/format/tokens/LiteralTokenStyleableItem.java
// public final class LiteralTokenStyleableItem<R> implements StyleableItemFormatToken<R>, Serializable {
//
// /**
// * The literal part.
// */
// private String token;
//
// /**
// * Constructor.
// *
// * @param token
// * The literal token part.
// */
// public LiteralTokenStyleableItem(String token) {
// if (token == null) {
// throw new IllegalArgumentException("Token is required.");
// }
// this.token = token;
// }
//
//
// /*
// * (non-Javadoc)
// *
// * @see
// * javax.money.format.StyleableItemFormatToken#parse(javax.money.format.ItemParseContext,
// * java.util.Locale, javax.money.format.LocalizationStyle)
// */
// @Override
// public void parse(ItemParseContext<R> context, Locale locale,
// LocalizationContext style)
// throws ItemParseException{
// if (!context.consume(token)) {
// throw new ItemParseException("Expected '" + token + "' in "
// + context.getInput().toString());
// }
// }
//
// /*
// * (non-Javadoc)
// *
// * @see javax.money.format.StyleableItemFormatToken#print(java.lang.Appendable,
// * java.lang.Object, java.util.Locale, javax.money.format.LocalizationStyle)
// */
// @Override
// public void print(Appendable appendable, R item, Locale locale,
// LocalizationContext style)
// throws IOException {
// appendable.append(this.token);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// return "LiteralTokenStyleableItem [token=" + token + "]";
// }
//
// }
|
import org.javamoney.format.tokens.LiteralTokenStyleableItem;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
|
*
* @param targetType the target type to be applied.
* @return the builder instance, for chaining.
*/
public ItemFormatBuilder<T> withTargetType(Class<T> targetType){
if(targetType == null){
throw new IllegalArgumentException("targetType required.");
}
this.targetType = targetType;
return this;
}
/**
* Add a {@link StyleableItemFormatToken} to the token list.
*
* @param token the token to add.
* @return the builder, for chaining.
*/
public ItemFormatBuilder<T> append(StyleableItemFormatToken<T> token){
this.tokens.add(token);
return this;
}
/**
* Add a {@link StyleableItemFormatToken} to the token list.
*
* @param token the token to add.
* @return the builder, for chaining.
*/
public ItemFormatBuilder<T> append(String token){
|
// Path: retired/format/src/main/java/org/javamoney/format/tokens/LiteralTokenStyleableItem.java
// public final class LiteralTokenStyleableItem<R> implements StyleableItemFormatToken<R>, Serializable {
//
// /**
// * The literal part.
// */
// private String token;
//
// /**
// * Constructor.
// *
// * @param token
// * The literal token part.
// */
// public LiteralTokenStyleableItem(String token) {
// if (token == null) {
// throw new IllegalArgumentException("Token is required.");
// }
// this.token = token;
// }
//
//
// /*
// * (non-Javadoc)
// *
// * @see
// * javax.money.format.StyleableItemFormatToken#parse(javax.money.format.ItemParseContext,
// * java.util.Locale, javax.money.format.LocalizationStyle)
// */
// @Override
// public void parse(ItemParseContext<R> context, Locale locale,
// LocalizationContext style)
// throws ItemParseException{
// if (!context.consume(token)) {
// throw new ItemParseException("Expected '" + token + "' in "
// + context.getInput().toString());
// }
// }
//
// /*
// * (non-Javadoc)
// *
// * @see javax.money.format.StyleableItemFormatToken#print(java.lang.Appendable,
// * java.lang.Object, java.util.Locale, javax.money.format.LocalizationStyle)
// */
// @Override
// public void print(Appendable appendable, R item, Locale locale,
// LocalizationContext style)
// throws IOException {
// appendable.append(this.token);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// return "LiteralTokenStyleableItem [token=" + token + "]";
// }
//
// }
// Path: retired/format/src/main/java/org/javamoney/format/ItemFormatBuilder.java
import org.javamoney.format.tokens.LiteralTokenStyleableItem;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
*
* @param targetType the target type to be applied.
* @return the builder instance, for chaining.
*/
public ItemFormatBuilder<T> withTargetType(Class<T> targetType){
if(targetType == null){
throw new IllegalArgumentException("targetType required.");
}
this.targetType = targetType;
return this;
}
/**
* Add a {@link StyleableItemFormatToken} to the token list.
*
* @param token the token to add.
* @return the builder, for chaining.
*/
public ItemFormatBuilder<T> append(StyleableItemFormatToken<T> token){
this.tokens.add(token);
return this;
}
/**
* Add a {@link StyleableItemFormatToken} to the token list.
*
* @param token the token to add.
* @return the builder, for chaining.
*/
public ItemFormatBuilder<T> append(String token){
|
this.tokens.add(new LiteralTokenStyleableItem<T>(token));
|
JavaMoney/javamoney-shelter
|
retired/regions/src/main/java/org/javamoney/regions/spi/BuildableRegionNode.java
|
// Path: retired/regions/src/main/java/org/javamoney/regions/Region.java
// public interface Region {
//
// /**
// * Get the region's type.
// *
// * @return the region's type, never {@code null}.
// */
// public RegionType getRegionType();
//
// /**
// * Access the region's code. The code is unique in combination with the
// * region type.
// *
// * @return the region's type, never {@code null}.
// */
// public String getRegionCode();
//
// /**
// * Get the region's numeric code. If not defined -1 is returned.
// *
// * @return the numeric region code, or {@code -1}.
// */
// public int getNumericRegionCode();
//
// /**
// * Return the time zones valid for this region (in the long form, e.g.
// * Europe/Berlin). If the region has subregions, by default, the timezones
// * returned should be the transitive closure of all timezones of all child
// * regions. Nevertheless there might be use cases were the child regions
// * must not transitively define the parents timezones, so transitivity is
// * not enforced by this JSR.<br/>
// * Additionally all ids returned should be known by {@link java.util.TimeZone}.
// *
// * @return the timezone ids of this region, never {@code null}.
// */
// public Collection<String> getTimezoneIds();
//
// /**
// * Return according {@link java.util.Locale}, if possible.
// *
// * @return the corresponding {@link java.util.Locale} for that {@link org.javamoney.regions.Region}, may
// * also return {@code null}.
// */
// public Locale getLocale();
//
// }
//
// Path: retired/regions/src/main/java/org/javamoney/regions/RegionTreeNode.java
// public interface RegionTreeNode {
//
// /**
// * Get the corresponding region.
// *
// * @return the region, never {@code null}.
// */
// public Region getRegion();
//
// /**
// * Get the direct parent region of this region.
// *
// * @return the parent region, or {@code null}, if this region has no parent
// * (is a root region).
// */
// public RegionTreeNode getParent();
//
// /**
// * Access all direct child regions.
// *
// * @return all direct child regions, never {@code null}.
// */
// public Collection<RegionTreeNode> getChildren();
//
// /**
// * Determines if the given region is contained within this region tree.
// *
// * @param region
// * the region being looked up, null hereby is never contained.
// * @return {@code true} if the given region is a direct or indirect child of
// * this region instance.
// */
// public boolean contains(Region region);
//
// /**
// * Select the parent region with the given type. This method will navigate
// * up the region tree and select the first parent encountered that has the
// * given region type.
// *
// * @param predicate
// * the selecting filter, {@code null} will return the direct
// * parent, if any.
// * @return the region found, or {@code null}.
// */
// public RegionTreeNode selectParent(MonetaryPredicate<Region> predicate);
//
// /**
// * Select a collection of regions selected by the given filter.
// *
// * @param predicate
// * the region selector, {@code null} will return all regions.
// * @return the regions selected.
// */
// public Collection<RegionTreeNode> select(MonetaryPredicate<Region> predicate);
//
// /**
// * Access a {@link Region} using the region path, which allows access of a
// * {@link Region} from the tree, e.g. {@code WORLD/EUROPE/GERMANY} or
// * {@code STANDARDS/ISO/GER}.
// *
// * @param path
// * the path to be accessed, not {@code null}.
// * @return the {@link Region} found, or {@code null}.
// */
// public RegionTreeNode getRegionTree(String path);
//
// }
|
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.javamoney.regions.Region;
import org.javamoney.regions.RegionTreeNode;
|
/*
* CREDIT SUISSE IS WILLING TO LICENSE THIS SPECIFICATION TO YOU ONLY UPON THE
* CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS AGREEMENT.
* PLEASE READ THE TERMS AND CONDITIONS OF THIS AGREEMENT CAREFULLY. BY
* DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF THE
* AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY IT, SELECT THE "DECLINE"
* BUTTON AT THE BOTTOM OF THIS PAGE. Specification: JSR-354 Money and Currency
* API ("Specification") Copyright (c) 2012-2013, Credit Suisse All rights
* reserved.
*/
package org.javamoney.regions.spi;
/**
* {@link Region}s can be used to segregate or access artifacts (e.g.
* CurrencyUnits) either based on geographical, or commercial aspects (e.g.
* legal units). This implementation provides a class with an according
* {@link org.javamoney.regions.spi.BuildableRegionNode.Builder} for creation.
*
* @see <a href="http://unstats.un.org/unsd/methods/m49/m49regin.htm">UN M.49:
* UN Statistics Division Country or area & region codes</a>
*
* @author Anatole Tresch
*/
public class BuildableRegionNode extends AbstractRegionNode implements
RegionTreeNode, Serializable,
Comparable<RegionTreeNode> {
/**
* serialID.
*/
private static final long serialVersionUID = -8957470024522944264L;
/**
* Creates a region. Regions should only be accessed using the accessor
* method {@link Monetary#getExtension(Class)}, passing
* {@link RegionProvider} as type.
*
* @param id
* the region's id, not null.
* @param type
* the region's type, not null.
*/
|
// Path: retired/regions/src/main/java/org/javamoney/regions/Region.java
// public interface Region {
//
// /**
// * Get the region's type.
// *
// * @return the region's type, never {@code null}.
// */
// public RegionType getRegionType();
//
// /**
// * Access the region's code. The code is unique in combination with the
// * region type.
// *
// * @return the region's type, never {@code null}.
// */
// public String getRegionCode();
//
// /**
// * Get the region's numeric code. If not defined -1 is returned.
// *
// * @return the numeric region code, or {@code -1}.
// */
// public int getNumericRegionCode();
//
// /**
// * Return the time zones valid for this region (in the long form, e.g.
// * Europe/Berlin). If the region has subregions, by default, the timezones
// * returned should be the transitive closure of all timezones of all child
// * regions. Nevertheless there might be use cases were the child regions
// * must not transitively define the parents timezones, so transitivity is
// * not enforced by this JSR.<br/>
// * Additionally all ids returned should be known by {@link java.util.TimeZone}.
// *
// * @return the timezone ids of this region, never {@code null}.
// */
// public Collection<String> getTimezoneIds();
//
// /**
// * Return according {@link java.util.Locale}, if possible.
// *
// * @return the corresponding {@link java.util.Locale} for that {@link org.javamoney.regions.Region}, may
// * also return {@code null}.
// */
// public Locale getLocale();
//
// }
//
// Path: retired/regions/src/main/java/org/javamoney/regions/RegionTreeNode.java
// public interface RegionTreeNode {
//
// /**
// * Get the corresponding region.
// *
// * @return the region, never {@code null}.
// */
// public Region getRegion();
//
// /**
// * Get the direct parent region of this region.
// *
// * @return the parent region, or {@code null}, if this region has no parent
// * (is a root region).
// */
// public RegionTreeNode getParent();
//
// /**
// * Access all direct child regions.
// *
// * @return all direct child regions, never {@code null}.
// */
// public Collection<RegionTreeNode> getChildren();
//
// /**
// * Determines if the given region is contained within this region tree.
// *
// * @param region
// * the region being looked up, null hereby is never contained.
// * @return {@code true} if the given region is a direct or indirect child of
// * this region instance.
// */
// public boolean contains(Region region);
//
// /**
// * Select the parent region with the given type. This method will navigate
// * up the region tree and select the first parent encountered that has the
// * given region type.
// *
// * @param predicate
// * the selecting filter, {@code null} will return the direct
// * parent, if any.
// * @return the region found, or {@code null}.
// */
// public RegionTreeNode selectParent(MonetaryPredicate<Region> predicate);
//
// /**
// * Select a collection of regions selected by the given filter.
// *
// * @param predicate
// * the region selector, {@code null} will return all regions.
// * @return the regions selected.
// */
// public Collection<RegionTreeNode> select(MonetaryPredicate<Region> predicate);
//
// /**
// * Access a {@link Region} using the region path, which allows access of a
// * {@link Region} from the tree, e.g. {@code WORLD/EUROPE/GERMANY} or
// * {@code STANDARDS/ISO/GER}.
// *
// * @param path
// * the path to be accessed, not {@code null}.
// * @return the {@link Region} found, or {@code null}.
// */
// public RegionTreeNode getRegionTree(String path);
//
// }
// Path: retired/regions/src/main/java/org/javamoney/regions/spi/BuildableRegionNode.java
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.javamoney.regions.Region;
import org.javamoney.regions.RegionTreeNode;
/*
* CREDIT SUISSE IS WILLING TO LICENSE THIS SPECIFICATION TO YOU ONLY UPON THE
* CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS AGREEMENT.
* PLEASE READ THE TERMS AND CONDITIONS OF THIS AGREEMENT CAREFULLY. BY
* DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF THE
* AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY IT, SELECT THE "DECLINE"
* BUTTON AT THE BOTTOM OF THIS PAGE. Specification: JSR-354 Money and Currency
* API ("Specification") Copyright (c) 2012-2013, Credit Suisse All rights
* reserved.
*/
package org.javamoney.regions.spi;
/**
* {@link Region}s can be used to segregate or access artifacts (e.g.
* CurrencyUnits) either based on geographical, or commercial aspects (e.g.
* legal units). This implementation provides a class with an according
* {@link org.javamoney.regions.spi.BuildableRegionNode.Builder} for creation.
*
* @see <a href="http://unstats.un.org/unsd/methods/m49/m49regin.htm">UN M.49:
* UN Statistics Division Country or area & region codes</a>
*
* @author Anatole Tresch
*/
public class BuildableRegionNode extends AbstractRegionNode implements
RegionTreeNode, Serializable,
Comparable<RegionTreeNode> {
/**
* serialID.
*/
private static final long serialVersionUID = -8957470024522944264L;
/**
* Creates a region. Regions should only be accessed using the accessor
* method {@link Monetary#getExtension(Class)}, passing
* {@link RegionProvider} as type.
*
* @param id
* the region's id, not null.
* @param type
* the region's type, not null.
*/
|
public BuildableRegionNode(Region region) {
|
JavaMoney/javamoney-shelter
|
retired/regions/src/main/java/org/javamoney/regions/internal/data/IcuRegionExtRegionDataProvider.java
|
// Path: retired/regions/src/main/java/org/javamoney/regions/Region.java
// public interface Region {
//
// /**
// * Get the region's type.
// *
// * @return the region's type, never {@code null}.
// */
// public RegionType getRegionType();
//
// /**
// * Access the region's code. The code is unique in combination with the
// * region type.
// *
// * @return the region's type, never {@code null}.
// */
// public String getRegionCode();
//
// /**
// * Get the region's numeric code. If not defined -1 is returned.
// *
// * @return the numeric region code, or {@code -1}.
// */
// public int getNumericRegionCode();
//
// /**
// * Return the time zones valid for this region (in the long form, e.g.
// * Europe/Berlin). If the region has subregions, by default, the timezones
// * returned should be the transitive closure of all timezones of all child
// * regions. Nevertheless there might be use cases were the child regions
// * must not transitively define the parents timezones, so transitivity is
// * not enforced by this JSR.<br/>
// * Additionally all ids returned should be known by {@link java.util.TimeZone}.
// *
// * @return the timezone ids of this region, never {@code null}.
// */
// public Collection<String> getTimezoneIds();
//
// /**
// * Return according {@link java.util.Locale}, if possible.
// *
// * @return the corresponding {@link java.util.Locale} for that {@link org.javamoney.regions.Region}, may
// * also return {@code null}.
// */
// public Locale getLocale();
//
// }
//
// Path: retired/regions/src/main/java/org/javamoney/regions/spi/ExtendedRegionDataProviderSpi.java
// public interface ExtendedRegionDataProviderSpi {
//
// /**
// * Get the extended data types, that can be accessed from this
// * {@link Region} by calling {@link #getRegionData(Class)}.
// *
// * @param region
// * the region for which addition data is requested.
// * @return the collection of supported region data, may be {@code empty} but
// * never {@code null}.
// */
// public Collection<Class> getExtendedRegionDataTypes(Region region);
//
// /**
// * Access the additional region data, using its type.
// * <p>
// * Note different to the API this method does never throw an
// * {@link IllegalArgumentException} when the required type is not supported,
// * but simply should return {@code null}.
// *
// * @param region
// * the region for which addition data is requested.
// * @param type
// * The region data type, not {@code null}.
// * @return the corresponding data item, or {@code null} if the type passed
// * is not supported.
// */
// public <T> T getExtendedRegionData(Region region, Class<T> type);
//
// }
|
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.javamoney.regions.Region;
import org.javamoney.regions.spi.ExtendedRegionDataProviderSpi;
|
/*
* Copyright (c) 2012, 2013, Credit Suisse (Anatole Tresch), Werner Keil.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.javamoney.regions.internal.data;
/**
* Implementation for {@link Region} based on ICU4J's
* {@link com.ibm.icu.util.Region}.
*
* @author Anatole Tresch
*
*/
public class IcuRegionExtRegionDataProvider implements
ExtendedRegionDataProviderSpi {
private static final List<Class> REGION_DATATYPES = Arrays
.asList(new Class[] { IcuRegion.class });
/*
* (non-Javadoc)
*
* @see javax.money.ext.Region#getRegionDataTypes()
*/
@Override
|
// Path: retired/regions/src/main/java/org/javamoney/regions/Region.java
// public interface Region {
//
// /**
// * Get the region's type.
// *
// * @return the region's type, never {@code null}.
// */
// public RegionType getRegionType();
//
// /**
// * Access the region's code. The code is unique in combination with the
// * region type.
// *
// * @return the region's type, never {@code null}.
// */
// public String getRegionCode();
//
// /**
// * Get the region's numeric code. If not defined -1 is returned.
// *
// * @return the numeric region code, or {@code -1}.
// */
// public int getNumericRegionCode();
//
// /**
// * Return the time zones valid for this region (in the long form, e.g.
// * Europe/Berlin). If the region has subregions, by default, the timezones
// * returned should be the transitive closure of all timezones of all child
// * regions. Nevertheless there might be use cases were the child regions
// * must not transitively define the parents timezones, so transitivity is
// * not enforced by this JSR.<br/>
// * Additionally all ids returned should be known by {@link java.util.TimeZone}.
// *
// * @return the timezone ids of this region, never {@code null}.
// */
// public Collection<String> getTimezoneIds();
//
// /**
// * Return according {@link java.util.Locale}, if possible.
// *
// * @return the corresponding {@link java.util.Locale} for that {@link org.javamoney.regions.Region}, may
// * also return {@code null}.
// */
// public Locale getLocale();
//
// }
//
// Path: retired/regions/src/main/java/org/javamoney/regions/spi/ExtendedRegionDataProviderSpi.java
// public interface ExtendedRegionDataProviderSpi {
//
// /**
// * Get the extended data types, that can be accessed from this
// * {@link Region} by calling {@link #getRegionData(Class)}.
// *
// * @param region
// * the region for which addition data is requested.
// * @return the collection of supported region data, may be {@code empty} but
// * never {@code null}.
// */
// public Collection<Class> getExtendedRegionDataTypes(Region region);
//
// /**
// * Access the additional region data, using its type.
// * <p>
// * Note different to the API this method does never throw an
// * {@link IllegalArgumentException} when the required type is not supported,
// * but simply should return {@code null}.
// *
// * @param region
// * the region for which addition data is requested.
// * @param type
// * The region data type, not {@code null}.
// * @return the corresponding data item, or {@code null} if the type passed
// * is not supported.
// */
// public <T> T getExtendedRegionData(Region region, Class<T> type);
//
// }
// Path: retired/regions/src/main/java/org/javamoney/regions/internal/data/IcuRegionExtRegionDataProvider.java
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.javamoney.regions.Region;
import org.javamoney.regions.spi.ExtendedRegionDataProviderSpi;
/*
* Copyright (c) 2012, 2013, Credit Suisse (Anatole Tresch), Werner Keil.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.javamoney.regions.internal.data;
/**
* Implementation for {@link Region} based on ICU4J's
* {@link com.ibm.icu.util.Region}.
*
* @author Anatole Tresch
*
*/
public class IcuRegionExtRegionDataProvider implements
ExtendedRegionDataProviderSpi {
private static final List<Class> REGION_DATATYPES = Arrays
.asList(new Class[] { IcuRegion.class });
/*
* (non-Javadoc)
*
* @see javax.money.ext.Region#getRegionDataTypes()
*/
@Override
|
public Collection<Class> getExtendedRegionDataTypes(Region region) {
|
JavaMoney/javamoney-shelter
|
retired/cldr-data/src/main/java/org/javamoney/data/icu4j/CLDRTranslations.java
|
// Path: retired/cldr-data/src/main/java/org/javamoney/data/AbstractXmlResourceLoaderListener.java
// public abstract class AbstractXmlResourceLoaderListener implements
// LoaderListener {
//
// private DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
// .newInstance();
//
// private Document document;
//
// /**
// * Constructor.
// */
// public AbstractXmlResourceLoaderListener() {
// docBuilderFactory.setIgnoringComments(true);
// docBuilderFactory.setIgnoringElementContentWhitespace(true);
// docBuilderFactory.setValidating(false);
// }
//
// @Override
// public void newDataLoaded(String dataId, InputStream is) {
// try {
// InputSource inputSource = new InputSource(is);
// docBuilderFactory.setValidating(false);
// DocumentBuilder builder = docBuilderFactory.newDocumentBuilder();
// builder.setEntityResolver((publicId, systemId) -> new InputSource(new ByteArrayInputStream(
// "<?xml version='1.0' encoding='UTF-8'?>"
// .getBytes())));
// document = builder.parse(inputSource);
// document.normalize();
// loadDocument(document);
// } catch (Exception e) {
// Logger.getLogger(getClass().getName()).log(Level.SEVERE,
// "Failed to parse resource " + dataId, e);
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (Exception e) {
// Logger.getLogger(getClass().getName()).log(Level.SEVERE,
// "Error closing input stream from " + dataId, e);
// }
// }
// }
// }
//
// /**
// * Access the underlying XML document, last read.
// *
// * @return the underlying document.
// */
// public Document getDocument() {
// return this.document;
// }
//
// /**
// * Method to be implemented to load the document data.
// *
// * @param document the document, not null.
// */
// protected abstract void loadDocument(Document document);
//
// }
|
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.money.spi.Bootstrap;
import org.javamoney.moneta.spi.LoaderService;
import org.javamoney.moneta.spi.LoaderService.UpdatePolicy;
import org.javamoney.data.AbstractXmlResourceLoaderListener;
|
/*
* Copyright (c) 2012, 2013, Credit Suisse (Anatole Tresch), Werner Keil.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.javamoney.data.icu4j;
public final class CLDRTranslations {
private static final CLDRTranslations INSTANCE = new CLDRTranslations();
private Map<String, LanguageTranslations> translations = new ConcurrentHashMap<>();
private CLDRTranslations() {
}
// @Produces
public static CLDRTranslations getInstance() {
return INSTANCE;
}
public static LanguageTranslations getInstance(String language) {
LanguageTranslations transl = INSTANCE.translations.get(language);
if (transl == null) {
try {
transl = new LanguageTranslations(language);
} catch (Exception e) {
throw new IllegalArgumentException("Unsupported language.", e);
}
INSTANCE.translations.put(language, transl);
}
return transl;
}
public static LanguageTranslations getInstance(Locale locale) {
return getInstance(locale.getLanguage());
}
public static final class LanguageTranslations extends
|
// Path: retired/cldr-data/src/main/java/org/javamoney/data/AbstractXmlResourceLoaderListener.java
// public abstract class AbstractXmlResourceLoaderListener implements
// LoaderListener {
//
// private DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
// .newInstance();
//
// private Document document;
//
// /**
// * Constructor.
// */
// public AbstractXmlResourceLoaderListener() {
// docBuilderFactory.setIgnoringComments(true);
// docBuilderFactory.setIgnoringElementContentWhitespace(true);
// docBuilderFactory.setValidating(false);
// }
//
// @Override
// public void newDataLoaded(String dataId, InputStream is) {
// try {
// InputSource inputSource = new InputSource(is);
// docBuilderFactory.setValidating(false);
// DocumentBuilder builder = docBuilderFactory.newDocumentBuilder();
// builder.setEntityResolver((publicId, systemId) -> new InputSource(new ByteArrayInputStream(
// "<?xml version='1.0' encoding='UTF-8'?>"
// .getBytes())));
// document = builder.parse(inputSource);
// document.normalize();
// loadDocument(document);
// } catch (Exception e) {
// Logger.getLogger(getClass().getName()).log(Level.SEVERE,
// "Failed to parse resource " + dataId, e);
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (Exception e) {
// Logger.getLogger(getClass().getName()).log(Level.SEVERE,
// "Error closing input stream from " + dataId, e);
// }
// }
// }
// }
//
// /**
// * Access the underlying XML document, last read.
// *
// * @return the underlying document.
// */
// public Document getDocument() {
// return this.document;
// }
//
// /**
// * Method to be implemented to load the document data.
// *
// * @param document the document, not null.
// */
// protected abstract void loadDocument(Document document);
//
// }
// Path: retired/cldr-data/src/main/java/org/javamoney/data/icu4j/CLDRTranslations.java
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.money.spi.Bootstrap;
import org.javamoney.moneta.spi.LoaderService;
import org.javamoney.moneta.spi.LoaderService.UpdatePolicy;
import org.javamoney.data.AbstractXmlResourceLoaderListener;
/*
* Copyright (c) 2012, 2013, Credit Suisse (Anatole Tresch), Werner Keil.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.javamoney.data.icu4j;
public final class CLDRTranslations {
private static final CLDRTranslations INSTANCE = new CLDRTranslations();
private Map<String, LanguageTranslations> translations = new ConcurrentHashMap<>();
private CLDRTranslations() {
}
// @Produces
public static CLDRTranslations getInstance() {
return INSTANCE;
}
public static LanguageTranslations getInstance(String language) {
LanguageTranslations transl = INSTANCE.translations.get(language);
if (transl == null) {
try {
transl = new LanguageTranslations(language);
} catch (Exception e) {
throw new IllegalArgumentException("Unsupported language.", e);
}
INSTANCE.translations.put(language, transl);
}
return transl;
}
public static LanguageTranslations getInstance(Locale locale) {
return getInstance(locale.getLanguage());
}
public static final class LanguageTranslations extends
|
AbstractXmlResourceLoaderListener {
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/PlacesApiBuilder.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClient.java
// public interface PlacesHttpClient {
// PlacesAutocompleteResponse executeAutocompleteRequest(Uri uri) throws IOException;
//
// PlacesDetailsResponse executeDetailsRequest(Uri uri) throws IOException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClientResolver.java
// public final class PlacesHttpClientResolver {
// public static final PlacesHttpClient PLACES_HTTP_CLIENT;
//
// static {
// boolean hasOkHttp;
//
// try {
// Class.forName("com.squareup.okhttp.OkHttpClient");
// hasOkHttp = true;
// } catch (ClassNotFoundException e) {
// hasOkHttp = false;
// }
//
// PlacesApiJsonParser parser = JsonParserResolver.JSON_PARSER;
//
// PLACES_HTTP_CLIENT = hasOkHttp ? new OkHttpPlacesHttpClient(parser) : new HttpUrlConnectionMapsHttpClient(parser);
// }
//
// private PlacesHttpClientResolver() {
// throw new RuntimeException("No Instances!");
// }
// }
|
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import com.seatgeek.placesautocomplete.network.PlacesHttpClient;
import com.seatgeek.placesautocomplete.network.PlacesHttpClientResolver;
|
package com.seatgeek.placesautocomplete;
public class PlacesApiBuilder {
@Nullable
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClient.java
// public interface PlacesHttpClient {
// PlacesAutocompleteResponse executeAutocompleteRequest(Uri uri) throws IOException;
//
// PlacesDetailsResponse executeDetailsRequest(Uri uri) throws IOException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClientResolver.java
// public final class PlacesHttpClientResolver {
// public static final PlacesHttpClient PLACES_HTTP_CLIENT;
//
// static {
// boolean hasOkHttp;
//
// try {
// Class.forName("com.squareup.okhttp.OkHttpClient");
// hasOkHttp = true;
// } catch (ClassNotFoundException e) {
// hasOkHttp = false;
// }
//
// PlacesApiJsonParser parser = JsonParserResolver.JSON_PARSER;
//
// PLACES_HTTP_CLIENT = hasOkHttp ? new OkHttpPlacesHttpClient(parser) : new HttpUrlConnectionMapsHttpClient(parser);
// }
//
// private PlacesHttpClientResolver() {
// throw new RuntimeException("No Instances!");
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/PlacesApiBuilder.java
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import com.seatgeek.placesautocomplete.network.PlacesHttpClient;
import com.seatgeek.placesautocomplete.network.PlacesHttpClientResolver;
package com.seatgeek.placesautocomplete;
public class PlacesApiBuilder {
@Nullable
|
private PlacesHttpClient apiClient;
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/PlacesApiBuilder.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClient.java
// public interface PlacesHttpClient {
// PlacesAutocompleteResponse executeAutocompleteRequest(Uri uri) throws IOException;
//
// PlacesDetailsResponse executeDetailsRequest(Uri uri) throws IOException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClientResolver.java
// public final class PlacesHttpClientResolver {
// public static final PlacesHttpClient PLACES_HTTP_CLIENT;
//
// static {
// boolean hasOkHttp;
//
// try {
// Class.forName("com.squareup.okhttp.OkHttpClient");
// hasOkHttp = true;
// } catch (ClassNotFoundException e) {
// hasOkHttp = false;
// }
//
// PlacesApiJsonParser parser = JsonParserResolver.JSON_PARSER;
//
// PLACES_HTTP_CLIENT = hasOkHttp ? new OkHttpPlacesHttpClient(parser) : new HttpUrlConnectionMapsHttpClient(parser);
// }
//
// private PlacesHttpClientResolver() {
// throw new RuntimeException("No Instances!");
// }
// }
|
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import com.seatgeek.placesautocomplete.network.PlacesHttpClient;
import com.seatgeek.placesautocomplete.network.PlacesHttpClientResolver;
|
package com.seatgeek.placesautocomplete;
public class PlacesApiBuilder {
@Nullable
private PlacesHttpClient apiClient;
@Nullable
private String googleApiKey;
public PlacesApiBuilder setApiClient(@NonNull final PlacesHttpClient apiClient) {
this.apiClient = apiClient;
return this;
}
public PlacesApiBuilder setGoogleApiKey(@NonNull final String googleApiKey) {
if (TextUtils.isEmpty(googleApiKey)) {
throw new IllegalArgumentException("googleApiKey cannot be null or empty!");
}
this.googleApiKey = googleApiKey;
return this;
}
@NonNull
public PlacesApi build() {
if (apiClient == null) {
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClient.java
// public interface PlacesHttpClient {
// PlacesAutocompleteResponse executeAutocompleteRequest(Uri uri) throws IOException;
//
// PlacesDetailsResponse executeDetailsRequest(Uri uri) throws IOException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClientResolver.java
// public final class PlacesHttpClientResolver {
// public static final PlacesHttpClient PLACES_HTTP_CLIENT;
//
// static {
// boolean hasOkHttp;
//
// try {
// Class.forName("com.squareup.okhttp.OkHttpClient");
// hasOkHttp = true;
// } catch (ClassNotFoundException e) {
// hasOkHttp = false;
// }
//
// PlacesApiJsonParser parser = JsonParserResolver.JSON_PARSER;
//
// PLACES_HTTP_CLIENT = hasOkHttp ? new OkHttpPlacesHttpClient(parser) : new HttpUrlConnectionMapsHttpClient(parser);
// }
//
// private PlacesHttpClientResolver() {
// throw new RuntimeException("No Instances!");
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/PlacesApiBuilder.java
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import com.seatgeek.placesautocomplete.network.PlacesHttpClient;
import com.seatgeek.placesautocomplete.network.PlacesHttpClientResolver;
package com.seatgeek.placesautocomplete;
public class PlacesApiBuilder {
@Nullable
private PlacesHttpClient apiClient;
@Nullable
private String googleApiKey;
public PlacesApiBuilder setApiClient(@NonNull final PlacesHttpClient apiClient) {
this.apiClient = apiClient;
return this;
}
public PlacesApiBuilder setGoogleApiKey(@NonNull final String googleApiKey) {
if (TextUtils.isEmpty(googleApiKey)) {
throw new IllegalArgumentException("googleApiKey cannot be null or empty!");
}
this.googleApiKey = googleApiKey;
return this;
}
@NonNull
public PlacesApi build() {
if (apiClient == null) {
|
apiClient = PlacesHttpClientResolver.PLACES_HTTP_CLIENT;
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClientResolver.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/JsonParserResolver.java
// public final class JsonParserResolver {
// public static final PlacesApiJsonParser JSON_PARSER;
//
// static {
// boolean hasGson;
// try {
// Class.forName("com.google.gson.Gson");
// hasGson = true;
// } catch (ClassNotFoundException e) {
// hasGson = false;
// }
//
// JSON_PARSER = hasGson ? new GsonPlacesApiJsonParser() : new AndroidPlacesApiJsonParser();
// }
//
// private JsonParserResolver() {
// throw new RuntimeException("No instances");
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
|
import com.seatgeek.placesautocomplete.json.JsonParserResolver;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
|
package com.seatgeek.placesautocomplete.network;
public final class PlacesHttpClientResolver {
public static final PlacesHttpClient PLACES_HTTP_CLIENT;
static {
boolean hasOkHttp;
try {
Class.forName("com.squareup.okhttp.OkHttpClient");
hasOkHttp = true;
} catch (ClassNotFoundException e) {
hasOkHttp = false;
}
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/JsonParserResolver.java
// public final class JsonParserResolver {
// public static final PlacesApiJsonParser JSON_PARSER;
//
// static {
// boolean hasGson;
// try {
// Class.forName("com.google.gson.Gson");
// hasGson = true;
// } catch (ClassNotFoundException e) {
// hasGson = false;
// }
//
// JSON_PARSER = hasGson ? new GsonPlacesApiJsonParser() : new AndroidPlacesApiJsonParser();
// }
//
// private JsonParserResolver() {
// throw new RuntimeException("No instances");
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClientResolver.java
import com.seatgeek.placesautocomplete.json.JsonParserResolver;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
package com.seatgeek.placesautocomplete.network;
public final class PlacesHttpClientResolver {
public static final PlacesHttpClient PLACES_HTTP_CLIENT;
static {
boolean hasOkHttp;
try {
Class.forName("com.squareup.okhttp.OkHttpClient");
hasOkHttp = true;
} catch (ClassNotFoundException e) {
hasOkHttp = false;
}
|
PlacesApiJsonParser parser = JsonParserResolver.JSON_PARSER;
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClientResolver.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/JsonParserResolver.java
// public final class JsonParserResolver {
// public static final PlacesApiJsonParser JSON_PARSER;
//
// static {
// boolean hasGson;
// try {
// Class.forName("com.google.gson.Gson");
// hasGson = true;
// } catch (ClassNotFoundException e) {
// hasGson = false;
// }
//
// JSON_PARSER = hasGson ? new GsonPlacesApiJsonParser() : new AndroidPlacesApiJsonParser();
// }
//
// private JsonParserResolver() {
// throw new RuntimeException("No instances");
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
|
import com.seatgeek.placesautocomplete.json.JsonParserResolver;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
|
package com.seatgeek.placesautocomplete.network;
public final class PlacesHttpClientResolver {
public static final PlacesHttpClient PLACES_HTTP_CLIENT;
static {
boolean hasOkHttp;
try {
Class.forName("com.squareup.okhttp.OkHttpClient");
hasOkHttp = true;
} catch (ClassNotFoundException e) {
hasOkHttp = false;
}
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/JsonParserResolver.java
// public final class JsonParserResolver {
// public static final PlacesApiJsonParser JSON_PARSER;
//
// static {
// boolean hasGson;
// try {
// Class.forName("com.google.gson.Gson");
// hasGson = true;
// } catch (ClassNotFoundException e) {
// hasGson = false;
// }
//
// JSON_PARSER = hasGson ? new GsonPlacesApiJsonParser() : new AndroidPlacesApiJsonParser();
// }
//
// private JsonParserResolver() {
// throw new RuntimeException("No instances");
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClientResolver.java
import com.seatgeek.placesautocomplete.json.JsonParserResolver;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
package com.seatgeek.placesautocomplete.network;
public final class PlacesHttpClientResolver {
public static final PlacesHttpClient PLACES_HTTP_CLIENT;
static {
boolean hasOkHttp;
try {
Class.forName("com.squareup.okhttp.OkHttpClient");
hasOkHttp = true;
} catch (ClassNotFoundException e) {
hasOkHttp = false;
}
|
PlacesApiJsonParser parser = JsonParserResolver.JSON_PARSER;
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/PlacesApi.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/AutocompleteResultType.java
// public enum AutocompleteResultType {
// /**
// * Any location
// */
// GEOCODE("geocode"),
// /**
// * Any location represented by a full postal address
// */
// ADDRESS("address"),
// /**
// * Any location represented by a full postal address that is a business establishment
// */
//
// CITY("(cities)"),
//
// ESTABLISHMENT("establishment"),
// /**
// * Any location or establishment
// */
// NO_TYPE("no_type");
//
//
// private final String queryParam;
//
// AutocompleteResultType(final String queryParam) {
// this.queryParam = queryParam;
// }
//
// public String getQueryParam() {
// return queryParam;
// }
//
// public static AutocompleteResultType fromEnum(int enumerated) {
// return AutocompleteResultType.values()[enumerated];
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClient.java
// public interface PlacesHttpClient {
// PlacesAutocompleteResponse executeAutocompleteRequest(Uri uri) throws IOException;
//
// PlacesDetailsResponse executeDetailsRequest(Uri uri) throws IOException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/util/LocationUtils.java
// public final class LocationUtils {
//
// public static String toLatLngString(@NonNull Location location) {
// return location.getLatitude() + "," + location.getLongitude();
// }
//
// private LocationUtils() {
// }
// }
|
import android.location.Location;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.seatgeek.placesautocomplete.model.AutocompleteResultType;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import com.seatgeek.placesautocomplete.network.PlacesHttpClient;
import com.seatgeek.placesautocomplete.util.LocationUtils;
import java.io.IOException;
|
package com.seatgeek.placesautocomplete;
/**
* An Abstraction for the Google Maps Places API. Manages the building of requests to the API and
* executing them using the provided {@link PlacesHttpClient}
*/
public class PlacesApi {
public static final AutocompleteResultType DEFAULT_RESULT_TYPE = AutocompleteResultType.ADDRESS;
private static final String PLACES_API_BASE = "https://maps.googleapis.com/maps/api/place";
private static final String PATH_AUTOCOMPLETE = "autocomplete";
private static final String PATH_DETAILS = "details";
private static final String PATH_JSON = "json";
private static final String PARAMETER_LOCATION = "location";
private static final String PARAMETER_RADIUS = "radius";
private static final String PARAMETER_INPUT = "input";
private static final String PARAMETER_KEY = "key";
private static final String PARAMETER_COMPONENT = "components";
private static final String PARAMETER_TYPE = "types";
private static final String PARAMETER_PLACE_ID = "placeid";
private static final String PARAMETER_LANGUAGE = "language";
private static final Long NO_BIAS_RADIUS = 20000000L;
private static final Location NO_BIAS_LOCATION;
static {
NO_BIAS_LOCATION = new Location("none");
NO_BIAS_LOCATION.setLatitude(0.0d);
NO_BIAS_LOCATION.setLongitude(0.0d);
}
@NonNull
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/AutocompleteResultType.java
// public enum AutocompleteResultType {
// /**
// * Any location
// */
// GEOCODE("geocode"),
// /**
// * Any location represented by a full postal address
// */
// ADDRESS("address"),
// /**
// * Any location represented by a full postal address that is a business establishment
// */
//
// CITY("(cities)"),
//
// ESTABLISHMENT("establishment"),
// /**
// * Any location or establishment
// */
// NO_TYPE("no_type");
//
//
// private final String queryParam;
//
// AutocompleteResultType(final String queryParam) {
// this.queryParam = queryParam;
// }
//
// public String getQueryParam() {
// return queryParam;
// }
//
// public static AutocompleteResultType fromEnum(int enumerated) {
// return AutocompleteResultType.values()[enumerated];
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClient.java
// public interface PlacesHttpClient {
// PlacesAutocompleteResponse executeAutocompleteRequest(Uri uri) throws IOException;
//
// PlacesDetailsResponse executeDetailsRequest(Uri uri) throws IOException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/util/LocationUtils.java
// public final class LocationUtils {
//
// public static String toLatLngString(@NonNull Location location) {
// return location.getLatitude() + "," + location.getLongitude();
// }
//
// private LocationUtils() {
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/PlacesApi.java
import android.location.Location;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.seatgeek.placesautocomplete.model.AutocompleteResultType;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import com.seatgeek.placesautocomplete.network.PlacesHttpClient;
import com.seatgeek.placesautocomplete.util.LocationUtils;
import java.io.IOException;
package com.seatgeek.placesautocomplete;
/**
* An Abstraction for the Google Maps Places API. Manages the building of requests to the API and
* executing them using the provided {@link PlacesHttpClient}
*/
public class PlacesApi {
public static final AutocompleteResultType DEFAULT_RESULT_TYPE = AutocompleteResultType.ADDRESS;
private static final String PLACES_API_BASE = "https://maps.googleapis.com/maps/api/place";
private static final String PATH_AUTOCOMPLETE = "autocomplete";
private static final String PATH_DETAILS = "details";
private static final String PATH_JSON = "json";
private static final String PARAMETER_LOCATION = "location";
private static final String PARAMETER_RADIUS = "radius";
private static final String PARAMETER_INPUT = "input";
private static final String PARAMETER_KEY = "key";
private static final String PARAMETER_COMPONENT = "components";
private static final String PARAMETER_TYPE = "types";
private static final String PARAMETER_PLACE_ID = "placeid";
private static final String PARAMETER_LANGUAGE = "language";
private static final Long NO_BIAS_RADIUS = 20000000L;
private static final Location NO_BIAS_LOCATION;
static {
NO_BIAS_LOCATION = new Location("none");
NO_BIAS_LOCATION.setLatitude(0.0d);
NO_BIAS_LOCATION.setLongitude(0.0d);
}
@NonNull
|
private final PlacesHttpClient httpClient;
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/PlacesApi.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/AutocompleteResultType.java
// public enum AutocompleteResultType {
// /**
// * Any location
// */
// GEOCODE("geocode"),
// /**
// * Any location represented by a full postal address
// */
// ADDRESS("address"),
// /**
// * Any location represented by a full postal address that is a business establishment
// */
//
// CITY("(cities)"),
//
// ESTABLISHMENT("establishment"),
// /**
// * Any location or establishment
// */
// NO_TYPE("no_type");
//
//
// private final String queryParam;
//
// AutocompleteResultType(final String queryParam) {
// this.queryParam = queryParam;
// }
//
// public String getQueryParam() {
// return queryParam;
// }
//
// public static AutocompleteResultType fromEnum(int enumerated) {
// return AutocompleteResultType.values()[enumerated];
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClient.java
// public interface PlacesHttpClient {
// PlacesAutocompleteResponse executeAutocompleteRequest(Uri uri) throws IOException;
//
// PlacesDetailsResponse executeDetailsRequest(Uri uri) throws IOException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/util/LocationUtils.java
// public final class LocationUtils {
//
// public static String toLatLngString(@NonNull Location location) {
// return location.getLatitude() + "," + location.getLongitude();
// }
//
// private LocationUtils() {
// }
// }
|
import android.location.Location;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.seatgeek.placesautocomplete.model.AutocompleteResultType;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import com.seatgeek.placesautocomplete.network.PlacesHttpClient;
import com.seatgeek.placesautocomplete.util.LocationUtils;
import java.io.IOException;
|
return languageCode;
}
/**
* Sets the languageCode code used for autocomplete and place details calls.
* List of supportable codes can be seen in <a href="https://developers.google.com/maps/faq#languagesupport">documentation</a>
*
* @param language the languageCode code
*/
public void setLanguageCode(@Nullable String language) {
this.languageCode = language;
}
/**
* Sets the countryCode code used for autocomplete and place details calls.
* List of supportable codes can be seen in <a href="https://developers.google.com/maps/faq#languagesupport">documentation</a>
*
* @param countryCode the countryCode code
*/
public void setCountryCode(@Nullable String countryCode) {
this.countryCode = countryCode;
}
/**
* Performs autocompletion for the given input text and the type of response desired. This is a
* synchronous call, you must provide your own Async if you need it
* @param input the textual input that will be autocompleted
* @param type the response type from the api
* @throws IOException
*/
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/AutocompleteResultType.java
// public enum AutocompleteResultType {
// /**
// * Any location
// */
// GEOCODE("geocode"),
// /**
// * Any location represented by a full postal address
// */
// ADDRESS("address"),
// /**
// * Any location represented by a full postal address that is a business establishment
// */
//
// CITY("(cities)"),
//
// ESTABLISHMENT("establishment"),
// /**
// * Any location or establishment
// */
// NO_TYPE("no_type");
//
//
// private final String queryParam;
//
// AutocompleteResultType(final String queryParam) {
// this.queryParam = queryParam;
// }
//
// public String getQueryParam() {
// return queryParam;
// }
//
// public static AutocompleteResultType fromEnum(int enumerated) {
// return AutocompleteResultType.values()[enumerated];
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClient.java
// public interface PlacesHttpClient {
// PlacesAutocompleteResponse executeAutocompleteRequest(Uri uri) throws IOException;
//
// PlacesDetailsResponse executeDetailsRequest(Uri uri) throws IOException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/util/LocationUtils.java
// public final class LocationUtils {
//
// public static String toLatLngString(@NonNull Location location) {
// return location.getLatitude() + "," + location.getLongitude();
// }
//
// private LocationUtils() {
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/PlacesApi.java
import android.location.Location;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.seatgeek.placesautocomplete.model.AutocompleteResultType;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import com.seatgeek.placesautocomplete.network.PlacesHttpClient;
import com.seatgeek.placesautocomplete.util.LocationUtils;
import java.io.IOException;
return languageCode;
}
/**
* Sets the languageCode code used for autocomplete and place details calls.
* List of supportable codes can be seen in <a href="https://developers.google.com/maps/faq#languagesupport">documentation</a>
*
* @param language the languageCode code
*/
public void setLanguageCode(@Nullable String language) {
this.languageCode = language;
}
/**
* Sets the countryCode code used for autocomplete and place details calls.
* List of supportable codes can be seen in <a href="https://developers.google.com/maps/faq#languagesupport">documentation</a>
*
* @param countryCode the countryCode code
*/
public void setCountryCode(@Nullable String countryCode) {
this.countryCode = countryCode;
}
/**
* Performs autocompletion for the given input text and the type of response desired. This is a
* synchronous call, you must provide your own Async if you need it
* @param input the textual input that will be autocompleted
* @param type the response type from the api
* @throws IOException
*/
|
public PlacesAutocompleteResponse autocomplete(final String input, final AutocompleteResultType type) throws IOException {
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/PlacesApi.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/AutocompleteResultType.java
// public enum AutocompleteResultType {
// /**
// * Any location
// */
// GEOCODE("geocode"),
// /**
// * Any location represented by a full postal address
// */
// ADDRESS("address"),
// /**
// * Any location represented by a full postal address that is a business establishment
// */
//
// CITY("(cities)"),
//
// ESTABLISHMENT("establishment"),
// /**
// * Any location or establishment
// */
// NO_TYPE("no_type");
//
//
// private final String queryParam;
//
// AutocompleteResultType(final String queryParam) {
// this.queryParam = queryParam;
// }
//
// public String getQueryParam() {
// return queryParam;
// }
//
// public static AutocompleteResultType fromEnum(int enumerated) {
// return AutocompleteResultType.values()[enumerated];
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClient.java
// public interface PlacesHttpClient {
// PlacesAutocompleteResponse executeAutocompleteRequest(Uri uri) throws IOException;
//
// PlacesDetailsResponse executeDetailsRequest(Uri uri) throws IOException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/util/LocationUtils.java
// public final class LocationUtils {
//
// public static String toLatLngString(@NonNull Location location) {
// return location.getLatitude() + "," + location.getLongitude();
// }
//
// private LocationUtils() {
// }
// }
|
import android.location.Location;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.seatgeek.placesautocomplete.model.AutocompleteResultType;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import com.seatgeek.placesautocomplete.network.PlacesHttpClient;
import com.seatgeek.placesautocomplete.util.LocationUtils;
import java.io.IOException;
|
* @param countryCode the countryCode code
*/
public void setCountryCode(@Nullable String countryCode) {
this.countryCode = countryCode;
}
/**
* Performs autocompletion for the given input text and the type of response desired. This is a
* synchronous call, you must provide your own Async if you need it
* @param input the textual input that will be autocompleted
* @param type the response type from the api
* @throws IOException
*/
public PlacesAutocompleteResponse autocomplete(final String input, final AutocompleteResultType type) throws IOException {
final String finalInput = input == null ? "" : input;
final AutocompleteResultType finalType = type == null ? DEFAULT_RESULT_TYPE : type;
Uri.Builder uriBuilder = Uri.parse(PLACES_API_BASE)
.buildUpon()
.appendPath(PATH_AUTOCOMPLETE)
.appendPath(PATH_JSON)
.appendQueryParameter(PARAMETER_KEY, googleApiKey)
.appendQueryParameter(PARAMETER_INPUT, finalInput);
if (finalType != AutocompleteResultType.NO_TYPE) {
uriBuilder.appendQueryParameter(PARAMETER_TYPE, finalType.getQueryParam());
}
if (locationBiasEnabled && currentLocation != null) {
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/AutocompleteResultType.java
// public enum AutocompleteResultType {
// /**
// * Any location
// */
// GEOCODE("geocode"),
// /**
// * Any location represented by a full postal address
// */
// ADDRESS("address"),
// /**
// * Any location represented by a full postal address that is a business establishment
// */
//
// CITY("(cities)"),
//
// ESTABLISHMENT("establishment"),
// /**
// * Any location or establishment
// */
// NO_TYPE("no_type");
//
//
// private final String queryParam;
//
// AutocompleteResultType(final String queryParam) {
// this.queryParam = queryParam;
// }
//
// public String getQueryParam() {
// return queryParam;
// }
//
// public static AutocompleteResultType fromEnum(int enumerated) {
// return AutocompleteResultType.values()[enumerated];
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClient.java
// public interface PlacesHttpClient {
// PlacesAutocompleteResponse executeAutocompleteRequest(Uri uri) throws IOException;
//
// PlacesDetailsResponse executeDetailsRequest(Uri uri) throws IOException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/util/LocationUtils.java
// public final class LocationUtils {
//
// public static String toLatLngString(@NonNull Location location) {
// return location.getLatitude() + "," + location.getLongitude();
// }
//
// private LocationUtils() {
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/PlacesApi.java
import android.location.Location;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.seatgeek.placesautocomplete.model.AutocompleteResultType;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import com.seatgeek.placesautocomplete.network.PlacesHttpClient;
import com.seatgeek.placesautocomplete.util.LocationUtils;
import java.io.IOException;
* @param countryCode the countryCode code
*/
public void setCountryCode(@Nullable String countryCode) {
this.countryCode = countryCode;
}
/**
* Performs autocompletion for the given input text and the type of response desired. This is a
* synchronous call, you must provide your own Async if you need it
* @param input the textual input that will be autocompleted
* @param type the response type from the api
* @throws IOException
*/
public PlacesAutocompleteResponse autocomplete(final String input, final AutocompleteResultType type) throws IOException {
final String finalInput = input == null ? "" : input;
final AutocompleteResultType finalType = type == null ? DEFAULT_RESULT_TYPE : type;
Uri.Builder uriBuilder = Uri.parse(PLACES_API_BASE)
.buildUpon()
.appendPath(PATH_AUTOCOMPLETE)
.appendPath(PATH_JSON)
.appendQueryParameter(PARAMETER_KEY, googleApiKey)
.appendQueryParameter(PARAMETER_INPUT, finalInput);
if (finalType != AutocompleteResultType.NO_TYPE) {
uriBuilder.appendQueryParameter(PARAMETER_TYPE, finalType.getQueryParam());
}
if (locationBiasEnabled && currentLocation != null) {
|
uriBuilder.appendQueryParameter(PARAMETER_LOCATION, LocationUtils.toLatLngString(currentLocation));
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/PlacesApi.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/AutocompleteResultType.java
// public enum AutocompleteResultType {
// /**
// * Any location
// */
// GEOCODE("geocode"),
// /**
// * Any location represented by a full postal address
// */
// ADDRESS("address"),
// /**
// * Any location represented by a full postal address that is a business establishment
// */
//
// CITY("(cities)"),
//
// ESTABLISHMENT("establishment"),
// /**
// * Any location or establishment
// */
// NO_TYPE("no_type");
//
//
// private final String queryParam;
//
// AutocompleteResultType(final String queryParam) {
// this.queryParam = queryParam;
// }
//
// public String getQueryParam() {
// return queryParam;
// }
//
// public static AutocompleteResultType fromEnum(int enumerated) {
// return AutocompleteResultType.values()[enumerated];
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClient.java
// public interface PlacesHttpClient {
// PlacesAutocompleteResponse executeAutocompleteRequest(Uri uri) throws IOException;
//
// PlacesDetailsResponse executeDetailsRequest(Uri uri) throws IOException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/util/LocationUtils.java
// public final class LocationUtils {
//
// public static String toLatLngString(@NonNull Location location) {
// return location.getLatitude() + "," + location.getLongitude();
// }
//
// private LocationUtils() {
// }
// }
|
import android.location.Location;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.seatgeek.placesautocomplete.model.AutocompleteResultType;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import com.seatgeek.placesautocomplete.network.PlacesHttpClient;
import com.seatgeek.placesautocomplete.util.LocationUtils;
import java.io.IOException;
|
uriBuilder.appendQueryParameter(PARAMETER_LOCATION, LocationUtils.toLatLngString(currentLocation));
}
if (locationBiasEnabled && radiusM != null) {
uriBuilder.appendQueryParameter(PARAMETER_RADIUS, radiusM.toString());
}
if (!locationBiasEnabled) {
uriBuilder.appendQueryParameter(PARAMETER_LOCATION, LocationUtils.toLatLngString(NO_BIAS_LOCATION));
uriBuilder.appendQueryParameter(PARAMETER_RADIUS, NO_BIAS_RADIUS.toString());
}
if (languageCode != null) {
uriBuilder.appendQueryParameter(PARAMETER_LANGUAGE, languageCode);
}
if (countryCode != null) {
uriBuilder.appendQueryParameter(PARAMETER_COMPONENT, "country:"+countryCode.toUpperCase());
}
return httpClient.executeAutocompleteRequest(uriBuilder.build());
}
/**
* Fetches the PlaceDetails for the given place_id. This is a
* synchronous call, you must provide your own Async if you need it
* @param placeId the Google Maps Places API Place ID for the place you desire details of
* @return the details for the place id
* @throws IOException
*/
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/AutocompleteResultType.java
// public enum AutocompleteResultType {
// /**
// * Any location
// */
// GEOCODE("geocode"),
// /**
// * Any location represented by a full postal address
// */
// ADDRESS("address"),
// /**
// * Any location represented by a full postal address that is a business establishment
// */
//
// CITY("(cities)"),
//
// ESTABLISHMENT("establishment"),
// /**
// * Any location or establishment
// */
// NO_TYPE("no_type");
//
//
// private final String queryParam;
//
// AutocompleteResultType(final String queryParam) {
// this.queryParam = queryParam;
// }
//
// public String getQueryParam() {
// return queryParam;
// }
//
// public static AutocompleteResultType fromEnum(int enumerated) {
// return AutocompleteResultType.values()[enumerated];
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClient.java
// public interface PlacesHttpClient {
// PlacesAutocompleteResponse executeAutocompleteRequest(Uri uri) throws IOException;
//
// PlacesDetailsResponse executeDetailsRequest(Uri uri) throws IOException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/util/LocationUtils.java
// public final class LocationUtils {
//
// public static String toLatLngString(@NonNull Location location) {
// return location.getLatitude() + "," + location.getLongitude();
// }
//
// private LocationUtils() {
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/PlacesApi.java
import android.location.Location;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.seatgeek.placesautocomplete.model.AutocompleteResultType;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import com.seatgeek.placesautocomplete.network.PlacesHttpClient;
import com.seatgeek.placesautocomplete.util.LocationUtils;
import java.io.IOException;
uriBuilder.appendQueryParameter(PARAMETER_LOCATION, LocationUtils.toLatLngString(currentLocation));
}
if (locationBiasEnabled && radiusM != null) {
uriBuilder.appendQueryParameter(PARAMETER_RADIUS, radiusM.toString());
}
if (!locationBiasEnabled) {
uriBuilder.appendQueryParameter(PARAMETER_LOCATION, LocationUtils.toLatLngString(NO_BIAS_LOCATION));
uriBuilder.appendQueryParameter(PARAMETER_RADIUS, NO_BIAS_RADIUS.toString());
}
if (languageCode != null) {
uriBuilder.appendQueryParameter(PARAMETER_LANGUAGE, languageCode);
}
if (countryCode != null) {
uriBuilder.appendQueryParameter(PARAMETER_COMPONENT, "country:"+countryCode.toUpperCase());
}
return httpClient.executeAutocompleteRequest(uriBuilder.build());
}
/**
* Fetches the PlaceDetails for the given place_id. This is a
* synchronous call, you must provide your own Async if you need it
* @param placeId the Google Maps Places API Place ID for the place you desire details of
* @return the details for the place id
* @throws IOException
*/
|
public PlacesDetailsResponse details(final String placeId) throws IOException {
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/async/BackgroundExecutorService.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/Constants.java
// public class Constants {
// public static final String LOG_TAG = "MapsPlacesAutoComplete";
// public static final String MAGIC_HISTORY_VALUE_PRE = "____history____=";
// }
|
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import com.seatgeek.placesautocomplete.Constants;
import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
|
package com.seatgeek.placesautocomplete.async;
public enum BackgroundExecutorService {
INSTANCE;
/*
* Max single thread ExecutorService that will spin down thread after use
*/
private final Executor executor;
{
ThreadPoolExecutor executor = new ThreadPoolExecutor(1, 1,
5L, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(),
new ThreadFactory() {
@Override
public Thread newThread(@NonNull final Runnable r) {
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/Constants.java
// public class Constants {
// public static final String LOG_TAG = "MapsPlacesAutoComplete";
// public static final String MAGIC_HISTORY_VALUE_PRE = "____history____=";
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/async/BackgroundExecutorService.java
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import com.seatgeek.placesautocomplete.Constants;
import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
package com.seatgeek.placesautocomplete.async;
public enum BackgroundExecutorService {
INSTANCE;
/*
* Max single thread ExecutorService that will spin down thread after use
*/
private final Executor executor;
{
ThreadPoolExecutor executor = new ThreadPoolExecutor(1, 1,
5L, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(),
new ThreadFactory() {
@Override
public Thread newThread(@NonNull final Runnable r) {
|
return new Thread(r, Constants.LOG_TAG + "Thread");
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/GsonPlacesApiJsonParser.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Place.java
// public final class Place {
//
// /**
// * Human readable description of the place returned from the api. e.g. "235 Park Ave South, New York, NY, USA"
// */
// public final String description;
//
// /**
// * A unique place id used in the maps apu. this can be used to query for further information about
// * the location from the places api. See https://developers.google.com/places/documentation/place-id
// * for more information about place_id
// */
// public final String place_id;
//
// /**
// * The lengths and offsets of the substrings the query matched in the description
// */
// public final List<MatchedSubstring> matched_substrings;
//
// /**
// * The strings and offsets of the components that make up the description.
// */
// public final List<DescriptionTerm> terms;
//
// /**
// * The types of place that this corresponds to in the places api. See individual PlaceType's for
// * thier descriptions
// */
// public final List<PlaceType> types;
//
// public Place(final String description, final String place_id, final List<MatchedSubstring> matched_substrings, final List<DescriptionTerm> terms, final List<PlaceType> types) {
// this.description = description;
// this.place_id = place_id;
// this.matched_substrings = matched_substrings;
// this.terms = terms;
// this.types = types;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof Place)) return false;
//
// Place place = (Place) o;
//
// if (description != null ? !description.equals(place.description) : place.description != null) return false;
// if (matched_substrings != null ? !matched_substrings.equals(place.matched_substrings) : place.matched_substrings != null)
// return false;
// if (place_id != null ? !place_id.equals(place.place_id) : place.place_id != null) return false;
// if (terms != null ? !terms.equals(place.terms) : place.terms != null) return false;
// if (types != null ? !types.equals(place.types) : place.types != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = description != null ? description.hashCode() : 0;
// result = 31 * result + (place_id != null ? place_id.hashCode() : 0);
// result = 31 * result + (matched_substrings != null ? matched_substrings.hashCode() : 0);
// result = 31 * result + (terms != null ? terms.hashCode() : 0);
// result = 31 * result + (types != null ? types.hashCode() : 0);
// return result;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
|
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.seatgeek.placesautocomplete.model.Place;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
|
package com.seatgeek.placesautocomplete.json;
class GsonPlacesApiJsonParser implements PlacesApiJsonParser {
private final Gson gson;
public GsonPlacesApiJsonParser() {
gson = new GsonBuilder()
.create();
}
@Override
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Place.java
// public final class Place {
//
// /**
// * Human readable description of the place returned from the api. e.g. "235 Park Ave South, New York, NY, USA"
// */
// public final String description;
//
// /**
// * A unique place id used in the maps apu. this can be used to query for further information about
// * the location from the places api. See https://developers.google.com/places/documentation/place-id
// * for more information about place_id
// */
// public final String place_id;
//
// /**
// * The lengths and offsets of the substrings the query matched in the description
// */
// public final List<MatchedSubstring> matched_substrings;
//
// /**
// * The strings and offsets of the components that make up the description.
// */
// public final List<DescriptionTerm> terms;
//
// /**
// * The types of place that this corresponds to in the places api. See individual PlaceType's for
// * thier descriptions
// */
// public final List<PlaceType> types;
//
// public Place(final String description, final String place_id, final List<MatchedSubstring> matched_substrings, final List<DescriptionTerm> terms, final List<PlaceType> types) {
// this.description = description;
// this.place_id = place_id;
// this.matched_substrings = matched_substrings;
// this.terms = terms;
// this.types = types;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof Place)) return false;
//
// Place place = (Place) o;
//
// if (description != null ? !description.equals(place.description) : place.description != null) return false;
// if (matched_substrings != null ? !matched_substrings.equals(place.matched_substrings) : place.matched_substrings != null)
// return false;
// if (place_id != null ? !place_id.equals(place.place_id) : place.place_id != null) return false;
// if (terms != null ? !terms.equals(place.terms) : place.terms != null) return false;
// if (types != null ? !types.equals(place.types) : place.types != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = description != null ? description.hashCode() : 0;
// result = 31 * result + (place_id != null ? place_id.hashCode() : 0);
// result = 31 * result + (matched_substrings != null ? matched_substrings.hashCode() : 0);
// result = 31 * result + (terms != null ? terms.hashCode() : 0);
// result = 31 * result + (types != null ? types.hashCode() : 0);
// return result;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/GsonPlacesApiJsonParser.java
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.seatgeek.placesautocomplete.model.Place;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
package com.seatgeek.placesautocomplete.json;
class GsonPlacesApiJsonParser implements PlacesApiJsonParser {
private final Gson gson;
public GsonPlacesApiJsonParser() {
gson = new GsonBuilder()
.create();
}
@Override
|
public PlacesAutocompleteResponse autocompleteFromStream(final InputStream is) throws JsonParsingException {
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/GsonPlacesApiJsonParser.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Place.java
// public final class Place {
//
// /**
// * Human readable description of the place returned from the api. e.g. "235 Park Ave South, New York, NY, USA"
// */
// public final String description;
//
// /**
// * A unique place id used in the maps apu. this can be used to query for further information about
// * the location from the places api. See https://developers.google.com/places/documentation/place-id
// * for more information about place_id
// */
// public final String place_id;
//
// /**
// * The lengths and offsets of the substrings the query matched in the description
// */
// public final List<MatchedSubstring> matched_substrings;
//
// /**
// * The strings and offsets of the components that make up the description.
// */
// public final List<DescriptionTerm> terms;
//
// /**
// * The types of place that this corresponds to in the places api. See individual PlaceType's for
// * thier descriptions
// */
// public final List<PlaceType> types;
//
// public Place(final String description, final String place_id, final List<MatchedSubstring> matched_substrings, final List<DescriptionTerm> terms, final List<PlaceType> types) {
// this.description = description;
// this.place_id = place_id;
// this.matched_substrings = matched_substrings;
// this.terms = terms;
// this.types = types;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof Place)) return false;
//
// Place place = (Place) o;
//
// if (description != null ? !description.equals(place.description) : place.description != null) return false;
// if (matched_substrings != null ? !matched_substrings.equals(place.matched_substrings) : place.matched_substrings != null)
// return false;
// if (place_id != null ? !place_id.equals(place.place_id) : place.place_id != null) return false;
// if (terms != null ? !terms.equals(place.terms) : place.terms != null) return false;
// if (types != null ? !types.equals(place.types) : place.types != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = description != null ? description.hashCode() : 0;
// result = 31 * result + (place_id != null ? place_id.hashCode() : 0);
// result = 31 * result + (matched_substrings != null ? matched_substrings.hashCode() : 0);
// result = 31 * result + (terms != null ? terms.hashCode() : 0);
// result = 31 * result + (types != null ? types.hashCode() : 0);
// return result;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
|
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.seatgeek.placesautocomplete.model.Place;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
|
package com.seatgeek.placesautocomplete.json;
class GsonPlacesApiJsonParser implements PlacesApiJsonParser {
private final Gson gson;
public GsonPlacesApiJsonParser() {
gson = new GsonBuilder()
.create();
}
@Override
public PlacesAutocompleteResponse autocompleteFromStream(final InputStream is) throws JsonParsingException {
try {
final BufferedReader reader = new BufferedReader(new InputStreamReader(is));
return gson.fromJson(reader, PlacesAutocompleteResponse.class);
} catch (Exception e) {
throw new JsonParsingException(e);
}
}
@Override
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Place.java
// public final class Place {
//
// /**
// * Human readable description of the place returned from the api. e.g. "235 Park Ave South, New York, NY, USA"
// */
// public final String description;
//
// /**
// * A unique place id used in the maps apu. this can be used to query for further information about
// * the location from the places api. See https://developers.google.com/places/documentation/place-id
// * for more information about place_id
// */
// public final String place_id;
//
// /**
// * The lengths and offsets of the substrings the query matched in the description
// */
// public final List<MatchedSubstring> matched_substrings;
//
// /**
// * The strings and offsets of the components that make up the description.
// */
// public final List<DescriptionTerm> terms;
//
// /**
// * The types of place that this corresponds to in the places api. See individual PlaceType's for
// * thier descriptions
// */
// public final List<PlaceType> types;
//
// public Place(final String description, final String place_id, final List<MatchedSubstring> matched_substrings, final List<DescriptionTerm> terms, final List<PlaceType> types) {
// this.description = description;
// this.place_id = place_id;
// this.matched_substrings = matched_substrings;
// this.terms = terms;
// this.types = types;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof Place)) return false;
//
// Place place = (Place) o;
//
// if (description != null ? !description.equals(place.description) : place.description != null) return false;
// if (matched_substrings != null ? !matched_substrings.equals(place.matched_substrings) : place.matched_substrings != null)
// return false;
// if (place_id != null ? !place_id.equals(place.place_id) : place.place_id != null) return false;
// if (terms != null ? !terms.equals(place.terms) : place.terms != null) return false;
// if (types != null ? !types.equals(place.types) : place.types != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = description != null ? description.hashCode() : 0;
// result = 31 * result + (place_id != null ? place_id.hashCode() : 0);
// result = 31 * result + (matched_substrings != null ? matched_substrings.hashCode() : 0);
// result = 31 * result + (terms != null ? terms.hashCode() : 0);
// result = 31 * result + (types != null ? types.hashCode() : 0);
// return result;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/GsonPlacesApiJsonParser.java
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.seatgeek.placesautocomplete.model.Place;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
package com.seatgeek.placesautocomplete.json;
class GsonPlacesApiJsonParser implements PlacesApiJsonParser {
private final Gson gson;
public GsonPlacesApiJsonParser() {
gson = new GsonBuilder()
.create();
}
@Override
public PlacesAutocompleteResponse autocompleteFromStream(final InputStream is) throws JsonParsingException {
try {
final BufferedReader reader = new BufferedReader(new InputStreamReader(is));
return gson.fromJson(reader, PlacesAutocompleteResponse.class);
} catch (Exception e) {
throw new JsonParsingException(e);
}
}
@Override
|
public PlacesDetailsResponse detailsFromStream(final InputStream is) throws JsonParsingException {
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/GsonPlacesApiJsonParser.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Place.java
// public final class Place {
//
// /**
// * Human readable description of the place returned from the api. e.g. "235 Park Ave South, New York, NY, USA"
// */
// public final String description;
//
// /**
// * A unique place id used in the maps apu. this can be used to query for further information about
// * the location from the places api. See https://developers.google.com/places/documentation/place-id
// * for more information about place_id
// */
// public final String place_id;
//
// /**
// * The lengths and offsets of the substrings the query matched in the description
// */
// public final List<MatchedSubstring> matched_substrings;
//
// /**
// * The strings and offsets of the components that make up the description.
// */
// public final List<DescriptionTerm> terms;
//
// /**
// * The types of place that this corresponds to in the places api. See individual PlaceType's for
// * thier descriptions
// */
// public final List<PlaceType> types;
//
// public Place(final String description, final String place_id, final List<MatchedSubstring> matched_substrings, final List<DescriptionTerm> terms, final List<PlaceType> types) {
// this.description = description;
// this.place_id = place_id;
// this.matched_substrings = matched_substrings;
// this.terms = terms;
// this.types = types;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof Place)) return false;
//
// Place place = (Place) o;
//
// if (description != null ? !description.equals(place.description) : place.description != null) return false;
// if (matched_substrings != null ? !matched_substrings.equals(place.matched_substrings) : place.matched_substrings != null)
// return false;
// if (place_id != null ? !place_id.equals(place.place_id) : place.place_id != null) return false;
// if (terms != null ? !terms.equals(place.terms) : place.terms != null) return false;
// if (types != null ? !types.equals(place.types) : place.types != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = description != null ? description.hashCode() : 0;
// result = 31 * result + (place_id != null ? place_id.hashCode() : 0);
// result = 31 * result + (matched_substrings != null ? matched_substrings.hashCode() : 0);
// result = 31 * result + (terms != null ? terms.hashCode() : 0);
// result = 31 * result + (types != null ? types.hashCode() : 0);
// return result;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
|
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.seatgeek.placesautocomplete.model.Place;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
|
package com.seatgeek.placesautocomplete.json;
class GsonPlacesApiJsonParser implements PlacesApiJsonParser {
private final Gson gson;
public GsonPlacesApiJsonParser() {
gson = new GsonBuilder()
.create();
}
@Override
public PlacesAutocompleteResponse autocompleteFromStream(final InputStream is) throws JsonParsingException {
try {
final BufferedReader reader = new BufferedReader(new InputStreamReader(is));
return gson.fromJson(reader, PlacesAutocompleteResponse.class);
} catch (Exception e) {
throw new JsonParsingException(e);
}
}
@Override
public PlacesDetailsResponse detailsFromStream(final InputStream is) throws JsonParsingException {
try {
final BufferedReader reader = new BufferedReader(new InputStreamReader(is));
return gson.fromJson(reader, PlacesDetailsResponse.class);
} catch (Exception e) {
throw new JsonParsingException(e);
}
}
@Override
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Place.java
// public final class Place {
//
// /**
// * Human readable description of the place returned from the api. e.g. "235 Park Ave South, New York, NY, USA"
// */
// public final String description;
//
// /**
// * A unique place id used in the maps apu. this can be used to query for further information about
// * the location from the places api. See https://developers.google.com/places/documentation/place-id
// * for more information about place_id
// */
// public final String place_id;
//
// /**
// * The lengths and offsets of the substrings the query matched in the description
// */
// public final List<MatchedSubstring> matched_substrings;
//
// /**
// * The strings and offsets of the components that make up the description.
// */
// public final List<DescriptionTerm> terms;
//
// /**
// * The types of place that this corresponds to in the places api. See individual PlaceType's for
// * thier descriptions
// */
// public final List<PlaceType> types;
//
// public Place(final String description, final String place_id, final List<MatchedSubstring> matched_substrings, final List<DescriptionTerm> terms, final List<PlaceType> types) {
// this.description = description;
// this.place_id = place_id;
// this.matched_substrings = matched_substrings;
// this.terms = terms;
// this.types = types;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof Place)) return false;
//
// Place place = (Place) o;
//
// if (description != null ? !description.equals(place.description) : place.description != null) return false;
// if (matched_substrings != null ? !matched_substrings.equals(place.matched_substrings) : place.matched_substrings != null)
// return false;
// if (place_id != null ? !place_id.equals(place.place_id) : place.place_id != null) return false;
// if (terms != null ? !terms.equals(place.terms) : place.terms != null) return false;
// if (types != null ? !types.equals(place.types) : place.types != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = description != null ? description.hashCode() : 0;
// result = 31 * result + (place_id != null ? place_id.hashCode() : 0);
// result = 31 * result + (matched_substrings != null ? matched_substrings.hashCode() : 0);
// result = 31 * result + (terms != null ? terms.hashCode() : 0);
// result = 31 * result + (types != null ? types.hashCode() : 0);
// return result;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/GsonPlacesApiJsonParser.java
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.seatgeek.placesautocomplete.model.Place;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
package com.seatgeek.placesautocomplete.json;
class GsonPlacesApiJsonParser implements PlacesApiJsonParser {
private final Gson gson;
public GsonPlacesApiJsonParser() {
gson = new GsonBuilder()
.create();
}
@Override
public PlacesAutocompleteResponse autocompleteFromStream(final InputStream is) throws JsonParsingException {
try {
final BufferedReader reader = new BufferedReader(new InputStreamReader(is));
return gson.fromJson(reader, PlacesAutocompleteResponse.class);
} catch (Exception e) {
throw new JsonParsingException(e);
}
}
@Override
public PlacesDetailsResponse detailsFromStream(final InputStream is) throws JsonParsingException {
try {
final BufferedReader reader = new BufferedReader(new InputStreamReader(is));
return gson.fromJson(reader, PlacesDetailsResponse.class);
} catch (Exception e) {
throw new JsonParsingException(e);
}
}
@Override
|
public List<Place> readHistoryJson(final InputStream in) throws JsonParsingException {
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/HttpUrlConnectionMapsHttpClient.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiException.java
// public class PlacesApiException extends IOException {
//
// public PlacesApiException() {
// }
//
// public PlacesApiException(final String detailMessage) {
// super(detailMessage);
// }
//
// public PlacesApiException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public PlacesApiException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Status.java
// public enum Status {
// @SerializedName("OK")
// OK(true),
// @SerializedName("ZERO_RESULTS")
// ZERO_RESULTS(true),
// @SerializedName("OVER_QUERY_LIMIT")
// OVER_QUERY_LIMIT(false),
// @SerializedName("REQUEST_DENIED")
// REQUEST_DENIED(false),
// @SerializedName("INVALID_REQUEST")
// INVALID_REQUEST(false);
//
// private final boolean successful;
//
// Status(final boolean successfulResponse) {
// successful = successfulResponse;
// }
//
// public boolean isSuccessful() {
// return successful;
// }
// }
|
import android.net.Uri;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiException;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.Status;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
|
package com.seatgeek.placesautocomplete.network;
class HttpUrlConnectionMapsHttpClient extends AbstractPlacesHttpClient {
HttpUrlConnectionMapsHttpClient(final PlacesApiJsonParser parser) {
super(parser);
}
@Override
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiException.java
// public class PlacesApiException extends IOException {
//
// public PlacesApiException() {
// }
//
// public PlacesApiException(final String detailMessage) {
// super(detailMessage);
// }
//
// public PlacesApiException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public PlacesApiException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Status.java
// public enum Status {
// @SerializedName("OK")
// OK(true),
// @SerializedName("ZERO_RESULTS")
// ZERO_RESULTS(true),
// @SerializedName("OVER_QUERY_LIMIT")
// OVER_QUERY_LIMIT(false),
// @SerializedName("REQUEST_DENIED")
// REQUEST_DENIED(false),
// @SerializedName("INVALID_REQUEST")
// INVALID_REQUEST(false);
//
// private final boolean successful;
//
// Status(final boolean successfulResponse) {
// successful = successfulResponse;
// }
//
// public boolean isSuccessful() {
// return successful;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/HttpUrlConnectionMapsHttpClient.java
import android.net.Uri;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiException;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.Status;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
package com.seatgeek.placesautocomplete.network;
class HttpUrlConnectionMapsHttpClient extends AbstractPlacesHttpClient {
HttpUrlConnectionMapsHttpClient(final PlacesApiJsonParser parser) {
super(parser);
}
@Override
|
protected <T extends PlacesApiResponse> T executeNetworkRequest(final Uri uri, final ResponseHandler<T> handler) throws IOException {
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/HttpUrlConnectionMapsHttpClient.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiException.java
// public class PlacesApiException extends IOException {
//
// public PlacesApiException() {
// }
//
// public PlacesApiException(final String detailMessage) {
// super(detailMessage);
// }
//
// public PlacesApiException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public PlacesApiException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Status.java
// public enum Status {
// @SerializedName("OK")
// OK(true),
// @SerializedName("ZERO_RESULTS")
// ZERO_RESULTS(true),
// @SerializedName("OVER_QUERY_LIMIT")
// OVER_QUERY_LIMIT(false),
// @SerializedName("REQUEST_DENIED")
// REQUEST_DENIED(false),
// @SerializedName("INVALID_REQUEST")
// INVALID_REQUEST(false);
//
// private final boolean successful;
//
// Status(final boolean successfulResponse) {
// successful = successfulResponse;
// }
//
// public boolean isSuccessful() {
// return successful;
// }
// }
|
import android.net.Uri;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiException;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.Status;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
|
package com.seatgeek.placesautocomplete.network;
class HttpUrlConnectionMapsHttpClient extends AbstractPlacesHttpClient {
HttpUrlConnectionMapsHttpClient(final PlacesApiJsonParser parser) {
super(parser);
}
@Override
protected <T extends PlacesApiResponse> T executeNetworkRequest(final Uri uri, final ResponseHandler<T> handler) throws IOException {
URL url = new URL(uri.toString());
T response = null;
HttpURLConnection conn = null;
InputStream is = null;
try {
conn = (HttpURLConnection) url.openConnection();
if (conn != null) {
conn.setConnectTimeout(15000);
conn.setReadTimeout(15000);
is = conn.getInputStream();
response = handler.handleStreamResult(is);
}
} finally {
if (conn != null) {
conn.disconnect();
}
if (is != null) {
is.close();
}
}
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiException.java
// public class PlacesApiException extends IOException {
//
// public PlacesApiException() {
// }
//
// public PlacesApiException(final String detailMessage) {
// super(detailMessage);
// }
//
// public PlacesApiException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public PlacesApiException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Status.java
// public enum Status {
// @SerializedName("OK")
// OK(true),
// @SerializedName("ZERO_RESULTS")
// ZERO_RESULTS(true),
// @SerializedName("OVER_QUERY_LIMIT")
// OVER_QUERY_LIMIT(false),
// @SerializedName("REQUEST_DENIED")
// REQUEST_DENIED(false),
// @SerializedName("INVALID_REQUEST")
// INVALID_REQUEST(false);
//
// private final boolean successful;
//
// Status(final boolean successfulResponse) {
// successful = successfulResponse;
// }
//
// public boolean isSuccessful() {
// return successful;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/HttpUrlConnectionMapsHttpClient.java
import android.net.Uri;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiException;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.Status;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
package com.seatgeek.placesautocomplete.network;
class HttpUrlConnectionMapsHttpClient extends AbstractPlacesHttpClient {
HttpUrlConnectionMapsHttpClient(final PlacesApiJsonParser parser) {
super(parser);
}
@Override
protected <T extends PlacesApiResponse> T executeNetworkRequest(final Uri uri, final ResponseHandler<T> handler) throws IOException {
URL url = new URL(uri.toString());
T response = null;
HttpURLConnection conn = null;
InputStream is = null;
try {
conn = (HttpURLConnection) url.openConnection();
if (conn != null) {
conn.setConnectTimeout(15000);
conn.setReadTimeout(15000);
is = conn.getInputStream();
response = handler.handleStreamResult(is);
}
} finally {
if (conn != null) {
conn.disconnect();
}
if (is != null) {
is.close();
}
}
|
Status status = response != null ? response.status : null;
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/HttpUrlConnectionMapsHttpClient.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiException.java
// public class PlacesApiException extends IOException {
//
// public PlacesApiException() {
// }
//
// public PlacesApiException(final String detailMessage) {
// super(detailMessage);
// }
//
// public PlacesApiException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public PlacesApiException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Status.java
// public enum Status {
// @SerializedName("OK")
// OK(true),
// @SerializedName("ZERO_RESULTS")
// ZERO_RESULTS(true),
// @SerializedName("OVER_QUERY_LIMIT")
// OVER_QUERY_LIMIT(false),
// @SerializedName("REQUEST_DENIED")
// REQUEST_DENIED(false),
// @SerializedName("INVALID_REQUEST")
// INVALID_REQUEST(false);
//
// private final boolean successful;
//
// Status(final boolean successfulResponse) {
// successful = successfulResponse;
// }
//
// public boolean isSuccessful() {
// return successful;
// }
// }
|
import android.net.Uri;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiException;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.Status;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
|
package com.seatgeek.placesautocomplete.network;
class HttpUrlConnectionMapsHttpClient extends AbstractPlacesHttpClient {
HttpUrlConnectionMapsHttpClient(final PlacesApiJsonParser parser) {
super(parser);
}
@Override
protected <T extends PlacesApiResponse> T executeNetworkRequest(final Uri uri, final ResponseHandler<T> handler) throws IOException {
URL url = new URL(uri.toString());
T response = null;
HttpURLConnection conn = null;
InputStream is = null;
try {
conn = (HttpURLConnection) url.openConnection();
if (conn != null) {
conn.setConnectTimeout(15000);
conn.setReadTimeout(15000);
is = conn.getInputStream();
response = handler.handleStreamResult(is);
}
} finally {
if (conn != null) {
conn.disconnect();
}
if (is != null) {
is.close();
}
}
Status status = response != null ? response.status : null;
if (isErrorResponse(response, status)) {
String err = response != null ? response.error_message : null;
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiException.java
// public class PlacesApiException extends IOException {
//
// public PlacesApiException() {
// }
//
// public PlacesApiException(final String detailMessage) {
// super(detailMessage);
// }
//
// public PlacesApiException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public PlacesApiException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Status.java
// public enum Status {
// @SerializedName("OK")
// OK(true),
// @SerializedName("ZERO_RESULTS")
// ZERO_RESULTS(true),
// @SerializedName("OVER_QUERY_LIMIT")
// OVER_QUERY_LIMIT(false),
// @SerializedName("REQUEST_DENIED")
// REQUEST_DENIED(false),
// @SerializedName("INVALID_REQUEST")
// INVALID_REQUEST(false);
//
// private final boolean successful;
//
// Status(final boolean successfulResponse) {
// successful = successfulResponse;
// }
//
// public boolean isSuccessful() {
// return successful;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/HttpUrlConnectionMapsHttpClient.java
import android.net.Uri;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiException;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.Status;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
package com.seatgeek.placesautocomplete.network;
class HttpUrlConnectionMapsHttpClient extends AbstractPlacesHttpClient {
HttpUrlConnectionMapsHttpClient(final PlacesApiJsonParser parser) {
super(parser);
}
@Override
protected <T extends PlacesApiResponse> T executeNetworkRequest(final Uri uri, final ResponseHandler<T> handler) throws IOException {
URL url = new URL(uri.toString());
T response = null;
HttpURLConnection conn = null;
InputStream is = null;
try {
conn = (HttpURLConnection) url.openConnection();
if (conn != null) {
conn.setConnectTimeout(15000);
conn.setReadTimeout(15000);
is = conn.getInputStream();
response = handler.handleStreamResult(is);
}
} finally {
if (conn != null) {
conn.disconnect();
}
if (is != null) {
is.close();
}
}
Status status = response != null ? response.status : null;
if (isErrorResponse(response, status)) {
String err = response != null ? response.error_message : null;
|
throw new PlacesApiException(err != null ? err : "Unknown Places Api Error");
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/OkHttpPlacesHttpClient.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/Constants.java
// public class Constants {
// public static final String LOG_TAG = "MapsPlacesAutoComplete";
// public static final String MAGIC_HISTORY_VALUE_PRE = "____history____=";
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiException.java
// public class PlacesApiException extends IOException {
//
// public PlacesApiException() {
// }
//
// public PlacesApiException(final String detailMessage) {
// super(detailMessage);
// }
//
// public PlacesApiException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public PlacesApiException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Status.java
// public enum Status {
// @SerializedName("OK")
// OK(true),
// @SerializedName("ZERO_RESULTS")
// ZERO_RESULTS(true),
// @SerializedName("OVER_QUERY_LIMIT")
// OVER_QUERY_LIMIT(false),
// @SerializedName("REQUEST_DENIED")
// REQUEST_DENIED(false),
// @SerializedName("INVALID_REQUEST")
// INVALID_REQUEST(false);
//
// private final boolean successful;
//
// Status(final boolean successfulResponse) {
// successful = successfulResponse;
// }
//
// public boolean isSuccessful() {
// return successful;
// }
// }
|
import android.net.Uri;
import android.util.Log;
import com.seatgeek.placesautocomplete.Constants;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiException;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.Status;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
|
package com.seatgeek.placesautocomplete.network;
class OkHttpPlacesHttpClient extends AbstractPlacesHttpClient {
private final OkHttpClient okHttpClient;
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/Constants.java
// public class Constants {
// public static final String LOG_TAG = "MapsPlacesAutoComplete";
// public static final String MAGIC_HISTORY_VALUE_PRE = "____history____=";
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiException.java
// public class PlacesApiException extends IOException {
//
// public PlacesApiException() {
// }
//
// public PlacesApiException(final String detailMessage) {
// super(detailMessage);
// }
//
// public PlacesApiException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public PlacesApiException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Status.java
// public enum Status {
// @SerializedName("OK")
// OK(true),
// @SerializedName("ZERO_RESULTS")
// ZERO_RESULTS(true),
// @SerializedName("OVER_QUERY_LIMIT")
// OVER_QUERY_LIMIT(false),
// @SerializedName("REQUEST_DENIED")
// REQUEST_DENIED(false),
// @SerializedName("INVALID_REQUEST")
// INVALID_REQUEST(false);
//
// private final boolean successful;
//
// Status(final boolean successfulResponse) {
// successful = successfulResponse;
// }
//
// public boolean isSuccessful() {
// return successful;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/OkHttpPlacesHttpClient.java
import android.net.Uri;
import android.util.Log;
import com.seatgeek.placesautocomplete.Constants;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiException;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.Status;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
package com.seatgeek.placesautocomplete.network;
class OkHttpPlacesHttpClient extends AbstractPlacesHttpClient {
private final OkHttpClient okHttpClient;
|
OkHttpPlacesHttpClient(PlacesApiJsonParser parser) {
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/OkHttpPlacesHttpClient.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/Constants.java
// public class Constants {
// public static final String LOG_TAG = "MapsPlacesAutoComplete";
// public static final String MAGIC_HISTORY_VALUE_PRE = "____history____=";
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiException.java
// public class PlacesApiException extends IOException {
//
// public PlacesApiException() {
// }
//
// public PlacesApiException(final String detailMessage) {
// super(detailMessage);
// }
//
// public PlacesApiException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public PlacesApiException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Status.java
// public enum Status {
// @SerializedName("OK")
// OK(true),
// @SerializedName("ZERO_RESULTS")
// ZERO_RESULTS(true),
// @SerializedName("OVER_QUERY_LIMIT")
// OVER_QUERY_LIMIT(false),
// @SerializedName("REQUEST_DENIED")
// REQUEST_DENIED(false),
// @SerializedName("INVALID_REQUEST")
// INVALID_REQUEST(false);
//
// private final boolean successful;
//
// Status(final boolean successfulResponse) {
// successful = successfulResponse;
// }
//
// public boolean isSuccessful() {
// return successful;
// }
// }
|
import android.net.Uri;
import android.util.Log;
import com.seatgeek.placesautocomplete.Constants;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiException;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.Status;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
|
package com.seatgeek.placesautocomplete.network;
class OkHttpPlacesHttpClient extends AbstractPlacesHttpClient {
private final OkHttpClient okHttpClient;
OkHttpPlacesHttpClient(PlacesApiJsonParser parser) {
super(parser);
okHttpClient = new OkHttpClient.Builder()
.connectTimeout(15L, TimeUnit.SECONDS)
.readTimeout(15L, TimeUnit.SECONDS)
.writeTimeout(15L, TimeUnit.SECONDS)
.build();
}
@Override
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/Constants.java
// public class Constants {
// public static final String LOG_TAG = "MapsPlacesAutoComplete";
// public static final String MAGIC_HISTORY_VALUE_PRE = "____history____=";
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiException.java
// public class PlacesApiException extends IOException {
//
// public PlacesApiException() {
// }
//
// public PlacesApiException(final String detailMessage) {
// super(detailMessage);
// }
//
// public PlacesApiException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public PlacesApiException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Status.java
// public enum Status {
// @SerializedName("OK")
// OK(true),
// @SerializedName("ZERO_RESULTS")
// ZERO_RESULTS(true),
// @SerializedName("OVER_QUERY_LIMIT")
// OVER_QUERY_LIMIT(false),
// @SerializedName("REQUEST_DENIED")
// REQUEST_DENIED(false),
// @SerializedName("INVALID_REQUEST")
// INVALID_REQUEST(false);
//
// private final boolean successful;
//
// Status(final boolean successfulResponse) {
// successful = successfulResponse;
// }
//
// public boolean isSuccessful() {
// return successful;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/OkHttpPlacesHttpClient.java
import android.net.Uri;
import android.util.Log;
import com.seatgeek.placesautocomplete.Constants;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiException;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.Status;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
package com.seatgeek.placesautocomplete.network;
class OkHttpPlacesHttpClient extends AbstractPlacesHttpClient {
private final OkHttpClient okHttpClient;
OkHttpPlacesHttpClient(PlacesApiJsonParser parser) {
super(parser);
okHttpClient = new OkHttpClient.Builder()
.connectTimeout(15L, TimeUnit.SECONDS)
.readTimeout(15L, TimeUnit.SECONDS)
.writeTimeout(15L, TimeUnit.SECONDS)
.build();
}
@Override
|
protected <T extends PlacesApiResponse> T executeNetworkRequest(final Uri uri, final ResponseHandler<T> responseHandler) throws IOException {
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/OkHttpPlacesHttpClient.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/Constants.java
// public class Constants {
// public static final String LOG_TAG = "MapsPlacesAutoComplete";
// public static final String MAGIC_HISTORY_VALUE_PRE = "____history____=";
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiException.java
// public class PlacesApiException extends IOException {
//
// public PlacesApiException() {
// }
//
// public PlacesApiException(final String detailMessage) {
// super(detailMessage);
// }
//
// public PlacesApiException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public PlacesApiException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Status.java
// public enum Status {
// @SerializedName("OK")
// OK(true),
// @SerializedName("ZERO_RESULTS")
// ZERO_RESULTS(true),
// @SerializedName("OVER_QUERY_LIMIT")
// OVER_QUERY_LIMIT(false),
// @SerializedName("REQUEST_DENIED")
// REQUEST_DENIED(false),
// @SerializedName("INVALID_REQUEST")
// INVALID_REQUEST(false);
//
// private final boolean successful;
//
// Status(final boolean successfulResponse) {
// successful = successfulResponse;
// }
//
// public boolean isSuccessful() {
// return successful;
// }
// }
|
import android.net.Uri;
import android.util.Log;
import com.seatgeek.placesautocomplete.Constants;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiException;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.Status;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
|
package com.seatgeek.placesautocomplete.network;
class OkHttpPlacesHttpClient extends AbstractPlacesHttpClient {
private final OkHttpClient okHttpClient;
OkHttpPlacesHttpClient(PlacesApiJsonParser parser) {
super(parser);
okHttpClient = new OkHttpClient.Builder()
.connectTimeout(15L, TimeUnit.SECONDS)
.readTimeout(15L, TimeUnit.SECONDS)
.writeTimeout(15L, TimeUnit.SECONDS)
.build();
}
@Override
protected <T extends PlacesApiResponse> T executeNetworkRequest(final Uri uri, final ResponseHandler<T> responseHandler) throws IOException {
final Request request = new Request.Builder()
.url(uri.toString())
.build();
Response response = okHttpClient.newCall(request).execute();
try {
T body = responseHandler.handleStreamResult(response.body().byteStream());
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/Constants.java
// public class Constants {
// public static final String LOG_TAG = "MapsPlacesAutoComplete";
// public static final String MAGIC_HISTORY_VALUE_PRE = "____history____=";
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiException.java
// public class PlacesApiException extends IOException {
//
// public PlacesApiException() {
// }
//
// public PlacesApiException(final String detailMessage) {
// super(detailMessage);
// }
//
// public PlacesApiException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public PlacesApiException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Status.java
// public enum Status {
// @SerializedName("OK")
// OK(true),
// @SerializedName("ZERO_RESULTS")
// ZERO_RESULTS(true),
// @SerializedName("OVER_QUERY_LIMIT")
// OVER_QUERY_LIMIT(false),
// @SerializedName("REQUEST_DENIED")
// REQUEST_DENIED(false),
// @SerializedName("INVALID_REQUEST")
// INVALID_REQUEST(false);
//
// private final boolean successful;
//
// Status(final boolean successfulResponse) {
// successful = successfulResponse;
// }
//
// public boolean isSuccessful() {
// return successful;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/OkHttpPlacesHttpClient.java
import android.net.Uri;
import android.util.Log;
import com.seatgeek.placesautocomplete.Constants;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiException;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.Status;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
package com.seatgeek.placesautocomplete.network;
class OkHttpPlacesHttpClient extends AbstractPlacesHttpClient {
private final OkHttpClient okHttpClient;
OkHttpPlacesHttpClient(PlacesApiJsonParser parser) {
super(parser);
okHttpClient = new OkHttpClient.Builder()
.connectTimeout(15L, TimeUnit.SECONDS)
.readTimeout(15L, TimeUnit.SECONDS)
.writeTimeout(15L, TimeUnit.SECONDS)
.build();
}
@Override
protected <T extends PlacesApiResponse> T executeNetworkRequest(final Uri uri, final ResponseHandler<T> responseHandler) throws IOException {
final Request request = new Request.Builder()
.url(uri.toString())
.build();
Response response = okHttpClient.newCall(request).execute();
try {
T body = responseHandler.handleStreamResult(response.body().byteStream());
|
Status status = body.status;
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/OkHttpPlacesHttpClient.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/Constants.java
// public class Constants {
// public static final String LOG_TAG = "MapsPlacesAutoComplete";
// public static final String MAGIC_HISTORY_VALUE_PRE = "____history____=";
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiException.java
// public class PlacesApiException extends IOException {
//
// public PlacesApiException() {
// }
//
// public PlacesApiException(final String detailMessage) {
// super(detailMessage);
// }
//
// public PlacesApiException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public PlacesApiException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Status.java
// public enum Status {
// @SerializedName("OK")
// OK(true),
// @SerializedName("ZERO_RESULTS")
// ZERO_RESULTS(true),
// @SerializedName("OVER_QUERY_LIMIT")
// OVER_QUERY_LIMIT(false),
// @SerializedName("REQUEST_DENIED")
// REQUEST_DENIED(false),
// @SerializedName("INVALID_REQUEST")
// INVALID_REQUEST(false);
//
// private final boolean successful;
//
// Status(final boolean successfulResponse) {
// successful = successfulResponse;
// }
//
// public boolean isSuccessful() {
// return successful;
// }
// }
|
import android.net.Uri;
import android.util.Log;
import com.seatgeek.placesautocomplete.Constants;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiException;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.Status;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
|
package com.seatgeek.placesautocomplete.network;
class OkHttpPlacesHttpClient extends AbstractPlacesHttpClient {
private final OkHttpClient okHttpClient;
OkHttpPlacesHttpClient(PlacesApiJsonParser parser) {
super(parser);
okHttpClient = new OkHttpClient.Builder()
.connectTimeout(15L, TimeUnit.SECONDS)
.readTimeout(15L, TimeUnit.SECONDS)
.writeTimeout(15L, TimeUnit.SECONDS)
.build();
}
@Override
protected <T extends PlacesApiResponse> T executeNetworkRequest(final Uri uri, final ResponseHandler<T> responseHandler) throws IOException {
final Request request = new Request.Builder()
.url(uri.toString())
.build();
Response response = okHttpClient.newCall(request).execute();
try {
T body = responseHandler.handleStreamResult(response.body().byteStream());
Status status = body.status;
if (status != null && !status.isSuccessful()) {
String err = body.error_message;
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/Constants.java
// public class Constants {
// public static final String LOG_TAG = "MapsPlacesAutoComplete";
// public static final String MAGIC_HISTORY_VALUE_PRE = "____history____=";
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiException.java
// public class PlacesApiException extends IOException {
//
// public PlacesApiException() {
// }
//
// public PlacesApiException(final String detailMessage) {
// super(detailMessage);
// }
//
// public PlacesApiException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public PlacesApiException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Status.java
// public enum Status {
// @SerializedName("OK")
// OK(true),
// @SerializedName("ZERO_RESULTS")
// ZERO_RESULTS(true),
// @SerializedName("OVER_QUERY_LIMIT")
// OVER_QUERY_LIMIT(false),
// @SerializedName("REQUEST_DENIED")
// REQUEST_DENIED(false),
// @SerializedName("INVALID_REQUEST")
// INVALID_REQUEST(false);
//
// private final boolean successful;
//
// Status(final boolean successfulResponse) {
// successful = successfulResponse;
// }
//
// public boolean isSuccessful() {
// return successful;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/OkHttpPlacesHttpClient.java
import android.net.Uri;
import android.util.Log;
import com.seatgeek.placesautocomplete.Constants;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiException;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.Status;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
package com.seatgeek.placesautocomplete.network;
class OkHttpPlacesHttpClient extends AbstractPlacesHttpClient {
private final OkHttpClient okHttpClient;
OkHttpPlacesHttpClient(PlacesApiJsonParser parser) {
super(parser);
okHttpClient = new OkHttpClient.Builder()
.connectTimeout(15L, TimeUnit.SECONDS)
.readTimeout(15L, TimeUnit.SECONDS)
.writeTimeout(15L, TimeUnit.SECONDS)
.build();
}
@Override
protected <T extends PlacesApiResponse> T executeNetworkRequest(final Uri uri, final ResponseHandler<T> responseHandler) throws IOException {
final Request request = new Request.Builder()
.url(uri.toString())
.build();
Response response = okHttpClient.newCall(request).execute();
try {
T body = responseHandler.handleStreamResult(response.body().byteStream());
Status status = body.status;
if (status != null && !status.isSuccessful()) {
String err = body.error_message;
|
throw new PlacesApiException(err != null ? err : "Unknown Places Api Error");
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/OkHttpPlacesHttpClient.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/Constants.java
// public class Constants {
// public static final String LOG_TAG = "MapsPlacesAutoComplete";
// public static final String MAGIC_HISTORY_VALUE_PRE = "____history____=";
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiException.java
// public class PlacesApiException extends IOException {
//
// public PlacesApiException() {
// }
//
// public PlacesApiException(final String detailMessage) {
// super(detailMessage);
// }
//
// public PlacesApiException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public PlacesApiException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Status.java
// public enum Status {
// @SerializedName("OK")
// OK(true),
// @SerializedName("ZERO_RESULTS")
// ZERO_RESULTS(true),
// @SerializedName("OVER_QUERY_LIMIT")
// OVER_QUERY_LIMIT(false),
// @SerializedName("REQUEST_DENIED")
// REQUEST_DENIED(false),
// @SerializedName("INVALID_REQUEST")
// INVALID_REQUEST(false);
//
// private final boolean successful;
//
// Status(final boolean successfulResponse) {
// successful = successfulResponse;
// }
//
// public boolean isSuccessful() {
// return successful;
// }
// }
|
import android.net.Uri;
import android.util.Log;
import com.seatgeek.placesautocomplete.Constants;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiException;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.Status;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
|
okHttpClient = new OkHttpClient.Builder()
.connectTimeout(15L, TimeUnit.SECONDS)
.readTimeout(15L, TimeUnit.SECONDS)
.writeTimeout(15L, TimeUnit.SECONDS)
.build();
}
@Override
protected <T extends PlacesApiResponse> T executeNetworkRequest(final Uri uri, final ResponseHandler<T> responseHandler) throws IOException {
final Request request = new Request.Builder()
.url(uri.toString())
.build();
Response response = okHttpClient.newCall(request).execute();
try {
T body = responseHandler.handleStreamResult(response.body().byteStream());
Status status = body.status;
if (status != null && !status.isSuccessful()) {
String err = body.error_message;
throw new PlacesApiException(err != null ? err : "Unknown Places Api Error");
} else {
return body;
}
} finally {
if (response != null) {
try {
response.body().close();
} catch (Exception e) {
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/Constants.java
// public class Constants {
// public static final String LOG_TAG = "MapsPlacesAutoComplete";
// public static final String MAGIC_HISTORY_VALUE_PRE = "____history____=";
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiException.java
// public class PlacesApiException extends IOException {
//
// public PlacesApiException() {
// }
//
// public PlacesApiException(final String detailMessage) {
// super(detailMessage);
// }
//
// public PlacesApiException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public PlacesApiException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Status.java
// public enum Status {
// @SerializedName("OK")
// OK(true),
// @SerializedName("ZERO_RESULTS")
// ZERO_RESULTS(true),
// @SerializedName("OVER_QUERY_LIMIT")
// OVER_QUERY_LIMIT(false),
// @SerializedName("REQUEST_DENIED")
// REQUEST_DENIED(false),
// @SerializedName("INVALID_REQUEST")
// INVALID_REQUEST(false);
//
// private final boolean successful;
//
// Status(final boolean successfulResponse) {
// successful = successfulResponse;
// }
//
// public boolean isSuccessful() {
// return successful;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/OkHttpPlacesHttpClient.java
import android.net.Uri;
import android.util.Log;
import com.seatgeek.placesautocomplete.Constants;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiException;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.Status;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
okHttpClient = new OkHttpClient.Builder()
.connectTimeout(15L, TimeUnit.SECONDS)
.readTimeout(15L, TimeUnit.SECONDS)
.writeTimeout(15L, TimeUnit.SECONDS)
.build();
}
@Override
protected <T extends PlacesApiResponse> T executeNetworkRequest(final Uri uri, final ResponseHandler<T> responseHandler) throws IOException {
final Request request = new Request.Builder()
.url(uri.toString())
.build();
Response response = okHttpClient.newCall(request).execute();
try {
T body = responseHandler.handleStreamResult(response.body().byteStream());
Status status = body.status;
if (status != null && !status.isSuccessful()) {
String err = body.error_message;
throw new PlacesApiException(err != null ? err : "Unknown Places Api Error");
} else {
return body;
}
} finally {
if (response != null) {
try {
response.body().close();
} catch (Exception e) {
|
Log.w(Constants.LOG_TAG, "Exception Closing Response body..", e);
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Place.java
// public final class Place {
//
// /**
// * Human readable description of the place returned from the api. e.g. "235 Park Ave South, New York, NY, USA"
// */
// public final String description;
//
// /**
// * A unique place id used in the maps apu. this can be used to query for further information about
// * the location from the places api. See https://developers.google.com/places/documentation/place-id
// * for more information about place_id
// */
// public final String place_id;
//
// /**
// * The lengths and offsets of the substrings the query matched in the description
// */
// public final List<MatchedSubstring> matched_substrings;
//
// /**
// * The strings and offsets of the components that make up the description.
// */
// public final List<DescriptionTerm> terms;
//
// /**
// * The types of place that this corresponds to in the places api. See individual PlaceType's for
// * thier descriptions
// */
// public final List<PlaceType> types;
//
// public Place(final String description, final String place_id, final List<MatchedSubstring> matched_substrings, final List<DescriptionTerm> terms, final List<PlaceType> types) {
// this.description = description;
// this.place_id = place_id;
// this.matched_substrings = matched_substrings;
// this.terms = terms;
// this.types = types;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof Place)) return false;
//
// Place place = (Place) o;
//
// if (description != null ? !description.equals(place.description) : place.description != null) return false;
// if (matched_substrings != null ? !matched_substrings.equals(place.matched_substrings) : place.matched_substrings != null)
// return false;
// if (place_id != null ? !place_id.equals(place.place_id) : place.place_id != null) return false;
// if (terms != null ? !terms.equals(place.terms) : place.terms != null) return false;
// if (types != null ? !types.equals(place.types) : place.types != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = description != null ? description.hashCode() : 0;
// result = 31 * result + (place_id != null ? place_id.hashCode() : 0);
// result = 31 * result + (matched_substrings != null ? matched_substrings.hashCode() : 0);
// result = 31 * result + (terms != null ? terms.hashCode() : 0);
// result = 31 * result + (types != null ? types.hashCode() : 0);
// return result;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
|
import com.seatgeek.placesautocomplete.model.Place;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
|
package com.seatgeek.placesautocomplete.json;
public interface PlacesApiJsonParser {
PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Place.java
// public final class Place {
//
// /**
// * Human readable description of the place returned from the api. e.g. "235 Park Ave South, New York, NY, USA"
// */
// public final String description;
//
// /**
// * A unique place id used in the maps apu. this can be used to query for further information about
// * the location from the places api. See https://developers.google.com/places/documentation/place-id
// * for more information about place_id
// */
// public final String place_id;
//
// /**
// * The lengths and offsets of the substrings the query matched in the description
// */
// public final List<MatchedSubstring> matched_substrings;
//
// /**
// * The strings and offsets of the components that make up the description.
// */
// public final List<DescriptionTerm> terms;
//
// /**
// * The types of place that this corresponds to in the places api. See individual PlaceType's for
// * thier descriptions
// */
// public final List<PlaceType> types;
//
// public Place(final String description, final String place_id, final List<MatchedSubstring> matched_substrings, final List<DescriptionTerm> terms, final List<PlaceType> types) {
// this.description = description;
// this.place_id = place_id;
// this.matched_substrings = matched_substrings;
// this.terms = terms;
// this.types = types;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof Place)) return false;
//
// Place place = (Place) o;
//
// if (description != null ? !description.equals(place.description) : place.description != null) return false;
// if (matched_substrings != null ? !matched_substrings.equals(place.matched_substrings) : place.matched_substrings != null)
// return false;
// if (place_id != null ? !place_id.equals(place.place_id) : place.place_id != null) return false;
// if (terms != null ? !terms.equals(place.terms) : place.terms != null) return false;
// if (types != null ? !types.equals(place.types) : place.types != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = description != null ? description.hashCode() : 0;
// result = 31 * result + (place_id != null ? place_id.hashCode() : 0);
// result = 31 * result + (matched_substrings != null ? matched_substrings.hashCode() : 0);
// result = 31 * result + (terms != null ? terms.hashCode() : 0);
// result = 31 * result + (types != null ? types.hashCode() : 0);
// return result;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
import com.seatgeek.placesautocomplete.model.Place;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
package com.seatgeek.placesautocomplete.json;
public interface PlacesApiJsonParser {
PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
|
PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Place.java
// public final class Place {
//
// /**
// * Human readable description of the place returned from the api. e.g. "235 Park Ave South, New York, NY, USA"
// */
// public final String description;
//
// /**
// * A unique place id used in the maps apu. this can be used to query for further information about
// * the location from the places api. See https://developers.google.com/places/documentation/place-id
// * for more information about place_id
// */
// public final String place_id;
//
// /**
// * The lengths and offsets of the substrings the query matched in the description
// */
// public final List<MatchedSubstring> matched_substrings;
//
// /**
// * The strings and offsets of the components that make up the description.
// */
// public final List<DescriptionTerm> terms;
//
// /**
// * The types of place that this corresponds to in the places api. See individual PlaceType's for
// * thier descriptions
// */
// public final List<PlaceType> types;
//
// public Place(final String description, final String place_id, final List<MatchedSubstring> matched_substrings, final List<DescriptionTerm> terms, final List<PlaceType> types) {
// this.description = description;
// this.place_id = place_id;
// this.matched_substrings = matched_substrings;
// this.terms = terms;
// this.types = types;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof Place)) return false;
//
// Place place = (Place) o;
//
// if (description != null ? !description.equals(place.description) : place.description != null) return false;
// if (matched_substrings != null ? !matched_substrings.equals(place.matched_substrings) : place.matched_substrings != null)
// return false;
// if (place_id != null ? !place_id.equals(place.place_id) : place.place_id != null) return false;
// if (terms != null ? !terms.equals(place.terms) : place.terms != null) return false;
// if (types != null ? !types.equals(place.types) : place.types != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = description != null ? description.hashCode() : 0;
// result = 31 * result + (place_id != null ? place_id.hashCode() : 0);
// result = 31 * result + (matched_substrings != null ? matched_substrings.hashCode() : 0);
// result = 31 * result + (terms != null ? terms.hashCode() : 0);
// result = 31 * result + (types != null ? types.hashCode() : 0);
// return result;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
|
import com.seatgeek.placesautocomplete.model.Place;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
|
package com.seatgeek.placesautocomplete.json;
public interface PlacesApiJsonParser {
PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Place.java
// public final class Place {
//
// /**
// * Human readable description of the place returned from the api. e.g. "235 Park Ave South, New York, NY, USA"
// */
// public final String description;
//
// /**
// * A unique place id used in the maps apu. this can be used to query for further information about
// * the location from the places api. See https://developers.google.com/places/documentation/place-id
// * for more information about place_id
// */
// public final String place_id;
//
// /**
// * The lengths and offsets of the substrings the query matched in the description
// */
// public final List<MatchedSubstring> matched_substrings;
//
// /**
// * The strings and offsets of the components that make up the description.
// */
// public final List<DescriptionTerm> terms;
//
// /**
// * The types of place that this corresponds to in the places api. See individual PlaceType's for
// * thier descriptions
// */
// public final List<PlaceType> types;
//
// public Place(final String description, final String place_id, final List<MatchedSubstring> matched_substrings, final List<DescriptionTerm> terms, final List<PlaceType> types) {
// this.description = description;
// this.place_id = place_id;
// this.matched_substrings = matched_substrings;
// this.terms = terms;
// this.types = types;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof Place)) return false;
//
// Place place = (Place) o;
//
// if (description != null ? !description.equals(place.description) : place.description != null) return false;
// if (matched_substrings != null ? !matched_substrings.equals(place.matched_substrings) : place.matched_substrings != null)
// return false;
// if (place_id != null ? !place_id.equals(place.place_id) : place.place_id != null) return false;
// if (terms != null ? !terms.equals(place.terms) : place.terms != null) return false;
// if (types != null ? !types.equals(place.types) : place.types != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = description != null ? description.hashCode() : 0;
// result = 31 * result + (place_id != null ? place_id.hashCode() : 0);
// result = 31 * result + (matched_substrings != null ? matched_substrings.hashCode() : 0);
// result = 31 * result + (terms != null ? terms.hashCode() : 0);
// result = 31 * result + (types != null ? types.hashCode() : 0);
// return result;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
import com.seatgeek.placesautocomplete.model.Place;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
package com.seatgeek.placesautocomplete.json;
public interface PlacesApiJsonParser {
PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
|
List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/history/AutocompleteHistoryManager.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Place.java
// public final class Place {
//
// /**
// * Human readable description of the place returned from the api. e.g. "235 Park Ave South, New York, NY, USA"
// */
// public final String description;
//
// /**
// * A unique place id used in the maps apu. this can be used to query for further information about
// * the location from the places api. See https://developers.google.com/places/documentation/place-id
// * for more information about place_id
// */
// public final String place_id;
//
// /**
// * The lengths and offsets of the substrings the query matched in the description
// */
// public final List<MatchedSubstring> matched_substrings;
//
// /**
// * The strings and offsets of the components that make up the description.
// */
// public final List<DescriptionTerm> terms;
//
// /**
// * The types of place that this corresponds to in the places api. See individual PlaceType's for
// * thier descriptions
// */
// public final List<PlaceType> types;
//
// public Place(final String description, final String place_id, final List<MatchedSubstring> matched_substrings, final List<DescriptionTerm> terms, final List<PlaceType> types) {
// this.description = description;
// this.place_id = place_id;
// this.matched_substrings = matched_substrings;
// this.terms = terms;
// this.types = types;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof Place)) return false;
//
// Place place = (Place) o;
//
// if (description != null ? !description.equals(place.description) : place.description != null) return false;
// if (matched_substrings != null ? !matched_substrings.equals(place.matched_substrings) : place.matched_substrings != null)
// return false;
// if (place_id != null ? !place_id.equals(place.place_id) : place.place_id != null) return false;
// if (terms != null ? !terms.equals(place.terms) : place.terms != null) return false;
// if (types != null ? !types.equals(place.types) : place.types != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = description != null ? description.hashCode() : 0;
// result = 31 * result + (place_id != null ? place_id.hashCode() : 0);
// result = 31 * result + (matched_substrings != null ? matched_substrings.hashCode() : 0);
// result = 31 * result + (terms != null ? terms.hashCode() : 0);
// result = 31 * result + (types != null ? types.hashCode() : 0);
// return result;
// }
// }
|
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.seatgeek.placesautocomplete.model.Place;
import java.util.List;
|
package com.seatgeek.placesautocomplete.history;
/**
* An interface used by the PlacesAutocompleteTextView to first filter with results matching the
* historical selections by the user
*/
public interface AutocompleteHistoryManager {
/**
* @param listener a listener to register to this instance of an AutocompleteHistoryManager that
* will report changes to the sotred history
*/
void setListener(@Nullable OnHistoryUpdatedListener listener);
/**
* @param place a selected place that should be added to the history file
*/
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/Place.java
// public final class Place {
//
// /**
// * Human readable description of the place returned from the api. e.g. "235 Park Ave South, New York, NY, USA"
// */
// public final String description;
//
// /**
// * A unique place id used in the maps apu. this can be used to query for further information about
// * the location from the places api. See https://developers.google.com/places/documentation/place-id
// * for more information about place_id
// */
// public final String place_id;
//
// /**
// * The lengths and offsets of the substrings the query matched in the description
// */
// public final List<MatchedSubstring> matched_substrings;
//
// /**
// * The strings and offsets of the components that make up the description.
// */
// public final List<DescriptionTerm> terms;
//
// /**
// * The types of place that this corresponds to in the places api. See individual PlaceType's for
// * thier descriptions
// */
// public final List<PlaceType> types;
//
// public Place(final String description, final String place_id, final List<MatchedSubstring> matched_substrings, final List<DescriptionTerm> terms, final List<PlaceType> types) {
// this.description = description;
// this.place_id = place_id;
// this.matched_substrings = matched_substrings;
// this.terms = terms;
// this.types = types;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof Place)) return false;
//
// Place place = (Place) o;
//
// if (description != null ? !description.equals(place.description) : place.description != null) return false;
// if (matched_substrings != null ? !matched_substrings.equals(place.matched_substrings) : place.matched_substrings != null)
// return false;
// if (place_id != null ? !place_id.equals(place.place_id) : place.place_id != null) return false;
// if (terms != null ? !terms.equals(place.terms) : place.terms != null) return false;
// if (types != null ? !types.equals(place.types) : place.types != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// int result = description != null ? description.hashCode() : 0;
// result = 31 * result + (place_id != null ? place_id.hashCode() : 0);
// result = 31 * result + (matched_substrings != null ? matched_substrings.hashCode() : 0);
// result = 31 * result + (terms != null ? terms.hashCode() : 0);
// result = 31 * result + (types != null ? types.hashCode() : 0);
// return result;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/history/AutocompleteHistoryManager.java
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.seatgeek.placesautocomplete.model.Place;
import java.util.List;
package com.seatgeek.placesautocomplete.history;
/**
* An interface used by the PlacesAutocompleteTextView to first filter with results matching the
* historical selections by the user
*/
public interface AutocompleteHistoryManager {
/**
* @param listener a listener to register to this instance of an AutocompleteHistoryManager that
* will report changes to the sotred history
*/
void setListener(@Nullable OnHistoryUpdatedListener listener);
/**
* @param place a selected place that should be added to the history file
*/
|
void addItemToHistory(@NonNull Place place);
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClient.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
|
import android.net.Uri;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.IOException;
|
package com.seatgeek.placesautocomplete.network;
public interface PlacesHttpClient {
PlacesAutocompleteResponse executeAutocompleteRequest(Uri uri) throws IOException;
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/PlacesHttpClient.java
import android.net.Uri;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.IOException;
package com.seatgeek.placesautocomplete.network;
public interface PlacesHttpClient {
PlacesAutocompleteResponse executeAutocompleteRequest(Uri uri) throws IOException;
|
PlacesDetailsResponse executeDetailsRequest(Uri uri) throws IOException;
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/AbstractPlacesHttpClient.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/JsonParsingException.java
// public class JsonParsingException extends IOException {
//
// public JsonParsingException() {
// }
//
// public JsonParsingException(final String detailMessage) {
// super(detailMessage);
// }
//
// public JsonParsingException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public JsonParsingException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
|
import android.net.Uri;
import com.seatgeek.placesautocomplete.json.JsonParsingException;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.IOException;
import java.io.InputStream;
|
package com.seatgeek.placesautocomplete.network;
abstract class AbstractPlacesHttpClient implements PlacesHttpClient {
protected final PlacesApiJsonParser placesApiJsonParser;
protected AbstractPlacesHttpClient(PlacesApiJsonParser parser) {
placesApiJsonParser = parser;
}
@Override
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/JsonParsingException.java
// public class JsonParsingException extends IOException {
//
// public JsonParsingException() {
// }
//
// public JsonParsingException(final String detailMessage) {
// super(detailMessage);
// }
//
// public JsonParsingException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public JsonParsingException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/AbstractPlacesHttpClient.java
import android.net.Uri;
import com.seatgeek.placesautocomplete.json.JsonParsingException;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.IOException;
import java.io.InputStream;
package com.seatgeek.placesautocomplete.network;
abstract class AbstractPlacesHttpClient implements PlacesHttpClient {
protected final PlacesApiJsonParser placesApiJsonParser;
protected AbstractPlacesHttpClient(PlacesApiJsonParser parser) {
placesApiJsonParser = parser;
}
@Override
|
public PlacesAutocompleteResponse executeAutocompleteRequest(final Uri uri) throws IOException {
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/AbstractPlacesHttpClient.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/JsonParsingException.java
// public class JsonParsingException extends IOException {
//
// public JsonParsingException() {
// }
//
// public JsonParsingException(final String detailMessage) {
// super(detailMessage);
// }
//
// public JsonParsingException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public JsonParsingException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
|
import android.net.Uri;
import com.seatgeek.placesautocomplete.json.JsonParsingException;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.IOException;
import java.io.InputStream;
|
package com.seatgeek.placesautocomplete.network;
abstract class AbstractPlacesHttpClient implements PlacesHttpClient {
protected final PlacesApiJsonParser placesApiJsonParser;
protected AbstractPlacesHttpClient(PlacesApiJsonParser parser) {
placesApiJsonParser = parser;
}
@Override
public PlacesAutocompleteResponse executeAutocompleteRequest(final Uri uri) throws IOException {
return executeNetworkRequest(uri, new ResponseHandler<PlacesAutocompleteResponse>() {
@Override
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/JsonParsingException.java
// public class JsonParsingException extends IOException {
//
// public JsonParsingException() {
// }
//
// public JsonParsingException(final String detailMessage) {
// super(detailMessage);
// }
//
// public JsonParsingException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public JsonParsingException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/AbstractPlacesHttpClient.java
import android.net.Uri;
import com.seatgeek.placesautocomplete.json.JsonParsingException;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.IOException;
import java.io.InputStream;
package com.seatgeek.placesautocomplete.network;
abstract class AbstractPlacesHttpClient implements PlacesHttpClient {
protected final PlacesApiJsonParser placesApiJsonParser;
protected AbstractPlacesHttpClient(PlacesApiJsonParser parser) {
placesApiJsonParser = parser;
}
@Override
public PlacesAutocompleteResponse executeAutocompleteRequest(final Uri uri) throws IOException {
return executeNetworkRequest(uri, new ResponseHandler<PlacesAutocompleteResponse>() {
@Override
|
public PlacesAutocompleteResponse handleStreamResult(final InputStream is) throws JsonParsingException {
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/AbstractPlacesHttpClient.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/JsonParsingException.java
// public class JsonParsingException extends IOException {
//
// public JsonParsingException() {
// }
//
// public JsonParsingException(final String detailMessage) {
// super(detailMessage);
// }
//
// public JsonParsingException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public JsonParsingException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
|
import android.net.Uri;
import com.seatgeek.placesautocomplete.json.JsonParsingException;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.IOException;
import java.io.InputStream;
|
package com.seatgeek.placesautocomplete.network;
abstract class AbstractPlacesHttpClient implements PlacesHttpClient {
protected final PlacesApiJsonParser placesApiJsonParser;
protected AbstractPlacesHttpClient(PlacesApiJsonParser parser) {
placesApiJsonParser = parser;
}
@Override
public PlacesAutocompleteResponse executeAutocompleteRequest(final Uri uri) throws IOException {
return executeNetworkRequest(uri, new ResponseHandler<PlacesAutocompleteResponse>() {
@Override
public PlacesAutocompleteResponse handleStreamResult(final InputStream is) throws JsonParsingException {
return placesApiJsonParser.autocompleteFromStream(is);
}
});
}
@Override
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/JsonParsingException.java
// public class JsonParsingException extends IOException {
//
// public JsonParsingException() {
// }
//
// public JsonParsingException(final String detailMessage) {
// super(detailMessage);
// }
//
// public JsonParsingException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public JsonParsingException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/AbstractPlacesHttpClient.java
import android.net.Uri;
import com.seatgeek.placesautocomplete.json.JsonParsingException;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.IOException;
import java.io.InputStream;
package com.seatgeek.placesautocomplete.network;
abstract class AbstractPlacesHttpClient implements PlacesHttpClient {
protected final PlacesApiJsonParser placesApiJsonParser;
protected AbstractPlacesHttpClient(PlacesApiJsonParser parser) {
placesApiJsonParser = parser;
}
@Override
public PlacesAutocompleteResponse executeAutocompleteRequest(final Uri uri) throws IOException {
return executeNetworkRequest(uri, new ResponseHandler<PlacesAutocompleteResponse>() {
@Override
public PlacesAutocompleteResponse handleStreamResult(final InputStream is) throws JsonParsingException {
return placesApiJsonParser.autocompleteFromStream(is);
}
});
}
@Override
|
public PlacesDetailsResponse executeDetailsRequest(final Uri uri) throws IOException {
|
seatgeek/android-PlacesAutocompleteTextView
|
placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/AbstractPlacesHttpClient.java
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/JsonParsingException.java
// public class JsonParsingException extends IOException {
//
// public JsonParsingException() {
// }
//
// public JsonParsingException(final String detailMessage) {
// super(detailMessage);
// }
//
// public JsonParsingException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public JsonParsingException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
|
import android.net.Uri;
import com.seatgeek.placesautocomplete.json.JsonParsingException;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.IOException;
import java.io.InputStream;
|
package com.seatgeek.placesautocomplete.network;
abstract class AbstractPlacesHttpClient implements PlacesHttpClient {
protected final PlacesApiJsonParser placesApiJsonParser;
protected AbstractPlacesHttpClient(PlacesApiJsonParser parser) {
placesApiJsonParser = parser;
}
@Override
public PlacesAutocompleteResponse executeAutocompleteRequest(final Uri uri) throws IOException {
return executeNetworkRequest(uri, new ResponseHandler<PlacesAutocompleteResponse>() {
@Override
public PlacesAutocompleteResponse handleStreamResult(final InputStream is) throws JsonParsingException {
return placesApiJsonParser.autocompleteFromStream(is);
}
});
}
@Override
public PlacesDetailsResponse executeDetailsRequest(final Uri uri) throws IOException {
return executeNetworkRequest(uri, new ResponseHandler<PlacesDetailsResponse>() {
@Override
public PlacesDetailsResponse handleStreamResult(final InputStream is) throws JsonParsingException {
return placesApiJsonParser.detailsFromStream(is);
}
});
}
|
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/JsonParsingException.java
// public class JsonParsingException extends IOException {
//
// public JsonParsingException() {
// }
//
// public JsonParsingException(final String detailMessage) {
// super(detailMessage);
// }
//
// public JsonParsingException(final String detailMessage, final Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public JsonParsingException(final Throwable throwable) {
// super(throwable);
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/json/PlacesApiJsonParser.java
// public interface PlacesApiJsonParser {
// PlacesAutocompleteResponse autocompleteFromStream(InputStream is) throws JsonParsingException;
//
// PlacesDetailsResponse detailsFromStream(InputStream is) throws JsonParsingException;
//
// List<Place> readHistoryJson(InputStream in) throws JsonParsingException;
//
// void writeHistoryJson(OutputStream os, List<Place> places) throws JsonWritingException;
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesApiResponse.java
// public class PlacesApiResponse {
//
// /**
// * API response status. Can and should be used to see if a request was successful
// */
// public final Status status;
//
// /**
// * If !status.isSuccessful(), should return an en error message about what went wrong
// */
// public final String error_message;
//
// public PlacesApiResponse(final Status status, final String error_message) {
// this.status = status;
// this.error_message = error_message;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesAutocompleteResponse.java
// public final class PlacesAutocompleteResponse extends PlacesApiResponse {
//
// /**
// * A list of predicted places from the api based on the given input
// */
// public final List<Place> predictions;
//
// public PlacesAutocompleteResponse(final Status status, final String error_message, final List<Place> predictions) {
// super(status, error_message);
// this.predictions = predictions;
// }
// }
//
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/model/PlacesDetailsResponse.java
// public final class PlacesDetailsResponse extends PlacesApiResponse {
//
// public final PlaceDetails result;
//
// public PlacesDetailsResponse(final Status status, final String error_message, final PlaceDetails result) {
// super(status, error_message);
// this.result = result;
// }
// }
// Path: placesautocomplete/src/main/java/com/seatgeek/placesautocomplete/network/AbstractPlacesHttpClient.java
import android.net.Uri;
import com.seatgeek.placesautocomplete.json.JsonParsingException;
import com.seatgeek.placesautocomplete.json.PlacesApiJsonParser;
import com.seatgeek.placesautocomplete.model.PlacesApiResponse;
import com.seatgeek.placesautocomplete.model.PlacesAutocompleteResponse;
import com.seatgeek.placesautocomplete.model.PlacesDetailsResponse;
import java.io.IOException;
import java.io.InputStream;
package com.seatgeek.placesautocomplete.network;
abstract class AbstractPlacesHttpClient implements PlacesHttpClient {
protected final PlacesApiJsonParser placesApiJsonParser;
protected AbstractPlacesHttpClient(PlacesApiJsonParser parser) {
placesApiJsonParser = parser;
}
@Override
public PlacesAutocompleteResponse executeAutocompleteRequest(final Uri uri) throws IOException {
return executeNetworkRequest(uri, new ResponseHandler<PlacesAutocompleteResponse>() {
@Override
public PlacesAutocompleteResponse handleStreamResult(final InputStream is) throws JsonParsingException {
return placesApiJsonParser.autocompleteFromStream(is);
}
});
}
@Override
public PlacesDetailsResponse executeDetailsRequest(final Uri uri) throws IOException {
return executeNetworkRequest(uri, new ResponseHandler<PlacesDetailsResponse>() {
@Override
public PlacesDetailsResponse handleStreamResult(final InputStream is) throws JsonParsingException {
return placesApiJsonParser.detailsFromStream(is);
}
});
}
|
protected abstract <T extends PlacesApiResponse> T executeNetworkRequest(Uri uri, ResponseHandler<T> responseHandler) throws IOException;
|
voyages-sncf-technologies/hesperides
|
core/presentation/src/main/java/org/hesperides/core/presentation/io/templatecontainers/PropertyOutput.java
|
// Path: core/domain/src/main/java/org/hesperides/core/domain/templatecontainers/queries/IterablePropertyView.java
// @Value
// @EqualsAndHashCode(callSuper = true)
// public class IterablePropertyView extends AbstractPropertyView {
//
// List<AbstractPropertyView> properties;
//
// public IterablePropertyView(String name, List<AbstractPropertyView> properties) {
// super(name);
// this.properties = properties;
// }
//
// @Override
// protected Stream<PropertyView> flattenProperties() {
// return Optional.ofNullable(properties)
// .orElseGet(Collections::emptyList)
// .stream()
// .map(AbstractPropertyView::flattenProperties)
// .flatMap(Function.identity());
// }
// }
|
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.*;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Value;
import org.hesperides.core.domain.templatecontainers.queries.AbstractPropertyView;
import org.hesperides.core.domain.templatecontainers.queries.IterablePropertyView;
import org.hesperides.core.domain.templatecontainers.queries.PropertyView;
import java.lang.reflect.Type;
import java.util.*;
import java.util.stream.Collectors;
|
jsonObject.remove("fields");
if (src.getProperties() != null) {
// Cas d'une propriété itérable : seuls les champs "name" & "fields" ont du sens
JsonArray jsonArray = new JsonArray();
for (PropertyOutput propertyOutput : src.getProperties()) {
jsonArray.add(context.serialize(propertyOutput, PropertyOutput.class));
}
jsonObject.add("fields", jsonArray);
jsonObject.remove("required");
jsonObject.remove("comment");
jsonObject.remove("defaultValue");
jsonObject.remove("pattern");
jsonObject.remove("password");
}
return jsonObject;
}
}
PropertyOutput(AbstractPropertyView abstractPropertyView) {
this.name = abstractPropertyView.getName();
if (abstractPropertyView instanceof PropertyView) {
final PropertyView propertyView = (PropertyView) abstractPropertyView;
this.isRequired = propertyView.isRequired();
this.comment = propertyView.getComment();
this.defaultValue = propertyView.getDefaultValue();
this.pattern = propertyView.getPattern();
this.isPassword = propertyView.isPassword();
this.properties = null;
|
// Path: core/domain/src/main/java/org/hesperides/core/domain/templatecontainers/queries/IterablePropertyView.java
// @Value
// @EqualsAndHashCode(callSuper = true)
// public class IterablePropertyView extends AbstractPropertyView {
//
// List<AbstractPropertyView> properties;
//
// public IterablePropertyView(String name, List<AbstractPropertyView> properties) {
// super(name);
// this.properties = properties;
// }
//
// @Override
// protected Stream<PropertyView> flattenProperties() {
// return Optional.ofNullable(properties)
// .orElseGet(Collections::emptyList)
// .stream()
// .map(AbstractPropertyView::flattenProperties)
// .flatMap(Function.identity());
// }
// }
// Path: core/presentation/src/main/java/org/hesperides/core/presentation/io/templatecontainers/PropertyOutput.java
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.*;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Value;
import org.hesperides.core.domain.templatecontainers.queries.AbstractPropertyView;
import org.hesperides.core.domain.templatecontainers.queries.IterablePropertyView;
import org.hesperides.core.domain.templatecontainers.queries.PropertyView;
import java.lang.reflect.Type;
import java.util.*;
import java.util.stream.Collectors;
jsonObject.remove("fields");
if (src.getProperties() != null) {
// Cas d'une propriété itérable : seuls les champs "name" & "fields" ont du sens
JsonArray jsonArray = new JsonArray();
for (PropertyOutput propertyOutput : src.getProperties()) {
jsonArray.add(context.serialize(propertyOutput, PropertyOutput.class));
}
jsonObject.add("fields", jsonArray);
jsonObject.remove("required");
jsonObject.remove("comment");
jsonObject.remove("defaultValue");
jsonObject.remove("pattern");
jsonObject.remove("password");
}
return jsonObject;
}
}
PropertyOutput(AbstractPropertyView abstractPropertyView) {
this.name = abstractPropertyView.getName();
if (abstractPropertyView instanceof PropertyView) {
final PropertyView propertyView = (PropertyView) abstractPropertyView;
this.isRequired = propertyView.isRequired();
this.comment = propertyView.getComment();
this.defaultValue = propertyView.getDefaultValue();
this.pattern = propertyView.getPattern();
this.isPassword = propertyView.isPassword();
this.properties = null;
|
} else if (abstractPropertyView instanceof IterablePropertyView) {
|
voyages-sncf-technologies/hesperides
|
core/infrastructure/src/main/java/org/hesperides/core/infrastructure/mongo/technos/TechnoDocument.java
|
// Path: core/domain/src/main/java/org/hesperides/core/domain/technos/entities/Techno.java
// @Value
// @EqualsAndHashCode(callSuper = true)
// public class Techno extends TemplateContainer {
//
// public Techno(TemplateContainer.Key key, List<Template> templates) {
// super(key, templates);
// }
//
// public static List<String> getTemplatesName(List<Techno> technos) {
// return Optional.ofNullable(technos)
// .orElseGet(Collections::emptyList)
// .stream()
// .map(TemplateContainer::getTemplatesName)
// .flatMap(List::stream)
// .collect(Collectors.toList());
// }
//
// public static class Key extends TemplateContainer.Key {
//
// private static final String URI_PREFIX = "/templates/packages";
// private static final String NAMESPACE_PREFIX = "packages";
// private static final String TOSTRING_PREFIX = "techno";
//
// public Key(String name, String version, VersionType versionType) {
// super(name, version, versionType);
// }
//
// public Key(TemplateContainerKeyView key) {
// super(key.getName(), key.getVersion(), TemplateContainer.getVersionType(key.getIsWorkingCopy()));
// }
//
// public static List<Key> fromViews(List<TemplateContainerKeyView> keys) {
// return Optional.ofNullable(keys)
// .orElse(Collections.emptyList())
// .stream()
// .map(Key::new)
// .collect(Collectors.toList());
// }
//
// @Override
// protected String getUriPrefix() {
// return URI_PREFIX;
// }
//
// @Override
// protected String getNamespacePrefix() {
// return NAMESPACE_PREFIX;
// }
//
// public String toString() {
// return TOSTRING_PREFIX + super.toString();
// }
// }
// }
|
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static org.hesperides.core.infrastructure.mongo.Collections.TECHNO;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hesperides.core.domain.technos.entities.Techno;
import org.hesperides.core.domain.technos.queries.TechnoView;
import org.hesperides.core.domain.templatecontainers.entities.AbstractProperty;
import org.hesperides.core.domain.templatecontainers.entities.Template;
import org.hesperides.core.domain.templatecontainers.entities.TemplateContainer;
import org.hesperides.core.infrastructure.mongo.templatecontainers.AbstractPropertyDocument;
import org.hesperides.core.infrastructure.mongo.templatecontainers.KeyDocument;
import org.hesperides.core.infrastructure.mongo.templatecontainers.TemplateDocument;
|
/*
*
* This file is part of the Hesperides distribution.
* (https://github.com/voyages-sncf-technologies/hesperides)
* Copyright (c) 2016 VSCT.
*
* Hesperides is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, version 3.
*
* Hesperides 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 for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
package org.hesperides.core.infrastructure.mongo.technos;
@Data
@Document(collection = TECHNO)
@NoArgsConstructor
public class TechnoDocument {
@Id
private String id;
private KeyDocument key;
private List<TemplateDocument> templates;
private List<AbstractPropertyDocument> properties;
|
// Path: core/domain/src/main/java/org/hesperides/core/domain/technos/entities/Techno.java
// @Value
// @EqualsAndHashCode(callSuper = true)
// public class Techno extends TemplateContainer {
//
// public Techno(TemplateContainer.Key key, List<Template> templates) {
// super(key, templates);
// }
//
// public static List<String> getTemplatesName(List<Techno> technos) {
// return Optional.ofNullable(technos)
// .orElseGet(Collections::emptyList)
// .stream()
// .map(TemplateContainer::getTemplatesName)
// .flatMap(List::stream)
// .collect(Collectors.toList());
// }
//
// public static class Key extends TemplateContainer.Key {
//
// private static final String URI_PREFIX = "/templates/packages";
// private static final String NAMESPACE_PREFIX = "packages";
// private static final String TOSTRING_PREFIX = "techno";
//
// public Key(String name, String version, VersionType versionType) {
// super(name, version, versionType);
// }
//
// public Key(TemplateContainerKeyView key) {
// super(key.getName(), key.getVersion(), TemplateContainer.getVersionType(key.getIsWorkingCopy()));
// }
//
// public static List<Key> fromViews(List<TemplateContainerKeyView> keys) {
// return Optional.ofNullable(keys)
// .orElse(Collections.emptyList())
// .stream()
// .map(Key::new)
// .collect(Collectors.toList());
// }
//
// @Override
// protected String getUriPrefix() {
// return URI_PREFIX;
// }
//
// @Override
// protected String getNamespacePrefix() {
// return NAMESPACE_PREFIX;
// }
//
// public String toString() {
// return TOSTRING_PREFIX + super.toString();
// }
// }
// }
// Path: core/infrastructure/src/main/java/org/hesperides/core/infrastructure/mongo/technos/TechnoDocument.java
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static org.hesperides.core.infrastructure.mongo.Collections.TECHNO;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hesperides.core.domain.technos.entities.Techno;
import org.hesperides.core.domain.technos.queries.TechnoView;
import org.hesperides.core.domain.templatecontainers.entities.AbstractProperty;
import org.hesperides.core.domain.templatecontainers.entities.Template;
import org.hesperides.core.domain.templatecontainers.entities.TemplateContainer;
import org.hesperides.core.infrastructure.mongo.templatecontainers.AbstractPropertyDocument;
import org.hesperides.core.infrastructure.mongo.templatecontainers.KeyDocument;
import org.hesperides.core.infrastructure.mongo.templatecontainers.TemplateDocument;
/*
*
* This file is part of the Hesperides distribution.
* (https://github.com/voyages-sncf-technologies/hesperides)
* Copyright (c) 2016 VSCT.
*
* Hesperides is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, version 3.
*
* Hesperides 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 for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
package org.hesperides.core.infrastructure.mongo.technos;
@Data
@Document(collection = TECHNO)
@NoArgsConstructor
public class TechnoDocument {
@Id
private String id;
private KeyDocument key;
private List<TemplateDocument> templates;
private List<AbstractPropertyDocument> properties;
|
TechnoDocument(String id, Techno techno) {
|
voyages-sncf-technologies/hesperides
|
tests/bdd/src/main/java/org/hesperides/test/bdd/events/EventClient.java
|
// Path: core/presentation/src/main/java/org/hesperides/core/presentation/io/events/EventOutput.java
// @Value
// public class EventOutput {
//
// String type;
// Long timestamp;
// String user;
// Object data;
//
// public EventOutput(EventView view) {
// this.type = view.getType();
// this.timestamp = view.getTimestamp().getEpochSecond();
// this.user = view.getData().getUser();
// this.data = getEventData(view.getData());
// }
//
// /*
// * For legacy retro-compatibility, look for usage of event.data in: https://github.com/voyages-sncf-technologies/hesperides-gui/tree/master/src/app/event/directives
// */
// private static Object getEventData(final UserEvent userEvent) {
// if (userEvent instanceof ModuleCreatedEvent) {
// return new ModuleCreatedEventIO((ModuleCreatedEvent) userEvent);
// }
// if (userEvent instanceof TemplateCreatedEvent) {
// return new TemplateCreatedEventIO((TemplateCreatedEvent) userEvent);
// }
// if (userEvent instanceof TemplateUpdatedEvent) {
// return new TemplateUpdatedEventIO((TemplateUpdatedEvent) userEvent);
// }
// // For TemplateDeletedEvent, only field used by legacy front is .templateName, so we pass through the event
// // For many other events (ModuleTechnosUpdatedEvent, techno events...) legacy front was totally bogus and used .platform.platform_name...
// return userEvent;
// }
// }
|
import org.hesperides.core.presentation.io.ModuleIO;
import org.hesperides.core.presentation.io.events.EventOutput;
import org.hesperides.core.presentation.io.platforms.PlatformIO;
import org.hesperides.test.bdd.templatecontainers.TestVersionType;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import static org.hesperides.test.bdd.commons.TestContext.getResponseType;
|
/*
*
* This file is part of the Hesperides distribution.
* (https://github.com/voyages-sncf-technologies/hesperides)
* Copyright (c) 2016 VSCT.
*
* Hesperides is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, version 3.
*
* Hesperides 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 for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
package org.hesperides.test.bdd.events;
@Component
public class EventClient {
private final RestTemplate restTemplate;
public EventClient(RestTemplate restTemplate) {
this.restTemplate = restTemplate;
}
void getModuleEvents(ModuleIO moduleInput, String tryTo) {
restTemplate.getForEntity("/events/modules/{name}/{version}/{type}",
|
// Path: core/presentation/src/main/java/org/hesperides/core/presentation/io/events/EventOutput.java
// @Value
// public class EventOutput {
//
// String type;
// Long timestamp;
// String user;
// Object data;
//
// public EventOutput(EventView view) {
// this.type = view.getType();
// this.timestamp = view.getTimestamp().getEpochSecond();
// this.user = view.getData().getUser();
// this.data = getEventData(view.getData());
// }
//
// /*
// * For legacy retro-compatibility, look for usage of event.data in: https://github.com/voyages-sncf-technologies/hesperides-gui/tree/master/src/app/event/directives
// */
// private static Object getEventData(final UserEvent userEvent) {
// if (userEvent instanceof ModuleCreatedEvent) {
// return new ModuleCreatedEventIO((ModuleCreatedEvent) userEvent);
// }
// if (userEvent instanceof TemplateCreatedEvent) {
// return new TemplateCreatedEventIO((TemplateCreatedEvent) userEvent);
// }
// if (userEvent instanceof TemplateUpdatedEvent) {
// return new TemplateUpdatedEventIO((TemplateUpdatedEvent) userEvent);
// }
// // For TemplateDeletedEvent, only field used by legacy front is .templateName, so we pass through the event
// // For many other events (ModuleTechnosUpdatedEvent, techno events...) legacy front was totally bogus and used .platform.platform_name...
// return userEvent;
// }
// }
// Path: tests/bdd/src/main/java/org/hesperides/test/bdd/events/EventClient.java
import org.hesperides.core.presentation.io.ModuleIO;
import org.hesperides.core.presentation.io.events.EventOutput;
import org.hesperides.core.presentation.io.platforms.PlatformIO;
import org.hesperides.test.bdd.templatecontainers.TestVersionType;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import static org.hesperides.test.bdd.commons.TestContext.getResponseType;
/*
*
* This file is part of the Hesperides distribution.
* (https://github.com/voyages-sncf-technologies/hesperides)
* Copyright (c) 2016 VSCT.
*
* Hesperides is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, version 3.
*
* Hesperides 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 for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
package org.hesperides.test.bdd.events;
@Component
public class EventClient {
private final RestTemplate restTemplate;
public EventClient(RestTemplate restTemplate) {
this.restTemplate = restTemplate;
}
void getModuleEvents(ModuleIO moduleInput, String tryTo) {
restTemplate.getForEntity("/events/modules/{name}/{version}/{type}",
|
getResponseType(tryTo, EventOutput[].class),
|
voyages-sncf-technologies/hesperides
|
tests/bdd/src/main/java/org/hesperides/test/bdd/platforms/PlatformClient.java
|
// Path: core/presentation/src/main/java/org/hesperides/core/presentation/io/platforms/properties/PropertiesIO.java
// @Value
// @AllArgsConstructor
// public class PropertiesIO {
//
// // Annotation @NotNull à remettre en place lorsque le support d'un payload
// // json sans properties_version_id sera officiellement arrêté
// @SerializedName("properties_version_id")
// @JsonProperty("properties_version_id")
// @Valid
// Long propertiesVersionId;
//
// @NotNull
// @SerializedName("key_value_properties")
// @JsonProperty("key_value_properties")
// @Valid
// Set<ValuedPropertyIO> valuedProperties;
//
// @NotNull
// @SerializedName("iterable_properties")
// @JsonProperty("iterable_properties")
// @Valid
// Set<IterableValuedPropertyIO> iterableValuedProperties;
//
// public List<AbstractValuedProperty> toDomainInstances() {
// List<ValuedProperty> valuedProperties = ValuedPropertyIO.toDomainInstances(this.valuedProperties);
// List<IterableValuedProperty> iterableValuedProperties = IterableValuedPropertyIO.toDomainInstances(this.iterableValuedProperties);
// List<AbstractValuedProperty> properties = new ArrayList<>();
// properties.addAll(valuedProperties);
// properties.addAll(iterableValuedProperties);
// return properties;
// }
//
// public PropertiesIO(Long propertiesVersionId, List<AbstractValuedPropertyView> abstractValuedPropertyViews) {
// this.propertiesVersionId = propertiesVersionId;
// List<ValuedPropertyView> valuedPropertyViews = AbstractValuedPropertyView.getAbstractValuedPropertyViewWithType(abstractValuedPropertyViews, ValuedPropertyView.class);
// valuedProperties = ValuedPropertyIO.fromValuedPropertyViews(valuedPropertyViews);
// List<IterableValuedPropertyView> iterableValuedPropertyViews = AbstractValuedPropertyView.getAbstractValuedPropertyViewWithType(abstractValuedPropertyViews, IterableValuedPropertyView.class);
// iterableValuedProperties = IterableValuedPropertyIO.fromIterableValuedPropertyViews(iterableValuedPropertyViews);
// }
//
// // On initialise le propertiesVersionId dans le cas ou il n'est pas fourni (le temps de repassé l'attribut en @NotNull)
// public Long getPropertiesVersionId() {
// return propertiesVersionId != null ? propertiesVersionId : DeployedModule.INIT_PROPERTIES_VERSION_ID;
// }
// }
|
import org.apache.commons.lang3.StringUtils;
import org.hesperides.core.presentation.io.ModuleIO;
import org.hesperides.core.presentation.io.platforms.*;
import org.hesperides.core.presentation.io.platforms.properties.GlobalPropertyUsageOutput;
import org.hesperides.core.presentation.io.platforms.properties.PlatformDetailedPropertiesOutput;
import org.hesperides.core.presentation.io.platforms.properties.PropertiesIO;
import org.hesperides.core.presentation.io.platforms.properties.PropertySearchResultOutput;
import org.hesperides.core.presentation.io.platforms.properties.diff.PropertiesDiffOutput;
import org.hesperides.test.bdd.commons.TestContext;
import org.hesperides.test.bdd.configuration.CustomRestTemplate;
import org.hesperides.test.bdd.templatecontainers.TestVersionType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.Set;
import static org.hesperides.test.bdd.commons.TestContext.getResponseType;
|
String url = "/applications/platforms/perform_search?applicationName=" + applicationName;
if (StringUtils.isNotBlank(platformName)) {
url += "&platformName=" + platformName;
}
restTemplate.postForEntity(
url,
null,
getResponseType(tryTo, SearchResultOutput[].class));
}
public InstancesModelOutput getInstancesModel(PlatformIO platform, String propertiesPath) {
restTemplate.getForEntity(
"/applications/{application_name}/platforms/{platform_name}/properties/instance_model?path={path}",
InstancesModelOutput.class,
platform.getApplicationName(),
platform.getPlatformName(),
propertiesPath);
return testContext.getResponseBody();
}
public void cleanUnusedProperties(PlatformIO platformInput, String propertiesPath, String tryTo) {
restTemplate.deleteForEntity(
"/applications/{application_name}/platforms/{platform_name}/properties/clean_unused_properties?properties_path={path}",
getResponseType(tryTo, Void.class),
platformInput.getApplicationName(),
platformInput.getPlatformName(),
propertiesPath
);
}
|
// Path: core/presentation/src/main/java/org/hesperides/core/presentation/io/platforms/properties/PropertiesIO.java
// @Value
// @AllArgsConstructor
// public class PropertiesIO {
//
// // Annotation @NotNull à remettre en place lorsque le support d'un payload
// // json sans properties_version_id sera officiellement arrêté
// @SerializedName("properties_version_id")
// @JsonProperty("properties_version_id")
// @Valid
// Long propertiesVersionId;
//
// @NotNull
// @SerializedName("key_value_properties")
// @JsonProperty("key_value_properties")
// @Valid
// Set<ValuedPropertyIO> valuedProperties;
//
// @NotNull
// @SerializedName("iterable_properties")
// @JsonProperty("iterable_properties")
// @Valid
// Set<IterableValuedPropertyIO> iterableValuedProperties;
//
// public List<AbstractValuedProperty> toDomainInstances() {
// List<ValuedProperty> valuedProperties = ValuedPropertyIO.toDomainInstances(this.valuedProperties);
// List<IterableValuedProperty> iterableValuedProperties = IterableValuedPropertyIO.toDomainInstances(this.iterableValuedProperties);
// List<AbstractValuedProperty> properties = new ArrayList<>();
// properties.addAll(valuedProperties);
// properties.addAll(iterableValuedProperties);
// return properties;
// }
//
// public PropertiesIO(Long propertiesVersionId, List<AbstractValuedPropertyView> abstractValuedPropertyViews) {
// this.propertiesVersionId = propertiesVersionId;
// List<ValuedPropertyView> valuedPropertyViews = AbstractValuedPropertyView.getAbstractValuedPropertyViewWithType(abstractValuedPropertyViews, ValuedPropertyView.class);
// valuedProperties = ValuedPropertyIO.fromValuedPropertyViews(valuedPropertyViews);
// List<IterableValuedPropertyView> iterableValuedPropertyViews = AbstractValuedPropertyView.getAbstractValuedPropertyViewWithType(abstractValuedPropertyViews, IterableValuedPropertyView.class);
// iterableValuedProperties = IterableValuedPropertyIO.fromIterableValuedPropertyViews(iterableValuedPropertyViews);
// }
//
// // On initialise le propertiesVersionId dans le cas ou il n'est pas fourni (le temps de repassé l'attribut en @NotNull)
// public Long getPropertiesVersionId() {
// return propertiesVersionId != null ? propertiesVersionId : DeployedModule.INIT_PROPERTIES_VERSION_ID;
// }
// }
// Path: tests/bdd/src/main/java/org/hesperides/test/bdd/platforms/PlatformClient.java
import org.apache.commons.lang3.StringUtils;
import org.hesperides.core.presentation.io.ModuleIO;
import org.hesperides.core.presentation.io.platforms.*;
import org.hesperides.core.presentation.io.platforms.properties.GlobalPropertyUsageOutput;
import org.hesperides.core.presentation.io.platforms.properties.PlatformDetailedPropertiesOutput;
import org.hesperides.core.presentation.io.platforms.properties.PropertiesIO;
import org.hesperides.core.presentation.io.platforms.properties.PropertySearchResultOutput;
import org.hesperides.core.presentation.io.platforms.properties.diff.PropertiesDiffOutput;
import org.hesperides.test.bdd.commons.TestContext;
import org.hesperides.test.bdd.configuration.CustomRestTemplate;
import org.hesperides.test.bdd.templatecontainers.TestVersionType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.Set;
import static org.hesperides.test.bdd.commons.TestContext.getResponseType;
String url = "/applications/platforms/perform_search?applicationName=" + applicationName;
if (StringUtils.isNotBlank(platformName)) {
url += "&platformName=" + platformName;
}
restTemplate.postForEntity(
url,
null,
getResponseType(tryTo, SearchResultOutput[].class));
}
public InstancesModelOutput getInstancesModel(PlatformIO platform, String propertiesPath) {
restTemplate.getForEntity(
"/applications/{application_name}/platforms/{platform_name}/properties/instance_model?path={path}",
InstancesModelOutput.class,
platform.getApplicationName(),
platform.getPlatformName(),
propertiesPath);
return testContext.getResponseBody();
}
public void cleanUnusedProperties(PlatformIO platformInput, String propertiesPath, String tryTo) {
restTemplate.deleteForEntity(
"/applications/{application_name}/platforms/{platform_name}/properties/clean_unused_properties?properties_path={path}",
getResponseType(tryTo, Void.class),
platformInput.getApplicationName(),
platformInput.getPlatformName(),
propertiesPath
);
}
|
public void saveGlobalProperties(PlatformIO platform, PropertiesIO propertiesInput) {
|
voyages-sncf-technologies/hesperides
|
core/presentation/src/main/java/org/hesperides/core/presentation/controllers/PropertiesController.java
|
// Path: core/presentation/src/main/java/org/hesperides/core/presentation/io/platforms/PropertiesEventOutput.java
// @Value
// public class PropertiesEventOutput {
// Long timestamp;
// String author;
// String comment;
// @SerializedName("added_properties")
// List<ValuedPropertyOutput> addedProperties;
// @SerializedName("updated_properties")
// List<UpdatedPropertyOutput> updatedProperties;
// @SerializedName("removed_properties")
// List<ValuedPropertyOutput> removedProperties;
//
// public static List<PropertiesEventOutput> fromViews(List<PropertiesEventView> views) {
// return views.stream()
// .map(PropertiesEventOutput::new)
// .collect(Collectors.toList());
// }
//
// public PropertiesEventOutput(PropertiesEventView view) {
// timestamp = view.getTimestamp().toEpochMilli();
// author = view.getAuthor();
// comment = view.getComment();
// addedProperties = ValuedPropertyOutput.fromViews(view.getAddedProperties());
// updatedProperties = UpdatedPropertyOutput.fromViews(view.getUpdatedProperties());
// removedProperties = ValuedPropertyOutput.fromViews(view.getRemovedProperties());
// }
//
// @Value
// @AllArgsConstructor
// public static class ValuedPropertyOutput {
// String name;
// String value;
//
// public static List<ValuedPropertyOutput> fromViews(List<ValuedPropertyView> views) {
// return views.stream()
// .map(ValuedPropertyOutput::new)
// .collect(Collectors.toList());
// }
//
// public ValuedPropertyOutput(ValuedPropertyView view) {
// this.name = view.getName();
// this.value = view.getValue();
// }
// }
//
// @Value
// @AllArgsConstructor
// public static class UpdatedPropertyOutput {
// String name;
// @SerializedName("old_value")
// String oldValue;
// @SerializedName("new_value")
// String newValue;
//
// public static List<UpdatedPropertyOutput> fromViews(List<UpdatedPropertyView> views) {
// return views.stream()
// .map(UpdatedPropertyOutput::new)
// .collect(Collectors.toList());
// }
//
// public UpdatedPropertyOutput(UpdatedPropertyView view) {
// this.name = view.getName();
// this.oldValue = view.getOldValue();
// this.newValue = view.getNewValue();
// }
// }
// }
|
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.hesperides.core.application.platforms.PlatformUseCases;
import org.hesperides.core.application.platforms.PropertiesUseCases;
import org.hesperides.core.domain.platforms.entities.Platform;
import org.hesperides.core.domain.platforms.entities.properties.AbstractValuedProperty;
import org.hesperides.core.domain.platforms.entities.properties.diff.PropertiesDiff;
import org.hesperides.core.domain.platforms.queries.views.PropertiesEventView;
import org.hesperides.core.domain.platforms.queries.views.properties.*;
import org.hesperides.core.domain.security.entities.User;
import org.hesperides.core.presentation.io.platforms.InstancesModelOutput;
import org.hesperides.core.presentation.io.platforms.PropertiesEventOutput;
import org.hesperides.core.presentation.io.platforms.properties.*;
import org.hesperides.core.presentation.io.platforms.properties.diff.PropertiesDiffOutput;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.hesperides.core.domain.platforms.entities.properties.diff.PropertiesDiff.ComparisonMode;
|
Platform.Key platformKey = new Platform.Key(applicationName, platformName);
User authenticatedUser = new User(authentication);
if (StringUtils.isEmpty(propertiesPath)) {
// tous les modules
platformUseCases.getPlatform(platformKey).findActiveDeployedModules()
.forEach(module -> propertiesUseCases.purgeUnusedProperties(platformKey, module.getPropertiesPath(), authenticatedUser));
} else {
// un seul module
propertiesUseCases.purgeUnusedProperties(platformKey, propertiesPath, authenticatedUser);
}
return ResponseEntity.noContent().build();
}
@ApiOperation("Get detailed properties of a platform or a deployed module")
@GetMapping("/{application_name}/platforms/{platform_name}/detailed_properties")
public ResponseEntity<PlatformDetailedPropertiesOutput> getDetailedProperties(Authentication authentication,
@PathVariable("application_name") final String applicationName,
@PathVariable("platform_name") final String platformName,
@RequestParam(value = "properties_path", required = false) final String propertiesPath) {
Platform.Key platformKey = new Platform.Key(applicationName, platformName);
User user = new User(authentication);
PlatformDetailedPropertiesView platformDetailedPropertiesView = propertiesUseCases.getDetailedProperties(platformKey, propertiesPath, user);
PlatformDetailedPropertiesOutput platformDetailedPropertiesOutput = new PlatformDetailedPropertiesOutput(platformDetailedPropertiesView);
return ResponseEntity.ok(platformDetailedPropertiesOutput);
}
@ApiOperation("Get the history of raw values for module properties or global properties")
@GetMapping("/{application_name}/platforms/{platform_name:.+}/properties/events")
|
// Path: core/presentation/src/main/java/org/hesperides/core/presentation/io/platforms/PropertiesEventOutput.java
// @Value
// public class PropertiesEventOutput {
// Long timestamp;
// String author;
// String comment;
// @SerializedName("added_properties")
// List<ValuedPropertyOutput> addedProperties;
// @SerializedName("updated_properties")
// List<UpdatedPropertyOutput> updatedProperties;
// @SerializedName("removed_properties")
// List<ValuedPropertyOutput> removedProperties;
//
// public static List<PropertiesEventOutput> fromViews(List<PropertiesEventView> views) {
// return views.stream()
// .map(PropertiesEventOutput::new)
// .collect(Collectors.toList());
// }
//
// public PropertiesEventOutput(PropertiesEventView view) {
// timestamp = view.getTimestamp().toEpochMilli();
// author = view.getAuthor();
// comment = view.getComment();
// addedProperties = ValuedPropertyOutput.fromViews(view.getAddedProperties());
// updatedProperties = UpdatedPropertyOutput.fromViews(view.getUpdatedProperties());
// removedProperties = ValuedPropertyOutput.fromViews(view.getRemovedProperties());
// }
//
// @Value
// @AllArgsConstructor
// public static class ValuedPropertyOutput {
// String name;
// String value;
//
// public static List<ValuedPropertyOutput> fromViews(List<ValuedPropertyView> views) {
// return views.stream()
// .map(ValuedPropertyOutput::new)
// .collect(Collectors.toList());
// }
//
// public ValuedPropertyOutput(ValuedPropertyView view) {
// this.name = view.getName();
// this.value = view.getValue();
// }
// }
//
// @Value
// @AllArgsConstructor
// public static class UpdatedPropertyOutput {
// String name;
// @SerializedName("old_value")
// String oldValue;
// @SerializedName("new_value")
// String newValue;
//
// public static List<UpdatedPropertyOutput> fromViews(List<UpdatedPropertyView> views) {
// return views.stream()
// .map(UpdatedPropertyOutput::new)
// .collect(Collectors.toList());
// }
//
// public UpdatedPropertyOutput(UpdatedPropertyView view) {
// this.name = view.getName();
// this.oldValue = view.getOldValue();
// this.newValue = view.getNewValue();
// }
// }
// }
// Path: core/presentation/src/main/java/org/hesperides/core/presentation/controllers/PropertiesController.java
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.hesperides.core.application.platforms.PlatformUseCases;
import org.hesperides.core.application.platforms.PropertiesUseCases;
import org.hesperides.core.domain.platforms.entities.Platform;
import org.hesperides.core.domain.platforms.entities.properties.AbstractValuedProperty;
import org.hesperides.core.domain.platforms.entities.properties.diff.PropertiesDiff;
import org.hesperides.core.domain.platforms.queries.views.PropertiesEventView;
import org.hesperides.core.domain.platforms.queries.views.properties.*;
import org.hesperides.core.domain.security.entities.User;
import org.hesperides.core.presentation.io.platforms.InstancesModelOutput;
import org.hesperides.core.presentation.io.platforms.PropertiesEventOutput;
import org.hesperides.core.presentation.io.platforms.properties.*;
import org.hesperides.core.presentation.io.platforms.properties.diff.PropertiesDiffOutput;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.hesperides.core.domain.platforms.entities.properties.diff.PropertiesDiff.ComparisonMode;
Platform.Key platformKey = new Platform.Key(applicationName, platformName);
User authenticatedUser = new User(authentication);
if (StringUtils.isEmpty(propertiesPath)) {
// tous les modules
platformUseCases.getPlatform(platformKey).findActiveDeployedModules()
.forEach(module -> propertiesUseCases.purgeUnusedProperties(platformKey, module.getPropertiesPath(), authenticatedUser));
} else {
// un seul module
propertiesUseCases.purgeUnusedProperties(platformKey, propertiesPath, authenticatedUser);
}
return ResponseEntity.noContent().build();
}
@ApiOperation("Get detailed properties of a platform or a deployed module")
@GetMapping("/{application_name}/platforms/{platform_name}/detailed_properties")
public ResponseEntity<PlatformDetailedPropertiesOutput> getDetailedProperties(Authentication authentication,
@PathVariable("application_name") final String applicationName,
@PathVariable("platform_name") final String platformName,
@RequestParam(value = "properties_path", required = false) final String propertiesPath) {
Platform.Key platformKey = new Platform.Key(applicationName, platformName);
User user = new User(authentication);
PlatformDetailedPropertiesView platformDetailedPropertiesView = propertiesUseCases.getDetailedProperties(platformKey, propertiesPath, user);
PlatformDetailedPropertiesOutput platformDetailedPropertiesOutput = new PlatformDetailedPropertiesOutput(platformDetailedPropertiesView);
return ResponseEntity.ok(platformDetailedPropertiesOutput);
}
@ApiOperation("Get the history of raw values for module properties or global properties")
@GetMapping("/{application_name}/platforms/{platform_name:.+}/properties/events")
|
public ResponseEntity<List<PropertiesEventOutput>> getPropertiesEvents(Authentication authentication,
|
voyages-sncf-technologies/hesperides
|
core/infrastructure/src/main/java/org/hesperides/core/infrastructure/mongo/modules/ModuleDocument.java
|
// Path: core/infrastructure/src/main/java/org/hesperides/core/infrastructure/mongo/technos/TechnoDocument.java
// @Data
// @Document(collection = TECHNO)
// @NoArgsConstructor
// public class TechnoDocument {
// @Id
// private String id;
// private KeyDocument key;
// private List<TemplateDocument> templates;
// private List<AbstractPropertyDocument> properties;
//
// TechnoDocument(String id, Techno techno) {
// this.id = id;
// this.key = new KeyDocument(techno.getKey());
// this.templates = TemplateDocument.fromDomainInstances(techno.getTemplates());
// }
//
// public static List<TechnoView> toTechnoViews(List<TechnoDocument> technos) {
// return Optional.ofNullable(technos)
// .orElseGet(Collections::emptyList)
// .stream()
// .map(TechnoDocument::toTechnoView)
// .collect(Collectors.toList());
// }
//
// public static List<Techno> toDomainInstances(List<TechnoDocument> technoDocuments) {
// return Optional.ofNullable(technoDocuments)
// .orElseGet(Collections::emptyList)
// .stream()
// .map(TechnoDocument::toDomainInstance)
// .collect(Collectors.toList());
// }
//
// public Techno toDomainInstance() {
// TemplateContainer.Key technoKey = getDomainKey();
// return new Techno(
// technoKey,
// TemplateDocument.toDomainInstances(templates, technoKey)
// );
// }
//
// TechnoView toTechnoView() {
// TemplateContainer.Key technoKey = getDomainKey();
// return new TechnoView(key.getName(), key.getVersion(), key.isWorkingCopy(),
// TemplateDocument.toTemplateViews(templates, technoKey));
// }
//
// public void addTemplate(TemplateDocument templateDocument) {
// if (templates == null) {
// templates = new ArrayList<>();
// }
// templates.add(templateDocument);
// }
//
// public void updateTemplate(TemplateDocument updatedTemplateDocument) {
// removeTemplate(updatedTemplateDocument.getName());
// addTemplate(updatedTemplateDocument);
// }
//
// void removeTemplate(String templateName) {
// templates.removeIf(templateDocument -> templateDocument.getName().equalsIgnoreCase(templateName));
// }
//
// void extractPropertiesAndSave(MongoTechnoRepository technoRepository) {
// this.setProperties(extractPropertiesFromTemplates());
// technoRepository.save(this);
// }
//
// private List<AbstractPropertyDocument> extractPropertiesFromTemplates() {
// TemplateContainer.Key technoKey = getDomainKey();
// List<Template> templates = TemplateDocument.toDomainInstances(this.templates, technoKey);
// List<AbstractProperty> abstractProperties = AbstractProperty.extractPropertiesFromTemplates(templates, key.toString());
// return AbstractPropertyDocument.fromDomainInstances(abstractProperties);
// }
//
// Techno.Key getDomainKey() {
// return new Techno.Key(key.getName(), key.getVersion(), TemplateContainer.getVersionType(key.isWorkingCopy()));
// }
// }
|
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hesperides.core.domain.modules.entities.Module;
import org.hesperides.core.domain.modules.queries.ModulePasswordProperties;
import org.hesperides.core.domain.modules.queries.ModulePropertiesView;
import org.hesperides.core.domain.modules.queries.ModuleView;
import org.hesperides.core.domain.templatecontainers.entities.AbstractProperty;
import org.hesperides.core.domain.templatecontainers.entities.Template;
import org.hesperides.core.domain.templatecontainers.entities.TemplateContainer;
import org.hesperides.core.infrastructure.mongo.technos.TechnoDocument;
import org.hesperides.core.infrastructure.mongo.templatecontainers.AbstractPropertyDocument;
import org.hesperides.core.infrastructure.mongo.templatecontainers.KeyDocument;
import org.hesperides.core.infrastructure.mongo.templatecontainers.PropertyDocument;
import org.hesperides.core.infrastructure.mongo.templatecontainers.TemplateDocument;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.*;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.toSet;
import static org.hesperides.core.infrastructure.mongo.Collections.MODULE;
|
package org.hesperides.core.infrastructure.mongo.modules;
@Data
@Document(collection = MODULE)
@NoArgsConstructor
public class ModuleDocument {
@Id
private String id;
private KeyDocument key;
private List<TemplateDocument> templates;
@DBRef
|
// Path: core/infrastructure/src/main/java/org/hesperides/core/infrastructure/mongo/technos/TechnoDocument.java
// @Data
// @Document(collection = TECHNO)
// @NoArgsConstructor
// public class TechnoDocument {
// @Id
// private String id;
// private KeyDocument key;
// private List<TemplateDocument> templates;
// private List<AbstractPropertyDocument> properties;
//
// TechnoDocument(String id, Techno techno) {
// this.id = id;
// this.key = new KeyDocument(techno.getKey());
// this.templates = TemplateDocument.fromDomainInstances(techno.getTemplates());
// }
//
// public static List<TechnoView> toTechnoViews(List<TechnoDocument> technos) {
// return Optional.ofNullable(technos)
// .orElseGet(Collections::emptyList)
// .stream()
// .map(TechnoDocument::toTechnoView)
// .collect(Collectors.toList());
// }
//
// public static List<Techno> toDomainInstances(List<TechnoDocument> technoDocuments) {
// return Optional.ofNullable(technoDocuments)
// .orElseGet(Collections::emptyList)
// .stream()
// .map(TechnoDocument::toDomainInstance)
// .collect(Collectors.toList());
// }
//
// public Techno toDomainInstance() {
// TemplateContainer.Key technoKey = getDomainKey();
// return new Techno(
// technoKey,
// TemplateDocument.toDomainInstances(templates, technoKey)
// );
// }
//
// TechnoView toTechnoView() {
// TemplateContainer.Key technoKey = getDomainKey();
// return new TechnoView(key.getName(), key.getVersion(), key.isWorkingCopy(),
// TemplateDocument.toTemplateViews(templates, technoKey));
// }
//
// public void addTemplate(TemplateDocument templateDocument) {
// if (templates == null) {
// templates = new ArrayList<>();
// }
// templates.add(templateDocument);
// }
//
// public void updateTemplate(TemplateDocument updatedTemplateDocument) {
// removeTemplate(updatedTemplateDocument.getName());
// addTemplate(updatedTemplateDocument);
// }
//
// void removeTemplate(String templateName) {
// templates.removeIf(templateDocument -> templateDocument.getName().equalsIgnoreCase(templateName));
// }
//
// void extractPropertiesAndSave(MongoTechnoRepository technoRepository) {
// this.setProperties(extractPropertiesFromTemplates());
// technoRepository.save(this);
// }
//
// private List<AbstractPropertyDocument> extractPropertiesFromTemplates() {
// TemplateContainer.Key technoKey = getDomainKey();
// List<Template> templates = TemplateDocument.toDomainInstances(this.templates, technoKey);
// List<AbstractProperty> abstractProperties = AbstractProperty.extractPropertiesFromTemplates(templates, key.toString());
// return AbstractPropertyDocument.fromDomainInstances(abstractProperties);
// }
//
// Techno.Key getDomainKey() {
// return new Techno.Key(key.getName(), key.getVersion(), TemplateContainer.getVersionType(key.isWorkingCopy()));
// }
// }
// Path: core/infrastructure/src/main/java/org/hesperides/core/infrastructure/mongo/modules/ModuleDocument.java
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hesperides.core.domain.modules.entities.Module;
import org.hesperides.core.domain.modules.queries.ModulePasswordProperties;
import org.hesperides.core.domain.modules.queries.ModulePropertiesView;
import org.hesperides.core.domain.modules.queries.ModuleView;
import org.hesperides.core.domain.templatecontainers.entities.AbstractProperty;
import org.hesperides.core.domain.templatecontainers.entities.Template;
import org.hesperides.core.domain.templatecontainers.entities.TemplateContainer;
import org.hesperides.core.infrastructure.mongo.technos.TechnoDocument;
import org.hesperides.core.infrastructure.mongo.templatecontainers.AbstractPropertyDocument;
import org.hesperides.core.infrastructure.mongo.templatecontainers.KeyDocument;
import org.hesperides.core.infrastructure.mongo.templatecontainers.PropertyDocument;
import org.hesperides.core.infrastructure.mongo.templatecontainers.TemplateDocument;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.*;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.toSet;
import static org.hesperides.core.infrastructure.mongo.Collections.MODULE;
package org.hesperides.core.infrastructure.mongo.modules;
@Data
@Document(collection = MODULE)
@NoArgsConstructor
public class ModuleDocument {
@Id
private String id;
private KeyDocument key;
private List<TemplateDocument> templates;
@DBRef
|
private List<TechnoDocument> technos;
|
voyages-sncf-technologies/hesperides
|
core/infrastructure/src/main/java/org/hesperides/core/infrastructure/security/groups/LdapSearchContext.java
|
// Path: core/domain/src/main/java/org/hesperides/core/domain/security/entities/springauthorities/DirectoryGroupDN.java
// public class DirectoryGroupDN implements GrantedAuthority {
//
// private final String authority;
//
// public DirectoryGroupDN(String authority) {
// this.authority = authority;
// }
//
// @Override
// public String getAuthority() {
// return authority;
// }
//
// public static String extractCnFromDn(String dn) {
// String cn = null;
// try {
// LdapName ldapName = new LdapName(dn);
// for (Rdn rdn : ldapName.getRdns()) {
// if (rdn.getType().equalsIgnoreCase("CN")) {
// cn = (String) rdn.getValue();
// }
// }
// } catch (InvalidNameException e) {
// throw new IllegalArgumentException("Invalid DN: " + dn, e);
// }
// if (cn == null) {
// throw new IllegalArgumentException("Can't find CN in DN: " + dn);
// }
// return cn;
// }
// }
//
// Path: core/infrastructure/src/main/java/org/hesperides/core/infrastructure/security/LdapConfiguration.java
// @Profile(LDAP)
// @Component
// @ConfigurationProperties(prefix = "ldap")
// @Getter
// @Setter
// @Validated
// public class LdapConfiguration {
// @NotEmpty
// private String url;
//
// private String domain;
//
// private String bindDn;
//
// private String bindPassword;
// @NotEmpty
// private String userSearchBase;
// @NotEmpty
// private String roleSearchBase;
// @NotEmpty
// private String usernameAttribute;
// @NotEmpty
// private String connectTimeout;
// @NotEmpty
// private String readTimeout;
// @NotEmpty
// private String prodGroupDN;
// @NotEmpty
// private String techGroupDN;
//
// public String getSearchFilterForCN(String username) {
// return String.format("(%s=%s)", usernameAttribute, username);
// }
// }
|
import com.evanlennick.retry4j.CallExecutor;
import com.evanlennick.retry4j.CallExecutorBuilder;
import com.evanlennick.retry4j.config.RetryConfig;
import com.evanlennick.retry4j.exception.RetriesExhaustedException;
import com.evanlennick.retry4j.exception.UnexpectedException;
import com.google.gson.Gson;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Timer;
import lombok.extern.slf4j.Slf4j;
import org.hesperides.core.domain.security.entities.springauthorities.DirectoryGroupDN;
import org.hesperides.core.infrastructure.security.LdapConfiguration;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.ldap.core.DirContextOperations;
import org.springframework.ldap.core.support.DefaultDirObjectFactory;
import org.springframework.ldap.support.LdapUtils;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.core.SpringSecurityMessageSource;
import org.springframework.security.ldap.SpringSecurityLdapTemplate;
import javax.naming.*;
import javax.naming.directory.*;
import javax.naming.ldap.InitialLdapContext;
import java.util.*;
import java.util.function.Supplier;
|
package org.hesperides.core.infrastructure.security.groups;
/*
* Wrapper around javax.naming.* & org.springframework.ldap.* classes & logic,
* with logging, metrics & retrying.
*
* IMPORTANT: instances of this class must be manually closed
* at the end of their lifespan by calling .closeContext() on them.
*/
@Slf4j
public class LdapSearchContext implements ParentGroupsDNRetriever {
private final String username;
private final String password;
|
// Path: core/domain/src/main/java/org/hesperides/core/domain/security/entities/springauthorities/DirectoryGroupDN.java
// public class DirectoryGroupDN implements GrantedAuthority {
//
// private final String authority;
//
// public DirectoryGroupDN(String authority) {
// this.authority = authority;
// }
//
// @Override
// public String getAuthority() {
// return authority;
// }
//
// public static String extractCnFromDn(String dn) {
// String cn = null;
// try {
// LdapName ldapName = new LdapName(dn);
// for (Rdn rdn : ldapName.getRdns()) {
// if (rdn.getType().equalsIgnoreCase("CN")) {
// cn = (String) rdn.getValue();
// }
// }
// } catch (InvalidNameException e) {
// throw new IllegalArgumentException("Invalid DN: " + dn, e);
// }
// if (cn == null) {
// throw new IllegalArgumentException("Can't find CN in DN: " + dn);
// }
// return cn;
// }
// }
//
// Path: core/infrastructure/src/main/java/org/hesperides/core/infrastructure/security/LdapConfiguration.java
// @Profile(LDAP)
// @Component
// @ConfigurationProperties(prefix = "ldap")
// @Getter
// @Setter
// @Validated
// public class LdapConfiguration {
// @NotEmpty
// private String url;
//
// private String domain;
//
// private String bindDn;
//
// private String bindPassword;
// @NotEmpty
// private String userSearchBase;
// @NotEmpty
// private String roleSearchBase;
// @NotEmpty
// private String usernameAttribute;
// @NotEmpty
// private String connectTimeout;
// @NotEmpty
// private String readTimeout;
// @NotEmpty
// private String prodGroupDN;
// @NotEmpty
// private String techGroupDN;
//
// public String getSearchFilterForCN(String username) {
// return String.format("(%s=%s)", usernameAttribute, username);
// }
// }
// Path: core/infrastructure/src/main/java/org/hesperides/core/infrastructure/security/groups/LdapSearchContext.java
import com.evanlennick.retry4j.CallExecutor;
import com.evanlennick.retry4j.CallExecutorBuilder;
import com.evanlennick.retry4j.config.RetryConfig;
import com.evanlennick.retry4j.exception.RetriesExhaustedException;
import com.evanlennick.retry4j.exception.UnexpectedException;
import com.google.gson.Gson;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Timer;
import lombok.extern.slf4j.Slf4j;
import org.hesperides.core.domain.security.entities.springauthorities.DirectoryGroupDN;
import org.hesperides.core.infrastructure.security.LdapConfiguration;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.ldap.core.DirContextOperations;
import org.springframework.ldap.core.support.DefaultDirObjectFactory;
import org.springframework.ldap.support.LdapUtils;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.core.SpringSecurityMessageSource;
import org.springframework.security.ldap.SpringSecurityLdapTemplate;
import javax.naming.*;
import javax.naming.directory.*;
import javax.naming.ldap.InitialLdapContext;
import java.util.*;
import java.util.function.Supplier;
package org.hesperides.core.infrastructure.security.groups;
/*
* Wrapper around javax.naming.* & org.springframework.ldap.* classes & logic,
* with logging, metrics & retrying.
*
* IMPORTANT: instances of this class must be manually closed
* at the end of their lifespan by calling .closeContext() on them.
*/
@Slf4j
public class LdapSearchContext implements ParentGroupsDNRetriever {
private final String username;
private final String password;
|
private final LdapConfiguration ldapConfiguration;
|
voyages-sncf-technologies/hesperides
|
core/infrastructure/src/main/java/org/hesperides/core/infrastructure/security/groups/LdapSearchContext.java
|
// Path: core/domain/src/main/java/org/hesperides/core/domain/security/entities/springauthorities/DirectoryGroupDN.java
// public class DirectoryGroupDN implements GrantedAuthority {
//
// private final String authority;
//
// public DirectoryGroupDN(String authority) {
// this.authority = authority;
// }
//
// @Override
// public String getAuthority() {
// return authority;
// }
//
// public static String extractCnFromDn(String dn) {
// String cn = null;
// try {
// LdapName ldapName = new LdapName(dn);
// for (Rdn rdn : ldapName.getRdns()) {
// if (rdn.getType().equalsIgnoreCase("CN")) {
// cn = (String) rdn.getValue();
// }
// }
// } catch (InvalidNameException e) {
// throw new IllegalArgumentException("Invalid DN: " + dn, e);
// }
// if (cn == null) {
// throw new IllegalArgumentException("Can't find CN in DN: " + dn);
// }
// return cn;
// }
// }
//
// Path: core/infrastructure/src/main/java/org/hesperides/core/infrastructure/security/LdapConfiguration.java
// @Profile(LDAP)
// @Component
// @ConfigurationProperties(prefix = "ldap")
// @Getter
// @Setter
// @Validated
// public class LdapConfiguration {
// @NotEmpty
// private String url;
//
// private String domain;
//
// private String bindDn;
//
// private String bindPassword;
// @NotEmpty
// private String userSearchBase;
// @NotEmpty
// private String roleSearchBase;
// @NotEmpty
// private String usernameAttribute;
// @NotEmpty
// private String connectTimeout;
// @NotEmpty
// private String readTimeout;
// @NotEmpty
// private String prodGroupDN;
// @NotEmpty
// private String techGroupDN;
//
// public String getSearchFilterForCN(String username) {
// return String.format("(%s=%s)", usernameAttribute, username);
// }
// }
|
import com.evanlennick.retry4j.CallExecutor;
import com.evanlennick.retry4j.CallExecutorBuilder;
import com.evanlennick.retry4j.config.RetryConfig;
import com.evanlennick.retry4j.exception.RetriesExhaustedException;
import com.evanlennick.retry4j.exception.UnexpectedException;
import com.google.gson.Gson;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Timer;
import lombok.extern.slf4j.Slf4j;
import org.hesperides.core.domain.security.entities.springauthorities.DirectoryGroupDN;
import org.hesperides.core.infrastructure.security.LdapConfiguration;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.ldap.core.DirContextOperations;
import org.springframework.ldap.core.support.DefaultDirObjectFactory;
import org.springframework.ldap.support.LdapUtils;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.core.SpringSecurityMessageSource;
import org.springframework.security.ldap.SpringSecurityLdapTemplate;
import javax.naming.*;
import javax.naming.directory.*;
import javax.naming.ldap.InitialLdapContext;
import java.util.*;
import java.util.function.Supplier;
|
else{
if (ldapConfiguration.getDomain() != null && !ldapConfiguration.getDomain().isEmpty()){
env.put(Context.SECURITY_PRINCIPAL, String.format("%s\\%s", ldapConfiguration.getDomain(), username));
}
else{
env.put(Context.SECURITY_PRINCIPAL, username);
}
env.put(Context.SECURITY_CREDENTIALS, password);
}
try {
DirContext dirContext = new InitialLdapContext(env, null);
// ici dirContext ne contient que des infos relatives au serveur avec lequel la connexion vient d'être établie
if (log.isDebugEnabled()) { // on évite ce traitement si ce n'est pas nécessaire
log.debug("[buildSearchContext] dirContext: {}", gson.toJson(attributesToNative(dirContext.getAttributes("").getAll())));
}
return dirContext;
} catch (AuthenticationException | OperationNotSupportedException cause) {
throw new BadCredentialsException(messages.getMessage(
"LdapAuthenticationProvider.badCredentials", "Bad credentials"), cause);
} catch (NamingException e) {
log.error(e.getExplanation() + (e.getCause() != null ? (" : " + e.getCause().getMessage()) : ""));
throw LdapUtils.convertLdapException(e);
}
}
public HashSet<String> retrieveParentGroupDNs(String dn) {
HashSet<String> parentGroupDNs = new HashSet<>();
try {
|
// Path: core/domain/src/main/java/org/hesperides/core/domain/security/entities/springauthorities/DirectoryGroupDN.java
// public class DirectoryGroupDN implements GrantedAuthority {
//
// private final String authority;
//
// public DirectoryGroupDN(String authority) {
// this.authority = authority;
// }
//
// @Override
// public String getAuthority() {
// return authority;
// }
//
// public static String extractCnFromDn(String dn) {
// String cn = null;
// try {
// LdapName ldapName = new LdapName(dn);
// for (Rdn rdn : ldapName.getRdns()) {
// if (rdn.getType().equalsIgnoreCase("CN")) {
// cn = (String) rdn.getValue();
// }
// }
// } catch (InvalidNameException e) {
// throw new IllegalArgumentException("Invalid DN: " + dn, e);
// }
// if (cn == null) {
// throw new IllegalArgumentException("Can't find CN in DN: " + dn);
// }
// return cn;
// }
// }
//
// Path: core/infrastructure/src/main/java/org/hesperides/core/infrastructure/security/LdapConfiguration.java
// @Profile(LDAP)
// @Component
// @ConfigurationProperties(prefix = "ldap")
// @Getter
// @Setter
// @Validated
// public class LdapConfiguration {
// @NotEmpty
// private String url;
//
// private String domain;
//
// private String bindDn;
//
// private String bindPassword;
// @NotEmpty
// private String userSearchBase;
// @NotEmpty
// private String roleSearchBase;
// @NotEmpty
// private String usernameAttribute;
// @NotEmpty
// private String connectTimeout;
// @NotEmpty
// private String readTimeout;
// @NotEmpty
// private String prodGroupDN;
// @NotEmpty
// private String techGroupDN;
//
// public String getSearchFilterForCN(String username) {
// return String.format("(%s=%s)", usernameAttribute, username);
// }
// }
// Path: core/infrastructure/src/main/java/org/hesperides/core/infrastructure/security/groups/LdapSearchContext.java
import com.evanlennick.retry4j.CallExecutor;
import com.evanlennick.retry4j.CallExecutorBuilder;
import com.evanlennick.retry4j.config.RetryConfig;
import com.evanlennick.retry4j.exception.RetriesExhaustedException;
import com.evanlennick.retry4j.exception.UnexpectedException;
import com.google.gson.Gson;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Timer;
import lombok.extern.slf4j.Slf4j;
import org.hesperides.core.domain.security.entities.springauthorities.DirectoryGroupDN;
import org.hesperides.core.infrastructure.security.LdapConfiguration;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.ldap.core.DirContextOperations;
import org.springframework.ldap.core.support.DefaultDirObjectFactory;
import org.springframework.ldap.support.LdapUtils;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.core.SpringSecurityMessageSource;
import org.springframework.security.ldap.SpringSecurityLdapTemplate;
import javax.naming.*;
import javax.naming.directory.*;
import javax.naming.ldap.InitialLdapContext;
import java.util.*;
import java.util.function.Supplier;
else{
if (ldapConfiguration.getDomain() != null && !ldapConfiguration.getDomain().isEmpty()){
env.put(Context.SECURITY_PRINCIPAL, String.format("%s\\%s", ldapConfiguration.getDomain(), username));
}
else{
env.put(Context.SECURITY_PRINCIPAL, username);
}
env.put(Context.SECURITY_CREDENTIALS, password);
}
try {
DirContext dirContext = new InitialLdapContext(env, null);
// ici dirContext ne contient que des infos relatives au serveur avec lequel la connexion vient d'être établie
if (log.isDebugEnabled()) { // on évite ce traitement si ce n'est pas nécessaire
log.debug("[buildSearchContext] dirContext: {}", gson.toJson(attributesToNative(dirContext.getAttributes("").getAll())));
}
return dirContext;
} catch (AuthenticationException | OperationNotSupportedException cause) {
throw new BadCredentialsException(messages.getMessage(
"LdapAuthenticationProvider.badCredentials", "Bad credentials"), cause);
} catch (NamingException e) {
log.error(e.getExplanation() + (e.getCause() != null ? (" : " + e.getCause().getMessage()) : ""));
throw LdapUtils.convertLdapException(e);
}
}
public HashSet<String> retrieveParentGroupDNs(String dn) {
HashSet<String> parentGroupDNs = new HashSet<>();
try {
|
String cn = DirectoryGroupDN.extractCnFromDn(dn);
|
DosMike/VillagerShops
|
src/main/java/de/dosmike/sponge/vshop/Utilities.java
|
// Path: src/main/java/de/dosmike/sponge/vshop/systems/pluginfilter/FilterResolutionException.java
// public class FilterResolutionException extends Exception {
//
// public FilterResolutionException() {
// }
//
// public FilterResolutionException(String message) {
// super(message);
// }
//
// public FilterResolutionException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public FilterResolutionException(Throwable cause) {
// super(cause);
// }
// }
|
import com.flowpowered.math.TrigMath;
import com.flowpowered.math.vector.Vector3d;
import de.dosmike.sponge.megamenus.impl.RenderManager;
import de.dosmike.sponge.vshop.systems.pluginfilter.FilterResolutionException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.data.DataQuery;
import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.living.player.User;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.service.economy.Currency;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
import org.spongepowered.api.world.extent.Extent;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.*;
import java.util.stream.Collectors;
|
package de.dosmike.sponge.vshop;
public class Utilities {
/**
* to prevent bugs from spamming actions, we'll use this to lock any actions
* until 1 tick after the inventory handler finished
*/
public static final Set<UUID> actionUnstack = new HashSet<>();
/**
* remembers what player is viewing what shop as Player <-> Shop mapping
*/
static final Map<UUID, UUID> openShops = new HashMap<>();
public static @Nullable UUID getOpenShopFor(Player player) {
return openShops.get(player.getUniqueId());
}
public static void _openShops_remove(Player player) {
openShops.remove(player.getUniqueId());
}
public static void _openShops_add(Player player, UUID shopID) {
openShops.put(player.getUniqueId(), shopID);
}
public static void redrawAllShopMenus(@NotNull ItemStack withItem) {
//get all shops that have the specified item in their listing
// Im doing this first, because shops can be opened by multiple players
// and I don't want to test shops twice for performance
Set<UUID> prefilteredShops = openShops.values().stream()
.unordered().distinct()
.filter(uuid -> VillagerShops.getShopFromShopId(uuid)
.map(se -> se.getMenu().getAllItems().stream().anyMatch(si -> {
try {
return si.test(withItem);
|
// Path: src/main/java/de/dosmike/sponge/vshop/systems/pluginfilter/FilterResolutionException.java
// public class FilterResolutionException extends Exception {
//
// public FilterResolutionException() {
// }
//
// public FilterResolutionException(String message) {
// super(message);
// }
//
// public FilterResolutionException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public FilterResolutionException(Throwable cause) {
// super(cause);
// }
// }
// Path: src/main/java/de/dosmike/sponge/vshop/Utilities.java
import com.flowpowered.math.TrigMath;
import com.flowpowered.math.vector.Vector3d;
import de.dosmike.sponge.megamenus.impl.RenderManager;
import de.dosmike.sponge.vshop.systems.pluginfilter.FilterResolutionException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.data.DataQuery;
import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.living.player.User;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.service.economy.Currency;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
import org.spongepowered.api.world.extent.Extent;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.*;
import java.util.stream.Collectors;
package de.dosmike.sponge.vshop;
public class Utilities {
/**
* to prevent bugs from spamming actions, we'll use this to lock any actions
* until 1 tick after the inventory handler finished
*/
public static final Set<UUID> actionUnstack = new HashSet<>();
/**
* remembers what player is viewing what shop as Player <-> Shop mapping
*/
static final Map<UUID, UUID> openShops = new HashMap<>();
public static @Nullable UUID getOpenShopFor(Player player) {
return openShops.get(player.getUniqueId());
}
public static void _openShops_remove(Player player) {
openShops.remove(player.getUniqueId());
}
public static void _openShops_add(Player player, UUID shopID) {
openShops.put(player.getUniqueId(), shopID);
}
public static void redrawAllShopMenus(@NotNull ItemStack withItem) {
//get all shops that have the specified item in their listing
// Im doing this first, because shops can be opened by multiple players
// and I don't want to test shops twice for performance
Set<UUID> prefilteredShops = openShops.values().stream()
.unordered().distinct()
.filter(uuid -> VillagerShops.getShopFromShopId(uuid)
.map(se -> se.getMenu().getAllItems().stream().anyMatch(si -> {
try {
return si.test(withItem);
|
} catch (FilterResolutionException e) {
|
DosMike/VillagerShops
|
src/main/java/de/dosmike/sponge/vshop/systems/pluginfilter/DummyItemFilter.java
|
// Path: src/main/java/de/dosmike/sponge/vshop/systems/ShopType.java
// public enum ShopType {
// PlayerShop,
// AdminShop;
//
// public static ShopType fromInstance(ShopEntity shop) {
// return shop.getShopOwner().isPresent() ? PlayerShop : AdminShop;
// }
//
// public static ShopType fromInternalFlag(boolean shopTypeFlag) {
// return shopTypeFlag ? AdminShop : PlayerShop;
// }
// }
|
import de.dosmike.sponge.vshop.systems.ShopType;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import java.util.Optional;
|
package de.dosmike.sponge.vshop.systems.pluginfilter;
public class DummyItemFilter implements PluginItemFilter {
String itemId;
private DummyItemFilter() {}
private DummyItemFilter(String itemId) { this.itemId = itemId; }
public static DummyItemFilter of(String pluginItemId) {
return new DummyItemFilter(pluginItemId);
}
public PluginItemFilter get() throws FilterResolutionException {
return PluginItemServiceImpl.getItemFilter(itemId).orElseThrow(()->new FilterResolutionException("Plugin Item Filter for ID "+itemId+" is no longer provided!"));
}
@Override
public String toString() {
return itemId;
}
@Override
public boolean isItem(ItemStack item) {
throw new IllegalStateException("Dummy Filter was not resolved");
}
@Override
|
// Path: src/main/java/de/dosmike/sponge/vshop/systems/ShopType.java
// public enum ShopType {
// PlayerShop,
// AdminShop;
//
// public static ShopType fromInstance(ShopEntity shop) {
// return shop.getShopOwner().isPresent() ? PlayerShop : AdminShop;
// }
//
// public static ShopType fromInternalFlag(boolean shopTypeFlag) {
// return shopTypeFlag ? AdminShop : PlayerShop;
// }
// }
// Path: src/main/java/de/dosmike/sponge/vshop/systems/pluginfilter/DummyItemFilter.java
import de.dosmike.sponge.vshop.systems.ShopType;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import java.util.Optional;
package de.dosmike.sponge.vshop.systems.pluginfilter;
public class DummyItemFilter implements PluginItemFilter {
String itemId;
private DummyItemFilter() {}
private DummyItemFilter(String itemId) { this.itemId = itemId; }
public static DummyItemFilter of(String pluginItemId) {
return new DummyItemFilter(pluginItemId);
}
public PluginItemFilter get() throws FilterResolutionException {
return PluginItemServiceImpl.getItemFilter(itemId).orElseThrow(()->new FilterResolutionException("Plugin Item Filter for ID "+itemId+" is no longer provided!"));
}
@Override
public String toString() {
return itemId;
}
@Override
public boolean isItem(ItemStack item) {
throw new IllegalStateException("Dummy Filter was not resolved");
}
@Override
|
public ItemStack supply(int amount, ShopType shopType) {
|
DosMike/VillagerShops
|
src/main/java/de/dosmike/sponge/vshop/systems/pluginfilter/PluginItemFilter.java
|
// Path: src/main/java/de/dosmike/sponge/vshop/systems/ShopType.java
// public enum ShopType {
// PlayerShop,
// AdminShop;
//
// public static ShopType fromInstance(ShopEntity shop) {
// return shop.getShopOwner().isPresent() ? PlayerShop : AdminShop;
// }
//
// public static ShopType fromInternalFlag(boolean shopTypeFlag) {
// return shopTypeFlag ? AdminShop : PlayerShop;
// }
// }
|
import de.dosmike.sponge.vshop.systems.ShopType;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.inventory.Inventory;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.item.inventory.Slot;
import java.util.Optional;
|
package de.dosmike.sponge.vshop.systems.pluginfilter;
public interface PluginItemFilter {
/**
* Used to filter {@link Slot}s out of an {@link Inventory}. Don't forget to check basic properties like
* {@link ItemType} here!
*
* @return true if item represents an item of this filter-type
*/
boolean isItem(ItemStack item);
/**
* Can be used to enforce the use of this PluginItemFilter for items.
*
* @return true if this filter should automatically set in place, if an added item matched isItem()
*/
@SuppressWarnings("SameReturnValue")
default boolean enforce() {
return false;
}
/**
* If you want to block this item from being resold by players or admin shops you can use this
* to prevent the item from being added to a shop (or sold, if you change this later)
*
* @param shopType the type of shop this item is currently listed in
* @return true if the item can be added to this shop
*/
@SuppressWarnings({"SameReturnValue"})
|
// Path: src/main/java/de/dosmike/sponge/vshop/systems/ShopType.java
// public enum ShopType {
// PlayerShop,
// AdminShop;
//
// public static ShopType fromInstance(ShopEntity shop) {
// return shop.getShopOwner().isPresent() ? PlayerShop : AdminShop;
// }
//
// public static ShopType fromInternalFlag(boolean shopTypeFlag) {
// return shopTypeFlag ? AdminShop : PlayerShop;
// }
// }
// Path: src/main/java/de/dosmike/sponge/vshop/systems/pluginfilter/PluginItemFilter.java
import de.dosmike.sponge.vshop.systems.ShopType;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.inventory.Inventory;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.item.inventory.Slot;
import java.util.Optional;
package de.dosmike.sponge.vshop.systems.pluginfilter;
public interface PluginItemFilter {
/**
* Used to filter {@link Slot}s out of an {@link Inventory}. Don't forget to check basic properties like
* {@link ItemType} here!
*
* @return true if item represents an item of this filter-type
*/
boolean isItem(ItemStack item);
/**
* Can be used to enforce the use of this PluginItemFilter for items.
*
* @return true if this filter should automatically set in place, if an added item matched isItem()
*/
@SuppressWarnings("SameReturnValue")
default boolean enforce() {
return false;
}
/**
* If you want to block this item from being resold by players or admin shops you can use this
* to prevent the item from being added to a shop (or sold, if you change this later)
*
* @param shopType the type of shop this item is currently listed in
* @return true if the item can be added to this shop
*/
@SuppressWarnings({"SameReturnValue"})
|
default boolean supportShopType(ShopType shopType) {
|
DosMike/VillagerShops
|
src/main/java/de/dosmike/sponge/vshop/integrations/crateplugins/KeysFilterProvider.java
|
// Path: src/main/java/de/dosmike/sponge/vshop/systems/pluginfilter/PluginItemService.java
// public interface PluginItemService {
//
// /**
// * Register an {@link PluginItemFilter} for your plugin.
// * Registering filters has to happen before VillagerShop tries to load shops. Shops
// * are loaded with worlds, so the latest possible event for registering would be
// * {@link GameLoadCompleteEvent}. It's recommended to register the filters directly
// * within {@link ChangeServiceProviderEvent}
// *
// * @param pluginItemId a custom id you specify for your item. e.g.: myplugin:votekey
// * @param filter the ItemFilter handling this item
// */
// void registerItemFilter(String pluginItemId, PluginItemFilter filter);
//
// /**
// * Remove an {@link PluginItemFilter} by it's id.
// *
// * @param pluginItemId the id of the filter to remove
// */
// void unregisterItemFilter(String pluginItemId);
//
// }
|
import de.dosmike.sponge.vshop.systems.pluginfilter.PluginItemService;
import org.spongepowered.api.GameState;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.event.game.state.GameInitializationEvent;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
|
package de.dosmike.sponge.vshop.integrations.crateplugins;
public interface KeysFilterProvider {
/**
* Core to super optional dependency:<br>
* Tries to get the ClaimAccess instance from the classloader.
* On failure it creates a new Default provider.
* <br><br>
* Doing it this way makes this class not quite know about the dependency.
* And the ClassLoader will not attempt to look into the dependency unless the wrapper
* is constructed for the first time.
* <br><br>
* This method should only be called once in {@link GameInitializationEvent}
*/
static Collection<KeysFilterProvider> scan() {
assert Sponge.getGame().getState().ordinal() >= GameState.INITIALIZATION.ordinal()
: "Dependent services might not be registered yet!";
Set<KeysFilterProvider> kfp = new HashSet<>();
try {
Class.forName("com.codehusky.huskycrates.HuskyCrates");
kfp.add(new HuskyCrateKeys());
} catch (Throwable dependencyError) {
}
return kfp;
}
|
// Path: src/main/java/de/dosmike/sponge/vshop/systems/pluginfilter/PluginItemService.java
// public interface PluginItemService {
//
// /**
// * Register an {@link PluginItemFilter} for your plugin.
// * Registering filters has to happen before VillagerShop tries to load shops. Shops
// * are loaded with worlds, so the latest possible event for registering would be
// * {@link GameLoadCompleteEvent}. It's recommended to register the filters directly
// * within {@link ChangeServiceProviderEvent}
// *
// * @param pluginItemId a custom id you specify for your item. e.g.: myplugin:votekey
// * @param filter the ItemFilter handling this item
// */
// void registerItemFilter(String pluginItemId, PluginItemFilter filter);
//
// /**
// * Remove an {@link PluginItemFilter} by it's id.
// *
// * @param pluginItemId the id of the filter to remove
// */
// void unregisterItemFilter(String pluginItemId);
//
// }
// Path: src/main/java/de/dosmike/sponge/vshop/integrations/crateplugins/KeysFilterProvider.java
import de.dosmike.sponge.vshop.systems.pluginfilter.PluginItemService;
import org.spongepowered.api.GameState;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.event.game.state.GameInitializationEvent;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
package de.dosmike.sponge.vshop.integrations.crateplugins;
public interface KeysFilterProvider {
/**
* Core to super optional dependency:<br>
* Tries to get the ClaimAccess instance from the classloader.
* On failure it creates a new Default provider.
* <br><br>
* Doing it this way makes this class not quite know about the dependency.
* And the ClassLoader will not attempt to look into the dependency unless the wrapper
* is constructed for the first time.
* <br><br>
* This method should only be called once in {@link GameInitializationEvent}
*/
static Collection<KeysFilterProvider> scan() {
assert Sponge.getGame().getState().ordinal() >= GameState.INITIALIZATION.ordinal()
: "Dependent services might not be registered yet!";
Set<KeysFilterProvider> kfp = new HashSet<>();
try {
Class.forName("com.codehusky.huskycrates.HuskyCrates");
kfp.add(new HuskyCrateKeys());
} catch (Throwable dependencyError) {
}
return kfp;
}
|
default void updateFilters(PluginItemService pis) {
|
maxmind/GeoIP2-java
|
src/main/java/com/maxmind/geoip2/model/IspResponse.java
|
// Path: src/main/java/com/maxmind/geoip2/NetworkDeserializer.java
// public class NetworkDeserializer extends StdDeserializer<Network> {
//
// public NetworkDeserializer() {
// this(null);
// }
//
// public NetworkDeserializer(Class<?> vc) {
// super(vc);
// }
//
// @Override
// public Network deserialize(
// JsonParser jsonparser, DeserializationContext context)
// throws IOException {
//
// String cidr = jsonparser.getText();
// if (cidr == null) {
// return null;
// }
// String[] parts = cidr.split("/", 2);
// if (parts.length != 2) {
// throw new RuntimeException("Invalid cidr format: " + cidr);
// }
// int prefixLength = Integer.parseInt(parts[1]);
// try {
// return new Network(InetAddress.getByName(parts[0]), prefixLength);
// } catch (UnknownHostException e) {
// throw new RuntimeException(e);
// }
// }
// }
|
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.maxmind.db.MaxMindDbConstructor;
import com.maxmind.db.MaxMindDbParameter;
import com.maxmind.db.Network;
import com.maxmind.geoip2.NetworkDeserializer;
|
package com.maxmind.geoip2.model;
/**
* This class provides the GeoIP2 ISP model.
*/
public class IspResponse extends AsnResponse {
private final String isp;
private final String organization;
private final String mobileCountryCode;
private final String mobileNetworkCode;
@MaxMindDbConstructor
public IspResponse(
@JsonProperty("autonomous_system_number") @MaxMindDbParameter(name = "autonomous_system_number") Long autonomousSystemNumber,
@JsonProperty("autonomous_system_organization") @MaxMindDbParameter(name = "autonomous_system_organization") String autonomousSystemOrganization,
@JacksonInject("ip_address") @JsonProperty("ip_address") @MaxMindDbParameter(name = "ip_address") String ipAddress,
@JsonProperty("isp") @MaxMindDbParameter(name = "isp") String isp,
@JsonProperty("mobile_country_code") @MaxMindDbParameter(name = "mobile_country_code") String mobileCountryCode,
@JsonProperty("mobile_network_code") @MaxMindDbParameter(name = "mobile_network_code") String mobileNetworkCode,
@JsonProperty("organization") @MaxMindDbParameter(name = "organization") String organization,
|
// Path: src/main/java/com/maxmind/geoip2/NetworkDeserializer.java
// public class NetworkDeserializer extends StdDeserializer<Network> {
//
// public NetworkDeserializer() {
// this(null);
// }
//
// public NetworkDeserializer(Class<?> vc) {
// super(vc);
// }
//
// @Override
// public Network deserialize(
// JsonParser jsonparser, DeserializationContext context)
// throws IOException {
//
// String cidr = jsonparser.getText();
// if (cidr == null) {
// return null;
// }
// String[] parts = cidr.split("/", 2);
// if (parts.length != 2) {
// throw new RuntimeException("Invalid cidr format: " + cidr);
// }
// int prefixLength = Integer.parseInt(parts[1]);
// try {
// return new Network(InetAddress.getByName(parts[0]), prefixLength);
// } catch (UnknownHostException e) {
// throw new RuntimeException(e);
// }
// }
// }
// Path: src/main/java/com/maxmind/geoip2/model/IspResponse.java
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.maxmind.db.MaxMindDbConstructor;
import com.maxmind.db.MaxMindDbParameter;
import com.maxmind.db.Network;
import com.maxmind.geoip2.NetworkDeserializer;
package com.maxmind.geoip2.model;
/**
* This class provides the GeoIP2 ISP model.
*/
public class IspResponse extends AsnResponse {
private final String isp;
private final String organization;
private final String mobileCountryCode;
private final String mobileNetworkCode;
@MaxMindDbConstructor
public IspResponse(
@JsonProperty("autonomous_system_number") @MaxMindDbParameter(name = "autonomous_system_number") Long autonomousSystemNumber,
@JsonProperty("autonomous_system_organization") @MaxMindDbParameter(name = "autonomous_system_organization") String autonomousSystemOrganization,
@JacksonInject("ip_address") @JsonProperty("ip_address") @MaxMindDbParameter(name = "ip_address") String ipAddress,
@JsonProperty("isp") @MaxMindDbParameter(name = "isp") String isp,
@JsonProperty("mobile_country_code") @MaxMindDbParameter(name = "mobile_country_code") String mobileCountryCode,
@JsonProperty("mobile_network_code") @MaxMindDbParameter(name = "mobile_network_code") String mobileNetworkCode,
@JsonProperty("organization") @MaxMindDbParameter(name = "organization") String organization,
|
@JacksonInject("network") @JsonProperty("network") @JsonDeserialize(using = NetworkDeserializer.class) @MaxMindDbParameter(name = "network") Network network
|
maxmind/GeoIP2-java
|
src/main/java/com/maxmind/geoip2/model/ConnectionTypeResponse.java
|
// Path: src/main/java/com/maxmind/geoip2/NetworkDeserializer.java
// public class NetworkDeserializer extends StdDeserializer<Network> {
//
// public NetworkDeserializer() {
// this(null);
// }
//
// public NetworkDeserializer(Class<?> vc) {
// super(vc);
// }
//
// @Override
// public Network deserialize(
// JsonParser jsonparser, DeserializationContext context)
// throws IOException {
//
// String cidr = jsonparser.getText();
// if (cidr == null) {
// return null;
// }
// String[] parts = cidr.split("/", 2);
// if (parts.length != 2) {
// throw new RuntimeException("Invalid cidr format: " + cidr);
// }
// int prefixLength = Integer.parseInt(parts[1]);
// try {
// return new Network(InetAddress.getByName(parts[0]), prefixLength);
// } catch (UnknownHostException e) {
// throw new RuntimeException(e);
// }
// }
// }
|
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.maxmind.db.MaxMindDbConstructor;
import com.maxmind.db.MaxMindDbParameter;
import com.maxmind.db.Network;
import com.maxmind.geoip2.NetworkDeserializer;
|
return this.name;
}
public static ConnectionType fromString(String s) {
if (s == null) {
return null;
}
switch (s) {
case "Dialup":
return ConnectionType.DIALUP;
case "Cable/DSL":
return ConnectionType.CABLE_DSL;
case "Corporate":
return ConnectionType.CORPORATE;
case "Cellular":
return ConnectionType.CELLULAR;
default:
return null;
}
}
}
private final ConnectionType connectionType;
private final String ipAddress;
private final Network network;
public ConnectionTypeResponse(
@JsonProperty("connection_type") ConnectionType connectionType,
@JacksonInject("ip_address") @JsonProperty("ip_address") String ipAddress,
|
// Path: src/main/java/com/maxmind/geoip2/NetworkDeserializer.java
// public class NetworkDeserializer extends StdDeserializer<Network> {
//
// public NetworkDeserializer() {
// this(null);
// }
//
// public NetworkDeserializer(Class<?> vc) {
// super(vc);
// }
//
// @Override
// public Network deserialize(
// JsonParser jsonparser, DeserializationContext context)
// throws IOException {
//
// String cidr = jsonparser.getText();
// if (cidr == null) {
// return null;
// }
// String[] parts = cidr.split("/", 2);
// if (parts.length != 2) {
// throw new RuntimeException("Invalid cidr format: " + cidr);
// }
// int prefixLength = Integer.parseInt(parts[1]);
// try {
// return new Network(InetAddress.getByName(parts[0]), prefixLength);
// } catch (UnknownHostException e) {
// throw new RuntimeException(e);
// }
// }
// }
// Path: src/main/java/com/maxmind/geoip2/model/ConnectionTypeResponse.java
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.maxmind.db.MaxMindDbConstructor;
import com.maxmind.db.MaxMindDbParameter;
import com.maxmind.db.Network;
import com.maxmind.geoip2.NetworkDeserializer;
return this.name;
}
public static ConnectionType fromString(String s) {
if (s == null) {
return null;
}
switch (s) {
case "Dialup":
return ConnectionType.DIALUP;
case "Cable/DSL":
return ConnectionType.CABLE_DSL;
case "Corporate":
return ConnectionType.CORPORATE;
case "Cellular":
return ConnectionType.CELLULAR;
default:
return null;
}
}
}
private final ConnectionType connectionType;
private final String ipAddress;
private final Network network;
public ConnectionTypeResponse(
@JsonProperty("connection_type") ConnectionType connectionType,
@JacksonInject("ip_address") @JsonProperty("ip_address") String ipAddress,
|
@JacksonInject("network") @JsonProperty("network") @JsonDeserialize(using = NetworkDeserializer.class) Network network
|
maxmind/GeoIP2-java
|
src/main/java/com/maxmind/geoip2/model/DomainResponse.java
|
// Path: src/main/java/com/maxmind/geoip2/NetworkDeserializer.java
// public class NetworkDeserializer extends StdDeserializer<Network> {
//
// public NetworkDeserializer() {
// this(null);
// }
//
// public NetworkDeserializer(Class<?> vc) {
// super(vc);
// }
//
// @Override
// public Network deserialize(
// JsonParser jsonparser, DeserializationContext context)
// throws IOException {
//
// String cidr = jsonparser.getText();
// if (cidr == null) {
// return null;
// }
// String[] parts = cidr.split("/", 2);
// if (parts.length != 2) {
// throw new RuntimeException("Invalid cidr format: " + cidr);
// }
// int prefixLength = Integer.parseInt(parts[1]);
// try {
// return new Network(InetAddress.getByName(parts[0]), prefixLength);
// } catch (UnknownHostException e) {
// throw new RuntimeException(e);
// }
// }
// }
|
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.maxmind.db.MaxMindDbConstructor;
import com.maxmind.db.MaxMindDbParameter;
import com.maxmind.db.Network;
import com.maxmind.geoip2.NetworkDeserializer;
|
package com.maxmind.geoip2.model;
/**
* This class provides the GeoIP2 Domain model.
*/
public class DomainResponse extends AbstractResponse {
private final String domain;
private final String ipAddress;
private final Network network;
@MaxMindDbConstructor
public DomainResponse(
@JsonProperty("domain") @MaxMindDbParameter(name = "domain") String domain,
@JacksonInject("ip_address") @JsonProperty("ip_address") @MaxMindDbParameter(name = "ip_address") String ipAddress,
|
// Path: src/main/java/com/maxmind/geoip2/NetworkDeserializer.java
// public class NetworkDeserializer extends StdDeserializer<Network> {
//
// public NetworkDeserializer() {
// this(null);
// }
//
// public NetworkDeserializer(Class<?> vc) {
// super(vc);
// }
//
// @Override
// public Network deserialize(
// JsonParser jsonparser, DeserializationContext context)
// throws IOException {
//
// String cidr = jsonparser.getText();
// if (cidr == null) {
// return null;
// }
// String[] parts = cidr.split("/", 2);
// if (parts.length != 2) {
// throw new RuntimeException("Invalid cidr format: " + cidr);
// }
// int prefixLength = Integer.parseInt(parts[1]);
// try {
// return new Network(InetAddress.getByName(parts[0]), prefixLength);
// } catch (UnknownHostException e) {
// throw new RuntimeException(e);
// }
// }
// }
// Path: src/main/java/com/maxmind/geoip2/model/DomainResponse.java
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.maxmind.db.MaxMindDbConstructor;
import com.maxmind.db.MaxMindDbParameter;
import com.maxmind.db.Network;
import com.maxmind.geoip2.NetworkDeserializer;
package com.maxmind.geoip2.model;
/**
* This class provides the GeoIP2 Domain model.
*/
public class DomainResponse extends AbstractResponse {
private final String domain;
private final String ipAddress;
private final Network network;
@MaxMindDbConstructor
public DomainResponse(
@JsonProperty("domain") @MaxMindDbParameter(name = "domain") String domain,
@JacksonInject("ip_address") @JsonProperty("ip_address") @MaxMindDbParameter(name = "ip_address") String ipAddress,
|
@JacksonInject("network") @JsonProperty("network") @JsonDeserialize(using = NetworkDeserializer.class) @MaxMindDbParameter(name = "network") Network network
|
maxmind/GeoIP2-java
|
src/main/java/com/maxmind/geoip2/model/AnonymousIpResponse.java
|
// Path: src/main/java/com/maxmind/geoip2/NetworkDeserializer.java
// public class NetworkDeserializer extends StdDeserializer<Network> {
//
// public NetworkDeserializer() {
// this(null);
// }
//
// public NetworkDeserializer(Class<?> vc) {
// super(vc);
// }
//
// @Override
// public Network deserialize(
// JsonParser jsonparser, DeserializationContext context)
// throws IOException {
//
// String cidr = jsonparser.getText();
// if (cidr == null) {
// return null;
// }
// String[] parts = cidr.split("/", 2);
// if (parts.length != 2) {
// throw new RuntimeException("Invalid cidr format: " + cidr);
// }
// int prefixLength = Integer.parseInt(parts[1]);
// try {
// return new Network(InetAddress.getByName(parts[0]), prefixLength);
// } catch (UnknownHostException e) {
// throw new RuntimeException(e);
// }
// }
// }
|
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.maxmind.db.MaxMindDbConstructor;
import com.maxmind.db.MaxMindDbParameter;
import com.maxmind.db.Network;
import com.maxmind.geoip2.NetworkDeserializer;
|
package com.maxmind.geoip2.model;
/**
* This class provides the GeoIP2 Anonymous IP model.
*/
public class AnonymousIpResponse extends AbstractResponse {
private final boolean isAnonymous;
private final boolean isAnonymousVpn;
private final boolean isHostingProvider;
private final boolean isPublicProxy;
private final boolean isResidentialProxy;
private final boolean isTorExitNode;
private final String ipAddress;
private final Network network;
public AnonymousIpResponse(
@JacksonInject("ip_address") @JsonProperty("ip_address") String ipAddress,
@JsonProperty("is_anonymous") boolean isAnonymous,
@JsonProperty("is_anonymous_vpn") boolean isAnonymousVpn,
@JsonProperty("is_hosting_provider") boolean isHostingProvider,
@JsonProperty("is_public_proxy") boolean isPublicProxy,
@JsonProperty("is_residential_proxy") boolean isResidentialProxy,
@JsonProperty("is_tor_exit_node") boolean isTorExitNode,
|
// Path: src/main/java/com/maxmind/geoip2/NetworkDeserializer.java
// public class NetworkDeserializer extends StdDeserializer<Network> {
//
// public NetworkDeserializer() {
// this(null);
// }
//
// public NetworkDeserializer(Class<?> vc) {
// super(vc);
// }
//
// @Override
// public Network deserialize(
// JsonParser jsonparser, DeserializationContext context)
// throws IOException {
//
// String cidr = jsonparser.getText();
// if (cidr == null) {
// return null;
// }
// String[] parts = cidr.split("/", 2);
// if (parts.length != 2) {
// throw new RuntimeException("Invalid cidr format: " + cidr);
// }
// int prefixLength = Integer.parseInt(parts[1]);
// try {
// return new Network(InetAddress.getByName(parts[0]), prefixLength);
// } catch (UnknownHostException e) {
// throw new RuntimeException(e);
// }
// }
// }
// Path: src/main/java/com/maxmind/geoip2/model/AnonymousIpResponse.java
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.maxmind.db.MaxMindDbConstructor;
import com.maxmind.db.MaxMindDbParameter;
import com.maxmind.db.Network;
import com.maxmind.geoip2.NetworkDeserializer;
package com.maxmind.geoip2.model;
/**
* This class provides the GeoIP2 Anonymous IP model.
*/
public class AnonymousIpResponse extends AbstractResponse {
private final boolean isAnonymous;
private final boolean isAnonymousVpn;
private final boolean isHostingProvider;
private final boolean isPublicProxy;
private final boolean isResidentialProxy;
private final boolean isTorExitNode;
private final String ipAddress;
private final Network network;
public AnonymousIpResponse(
@JacksonInject("ip_address") @JsonProperty("ip_address") String ipAddress,
@JsonProperty("is_anonymous") boolean isAnonymous,
@JsonProperty("is_anonymous_vpn") boolean isAnonymousVpn,
@JsonProperty("is_hosting_provider") boolean isHostingProvider,
@JsonProperty("is_public_proxy") boolean isPublicProxy,
@JsonProperty("is_residential_proxy") boolean isResidentialProxy,
@JsonProperty("is_tor_exit_node") boolean isTorExitNode,
|
@JacksonInject("network") @JsonProperty("network") @JsonDeserialize(using = NetworkDeserializer.class) Network network
|
maxmind/GeoIP2-java
|
src/main/java/com/maxmind/geoip2/model/AsnResponse.java
|
// Path: src/main/java/com/maxmind/geoip2/NetworkDeserializer.java
// public class NetworkDeserializer extends StdDeserializer<Network> {
//
// public NetworkDeserializer() {
// this(null);
// }
//
// public NetworkDeserializer(Class<?> vc) {
// super(vc);
// }
//
// @Override
// public Network deserialize(
// JsonParser jsonparser, DeserializationContext context)
// throws IOException {
//
// String cidr = jsonparser.getText();
// if (cidr == null) {
// return null;
// }
// String[] parts = cidr.split("/", 2);
// if (parts.length != 2) {
// throw new RuntimeException("Invalid cidr format: " + cidr);
// }
// int prefixLength = Integer.parseInt(parts[1]);
// try {
// return new Network(InetAddress.getByName(parts[0]), prefixLength);
// } catch (UnknownHostException e) {
// throw new RuntimeException(e);
// }
// }
// }
|
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.maxmind.db.MaxMindDbConstructor;
import com.maxmind.db.MaxMindDbParameter;
import com.maxmind.db.Network;
import com.maxmind.geoip2.NetworkDeserializer;
|
package com.maxmind.geoip2.model;
/**
* This class provides the GeoLite2 ASN model.
*/
public class AsnResponse extends AbstractResponse {
private final Long autonomousSystemNumber;
private final String autonomousSystemOrganization;
private final String ipAddress;
private final Network network;
@MaxMindDbConstructor
public AsnResponse(
@JsonProperty("autonomous_system_number") @MaxMindDbParameter(name = "autonomous_system_number") Long autonomousSystemNumber,
@JsonProperty("autonomous_system_organization") @MaxMindDbParameter(name = "autonomous_system_organization") String autonomousSystemOrganization,
@JacksonInject("ip_address") @JsonProperty("ip_address") @MaxMindDbParameter(name = "ip_address") String ipAddress,
|
// Path: src/main/java/com/maxmind/geoip2/NetworkDeserializer.java
// public class NetworkDeserializer extends StdDeserializer<Network> {
//
// public NetworkDeserializer() {
// this(null);
// }
//
// public NetworkDeserializer(Class<?> vc) {
// super(vc);
// }
//
// @Override
// public Network deserialize(
// JsonParser jsonparser, DeserializationContext context)
// throws IOException {
//
// String cidr = jsonparser.getText();
// if (cidr == null) {
// return null;
// }
// String[] parts = cidr.split("/", 2);
// if (parts.length != 2) {
// throw new RuntimeException("Invalid cidr format: " + cidr);
// }
// int prefixLength = Integer.parseInt(parts[1]);
// try {
// return new Network(InetAddress.getByName(parts[0]), prefixLength);
// } catch (UnknownHostException e) {
// throw new RuntimeException(e);
// }
// }
// }
// Path: src/main/java/com/maxmind/geoip2/model/AsnResponse.java
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.maxmind.db.MaxMindDbConstructor;
import com.maxmind.db.MaxMindDbParameter;
import com.maxmind.db.Network;
import com.maxmind.geoip2.NetworkDeserializer;
package com.maxmind.geoip2.model;
/**
* This class provides the GeoLite2 ASN model.
*/
public class AsnResponse extends AbstractResponse {
private final Long autonomousSystemNumber;
private final String autonomousSystemOrganization;
private final String ipAddress;
private final Network network;
@MaxMindDbConstructor
public AsnResponse(
@JsonProperty("autonomous_system_number") @MaxMindDbParameter(name = "autonomous_system_number") Long autonomousSystemNumber,
@JsonProperty("autonomous_system_organization") @MaxMindDbParameter(name = "autonomous_system_organization") String autonomousSystemOrganization,
@JacksonInject("ip_address") @JsonProperty("ip_address") @MaxMindDbParameter(name = "ip_address") String ipAddress,
|
@JacksonInject("network") @JsonProperty("network") @JsonDeserialize(using = NetworkDeserializer.class) @MaxMindDbParameter(name = "network") Network network
|
maxmind/GeoIP2-java
|
src/main/java/com/maxmind/geoip2/WebServiceClient.java
|
// Path: src/main/java/com/maxmind/geoip2/model/CityResponse.java
// public final class CityResponse extends AbstractCityResponse {
// @MaxMindDbConstructor
// public CityResponse(
// @JsonProperty("city") @MaxMindDbParameter(name = "city") City city,
// @JsonProperty("continent") @MaxMindDbParameter(name = "continent") Continent continent,
// @JsonProperty("country") @MaxMindDbParameter(name = "country") Country country,
// @JsonProperty("location") @MaxMindDbParameter(name = "location") Location location,
// @JsonProperty("maxmind") @MaxMindDbParameter(name = "maxmind") MaxMind maxmind,
// @JsonProperty("postal") @MaxMindDbParameter(name = "postal") Postal postal,
// @JsonProperty("registered_country") @MaxMindDbParameter(name = "registered_country") Country registeredCountry,
// @JsonProperty("represented_country") @MaxMindDbParameter(name = "represented_country") RepresentedCountry representedCountry,
// @JsonProperty("subdivisions") @MaxMindDbParameter(name = "subdivisions") ArrayList<Subdivision> subdivisions,
// @JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name = "traits") Traits traits
// ) {
// super(city, continent, country, location, maxmind, postal, registeredCountry,
// representedCountry, subdivisions, traits);
// }
//
// public CityResponse(
// CityResponse response,
// String ipAddress,
// Network network,
// List<String> locales
// ) {
// super(response, ipAddress, network, locales);
// }
// }
//
// Path: src/main/java/com/maxmind/geoip2/model/CountryResponse.java
// public final class CountryResponse extends AbstractCountryResponse {
// @MaxMindDbConstructor
// public CountryResponse(
// @JsonProperty("continent") @MaxMindDbParameter(name = "continent") Continent continent,
// @JsonProperty("country") @MaxMindDbParameter(name = "country") Country country,
// @JsonProperty("maxmind") @MaxMindDbParameter(name = "maxmind") MaxMind maxmind,
// @JsonProperty("registered_country") @MaxMindDbParameter(name = "registered_country") Country registeredCountry,
// @JsonProperty("represented_country") @MaxMindDbParameter(name = "represented_country") RepresentedCountry representedCountry,
// @JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name = "traits") Traits traits
// ) {
// super(continent, country, maxmind, registeredCountry, representedCountry, traits);
// }
//
// public CountryResponse(
// CountryResponse response,
// String ipAddress,
// Network network,
// List<String> locales
// ) {
// super(response, ipAddress, network, locales);
// }
// }
//
// Path: src/main/java/com/maxmind/geoip2/model/InsightsResponse.java
// public class InsightsResponse extends AbstractCityResponse {
// public InsightsResponse(
// @JsonProperty("city") City city,
// @JsonProperty("continent") Continent continent,
// @JsonProperty("country") Country country,
// @JsonProperty("location") Location location,
// @JsonProperty("maxmind") MaxMind maxmind,
// @JsonProperty("postal") Postal postal,
// @JsonProperty("registered_country") Country registeredCountry,
// @JsonProperty("represented_country") RepresentedCountry representedCountry,
// @JsonProperty("subdivisions") List<Subdivision> subdivisions,
// @JacksonInject("traits") @JsonProperty("traits") Traits traits
// ) {
// super(city, continent, country, location, maxmind, postal, registeredCountry,
// representedCountry, subdivisions, traits);
// }
// }
|
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.InjectableValues;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.maxmind.geoip2.exception.*;
import com.maxmind.geoip2.model.CityResponse;
import com.maxmind.geoip2.model.CountryResponse;
import com.maxmind.geoip2.model.InsightsResponse;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.net.*;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.*;
|
public Builder proxy(Proxy val) {
if (val != null && val != Proxy.NO_PROXY) {
this.proxy = ProxySelector.of((InetSocketAddress) val.address());
}
return this;
}
/**
* @param val the proxy to use when making this request.
* @return Builder object
*/
public Builder proxy(ProxySelector val) {
this.proxy = val;
return this;
}
/**
* @return an instance of {@code WebServiceClient} created from the
* fields set on this builder.
*/
public WebServiceClient build() {
return new WebServiceClient(this);
}
}
/**
* @return A Country model for the requesting IP address
* @throws GeoIp2Exception if there is an error from the web service
* @throws IOException if an IO error happens during the request
*/
|
// Path: src/main/java/com/maxmind/geoip2/model/CityResponse.java
// public final class CityResponse extends AbstractCityResponse {
// @MaxMindDbConstructor
// public CityResponse(
// @JsonProperty("city") @MaxMindDbParameter(name = "city") City city,
// @JsonProperty("continent") @MaxMindDbParameter(name = "continent") Continent continent,
// @JsonProperty("country") @MaxMindDbParameter(name = "country") Country country,
// @JsonProperty("location") @MaxMindDbParameter(name = "location") Location location,
// @JsonProperty("maxmind") @MaxMindDbParameter(name = "maxmind") MaxMind maxmind,
// @JsonProperty("postal") @MaxMindDbParameter(name = "postal") Postal postal,
// @JsonProperty("registered_country") @MaxMindDbParameter(name = "registered_country") Country registeredCountry,
// @JsonProperty("represented_country") @MaxMindDbParameter(name = "represented_country") RepresentedCountry representedCountry,
// @JsonProperty("subdivisions") @MaxMindDbParameter(name = "subdivisions") ArrayList<Subdivision> subdivisions,
// @JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name = "traits") Traits traits
// ) {
// super(city, continent, country, location, maxmind, postal, registeredCountry,
// representedCountry, subdivisions, traits);
// }
//
// public CityResponse(
// CityResponse response,
// String ipAddress,
// Network network,
// List<String> locales
// ) {
// super(response, ipAddress, network, locales);
// }
// }
//
// Path: src/main/java/com/maxmind/geoip2/model/CountryResponse.java
// public final class CountryResponse extends AbstractCountryResponse {
// @MaxMindDbConstructor
// public CountryResponse(
// @JsonProperty("continent") @MaxMindDbParameter(name = "continent") Continent continent,
// @JsonProperty("country") @MaxMindDbParameter(name = "country") Country country,
// @JsonProperty("maxmind") @MaxMindDbParameter(name = "maxmind") MaxMind maxmind,
// @JsonProperty("registered_country") @MaxMindDbParameter(name = "registered_country") Country registeredCountry,
// @JsonProperty("represented_country") @MaxMindDbParameter(name = "represented_country") RepresentedCountry representedCountry,
// @JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name = "traits") Traits traits
// ) {
// super(continent, country, maxmind, registeredCountry, representedCountry, traits);
// }
//
// public CountryResponse(
// CountryResponse response,
// String ipAddress,
// Network network,
// List<String> locales
// ) {
// super(response, ipAddress, network, locales);
// }
// }
//
// Path: src/main/java/com/maxmind/geoip2/model/InsightsResponse.java
// public class InsightsResponse extends AbstractCityResponse {
// public InsightsResponse(
// @JsonProperty("city") City city,
// @JsonProperty("continent") Continent continent,
// @JsonProperty("country") Country country,
// @JsonProperty("location") Location location,
// @JsonProperty("maxmind") MaxMind maxmind,
// @JsonProperty("postal") Postal postal,
// @JsonProperty("registered_country") Country registeredCountry,
// @JsonProperty("represented_country") RepresentedCountry representedCountry,
// @JsonProperty("subdivisions") List<Subdivision> subdivisions,
// @JacksonInject("traits") @JsonProperty("traits") Traits traits
// ) {
// super(city, continent, country, location, maxmind, postal, registeredCountry,
// representedCountry, subdivisions, traits);
// }
// }
// Path: src/main/java/com/maxmind/geoip2/WebServiceClient.java
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.InjectableValues;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.maxmind.geoip2.exception.*;
import com.maxmind.geoip2.model.CityResponse;
import com.maxmind.geoip2.model.CountryResponse;
import com.maxmind.geoip2.model.InsightsResponse;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.net.*;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.*;
public Builder proxy(Proxy val) {
if (val != null && val != Proxy.NO_PROXY) {
this.proxy = ProxySelector.of((InetSocketAddress) val.address());
}
return this;
}
/**
* @param val the proxy to use when making this request.
* @return Builder object
*/
public Builder proxy(ProxySelector val) {
this.proxy = val;
return this;
}
/**
* @return an instance of {@code WebServiceClient} created from the
* fields set on this builder.
*/
public WebServiceClient build() {
return new WebServiceClient(this);
}
}
/**
* @return A Country model for the requesting IP address
* @throws GeoIp2Exception if there is an error from the web service
* @throws IOException if an IO error happens during the request
*/
|
public CountryResponse country() throws IOException, GeoIp2Exception {
|
maxmind/GeoIP2-java
|
src/main/java/com/maxmind/geoip2/WebServiceClient.java
|
// Path: src/main/java/com/maxmind/geoip2/model/CityResponse.java
// public final class CityResponse extends AbstractCityResponse {
// @MaxMindDbConstructor
// public CityResponse(
// @JsonProperty("city") @MaxMindDbParameter(name = "city") City city,
// @JsonProperty("continent") @MaxMindDbParameter(name = "continent") Continent continent,
// @JsonProperty("country") @MaxMindDbParameter(name = "country") Country country,
// @JsonProperty("location") @MaxMindDbParameter(name = "location") Location location,
// @JsonProperty("maxmind") @MaxMindDbParameter(name = "maxmind") MaxMind maxmind,
// @JsonProperty("postal") @MaxMindDbParameter(name = "postal") Postal postal,
// @JsonProperty("registered_country") @MaxMindDbParameter(name = "registered_country") Country registeredCountry,
// @JsonProperty("represented_country") @MaxMindDbParameter(name = "represented_country") RepresentedCountry representedCountry,
// @JsonProperty("subdivisions") @MaxMindDbParameter(name = "subdivisions") ArrayList<Subdivision> subdivisions,
// @JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name = "traits") Traits traits
// ) {
// super(city, continent, country, location, maxmind, postal, registeredCountry,
// representedCountry, subdivisions, traits);
// }
//
// public CityResponse(
// CityResponse response,
// String ipAddress,
// Network network,
// List<String> locales
// ) {
// super(response, ipAddress, network, locales);
// }
// }
//
// Path: src/main/java/com/maxmind/geoip2/model/CountryResponse.java
// public final class CountryResponse extends AbstractCountryResponse {
// @MaxMindDbConstructor
// public CountryResponse(
// @JsonProperty("continent") @MaxMindDbParameter(name = "continent") Continent continent,
// @JsonProperty("country") @MaxMindDbParameter(name = "country") Country country,
// @JsonProperty("maxmind") @MaxMindDbParameter(name = "maxmind") MaxMind maxmind,
// @JsonProperty("registered_country") @MaxMindDbParameter(name = "registered_country") Country registeredCountry,
// @JsonProperty("represented_country") @MaxMindDbParameter(name = "represented_country") RepresentedCountry representedCountry,
// @JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name = "traits") Traits traits
// ) {
// super(continent, country, maxmind, registeredCountry, representedCountry, traits);
// }
//
// public CountryResponse(
// CountryResponse response,
// String ipAddress,
// Network network,
// List<String> locales
// ) {
// super(response, ipAddress, network, locales);
// }
// }
//
// Path: src/main/java/com/maxmind/geoip2/model/InsightsResponse.java
// public class InsightsResponse extends AbstractCityResponse {
// public InsightsResponse(
// @JsonProperty("city") City city,
// @JsonProperty("continent") Continent continent,
// @JsonProperty("country") Country country,
// @JsonProperty("location") Location location,
// @JsonProperty("maxmind") MaxMind maxmind,
// @JsonProperty("postal") Postal postal,
// @JsonProperty("registered_country") Country registeredCountry,
// @JsonProperty("represented_country") RepresentedCountry representedCountry,
// @JsonProperty("subdivisions") List<Subdivision> subdivisions,
// @JacksonInject("traits") @JsonProperty("traits") Traits traits
// ) {
// super(city, continent, country, location, maxmind, postal, registeredCountry,
// representedCountry, subdivisions, traits);
// }
// }
|
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.InjectableValues;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.maxmind.geoip2.exception.*;
import com.maxmind.geoip2.model.CityResponse;
import com.maxmind.geoip2.model.CountryResponse;
import com.maxmind.geoip2.model.InsightsResponse;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.net.*;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.*;
|
/**
* @return an instance of {@code WebServiceClient} created from the
* fields set on this builder.
*/
public WebServiceClient build() {
return new WebServiceClient(this);
}
}
/**
* @return A Country model for the requesting IP address
* @throws GeoIp2Exception if there is an error from the web service
* @throws IOException if an IO error happens during the request
*/
public CountryResponse country() throws IOException, GeoIp2Exception {
return this.country(null);
}
@Override
public CountryResponse country(InetAddress ipAddress) throws IOException,
GeoIp2Exception {
return this.responseFor("country", ipAddress, CountryResponse.class);
}
/**
* @return A City Plus model for the requesting IP address
* @throws GeoIp2Exception if there is an error from the web service
* @throws IOException if an IO error happens during the request
*/
|
// Path: src/main/java/com/maxmind/geoip2/model/CityResponse.java
// public final class CityResponse extends AbstractCityResponse {
// @MaxMindDbConstructor
// public CityResponse(
// @JsonProperty("city") @MaxMindDbParameter(name = "city") City city,
// @JsonProperty("continent") @MaxMindDbParameter(name = "continent") Continent continent,
// @JsonProperty("country") @MaxMindDbParameter(name = "country") Country country,
// @JsonProperty("location") @MaxMindDbParameter(name = "location") Location location,
// @JsonProperty("maxmind") @MaxMindDbParameter(name = "maxmind") MaxMind maxmind,
// @JsonProperty("postal") @MaxMindDbParameter(name = "postal") Postal postal,
// @JsonProperty("registered_country") @MaxMindDbParameter(name = "registered_country") Country registeredCountry,
// @JsonProperty("represented_country") @MaxMindDbParameter(name = "represented_country") RepresentedCountry representedCountry,
// @JsonProperty("subdivisions") @MaxMindDbParameter(name = "subdivisions") ArrayList<Subdivision> subdivisions,
// @JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name = "traits") Traits traits
// ) {
// super(city, continent, country, location, maxmind, postal, registeredCountry,
// representedCountry, subdivisions, traits);
// }
//
// public CityResponse(
// CityResponse response,
// String ipAddress,
// Network network,
// List<String> locales
// ) {
// super(response, ipAddress, network, locales);
// }
// }
//
// Path: src/main/java/com/maxmind/geoip2/model/CountryResponse.java
// public final class CountryResponse extends AbstractCountryResponse {
// @MaxMindDbConstructor
// public CountryResponse(
// @JsonProperty("continent") @MaxMindDbParameter(name = "continent") Continent continent,
// @JsonProperty("country") @MaxMindDbParameter(name = "country") Country country,
// @JsonProperty("maxmind") @MaxMindDbParameter(name = "maxmind") MaxMind maxmind,
// @JsonProperty("registered_country") @MaxMindDbParameter(name = "registered_country") Country registeredCountry,
// @JsonProperty("represented_country") @MaxMindDbParameter(name = "represented_country") RepresentedCountry representedCountry,
// @JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name = "traits") Traits traits
// ) {
// super(continent, country, maxmind, registeredCountry, representedCountry, traits);
// }
//
// public CountryResponse(
// CountryResponse response,
// String ipAddress,
// Network network,
// List<String> locales
// ) {
// super(response, ipAddress, network, locales);
// }
// }
//
// Path: src/main/java/com/maxmind/geoip2/model/InsightsResponse.java
// public class InsightsResponse extends AbstractCityResponse {
// public InsightsResponse(
// @JsonProperty("city") City city,
// @JsonProperty("continent") Continent continent,
// @JsonProperty("country") Country country,
// @JsonProperty("location") Location location,
// @JsonProperty("maxmind") MaxMind maxmind,
// @JsonProperty("postal") Postal postal,
// @JsonProperty("registered_country") Country registeredCountry,
// @JsonProperty("represented_country") RepresentedCountry representedCountry,
// @JsonProperty("subdivisions") List<Subdivision> subdivisions,
// @JacksonInject("traits") @JsonProperty("traits") Traits traits
// ) {
// super(city, continent, country, location, maxmind, postal, registeredCountry,
// representedCountry, subdivisions, traits);
// }
// }
// Path: src/main/java/com/maxmind/geoip2/WebServiceClient.java
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.InjectableValues;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.maxmind.geoip2.exception.*;
import com.maxmind.geoip2.model.CityResponse;
import com.maxmind.geoip2.model.CountryResponse;
import com.maxmind.geoip2.model.InsightsResponse;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.net.*;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.*;
/**
* @return an instance of {@code WebServiceClient} created from the
* fields set on this builder.
*/
public WebServiceClient build() {
return new WebServiceClient(this);
}
}
/**
* @return A Country model for the requesting IP address
* @throws GeoIp2Exception if there is an error from the web service
* @throws IOException if an IO error happens during the request
*/
public CountryResponse country() throws IOException, GeoIp2Exception {
return this.country(null);
}
@Override
public CountryResponse country(InetAddress ipAddress) throws IOException,
GeoIp2Exception {
return this.responseFor("country", ipAddress, CountryResponse.class);
}
/**
* @return A City Plus model for the requesting IP address
* @throws GeoIp2Exception if there is an error from the web service
* @throws IOException if an IO error happens during the request
*/
|
public CityResponse city() throws IOException, GeoIp2Exception {
|
maxmind/GeoIP2-java
|
src/main/java/com/maxmind/geoip2/WebServiceClient.java
|
// Path: src/main/java/com/maxmind/geoip2/model/CityResponse.java
// public final class CityResponse extends AbstractCityResponse {
// @MaxMindDbConstructor
// public CityResponse(
// @JsonProperty("city") @MaxMindDbParameter(name = "city") City city,
// @JsonProperty("continent") @MaxMindDbParameter(name = "continent") Continent continent,
// @JsonProperty("country") @MaxMindDbParameter(name = "country") Country country,
// @JsonProperty("location") @MaxMindDbParameter(name = "location") Location location,
// @JsonProperty("maxmind") @MaxMindDbParameter(name = "maxmind") MaxMind maxmind,
// @JsonProperty("postal") @MaxMindDbParameter(name = "postal") Postal postal,
// @JsonProperty("registered_country") @MaxMindDbParameter(name = "registered_country") Country registeredCountry,
// @JsonProperty("represented_country") @MaxMindDbParameter(name = "represented_country") RepresentedCountry representedCountry,
// @JsonProperty("subdivisions") @MaxMindDbParameter(name = "subdivisions") ArrayList<Subdivision> subdivisions,
// @JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name = "traits") Traits traits
// ) {
// super(city, continent, country, location, maxmind, postal, registeredCountry,
// representedCountry, subdivisions, traits);
// }
//
// public CityResponse(
// CityResponse response,
// String ipAddress,
// Network network,
// List<String> locales
// ) {
// super(response, ipAddress, network, locales);
// }
// }
//
// Path: src/main/java/com/maxmind/geoip2/model/CountryResponse.java
// public final class CountryResponse extends AbstractCountryResponse {
// @MaxMindDbConstructor
// public CountryResponse(
// @JsonProperty("continent") @MaxMindDbParameter(name = "continent") Continent continent,
// @JsonProperty("country") @MaxMindDbParameter(name = "country") Country country,
// @JsonProperty("maxmind") @MaxMindDbParameter(name = "maxmind") MaxMind maxmind,
// @JsonProperty("registered_country") @MaxMindDbParameter(name = "registered_country") Country registeredCountry,
// @JsonProperty("represented_country") @MaxMindDbParameter(name = "represented_country") RepresentedCountry representedCountry,
// @JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name = "traits") Traits traits
// ) {
// super(continent, country, maxmind, registeredCountry, representedCountry, traits);
// }
//
// public CountryResponse(
// CountryResponse response,
// String ipAddress,
// Network network,
// List<String> locales
// ) {
// super(response, ipAddress, network, locales);
// }
// }
//
// Path: src/main/java/com/maxmind/geoip2/model/InsightsResponse.java
// public class InsightsResponse extends AbstractCityResponse {
// public InsightsResponse(
// @JsonProperty("city") City city,
// @JsonProperty("continent") Continent continent,
// @JsonProperty("country") Country country,
// @JsonProperty("location") Location location,
// @JsonProperty("maxmind") MaxMind maxmind,
// @JsonProperty("postal") Postal postal,
// @JsonProperty("registered_country") Country registeredCountry,
// @JsonProperty("represented_country") RepresentedCountry representedCountry,
// @JsonProperty("subdivisions") List<Subdivision> subdivisions,
// @JacksonInject("traits") @JsonProperty("traits") Traits traits
// ) {
// super(city, continent, country, location, maxmind, postal, registeredCountry,
// representedCountry, subdivisions, traits);
// }
// }
|
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.InjectableValues;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.maxmind.geoip2.exception.*;
import com.maxmind.geoip2.model.CityResponse;
import com.maxmind.geoip2.model.CountryResponse;
import com.maxmind.geoip2.model.InsightsResponse;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.net.*;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.*;
|
public CountryResponse country() throws IOException, GeoIp2Exception {
return this.country(null);
}
@Override
public CountryResponse country(InetAddress ipAddress) throws IOException,
GeoIp2Exception {
return this.responseFor("country", ipAddress, CountryResponse.class);
}
/**
* @return A City Plus model for the requesting IP address
* @throws GeoIp2Exception if there is an error from the web service
* @throws IOException if an IO error happens during the request
*/
public CityResponse city() throws IOException, GeoIp2Exception {
return this.city(null);
}
@Override
public CityResponse city(InetAddress ipAddress) throws IOException,
GeoIp2Exception {
return this.responseFor("city", ipAddress, CityResponse.class);
}
/**
* @return An Insights model for the requesting IP address
* @throws GeoIp2Exception if there is an error from the web service
* @throws IOException if an IO error happens during the request
*/
|
// Path: src/main/java/com/maxmind/geoip2/model/CityResponse.java
// public final class CityResponse extends AbstractCityResponse {
// @MaxMindDbConstructor
// public CityResponse(
// @JsonProperty("city") @MaxMindDbParameter(name = "city") City city,
// @JsonProperty("continent") @MaxMindDbParameter(name = "continent") Continent continent,
// @JsonProperty("country") @MaxMindDbParameter(name = "country") Country country,
// @JsonProperty("location") @MaxMindDbParameter(name = "location") Location location,
// @JsonProperty("maxmind") @MaxMindDbParameter(name = "maxmind") MaxMind maxmind,
// @JsonProperty("postal") @MaxMindDbParameter(name = "postal") Postal postal,
// @JsonProperty("registered_country") @MaxMindDbParameter(name = "registered_country") Country registeredCountry,
// @JsonProperty("represented_country") @MaxMindDbParameter(name = "represented_country") RepresentedCountry representedCountry,
// @JsonProperty("subdivisions") @MaxMindDbParameter(name = "subdivisions") ArrayList<Subdivision> subdivisions,
// @JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name = "traits") Traits traits
// ) {
// super(city, continent, country, location, maxmind, postal, registeredCountry,
// representedCountry, subdivisions, traits);
// }
//
// public CityResponse(
// CityResponse response,
// String ipAddress,
// Network network,
// List<String> locales
// ) {
// super(response, ipAddress, network, locales);
// }
// }
//
// Path: src/main/java/com/maxmind/geoip2/model/CountryResponse.java
// public final class CountryResponse extends AbstractCountryResponse {
// @MaxMindDbConstructor
// public CountryResponse(
// @JsonProperty("continent") @MaxMindDbParameter(name = "continent") Continent continent,
// @JsonProperty("country") @MaxMindDbParameter(name = "country") Country country,
// @JsonProperty("maxmind") @MaxMindDbParameter(name = "maxmind") MaxMind maxmind,
// @JsonProperty("registered_country") @MaxMindDbParameter(name = "registered_country") Country registeredCountry,
// @JsonProperty("represented_country") @MaxMindDbParameter(name = "represented_country") RepresentedCountry representedCountry,
// @JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name = "traits") Traits traits
// ) {
// super(continent, country, maxmind, registeredCountry, representedCountry, traits);
// }
//
// public CountryResponse(
// CountryResponse response,
// String ipAddress,
// Network network,
// List<String> locales
// ) {
// super(response, ipAddress, network, locales);
// }
// }
//
// Path: src/main/java/com/maxmind/geoip2/model/InsightsResponse.java
// public class InsightsResponse extends AbstractCityResponse {
// public InsightsResponse(
// @JsonProperty("city") City city,
// @JsonProperty("continent") Continent continent,
// @JsonProperty("country") Country country,
// @JsonProperty("location") Location location,
// @JsonProperty("maxmind") MaxMind maxmind,
// @JsonProperty("postal") Postal postal,
// @JsonProperty("registered_country") Country registeredCountry,
// @JsonProperty("represented_country") RepresentedCountry representedCountry,
// @JsonProperty("subdivisions") List<Subdivision> subdivisions,
// @JacksonInject("traits") @JsonProperty("traits") Traits traits
// ) {
// super(city, continent, country, location, maxmind, postal, registeredCountry,
// representedCountry, subdivisions, traits);
// }
// }
// Path: src/main/java/com/maxmind/geoip2/WebServiceClient.java
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.InjectableValues;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.maxmind.geoip2.exception.*;
import com.maxmind.geoip2.model.CityResponse;
import com.maxmind.geoip2.model.CountryResponse;
import com.maxmind.geoip2.model.InsightsResponse;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.net.*;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.*;
public CountryResponse country() throws IOException, GeoIp2Exception {
return this.country(null);
}
@Override
public CountryResponse country(InetAddress ipAddress) throws IOException,
GeoIp2Exception {
return this.responseFor("country", ipAddress, CountryResponse.class);
}
/**
* @return A City Plus model for the requesting IP address
* @throws GeoIp2Exception if there is an error from the web service
* @throws IOException if an IO error happens during the request
*/
public CityResponse city() throws IOException, GeoIp2Exception {
return this.city(null);
}
@Override
public CityResponse city(InetAddress ipAddress) throws IOException,
GeoIp2Exception {
return this.responseFor("city", ipAddress, CityResponse.class);
}
/**
* @return An Insights model for the requesting IP address
* @throws GeoIp2Exception if there is an error from the web service
* @throws IOException if an IO error happens during the request
*/
|
public InsightsResponse insights() throws IOException, GeoIp2Exception {
|
maxmind/GeoIP2-java
|
src/test/java/com/maxmind/geoip2/DatabaseReaderTest.java
|
// Path: src/main/java/com/maxmind/geoip2/model/ConnectionTypeResponse.java
// public enum ConnectionType {
// DIALUP("Dialup"), CABLE_DSL("Cable/DSL"), CORPORATE("Corporate"), CELLULAR(
// "Cellular");
//
// private final String name;
//
// ConnectionType(String name) {
// this.name = name;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Enum#toString()
// */
// @JsonValue
// @Override
// public String toString() {
// return this.name;
// }
//
// public static ConnectionType fromString(String s) {
// if (s == null) {
// return null;
// }
//
// switch (s) {
// case "Dialup":
// return ConnectionType.DIALUP;
// case "Cable/DSL":
// return ConnectionType.CABLE_DSL;
// case "Corporate":
// return ConnectionType.CORPORATE;
// case "Cellular":
// return ConnectionType.CELLULAR;
// default:
// return null;
// }
// }
// }
|
import com.maxmind.db.Reader;
import com.maxmind.geoip2.exception.AddressNotFoundException;
import com.maxmind.geoip2.exception.GeoIp2Exception;
import com.maxmind.geoip2.model.*;
import com.maxmind.geoip2.model.ConnectionTypeResponse.ConnectionType;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Arrays;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
|
try (DatabaseReader reader = new DatabaseReader.Builder(
getFile("GeoIP2-City-Test.mmdb")).build()
) {
InetAddress ipAddress = InetAddress.getByName("81.2.69.192");
CityResponse response = reader.city(ipAddress);
assertEquals(2635167, response.getCountry().getGeoNameId().intValue());
assertEquals(100, response.getLocation().getAccuracyRadius().intValue());
assertFalse(response.getTraits().isLegitimateProxy());
assertEquals(ipAddress.getHostAddress(), response.getTraits().getIpAddress());
assertEquals("81.2.69.192/28", response.getTraits().getNetwork().toString());
CityResponse tryResponse = reader.tryCity(ipAddress).get();
assertEquals(response.toJson(), tryResponse.toJson());
// Test that the methods can be called on DB without
// an exception
reader.country(ipAddress);
}
}
@Test
public void testConnectionType() throws Exception {
try (DatabaseReader reader = new DatabaseReader.Builder(
this.getFile("GeoIP2-Connection-Type-Test.mmdb")).build()
) {
InetAddress ipAddress = InetAddress.getByName("1.0.1.0");
ConnectionTypeResponse response = reader.connectionType(ipAddress);
|
// Path: src/main/java/com/maxmind/geoip2/model/ConnectionTypeResponse.java
// public enum ConnectionType {
// DIALUP("Dialup"), CABLE_DSL("Cable/DSL"), CORPORATE("Corporate"), CELLULAR(
// "Cellular");
//
// private final String name;
//
// ConnectionType(String name) {
// this.name = name;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Enum#toString()
// */
// @JsonValue
// @Override
// public String toString() {
// return this.name;
// }
//
// public static ConnectionType fromString(String s) {
// if (s == null) {
// return null;
// }
//
// switch (s) {
// case "Dialup":
// return ConnectionType.DIALUP;
// case "Cable/DSL":
// return ConnectionType.CABLE_DSL;
// case "Corporate":
// return ConnectionType.CORPORATE;
// case "Cellular":
// return ConnectionType.CELLULAR;
// default:
// return null;
// }
// }
// }
// Path: src/test/java/com/maxmind/geoip2/DatabaseReaderTest.java
import com.maxmind.db.Reader;
import com.maxmind.geoip2.exception.AddressNotFoundException;
import com.maxmind.geoip2.exception.GeoIp2Exception;
import com.maxmind.geoip2.model.*;
import com.maxmind.geoip2.model.ConnectionTypeResponse.ConnectionType;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Arrays;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
try (DatabaseReader reader = new DatabaseReader.Builder(
getFile("GeoIP2-City-Test.mmdb")).build()
) {
InetAddress ipAddress = InetAddress.getByName("81.2.69.192");
CityResponse response = reader.city(ipAddress);
assertEquals(2635167, response.getCountry().getGeoNameId().intValue());
assertEquals(100, response.getLocation().getAccuracyRadius().intValue());
assertFalse(response.getTraits().isLegitimateProxy());
assertEquals(ipAddress.getHostAddress(), response.getTraits().getIpAddress());
assertEquals("81.2.69.192/28", response.getTraits().getNetwork().toString());
CityResponse tryResponse = reader.tryCity(ipAddress).get();
assertEquals(response.toJson(), tryResponse.toJson());
// Test that the methods can be called on DB without
// an exception
reader.country(ipAddress);
}
}
@Test
public void testConnectionType() throws Exception {
try (DatabaseReader reader = new DatabaseReader.Builder(
this.getFile("GeoIP2-Connection-Type-Test.mmdb")).build()
) {
InetAddress ipAddress = InetAddress.getByName("1.0.1.0");
ConnectionTypeResponse response = reader.connectionType(ipAddress);
|
assertEquals(ConnectionType.CABLE_DSL, response.getConnectionType());
|
maxmind/GeoIP2-java
|
src/main/java/com/maxmind/geoip2/record/Traits.java
|
// Path: src/main/java/com/maxmind/geoip2/NetworkDeserializer.java
// public class NetworkDeserializer extends StdDeserializer<Network> {
//
// public NetworkDeserializer() {
// this(null);
// }
//
// public NetworkDeserializer(Class<?> vc) {
// super(vc);
// }
//
// @Override
// public Network deserialize(
// JsonParser jsonparser, DeserializationContext context)
// throws IOException {
//
// String cidr = jsonparser.getText();
// if (cidr == null) {
// return null;
// }
// String[] parts = cidr.split("/", 2);
// if (parts.length != 2) {
// throw new RuntimeException("Invalid cidr format: " + cidr);
// }
// int prefixLength = Integer.parseInt(parts[1]);
// try {
// return new Network(InetAddress.getByName(parts[0]), prefixLength);
// } catch (UnknownHostException e) {
// throw new RuntimeException(e);
// }
// }
// }
//
// Path: src/main/java/com/maxmind/geoip2/model/ConnectionTypeResponse.java
// public enum ConnectionType {
// DIALUP("Dialup"), CABLE_DSL("Cable/DSL"), CORPORATE("Corporate"), CELLULAR(
// "Cellular");
//
// private final String name;
//
// ConnectionType(String name) {
// this.name = name;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Enum#toString()
// */
// @JsonValue
// @Override
// public String toString() {
// return this.name;
// }
//
// public static ConnectionType fromString(String s) {
// if (s == null) {
// return null;
// }
//
// switch (s) {
// case "Dialup":
// return ConnectionType.DIALUP;
// case "Cable/DSL":
// return ConnectionType.CABLE_DSL;
// case "Corporate":
// return ConnectionType.CORPORATE;
// case "Cellular":
// return ConnectionType.CELLULAR;
// default:
// return null;
// }
// }
// }
|
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.maxmind.db.MaxMindDbConstructor;
import com.maxmind.db.MaxMindDbParameter;
import com.maxmind.db.Network;
import com.maxmind.geoip2.NetworkDeserializer;
import com.maxmind.geoip2.model.ConnectionTypeResponse.ConnectionType;
|
package com.maxmind.geoip2.record;
/**
* Contains data for the traits record associated with an IP address.
*/
public final class Traits extends AbstractRecord {
private final Long autonomousSystemNumber;
private final String autonomousSystemOrganization;
|
// Path: src/main/java/com/maxmind/geoip2/NetworkDeserializer.java
// public class NetworkDeserializer extends StdDeserializer<Network> {
//
// public NetworkDeserializer() {
// this(null);
// }
//
// public NetworkDeserializer(Class<?> vc) {
// super(vc);
// }
//
// @Override
// public Network deserialize(
// JsonParser jsonparser, DeserializationContext context)
// throws IOException {
//
// String cidr = jsonparser.getText();
// if (cidr == null) {
// return null;
// }
// String[] parts = cidr.split("/", 2);
// if (parts.length != 2) {
// throw new RuntimeException("Invalid cidr format: " + cidr);
// }
// int prefixLength = Integer.parseInt(parts[1]);
// try {
// return new Network(InetAddress.getByName(parts[0]), prefixLength);
// } catch (UnknownHostException e) {
// throw new RuntimeException(e);
// }
// }
// }
//
// Path: src/main/java/com/maxmind/geoip2/model/ConnectionTypeResponse.java
// public enum ConnectionType {
// DIALUP("Dialup"), CABLE_DSL("Cable/DSL"), CORPORATE("Corporate"), CELLULAR(
// "Cellular");
//
// private final String name;
//
// ConnectionType(String name) {
// this.name = name;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Enum#toString()
// */
// @JsonValue
// @Override
// public String toString() {
// return this.name;
// }
//
// public static ConnectionType fromString(String s) {
// if (s == null) {
// return null;
// }
//
// switch (s) {
// case "Dialup":
// return ConnectionType.DIALUP;
// case "Cable/DSL":
// return ConnectionType.CABLE_DSL;
// case "Corporate":
// return ConnectionType.CORPORATE;
// case "Cellular":
// return ConnectionType.CELLULAR;
// default:
// return null;
// }
// }
// }
// Path: src/main/java/com/maxmind/geoip2/record/Traits.java
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.maxmind.db.MaxMindDbConstructor;
import com.maxmind.db.MaxMindDbParameter;
import com.maxmind.db.Network;
import com.maxmind.geoip2.NetworkDeserializer;
import com.maxmind.geoip2.model.ConnectionTypeResponse.ConnectionType;
package com.maxmind.geoip2.record;
/**
* Contains data for the traits record associated with an IP address.
*/
public final class Traits extends AbstractRecord {
private final Long autonomousSystemNumber;
private final String autonomousSystemOrganization;
|
private final ConnectionType connectionType;
|
maxmind/GeoIP2-java
|
src/main/java/com/maxmind/geoip2/record/Traits.java
|
// Path: src/main/java/com/maxmind/geoip2/NetworkDeserializer.java
// public class NetworkDeserializer extends StdDeserializer<Network> {
//
// public NetworkDeserializer() {
// this(null);
// }
//
// public NetworkDeserializer(Class<?> vc) {
// super(vc);
// }
//
// @Override
// public Network deserialize(
// JsonParser jsonparser, DeserializationContext context)
// throws IOException {
//
// String cidr = jsonparser.getText();
// if (cidr == null) {
// return null;
// }
// String[] parts = cidr.split("/", 2);
// if (parts.length != 2) {
// throw new RuntimeException("Invalid cidr format: " + cidr);
// }
// int prefixLength = Integer.parseInt(parts[1]);
// try {
// return new Network(InetAddress.getByName(parts[0]), prefixLength);
// } catch (UnknownHostException e) {
// throw new RuntimeException(e);
// }
// }
// }
//
// Path: src/main/java/com/maxmind/geoip2/model/ConnectionTypeResponse.java
// public enum ConnectionType {
// DIALUP("Dialup"), CABLE_DSL("Cable/DSL"), CORPORATE("Corporate"), CELLULAR(
// "Cellular");
//
// private final String name;
//
// ConnectionType(String name) {
// this.name = name;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Enum#toString()
// */
// @JsonValue
// @Override
// public String toString() {
// return this.name;
// }
//
// public static ConnectionType fromString(String s) {
// if (s == null) {
// return null;
// }
//
// switch (s) {
// case "Dialup":
// return ConnectionType.DIALUP;
// case "Cable/DSL":
// return ConnectionType.CABLE_DSL;
// case "Corporate":
// return ConnectionType.CORPORATE;
// case "Cellular":
// return ConnectionType.CELLULAR;
// default:
// return null;
// }
// }
// }
|
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.maxmind.db.MaxMindDbConstructor;
import com.maxmind.db.MaxMindDbParameter;
import com.maxmind.db.Network;
import com.maxmind.geoip2.NetworkDeserializer;
import com.maxmind.geoip2.model.ConnectionTypeResponse.ConnectionType;
|
null, false, false, false, false,
false, false, false, false, false, null,
null, null, null, null, null, null, null);
}
public Traits(String ipAddress, Network network) {
this(null, null, null, null,
ipAddress, false, false, false, false,
false, false, false, false, false, null,
null, null, network, null, null, null, null);
}
public Traits(
@JsonProperty("autonomous_system_number") Long autonomousSystemNumber,
@JsonProperty("autonomous_system_organization") String autonomousSystemOrganization,
@JsonProperty("connection_type") ConnectionType connectionType,
@JsonProperty("domain") String domain,
@JacksonInject("ip_address") @JsonProperty("ip_address") String ipAddress,
@JsonProperty("is_anonymous") boolean isAnonymous,
@JsonProperty("is_anonymous_proxy") boolean isAnonymousProxy,
@JsonProperty("is_anonymous_vpn") boolean isAnonymousVpn,
@JsonProperty("is_hosting_provider") boolean isHostingProvider,
@JsonProperty("is_legitimate_proxy") boolean isLegitimateProxy,
@JsonProperty("is_public_proxy") boolean isPublicProxy,
@JsonProperty("is_residential_proxy") boolean isResidentialProxy,
@JsonProperty("is_satellite_provider") boolean isSatelliteProvider,
@JsonProperty("is_tor_exit_node") boolean isTorExitNode,
@JsonProperty("isp") String isp,
@JsonProperty("mobile_country_code") String mobileCountryCode,
@JsonProperty("mobile_network_code") String mobileNetworkCode,
|
// Path: src/main/java/com/maxmind/geoip2/NetworkDeserializer.java
// public class NetworkDeserializer extends StdDeserializer<Network> {
//
// public NetworkDeserializer() {
// this(null);
// }
//
// public NetworkDeserializer(Class<?> vc) {
// super(vc);
// }
//
// @Override
// public Network deserialize(
// JsonParser jsonparser, DeserializationContext context)
// throws IOException {
//
// String cidr = jsonparser.getText();
// if (cidr == null) {
// return null;
// }
// String[] parts = cidr.split("/", 2);
// if (parts.length != 2) {
// throw new RuntimeException("Invalid cidr format: " + cidr);
// }
// int prefixLength = Integer.parseInt(parts[1]);
// try {
// return new Network(InetAddress.getByName(parts[0]), prefixLength);
// } catch (UnknownHostException e) {
// throw new RuntimeException(e);
// }
// }
// }
//
// Path: src/main/java/com/maxmind/geoip2/model/ConnectionTypeResponse.java
// public enum ConnectionType {
// DIALUP("Dialup"), CABLE_DSL("Cable/DSL"), CORPORATE("Corporate"), CELLULAR(
// "Cellular");
//
// private final String name;
//
// ConnectionType(String name) {
// this.name = name;
// }
//
// /*
// * (non-Javadoc)
// *
// * @see java.lang.Enum#toString()
// */
// @JsonValue
// @Override
// public String toString() {
// return this.name;
// }
//
// public static ConnectionType fromString(String s) {
// if (s == null) {
// return null;
// }
//
// switch (s) {
// case "Dialup":
// return ConnectionType.DIALUP;
// case "Cable/DSL":
// return ConnectionType.CABLE_DSL;
// case "Corporate":
// return ConnectionType.CORPORATE;
// case "Cellular":
// return ConnectionType.CELLULAR;
// default:
// return null;
// }
// }
// }
// Path: src/main/java/com/maxmind/geoip2/record/Traits.java
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.maxmind.db.MaxMindDbConstructor;
import com.maxmind.db.MaxMindDbParameter;
import com.maxmind.db.Network;
import com.maxmind.geoip2.NetworkDeserializer;
import com.maxmind.geoip2.model.ConnectionTypeResponse.ConnectionType;
null, false, false, false, false,
false, false, false, false, false, null,
null, null, null, null, null, null, null);
}
public Traits(String ipAddress, Network network) {
this(null, null, null, null,
ipAddress, false, false, false, false,
false, false, false, false, false, null,
null, null, network, null, null, null, null);
}
public Traits(
@JsonProperty("autonomous_system_number") Long autonomousSystemNumber,
@JsonProperty("autonomous_system_organization") String autonomousSystemOrganization,
@JsonProperty("connection_type") ConnectionType connectionType,
@JsonProperty("domain") String domain,
@JacksonInject("ip_address") @JsonProperty("ip_address") String ipAddress,
@JsonProperty("is_anonymous") boolean isAnonymous,
@JsonProperty("is_anonymous_proxy") boolean isAnonymousProxy,
@JsonProperty("is_anonymous_vpn") boolean isAnonymousVpn,
@JsonProperty("is_hosting_provider") boolean isHostingProvider,
@JsonProperty("is_legitimate_proxy") boolean isLegitimateProxy,
@JsonProperty("is_public_proxy") boolean isPublicProxy,
@JsonProperty("is_residential_proxy") boolean isResidentialProxy,
@JsonProperty("is_satellite_provider") boolean isSatelliteProvider,
@JsonProperty("is_tor_exit_node") boolean isTorExitNode,
@JsonProperty("isp") String isp,
@JsonProperty("mobile_country_code") String mobileCountryCode,
@JsonProperty("mobile_network_code") String mobileNetworkCode,
|
@JacksonInject("network") @JsonProperty("network") @JsonDeserialize(using = NetworkDeserializer.class) Network network,
|
maxmind/GeoIP2-java
|
src/main/java/com/maxmind/geoip2/GeoIp2Provider.java
|
// Path: src/main/java/com/maxmind/geoip2/model/CityResponse.java
// public final class CityResponse extends AbstractCityResponse {
// @MaxMindDbConstructor
// public CityResponse(
// @JsonProperty("city") @MaxMindDbParameter(name = "city") City city,
// @JsonProperty("continent") @MaxMindDbParameter(name = "continent") Continent continent,
// @JsonProperty("country") @MaxMindDbParameter(name = "country") Country country,
// @JsonProperty("location") @MaxMindDbParameter(name = "location") Location location,
// @JsonProperty("maxmind") @MaxMindDbParameter(name = "maxmind") MaxMind maxmind,
// @JsonProperty("postal") @MaxMindDbParameter(name = "postal") Postal postal,
// @JsonProperty("registered_country") @MaxMindDbParameter(name = "registered_country") Country registeredCountry,
// @JsonProperty("represented_country") @MaxMindDbParameter(name = "represented_country") RepresentedCountry representedCountry,
// @JsonProperty("subdivisions") @MaxMindDbParameter(name = "subdivisions") ArrayList<Subdivision> subdivisions,
// @JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name = "traits") Traits traits
// ) {
// super(city, continent, country, location, maxmind, postal, registeredCountry,
// representedCountry, subdivisions, traits);
// }
//
// public CityResponse(
// CityResponse response,
// String ipAddress,
// Network network,
// List<String> locales
// ) {
// super(response, ipAddress, network, locales);
// }
// }
//
// Path: src/main/java/com/maxmind/geoip2/model/CountryResponse.java
// public final class CountryResponse extends AbstractCountryResponse {
// @MaxMindDbConstructor
// public CountryResponse(
// @JsonProperty("continent") @MaxMindDbParameter(name = "continent") Continent continent,
// @JsonProperty("country") @MaxMindDbParameter(name = "country") Country country,
// @JsonProperty("maxmind") @MaxMindDbParameter(name = "maxmind") MaxMind maxmind,
// @JsonProperty("registered_country") @MaxMindDbParameter(name = "registered_country") Country registeredCountry,
// @JsonProperty("represented_country") @MaxMindDbParameter(name = "represented_country") RepresentedCountry representedCountry,
// @JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name = "traits") Traits traits
// ) {
// super(continent, country, maxmind, registeredCountry, representedCountry, traits);
// }
//
// public CountryResponse(
// CountryResponse response,
// String ipAddress,
// Network network,
// List<String> locales
// ) {
// super(response, ipAddress, network, locales);
// }
// }
|
import com.maxmind.geoip2.exception.GeoIp2Exception;
import com.maxmind.geoip2.model.CityResponse;
import com.maxmind.geoip2.model.CountryResponse;
import java.io.IOException;
import java.net.InetAddress;
|
package com.maxmind.geoip2;
public interface GeoIp2Provider {
/**
* @param ipAddress IPv4 or IPv6 address to lookup.
* @return A Country model for the requested IP address.
* @throws GeoIp2Exception if there is an error looking up the IP
* @throws IOException if there is an IO error
*/
CountryResponse country(InetAddress ipAddress) throws IOException,
GeoIp2Exception;
/**
* @param ipAddress IPv4 or IPv6 address to lookup.
* @return A City model for the requested IP address.
* @throws GeoIp2Exception if there is an error looking up the IP
* @throws IOException if there is an IO error
*/
|
// Path: src/main/java/com/maxmind/geoip2/model/CityResponse.java
// public final class CityResponse extends AbstractCityResponse {
// @MaxMindDbConstructor
// public CityResponse(
// @JsonProperty("city") @MaxMindDbParameter(name = "city") City city,
// @JsonProperty("continent") @MaxMindDbParameter(name = "continent") Continent continent,
// @JsonProperty("country") @MaxMindDbParameter(name = "country") Country country,
// @JsonProperty("location") @MaxMindDbParameter(name = "location") Location location,
// @JsonProperty("maxmind") @MaxMindDbParameter(name = "maxmind") MaxMind maxmind,
// @JsonProperty("postal") @MaxMindDbParameter(name = "postal") Postal postal,
// @JsonProperty("registered_country") @MaxMindDbParameter(name = "registered_country") Country registeredCountry,
// @JsonProperty("represented_country") @MaxMindDbParameter(name = "represented_country") RepresentedCountry representedCountry,
// @JsonProperty("subdivisions") @MaxMindDbParameter(name = "subdivisions") ArrayList<Subdivision> subdivisions,
// @JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name = "traits") Traits traits
// ) {
// super(city, continent, country, location, maxmind, postal, registeredCountry,
// representedCountry, subdivisions, traits);
// }
//
// public CityResponse(
// CityResponse response,
// String ipAddress,
// Network network,
// List<String> locales
// ) {
// super(response, ipAddress, network, locales);
// }
// }
//
// Path: src/main/java/com/maxmind/geoip2/model/CountryResponse.java
// public final class CountryResponse extends AbstractCountryResponse {
// @MaxMindDbConstructor
// public CountryResponse(
// @JsonProperty("continent") @MaxMindDbParameter(name = "continent") Continent continent,
// @JsonProperty("country") @MaxMindDbParameter(name = "country") Country country,
// @JsonProperty("maxmind") @MaxMindDbParameter(name = "maxmind") MaxMind maxmind,
// @JsonProperty("registered_country") @MaxMindDbParameter(name = "registered_country") Country registeredCountry,
// @JsonProperty("represented_country") @MaxMindDbParameter(name = "represented_country") RepresentedCountry representedCountry,
// @JacksonInject("traits") @JsonProperty("traits") @MaxMindDbParameter(name = "traits") Traits traits
// ) {
// super(continent, country, maxmind, registeredCountry, representedCountry, traits);
// }
//
// public CountryResponse(
// CountryResponse response,
// String ipAddress,
// Network network,
// List<String> locales
// ) {
// super(response, ipAddress, network, locales);
// }
// }
// Path: src/main/java/com/maxmind/geoip2/GeoIp2Provider.java
import com.maxmind.geoip2.exception.GeoIp2Exception;
import com.maxmind.geoip2.model.CityResponse;
import com.maxmind.geoip2.model.CountryResponse;
import java.io.IOException;
import java.net.InetAddress;
package com.maxmind.geoip2;
public interface GeoIp2Provider {
/**
* @param ipAddress IPv4 or IPv6 address to lookup.
* @return A Country model for the requested IP address.
* @throws GeoIp2Exception if there is an error looking up the IP
* @throws IOException if there is an IO error
*/
CountryResponse country(InetAddress ipAddress) throws IOException,
GeoIp2Exception;
/**
* @param ipAddress IPv4 or IPv6 address to lookup.
* @return A City model for the requested IP address.
* @throws GeoIp2Exception if there is an error looking up the IP
* @throws IOException if there is an IO error
*/
|
CityResponse city(InetAddress ipAddress) throws IOException,
|
maxmind/GeoIP2-java
|
src/test/java/com/maxmind/geoip2/WebServiceClientTest.java
|
// Path: src/main/java/com/maxmind/geoip2/model/InsightsResponse.java
// public class InsightsResponse extends AbstractCityResponse {
// public InsightsResponse(
// @JsonProperty("city") City city,
// @JsonProperty("continent") Continent continent,
// @JsonProperty("country") Country country,
// @JsonProperty("location") Location location,
// @JsonProperty("maxmind") MaxMind maxmind,
// @JsonProperty("postal") Postal postal,
// @JsonProperty("registered_country") Country registeredCountry,
// @JsonProperty("represented_country") RepresentedCountry representedCountry,
// @JsonProperty("subdivisions") List<Subdivision> subdivisions,
// @JacksonInject("traits") @JsonProperty("traits") Traits traits
// ) {
// super(city, continent, country, location, maxmind, postal, registeredCountry,
// representedCountry, subdivisions, traits);
// }
// }
|
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.maxmind.geoip2.exception.*;
import com.maxmind.geoip2.model.InsightsResponse;
import com.maxmind.geoip2.record.*;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.hamcrest.CoreMatchers;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.nio.charset.StandardCharsets;
import java.util.List;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.jcabi.matchers.RegexMatchers.matchesPattern;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.StringStartsWith.startsWith;
import static org.junit.Assert.*;
|
package com.maxmind.geoip2;
@RunWith(JUnitParamsRunner.class)
public class WebServiceClientTest {
@Rule
public final WireMockRule wireMockRule = new WireMockRule(0); // 0 picks random port
@Test
public void test200WithNoBody() throws Exception {
WebServiceClient client = createSuccessClient("insights", "me", "");
Exception ex = assertThrows(GeoIp2Exception.class, client::insights);
assertEquals("Received a 200 response but could not decode it as JSON", ex.getMessage());
}
@Test
public void test200WithInvalidJson() throws Exception {
WebServiceClient client = createSuccessClient("insights", "me", "{");
Exception ex = assertThrows(GeoIp2Exception.class, client::insights);
assertEquals("Received a 200 response but could not decode it as JSON", ex.getMessage());
}
@Test
public void test200WithDefaultValues() throws Exception {
WebServiceClient client = createSuccessClient("insights", "1.2.3.13",
"{\"traits\":{\"ip_address\":\"1.2.3.13\",\"network\":\"1.2.3.0/24\"}}");
|
// Path: src/main/java/com/maxmind/geoip2/model/InsightsResponse.java
// public class InsightsResponse extends AbstractCityResponse {
// public InsightsResponse(
// @JsonProperty("city") City city,
// @JsonProperty("continent") Continent continent,
// @JsonProperty("country") Country country,
// @JsonProperty("location") Location location,
// @JsonProperty("maxmind") MaxMind maxmind,
// @JsonProperty("postal") Postal postal,
// @JsonProperty("registered_country") Country registeredCountry,
// @JsonProperty("represented_country") RepresentedCountry representedCountry,
// @JsonProperty("subdivisions") List<Subdivision> subdivisions,
// @JacksonInject("traits") @JsonProperty("traits") Traits traits
// ) {
// super(city, continent, country, location, maxmind, postal, registeredCountry,
// representedCountry, subdivisions, traits);
// }
// }
// Path: src/test/java/com/maxmind/geoip2/WebServiceClientTest.java
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.maxmind.geoip2.exception.*;
import com.maxmind.geoip2.model.InsightsResponse;
import com.maxmind.geoip2.record.*;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.hamcrest.CoreMatchers;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.nio.charset.StandardCharsets;
import java.util.List;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.jcabi.matchers.RegexMatchers.matchesPattern;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.StringStartsWith.startsWith;
import static org.junit.Assert.*;
package com.maxmind.geoip2;
@RunWith(JUnitParamsRunner.class)
public class WebServiceClientTest {
@Rule
public final WireMockRule wireMockRule = new WireMockRule(0); // 0 picks random port
@Test
public void test200WithNoBody() throws Exception {
WebServiceClient client = createSuccessClient("insights", "me", "");
Exception ex = assertThrows(GeoIp2Exception.class, client::insights);
assertEquals("Received a 200 response but could not decode it as JSON", ex.getMessage());
}
@Test
public void test200WithInvalidJson() throws Exception {
WebServiceClient client = createSuccessClient("insights", "me", "{");
Exception ex = assertThrows(GeoIp2Exception.class, client::insights);
assertEquals("Received a 200 response but could not decode it as JSON", ex.getMessage());
}
@Test
public void test200WithDefaultValues() throws Exception {
WebServiceClient client = createSuccessClient("insights", "1.2.3.13",
"{\"traits\":{\"ip_address\":\"1.2.3.13\",\"network\":\"1.2.3.0/24\"}}");
|
InsightsResponse insights = client.insights(InetAddress
|
BottyIvan/Wall
|
app/src/main/java/com/botty/wall/activity/Intro.java
|
// Path: app/src/main/java/com/botty/wall/app/PrefManager.java
// public class PrefManager {
//
// SharedPreferences pref;
// SharedPreferences.Editor editor;
// Context _context;
//
// // shared pref mode
// int PRIVATE_MODE = 0;
//
// // Shared preferences file name
// private static final String PREF_NAME = "com.botty.wall-welcome";
//
// private static final String IS_FIRST_TIME_LAUNCH = "IsFirstTimeLaunch";
//
// private static final String CAN_WRITE_SD = "grant_access";
//
// public PrefManager(Context context) {
// this._context = context;
// pref = _context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
// editor = pref.edit();
// }
//
// public void setFirstTimeLaunch(boolean isFirstTime) {
// editor.putBoolean(IS_FIRST_TIME_LAUNCH, isFirstTime);
// editor.commit();
// }
//
// public boolean isFirstTimeLaunch() {
// return pref.getBoolean(IS_FIRST_TIME_LAUNCH, true);
// }
//
// public void setCanWriteSd(boolean canWriteSd){
// editor.putBoolean(CAN_WRITE_SD, canWriteSd);
// editor.commit();
// }
//
// public boolean canWriteSD(){
// return pref.getBoolean(CAN_WRITE_SD,false);
// }
//
// }
|
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.botty.wall.R;
import com.botty.wall.app.PrefManager;
|
package com.botty.wall.activity;
public class Intro extends AppCompatActivity {
private ViewPager viewPager;
private MyViewPagerAdapter myViewPagerAdapter;
private LinearLayout dotsLayout;
private TextView[] dots;
private int[] layouts;
private Button btnSkip, btnNext;
|
// Path: app/src/main/java/com/botty/wall/app/PrefManager.java
// public class PrefManager {
//
// SharedPreferences pref;
// SharedPreferences.Editor editor;
// Context _context;
//
// // shared pref mode
// int PRIVATE_MODE = 0;
//
// // Shared preferences file name
// private static final String PREF_NAME = "com.botty.wall-welcome";
//
// private static final String IS_FIRST_TIME_LAUNCH = "IsFirstTimeLaunch";
//
// private static final String CAN_WRITE_SD = "grant_access";
//
// public PrefManager(Context context) {
// this._context = context;
// pref = _context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
// editor = pref.edit();
// }
//
// public void setFirstTimeLaunch(boolean isFirstTime) {
// editor.putBoolean(IS_FIRST_TIME_LAUNCH, isFirstTime);
// editor.commit();
// }
//
// public boolean isFirstTimeLaunch() {
// return pref.getBoolean(IS_FIRST_TIME_LAUNCH, true);
// }
//
// public void setCanWriteSd(boolean canWriteSd){
// editor.putBoolean(CAN_WRITE_SD, canWriteSd);
// editor.commit();
// }
//
// public boolean canWriteSD(){
// return pref.getBoolean(CAN_WRITE_SD,false);
// }
//
// }
// Path: app/src/main/java/com/botty/wall/activity/Intro.java
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.botty.wall.R;
import com.botty.wall.app.PrefManager;
package com.botty.wall.activity;
public class Intro extends AppCompatActivity {
private ViewPager viewPager;
private MyViewPagerAdapter myViewPagerAdapter;
private LinearLayout dotsLayout;
private TextView[] dots;
private int[] layouts;
private Button btnSkip, btnNext;
|
private PrefManager prefManager;
|
BottyIvan/Wall
|
app/src/main/java/com/botty/wall/adapter/LibsAdapter.java
|
// Path: app/src/main/java/com/botty/wall/model/libs_model.java
// public class libs_model {
//
// private String nameLib;
// private String linkLib;
// private String iconLib;
// private String creator;
//
// public libs_model(){
//
// }
//
// public libs_model(String nameLib, String linkLib, String iconLib, String creator){
// this.nameLib = nameLib;
// this.linkLib = linkLib;
// this.iconLib = iconLib;
// this.creator = creator;
// }
//
// public void setNameLib(String nameLib) {
// this.nameLib = nameLib;
// }
//
// public String getNameLib() {
// return nameLib;
// }
//
// public void setLinkLib(String linkLib) {
// this.linkLib = linkLib;
// }
//
// public String getLinkLib() {
// return linkLib;
// }
//
// public void setIconLib(String iconLib) {
// this.iconLib = iconLib;
// }
//
// public String getIconLib() {
// return iconLib;
// }
//
// public void setCreator(String creator) {
// this.creator = creator;
// }
//
// public String getCreator() {
// return creator;
// }
// }
//
// Path: app/src/main/java/com/botty/wall/util/ItemClickListener.java
// public interface ItemClickListener {
// void onClick(View view);
// }
|
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.botty.wall.R;
import com.botty.wall.model.libs_model;
import com.botty.wall.util.ItemClickListener;
import com.squareup.picasso.Picasso;
import java.util.List;
|
package com.botty.wall.adapter;
public class LibsAdapter extends RecyclerView.Adapter<LibsAdapter.MyViewHolder> {
private List<libs_model> libs_models;
public Context context;
public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView libsName,creator;
public ImageView libsLogo;
public CardView linkLibs;
|
// Path: app/src/main/java/com/botty/wall/model/libs_model.java
// public class libs_model {
//
// private String nameLib;
// private String linkLib;
// private String iconLib;
// private String creator;
//
// public libs_model(){
//
// }
//
// public libs_model(String nameLib, String linkLib, String iconLib, String creator){
// this.nameLib = nameLib;
// this.linkLib = linkLib;
// this.iconLib = iconLib;
// this.creator = creator;
// }
//
// public void setNameLib(String nameLib) {
// this.nameLib = nameLib;
// }
//
// public String getNameLib() {
// return nameLib;
// }
//
// public void setLinkLib(String linkLib) {
// this.linkLib = linkLib;
// }
//
// public String getLinkLib() {
// return linkLib;
// }
//
// public void setIconLib(String iconLib) {
// this.iconLib = iconLib;
// }
//
// public String getIconLib() {
// return iconLib;
// }
//
// public void setCreator(String creator) {
// this.creator = creator;
// }
//
// public String getCreator() {
// return creator;
// }
// }
//
// Path: app/src/main/java/com/botty/wall/util/ItemClickListener.java
// public interface ItemClickListener {
// void onClick(View view);
// }
// Path: app/src/main/java/com/botty/wall/adapter/LibsAdapter.java
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.botty.wall.R;
import com.botty.wall.model.libs_model;
import com.botty.wall.util.ItemClickListener;
import com.squareup.picasso.Picasso;
import java.util.List;
package com.botty.wall.adapter;
public class LibsAdapter extends RecyclerView.Adapter<LibsAdapter.MyViewHolder> {
private List<libs_model> libs_models;
public Context context;
public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView libsName,creator;
public ImageView libsLogo;
public CardView linkLibs;
|
private ItemClickListener clickListener;
|
BottyIvan/Wall
|
app/src/main/java/com/botty/wall/fragment/LibsFragment.java
|
// Path: app/src/main/java/com/botty/wall/adapter/LibsAdapter.java
// public class LibsAdapter extends RecyclerView.Adapter<LibsAdapter.MyViewHolder> {
//
// private List<libs_model> libs_models;
// public Context context;
//
// public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
// public TextView libsName,creator;
// public ImageView libsLogo;
// public CardView linkLibs;
// private ItemClickListener clickListener;
//
// public MyViewHolder(View view) {
// super(view);
// libsName = view.findViewById(R.id.name_lib);
// libsLogo = view.findViewById(R.id.logo_libs);
// creator = view.findViewById(R.id.name_creator);
// linkLibs = view.findViewById(R.id.link_libs);
//
// view.setOnClickListener(this);
// }
//
// public void setClickListener(ItemClickListener itemClickListener) {
// this.clickListener = itemClickListener;
// }
//
//
// @Override
// public void onClick(View v) {
// clickListener.onClick(v);
// }
//
// }
//
// public LibsAdapter(List<libs_model> libs_models){
// this.libs_models = libs_models;
// }
//
// @Override
// public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View itemView = LayoutInflater.from(parent.getContext())
// .inflate(R.layout.list_libs_item, parent, false);
// return new MyViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(@NonNull MyViewHolder holder, final int position) {
// if (context != null)
// return;
// final libs_model libsModel = libs_models.get(position);
// holder.libsName.setText(libsModel.getNameLib());
// holder.creator.setText(libsModel.getCreator());
//
// Picasso.get()
// .load(libsModel.getIconLib())
// .noFade()
// .into(holder.libsLogo);
// }
//
//
// @Override
// public int getItemCount() {
// return libs_models.size();
// }
// }
//
// Path: app/src/main/java/com/botty/wall/model/libs_model.java
// public class libs_model {
//
// private String nameLib;
// private String linkLib;
// private String iconLib;
// private String creator;
//
// public libs_model(){
//
// }
//
// public libs_model(String nameLib, String linkLib, String iconLib, String creator){
// this.nameLib = nameLib;
// this.linkLib = linkLib;
// this.iconLib = iconLib;
// this.creator = creator;
// }
//
// public void setNameLib(String nameLib) {
// this.nameLib = nameLib;
// }
//
// public String getNameLib() {
// return nameLib;
// }
//
// public void setLinkLib(String linkLib) {
// this.linkLib = linkLib;
// }
//
// public String getLinkLib() {
// return linkLib;
// }
//
// public void setIconLib(String iconLib) {
// this.iconLib = iconLib;
// }
//
// public String getIconLib() {
// return iconLib;
// }
//
// public void setCreator(String creator) {
// this.creator = creator;
// }
//
// public String getCreator() {
// return creator;
// }
// }
|
import android.os.Bundle;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import com.botty.wall.R;
import com.botty.wall.adapter.LibsAdapter;
import com.botty.wall.model.libs_model;
import java.util.ArrayList;
import java.util.List;
|
package com.botty.wall.fragment;
public class LibsFragment extends BaseFragment {
private LibsAdapter libsAdapter;
private StaggeredGridLayoutManager staggeredGridLayoutManager;
|
// Path: app/src/main/java/com/botty/wall/adapter/LibsAdapter.java
// public class LibsAdapter extends RecyclerView.Adapter<LibsAdapter.MyViewHolder> {
//
// private List<libs_model> libs_models;
// public Context context;
//
// public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
// public TextView libsName,creator;
// public ImageView libsLogo;
// public CardView linkLibs;
// private ItemClickListener clickListener;
//
// public MyViewHolder(View view) {
// super(view);
// libsName = view.findViewById(R.id.name_lib);
// libsLogo = view.findViewById(R.id.logo_libs);
// creator = view.findViewById(R.id.name_creator);
// linkLibs = view.findViewById(R.id.link_libs);
//
// view.setOnClickListener(this);
// }
//
// public void setClickListener(ItemClickListener itemClickListener) {
// this.clickListener = itemClickListener;
// }
//
//
// @Override
// public void onClick(View v) {
// clickListener.onClick(v);
// }
//
// }
//
// public LibsAdapter(List<libs_model> libs_models){
// this.libs_models = libs_models;
// }
//
// @Override
// public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View itemView = LayoutInflater.from(parent.getContext())
// .inflate(R.layout.list_libs_item, parent, false);
// return new MyViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(@NonNull MyViewHolder holder, final int position) {
// if (context != null)
// return;
// final libs_model libsModel = libs_models.get(position);
// holder.libsName.setText(libsModel.getNameLib());
// holder.creator.setText(libsModel.getCreator());
//
// Picasso.get()
// .load(libsModel.getIconLib())
// .noFade()
// .into(holder.libsLogo);
// }
//
//
// @Override
// public int getItemCount() {
// return libs_models.size();
// }
// }
//
// Path: app/src/main/java/com/botty/wall/model/libs_model.java
// public class libs_model {
//
// private String nameLib;
// private String linkLib;
// private String iconLib;
// private String creator;
//
// public libs_model(){
//
// }
//
// public libs_model(String nameLib, String linkLib, String iconLib, String creator){
// this.nameLib = nameLib;
// this.linkLib = linkLib;
// this.iconLib = iconLib;
// this.creator = creator;
// }
//
// public void setNameLib(String nameLib) {
// this.nameLib = nameLib;
// }
//
// public String getNameLib() {
// return nameLib;
// }
//
// public void setLinkLib(String linkLib) {
// this.linkLib = linkLib;
// }
//
// public String getLinkLib() {
// return linkLib;
// }
//
// public void setIconLib(String iconLib) {
// this.iconLib = iconLib;
// }
//
// public String getIconLib() {
// return iconLib;
// }
//
// public void setCreator(String creator) {
// this.creator = creator;
// }
//
// public String getCreator() {
// return creator;
// }
// }
// Path: app/src/main/java/com/botty/wall/fragment/LibsFragment.java
import android.os.Bundle;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import com.botty.wall.R;
import com.botty.wall.adapter.LibsAdapter;
import com.botty.wall.model.libs_model;
import java.util.ArrayList;
import java.util.List;
package com.botty.wall.fragment;
public class LibsFragment extends BaseFragment {
private LibsAdapter libsAdapter;
private StaggeredGridLayoutManager staggeredGridLayoutManager;
|
private List<libs_model> libs_models = new ArrayList<>();
|
BottyIvan/Wall
|
app/src/main/java/com/botty/wall/activity/Settings.java
|
// Path: app/src/main/java/com/botty/wall/fragment/SettingsFragment.java
// public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
//
// public static final String NIGHTMODE = "nightmode";
// public static final String TWO_ROW = "two_row";
// public static final String SWIPE_ACTIVITY_WALL = "swipe_ui_wall_act";
// public static final String DIRECTORY_NAME = "directory";
//
// public static final String VERSION = "version";
//
// final private int REQUEST_CODE_ASK_PERMISSIONS = 123;
//
// private PrefManager prefManager;
// private Preference myAskSD,myVers;
//
// @Override
// public void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// addPreferencesFromResource(R.xml.preferences);
//
// myAskSD = findPreference("grant_access");
// myAskSD.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
// public boolean onPreferenceClick(Preference preference) {
// //open browser or intent here
// AskForWriteSDPermission();
// return true;
// }
// });
//
// myVers = findPreference("version");
// myVers.setTitle(getVersionApp(getActivity()));
// }
//
// public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
// String key) {
// if (key.equals(NIGHTMODE)) {
// sharedPreferences.getBoolean(key, true);
// } else if (key.equals(TWO_ROW)) {
// sharedPreferences.getBoolean(key, true);
// } else if (key.equals(SWIPE_ACTIVITY_WALL)) {
// sharedPreferences.getBoolean(key, true);
// } else if (key.equals(DIRECTORY_NAME)){
// Preference preference = findPreference(key);
// if (preference instanceof EditTextPreference){
// EditTextPreference editTextPreference = (EditTextPreference)preference;
// if (editTextPreference.getText().trim().length() > 0){
// editTextPreference.setSummary(editTextPreference.getText());
// }else{
// editTextPreference.setText("Not change");
// }
// }
// }
//
// if (key.equals(VERSION)){
// Preference customPref = findPreference(key);
// customPref.setSummary(getVersionApp(getActivity()));
// }
//
// }
// public static String getVersionApp(Context context){
// PackageInfo pInfo = null;
// String str = null;
// try {
// pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
// } catch (PackageManager.NameNotFoundException e) {
// e.printStackTrace();
// }
// String version = pInfo.versionName;
// int verCode = pInfo.versionCode;
// str = context.getString(R.string.app_name)+" "+" "+version+" ( "+verCode+" ) ";
// return str;
// }
//
// /**
// * Start method for asking the permission to write SD card
// */
// protected void AskForWriteSDPermission() {
// if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
// int hasWriteSDPermission = getActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
// if (hasWriteSDPermission != PackageManager.PERMISSION_GRANTED) {
// requestPermissions(new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE},
// REQUEST_CODE_ASK_PERMISSIONS);
// return;
// }
// }
// }
//
// @Override
// public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
// switch (requestCode) {
// case REQUEST_CODE_ASK_PERMISSIONS:
// if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// // Permission Granted
// prefManager = new PrefManager(getActivity());
// prefManager.setCanWriteSd(true);;
// CreateDirectory();
// Toast.makeText(getActivity(), R.string.can_download_wall, Toast.LENGTH_SHORT)
// .show();
// } else {
// // Permission Denied
// Toast.makeText(getActivity(), R.string.cant_download_wall, Toast.LENGTH_SHORT)
// .show();
// }
// break;
// default:
// super.onRequestPermissionsResult(requestCode, permissions, grantResults);
// }
// }
//
// protected void CreateDirectory(){
// File wallpaperDirectory = new File("/sdcard/WallApp/");
// wallpaperDirectory.mkdirs();
// }
//
// // End asking permission for SD card
// }
|
import android.os.Build;
import android.os.Bundle;
import android.preference.Preference;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.transition.Explode;
import android.view.Window;
import com.botty.wall.R;
import com.botty.wall.fragment.SettingsFragment;
|
package com.botty.wall.activity;
public class Settings extends AppCompatActivity {
private Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// inside your activity (if you did not enable transitions in your theme)
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
getWindow().setEnterTransition(new Explode());
// set an exit transition
getWindow().setExitTransition(new Explode());
}
setContentView(R.layout.activity_settings);
toolbar = (Toolbar) findViewById(R.id.toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
|
// Path: app/src/main/java/com/botty/wall/fragment/SettingsFragment.java
// public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
//
// public static final String NIGHTMODE = "nightmode";
// public static final String TWO_ROW = "two_row";
// public static final String SWIPE_ACTIVITY_WALL = "swipe_ui_wall_act";
// public static final String DIRECTORY_NAME = "directory";
//
// public static final String VERSION = "version";
//
// final private int REQUEST_CODE_ASK_PERMISSIONS = 123;
//
// private PrefManager prefManager;
// private Preference myAskSD,myVers;
//
// @Override
// public void onCreate(final Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// addPreferencesFromResource(R.xml.preferences);
//
// myAskSD = findPreference("grant_access");
// myAskSD.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
// public boolean onPreferenceClick(Preference preference) {
// //open browser or intent here
// AskForWriteSDPermission();
// return true;
// }
// });
//
// myVers = findPreference("version");
// myVers.setTitle(getVersionApp(getActivity()));
// }
//
// public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
// String key) {
// if (key.equals(NIGHTMODE)) {
// sharedPreferences.getBoolean(key, true);
// } else if (key.equals(TWO_ROW)) {
// sharedPreferences.getBoolean(key, true);
// } else if (key.equals(SWIPE_ACTIVITY_WALL)) {
// sharedPreferences.getBoolean(key, true);
// } else if (key.equals(DIRECTORY_NAME)){
// Preference preference = findPreference(key);
// if (preference instanceof EditTextPreference){
// EditTextPreference editTextPreference = (EditTextPreference)preference;
// if (editTextPreference.getText().trim().length() > 0){
// editTextPreference.setSummary(editTextPreference.getText());
// }else{
// editTextPreference.setText("Not change");
// }
// }
// }
//
// if (key.equals(VERSION)){
// Preference customPref = findPreference(key);
// customPref.setSummary(getVersionApp(getActivity()));
// }
//
// }
// public static String getVersionApp(Context context){
// PackageInfo pInfo = null;
// String str = null;
// try {
// pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
// } catch (PackageManager.NameNotFoundException e) {
// e.printStackTrace();
// }
// String version = pInfo.versionName;
// int verCode = pInfo.versionCode;
// str = context.getString(R.string.app_name)+" "+" "+version+" ( "+verCode+" ) ";
// return str;
// }
//
// /**
// * Start method for asking the permission to write SD card
// */
// protected void AskForWriteSDPermission() {
// if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
// int hasWriteSDPermission = getActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
// if (hasWriteSDPermission != PackageManager.PERMISSION_GRANTED) {
// requestPermissions(new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE},
// REQUEST_CODE_ASK_PERMISSIONS);
// return;
// }
// }
// }
//
// @Override
// public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
// switch (requestCode) {
// case REQUEST_CODE_ASK_PERMISSIONS:
// if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// // Permission Granted
// prefManager = new PrefManager(getActivity());
// prefManager.setCanWriteSd(true);;
// CreateDirectory();
// Toast.makeText(getActivity(), R.string.can_download_wall, Toast.LENGTH_SHORT)
// .show();
// } else {
// // Permission Denied
// Toast.makeText(getActivity(), R.string.cant_download_wall, Toast.LENGTH_SHORT)
// .show();
// }
// break;
// default:
// super.onRequestPermissionsResult(requestCode, permissions, grantResults);
// }
// }
//
// protected void CreateDirectory(){
// File wallpaperDirectory = new File("/sdcard/WallApp/");
// wallpaperDirectory.mkdirs();
// }
//
// // End asking permission for SD card
// }
// Path: app/src/main/java/com/botty/wall/activity/Settings.java
import android.os.Build;
import android.os.Bundle;
import android.preference.Preference;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.transition.Explode;
import android.view.Window;
import com.botty.wall.R;
import com.botty.wall.fragment.SettingsFragment;
package com.botty.wall.activity;
public class Settings extends AppCompatActivity {
private Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// inside your activity (if you did not enable transitions in your theme)
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
getWindow().setEnterTransition(new Explode());
// set an exit transition
getWindow().setExitTransition(new Explode());
}
setContentView(R.layout.activity_settings);
toolbar = (Toolbar) findViewById(R.id.toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
|
getFragmentManager().beginTransaction().replace(R.id.content_frame, new SettingsFragment()).commit();
|
BottyIvan/Wall
|
app/src/main/java/com/botty/wall/fragment/SettingsFragment.java
|
// Path: app/src/main/java/com/botty/wall/app/PrefManager.java
// public class PrefManager {
//
// SharedPreferences pref;
// SharedPreferences.Editor editor;
// Context _context;
//
// // shared pref mode
// int PRIVATE_MODE = 0;
//
// // Shared preferences file name
// private static final String PREF_NAME = "com.botty.wall-welcome";
//
// private static final String IS_FIRST_TIME_LAUNCH = "IsFirstTimeLaunch";
//
// private static final String CAN_WRITE_SD = "grant_access";
//
// public PrefManager(Context context) {
// this._context = context;
// pref = _context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
// editor = pref.edit();
// }
//
// public void setFirstTimeLaunch(boolean isFirstTime) {
// editor.putBoolean(IS_FIRST_TIME_LAUNCH, isFirstTime);
// editor.commit();
// }
//
// public boolean isFirstTimeLaunch() {
// return pref.getBoolean(IS_FIRST_TIME_LAUNCH, true);
// }
//
// public void setCanWriteSd(boolean canWriteSd){
// editor.putBoolean(CAN_WRITE_SD, canWriteSd);
// editor.commit();
// }
//
// public boolean canWriteSD(){
// return pref.getBoolean(CAN_WRITE_SD,false);
// }
//
// }
|
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.widget.Toast;
import com.botty.wall.R;
import com.botty.wall.app.PrefManager;
import java.io.File;
|
package com.botty.wall.fragment;
/**
* Created by BottyIvan on 06/08/16.
*/
public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
public static final String NIGHTMODE = "nightmode";
public static final String TWO_ROW = "two_row";
public static final String SWIPE_ACTIVITY_WALL = "swipe_ui_wall_act";
public static final String DIRECTORY_NAME = "directory";
public static final String VERSION = "version";
final private int REQUEST_CODE_ASK_PERMISSIONS = 123;
|
// Path: app/src/main/java/com/botty/wall/app/PrefManager.java
// public class PrefManager {
//
// SharedPreferences pref;
// SharedPreferences.Editor editor;
// Context _context;
//
// // shared pref mode
// int PRIVATE_MODE = 0;
//
// // Shared preferences file name
// private static final String PREF_NAME = "com.botty.wall-welcome";
//
// private static final String IS_FIRST_TIME_LAUNCH = "IsFirstTimeLaunch";
//
// private static final String CAN_WRITE_SD = "grant_access";
//
// public PrefManager(Context context) {
// this._context = context;
// pref = _context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
// editor = pref.edit();
// }
//
// public void setFirstTimeLaunch(boolean isFirstTime) {
// editor.putBoolean(IS_FIRST_TIME_LAUNCH, isFirstTime);
// editor.commit();
// }
//
// public boolean isFirstTimeLaunch() {
// return pref.getBoolean(IS_FIRST_TIME_LAUNCH, true);
// }
//
// public void setCanWriteSd(boolean canWriteSd){
// editor.putBoolean(CAN_WRITE_SD, canWriteSd);
// editor.commit();
// }
//
// public boolean canWriteSD(){
// return pref.getBoolean(CAN_WRITE_SD,false);
// }
//
// }
// Path: app/src/main/java/com/botty/wall/fragment/SettingsFragment.java
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.widget.Toast;
import com.botty.wall.R;
import com.botty.wall.app.PrefManager;
import java.io.File;
package com.botty.wall.fragment;
/**
* Created by BottyIvan on 06/08/16.
*/
public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
public static final String NIGHTMODE = "nightmode";
public static final String TWO_ROW = "two_row";
public static final String SWIPE_ACTIVITY_WALL = "swipe_ui_wall_act";
public static final String DIRECTORY_NAME = "directory";
public static final String VERSION = "version";
final private int REQUEST_CODE_ASK_PERMISSIONS = 123;
|
private PrefManager prefManager;
|
BottyIvan/Wall
|
app/src/main/java/com/botty/wall/fragment/SocialFragment.java
|
// Path: app/src/main/java/com/botty/wall/adapter/SocialAdapter.java
// public class SocialAdapter extends RecyclerView.Adapter<SocialAdapter.MyViewHolder>{
//
// private List<linkSocial> linkSocialList;
// public Context context;
//
// public class MyViewHolder extends RecyclerView.ViewHolder {
// public TextView sName;
// public Button sLink;
// public ImageView sLogo;
//
// public MyViewHolder(View view) {
// super(view);
// sName = view.findViewById(R.id.social_title);
// sLink = view.findViewById(R.id.social_link);
// sLogo = view.findViewById(R.id.social_logo);
// }
// }
//
// public SocialAdapter(List<linkSocial> linkSocialList){
// this.linkSocialList = linkSocialList;
// }
//
// @Override
// public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View itemView = LayoutInflater.from(parent.getContext())
// .inflate(R.layout.row, parent, false);
// return new MyViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(final MyViewHolder holder, int position) {
// if (context != null)
// return;
// final linkSocial linkSocial = linkSocialList.get(position);
// holder.sName.setText(linkSocial.getNomeSocial());
// holder.sLink.setText(linkSocial.getLinkSocial());
//
// if (linkSocial.getUrl() != null){
// Picasso.get()
// .load(linkSocial.getUrl())
// .noFade()
// .into(holder.sLogo);
// } else {
// holder.sLogo.setVisibility(View.GONE);
// }
// }
//
//
// @Override
// public int getItemCount() {
// return linkSocialList.size();
// }
// }
//
// Path: app/src/main/java/com/botty/wall/model/linkSocial.java
// public class linkSocial {
//
// private String nomeSocial;
// private String linkSocial;
// private String url;
// private String urlLink;
//
// public linkSocial(String nomeSocial,String linkSocial,String url,String urlLink){
// this.nomeSocial = nomeSocial;
// this.linkSocial = linkSocial;
// this.urlLink = urlLink;
// this.url = url;
// }
//
// public void setNomeSocial(String nomeSocial){
// this.nomeSocial = nomeSocial;
// }
//
// public String getNomeSocial(){
// return this.nomeSocial;
// }
//
// public void setLinkSocial(String linkSocial){
// this.linkSocial = linkSocial;
// }
//
// public String getLinkSocial(){
// return this.linkSocial;
// }
//
// public void setUrl(String url){
// this.url = url;
// }
//
// public String getUrl(){
// return this.url;
// }
//
// public void setUrlLink(String urlLink){this.urlLink = urlLink;}
//
// public String getUrlLink() {
// return this.urlLink;
// }
//
// }
|
import android.os.Bundle;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.botty.wall.R;
import com.botty.wall.adapter.SocialAdapter;
import com.botty.wall.model.linkSocial;
import java.util.ArrayList;
import java.util.List;
|
package com.botty.wall.fragment;
public class SocialFragment extends BaseFragment {
private SocialAdapter listLibsAdapter;
private StaggeredGridLayoutManager staggeredGridLayoutManager;
|
// Path: app/src/main/java/com/botty/wall/adapter/SocialAdapter.java
// public class SocialAdapter extends RecyclerView.Adapter<SocialAdapter.MyViewHolder>{
//
// private List<linkSocial> linkSocialList;
// public Context context;
//
// public class MyViewHolder extends RecyclerView.ViewHolder {
// public TextView sName;
// public Button sLink;
// public ImageView sLogo;
//
// public MyViewHolder(View view) {
// super(view);
// sName = view.findViewById(R.id.social_title);
// sLink = view.findViewById(R.id.social_link);
// sLogo = view.findViewById(R.id.social_logo);
// }
// }
//
// public SocialAdapter(List<linkSocial> linkSocialList){
// this.linkSocialList = linkSocialList;
// }
//
// @Override
// public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View itemView = LayoutInflater.from(parent.getContext())
// .inflate(R.layout.row, parent, false);
// return new MyViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(final MyViewHolder holder, int position) {
// if (context != null)
// return;
// final linkSocial linkSocial = linkSocialList.get(position);
// holder.sName.setText(linkSocial.getNomeSocial());
// holder.sLink.setText(linkSocial.getLinkSocial());
//
// if (linkSocial.getUrl() != null){
// Picasso.get()
// .load(linkSocial.getUrl())
// .noFade()
// .into(holder.sLogo);
// } else {
// holder.sLogo.setVisibility(View.GONE);
// }
// }
//
//
// @Override
// public int getItemCount() {
// return linkSocialList.size();
// }
// }
//
// Path: app/src/main/java/com/botty/wall/model/linkSocial.java
// public class linkSocial {
//
// private String nomeSocial;
// private String linkSocial;
// private String url;
// private String urlLink;
//
// public linkSocial(String nomeSocial,String linkSocial,String url,String urlLink){
// this.nomeSocial = nomeSocial;
// this.linkSocial = linkSocial;
// this.urlLink = urlLink;
// this.url = url;
// }
//
// public void setNomeSocial(String nomeSocial){
// this.nomeSocial = nomeSocial;
// }
//
// public String getNomeSocial(){
// return this.nomeSocial;
// }
//
// public void setLinkSocial(String linkSocial){
// this.linkSocial = linkSocial;
// }
//
// public String getLinkSocial(){
// return this.linkSocial;
// }
//
// public void setUrl(String url){
// this.url = url;
// }
//
// public String getUrl(){
// return this.url;
// }
//
// public void setUrlLink(String urlLink){this.urlLink = urlLink;}
//
// public String getUrlLink() {
// return this.urlLink;
// }
//
// }
// Path: app/src/main/java/com/botty/wall/fragment/SocialFragment.java
import android.os.Bundle;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.botty.wall.R;
import com.botty.wall.adapter.SocialAdapter;
import com.botty.wall.model.linkSocial;
import java.util.ArrayList;
import java.util.List;
package com.botty.wall.fragment;
public class SocialFragment extends BaseFragment {
private SocialAdapter listLibsAdapter;
private StaggeredGridLayoutManager staggeredGridLayoutManager;
|
private List<linkSocial> linkSocials = new ArrayList<>();
|
BottyIvan/Wall
|
app/src/main/java/com/botty/wall/activity/ImageFull.java
|
// Path: app/src/main/java/com/botty/wall/model/Image.java
// public class Image implements Serializable{
// private String name;
// private String small, medium, large,path;
// private String timestamp;
//
// public Image() {
// }
//
// public Image(String name, String small, String medium, String large, String timestamp) {
// this.name = name;
// this.small = small;
// this.medium = medium;
// this.large = large;
// this.timestamp = timestamp;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getSmall() {
// return small;
// }
//
// public void setSmall(String small) {
// this.small = small;
// }
//
// public String getMedium() {
// return medium;
// }
//
// public void setMedium(String medium) {
// this.medium = medium;
// }
//
// public String getLarge() {
// return large;
// }
//
// public void setLarge(String large) {
// this.large = large;
// }
//
// public String getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(String timestamp) {
// this.timestamp = timestamp;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path){
// this.path = path;
// }
// }
|
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.WallpaperManager;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.StrictMode;
import android.support.design.widget.BottomSheetDialog;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.botty.wall.R;
import com.botty.wall.model.Image;
import com.squareup.picasso.Picasso;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
|
package com.botty.wall.activity;
public class ImageFull extends BaseActivity {
private String TAG = ImageFull.class.getSimpleName();
|
// Path: app/src/main/java/com/botty/wall/model/Image.java
// public class Image implements Serializable{
// private String name;
// private String small, medium, large,path;
// private String timestamp;
//
// public Image() {
// }
//
// public Image(String name, String small, String medium, String large, String timestamp) {
// this.name = name;
// this.small = small;
// this.medium = medium;
// this.large = large;
// this.timestamp = timestamp;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getSmall() {
// return small;
// }
//
// public void setSmall(String small) {
// this.small = small;
// }
//
// public String getMedium() {
// return medium;
// }
//
// public void setMedium(String medium) {
// this.medium = medium;
// }
//
// public String getLarge() {
// return large;
// }
//
// public void setLarge(String large) {
// this.large = large;
// }
//
// public String getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(String timestamp) {
// this.timestamp = timestamp;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path){
// this.path = path;
// }
// }
// Path: app/src/main/java/com/botty/wall/activity/ImageFull.java
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.WallpaperManager;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.StrictMode;
import android.support.design.widget.BottomSheetDialog;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.botty.wall.R;
import com.botty.wall.model.Image;
import com.squareup.picasso.Picasso;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
package com.botty.wall.activity;
public class ImageFull extends BaseActivity {
private String TAG = ImageFull.class.getSimpleName();
|
private static ArrayList<Image> images;
|
suewonjp/civilizer
|
src/main/java/com/civilizer/domain/TextDecorator.java
|
// Path: src/main/java/com/civilizer/utils/Pair.java
// public final class Pair<A, B> {
//
// private final A first;
// private final B second;
//
// public Pair(A first, B second) {
// this.first = first;
// this.second = second;
// }
//
// public int hashCode() {
// int hashFirst = first != null ? first.hashCode() : 0;
// int hashSecond = second != null ? second.hashCode() : 0;
//
// return (hashFirst + hashSecond) * hashSecond + hashFirst;
// }
//
// public boolean equals(Object other) {
// if (other instanceof Pair) {
// Pair<?, ?> otherPair = (Pair<?, ?>) other;
// return
// (( this.first == otherPair.first ||
// ( this.first != null && otherPair.first != null &&
// this.first.equals(otherPair.first))) &&
// ( this.second == otherPair.second ||
// ( this.second != null && otherPair.second != null &&
// this.second.equals(otherPair.second))) );
// }
//
// return false;
// }
//
// public String toString()
// {
// return "(" + first + ", " + second + ")";
// }
//
// public A getFirst() {
// return first;
// }
//
// public B getSecond() {
// return second;
// }
//
// }
|
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.civilizer.utils.Pair;
|
package com.civilizer.domain;
public final class TextDecorator {
public static final String PREFIX_FOR_HIGHLIGHT = "%28%7B%28%5Bsh%5D%20";
public static final String POSTFIX_FOR_HIGHLIGHT = "%20%29%7D%29";
private static final RangeComparator rangeComparator = new RangeComparator();
|
// Path: src/main/java/com/civilizer/utils/Pair.java
// public final class Pair<A, B> {
//
// private final A first;
// private final B second;
//
// public Pair(A first, B second) {
// this.first = first;
// this.second = second;
// }
//
// public int hashCode() {
// int hashFirst = first != null ? first.hashCode() : 0;
// int hashSecond = second != null ? second.hashCode() : 0;
//
// return (hashFirst + hashSecond) * hashSecond + hashFirst;
// }
//
// public boolean equals(Object other) {
// if (other instanceof Pair) {
// Pair<?, ?> otherPair = (Pair<?, ?>) other;
// return
// (( this.first == otherPair.first ||
// ( this.first != null && otherPair.first != null &&
// this.first.equals(otherPair.first))) &&
// ( this.second == otherPair.second ||
// ( this.second != null && otherPair.second != null &&
// this.second.equals(otherPair.second))) );
// }
//
// return false;
// }
//
// public String toString()
// {
// return "(" + first + ", " + second + ")";
// }
//
// public A getFirst() {
// return first;
// }
//
// public B getSecond() {
// return second;
// }
//
// }
// Path: src/main/java/com/civilizer/domain/TextDecorator.java
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.civilizer.utils.Pair;
package com.civilizer.domain;
public final class TextDecorator {
public static final String PREFIX_FOR_HIGHLIGHT = "%28%7B%28%5Bsh%5D%20";
public static final String POSTFIX_FOR_HIGHLIGHT = "%20%29%7D%29";
private static final RangeComparator rangeComparator = new RangeComparator();
|
private static class RangeComparator implements Comparator<Pair<Integer, Integer>> {
|
suewonjp/civilizer
|
src/main/java/com/civilizer/domain/SearchParams.java
|
// Path: src/main/java/com/civilizer/utils/Pair.java
// public final class Pair<A, B> {
//
// private final A first;
// private final B second;
//
// public Pair(A first, B second) {
// this.first = first;
// this.second = second;
// }
//
// public int hashCode() {
// int hashFirst = first != null ? first.hashCode() : 0;
// int hashSecond = second != null ? second.hashCode() : 0;
//
// return (hashFirst + hashSecond) * hashSecond + hashFirst;
// }
//
// public boolean equals(Object other) {
// if (other instanceof Pair) {
// Pair<?, ?> otherPair = (Pair<?, ?>) other;
// return
// (( this.first == otherPair.first ||
// ( this.first != null && otherPair.first != null &&
// this.first.equals(otherPair.first))) &&
// ( this.second == otherPair.second ||
// ( this.second != null && otherPair.second != null &&
// this.second.equals(otherPair.second))) );
// }
//
// return false;
// }
//
// public String toString()
// {
// return "(" + first + ", " + second + ")";
// }
//
// public A getFirst() {
// return first;
// }
//
// public B getSecond() {
// return second;
// }
//
// }
|
import java.io.Serializable;
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import com.civilizer.utils.Pair;
|
if (word.startsWith("\"") && word.endsWith("\"")) {
// [RULE] "..." treats phrases containing spaces as a single unit
// Also any flag or directive inside the quotes will be treated as normal trivial characters
if (word.length() > 1) {
word = word.substring(1, word.length() - 1);
}
}
if (beginningWith && endingWith)
wholeWord = true;
if (wholeWord)
beginningWith = endingWith = true;
if (regex) {
// 'r' flag assumes case sensitivity regardless of the value of 'c' flag
caseSensitive = true;
// also 'r' flag ignores other pattern matching flags
wholeWord = beginningWith = endingWith = false;
}
this.word = word;
this.caseSensitive = caseSensitive;
this.wholeWord = wholeWord;
this.beginningWith = beginningWith;
this.endingWith = endingWith;
this.regex = regex;
this.inverse = inverse;
this.id = id;
this.tagHeirarchy = tagHeirarchy;
}
|
// Path: src/main/java/com/civilizer/utils/Pair.java
// public final class Pair<A, B> {
//
// private final A first;
// private final B second;
//
// public Pair(A first, B second) {
// this.first = first;
// this.second = second;
// }
//
// public int hashCode() {
// int hashFirst = first != null ? first.hashCode() : 0;
// int hashSecond = second != null ? second.hashCode() : 0;
//
// return (hashFirst + hashSecond) * hashSecond + hashFirst;
// }
//
// public boolean equals(Object other) {
// if (other instanceof Pair) {
// Pair<?, ?> otherPair = (Pair<?, ?>) other;
// return
// (( this.first == otherPair.first ||
// ( this.first != null && otherPair.first != null &&
// this.first.equals(otherPair.first))) &&
// ( this.second == otherPair.second ||
// ( this.second != null && otherPair.second != null &&
// this.second.equals(otherPair.second))) );
// }
//
// return false;
// }
//
// public String toString()
// {
// return "(" + first + ", " + second + ")";
// }
//
// public A getFirst() {
// return first;
// }
//
// public B getSecond() {
// return second;
// }
//
// }
// Path: src/main/java/com/civilizer/domain/SearchParams.java
import java.io.Serializable;
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import com.civilizer.utils.Pair;
if (word.startsWith("\"") && word.endsWith("\"")) {
// [RULE] "..." treats phrases containing spaces as a single unit
// Also any flag or directive inside the quotes will be treated as normal trivial characters
if (word.length() > 1) {
word = word.substring(1, word.length() - 1);
}
}
if (beginningWith && endingWith)
wholeWord = true;
if (wholeWord)
beginningWith = endingWith = true;
if (regex) {
// 'r' flag assumes case sensitivity regardless of the value of 'c' flag
caseSensitive = true;
// also 'r' flag ignores other pattern matching flags
wholeWord = beginningWith = endingWith = false;
}
this.word = word;
this.caseSensitive = caseSensitive;
this.wholeWord = wholeWord;
this.beginningWith = beginningWith;
this.endingWith = endingWith;
this.regex = regex;
this.inverse = inverse;
this.id = id;
this.tagHeirarchy = tagHeirarchy;
}
|
public static Pair<String, Character> escapeSqlWildcardCharacters(String word) {
|
suewonjp/civilizer
|
src/main/java/com/civilizer/web/view/AuthenticationBean.java
|
// Path: src/main/java/com/civilizer/security/UserDetailsService.java
// public final class UserDetailsService
// implements org.springframework.security.core.userdetails.UserDetailsService {
//
// public static final int ENCRYPTION_STRENGTH = 11;
// public static final String CREDENTIAL_FILE = ".cvz.pc";
// private static final String HASHED_DEFAULT_PW = "$2a$10$w.Jjtx0mrjH4E.DxQEmBZu.D1oCBKy26utS8KCOSn0fmq1xs2GXiK";
//
// private static UserDetails createUserDetails(String username, String passwordCode) {
// List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
// authorities.add(new SimpleGrantedAuthority("ROLE_USER"));
// return new User(username, passwordCode, authorities);
// }
//
// private static UserDetails getDefaultCredential(String username) {
// if (username.equals("owner")) {
// return createUserDetails(username, HASHED_DEFAULT_PW);
// }
// return null;
// }
//
// public static boolean encodingMatches(String raw, String encoded) {
// return new BCryptPasswordEncoder(UserDetailsService.ENCRYPTION_STRENGTH)
// .matches(raw, encoded);
// }
//
// private static UserDetails getCustomCredential(String username, String usernameCode, String passwordCode) {
// if (encodingMatches(username, usernameCode)) {
// return createUserDetails(username, passwordCode);
// }
// return null;
// }
//
// public static File getCredentialFile() {
// final String homePath = System.getProperty(AppOptions.PRIVATE_HOME_PATH);
// final String credFilePath = FsUtil.getAbsolutePath(CREDENTIAL_FILE, homePath);
// return new File(credFilePath);
// }
//
// public static void saveCustomCredential(String username, String password, String oldPwHash)
// throws IOException, InvalidParameterException {
//
// final BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(ENCRYPTION_STRENGTH);
// final List<String> lines = new ArrayList<>();
// if (username == null || username.isEmpty()) {
// throw new InvalidParameterException();
// }
// lines.add(encoder.encode(username));
// if (password == null || password.isEmpty()) {
// if (oldPwHash != null && !oldPwHash.isEmpty())
// lines.add(oldPwHash);
// else
// throw new InvalidParameterException();
// }
// else
// lines.add(encoder.encode(password));
// FileUtils.writeLines(UserDetailsService.getCredentialFile(), lines, "\n");
// }
//
// public static boolean authenticatePassword(String pw) {
// final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
// final Object principal = auth.getPrincipal();
// if (principal instanceof UserDetails) {
// final UserDetails ud = (UserDetails) principal;
// return encodingMatches(pw, ud.getPassword());
// }
// return false;
// }
//
// @Override
// public UserDetails loadUserByUsername(String username)
// throws UsernameNotFoundException {
// final Logger logger = LoggerFactory.getLogger(UserDetailsService.class);
// final File credentialFile = getCredentialFile();
// UserDetails output = null;
// boolean customCredential = credentialFile.isFile();
//
// if (customCredential) {
// try {
// final String content = FileUtils.readFileToString(credentialFile);
// final String[] tmp = content.split("\n");
// logger.info("processing custom credential...");
// output = getCustomCredential(username, tmp[0], tmp[1]);
// } catch (IOException e) {
// logger.error("Error in reading the file {}", credentialFile.getAbsoluteFile());
// e.printStackTrace();
// logger.error("Switching to default credential...");
// customCredential = false;
// }
// }
//
// if (customCredential == false) {
// logger.info("processing default credential...");
// output = getDefaultCredential(username);
// }
//
// if (output != null) {
// return output;
// }
//
// logger.info("authentication for {} failed!", username);
// throw new BadCredentialsException("Bad Credentials");
// }
//
// }
|
import java.io.Serializable;
import org.primefaces.context.RequestContext;
import com.civilizer.security.UserDetailsService;
|
package com.civilizer.web.view;
@SuppressWarnings("serial")
public final class AuthenticationBean implements Serializable {
private String password = "";
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public void validate() {
final String pw = password;
password = "";
|
// Path: src/main/java/com/civilizer/security/UserDetailsService.java
// public final class UserDetailsService
// implements org.springframework.security.core.userdetails.UserDetailsService {
//
// public static final int ENCRYPTION_STRENGTH = 11;
// public static final String CREDENTIAL_FILE = ".cvz.pc";
// private static final String HASHED_DEFAULT_PW = "$2a$10$w.Jjtx0mrjH4E.DxQEmBZu.D1oCBKy26utS8KCOSn0fmq1xs2GXiK";
//
// private static UserDetails createUserDetails(String username, String passwordCode) {
// List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
// authorities.add(new SimpleGrantedAuthority("ROLE_USER"));
// return new User(username, passwordCode, authorities);
// }
//
// private static UserDetails getDefaultCredential(String username) {
// if (username.equals("owner")) {
// return createUserDetails(username, HASHED_DEFAULT_PW);
// }
// return null;
// }
//
// public static boolean encodingMatches(String raw, String encoded) {
// return new BCryptPasswordEncoder(UserDetailsService.ENCRYPTION_STRENGTH)
// .matches(raw, encoded);
// }
//
// private static UserDetails getCustomCredential(String username, String usernameCode, String passwordCode) {
// if (encodingMatches(username, usernameCode)) {
// return createUserDetails(username, passwordCode);
// }
// return null;
// }
//
// public static File getCredentialFile() {
// final String homePath = System.getProperty(AppOptions.PRIVATE_HOME_PATH);
// final String credFilePath = FsUtil.getAbsolutePath(CREDENTIAL_FILE, homePath);
// return new File(credFilePath);
// }
//
// public static void saveCustomCredential(String username, String password, String oldPwHash)
// throws IOException, InvalidParameterException {
//
// final BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(ENCRYPTION_STRENGTH);
// final List<String> lines = new ArrayList<>();
// if (username == null || username.isEmpty()) {
// throw new InvalidParameterException();
// }
// lines.add(encoder.encode(username));
// if (password == null || password.isEmpty()) {
// if (oldPwHash != null && !oldPwHash.isEmpty())
// lines.add(oldPwHash);
// else
// throw new InvalidParameterException();
// }
// else
// lines.add(encoder.encode(password));
// FileUtils.writeLines(UserDetailsService.getCredentialFile(), lines, "\n");
// }
//
// public static boolean authenticatePassword(String pw) {
// final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
// final Object principal = auth.getPrincipal();
// if (principal instanceof UserDetails) {
// final UserDetails ud = (UserDetails) principal;
// return encodingMatches(pw, ud.getPassword());
// }
// return false;
// }
//
// @Override
// public UserDetails loadUserByUsername(String username)
// throws UsernameNotFoundException {
// final Logger logger = LoggerFactory.getLogger(UserDetailsService.class);
// final File credentialFile = getCredentialFile();
// UserDetails output = null;
// boolean customCredential = credentialFile.isFile();
//
// if (customCredential) {
// try {
// final String content = FileUtils.readFileToString(credentialFile);
// final String[] tmp = content.split("\n");
// logger.info("processing custom credential...");
// output = getCustomCredential(username, tmp[0], tmp[1]);
// } catch (IOException e) {
// logger.error("Error in reading the file {}", credentialFile.getAbsoluteFile());
// e.printStackTrace();
// logger.error("Switching to default credential...");
// customCredential = false;
// }
// }
//
// if (customCredential == false) {
// logger.info("processing default credential...");
// output = getDefaultCredential(username);
// }
//
// if (output != null) {
// return output;
// }
//
// logger.info("authentication for {} failed!", username);
// throw new BadCredentialsException("Bad Credentials");
// }
//
// }
// Path: src/main/java/com/civilizer/web/view/AuthenticationBean.java
import java.io.Serializable;
import org.primefaces.context.RequestContext;
import com.civilizer.security.UserDetailsService;
package com.civilizer.web.view;
@SuppressWarnings("serial")
public final class AuthenticationBean implements Serializable {
private String password = "";
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public void validate() {
final String pw = password;
password = "";
|
if (UserDetailsService.authenticatePassword(pw)) {
|
suewonjp/civilizer
|
src/main/java/com/civilizer/dao/hibernate/FileEntityDaoImpl.java
|
// Path: src/main/java/com/civilizer/dao/FileEntityDao.java
// public interface FileEntityDao {
//
// public long countAll();
//
// public List<FileEntity> findAll();
//
// public FileEntity findById(Long id);
//
// public FileEntity findByName(String name);
//
// public List<FileEntity> findByNamePattern(String pattern);
//
// public void save(FileEntity fe);
//
// public void delete(FileEntity fe);
//
// }
//
// Path: src/main/java/com/civilizer/domain/FileEntity.java
// @SuppressWarnings("serial")
// @Entity
// @Table(name = "FILE")
// public class FileEntity implements Serializable {
//
// private Long id;
//
// // [RULE] should be a relative path and begin with a path separator.
// // And the path separator should be a slash (/)
// private String fileName = "";
//
// public FileEntity() {}
//
// public FileEntity(String name) {
// setFileName(name);
// }
//
// @Id
// @GeneratedValue(strategy = IDENTITY)
// @Column(name = "file_id")
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @Column(name = "file_name", unique = true)
// public String getFileName() {
// return fileName;
// }
//
// public void setFileName(String name) {
// if (name != null)
// this.fileName = FilenameUtils.separatorsToUnix(name).intern();
// }
//
// public boolean isChildOf(String parentPath) {
// return fileName.startsWith(parentPath);
// }
//
// public Pair<String, String> splitName() {
// final String[] tmp = fileName.split(FsUtil.SEP);
// final String name = tmp.length > 0 ?
// tmp[tmp.length - 1] : "";
// String parentPath = "";
// for (int i=1; i<tmp.length-1; ++i) {
// parentPath += FsUtil.SEP + tmp[i];
// }
// return new Pair<String, String>(parentPath, name);
// }
//
// public String endName() {
// return splitName().getSecond();
// }
//
// public void replaceNameSegment(String oldIntermediatePath, String newSegment) {
// /*
// * let's say,
// * fileName = "/abc/def/ghi/jklm"
// * oldIntermediatePath = "/abc/def/ghi" ; oldIntermediatePath should be a subset of fileName
// * newSegment = "foo"
// */
// if (oldIntermediatePath == null) {
// oldIntermediatePath = fileName;
// }
// oldIntermediatePath = FilenameUtils.separatorsToUnix(oldIntermediatePath);
// final String[] tmp = oldIntermediatePath.split(FsUtil.SEP);
// final String oldSegment = tmp[tmp.length - 1];
// // oldSegment => "ghi"
// final int index = fileName.lastIndexOf(oldSegment);
// final String replaced = fileName.substring(0, index) + fileName.substring(index).replace(oldSegment, newSegment);
// // replaced => "/abc/def/foo/jklm"
// setFileName(replaced);
// }
//
// public File toFile(String prefix) {
// if (fileName.isEmpty()) {
// return null;
// }
// return new File(FsUtil.normalizePath(prefix + fileName));
// }
//
// public boolean persisted(String filesHome) {
// final File file = toFile(filesHome);
// if (file == null) {
// return false;
// }
// return file.exists();
// }
//
// public static Collection<FileEntity> getFilesUnder(String directory) {
// final File dir = new File(directory);
// if (! dir.isDirectory()) {
// Collection<FileEntity> tmp = Collections.emptyList();
// return tmp;
// }
// directory = dir.getAbsolutePath();
//
// Collection<File> files = FileUtils.listFiles(dir, null, true);
// final Collection<FileEntity> output = new ArrayList<>();
// final int beginIndex = directory.length();
// for (File file : files) {
// // [NOTE] as a rule, we need to pass a relative path when creating a FileEntry
// output.add(new FileEntity(FilenameUtils.separatorsToUnix(file.getAbsolutePath().substring(beginIndex))));
// }
//
// return output;
// }
//
// @Override
// public int hashCode() {
// final int prime = 59;
// int result = prime + ((id == null) ? 0 : id.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// FileEntity other = (FileEntity) obj;
// return this.fileName.equals(other.fileName);
// }
//
// @Override
// public String toString() {
// return getFileName();
// }
//
// }
|
import java.util.*;
import javax.annotation.Resource;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.civilizer.dao.FileEntityDao;
import com.civilizer.domain.FileEntity;
|
package com.civilizer.dao.hibernate;
@Repository("fileEntityDao")
@Transactional
|
// Path: src/main/java/com/civilizer/dao/FileEntityDao.java
// public interface FileEntityDao {
//
// public long countAll();
//
// public List<FileEntity> findAll();
//
// public FileEntity findById(Long id);
//
// public FileEntity findByName(String name);
//
// public List<FileEntity> findByNamePattern(String pattern);
//
// public void save(FileEntity fe);
//
// public void delete(FileEntity fe);
//
// }
//
// Path: src/main/java/com/civilizer/domain/FileEntity.java
// @SuppressWarnings("serial")
// @Entity
// @Table(name = "FILE")
// public class FileEntity implements Serializable {
//
// private Long id;
//
// // [RULE] should be a relative path and begin with a path separator.
// // And the path separator should be a slash (/)
// private String fileName = "";
//
// public FileEntity() {}
//
// public FileEntity(String name) {
// setFileName(name);
// }
//
// @Id
// @GeneratedValue(strategy = IDENTITY)
// @Column(name = "file_id")
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @Column(name = "file_name", unique = true)
// public String getFileName() {
// return fileName;
// }
//
// public void setFileName(String name) {
// if (name != null)
// this.fileName = FilenameUtils.separatorsToUnix(name).intern();
// }
//
// public boolean isChildOf(String parentPath) {
// return fileName.startsWith(parentPath);
// }
//
// public Pair<String, String> splitName() {
// final String[] tmp = fileName.split(FsUtil.SEP);
// final String name = tmp.length > 0 ?
// tmp[tmp.length - 1] : "";
// String parentPath = "";
// for (int i=1; i<tmp.length-1; ++i) {
// parentPath += FsUtil.SEP + tmp[i];
// }
// return new Pair<String, String>(parentPath, name);
// }
//
// public String endName() {
// return splitName().getSecond();
// }
//
// public void replaceNameSegment(String oldIntermediatePath, String newSegment) {
// /*
// * let's say,
// * fileName = "/abc/def/ghi/jklm"
// * oldIntermediatePath = "/abc/def/ghi" ; oldIntermediatePath should be a subset of fileName
// * newSegment = "foo"
// */
// if (oldIntermediatePath == null) {
// oldIntermediatePath = fileName;
// }
// oldIntermediatePath = FilenameUtils.separatorsToUnix(oldIntermediatePath);
// final String[] tmp = oldIntermediatePath.split(FsUtil.SEP);
// final String oldSegment = tmp[tmp.length - 1];
// // oldSegment => "ghi"
// final int index = fileName.lastIndexOf(oldSegment);
// final String replaced = fileName.substring(0, index) + fileName.substring(index).replace(oldSegment, newSegment);
// // replaced => "/abc/def/foo/jklm"
// setFileName(replaced);
// }
//
// public File toFile(String prefix) {
// if (fileName.isEmpty()) {
// return null;
// }
// return new File(FsUtil.normalizePath(prefix + fileName));
// }
//
// public boolean persisted(String filesHome) {
// final File file = toFile(filesHome);
// if (file == null) {
// return false;
// }
// return file.exists();
// }
//
// public static Collection<FileEntity> getFilesUnder(String directory) {
// final File dir = new File(directory);
// if (! dir.isDirectory()) {
// Collection<FileEntity> tmp = Collections.emptyList();
// return tmp;
// }
// directory = dir.getAbsolutePath();
//
// Collection<File> files = FileUtils.listFiles(dir, null, true);
// final Collection<FileEntity> output = new ArrayList<>();
// final int beginIndex = directory.length();
// for (File file : files) {
// // [NOTE] as a rule, we need to pass a relative path when creating a FileEntry
// output.add(new FileEntity(FilenameUtils.separatorsToUnix(file.getAbsolutePath().substring(beginIndex))));
// }
//
// return output;
// }
//
// @Override
// public int hashCode() {
// final int prime = 59;
// int result = prime + ((id == null) ? 0 : id.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// FileEntity other = (FileEntity) obj;
// return this.fileName.equals(other.fileName);
// }
//
// @Override
// public String toString() {
// return getFileName();
// }
//
// }
// Path: src/main/java/com/civilizer/dao/hibernate/FileEntityDaoImpl.java
import java.util.*;
import javax.annotation.Resource;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.civilizer.dao.FileEntityDao;
import com.civilizer.domain.FileEntity;
package com.civilizer.dao.hibernate;
@Repository("fileEntityDao")
@Transactional
|
public class FileEntityDaoImpl implements FileEntityDao {
|
suewonjp/civilizer
|
src/main/java/com/civilizer/dao/hibernate/FileEntityDaoImpl.java
|
// Path: src/main/java/com/civilizer/dao/FileEntityDao.java
// public interface FileEntityDao {
//
// public long countAll();
//
// public List<FileEntity> findAll();
//
// public FileEntity findById(Long id);
//
// public FileEntity findByName(String name);
//
// public List<FileEntity> findByNamePattern(String pattern);
//
// public void save(FileEntity fe);
//
// public void delete(FileEntity fe);
//
// }
//
// Path: src/main/java/com/civilizer/domain/FileEntity.java
// @SuppressWarnings("serial")
// @Entity
// @Table(name = "FILE")
// public class FileEntity implements Serializable {
//
// private Long id;
//
// // [RULE] should be a relative path and begin with a path separator.
// // And the path separator should be a slash (/)
// private String fileName = "";
//
// public FileEntity() {}
//
// public FileEntity(String name) {
// setFileName(name);
// }
//
// @Id
// @GeneratedValue(strategy = IDENTITY)
// @Column(name = "file_id")
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @Column(name = "file_name", unique = true)
// public String getFileName() {
// return fileName;
// }
//
// public void setFileName(String name) {
// if (name != null)
// this.fileName = FilenameUtils.separatorsToUnix(name).intern();
// }
//
// public boolean isChildOf(String parentPath) {
// return fileName.startsWith(parentPath);
// }
//
// public Pair<String, String> splitName() {
// final String[] tmp = fileName.split(FsUtil.SEP);
// final String name = tmp.length > 0 ?
// tmp[tmp.length - 1] : "";
// String parentPath = "";
// for (int i=1; i<tmp.length-1; ++i) {
// parentPath += FsUtil.SEP + tmp[i];
// }
// return new Pair<String, String>(parentPath, name);
// }
//
// public String endName() {
// return splitName().getSecond();
// }
//
// public void replaceNameSegment(String oldIntermediatePath, String newSegment) {
// /*
// * let's say,
// * fileName = "/abc/def/ghi/jklm"
// * oldIntermediatePath = "/abc/def/ghi" ; oldIntermediatePath should be a subset of fileName
// * newSegment = "foo"
// */
// if (oldIntermediatePath == null) {
// oldIntermediatePath = fileName;
// }
// oldIntermediatePath = FilenameUtils.separatorsToUnix(oldIntermediatePath);
// final String[] tmp = oldIntermediatePath.split(FsUtil.SEP);
// final String oldSegment = tmp[tmp.length - 1];
// // oldSegment => "ghi"
// final int index = fileName.lastIndexOf(oldSegment);
// final String replaced = fileName.substring(0, index) + fileName.substring(index).replace(oldSegment, newSegment);
// // replaced => "/abc/def/foo/jklm"
// setFileName(replaced);
// }
//
// public File toFile(String prefix) {
// if (fileName.isEmpty()) {
// return null;
// }
// return new File(FsUtil.normalizePath(prefix + fileName));
// }
//
// public boolean persisted(String filesHome) {
// final File file = toFile(filesHome);
// if (file == null) {
// return false;
// }
// return file.exists();
// }
//
// public static Collection<FileEntity> getFilesUnder(String directory) {
// final File dir = new File(directory);
// if (! dir.isDirectory()) {
// Collection<FileEntity> tmp = Collections.emptyList();
// return tmp;
// }
// directory = dir.getAbsolutePath();
//
// Collection<File> files = FileUtils.listFiles(dir, null, true);
// final Collection<FileEntity> output = new ArrayList<>();
// final int beginIndex = directory.length();
// for (File file : files) {
// // [NOTE] as a rule, we need to pass a relative path when creating a FileEntry
// output.add(new FileEntity(FilenameUtils.separatorsToUnix(file.getAbsolutePath().substring(beginIndex))));
// }
//
// return output;
// }
//
// @Override
// public int hashCode() {
// final int prime = 59;
// int result = prime + ((id == null) ? 0 : id.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// FileEntity other = (FileEntity) obj;
// return this.fileName.equals(other.fileName);
// }
//
// @Override
// public String toString() {
// return getFileName();
// }
//
// }
|
import java.util.*;
import javax.annotation.Resource;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.civilizer.dao.FileEntityDao;
import com.civilizer.domain.FileEntity;
|
package com.civilizer.dao.hibernate;
@Repository("fileEntityDao")
@Transactional
public class FileEntityDaoImpl implements FileEntityDao {
private SessionFactory sessionFactory;
@Resource(name = "sessionFactory")
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
@Override
public long countAll() {
return (Long) sessionFactory.getCurrentSession()
.getNamedQuery("FileEntity.countAll")
.iterate().next();
}
@SuppressWarnings("unchecked")
@Override
|
// Path: src/main/java/com/civilizer/dao/FileEntityDao.java
// public interface FileEntityDao {
//
// public long countAll();
//
// public List<FileEntity> findAll();
//
// public FileEntity findById(Long id);
//
// public FileEntity findByName(String name);
//
// public List<FileEntity> findByNamePattern(String pattern);
//
// public void save(FileEntity fe);
//
// public void delete(FileEntity fe);
//
// }
//
// Path: src/main/java/com/civilizer/domain/FileEntity.java
// @SuppressWarnings("serial")
// @Entity
// @Table(name = "FILE")
// public class FileEntity implements Serializable {
//
// private Long id;
//
// // [RULE] should be a relative path and begin with a path separator.
// // And the path separator should be a slash (/)
// private String fileName = "";
//
// public FileEntity() {}
//
// public FileEntity(String name) {
// setFileName(name);
// }
//
// @Id
// @GeneratedValue(strategy = IDENTITY)
// @Column(name = "file_id")
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @Column(name = "file_name", unique = true)
// public String getFileName() {
// return fileName;
// }
//
// public void setFileName(String name) {
// if (name != null)
// this.fileName = FilenameUtils.separatorsToUnix(name).intern();
// }
//
// public boolean isChildOf(String parentPath) {
// return fileName.startsWith(parentPath);
// }
//
// public Pair<String, String> splitName() {
// final String[] tmp = fileName.split(FsUtil.SEP);
// final String name = tmp.length > 0 ?
// tmp[tmp.length - 1] : "";
// String parentPath = "";
// for (int i=1; i<tmp.length-1; ++i) {
// parentPath += FsUtil.SEP + tmp[i];
// }
// return new Pair<String, String>(parentPath, name);
// }
//
// public String endName() {
// return splitName().getSecond();
// }
//
// public void replaceNameSegment(String oldIntermediatePath, String newSegment) {
// /*
// * let's say,
// * fileName = "/abc/def/ghi/jklm"
// * oldIntermediatePath = "/abc/def/ghi" ; oldIntermediatePath should be a subset of fileName
// * newSegment = "foo"
// */
// if (oldIntermediatePath == null) {
// oldIntermediatePath = fileName;
// }
// oldIntermediatePath = FilenameUtils.separatorsToUnix(oldIntermediatePath);
// final String[] tmp = oldIntermediatePath.split(FsUtil.SEP);
// final String oldSegment = tmp[tmp.length - 1];
// // oldSegment => "ghi"
// final int index = fileName.lastIndexOf(oldSegment);
// final String replaced = fileName.substring(0, index) + fileName.substring(index).replace(oldSegment, newSegment);
// // replaced => "/abc/def/foo/jklm"
// setFileName(replaced);
// }
//
// public File toFile(String prefix) {
// if (fileName.isEmpty()) {
// return null;
// }
// return new File(FsUtil.normalizePath(prefix + fileName));
// }
//
// public boolean persisted(String filesHome) {
// final File file = toFile(filesHome);
// if (file == null) {
// return false;
// }
// return file.exists();
// }
//
// public static Collection<FileEntity> getFilesUnder(String directory) {
// final File dir = new File(directory);
// if (! dir.isDirectory()) {
// Collection<FileEntity> tmp = Collections.emptyList();
// return tmp;
// }
// directory = dir.getAbsolutePath();
//
// Collection<File> files = FileUtils.listFiles(dir, null, true);
// final Collection<FileEntity> output = new ArrayList<>();
// final int beginIndex = directory.length();
// for (File file : files) {
// // [NOTE] as a rule, we need to pass a relative path when creating a FileEntry
// output.add(new FileEntity(FilenameUtils.separatorsToUnix(file.getAbsolutePath().substring(beginIndex))));
// }
//
// return output;
// }
//
// @Override
// public int hashCode() {
// final int prime = 59;
// int result = prime + ((id == null) ? 0 : id.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// FileEntity other = (FileEntity) obj;
// return this.fileName.equals(other.fileName);
// }
//
// @Override
// public String toString() {
// return getFileName();
// }
//
// }
// Path: src/main/java/com/civilizer/dao/hibernate/FileEntityDaoImpl.java
import java.util.*;
import javax.annotation.Resource;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.civilizer.dao.FileEntityDao;
import com.civilizer.domain.FileEntity;
package com.civilizer.dao.hibernate;
@Repository("fileEntityDao")
@Transactional
public class FileEntityDaoImpl implements FileEntityDao {
private SessionFactory sessionFactory;
@Resource(name = "sessionFactory")
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
@Override
public long countAll() {
return (Long) sessionFactory.getCurrentSession()
.getNamedQuery("FileEntity.countAll")
.iterate().next();
}
@SuppressWarnings("unchecked")
@Override
|
public List<FileEntity> findAll() {
|
suewonjp/civilizer
|
src/main/java/com/civilizer/web/converter/JodaDateTimeConverter.java
|
// Path: src/main/java/com/civilizer/web/view/ViewUtil.java
// public final class ViewUtil {
//
// private static final String MESSAGE_RESOURCE_BASE_NAME = "i18n.MessageResources";
// private static final String HELP_RESOURCE_BASE_NAME = "i18n.HelpResources";
//
// public static void addMessage(String title, String content, FacesMessage.Severity severity) {
// if (severity == null) {
// severity = FacesMessage.SEVERITY_INFO;
// }
// FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, title, content));
// }
//
// public static void addMessage(String clientId, String title, String content, FacesMessage.Severity severity) {
// if (severity == null) {
// severity = FacesMessage.SEVERITY_INFO;
// }
// FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(severity, title, content));
// }
//
// public static void addMessage(String objName, Object obj) {
// FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(objName, obj.toString()));
// }
//
// @SuppressWarnings("unchecked")
// public static <T> T findBean(String beanName) {
// FacesContext context = FacesContext.getCurrentInstance();
// if (context != null) {
// try {
// return (T) context.getApplication().evaluateExpressionGet(context, "#{" + beanName + "}", Object.class);
// } catch (ELException e) {}
// }
// final RequestContext rc = RequestContextHolder.getRequestContext();
// T r;
// r = (T) rc.getFlowScope().get(beanName);
// if (r == null)
// r = (T) rc.getRequestScope().get(beanName);
// if (r == null)
// r = (T) rc.getViewScope().get(beanName);
// return r;
// }
//
// public static void setLocale(RequestContext rc) {
// final ServletExternalContext ec = (ServletExternalContext)rc.getExternalContext();
// final HttpServletRequest req = (HttpServletRequest)ec.getNativeRequest();
// Locale locale = RequestContextUtils.getLocale(req); // Retrieve the locale info from the cookie
// // [NOTE] The locale setting via civilizer.locale option precedes the cookie locale.
// locale = Configurator.resolveLocale(locale);
// final UserProfileBean userProfileBean = (UserProfileBean) rc.getFlowScope().get("userProfileBean");
// userProfileBean.setLocale(locale);
// }
//
// public static String getResourceBundleString(String key) {
// final Locale locale = Configurator.getCurLocale();
// final ResourceBundle bundle = ResourceBundle.getBundle(MESSAGE_RESOURCE_BASE_NAME, locale);
// return bundle.getString(key);
// }
//
// public static String getHelpString(String key) {
// final Locale locale = Configurator.getCurLocale();
// final ResourceBundle bundle = ResourceBundle.getBundle(HELP_RESOURCE_BASE_NAME, locale);
// return bundle.getString(key);
// }
//
// public static boolean isAuthenticated() {
// Authentication auth = SecurityContextHolder.getContext().getAuthentication();
// Object principal = auth.getPrincipal();
// return principal instanceof UserDetails;
// }
//
// @SuppressWarnings("unchecked")
// public static <T> void putAttributeToFlowScope(String key, T value) {
// RequestContext requestContext = RequestContextHolder.getRequestContext();
// MutableAttributeMap<Object> attrMap = requestContext.getFlowScope();
// ArrayList<T> attr = (ArrayList<T>) attrMap.get(key);
// if (attr == null) {
// attrMap.put(key, new ArrayList<T>());
// attr = (ArrayList<T>) attrMap.get(key);
// }
// attr.add(value);
// }
//
// @SuppressWarnings("unchecked")
// public static <T> List<T> getAttributesFromFlowScope(String key) {
// RequestContext requestContext = RequestContextHolder.getRequestContext();
// MutableAttributeMap<Object> attrMap = requestContext.getFlowScope();
// return (List<T>) attrMap.get(key);
// }
//
// public static void removeAttributesFromFlowScope(String key) {
// RequestContext requestContext = RequestContextHolder.getRequestContext();
// MutableAttributeMap<Object> attrMap = requestContext.getFlowScope();
// attrMap.remove(key);
// }
// }
|
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import com.civilizer.web.view.ViewUtil;
|
package com.civilizer.web.converter;
@FacesConverter("jodaDateTimeConverter")
public final class JodaDateTimeConverter implements Converter
// , JsonDeserializer<DateTime>, JsonSerializer<DateTime>
{
|
// Path: src/main/java/com/civilizer/web/view/ViewUtil.java
// public final class ViewUtil {
//
// private static final String MESSAGE_RESOURCE_BASE_NAME = "i18n.MessageResources";
// private static final String HELP_RESOURCE_BASE_NAME = "i18n.HelpResources";
//
// public static void addMessage(String title, String content, FacesMessage.Severity severity) {
// if (severity == null) {
// severity = FacesMessage.SEVERITY_INFO;
// }
// FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, title, content));
// }
//
// public static void addMessage(String clientId, String title, String content, FacesMessage.Severity severity) {
// if (severity == null) {
// severity = FacesMessage.SEVERITY_INFO;
// }
// FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(severity, title, content));
// }
//
// public static void addMessage(String objName, Object obj) {
// FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(objName, obj.toString()));
// }
//
// @SuppressWarnings("unchecked")
// public static <T> T findBean(String beanName) {
// FacesContext context = FacesContext.getCurrentInstance();
// if (context != null) {
// try {
// return (T) context.getApplication().evaluateExpressionGet(context, "#{" + beanName + "}", Object.class);
// } catch (ELException e) {}
// }
// final RequestContext rc = RequestContextHolder.getRequestContext();
// T r;
// r = (T) rc.getFlowScope().get(beanName);
// if (r == null)
// r = (T) rc.getRequestScope().get(beanName);
// if (r == null)
// r = (T) rc.getViewScope().get(beanName);
// return r;
// }
//
// public static void setLocale(RequestContext rc) {
// final ServletExternalContext ec = (ServletExternalContext)rc.getExternalContext();
// final HttpServletRequest req = (HttpServletRequest)ec.getNativeRequest();
// Locale locale = RequestContextUtils.getLocale(req); // Retrieve the locale info from the cookie
// // [NOTE] The locale setting via civilizer.locale option precedes the cookie locale.
// locale = Configurator.resolveLocale(locale);
// final UserProfileBean userProfileBean = (UserProfileBean) rc.getFlowScope().get("userProfileBean");
// userProfileBean.setLocale(locale);
// }
//
// public static String getResourceBundleString(String key) {
// final Locale locale = Configurator.getCurLocale();
// final ResourceBundle bundle = ResourceBundle.getBundle(MESSAGE_RESOURCE_BASE_NAME, locale);
// return bundle.getString(key);
// }
//
// public static String getHelpString(String key) {
// final Locale locale = Configurator.getCurLocale();
// final ResourceBundle bundle = ResourceBundle.getBundle(HELP_RESOURCE_BASE_NAME, locale);
// return bundle.getString(key);
// }
//
// public static boolean isAuthenticated() {
// Authentication auth = SecurityContextHolder.getContext().getAuthentication();
// Object principal = auth.getPrincipal();
// return principal instanceof UserDetails;
// }
//
// @SuppressWarnings("unchecked")
// public static <T> void putAttributeToFlowScope(String key, T value) {
// RequestContext requestContext = RequestContextHolder.getRequestContext();
// MutableAttributeMap<Object> attrMap = requestContext.getFlowScope();
// ArrayList<T> attr = (ArrayList<T>) attrMap.get(key);
// if (attr == null) {
// attrMap.put(key, new ArrayList<T>());
// attr = (ArrayList<T>) attrMap.get(key);
// }
// attr.add(value);
// }
//
// @SuppressWarnings("unchecked")
// public static <T> List<T> getAttributesFromFlowScope(String key) {
// RequestContext requestContext = RequestContextHolder.getRequestContext();
// MutableAttributeMap<Object> attrMap = requestContext.getFlowScope();
// return (List<T>) attrMap.get(key);
// }
//
// public static void removeAttributesFromFlowScope(String key) {
// RequestContext requestContext = RequestContextHolder.getRequestContext();
// MutableAttributeMap<Object> attrMap = requestContext.getFlowScope();
// attrMap.remove(key);
// }
// }
// Path: src/main/java/com/civilizer/web/converter/JodaDateTimeConverter.java
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import com.civilizer.web.view.ViewUtil;
package com.civilizer.web.converter;
@FacesConverter("jodaDateTimeConverter")
public final class JodaDateTimeConverter implements Converter
// , JsonDeserializer<DateTime>, JsonSerializer<DateTime>
{
|
private final String PATTERN = ViewUtil.getResourceBundleString("date_time_format");
|
suewonjp/civilizer
|
src/main/java/com/civilizer/dao/hibernate/TagDaoImpl.java
|
// Path: src/main/java/com/civilizer/dao/TagDao.java
// public interface TagDao {
//
// public List<?> executeQueryForResult(String query);
//
// public void executeQuery(String query, boolean sql);
//
// public long countAll();
//
// public List<Tag> findAll();
//
// public List<Tag> findAllWithChildren(boolean includeSpecialTags);
//
// public void findIdsOfAllDescendants(Long parentTagId, Session s, Set<Long> idsInOut);
//
// public long countAllDescendants(Long id);
//
// public Tag findById(Long id);
//
// public Tag findById(Long id, boolean withFragments, boolean withChildren);
//
// public void populate(Tag target, boolean withFragments, boolean withChildren);
//
// public List<Tag> findParentTags(Long id);
//
// public void save(Tag tag);
//
// public void saveWithHierarchy(Tag tag, Collection<Tag> parents, Collection<Tag> children);
//
// public void delete(Tag tag);
//
// }
|
import java.util.*;
import javax.annotation.Resource;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.civilizer.dao.TagDao;
import com.civilizer.domain.*;
|
package com.civilizer.dao.hibernate;
@Repository("tagDao")
@Transactional
|
// Path: src/main/java/com/civilizer/dao/TagDao.java
// public interface TagDao {
//
// public List<?> executeQueryForResult(String query);
//
// public void executeQuery(String query, boolean sql);
//
// public long countAll();
//
// public List<Tag> findAll();
//
// public List<Tag> findAllWithChildren(boolean includeSpecialTags);
//
// public void findIdsOfAllDescendants(Long parentTagId, Session s, Set<Long> idsInOut);
//
// public long countAllDescendants(Long id);
//
// public Tag findById(Long id);
//
// public Tag findById(Long id, boolean withFragments, boolean withChildren);
//
// public void populate(Tag target, boolean withFragments, boolean withChildren);
//
// public List<Tag> findParentTags(Long id);
//
// public void save(Tag tag);
//
// public void saveWithHierarchy(Tag tag, Collection<Tag> parents, Collection<Tag> children);
//
// public void delete(Tag tag);
//
// }
// Path: src/main/java/com/civilizer/dao/hibernate/TagDaoImpl.java
import java.util.*;
import javax.annotation.Resource;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.civilizer.dao.TagDao;
import com.civilizer.domain.*;
package com.civilizer.dao.hibernate;
@Repository("tagDao")
@Transactional
|
public final class TagDaoImpl implements TagDao {
|
suewonjp/civilizer
|
src/main/java/com/civilizer/dao/FileEntityDao.java
|
// Path: src/main/java/com/civilizer/domain/FileEntity.java
// @SuppressWarnings("serial")
// @Entity
// @Table(name = "FILE")
// public class FileEntity implements Serializable {
//
// private Long id;
//
// // [RULE] should be a relative path and begin with a path separator.
// // And the path separator should be a slash (/)
// private String fileName = "";
//
// public FileEntity() {}
//
// public FileEntity(String name) {
// setFileName(name);
// }
//
// @Id
// @GeneratedValue(strategy = IDENTITY)
// @Column(name = "file_id")
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @Column(name = "file_name", unique = true)
// public String getFileName() {
// return fileName;
// }
//
// public void setFileName(String name) {
// if (name != null)
// this.fileName = FilenameUtils.separatorsToUnix(name).intern();
// }
//
// public boolean isChildOf(String parentPath) {
// return fileName.startsWith(parentPath);
// }
//
// public Pair<String, String> splitName() {
// final String[] tmp = fileName.split(FsUtil.SEP);
// final String name = tmp.length > 0 ?
// tmp[tmp.length - 1] : "";
// String parentPath = "";
// for (int i=1; i<tmp.length-1; ++i) {
// parentPath += FsUtil.SEP + tmp[i];
// }
// return new Pair<String, String>(parentPath, name);
// }
//
// public String endName() {
// return splitName().getSecond();
// }
//
// public void replaceNameSegment(String oldIntermediatePath, String newSegment) {
// /*
// * let's say,
// * fileName = "/abc/def/ghi/jklm"
// * oldIntermediatePath = "/abc/def/ghi" ; oldIntermediatePath should be a subset of fileName
// * newSegment = "foo"
// */
// if (oldIntermediatePath == null) {
// oldIntermediatePath = fileName;
// }
// oldIntermediatePath = FilenameUtils.separatorsToUnix(oldIntermediatePath);
// final String[] tmp = oldIntermediatePath.split(FsUtil.SEP);
// final String oldSegment = tmp[tmp.length - 1];
// // oldSegment => "ghi"
// final int index = fileName.lastIndexOf(oldSegment);
// final String replaced = fileName.substring(0, index) + fileName.substring(index).replace(oldSegment, newSegment);
// // replaced => "/abc/def/foo/jklm"
// setFileName(replaced);
// }
//
// public File toFile(String prefix) {
// if (fileName.isEmpty()) {
// return null;
// }
// return new File(FsUtil.normalizePath(prefix + fileName));
// }
//
// public boolean persisted(String filesHome) {
// final File file = toFile(filesHome);
// if (file == null) {
// return false;
// }
// return file.exists();
// }
//
// public static Collection<FileEntity> getFilesUnder(String directory) {
// final File dir = new File(directory);
// if (! dir.isDirectory()) {
// Collection<FileEntity> tmp = Collections.emptyList();
// return tmp;
// }
// directory = dir.getAbsolutePath();
//
// Collection<File> files = FileUtils.listFiles(dir, null, true);
// final Collection<FileEntity> output = new ArrayList<>();
// final int beginIndex = directory.length();
// for (File file : files) {
// // [NOTE] as a rule, we need to pass a relative path when creating a FileEntry
// output.add(new FileEntity(FilenameUtils.separatorsToUnix(file.getAbsolutePath().substring(beginIndex))));
// }
//
// return output;
// }
//
// @Override
// public int hashCode() {
// final int prime = 59;
// int result = prime + ((id == null) ? 0 : id.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// FileEntity other = (FileEntity) obj;
// return this.fileName.equals(other.fileName);
// }
//
// @Override
// public String toString() {
// return getFileName();
// }
//
// }
|
import java.util.*;
import com.civilizer.domain.FileEntity;
|
package com.civilizer.dao;
public interface FileEntityDao {
public long countAll();
|
// Path: src/main/java/com/civilizer/domain/FileEntity.java
// @SuppressWarnings("serial")
// @Entity
// @Table(name = "FILE")
// public class FileEntity implements Serializable {
//
// private Long id;
//
// // [RULE] should be a relative path and begin with a path separator.
// // And the path separator should be a slash (/)
// private String fileName = "";
//
// public FileEntity() {}
//
// public FileEntity(String name) {
// setFileName(name);
// }
//
// @Id
// @GeneratedValue(strategy = IDENTITY)
// @Column(name = "file_id")
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// @Column(name = "file_name", unique = true)
// public String getFileName() {
// return fileName;
// }
//
// public void setFileName(String name) {
// if (name != null)
// this.fileName = FilenameUtils.separatorsToUnix(name).intern();
// }
//
// public boolean isChildOf(String parentPath) {
// return fileName.startsWith(parentPath);
// }
//
// public Pair<String, String> splitName() {
// final String[] tmp = fileName.split(FsUtil.SEP);
// final String name = tmp.length > 0 ?
// tmp[tmp.length - 1] : "";
// String parentPath = "";
// for (int i=1; i<tmp.length-1; ++i) {
// parentPath += FsUtil.SEP + tmp[i];
// }
// return new Pair<String, String>(parentPath, name);
// }
//
// public String endName() {
// return splitName().getSecond();
// }
//
// public void replaceNameSegment(String oldIntermediatePath, String newSegment) {
// /*
// * let's say,
// * fileName = "/abc/def/ghi/jklm"
// * oldIntermediatePath = "/abc/def/ghi" ; oldIntermediatePath should be a subset of fileName
// * newSegment = "foo"
// */
// if (oldIntermediatePath == null) {
// oldIntermediatePath = fileName;
// }
// oldIntermediatePath = FilenameUtils.separatorsToUnix(oldIntermediatePath);
// final String[] tmp = oldIntermediatePath.split(FsUtil.SEP);
// final String oldSegment = tmp[tmp.length - 1];
// // oldSegment => "ghi"
// final int index = fileName.lastIndexOf(oldSegment);
// final String replaced = fileName.substring(0, index) + fileName.substring(index).replace(oldSegment, newSegment);
// // replaced => "/abc/def/foo/jklm"
// setFileName(replaced);
// }
//
// public File toFile(String prefix) {
// if (fileName.isEmpty()) {
// return null;
// }
// return new File(FsUtil.normalizePath(prefix + fileName));
// }
//
// public boolean persisted(String filesHome) {
// final File file = toFile(filesHome);
// if (file == null) {
// return false;
// }
// return file.exists();
// }
//
// public static Collection<FileEntity> getFilesUnder(String directory) {
// final File dir = new File(directory);
// if (! dir.isDirectory()) {
// Collection<FileEntity> tmp = Collections.emptyList();
// return tmp;
// }
// directory = dir.getAbsolutePath();
//
// Collection<File> files = FileUtils.listFiles(dir, null, true);
// final Collection<FileEntity> output = new ArrayList<>();
// final int beginIndex = directory.length();
// for (File file : files) {
// // [NOTE] as a rule, we need to pass a relative path when creating a FileEntry
// output.add(new FileEntity(FilenameUtils.separatorsToUnix(file.getAbsolutePath().substring(beginIndex))));
// }
//
// return output;
// }
//
// @Override
// public int hashCode() {
// final int prime = 59;
// int result = prime + ((id == null) ? 0 : id.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// FileEntity other = (FileEntity) obj;
// return this.fileName.equals(other.fileName);
// }
//
// @Override
// public String toString() {
// return getFileName();
// }
//
// }
// Path: src/main/java/com/civilizer/dao/FileEntityDao.java
import java.util.*;
import com.civilizer.domain.FileEntity;
package com.civilizer.dao;
public interface FileEntityDao {
public long countAll();
|
public List<FileEntity> findAll();
|
protonail/bolt-jna
|
bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltBucketStats.java
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/BucketStats.java
// public class BucketStats extends Structure {
// public static class ByValue extends BucketStats implements Structure.ByValue {}
//
// public int branchPageN;
// public int branchOverflowN;
// public int leafPageN;
// public int leafOverflowN;
//
// public int keyN;
// public int depth;
//
// public int branchAlloc;
// public int branchInUse;
// public int leafAlloc;
// public int leafInUse;
//
// public int bucketN;
// public int inlineBucketN;
// public int inlineBucketInUse;
//
// @Override
// protected List<String> getFieldOrder() {
// return Arrays.asList(
// "branchPageN",
// "branchOverflowN",
// "leafPageN",
// "leafOverflowN",
// "keyN",
// "depth",
// "branchAlloc",
// "branchInUse",
// "leafAlloc",
// "leafInUse",
// "bucketN",
// "inlineBucketN",
// "inlineBucketInUse"
// );
// }
// }
|
import com.protonail.bolt.jna.impl.BucketStats;
|
package com.protonail.bolt.jna;
public class BoltBucketStats {
private int branchPageN;
private int branchOverflowN;
private int leafPageN;
private int leafOverflowN;
private int keyN;
private int depth;
private int branchAlloc;
private int branchInUse;
private int leafAlloc;
private int leafInUse;
private int bucketN;
private int inlineBucketN;
private int inlineBucketInUse;
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/BucketStats.java
// public class BucketStats extends Structure {
// public static class ByValue extends BucketStats implements Structure.ByValue {}
//
// public int branchPageN;
// public int branchOverflowN;
// public int leafPageN;
// public int leafOverflowN;
//
// public int keyN;
// public int depth;
//
// public int branchAlloc;
// public int branchInUse;
// public int leafAlloc;
// public int leafInUse;
//
// public int bucketN;
// public int inlineBucketN;
// public int inlineBucketInUse;
//
// @Override
// protected List<String> getFieldOrder() {
// return Arrays.asList(
// "branchPageN",
// "branchOverflowN",
// "leafPageN",
// "leafOverflowN",
// "keyN",
// "depth",
// "branchAlloc",
// "branchInUse",
// "leafAlloc",
// "leafInUse",
// "bucketN",
// "inlineBucketN",
// "inlineBucketInUse"
// );
// }
// }
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltBucketStats.java
import com.protonail.bolt.jna.impl.BucketStats;
package com.protonail.bolt.jna;
public class BoltBucketStats {
private int branchPageN;
private int branchOverflowN;
private int leafPageN;
private int leafOverflowN;
private int keyN;
private int depth;
private int branchAlloc;
private int branchInUse;
private int leafAlloc;
private int leafInUse;
private int bucketN;
private int inlineBucketN;
private int inlineBucketInUse;
|
BoltBucketStats(BucketStats.ByValue bucketStats) {
|
protonail/bolt-jna
|
bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltTransaction.java
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/BoltNative.java
// public class BoltNative {
// static {
// Native.register("bolt");
// }
//
// // Common
//
// public static native void DoNothing();
//
// public static native void Free(Pointer pointer);
//
// public static native void Result_Free(Result.ByValue result);
//
// public static native void Error_Free(Error.ByValue error);
//
// public static native void Sequence_Free(Sequence.ByValue error);
//
// // Options
//
// public static native long BoltDBOptions_Create(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize);
//
// public static native void BoltDBOptions_Free(long optionsObjectId);
//
// // BoltDB
//
// public static native Result.ByValue BoltDB_Open(String databaseFileName, int fileMode, long optionsObjectId);
//
// public static native void BoltDB_Close(long boltObjectId);
//
// public static native Result.ByValue BoltDB_Begin(long boltObjectId, boolean writeable);
//
// public static native Stats.ByValue BoltDB_Stats(long boltObjectId);
//
// // Transaction
//
// public static native Error.ByValue BoltDBTransaction_Commit(long transactionObjectId);
//
// public static native Error.ByValue BoltDBTransaction_Rollback(long transactionObjectId);
//
// public static native int BoltDBTransaction_GetId(long transactionObjectId);
//
// public static native long BoltDBTransaction_Size(long transactionObjectId);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucketIfNotExists(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBTransaction_DeleteBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_Bucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBTransaction_Cursor(long transactionObjectId);
//
// public static native TransactionStats.ByValue BoltDBTransaction_Stats(long transactionObjectId);
//
// // Bucket
//
// public static native void BoltDBBucket_Free(long bucketObjectId);
//
// public static native Value.ByValue BoltDBBucket_Get(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Error.ByValue BoltDBBucket_Put(long bucketObjectId, byte[] key, int keyLength, byte[] value, int valueLength);
//
// public static native Error.ByValue BoltDBBucket_Delete(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucketIfNotExists(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBBucket_DeleteBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_Bucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBBucket_Cursor(long bucketObjectId);
//
// public static native Sequence.ByValue BoltDBBucket_NextSequence(long bucketObjectId);
//
// public static native BucketStats.ByValue BoltDBBucket_Stats(long bucketObjectId);
//
// // Cursor
//
// public static native void BoltDBCursor_Free(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_First(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Last(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Next(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Prev(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Seek(long cursorObjectId, byte[] seek, int seekLength);
//
// public static native Error.ByValue BoltDBCursor_Delete(long cursorObjectId);
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Error.java
// public class Error extends Structure {
// public static class ByValue extends Error implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Error_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Collections.singletonList("error");
// }
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Result.java
// public class Result extends Structure {
// public static class ByValue extends Result implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Result_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public long objectId;
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Arrays.asList("objectId", "error");
// }
// }
|
import com.protonail.bolt.jna.impl.BoltNative;
import com.protonail.bolt.jna.impl.Error;
import com.protonail.bolt.jna.impl.Result;
|
package com.protonail.bolt.jna;
public class BoltTransaction {
private long objectId;
BoltTransaction(long objectId) {
this.objectId = objectId;
}
public void commit() {
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/BoltNative.java
// public class BoltNative {
// static {
// Native.register("bolt");
// }
//
// // Common
//
// public static native void DoNothing();
//
// public static native void Free(Pointer pointer);
//
// public static native void Result_Free(Result.ByValue result);
//
// public static native void Error_Free(Error.ByValue error);
//
// public static native void Sequence_Free(Sequence.ByValue error);
//
// // Options
//
// public static native long BoltDBOptions_Create(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize);
//
// public static native void BoltDBOptions_Free(long optionsObjectId);
//
// // BoltDB
//
// public static native Result.ByValue BoltDB_Open(String databaseFileName, int fileMode, long optionsObjectId);
//
// public static native void BoltDB_Close(long boltObjectId);
//
// public static native Result.ByValue BoltDB_Begin(long boltObjectId, boolean writeable);
//
// public static native Stats.ByValue BoltDB_Stats(long boltObjectId);
//
// // Transaction
//
// public static native Error.ByValue BoltDBTransaction_Commit(long transactionObjectId);
//
// public static native Error.ByValue BoltDBTransaction_Rollback(long transactionObjectId);
//
// public static native int BoltDBTransaction_GetId(long transactionObjectId);
//
// public static native long BoltDBTransaction_Size(long transactionObjectId);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucketIfNotExists(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBTransaction_DeleteBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_Bucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBTransaction_Cursor(long transactionObjectId);
//
// public static native TransactionStats.ByValue BoltDBTransaction_Stats(long transactionObjectId);
//
// // Bucket
//
// public static native void BoltDBBucket_Free(long bucketObjectId);
//
// public static native Value.ByValue BoltDBBucket_Get(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Error.ByValue BoltDBBucket_Put(long bucketObjectId, byte[] key, int keyLength, byte[] value, int valueLength);
//
// public static native Error.ByValue BoltDBBucket_Delete(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucketIfNotExists(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBBucket_DeleteBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_Bucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBBucket_Cursor(long bucketObjectId);
//
// public static native Sequence.ByValue BoltDBBucket_NextSequence(long bucketObjectId);
//
// public static native BucketStats.ByValue BoltDBBucket_Stats(long bucketObjectId);
//
// // Cursor
//
// public static native void BoltDBCursor_Free(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_First(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Last(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Next(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Prev(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Seek(long cursorObjectId, byte[] seek, int seekLength);
//
// public static native Error.ByValue BoltDBCursor_Delete(long cursorObjectId);
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Error.java
// public class Error extends Structure {
// public static class ByValue extends Error implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Error_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Collections.singletonList("error");
// }
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Result.java
// public class Result extends Structure {
// public static class ByValue extends Result implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Result_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public long objectId;
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Arrays.asList("objectId", "error");
// }
// }
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltTransaction.java
import com.protonail.bolt.jna.impl.BoltNative;
import com.protonail.bolt.jna.impl.Error;
import com.protonail.bolt.jna.impl.Result;
package com.protonail.bolt.jna;
public class BoltTransaction {
private long objectId;
BoltTransaction(long objectId) {
this.objectId = objectId;
}
public void commit() {
|
Error.ByValue error = BoltNative.BoltDBTransaction_Commit(objectId);
|
protonail/bolt-jna
|
bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltTransaction.java
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/BoltNative.java
// public class BoltNative {
// static {
// Native.register("bolt");
// }
//
// // Common
//
// public static native void DoNothing();
//
// public static native void Free(Pointer pointer);
//
// public static native void Result_Free(Result.ByValue result);
//
// public static native void Error_Free(Error.ByValue error);
//
// public static native void Sequence_Free(Sequence.ByValue error);
//
// // Options
//
// public static native long BoltDBOptions_Create(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize);
//
// public static native void BoltDBOptions_Free(long optionsObjectId);
//
// // BoltDB
//
// public static native Result.ByValue BoltDB_Open(String databaseFileName, int fileMode, long optionsObjectId);
//
// public static native void BoltDB_Close(long boltObjectId);
//
// public static native Result.ByValue BoltDB_Begin(long boltObjectId, boolean writeable);
//
// public static native Stats.ByValue BoltDB_Stats(long boltObjectId);
//
// // Transaction
//
// public static native Error.ByValue BoltDBTransaction_Commit(long transactionObjectId);
//
// public static native Error.ByValue BoltDBTransaction_Rollback(long transactionObjectId);
//
// public static native int BoltDBTransaction_GetId(long transactionObjectId);
//
// public static native long BoltDBTransaction_Size(long transactionObjectId);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucketIfNotExists(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBTransaction_DeleteBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_Bucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBTransaction_Cursor(long transactionObjectId);
//
// public static native TransactionStats.ByValue BoltDBTransaction_Stats(long transactionObjectId);
//
// // Bucket
//
// public static native void BoltDBBucket_Free(long bucketObjectId);
//
// public static native Value.ByValue BoltDBBucket_Get(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Error.ByValue BoltDBBucket_Put(long bucketObjectId, byte[] key, int keyLength, byte[] value, int valueLength);
//
// public static native Error.ByValue BoltDBBucket_Delete(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucketIfNotExists(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBBucket_DeleteBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_Bucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBBucket_Cursor(long bucketObjectId);
//
// public static native Sequence.ByValue BoltDBBucket_NextSequence(long bucketObjectId);
//
// public static native BucketStats.ByValue BoltDBBucket_Stats(long bucketObjectId);
//
// // Cursor
//
// public static native void BoltDBCursor_Free(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_First(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Last(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Next(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Prev(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Seek(long cursorObjectId, byte[] seek, int seekLength);
//
// public static native Error.ByValue BoltDBCursor_Delete(long cursorObjectId);
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Error.java
// public class Error extends Structure {
// public static class ByValue extends Error implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Error_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Collections.singletonList("error");
// }
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Result.java
// public class Result extends Structure {
// public static class ByValue extends Result implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Result_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public long objectId;
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Arrays.asList("objectId", "error");
// }
// }
|
import com.protonail.bolt.jna.impl.BoltNative;
import com.protonail.bolt.jna.impl.Error;
import com.protonail.bolt.jna.impl.Result;
|
package com.protonail.bolt.jna;
public class BoltTransaction {
private long objectId;
BoltTransaction(long objectId) {
this.objectId = objectId;
}
public void commit() {
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/BoltNative.java
// public class BoltNative {
// static {
// Native.register("bolt");
// }
//
// // Common
//
// public static native void DoNothing();
//
// public static native void Free(Pointer pointer);
//
// public static native void Result_Free(Result.ByValue result);
//
// public static native void Error_Free(Error.ByValue error);
//
// public static native void Sequence_Free(Sequence.ByValue error);
//
// // Options
//
// public static native long BoltDBOptions_Create(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize);
//
// public static native void BoltDBOptions_Free(long optionsObjectId);
//
// // BoltDB
//
// public static native Result.ByValue BoltDB_Open(String databaseFileName, int fileMode, long optionsObjectId);
//
// public static native void BoltDB_Close(long boltObjectId);
//
// public static native Result.ByValue BoltDB_Begin(long boltObjectId, boolean writeable);
//
// public static native Stats.ByValue BoltDB_Stats(long boltObjectId);
//
// // Transaction
//
// public static native Error.ByValue BoltDBTransaction_Commit(long transactionObjectId);
//
// public static native Error.ByValue BoltDBTransaction_Rollback(long transactionObjectId);
//
// public static native int BoltDBTransaction_GetId(long transactionObjectId);
//
// public static native long BoltDBTransaction_Size(long transactionObjectId);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucketIfNotExists(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBTransaction_DeleteBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_Bucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBTransaction_Cursor(long transactionObjectId);
//
// public static native TransactionStats.ByValue BoltDBTransaction_Stats(long transactionObjectId);
//
// // Bucket
//
// public static native void BoltDBBucket_Free(long bucketObjectId);
//
// public static native Value.ByValue BoltDBBucket_Get(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Error.ByValue BoltDBBucket_Put(long bucketObjectId, byte[] key, int keyLength, byte[] value, int valueLength);
//
// public static native Error.ByValue BoltDBBucket_Delete(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucketIfNotExists(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBBucket_DeleteBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_Bucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBBucket_Cursor(long bucketObjectId);
//
// public static native Sequence.ByValue BoltDBBucket_NextSequence(long bucketObjectId);
//
// public static native BucketStats.ByValue BoltDBBucket_Stats(long bucketObjectId);
//
// // Cursor
//
// public static native void BoltDBCursor_Free(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_First(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Last(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Next(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Prev(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Seek(long cursorObjectId, byte[] seek, int seekLength);
//
// public static native Error.ByValue BoltDBCursor_Delete(long cursorObjectId);
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Error.java
// public class Error extends Structure {
// public static class ByValue extends Error implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Error_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Collections.singletonList("error");
// }
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Result.java
// public class Result extends Structure {
// public static class ByValue extends Result implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Result_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public long objectId;
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Arrays.asList("objectId", "error");
// }
// }
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltTransaction.java
import com.protonail.bolt.jna.impl.BoltNative;
import com.protonail.bolt.jna.impl.Error;
import com.protonail.bolt.jna.impl.Result;
package com.protonail.bolt.jna;
public class BoltTransaction {
private long objectId;
BoltTransaction(long objectId) {
this.objectId = objectId;
}
public void commit() {
|
Error.ByValue error = BoltNative.BoltDBTransaction_Commit(objectId);
|
protonail/bolt-jna
|
bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltTransaction.java
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/BoltNative.java
// public class BoltNative {
// static {
// Native.register("bolt");
// }
//
// // Common
//
// public static native void DoNothing();
//
// public static native void Free(Pointer pointer);
//
// public static native void Result_Free(Result.ByValue result);
//
// public static native void Error_Free(Error.ByValue error);
//
// public static native void Sequence_Free(Sequence.ByValue error);
//
// // Options
//
// public static native long BoltDBOptions_Create(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize);
//
// public static native void BoltDBOptions_Free(long optionsObjectId);
//
// // BoltDB
//
// public static native Result.ByValue BoltDB_Open(String databaseFileName, int fileMode, long optionsObjectId);
//
// public static native void BoltDB_Close(long boltObjectId);
//
// public static native Result.ByValue BoltDB_Begin(long boltObjectId, boolean writeable);
//
// public static native Stats.ByValue BoltDB_Stats(long boltObjectId);
//
// // Transaction
//
// public static native Error.ByValue BoltDBTransaction_Commit(long transactionObjectId);
//
// public static native Error.ByValue BoltDBTransaction_Rollback(long transactionObjectId);
//
// public static native int BoltDBTransaction_GetId(long transactionObjectId);
//
// public static native long BoltDBTransaction_Size(long transactionObjectId);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucketIfNotExists(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBTransaction_DeleteBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_Bucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBTransaction_Cursor(long transactionObjectId);
//
// public static native TransactionStats.ByValue BoltDBTransaction_Stats(long transactionObjectId);
//
// // Bucket
//
// public static native void BoltDBBucket_Free(long bucketObjectId);
//
// public static native Value.ByValue BoltDBBucket_Get(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Error.ByValue BoltDBBucket_Put(long bucketObjectId, byte[] key, int keyLength, byte[] value, int valueLength);
//
// public static native Error.ByValue BoltDBBucket_Delete(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucketIfNotExists(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBBucket_DeleteBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_Bucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBBucket_Cursor(long bucketObjectId);
//
// public static native Sequence.ByValue BoltDBBucket_NextSequence(long bucketObjectId);
//
// public static native BucketStats.ByValue BoltDBBucket_Stats(long bucketObjectId);
//
// // Cursor
//
// public static native void BoltDBCursor_Free(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_First(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Last(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Next(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Prev(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Seek(long cursorObjectId, byte[] seek, int seekLength);
//
// public static native Error.ByValue BoltDBCursor_Delete(long cursorObjectId);
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Error.java
// public class Error extends Structure {
// public static class ByValue extends Error implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Error_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Collections.singletonList("error");
// }
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Result.java
// public class Result extends Structure {
// public static class ByValue extends Result implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Result_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public long objectId;
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Arrays.asList("objectId", "error");
// }
// }
|
import com.protonail.bolt.jna.impl.BoltNative;
import com.protonail.bolt.jna.impl.Error;
import com.protonail.bolt.jna.impl.Result;
|
package com.protonail.bolt.jna;
public class BoltTransaction {
private long objectId;
BoltTransaction(long objectId) {
this.objectId = objectId;
}
public void commit() {
Error.ByValue error = BoltNative.BoltDBTransaction_Commit(objectId);
error.checkError();
}
public void rollback() {
Error.ByValue error = BoltNative.BoltDBTransaction_Rollback(objectId);
error.checkError();
}
public int getId() {
return BoltNative.BoltDBTransaction_GetId(objectId);
}
public long getDatabaseSize() {
return BoltNative.BoltDBTransaction_Size(objectId);
}
public BoltBucket createBucket(byte[] name) {
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/BoltNative.java
// public class BoltNative {
// static {
// Native.register("bolt");
// }
//
// // Common
//
// public static native void DoNothing();
//
// public static native void Free(Pointer pointer);
//
// public static native void Result_Free(Result.ByValue result);
//
// public static native void Error_Free(Error.ByValue error);
//
// public static native void Sequence_Free(Sequence.ByValue error);
//
// // Options
//
// public static native long BoltDBOptions_Create(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize);
//
// public static native void BoltDBOptions_Free(long optionsObjectId);
//
// // BoltDB
//
// public static native Result.ByValue BoltDB_Open(String databaseFileName, int fileMode, long optionsObjectId);
//
// public static native void BoltDB_Close(long boltObjectId);
//
// public static native Result.ByValue BoltDB_Begin(long boltObjectId, boolean writeable);
//
// public static native Stats.ByValue BoltDB_Stats(long boltObjectId);
//
// // Transaction
//
// public static native Error.ByValue BoltDBTransaction_Commit(long transactionObjectId);
//
// public static native Error.ByValue BoltDBTransaction_Rollback(long transactionObjectId);
//
// public static native int BoltDBTransaction_GetId(long transactionObjectId);
//
// public static native long BoltDBTransaction_Size(long transactionObjectId);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucketIfNotExists(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBTransaction_DeleteBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_Bucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBTransaction_Cursor(long transactionObjectId);
//
// public static native TransactionStats.ByValue BoltDBTransaction_Stats(long transactionObjectId);
//
// // Bucket
//
// public static native void BoltDBBucket_Free(long bucketObjectId);
//
// public static native Value.ByValue BoltDBBucket_Get(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Error.ByValue BoltDBBucket_Put(long bucketObjectId, byte[] key, int keyLength, byte[] value, int valueLength);
//
// public static native Error.ByValue BoltDBBucket_Delete(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucketIfNotExists(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBBucket_DeleteBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_Bucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBBucket_Cursor(long bucketObjectId);
//
// public static native Sequence.ByValue BoltDBBucket_NextSequence(long bucketObjectId);
//
// public static native BucketStats.ByValue BoltDBBucket_Stats(long bucketObjectId);
//
// // Cursor
//
// public static native void BoltDBCursor_Free(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_First(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Last(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Next(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Prev(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Seek(long cursorObjectId, byte[] seek, int seekLength);
//
// public static native Error.ByValue BoltDBCursor_Delete(long cursorObjectId);
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Error.java
// public class Error extends Structure {
// public static class ByValue extends Error implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Error_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Collections.singletonList("error");
// }
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Result.java
// public class Result extends Structure {
// public static class ByValue extends Result implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Result_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public long objectId;
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Arrays.asList("objectId", "error");
// }
// }
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltTransaction.java
import com.protonail.bolt.jna.impl.BoltNative;
import com.protonail.bolt.jna.impl.Error;
import com.protonail.bolt.jna.impl.Result;
package com.protonail.bolt.jna;
public class BoltTransaction {
private long objectId;
BoltTransaction(long objectId) {
this.objectId = objectId;
}
public void commit() {
Error.ByValue error = BoltNative.BoltDBTransaction_Commit(objectId);
error.checkError();
}
public void rollback() {
Error.ByValue error = BoltNative.BoltDBTransaction_Rollback(objectId);
error.checkError();
}
public int getId() {
return BoltNative.BoltDBTransaction_GetId(objectId);
}
public long getDatabaseSize() {
return BoltNative.BoltDBTransaction_Size(objectId);
}
public BoltBucket createBucket(byte[] name) {
|
Result.ByValue result = BoltNative.BoltDBTransaction_CreateBucket(objectId, name, name.length);
|
protonail/bolt-jna
|
bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltCursor.java
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/BoltNative.java
// public class BoltNative {
// static {
// Native.register("bolt");
// }
//
// // Common
//
// public static native void DoNothing();
//
// public static native void Free(Pointer pointer);
//
// public static native void Result_Free(Result.ByValue result);
//
// public static native void Error_Free(Error.ByValue error);
//
// public static native void Sequence_Free(Sequence.ByValue error);
//
// // Options
//
// public static native long BoltDBOptions_Create(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize);
//
// public static native void BoltDBOptions_Free(long optionsObjectId);
//
// // BoltDB
//
// public static native Result.ByValue BoltDB_Open(String databaseFileName, int fileMode, long optionsObjectId);
//
// public static native void BoltDB_Close(long boltObjectId);
//
// public static native Result.ByValue BoltDB_Begin(long boltObjectId, boolean writeable);
//
// public static native Stats.ByValue BoltDB_Stats(long boltObjectId);
//
// // Transaction
//
// public static native Error.ByValue BoltDBTransaction_Commit(long transactionObjectId);
//
// public static native Error.ByValue BoltDBTransaction_Rollback(long transactionObjectId);
//
// public static native int BoltDBTransaction_GetId(long transactionObjectId);
//
// public static native long BoltDBTransaction_Size(long transactionObjectId);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucketIfNotExists(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBTransaction_DeleteBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_Bucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBTransaction_Cursor(long transactionObjectId);
//
// public static native TransactionStats.ByValue BoltDBTransaction_Stats(long transactionObjectId);
//
// // Bucket
//
// public static native void BoltDBBucket_Free(long bucketObjectId);
//
// public static native Value.ByValue BoltDBBucket_Get(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Error.ByValue BoltDBBucket_Put(long bucketObjectId, byte[] key, int keyLength, byte[] value, int valueLength);
//
// public static native Error.ByValue BoltDBBucket_Delete(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucketIfNotExists(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBBucket_DeleteBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_Bucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBBucket_Cursor(long bucketObjectId);
//
// public static native Sequence.ByValue BoltDBBucket_NextSequence(long bucketObjectId);
//
// public static native BucketStats.ByValue BoltDBBucket_Stats(long bucketObjectId);
//
// // Cursor
//
// public static native void BoltDBCursor_Free(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_First(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Last(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Next(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Prev(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Seek(long cursorObjectId, byte[] seek, int seekLength);
//
// public static native Error.ByValue BoltDBCursor_Delete(long cursorObjectId);
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Error.java
// public class Error extends Structure {
// public static class ByValue extends Error implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Error_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Collections.singletonList("error");
// }
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/KeyValue.java
// public class KeyValue extends Structure {
// public static class ByValue extends KeyValue implements Structure.ByValue, AutoCloseable {
// @Override
// public void close() {
// if (key != null) {
// BoltNative.Free(key);
// }
//
// if (value != null) {
// BoltNative.Free(value);
// }
// }
// }
//
// public Pointer key;
// public int keyLength;
// public Pointer value;
// public int valueLength;
//
// @Override
// protected List<String> getFieldOrder() {
// return Arrays.asList("key", "keyLength", "value", "valueLength");
// }
//
// public boolean hasKeyValue() {
// return key != null;
// }
//
// public byte[] getKey() {
// return key != null ? key.getByteArray(0, keyLength) : null;
// }
//
// public byte[] getValue() {
// return value != null ? value.getByteArray(0, valueLength) : null;
// }
// }
|
import com.protonail.bolt.jna.impl.BoltNative;
import com.protonail.bolt.jna.impl.Error;
import com.protonail.bolt.jna.impl.KeyValue;
|
package com.protonail.bolt.jna;
public class BoltCursor implements AutoCloseable {
long objectId;
public BoltCursor(long objectId) {
this.objectId = objectId;
}
@Override
public void close() {
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/BoltNative.java
// public class BoltNative {
// static {
// Native.register("bolt");
// }
//
// // Common
//
// public static native void DoNothing();
//
// public static native void Free(Pointer pointer);
//
// public static native void Result_Free(Result.ByValue result);
//
// public static native void Error_Free(Error.ByValue error);
//
// public static native void Sequence_Free(Sequence.ByValue error);
//
// // Options
//
// public static native long BoltDBOptions_Create(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize);
//
// public static native void BoltDBOptions_Free(long optionsObjectId);
//
// // BoltDB
//
// public static native Result.ByValue BoltDB_Open(String databaseFileName, int fileMode, long optionsObjectId);
//
// public static native void BoltDB_Close(long boltObjectId);
//
// public static native Result.ByValue BoltDB_Begin(long boltObjectId, boolean writeable);
//
// public static native Stats.ByValue BoltDB_Stats(long boltObjectId);
//
// // Transaction
//
// public static native Error.ByValue BoltDBTransaction_Commit(long transactionObjectId);
//
// public static native Error.ByValue BoltDBTransaction_Rollback(long transactionObjectId);
//
// public static native int BoltDBTransaction_GetId(long transactionObjectId);
//
// public static native long BoltDBTransaction_Size(long transactionObjectId);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucketIfNotExists(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBTransaction_DeleteBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_Bucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBTransaction_Cursor(long transactionObjectId);
//
// public static native TransactionStats.ByValue BoltDBTransaction_Stats(long transactionObjectId);
//
// // Bucket
//
// public static native void BoltDBBucket_Free(long bucketObjectId);
//
// public static native Value.ByValue BoltDBBucket_Get(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Error.ByValue BoltDBBucket_Put(long bucketObjectId, byte[] key, int keyLength, byte[] value, int valueLength);
//
// public static native Error.ByValue BoltDBBucket_Delete(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucketIfNotExists(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBBucket_DeleteBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_Bucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBBucket_Cursor(long bucketObjectId);
//
// public static native Sequence.ByValue BoltDBBucket_NextSequence(long bucketObjectId);
//
// public static native BucketStats.ByValue BoltDBBucket_Stats(long bucketObjectId);
//
// // Cursor
//
// public static native void BoltDBCursor_Free(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_First(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Last(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Next(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Prev(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Seek(long cursorObjectId, byte[] seek, int seekLength);
//
// public static native Error.ByValue BoltDBCursor_Delete(long cursorObjectId);
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Error.java
// public class Error extends Structure {
// public static class ByValue extends Error implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Error_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Collections.singletonList("error");
// }
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/KeyValue.java
// public class KeyValue extends Structure {
// public static class ByValue extends KeyValue implements Structure.ByValue, AutoCloseable {
// @Override
// public void close() {
// if (key != null) {
// BoltNative.Free(key);
// }
//
// if (value != null) {
// BoltNative.Free(value);
// }
// }
// }
//
// public Pointer key;
// public int keyLength;
// public Pointer value;
// public int valueLength;
//
// @Override
// protected List<String> getFieldOrder() {
// return Arrays.asList("key", "keyLength", "value", "valueLength");
// }
//
// public boolean hasKeyValue() {
// return key != null;
// }
//
// public byte[] getKey() {
// return key != null ? key.getByteArray(0, keyLength) : null;
// }
//
// public byte[] getValue() {
// return value != null ? value.getByteArray(0, valueLength) : null;
// }
// }
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltCursor.java
import com.protonail.bolt.jna.impl.BoltNative;
import com.protonail.bolt.jna.impl.Error;
import com.protonail.bolt.jna.impl.KeyValue;
package com.protonail.bolt.jna;
public class BoltCursor implements AutoCloseable {
long objectId;
public BoltCursor(long objectId) {
this.objectId = objectId;
}
@Override
public void close() {
|
BoltNative.BoltDBCursor_Free(objectId);
|
protonail/bolt-jna
|
bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltCursor.java
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/BoltNative.java
// public class BoltNative {
// static {
// Native.register("bolt");
// }
//
// // Common
//
// public static native void DoNothing();
//
// public static native void Free(Pointer pointer);
//
// public static native void Result_Free(Result.ByValue result);
//
// public static native void Error_Free(Error.ByValue error);
//
// public static native void Sequence_Free(Sequence.ByValue error);
//
// // Options
//
// public static native long BoltDBOptions_Create(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize);
//
// public static native void BoltDBOptions_Free(long optionsObjectId);
//
// // BoltDB
//
// public static native Result.ByValue BoltDB_Open(String databaseFileName, int fileMode, long optionsObjectId);
//
// public static native void BoltDB_Close(long boltObjectId);
//
// public static native Result.ByValue BoltDB_Begin(long boltObjectId, boolean writeable);
//
// public static native Stats.ByValue BoltDB_Stats(long boltObjectId);
//
// // Transaction
//
// public static native Error.ByValue BoltDBTransaction_Commit(long transactionObjectId);
//
// public static native Error.ByValue BoltDBTransaction_Rollback(long transactionObjectId);
//
// public static native int BoltDBTransaction_GetId(long transactionObjectId);
//
// public static native long BoltDBTransaction_Size(long transactionObjectId);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucketIfNotExists(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBTransaction_DeleteBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_Bucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBTransaction_Cursor(long transactionObjectId);
//
// public static native TransactionStats.ByValue BoltDBTransaction_Stats(long transactionObjectId);
//
// // Bucket
//
// public static native void BoltDBBucket_Free(long bucketObjectId);
//
// public static native Value.ByValue BoltDBBucket_Get(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Error.ByValue BoltDBBucket_Put(long bucketObjectId, byte[] key, int keyLength, byte[] value, int valueLength);
//
// public static native Error.ByValue BoltDBBucket_Delete(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucketIfNotExists(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBBucket_DeleteBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_Bucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBBucket_Cursor(long bucketObjectId);
//
// public static native Sequence.ByValue BoltDBBucket_NextSequence(long bucketObjectId);
//
// public static native BucketStats.ByValue BoltDBBucket_Stats(long bucketObjectId);
//
// // Cursor
//
// public static native void BoltDBCursor_Free(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_First(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Last(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Next(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Prev(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Seek(long cursorObjectId, byte[] seek, int seekLength);
//
// public static native Error.ByValue BoltDBCursor_Delete(long cursorObjectId);
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Error.java
// public class Error extends Structure {
// public static class ByValue extends Error implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Error_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Collections.singletonList("error");
// }
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/KeyValue.java
// public class KeyValue extends Structure {
// public static class ByValue extends KeyValue implements Structure.ByValue, AutoCloseable {
// @Override
// public void close() {
// if (key != null) {
// BoltNative.Free(key);
// }
//
// if (value != null) {
// BoltNative.Free(value);
// }
// }
// }
//
// public Pointer key;
// public int keyLength;
// public Pointer value;
// public int valueLength;
//
// @Override
// protected List<String> getFieldOrder() {
// return Arrays.asList("key", "keyLength", "value", "valueLength");
// }
//
// public boolean hasKeyValue() {
// return key != null;
// }
//
// public byte[] getKey() {
// return key != null ? key.getByteArray(0, keyLength) : null;
// }
//
// public byte[] getValue() {
// return value != null ? value.getByteArray(0, valueLength) : null;
// }
// }
|
import com.protonail.bolt.jna.impl.BoltNative;
import com.protonail.bolt.jna.impl.Error;
import com.protonail.bolt.jna.impl.KeyValue;
|
package com.protonail.bolt.jna;
public class BoltCursor implements AutoCloseable {
long objectId;
public BoltCursor(long objectId) {
this.objectId = objectId;
}
@Override
public void close() {
BoltNative.BoltDBCursor_Free(objectId);
}
public BoltKeyValue first() {
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/BoltNative.java
// public class BoltNative {
// static {
// Native.register("bolt");
// }
//
// // Common
//
// public static native void DoNothing();
//
// public static native void Free(Pointer pointer);
//
// public static native void Result_Free(Result.ByValue result);
//
// public static native void Error_Free(Error.ByValue error);
//
// public static native void Sequence_Free(Sequence.ByValue error);
//
// // Options
//
// public static native long BoltDBOptions_Create(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize);
//
// public static native void BoltDBOptions_Free(long optionsObjectId);
//
// // BoltDB
//
// public static native Result.ByValue BoltDB_Open(String databaseFileName, int fileMode, long optionsObjectId);
//
// public static native void BoltDB_Close(long boltObjectId);
//
// public static native Result.ByValue BoltDB_Begin(long boltObjectId, boolean writeable);
//
// public static native Stats.ByValue BoltDB_Stats(long boltObjectId);
//
// // Transaction
//
// public static native Error.ByValue BoltDBTransaction_Commit(long transactionObjectId);
//
// public static native Error.ByValue BoltDBTransaction_Rollback(long transactionObjectId);
//
// public static native int BoltDBTransaction_GetId(long transactionObjectId);
//
// public static native long BoltDBTransaction_Size(long transactionObjectId);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucketIfNotExists(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBTransaction_DeleteBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_Bucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBTransaction_Cursor(long transactionObjectId);
//
// public static native TransactionStats.ByValue BoltDBTransaction_Stats(long transactionObjectId);
//
// // Bucket
//
// public static native void BoltDBBucket_Free(long bucketObjectId);
//
// public static native Value.ByValue BoltDBBucket_Get(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Error.ByValue BoltDBBucket_Put(long bucketObjectId, byte[] key, int keyLength, byte[] value, int valueLength);
//
// public static native Error.ByValue BoltDBBucket_Delete(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucketIfNotExists(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBBucket_DeleteBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_Bucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBBucket_Cursor(long bucketObjectId);
//
// public static native Sequence.ByValue BoltDBBucket_NextSequence(long bucketObjectId);
//
// public static native BucketStats.ByValue BoltDBBucket_Stats(long bucketObjectId);
//
// // Cursor
//
// public static native void BoltDBCursor_Free(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_First(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Last(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Next(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Prev(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Seek(long cursorObjectId, byte[] seek, int seekLength);
//
// public static native Error.ByValue BoltDBCursor_Delete(long cursorObjectId);
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Error.java
// public class Error extends Structure {
// public static class ByValue extends Error implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Error_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Collections.singletonList("error");
// }
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/KeyValue.java
// public class KeyValue extends Structure {
// public static class ByValue extends KeyValue implements Structure.ByValue, AutoCloseable {
// @Override
// public void close() {
// if (key != null) {
// BoltNative.Free(key);
// }
//
// if (value != null) {
// BoltNative.Free(value);
// }
// }
// }
//
// public Pointer key;
// public int keyLength;
// public Pointer value;
// public int valueLength;
//
// @Override
// protected List<String> getFieldOrder() {
// return Arrays.asList("key", "keyLength", "value", "valueLength");
// }
//
// public boolean hasKeyValue() {
// return key != null;
// }
//
// public byte[] getKey() {
// return key != null ? key.getByteArray(0, keyLength) : null;
// }
//
// public byte[] getValue() {
// return value != null ? value.getByteArray(0, valueLength) : null;
// }
// }
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltCursor.java
import com.protonail.bolt.jna.impl.BoltNative;
import com.protonail.bolt.jna.impl.Error;
import com.protonail.bolt.jna.impl.KeyValue;
package com.protonail.bolt.jna;
public class BoltCursor implements AutoCloseable {
long objectId;
public BoltCursor(long objectId) {
this.objectId = objectId;
}
@Override
public void close() {
BoltNative.BoltDBCursor_Free(objectId);
}
public BoltKeyValue first() {
|
try(KeyValue.ByValue keyValue = BoltNative.BoltDBCursor_First(objectId)) {
|
protonail/bolt-jna
|
bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Sequence.java
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltException.java
// public class BoltException extends RuntimeException {
// public BoltException(String message) {
// super(message);
// }
// }
|
import com.protonail.bolt.jna.BoltException;
import com.sun.jna.Structure;
import java.util.Arrays;
import java.util.List;
|
package com.protonail.bolt.jna.impl;
public class Sequence extends Structure {
public static class ByValue extends Sequence implements Structure.ByValue {
public void checkError() {
if (error != null) {
BoltNative.Sequence_Free(this);
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltException.java
// public class BoltException extends RuntimeException {
// public BoltException(String message) {
// super(message);
// }
// }
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Sequence.java
import com.protonail.bolt.jna.BoltException;
import com.sun.jna.Structure;
import java.util.Arrays;
import java.util.List;
package com.protonail.bolt.jna.impl;
public class Sequence extends Structure {
public static class ByValue extends Sequence implements Structure.ByValue {
public void checkError() {
if (error != null) {
BoltNative.Sequence_Free(this);
|
throw new BoltException(error);
|
protonail/bolt-jna
|
bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltBucket.java
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Error.java
// public class Error extends Structure {
// public static class ByValue extends Error implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Error_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Collections.singletonList("error");
// }
// }
|
import com.protonail.bolt.jna.impl.*;
import com.protonail.bolt.jna.impl.Error;
|
package com.protonail.bolt.jna;
public class BoltBucket implements AutoCloseable {
long objectId;
BoltBucket(long objectId) {
this.objectId = objectId;
}
@Override
public void close() {
BoltNative.BoltDBBucket_Free(objectId);
}
public byte[] get(byte[] key) {
try(Value.ByValue value = BoltNative.BoltDBBucket_Get(objectId, key, key.length)) {
return value.hasValue() ? value.getValue() : null;
}
}
public void put(byte[] key, byte[] value) {
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Error.java
// public class Error extends Structure {
// public static class ByValue extends Error implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Error_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Collections.singletonList("error");
// }
// }
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltBucket.java
import com.protonail.bolt.jna.impl.*;
import com.protonail.bolt.jna.impl.Error;
package com.protonail.bolt.jna;
public class BoltBucket implements AutoCloseable {
long objectId;
BoltBucket(long objectId) {
this.objectId = objectId;
}
@Override
public void close() {
BoltNative.BoltDBBucket_Free(objectId);
}
public byte[] get(byte[] key) {
try(Value.ByValue value = BoltNative.BoltDBBucket_Get(objectId, key, key.length)) {
return value.hasValue() ? value.getValue() : null;
}
}
public void put(byte[] key, byte[] value) {
|
Error.ByValue error = BoltNative.BoltDBBucket_Put(objectId, key, key.length, value, value.length);
|
protonail/bolt-jna
|
bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltOptions.java
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/BoltNative.java
// public class BoltNative {
// static {
// Native.register("bolt");
// }
//
// // Common
//
// public static native void DoNothing();
//
// public static native void Free(Pointer pointer);
//
// public static native void Result_Free(Result.ByValue result);
//
// public static native void Error_Free(Error.ByValue error);
//
// public static native void Sequence_Free(Sequence.ByValue error);
//
// // Options
//
// public static native long BoltDBOptions_Create(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize);
//
// public static native void BoltDBOptions_Free(long optionsObjectId);
//
// // BoltDB
//
// public static native Result.ByValue BoltDB_Open(String databaseFileName, int fileMode, long optionsObjectId);
//
// public static native void BoltDB_Close(long boltObjectId);
//
// public static native Result.ByValue BoltDB_Begin(long boltObjectId, boolean writeable);
//
// public static native Stats.ByValue BoltDB_Stats(long boltObjectId);
//
// // Transaction
//
// public static native Error.ByValue BoltDBTransaction_Commit(long transactionObjectId);
//
// public static native Error.ByValue BoltDBTransaction_Rollback(long transactionObjectId);
//
// public static native int BoltDBTransaction_GetId(long transactionObjectId);
//
// public static native long BoltDBTransaction_Size(long transactionObjectId);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucketIfNotExists(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBTransaction_DeleteBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_Bucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBTransaction_Cursor(long transactionObjectId);
//
// public static native TransactionStats.ByValue BoltDBTransaction_Stats(long transactionObjectId);
//
// // Bucket
//
// public static native void BoltDBBucket_Free(long bucketObjectId);
//
// public static native Value.ByValue BoltDBBucket_Get(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Error.ByValue BoltDBBucket_Put(long bucketObjectId, byte[] key, int keyLength, byte[] value, int valueLength);
//
// public static native Error.ByValue BoltDBBucket_Delete(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucketIfNotExists(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBBucket_DeleteBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_Bucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBBucket_Cursor(long bucketObjectId);
//
// public static native Sequence.ByValue BoltDBBucket_NextSequence(long bucketObjectId);
//
// public static native BucketStats.ByValue BoltDBBucket_Stats(long bucketObjectId);
//
// // Cursor
//
// public static native void BoltDBCursor_Free(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_First(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Last(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Next(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Prev(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Seek(long cursorObjectId, byte[] seek, int seekLength);
//
// public static native Error.ByValue BoltDBCursor_Delete(long cursorObjectId);
// }
|
import com.protonail.bolt.jna.impl.BoltNative;
|
package com.protonail.bolt.jna;
public class BoltOptions implements AutoCloseable {
long objectId;
public BoltOptions() {
this(1000);
}
public BoltOptions(long timeout) {
this(timeout, false, false, 0, 0);
}
public BoltOptions(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize) {
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/BoltNative.java
// public class BoltNative {
// static {
// Native.register("bolt");
// }
//
// // Common
//
// public static native void DoNothing();
//
// public static native void Free(Pointer pointer);
//
// public static native void Result_Free(Result.ByValue result);
//
// public static native void Error_Free(Error.ByValue error);
//
// public static native void Sequence_Free(Sequence.ByValue error);
//
// // Options
//
// public static native long BoltDBOptions_Create(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize);
//
// public static native void BoltDBOptions_Free(long optionsObjectId);
//
// // BoltDB
//
// public static native Result.ByValue BoltDB_Open(String databaseFileName, int fileMode, long optionsObjectId);
//
// public static native void BoltDB_Close(long boltObjectId);
//
// public static native Result.ByValue BoltDB_Begin(long boltObjectId, boolean writeable);
//
// public static native Stats.ByValue BoltDB_Stats(long boltObjectId);
//
// // Transaction
//
// public static native Error.ByValue BoltDBTransaction_Commit(long transactionObjectId);
//
// public static native Error.ByValue BoltDBTransaction_Rollback(long transactionObjectId);
//
// public static native int BoltDBTransaction_GetId(long transactionObjectId);
//
// public static native long BoltDBTransaction_Size(long transactionObjectId);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucketIfNotExists(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBTransaction_DeleteBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_Bucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBTransaction_Cursor(long transactionObjectId);
//
// public static native TransactionStats.ByValue BoltDBTransaction_Stats(long transactionObjectId);
//
// // Bucket
//
// public static native void BoltDBBucket_Free(long bucketObjectId);
//
// public static native Value.ByValue BoltDBBucket_Get(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Error.ByValue BoltDBBucket_Put(long bucketObjectId, byte[] key, int keyLength, byte[] value, int valueLength);
//
// public static native Error.ByValue BoltDBBucket_Delete(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucketIfNotExists(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBBucket_DeleteBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_Bucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBBucket_Cursor(long bucketObjectId);
//
// public static native Sequence.ByValue BoltDBBucket_NextSequence(long bucketObjectId);
//
// public static native BucketStats.ByValue BoltDBBucket_Stats(long bucketObjectId);
//
// // Cursor
//
// public static native void BoltDBCursor_Free(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_First(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Last(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Next(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Prev(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Seek(long cursorObjectId, byte[] seek, int seekLength);
//
// public static native Error.ByValue BoltDBCursor_Delete(long cursorObjectId);
// }
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltOptions.java
import com.protonail.bolt.jna.impl.BoltNative;
package com.protonail.bolt.jna;
public class BoltOptions implements AutoCloseable {
long objectId;
public BoltOptions() {
this(1000);
}
public BoltOptions(long timeout) {
this(timeout, false, false, 0, 0);
}
public BoltOptions(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize) {
|
objectId = BoltNative.BoltDBOptions_Create(timeout, noGrowSync, readOnly, mmapFlags, initialMmapSize);
|
protonail/bolt-jna
|
bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltTransactionStats.java
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/TransactionStats.java
// public class TransactionStats extends Structure {
// public static class ByValue extends TransactionStats implements Structure.ByValue {}
//
// public int pageCount;
// public int pageAlloc;
//
// public int cursorCount;
//
// public int nodeCount;
// public int nodeDeref;
//
// public int rebalance;
// public long rebalanceTime;
//
// public int split;
// public int spill;
// public long spillTime;
//
// public int write;
// public long writeTime;
//
// @Override
// protected List<String> getFieldOrder() {
// return Arrays.asList(
// "pageCount",
// "pageAlloc",
// "cursorCount",
// "nodeCount",
// "nodeDeref",
// "rebalance",
// "rebalanceTime",
// "split",
// "spill",
// "spillTime",
// "write",
// "writeTime");
// }
// }
|
import com.protonail.bolt.jna.impl.TransactionStats;
|
package com.protonail.bolt.jna;
public class BoltTransactionStats {
private int pageCount;
private int pageAlloc;
private int cursorCount;
private int nodeCount;
private int nodeDeref;
private int rebalance;
private long rebalanceTime;
private int split;
private int spill;
private long spillTime;
private int write;
private long writeTime;
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/TransactionStats.java
// public class TransactionStats extends Structure {
// public static class ByValue extends TransactionStats implements Structure.ByValue {}
//
// public int pageCount;
// public int pageAlloc;
//
// public int cursorCount;
//
// public int nodeCount;
// public int nodeDeref;
//
// public int rebalance;
// public long rebalanceTime;
//
// public int split;
// public int spill;
// public long spillTime;
//
// public int write;
// public long writeTime;
//
// @Override
// protected List<String> getFieldOrder() {
// return Arrays.asList(
// "pageCount",
// "pageAlloc",
// "cursorCount",
// "nodeCount",
// "nodeDeref",
// "rebalance",
// "rebalanceTime",
// "split",
// "spill",
// "spillTime",
// "write",
// "writeTime");
// }
// }
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltTransactionStats.java
import com.protonail.bolt.jna.impl.TransactionStats;
package com.protonail.bolt.jna;
public class BoltTransactionStats {
private int pageCount;
private int pageAlloc;
private int cursorCount;
private int nodeCount;
private int nodeDeref;
private int rebalance;
private long rebalanceTime;
private int split;
private int spill;
private long spillTime;
private int write;
private long writeTime;
|
BoltTransactionStats(TransactionStats.ByValue transactionStats) {
|
protonail/bolt-jna
|
bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Error.java
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltException.java
// public class BoltException extends RuntimeException {
// public BoltException(String message) {
// super(message);
// }
// }
|
import com.protonail.bolt.jna.BoltException;
import com.sun.jna.Structure;
import java.util.Collections;
import java.util.List;
|
package com.protonail.bolt.jna.impl;
public class Error extends Structure {
public static class ByValue extends Error implements Structure.ByValue {
public void checkError() {
if (error != null) {
BoltNative.Error_Free(this);
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltException.java
// public class BoltException extends RuntimeException {
// public BoltException(String message) {
// super(message);
// }
// }
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Error.java
import com.protonail.bolt.jna.BoltException;
import com.sun.jna.Structure;
import java.util.Collections;
import java.util.List;
package com.protonail.bolt.jna.impl;
public class Error extends Structure {
public static class ByValue extends Error implements Structure.ByValue {
public void checkError() {
if (error != null) {
BoltNative.Error_Free(this);
|
throw new BoltException(error);
|
protonail/bolt-jna
|
bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Result.java
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltException.java
// public class BoltException extends RuntimeException {
// public BoltException(String message) {
// super(message);
// }
// }
|
import com.protonail.bolt.jna.BoltException;
import com.sun.jna.Structure;
import java.util.Arrays;
import java.util.List;
|
package com.protonail.bolt.jna.impl;
public class Result extends Structure {
public static class ByValue extends Result implements Structure.ByValue {
public void checkError() {
if (error != null) {
BoltNative.Result_Free(this);
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltException.java
// public class BoltException extends RuntimeException {
// public BoltException(String message) {
// super(message);
// }
// }
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Result.java
import com.protonail.bolt.jna.BoltException;
import com.sun.jna.Structure;
import java.util.Arrays;
import java.util.List;
package com.protonail.bolt.jna.impl;
public class Result extends Structure {
public static class ByValue extends Result implements Structure.ByValue {
public void checkError() {
if (error != null) {
BoltNative.Result_Free(this);
|
throw new BoltException(error);
|
protonail/bolt-jna
|
bolt-jna-core/src/main/java/com/protonail/bolt/jna/Bolt.java
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/BoltNative.java
// public class BoltNative {
// static {
// Native.register("bolt");
// }
//
// // Common
//
// public static native void DoNothing();
//
// public static native void Free(Pointer pointer);
//
// public static native void Result_Free(Result.ByValue result);
//
// public static native void Error_Free(Error.ByValue error);
//
// public static native void Sequence_Free(Sequence.ByValue error);
//
// // Options
//
// public static native long BoltDBOptions_Create(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize);
//
// public static native void BoltDBOptions_Free(long optionsObjectId);
//
// // BoltDB
//
// public static native Result.ByValue BoltDB_Open(String databaseFileName, int fileMode, long optionsObjectId);
//
// public static native void BoltDB_Close(long boltObjectId);
//
// public static native Result.ByValue BoltDB_Begin(long boltObjectId, boolean writeable);
//
// public static native Stats.ByValue BoltDB_Stats(long boltObjectId);
//
// // Transaction
//
// public static native Error.ByValue BoltDBTransaction_Commit(long transactionObjectId);
//
// public static native Error.ByValue BoltDBTransaction_Rollback(long transactionObjectId);
//
// public static native int BoltDBTransaction_GetId(long transactionObjectId);
//
// public static native long BoltDBTransaction_Size(long transactionObjectId);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucketIfNotExists(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBTransaction_DeleteBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_Bucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBTransaction_Cursor(long transactionObjectId);
//
// public static native TransactionStats.ByValue BoltDBTransaction_Stats(long transactionObjectId);
//
// // Bucket
//
// public static native void BoltDBBucket_Free(long bucketObjectId);
//
// public static native Value.ByValue BoltDBBucket_Get(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Error.ByValue BoltDBBucket_Put(long bucketObjectId, byte[] key, int keyLength, byte[] value, int valueLength);
//
// public static native Error.ByValue BoltDBBucket_Delete(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucketIfNotExists(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBBucket_DeleteBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_Bucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBBucket_Cursor(long bucketObjectId);
//
// public static native Sequence.ByValue BoltDBBucket_NextSequence(long bucketObjectId);
//
// public static native BucketStats.ByValue BoltDBBucket_Stats(long bucketObjectId);
//
// // Cursor
//
// public static native void BoltDBCursor_Free(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_First(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Last(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Next(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Prev(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Seek(long cursorObjectId, byte[] seek, int seekLength);
//
// public static native Error.ByValue BoltDBCursor_Delete(long cursorObjectId);
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Result.java
// public class Result extends Structure {
// public static class ByValue extends Result implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Result_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public long objectId;
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Arrays.asList("objectId", "error");
// }
// }
|
import com.protonail.bolt.jna.impl.BoltNative;
import com.protonail.bolt.jna.impl.Result;
import java.util.EnumSet;
import java.util.function.Consumer;
|
package com.protonail.bolt.jna;
public class Bolt implements AutoCloseable {
private long objectId;
public Bolt(String databaseFileName) {
this(databaseFileName, BoltFileMode.DEFAULT, null);
}
public Bolt(String databaseFileName, EnumSet<BoltFileMode> fileMode) {
this(databaseFileName, fileMode, null);
}
public Bolt(String databaseFileName, EnumSet<BoltFileMode> fileMode, BoltOptions options) {
long optionsObjectId = options != null ? options.objectId : 0;
|
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/BoltNative.java
// public class BoltNative {
// static {
// Native.register("bolt");
// }
//
// // Common
//
// public static native void DoNothing();
//
// public static native void Free(Pointer pointer);
//
// public static native void Result_Free(Result.ByValue result);
//
// public static native void Error_Free(Error.ByValue error);
//
// public static native void Sequence_Free(Sequence.ByValue error);
//
// // Options
//
// public static native long BoltDBOptions_Create(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize);
//
// public static native void BoltDBOptions_Free(long optionsObjectId);
//
// // BoltDB
//
// public static native Result.ByValue BoltDB_Open(String databaseFileName, int fileMode, long optionsObjectId);
//
// public static native void BoltDB_Close(long boltObjectId);
//
// public static native Result.ByValue BoltDB_Begin(long boltObjectId, boolean writeable);
//
// public static native Stats.ByValue BoltDB_Stats(long boltObjectId);
//
// // Transaction
//
// public static native Error.ByValue BoltDBTransaction_Commit(long transactionObjectId);
//
// public static native Error.ByValue BoltDBTransaction_Rollback(long transactionObjectId);
//
// public static native int BoltDBTransaction_GetId(long transactionObjectId);
//
// public static native long BoltDBTransaction_Size(long transactionObjectId);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_CreateBucketIfNotExists(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBTransaction_DeleteBucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBTransaction_Bucket(long transactionObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBTransaction_Cursor(long transactionObjectId);
//
// public static native TransactionStats.ByValue BoltDBTransaction_Stats(long transactionObjectId);
//
// // Bucket
//
// public static native void BoltDBBucket_Free(long bucketObjectId);
//
// public static native Value.ByValue BoltDBBucket_Get(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Error.ByValue BoltDBBucket_Put(long bucketObjectId, byte[] key, int keyLength, byte[] value, int valueLength);
//
// public static native Error.ByValue BoltDBBucket_Delete(long bucketObjectId, byte[] key, int keyLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_CreateBucketIfNotExists(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Error.ByValue BoltDBBucket_DeleteBucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native Result.ByValue BoltDBBucket_Bucket(long bucketObjectId, byte[] name, int nameLength);
//
// public static native long BoltDBBucket_Cursor(long bucketObjectId);
//
// public static native Sequence.ByValue BoltDBBucket_NextSequence(long bucketObjectId);
//
// public static native BucketStats.ByValue BoltDBBucket_Stats(long bucketObjectId);
//
// // Cursor
//
// public static native void BoltDBCursor_Free(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_First(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Last(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Next(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Prev(long cursorObjectId);
//
// public static native KeyValue.ByValue BoltDBCursor_Seek(long cursorObjectId, byte[] seek, int seekLength);
//
// public static native Error.ByValue BoltDBCursor_Delete(long cursorObjectId);
// }
//
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Result.java
// public class Result extends Structure {
// public static class ByValue extends Result implements Structure.ByValue {
// public void checkError() {
// if (error != null) {
// BoltNative.Result_Free(this);
// throw new BoltException(error);
// }
// }
// }
//
// public long objectId;
// public String error;
//
// @Override
// protected List<String> getFieldOrder() {
// return Arrays.asList("objectId", "error");
// }
// }
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/Bolt.java
import com.protonail.bolt.jna.impl.BoltNative;
import com.protonail.bolt.jna.impl.Result;
import java.util.EnumSet;
import java.util.function.Consumer;
package com.protonail.bolt.jna;
public class Bolt implements AutoCloseable {
private long objectId;
public Bolt(String databaseFileName) {
this(databaseFileName, BoltFileMode.DEFAULT, null);
}
public Bolt(String databaseFileName, EnumSet<BoltFileMode> fileMode) {
this(databaseFileName, fileMode, null);
}
public Bolt(String databaseFileName, EnumSet<BoltFileMode> fileMode, BoltOptions options) {
long optionsObjectId = options != null ? options.objectId : 0;
|
Result.ByValue result = BoltNative.BoltDB_Open(databaseFileName, BoltFileMode.toFlag(fileMode), optionsObjectId);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.