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 |
|---|---|---|---|---|---|---|
javasoze/clue | src/main/java/io/dashbase/clue/commands/DocSetInfoCommand.java | // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
| import java.io.PrintStream;
import java.util.Arrays;
import java.util.List;
import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.util.BytesRef; | package io.dashbase.clue.commands;
@Readonly
public class DocSetInfoCommand extends ClueCommand {
private static final int DEFAULT_BUCKET_SIZE = 1000;
| // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
// Path: src/main/java/io/dashbase/clue/commands/DocSetInfoCommand.java
import java.io.PrintStream;
import java.util.Arrays;
import java.util.List;
import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.util.BytesRef;
package io.dashbase.clue.commands;
@Readonly
public class DocSetInfoCommand extends ClueCommand {
private static final int DEFAULT_BUCKET_SIZE = 1000;
| private final LuceneContext ctx; |
javasoze/clue | src/main/java/io/dashbase/clue/client/CmdlineHelper.java | // Path: src/main/java/io/dashbase/clue/api/QueryBuilder.java
// @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = DefaultQueryBuilder.class)
// @JsonSubTypes({
// @JsonSubTypes.Type(name = "default", value = DefaultQueryBuilder.class)
// })
// public interface QueryBuilder {
// void initialize(String defaultField, Analyzer analyzer) throws Exception;
// Query build(String rawQuery) throws Exception;
// }
| import io.dashbase.clue.api.QueryBuilder;
import jline.console.ConsoleReader;
import jline.console.completer.ArgumentCompleter;
import jline.console.completer.Completer;
import jline.console.completer.FileNameCompleter;
import jline.console.completer.StringsCompleter;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Supplier; | Collection<String> commands = commandNameSupplier != null
? commandNameSupplier.get() : Collections.emptyList();
Collection<String> fields = fieldNameSupplier != null
? fieldNameSupplier.get() : Collections.emptyList();
LinkedList<Completer> completors = new LinkedList<Completer>();
completors.add(new StringsCompleter(commands));
completors.add(new StringsCompleter(fields));
completors.add(new FileNameCompleter());
consoleReader.addCompleter(new ArgumentCompleter(completors));
}
public String readCommand() {
try {
return consoleReader.readLine("> ");
} catch (IOException e) {
System.err.println("Error! Clue is unable to read line from stdin: " + e.getMessage());
throw new IllegalStateException("Unable to read command line!", e);
}
}
public static String toString(List<String> list) {
StringBuilder buf = new StringBuilder();
for (String s : list) {
buf.append(s).append(" ");
}
return buf.toString().trim();
}
| // Path: src/main/java/io/dashbase/clue/api/QueryBuilder.java
// @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = DefaultQueryBuilder.class)
// @JsonSubTypes({
// @JsonSubTypes.Type(name = "default", value = DefaultQueryBuilder.class)
// })
// public interface QueryBuilder {
// void initialize(String defaultField, Analyzer analyzer) throws Exception;
// Query build(String rawQuery) throws Exception;
// }
// Path: src/main/java/io/dashbase/clue/client/CmdlineHelper.java
import io.dashbase.clue.api.QueryBuilder;
import jline.console.ConsoleReader;
import jline.console.completer.ArgumentCompleter;
import jline.console.completer.Completer;
import jline.console.completer.FileNameCompleter;
import jline.console.completer.StringsCompleter;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Supplier;
Collection<String> commands = commandNameSupplier != null
? commandNameSupplier.get() : Collections.emptyList();
Collection<String> fields = fieldNameSupplier != null
? fieldNameSupplier.get() : Collections.emptyList();
LinkedList<Completer> completors = new LinkedList<Completer>();
completors.add(new StringsCompleter(commands));
completors.add(new StringsCompleter(fields));
completors.add(new FileNameCompleter());
consoleReader.addCompleter(new ArgumentCompleter(completors));
}
public String readCommand() {
try {
return consoleReader.readLine("> ");
} catch (IOException e) {
System.err.println("Error! Clue is unable to read line from stdin: " + e.getMessage());
throw new IllegalStateException("Unable to read command line!", e);
}
}
public static String toString(List<String> list) {
StringBuilder buf = new StringBuilder();
for (String s : list) {
buf.append(s).append(" ");
}
return buf.toString().trim();
}
| public static Query toQuery(List<String> list, QueryBuilder queryBuilder) throws Exception { |
javasoze/clue | src/main/java/io/dashbase/clue/commands/TermsCommand.java | // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
//
// Path: src/main/java/io/dashbase/clue/api/BytesRefPrinter.java
// public interface BytesRefPrinter {
// String print(BytesRef bytesRef);
//
// public static BytesRefPrinter UTFPrinter = new BytesRefPrinter() {
//
// @Override
// public String print(BytesRef bytesRef) {
// return bytesRef.utf8ToString();
// }
//
// };
//
// public static BytesRefPrinter RawBytesPrinter = new BytesRefPrinter() {
//
// @Override
// public String print(BytesRef bytesRef) {
// return bytesRef.toString();
// }
//
// };
// }
| import java.io.PrintStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicInteger;
import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
import io.dashbase.clue.api.BytesRefPrinter;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.util.BytesRef; | package io.dashbase.clue.commands;
@Readonly
public class TermsCommand extends ClueCommand {
| // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
//
// Path: src/main/java/io/dashbase/clue/api/BytesRefPrinter.java
// public interface BytesRefPrinter {
// String print(BytesRef bytesRef);
//
// public static BytesRefPrinter UTFPrinter = new BytesRefPrinter() {
//
// @Override
// public String print(BytesRef bytesRef) {
// return bytesRef.utf8ToString();
// }
//
// };
//
// public static BytesRefPrinter RawBytesPrinter = new BytesRefPrinter() {
//
// @Override
// public String print(BytesRef bytesRef) {
// return bytesRef.toString();
// }
//
// };
// }
// Path: src/main/java/io/dashbase/clue/commands/TermsCommand.java
import java.io.PrintStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicInteger;
import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
import io.dashbase.clue.api.BytesRefPrinter;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.util.BytesRef;
package io.dashbase.clue.commands;
@Readonly
public class TermsCommand extends ClueCommand {
| private final LuceneContext ctx; |
javasoze/clue | src/main/java/io/dashbase/clue/commands/TermVectorCommand.java | // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
| import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.*;
import org.apache.lucene.util.BytesRef;
import java.io.PrintStream;
import java.util.List; | package io.dashbase.clue.commands;
@Readonly
public class TermVectorCommand extends ClueCommand {
| // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
// Path: src/main/java/io/dashbase/clue/commands/TermVectorCommand.java
import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.*;
import org.apache.lucene.util.BytesRef;
import java.io.PrintStream;
import java.util.List;
package io.dashbase.clue.commands;
@Readonly
public class TermVectorCommand extends ClueCommand {
| private final LuceneContext ctx; |
javasoze/clue | src/main/java/io/dashbase/clue/commands/CommandRegistrar.java | // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
| import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import io.dashbase.clue.ClueContext; | package io.dashbase.clue.commands;
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = DefaultCommandRegistrar.class)
@JsonSubTypes({
@JsonSubTypes.Type(name = "default", value = DefaultCommandRegistrar.class)
})
public interface CommandRegistrar { | // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
// Path: src/main/java/io/dashbase/clue/commands/CommandRegistrar.java
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import io.dashbase.clue.ClueContext;
package io.dashbase.clue.commands;
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = DefaultCommandRegistrar.class)
@JsonSubTypes({
@JsonSubTypes.Type(name = "default", value = DefaultCommandRegistrar.class)
})
public interface CommandRegistrar { | void registerCommands(ClueContext ctx); |
javasoze/clue | src/main/java/io/dashbase/clue/commands/DefaultCommandRegistrar.java | // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
| import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext; | package io.dashbase.clue.commands;
public class DefaultCommandRegistrar implements CommandRegistrar {
@Override | // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
// Path: src/main/java/io/dashbase/clue/commands/DefaultCommandRegistrar.java
import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
package io.dashbase.clue.commands;
public class DefaultCommandRegistrar implements CommandRegistrar {
@Override | public void registerCommands(ClueContext clueCtx) { |
javasoze/clue | src/main/java/io/dashbase/clue/commands/DefaultCommandRegistrar.java | // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
| import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext; | package io.dashbase.clue.commands;
public class DefaultCommandRegistrar implements CommandRegistrar {
@Override
public void registerCommands(ClueContext clueCtx) { | // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
// Path: src/main/java/io/dashbase/clue/commands/DefaultCommandRegistrar.java
import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
package io.dashbase.clue.commands;
public class DefaultCommandRegistrar implements CommandRegistrar {
@Override
public void registerCommands(ClueContext clueCtx) { | LuceneContext ctx = (LuceneContext)clueCtx; |
javasoze/clue | src/main/java/io/dashbase/clue/commands/ExportCommand.java | // Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
//
// Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
| import java.io.PrintStream;
import java.nio.file.FileSystems;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.codecs.simpletext.SimpleTextCodec;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.store.FSDirectory;
import io.dashbase.clue.ClueContext; | package io.dashbase.clue.commands;
@Readonly
public class ExportCommand extends ClueCommand {
| // Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
//
// Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
// Path: src/main/java/io/dashbase/clue/commands/ExportCommand.java
import java.io.PrintStream;
import java.nio.file.FileSystems;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.codecs.simpletext.SimpleTextCodec;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.store.FSDirectory;
import io.dashbase.clue.ClueContext;
package io.dashbase.clue.commands;
@Readonly
public class ExportCommand extends ClueCommand {
| private final LuceneContext ctx; |
javasoze/clue | src/main/java/io/dashbase/clue/commands/StoredFieldCommand.java | // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
| import java.io.PrintStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.util.BytesRef; | package io.dashbase.clue.commands;
@Readonly
public class StoredFieldCommand extends ClueCommand {
| // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
// Path: src/main/java/io/dashbase/clue/commands/StoredFieldCommand.java
import java.io.PrintStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.util.BytesRef;
package io.dashbase.clue.commands;
@Readonly
public class StoredFieldCommand extends ClueCommand {
| private final LuceneContext ctx; |
javasoze/clue | src/main/java/io/dashbase/clue/commands/ReadonlyCommand.java | // Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
| import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import java.io.PrintStream; | package io.dashbase.clue.commands;
@Readonly
public class ReadonlyCommand extends ClueCommand {
| // Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
// Path: src/main/java/io/dashbase/clue/commands/ReadonlyCommand.java
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import java.io.PrintStream;
package io.dashbase.clue.commands;
@Readonly
public class ReadonlyCommand extends ClueCommand {
| private final LuceneContext ctx; |
javasoze/clue | src/main/java/io/dashbase/clue/commands/ReconstructCommand.java | // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
| import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import java.util.TreeMap;
import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef; | package io.dashbase.clue.commands;
@Readonly
public class ReconstructCommand extends ClueCommand {
| // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
// Path: src/main/java/io/dashbase/clue/commands/ReconstructCommand.java
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import java.util.TreeMap;
import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
package io.dashbase.clue.commands;
@Readonly
public class ReconstructCommand extends ClueCommand {
| private final LuceneContext ctx; |
javasoze/clue | src/main/java/io/dashbase/clue/commands/DirectoryCommand.java | // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
| import java.io.PrintStream;
import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.Namespace; | package io.dashbase.clue.commands;
@Readonly
public class DirectoryCommand extends ClueCommand {
| // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
// Path: src/main/java/io/dashbase/clue/commands/DirectoryCommand.java
import java.io.PrintStream;
import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.Namespace;
package io.dashbase.clue.commands;
@Readonly
public class DirectoryCommand extends ClueCommand {
| private final LuceneContext ctx; |
javasoze/clue | src/main/java/io/dashbase/clue/commands/ExplainCommand.java | // Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
//
// Path: src/main/java/io/dashbase/clue/client/CmdlineHelper.java
// public class CmdlineHelper {
// private final ConsoleReader consoleReader;
//
// public CmdlineHelper(Supplier<Collection<String>> commandNameSupplier,
// Supplier<Collection<String>> fieldNameSupplier) throws IOException {
// consoleReader = new ConsoleReader();
// consoleReader.setBellEnabled(false);
//
// Collection<String> commands = commandNameSupplier != null
// ? commandNameSupplier.get() : Collections.emptyList();
//
// Collection<String> fields = fieldNameSupplier != null
// ? fieldNameSupplier.get() : Collections.emptyList();
//
// LinkedList<Completer> completors = new LinkedList<Completer>();
// completors.add(new StringsCompleter(commands));
// completors.add(new StringsCompleter(fields));
// completors.add(new FileNameCompleter());
// consoleReader.addCompleter(new ArgumentCompleter(completors));
// }
//
// public String readCommand() {
// try {
// return consoleReader.readLine("> ");
// } catch (IOException e) {
// System.err.println("Error! Clue is unable to read line from stdin: " + e.getMessage());
// throw new IllegalStateException("Unable to read command line!", e);
// }
// }
//
// public static String toString(List<String> list) {
// StringBuilder buf = new StringBuilder();
// for (String s : list) {
// buf.append(s).append(" ");
// }
// return buf.toString().trim();
// }
//
// public static Query toQuery(List<String> list, QueryBuilder queryBuilder) throws Exception {
// String qstring = toString(list);
// Query q = null;
// if (qstring == null || qstring.isEmpty() || qstring.equals("*")){
// q = new MatchAllDocsQuery();
// }
// else{
// q = queryBuilder.build(qstring);
// }
// return q;
// }
// }
| import io.dashbase.clue.LuceneContext;
import io.dashbase.clue.client.CmdlineHelper;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import java.io.PrintStream;
import java.util.List; | package io.dashbase.clue.commands;
@Readonly
public class ExplainCommand extends ClueCommand {
| // Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
//
// Path: src/main/java/io/dashbase/clue/client/CmdlineHelper.java
// public class CmdlineHelper {
// private final ConsoleReader consoleReader;
//
// public CmdlineHelper(Supplier<Collection<String>> commandNameSupplier,
// Supplier<Collection<String>> fieldNameSupplier) throws IOException {
// consoleReader = new ConsoleReader();
// consoleReader.setBellEnabled(false);
//
// Collection<String> commands = commandNameSupplier != null
// ? commandNameSupplier.get() : Collections.emptyList();
//
// Collection<String> fields = fieldNameSupplier != null
// ? fieldNameSupplier.get() : Collections.emptyList();
//
// LinkedList<Completer> completors = new LinkedList<Completer>();
// completors.add(new StringsCompleter(commands));
// completors.add(new StringsCompleter(fields));
// completors.add(new FileNameCompleter());
// consoleReader.addCompleter(new ArgumentCompleter(completors));
// }
//
// public String readCommand() {
// try {
// return consoleReader.readLine("> ");
// } catch (IOException e) {
// System.err.println("Error! Clue is unable to read line from stdin: " + e.getMessage());
// throw new IllegalStateException("Unable to read command line!", e);
// }
// }
//
// public static String toString(List<String> list) {
// StringBuilder buf = new StringBuilder();
// for (String s : list) {
// buf.append(s).append(" ");
// }
// return buf.toString().trim();
// }
//
// public static Query toQuery(List<String> list, QueryBuilder queryBuilder) throws Exception {
// String qstring = toString(list);
// Query q = null;
// if (qstring == null || qstring.isEmpty() || qstring.equals("*")){
// q = new MatchAllDocsQuery();
// }
// else{
// q = queryBuilder.build(qstring);
// }
// return q;
// }
// }
// Path: src/main/java/io/dashbase/clue/commands/ExplainCommand.java
import io.dashbase.clue.LuceneContext;
import io.dashbase.clue.client.CmdlineHelper;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import java.io.PrintStream;
import java.util.List;
package io.dashbase.clue.commands;
@Readonly
public class ExplainCommand extends ClueCommand {
| private final LuceneContext ctx; |
javasoze/clue | src/main/java/io/dashbase/clue/commands/GetUserCommitDataCommand.java | // Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
//
// Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
| import java.io.PrintStream;
import java.util.Map;
import java.util.Map.Entry;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import io.dashbase.clue.ClueContext; | package io.dashbase.clue.commands;
@Readonly
public class GetUserCommitDataCommand extends ClueCommand {
| // Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
//
// Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
// Path: src/main/java/io/dashbase/clue/commands/GetUserCommitDataCommand.java
import java.io.PrintStream;
import java.util.Map;
import java.util.Map.Entry;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import io.dashbase.clue.ClueContext;
package io.dashbase.clue.commands;
@Readonly
public class GetUserCommitDataCommand extends ClueCommand {
| private final LuceneContext ctx; |
javasoze/clue | src/main/java/io/dashbase/clue/commands/InfoCommand.java | // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
| import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.*;
import java.io.IOException;
import java.io.PrintStream;
import java.util.*; | package io.dashbase.clue.commands;
@Readonly
public class InfoCommand extends ClueCommand {
| // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
// Path: src/main/java/io/dashbase/clue/commands/InfoCommand.java
import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.*;
import java.io.IOException;
import java.io.PrintStream;
import java.util.*;
package io.dashbase.clue.commands;
@Readonly
public class InfoCommand extends ClueCommand {
| private final LuceneContext ctx; |
javasoze/clue | src/main/java/io/dashbase/clue/commands/DumpDocCommand.java | // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
| import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.util.BytesRef;
import java.io.PrintStream;
import java.util.List; | package io.dashbase.clue.commands;
@Readonly
public class DumpDocCommand extends ClueCommand {
| // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
// Path: src/main/java/io/dashbase/clue/commands/DumpDocCommand.java
import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.util.BytesRef;
import java.io.PrintStream;
import java.util.List;
package io.dashbase.clue.commands;
@Readonly
public class DumpDocCommand extends ClueCommand {
| private final LuceneContext ctx; |
javasoze/clue | src/main/java/io/dashbase/clue/server/ClueWebApplication.java | // Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
| import io.dashbase.clue.LuceneContext;
import io.dropwizard.Application;
import io.dropwizard.lifecycle.Managed;
import io.dropwizard.setup.Environment; | package io.dashbase.clue.server;
public class ClueWebApplication extends Application<ClueWebConfiguration> {
public static void main(String[] args) throws Exception {
new ClueWebApplication().run(args);
}
@Override
public void run(ClueWebConfiguration conf, Environment environment) throws Exception { | // Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
// Path: src/main/java/io/dashbase/clue/server/ClueWebApplication.java
import io.dashbase.clue.LuceneContext;
import io.dropwizard.Application;
import io.dropwizard.lifecycle.Managed;
import io.dropwizard.setup.Environment;
package io.dashbase.clue.server;
public class ClueWebApplication extends Application<ClueWebConfiguration> {
public static void main(String[] args) throws Exception {
new ClueWebApplication().run(args);
}
@Override
public void run(ClueWebConfiguration conf, Environment environment) throws Exception { | final LuceneContext ctx = new LuceneContext(conf.dir, conf.clue, true); |
javasoze/clue | src/main/java/io/dashbase/clue/commands/CountCommand.java | // Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
//
// Path: src/main/java/io/dashbase/clue/client/CmdlineHelper.java
// public class CmdlineHelper {
// private final ConsoleReader consoleReader;
//
// public CmdlineHelper(Supplier<Collection<String>> commandNameSupplier,
// Supplier<Collection<String>> fieldNameSupplier) throws IOException {
// consoleReader = new ConsoleReader();
// consoleReader.setBellEnabled(false);
//
// Collection<String> commands = commandNameSupplier != null
// ? commandNameSupplier.get() : Collections.emptyList();
//
// Collection<String> fields = fieldNameSupplier != null
// ? fieldNameSupplier.get() : Collections.emptyList();
//
// LinkedList<Completer> completors = new LinkedList<Completer>();
// completors.add(new StringsCompleter(commands));
// completors.add(new StringsCompleter(fields));
// completors.add(new FileNameCompleter());
// consoleReader.addCompleter(new ArgumentCompleter(completors));
// }
//
// public String readCommand() {
// try {
// return consoleReader.readLine("> ");
// } catch (IOException e) {
// System.err.println("Error! Clue is unable to read line from stdin: " + e.getMessage());
// throw new IllegalStateException("Unable to read command line!", e);
// }
// }
//
// public static String toString(List<String> list) {
// StringBuilder buf = new StringBuilder();
// for (String s : list) {
// buf.append(s).append(" ");
// }
// return buf.toString().trim();
// }
//
// public static Query toQuery(List<String> list, QueryBuilder queryBuilder) throws Exception {
// String qstring = toString(list);
// Query q = null;
// if (qstring == null || qstring.isEmpty() || qstring.equals("*")){
// q = new MatchAllDocsQuery();
// }
// else{
// q = queryBuilder.build(qstring);
// }
// return q;
// }
// }
| import java.io.PrintStream;
import java.util.List;
import io.dashbase.clue.LuceneContext;
import io.dashbase.clue.client.CmdlineHelper;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query; | package io.dashbase.clue.commands;
@Readonly
public class CountCommand extends ClueCommand {
| // Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
//
// Path: src/main/java/io/dashbase/clue/client/CmdlineHelper.java
// public class CmdlineHelper {
// private final ConsoleReader consoleReader;
//
// public CmdlineHelper(Supplier<Collection<String>> commandNameSupplier,
// Supplier<Collection<String>> fieldNameSupplier) throws IOException {
// consoleReader = new ConsoleReader();
// consoleReader.setBellEnabled(false);
//
// Collection<String> commands = commandNameSupplier != null
// ? commandNameSupplier.get() : Collections.emptyList();
//
// Collection<String> fields = fieldNameSupplier != null
// ? fieldNameSupplier.get() : Collections.emptyList();
//
// LinkedList<Completer> completors = new LinkedList<Completer>();
// completors.add(new StringsCompleter(commands));
// completors.add(new StringsCompleter(fields));
// completors.add(new FileNameCompleter());
// consoleReader.addCompleter(new ArgumentCompleter(completors));
// }
//
// public String readCommand() {
// try {
// return consoleReader.readLine("> ");
// } catch (IOException e) {
// System.err.println("Error! Clue is unable to read line from stdin: " + e.getMessage());
// throw new IllegalStateException("Unable to read command line!", e);
// }
// }
//
// public static String toString(List<String> list) {
// StringBuilder buf = new StringBuilder();
// for (String s : list) {
// buf.append(s).append(" ");
// }
// return buf.toString().trim();
// }
//
// public static Query toQuery(List<String> list, QueryBuilder queryBuilder) throws Exception {
// String qstring = toString(list);
// Query q = null;
// if (qstring == null || qstring.isEmpty() || qstring.equals("*")){
// q = new MatchAllDocsQuery();
// }
// else{
// q = queryBuilder.build(qstring);
// }
// return q;
// }
// }
// Path: src/main/java/io/dashbase/clue/commands/CountCommand.java
import java.io.PrintStream;
import java.util.List;
import io.dashbase.clue.LuceneContext;
import io.dashbase.clue.client.CmdlineHelper;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
package io.dashbase.clue.commands;
@Readonly
public class CountCommand extends ClueCommand {
| private final LuceneContext ctx; |
javasoze/clue | src/main/java/io/dashbase/clue/commands/CountCommand.java | // Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
//
// Path: src/main/java/io/dashbase/clue/client/CmdlineHelper.java
// public class CmdlineHelper {
// private final ConsoleReader consoleReader;
//
// public CmdlineHelper(Supplier<Collection<String>> commandNameSupplier,
// Supplier<Collection<String>> fieldNameSupplier) throws IOException {
// consoleReader = new ConsoleReader();
// consoleReader.setBellEnabled(false);
//
// Collection<String> commands = commandNameSupplier != null
// ? commandNameSupplier.get() : Collections.emptyList();
//
// Collection<String> fields = fieldNameSupplier != null
// ? fieldNameSupplier.get() : Collections.emptyList();
//
// LinkedList<Completer> completors = new LinkedList<Completer>();
// completors.add(new StringsCompleter(commands));
// completors.add(new StringsCompleter(fields));
// completors.add(new FileNameCompleter());
// consoleReader.addCompleter(new ArgumentCompleter(completors));
// }
//
// public String readCommand() {
// try {
// return consoleReader.readLine("> ");
// } catch (IOException e) {
// System.err.println("Error! Clue is unable to read line from stdin: " + e.getMessage());
// throw new IllegalStateException("Unable to read command line!", e);
// }
// }
//
// public static String toString(List<String> list) {
// StringBuilder buf = new StringBuilder();
// for (String s : list) {
// buf.append(s).append(" ");
// }
// return buf.toString().trim();
// }
//
// public static Query toQuery(List<String> list, QueryBuilder queryBuilder) throws Exception {
// String qstring = toString(list);
// Query q = null;
// if (qstring == null || qstring.isEmpty() || qstring.equals("*")){
// q = new MatchAllDocsQuery();
// }
// else{
// q = queryBuilder.build(qstring);
// }
// return q;
// }
// }
| import java.io.PrintStream;
import java.util.List;
import io.dashbase.clue.LuceneContext;
import io.dashbase.clue.client.CmdlineHelper;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query; | package io.dashbase.clue.commands;
@Readonly
public class CountCommand extends ClueCommand {
private final LuceneContext ctx;
public CountCommand(LuceneContext ctx) {
super(ctx);
this.ctx = ctx;
}
@Override
public String getName() {
return "count";
}
@Override
public String help() {
return "shows how many documents in index match the given query";
}
@Override
protected ArgumentParser buildParser(ArgumentParser parser) {
parser.addArgument("-q", "--query").nargs("*").setDefault(new String[]{"*"});
return parser;
}
@Override
public void execute(Namespace args, PrintStream out) throws Exception {
IndexSearcher searcher = ctx.getIndexSearcher();
List<String> qlist = args.getList("query");
Query q;
try{ | // Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
//
// Path: src/main/java/io/dashbase/clue/client/CmdlineHelper.java
// public class CmdlineHelper {
// private final ConsoleReader consoleReader;
//
// public CmdlineHelper(Supplier<Collection<String>> commandNameSupplier,
// Supplier<Collection<String>> fieldNameSupplier) throws IOException {
// consoleReader = new ConsoleReader();
// consoleReader.setBellEnabled(false);
//
// Collection<String> commands = commandNameSupplier != null
// ? commandNameSupplier.get() : Collections.emptyList();
//
// Collection<String> fields = fieldNameSupplier != null
// ? fieldNameSupplier.get() : Collections.emptyList();
//
// LinkedList<Completer> completors = new LinkedList<Completer>();
// completors.add(new StringsCompleter(commands));
// completors.add(new StringsCompleter(fields));
// completors.add(new FileNameCompleter());
// consoleReader.addCompleter(new ArgumentCompleter(completors));
// }
//
// public String readCommand() {
// try {
// return consoleReader.readLine("> ");
// } catch (IOException e) {
// System.err.println("Error! Clue is unable to read line from stdin: " + e.getMessage());
// throw new IllegalStateException("Unable to read command line!", e);
// }
// }
//
// public static String toString(List<String> list) {
// StringBuilder buf = new StringBuilder();
// for (String s : list) {
// buf.append(s).append(" ");
// }
// return buf.toString().trim();
// }
//
// public static Query toQuery(List<String> list, QueryBuilder queryBuilder) throws Exception {
// String qstring = toString(list);
// Query q = null;
// if (qstring == null || qstring.isEmpty() || qstring.equals("*")){
// q = new MatchAllDocsQuery();
// }
// else{
// q = queryBuilder.build(qstring);
// }
// return q;
// }
// }
// Path: src/main/java/io/dashbase/clue/commands/CountCommand.java
import java.io.PrintStream;
import java.util.List;
import io.dashbase.clue.LuceneContext;
import io.dashbase.clue.client.CmdlineHelper;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
package io.dashbase.clue.commands;
@Readonly
public class CountCommand extends ClueCommand {
private final LuceneContext ctx;
public CountCommand(LuceneContext ctx) {
super(ctx);
this.ctx = ctx;
}
@Override
public String getName() {
return "count";
}
@Override
public String help() {
return "shows how many documents in index match the given query";
}
@Override
protected ArgumentParser buildParser(ArgumentParser parser) {
parser.addArgument("-q", "--query").nargs("*").setDefault(new String[]{"*"});
return parser;
}
@Override
public void execute(Namespace args, PrintStream out) throws Exception {
IndexSearcher searcher = ctx.getIndexSearcher();
List<String> qlist = args.getList("query");
Query q;
try{ | q = CmdlineHelper.toQuery(qlist, ctx.getQueryBuilder()); |
javasoze/clue | src/main/java/io/dashbase/clue/ClueApplication.java | // Path: src/main/java/io/dashbase/clue/client/CmdlineHelper.java
// public class CmdlineHelper {
// private final ConsoleReader consoleReader;
//
// public CmdlineHelper(Supplier<Collection<String>> commandNameSupplier,
// Supplier<Collection<String>> fieldNameSupplier) throws IOException {
// consoleReader = new ConsoleReader();
// consoleReader.setBellEnabled(false);
//
// Collection<String> commands = commandNameSupplier != null
// ? commandNameSupplier.get() : Collections.emptyList();
//
// Collection<String> fields = fieldNameSupplier != null
// ? fieldNameSupplier.get() : Collections.emptyList();
//
// LinkedList<Completer> completors = new LinkedList<Completer>();
// completors.add(new StringsCompleter(commands));
// completors.add(new StringsCompleter(fields));
// completors.add(new FileNameCompleter());
// consoleReader.addCompleter(new ArgumentCompleter(completors));
// }
//
// public String readCommand() {
// try {
// return consoleReader.readLine("> ");
// } catch (IOException e) {
// System.err.println("Error! Clue is unable to read line from stdin: " + e.getMessage());
// throw new IllegalStateException("Unable to read command line!", e);
// }
// }
//
// public static String toString(List<String> list) {
// StringBuilder buf = new StringBuilder();
// for (String s : list) {
// buf.append(s).append(" ");
// }
// return buf.toString().trim();
// }
//
// public static Query toQuery(List<String> list, QueryBuilder queryBuilder) throws Exception {
// String qstring = toString(list);
// Query q = null;
// if (qstring == null || qstring.isEmpty() || qstring.equals("*")){
// q = new MatchAllDocsQuery();
// }
// else{
// q = queryBuilder.build(qstring);
// }
// return q;
// }
// }
//
// Path: src/main/java/io/dashbase/clue/commands/ClueCommand.java
// public abstract class ClueCommand {
//
// protected ClueContext ctx;
// private ArgumentParser parser;
//
// public ClueCommand(ClueContext ctx){
// this(ctx, false);
// }
//
// public ClueCommand(ClueContext ctx, boolean skipRegistration){
// this.ctx = ctx;
// if (!skipRegistration) {
// this.ctx.registerCommand(this);
// }
// }
//
// public final Namespace parseArgs(String[] args) throws ArgumentParserException {
// if (parser == null) {
// this.parser = buildParser(ArgumentParsers.newFor(getName())
// .build().defaultHelp(true).description(help()));
// if (parser == null) {
// return null;
// }
// }
// return parser.parseArgs(args);
// }
//
// public ClueContext getContext(){
// return ctx;
// }
//
// protected ArgumentParser buildParser(ArgumentParser parser) {
// return null;
// }
//
// public abstract String getName();
// public abstract String help();
// public abstract void execute(Namespace args, PrintStream out) throws Exception;
// }
//
// Path: src/main/java/io/dashbase/clue/commands/HelpCommand.java
// @Readonly
// public class HelpCommand extends ClueCommand {
//
// public static final String CMD_NAME = "help";
// public HelpCommand(ClueContext ctx) {
// super(ctx);
// }
//
// @Override
// public String getName() {
// return CMD_NAME;
// }
//
// @Override
// public String help() {
// return "displays help";
// }
//
// @Override
// public void execute(Namespace args, PrintStream out) {
// Collection<ClueCommand> commands = ctx.getCommandRegistry().getAvailableCommands();
//
// for (ClueCommand cmd : commands){
// out.println(cmd.getName()+" - " + cmd.help());
// }
// out.flush();
// }
//
// }
| import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.net.URI;
import java.util.Collection;
import java.util.Optional;
import java.util.function.Supplier;
import io.dashbase.clue.client.CmdlineHelper;
import net.sourceforge.argparse4j.helper.HelpScreenException;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.store.Directory;
import io.dashbase.clue.commands.ClueCommand;
import io.dashbase.clue.commands.HelpCommand; | package io.dashbase.clue;
public class ClueApplication {
private final LuceneContext ctx;
private static ClueAppConfiguration config;
| // Path: src/main/java/io/dashbase/clue/client/CmdlineHelper.java
// public class CmdlineHelper {
// private final ConsoleReader consoleReader;
//
// public CmdlineHelper(Supplier<Collection<String>> commandNameSupplier,
// Supplier<Collection<String>> fieldNameSupplier) throws IOException {
// consoleReader = new ConsoleReader();
// consoleReader.setBellEnabled(false);
//
// Collection<String> commands = commandNameSupplier != null
// ? commandNameSupplier.get() : Collections.emptyList();
//
// Collection<String> fields = fieldNameSupplier != null
// ? fieldNameSupplier.get() : Collections.emptyList();
//
// LinkedList<Completer> completors = new LinkedList<Completer>();
// completors.add(new StringsCompleter(commands));
// completors.add(new StringsCompleter(fields));
// completors.add(new FileNameCompleter());
// consoleReader.addCompleter(new ArgumentCompleter(completors));
// }
//
// public String readCommand() {
// try {
// return consoleReader.readLine("> ");
// } catch (IOException e) {
// System.err.println("Error! Clue is unable to read line from stdin: " + e.getMessage());
// throw new IllegalStateException("Unable to read command line!", e);
// }
// }
//
// public static String toString(List<String> list) {
// StringBuilder buf = new StringBuilder();
// for (String s : list) {
// buf.append(s).append(" ");
// }
// return buf.toString().trim();
// }
//
// public static Query toQuery(List<String> list, QueryBuilder queryBuilder) throws Exception {
// String qstring = toString(list);
// Query q = null;
// if (qstring == null || qstring.isEmpty() || qstring.equals("*")){
// q = new MatchAllDocsQuery();
// }
// else{
// q = queryBuilder.build(qstring);
// }
// return q;
// }
// }
//
// Path: src/main/java/io/dashbase/clue/commands/ClueCommand.java
// public abstract class ClueCommand {
//
// protected ClueContext ctx;
// private ArgumentParser parser;
//
// public ClueCommand(ClueContext ctx){
// this(ctx, false);
// }
//
// public ClueCommand(ClueContext ctx, boolean skipRegistration){
// this.ctx = ctx;
// if (!skipRegistration) {
// this.ctx.registerCommand(this);
// }
// }
//
// public final Namespace parseArgs(String[] args) throws ArgumentParserException {
// if (parser == null) {
// this.parser = buildParser(ArgumentParsers.newFor(getName())
// .build().defaultHelp(true).description(help()));
// if (parser == null) {
// return null;
// }
// }
// return parser.parseArgs(args);
// }
//
// public ClueContext getContext(){
// return ctx;
// }
//
// protected ArgumentParser buildParser(ArgumentParser parser) {
// return null;
// }
//
// public abstract String getName();
// public abstract String help();
// public abstract void execute(Namespace args, PrintStream out) throws Exception;
// }
//
// Path: src/main/java/io/dashbase/clue/commands/HelpCommand.java
// @Readonly
// public class HelpCommand extends ClueCommand {
//
// public static final String CMD_NAME = "help";
// public HelpCommand(ClueContext ctx) {
// super(ctx);
// }
//
// @Override
// public String getName() {
// return CMD_NAME;
// }
//
// @Override
// public String help() {
// return "displays help";
// }
//
// @Override
// public void execute(Namespace args, PrintStream out) {
// Collection<ClueCommand> commands = ctx.getCommandRegistry().getAvailableCommands();
//
// for (ClueCommand cmd : commands){
// out.println(cmd.getName()+" - " + cmd.help());
// }
// out.flush();
// }
//
// }
// Path: src/main/java/io/dashbase/clue/ClueApplication.java
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.net.URI;
import java.util.Collection;
import java.util.Optional;
import java.util.function.Supplier;
import io.dashbase.clue.client.CmdlineHelper;
import net.sourceforge.argparse4j.helper.HelpScreenException;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.store.Directory;
import io.dashbase.clue.commands.ClueCommand;
import io.dashbase.clue.commands.HelpCommand;
package io.dashbase.clue;
public class ClueApplication {
private final LuceneContext ctx;
private static ClueAppConfiguration config;
| private CmdlineHelper cmdlineHelper; |
javasoze/clue | src/main/java/io/dashbase/clue/ClueApplication.java | // Path: src/main/java/io/dashbase/clue/client/CmdlineHelper.java
// public class CmdlineHelper {
// private final ConsoleReader consoleReader;
//
// public CmdlineHelper(Supplier<Collection<String>> commandNameSupplier,
// Supplier<Collection<String>> fieldNameSupplier) throws IOException {
// consoleReader = new ConsoleReader();
// consoleReader.setBellEnabled(false);
//
// Collection<String> commands = commandNameSupplier != null
// ? commandNameSupplier.get() : Collections.emptyList();
//
// Collection<String> fields = fieldNameSupplier != null
// ? fieldNameSupplier.get() : Collections.emptyList();
//
// LinkedList<Completer> completors = new LinkedList<Completer>();
// completors.add(new StringsCompleter(commands));
// completors.add(new StringsCompleter(fields));
// completors.add(new FileNameCompleter());
// consoleReader.addCompleter(new ArgumentCompleter(completors));
// }
//
// public String readCommand() {
// try {
// return consoleReader.readLine("> ");
// } catch (IOException e) {
// System.err.println("Error! Clue is unable to read line from stdin: " + e.getMessage());
// throw new IllegalStateException("Unable to read command line!", e);
// }
// }
//
// public static String toString(List<String> list) {
// StringBuilder buf = new StringBuilder();
// for (String s : list) {
// buf.append(s).append(" ");
// }
// return buf.toString().trim();
// }
//
// public static Query toQuery(List<String> list, QueryBuilder queryBuilder) throws Exception {
// String qstring = toString(list);
// Query q = null;
// if (qstring == null || qstring.isEmpty() || qstring.equals("*")){
// q = new MatchAllDocsQuery();
// }
// else{
// q = queryBuilder.build(qstring);
// }
// return q;
// }
// }
//
// Path: src/main/java/io/dashbase/clue/commands/ClueCommand.java
// public abstract class ClueCommand {
//
// protected ClueContext ctx;
// private ArgumentParser parser;
//
// public ClueCommand(ClueContext ctx){
// this(ctx, false);
// }
//
// public ClueCommand(ClueContext ctx, boolean skipRegistration){
// this.ctx = ctx;
// if (!skipRegistration) {
// this.ctx.registerCommand(this);
// }
// }
//
// public final Namespace parseArgs(String[] args) throws ArgumentParserException {
// if (parser == null) {
// this.parser = buildParser(ArgumentParsers.newFor(getName())
// .build().defaultHelp(true).description(help()));
// if (parser == null) {
// return null;
// }
// }
// return parser.parseArgs(args);
// }
//
// public ClueContext getContext(){
// return ctx;
// }
//
// protected ArgumentParser buildParser(ArgumentParser parser) {
// return null;
// }
//
// public abstract String getName();
// public abstract String help();
// public abstract void execute(Namespace args, PrintStream out) throws Exception;
// }
//
// Path: src/main/java/io/dashbase/clue/commands/HelpCommand.java
// @Readonly
// public class HelpCommand extends ClueCommand {
//
// public static final String CMD_NAME = "help";
// public HelpCommand(ClueContext ctx) {
// super(ctx);
// }
//
// @Override
// public String getName() {
// return CMD_NAME;
// }
//
// @Override
// public String help() {
// return "displays help";
// }
//
// @Override
// public void execute(Namespace args, PrintStream out) {
// Collection<ClueCommand> commands = ctx.getCommandRegistry().getAvailableCommands();
//
// for (ClueCommand cmd : commands){
// out.println(cmd.getName()+" - " + cmd.help());
// }
// out.flush();
// }
//
// }
| import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.net.URI;
import java.util.Collection;
import java.util.Optional;
import java.util.function.Supplier;
import io.dashbase.clue.client.CmdlineHelper;
import net.sourceforge.argparse4j.helper.HelpScreenException;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.store.Directory;
import io.dashbase.clue.commands.ClueCommand;
import io.dashbase.clue.commands.HelpCommand; | package io.dashbase.clue;
public class ClueApplication {
private final LuceneContext ctx;
private static ClueAppConfiguration config;
private CmdlineHelper cmdlineHelper;
static {
try {
config = ClueAppConfiguration.load();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public ClueContext getContext() {
return ctx;
}
public ClueAppConfiguration getConfiguration() {
return config;
}
public LuceneContext newContext(String dir, ClueAppConfiguration config, boolean interactiveMode) throws Exception {
return new LuceneContext(dir, config, interactiveMode);
}
public ClueApplication(String idxLocation, boolean interactiveMode) throws Exception{
ctx = newContext(idxLocation, config, interactiveMode);
if (!DirectoryReader.indexExists(ctx.getDirectory())){
System.out.println("lucene index does not exist at: "+idxLocation);
System.exit(1);
}
}
public static void handleCommand(ClueContext ctx, String cmdName, String[] args, PrintStream out){ | // Path: src/main/java/io/dashbase/clue/client/CmdlineHelper.java
// public class CmdlineHelper {
// private final ConsoleReader consoleReader;
//
// public CmdlineHelper(Supplier<Collection<String>> commandNameSupplier,
// Supplier<Collection<String>> fieldNameSupplier) throws IOException {
// consoleReader = new ConsoleReader();
// consoleReader.setBellEnabled(false);
//
// Collection<String> commands = commandNameSupplier != null
// ? commandNameSupplier.get() : Collections.emptyList();
//
// Collection<String> fields = fieldNameSupplier != null
// ? fieldNameSupplier.get() : Collections.emptyList();
//
// LinkedList<Completer> completors = new LinkedList<Completer>();
// completors.add(new StringsCompleter(commands));
// completors.add(new StringsCompleter(fields));
// completors.add(new FileNameCompleter());
// consoleReader.addCompleter(new ArgumentCompleter(completors));
// }
//
// public String readCommand() {
// try {
// return consoleReader.readLine("> ");
// } catch (IOException e) {
// System.err.println("Error! Clue is unable to read line from stdin: " + e.getMessage());
// throw new IllegalStateException("Unable to read command line!", e);
// }
// }
//
// public static String toString(List<String> list) {
// StringBuilder buf = new StringBuilder();
// for (String s : list) {
// buf.append(s).append(" ");
// }
// return buf.toString().trim();
// }
//
// public static Query toQuery(List<String> list, QueryBuilder queryBuilder) throws Exception {
// String qstring = toString(list);
// Query q = null;
// if (qstring == null || qstring.isEmpty() || qstring.equals("*")){
// q = new MatchAllDocsQuery();
// }
// else{
// q = queryBuilder.build(qstring);
// }
// return q;
// }
// }
//
// Path: src/main/java/io/dashbase/clue/commands/ClueCommand.java
// public abstract class ClueCommand {
//
// protected ClueContext ctx;
// private ArgumentParser parser;
//
// public ClueCommand(ClueContext ctx){
// this(ctx, false);
// }
//
// public ClueCommand(ClueContext ctx, boolean skipRegistration){
// this.ctx = ctx;
// if (!skipRegistration) {
// this.ctx.registerCommand(this);
// }
// }
//
// public final Namespace parseArgs(String[] args) throws ArgumentParserException {
// if (parser == null) {
// this.parser = buildParser(ArgumentParsers.newFor(getName())
// .build().defaultHelp(true).description(help()));
// if (parser == null) {
// return null;
// }
// }
// return parser.parseArgs(args);
// }
//
// public ClueContext getContext(){
// return ctx;
// }
//
// protected ArgumentParser buildParser(ArgumentParser parser) {
// return null;
// }
//
// public abstract String getName();
// public abstract String help();
// public abstract void execute(Namespace args, PrintStream out) throws Exception;
// }
//
// Path: src/main/java/io/dashbase/clue/commands/HelpCommand.java
// @Readonly
// public class HelpCommand extends ClueCommand {
//
// public static final String CMD_NAME = "help";
// public HelpCommand(ClueContext ctx) {
// super(ctx);
// }
//
// @Override
// public String getName() {
// return CMD_NAME;
// }
//
// @Override
// public String help() {
// return "displays help";
// }
//
// @Override
// public void execute(Namespace args, PrintStream out) {
// Collection<ClueCommand> commands = ctx.getCommandRegistry().getAvailableCommands();
//
// for (ClueCommand cmd : commands){
// out.println(cmd.getName()+" - " + cmd.help());
// }
// out.flush();
// }
//
// }
// Path: src/main/java/io/dashbase/clue/ClueApplication.java
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.net.URI;
import java.util.Collection;
import java.util.Optional;
import java.util.function.Supplier;
import io.dashbase.clue.client.CmdlineHelper;
import net.sourceforge.argparse4j.helper.HelpScreenException;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.store.Directory;
import io.dashbase.clue.commands.ClueCommand;
import io.dashbase.clue.commands.HelpCommand;
package io.dashbase.clue;
public class ClueApplication {
private final LuceneContext ctx;
private static ClueAppConfiguration config;
private CmdlineHelper cmdlineHelper;
static {
try {
config = ClueAppConfiguration.load();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public ClueContext getContext() {
return ctx;
}
public ClueAppConfiguration getConfiguration() {
return config;
}
public LuceneContext newContext(String dir, ClueAppConfiguration config, boolean interactiveMode) throws Exception {
return new LuceneContext(dir, config, interactiveMode);
}
public ClueApplication(String idxLocation, boolean interactiveMode) throws Exception{
ctx = newContext(idxLocation, config, interactiveMode);
if (!DirectoryReader.indexExists(ctx.getDirectory())){
System.out.println("lucene index does not exist at: "+idxLocation);
System.exit(1);
}
}
public static void handleCommand(ClueContext ctx, String cmdName, String[] args, PrintStream out){ | Optional<ClueCommand> helpCommand = ctx.getCommand(HelpCommand.CMD_NAME); |
javasoze/clue | src/main/java/io/dashbase/clue/ClueApplication.java | // Path: src/main/java/io/dashbase/clue/client/CmdlineHelper.java
// public class CmdlineHelper {
// private final ConsoleReader consoleReader;
//
// public CmdlineHelper(Supplier<Collection<String>> commandNameSupplier,
// Supplier<Collection<String>> fieldNameSupplier) throws IOException {
// consoleReader = new ConsoleReader();
// consoleReader.setBellEnabled(false);
//
// Collection<String> commands = commandNameSupplier != null
// ? commandNameSupplier.get() : Collections.emptyList();
//
// Collection<String> fields = fieldNameSupplier != null
// ? fieldNameSupplier.get() : Collections.emptyList();
//
// LinkedList<Completer> completors = new LinkedList<Completer>();
// completors.add(new StringsCompleter(commands));
// completors.add(new StringsCompleter(fields));
// completors.add(new FileNameCompleter());
// consoleReader.addCompleter(new ArgumentCompleter(completors));
// }
//
// public String readCommand() {
// try {
// return consoleReader.readLine("> ");
// } catch (IOException e) {
// System.err.println("Error! Clue is unable to read line from stdin: " + e.getMessage());
// throw new IllegalStateException("Unable to read command line!", e);
// }
// }
//
// public static String toString(List<String> list) {
// StringBuilder buf = new StringBuilder();
// for (String s : list) {
// buf.append(s).append(" ");
// }
// return buf.toString().trim();
// }
//
// public static Query toQuery(List<String> list, QueryBuilder queryBuilder) throws Exception {
// String qstring = toString(list);
// Query q = null;
// if (qstring == null || qstring.isEmpty() || qstring.equals("*")){
// q = new MatchAllDocsQuery();
// }
// else{
// q = queryBuilder.build(qstring);
// }
// return q;
// }
// }
//
// Path: src/main/java/io/dashbase/clue/commands/ClueCommand.java
// public abstract class ClueCommand {
//
// protected ClueContext ctx;
// private ArgumentParser parser;
//
// public ClueCommand(ClueContext ctx){
// this(ctx, false);
// }
//
// public ClueCommand(ClueContext ctx, boolean skipRegistration){
// this.ctx = ctx;
// if (!skipRegistration) {
// this.ctx.registerCommand(this);
// }
// }
//
// public final Namespace parseArgs(String[] args) throws ArgumentParserException {
// if (parser == null) {
// this.parser = buildParser(ArgumentParsers.newFor(getName())
// .build().defaultHelp(true).description(help()));
// if (parser == null) {
// return null;
// }
// }
// return parser.parseArgs(args);
// }
//
// public ClueContext getContext(){
// return ctx;
// }
//
// protected ArgumentParser buildParser(ArgumentParser parser) {
// return null;
// }
//
// public abstract String getName();
// public abstract String help();
// public abstract void execute(Namespace args, PrintStream out) throws Exception;
// }
//
// Path: src/main/java/io/dashbase/clue/commands/HelpCommand.java
// @Readonly
// public class HelpCommand extends ClueCommand {
//
// public static final String CMD_NAME = "help";
// public HelpCommand(ClueContext ctx) {
// super(ctx);
// }
//
// @Override
// public String getName() {
// return CMD_NAME;
// }
//
// @Override
// public String help() {
// return "displays help";
// }
//
// @Override
// public void execute(Namespace args, PrintStream out) {
// Collection<ClueCommand> commands = ctx.getCommandRegistry().getAvailableCommands();
//
// for (ClueCommand cmd : commands){
// out.println(cmd.getName()+" - " + cmd.help());
// }
// out.flush();
// }
//
// }
| import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.net.URI;
import java.util.Collection;
import java.util.Optional;
import java.util.function.Supplier;
import io.dashbase.clue.client.CmdlineHelper;
import net.sourceforge.argparse4j.helper.HelpScreenException;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.store.Directory;
import io.dashbase.clue.commands.ClueCommand;
import io.dashbase.clue.commands.HelpCommand; | package io.dashbase.clue;
public class ClueApplication {
private final LuceneContext ctx;
private static ClueAppConfiguration config;
private CmdlineHelper cmdlineHelper;
static {
try {
config = ClueAppConfiguration.load();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public ClueContext getContext() {
return ctx;
}
public ClueAppConfiguration getConfiguration() {
return config;
}
public LuceneContext newContext(String dir, ClueAppConfiguration config, boolean interactiveMode) throws Exception {
return new LuceneContext(dir, config, interactiveMode);
}
public ClueApplication(String idxLocation, boolean interactiveMode) throws Exception{
ctx = newContext(idxLocation, config, interactiveMode);
if (!DirectoryReader.indexExists(ctx.getDirectory())){
System.out.println("lucene index does not exist at: "+idxLocation);
System.exit(1);
}
}
public static void handleCommand(ClueContext ctx, String cmdName, String[] args, PrintStream out){ | // Path: src/main/java/io/dashbase/clue/client/CmdlineHelper.java
// public class CmdlineHelper {
// private final ConsoleReader consoleReader;
//
// public CmdlineHelper(Supplier<Collection<String>> commandNameSupplier,
// Supplier<Collection<String>> fieldNameSupplier) throws IOException {
// consoleReader = new ConsoleReader();
// consoleReader.setBellEnabled(false);
//
// Collection<String> commands = commandNameSupplier != null
// ? commandNameSupplier.get() : Collections.emptyList();
//
// Collection<String> fields = fieldNameSupplier != null
// ? fieldNameSupplier.get() : Collections.emptyList();
//
// LinkedList<Completer> completors = new LinkedList<Completer>();
// completors.add(new StringsCompleter(commands));
// completors.add(new StringsCompleter(fields));
// completors.add(new FileNameCompleter());
// consoleReader.addCompleter(new ArgumentCompleter(completors));
// }
//
// public String readCommand() {
// try {
// return consoleReader.readLine("> ");
// } catch (IOException e) {
// System.err.println("Error! Clue is unable to read line from stdin: " + e.getMessage());
// throw new IllegalStateException("Unable to read command line!", e);
// }
// }
//
// public static String toString(List<String> list) {
// StringBuilder buf = new StringBuilder();
// for (String s : list) {
// buf.append(s).append(" ");
// }
// return buf.toString().trim();
// }
//
// public static Query toQuery(List<String> list, QueryBuilder queryBuilder) throws Exception {
// String qstring = toString(list);
// Query q = null;
// if (qstring == null || qstring.isEmpty() || qstring.equals("*")){
// q = new MatchAllDocsQuery();
// }
// else{
// q = queryBuilder.build(qstring);
// }
// return q;
// }
// }
//
// Path: src/main/java/io/dashbase/clue/commands/ClueCommand.java
// public abstract class ClueCommand {
//
// protected ClueContext ctx;
// private ArgumentParser parser;
//
// public ClueCommand(ClueContext ctx){
// this(ctx, false);
// }
//
// public ClueCommand(ClueContext ctx, boolean skipRegistration){
// this.ctx = ctx;
// if (!skipRegistration) {
// this.ctx.registerCommand(this);
// }
// }
//
// public final Namespace parseArgs(String[] args) throws ArgumentParserException {
// if (parser == null) {
// this.parser = buildParser(ArgumentParsers.newFor(getName())
// .build().defaultHelp(true).description(help()));
// if (parser == null) {
// return null;
// }
// }
// return parser.parseArgs(args);
// }
//
// public ClueContext getContext(){
// return ctx;
// }
//
// protected ArgumentParser buildParser(ArgumentParser parser) {
// return null;
// }
//
// public abstract String getName();
// public abstract String help();
// public abstract void execute(Namespace args, PrintStream out) throws Exception;
// }
//
// Path: src/main/java/io/dashbase/clue/commands/HelpCommand.java
// @Readonly
// public class HelpCommand extends ClueCommand {
//
// public static final String CMD_NAME = "help";
// public HelpCommand(ClueContext ctx) {
// super(ctx);
// }
//
// @Override
// public String getName() {
// return CMD_NAME;
// }
//
// @Override
// public String help() {
// return "displays help";
// }
//
// @Override
// public void execute(Namespace args, PrintStream out) {
// Collection<ClueCommand> commands = ctx.getCommandRegistry().getAvailableCommands();
//
// for (ClueCommand cmd : commands){
// out.println(cmd.getName()+" - " + cmd.help());
// }
// out.flush();
// }
//
// }
// Path: src/main/java/io/dashbase/clue/ClueApplication.java
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.net.URI;
import java.util.Collection;
import java.util.Optional;
import java.util.function.Supplier;
import io.dashbase.clue.client.CmdlineHelper;
import net.sourceforge.argparse4j.helper.HelpScreenException;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.store.Directory;
import io.dashbase.clue.commands.ClueCommand;
import io.dashbase.clue.commands.HelpCommand;
package io.dashbase.clue;
public class ClueApplication {
private final LuceneContext ctx;
private static ClueAppConfiguration config;
private CmdlineHelper cmdlineHelper;
static {
try {
config = ClueAppConfiguration.load();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public ClueContext getContext() {
return ctx;
}
public ClueAppConfiguration getConfiguration() {
return config;
}
public LuceneContext newContext(String dir, ClueAppConfiguration config, boolean interactiveMode) throws Exception {
return new LuceneContext(dir, config, interactiveMode);
}
public ClueApplication(String idxLocation, boolean interactiveMode) throws Exception{
ctx = newContext(idxLocation, config, interactiveMode);
if (!DirectoryReader.indexExists(ctx.getDirectory())){
System.out.println("lucene index does not exist at: "+idxLocation);
System.exit(1);
}
}
public static void handleCommand(ClueContext ctx, String cmdName, String[] args, PrintStream out){ | Optional<ClueCommand> helpCommand = ctx.getCommand(HelpCommand.CMD_NAME); |
javasoze/clue | src/main/java/io/dashbase/clue/commands/DocValCommand.java | // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
| import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.*;
import org.apache.lucene.util.BytesRef;
import java.io.IOException;
import java.io.PrintStream;
import java.util.List; | package io.dashbase.clue.commands;
@Readonly
public class DocValCommand extends ClueCommand {
private static final String NUM_TERMS_IN_FIELD = "numTerms in field: ";
| // Path: src/main/java/io/dashbase/clue/ClueContext.java
// public class ClueContext {
// protected final CommandRegistry registry = new CommandRegistry();
//
// private final boolean interactiveMode;
//
// public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
// commandRegistrar.registerCommands(this);
// this.interactiveMode = interactiveMode;
// }
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (registry.exists(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// registry.registerCommand(cmd);
// }
//
// public boolean isReadOnlyMode() {
// return registry.isReadonly();
// }
//
// public boolean isInteractiveMode(){
// return interactiveMode;
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
// return registry.getCommand(cmd);
// }
//
// public CommandRegistry getCommandRegistry(){
// return registry;
// }
//
// public void shutdown() throws Exception{
// }
// }
//
// Path: src/main/java/io/dashbase/clue/LuceneContext.java
// public class LuceneContext extends ClueContext {
// private final IndexReaderFactory readerFactory;
//
// private IndexWriter writer;
// private final Directory directory;
// private final IndexWriterConfig writerConfig;
// private final QueryBuilder queryBuilder;
// private final AnalyzerFactory analyzerFactory;
// private final BytesRefDisplay termBytesRefDisplay;
// private final BytesRefDisplay payloadBytesRefDisplay;
//
// public LuceneContext(String dir, ClueAppConfiguration config, boolean interactiveMode)
// throws Exception {
// super(config.commandRegistrar, interactiveMode);
// this.directory = config.dirBuilder.build(dir);
// this.analyzerFactory = config.analyzerFactory;
// this.readerFactory = config.indexReaderFactory;
// this.readerFactory.initialize(directory);
// this.queryBuilder = config.queryBuilder;
// this.queryBuilder.initialize("contents", analyzerFactory.forQuery());
// this.writerConfig = new IndexWriterConfig(new StandardAnalyzer());
// this.termBytesRefDisplay = new StringBytesRefDisplay();
// this.payloadBytesRefDisplay = new StringBytesRefDisplay();
// this.writer = null;
// }
//
//
// public IndexReader getIndexReader(){
// return readerFactory.getIndexReader();
// }
//
// public IndexSearcher getIndexSearcher() {
// return new IndexSearcher(getIndexReader());
// }
//
// public IndexWriter getIndexWriter(){
// if (registry.isReadonly()) return null;
// if (writer == null) {
// try {
// writer = new IndexWriter(directory, writerConfig);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return writer;
// }
//
// Collection<String> fieldNames() {
// LinkedList<String> fieldNames = new LinkedList<>();
// for (LeafReaderContext context : getIndexReader().leaves()) {
// LeafReader reader = context.reader();
// for(FieldInfo info : reader.getFieldInfos()) {
// fieldNames.add(info.name);
// }
// }
// return fieldNames;
// }
//
// public QueryBuilder getQueryBuilder() {
// return queryBuilder;
// }
//
// public Analyzer getAnalyzerQuery() {
// return analyzerFactory.forQuery();
// }
//
// public BytesRefDisplay getTermBytesRefDisplay() {
// return termBytesRefDisplay;
// }
//
// public BytesRefDisplay getPayloadBytesRefDisplay() {
// return payloadBytesRefDisplay;
// }
//
// public Directory getDirectory() {
// return directory;
// }
//
// public void setReadOnlyMode(boolean readOnlyMode) {
// this.registry.setReadonly(readOnlyMode);
// if (writer != null) {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// writer = null;
// }
// }
//
// public void refreshReader() throws Exception {
// readerFactory.refreshReader();
// }
//
// @Override
// public void shutdown() throws Exception{
// try {
// readerFactory.shutdown();
// }
// finally{
// directory.close();
// if (writer != null) {
// writer.close();
// }
// }
// }
// }
// Path: src/main/java/io/dashbase/clue/commands/DocValCommand.java
import io.dashbase.clue.ClueContext;
import io.dashbase.clue.LuceneContext;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.lucene.index.*;
import org.apache.lucene.util.BytesRef;
import java.io.IOException;
import java.io.PrintStream;
import java.util.List;
package io.dashbase.clue.commands;
@Readonly
public class DocValCommand extends ClueCommand {
private static final String NUM_TERMS_IN_FIELD = "numTerms in field: ";
| private final LuceneContext ctx; |
javasoze/clue | src/main/java/io/dashbase/clue/ClueContext.java | // Path: src/main/java/io/dashbase/clue/commands/ClueCommand.java
// public abstract class ClueCommand {
//
// protected ClueContext ctx;
// private ArgumentParser parser;
//
// public ClueCommand(ClueContext ctx){
// this(ctx, false);
// }
//
// public ClueCommand(ClueContext ctx, boolean skipRegistration){
// this.ctx = ctx;
// if (!skipRegistration) {
// this.ctx.registerCommand(this);
// }
// }
//
// public final Namespace parseArgs(String[] args) throws ArgumentParserException {
// if (parser == null) {
// this.parser = buildParser(ArgumentParsers.newFor(getName())
// .build().defaultHelp(true).description(help()));
// if (parser == null) {
// return null;
// }
// }
// return parser.parseArgs(args);
// }
//
// public ClueContext getContext(){
// return ctx;
// }
//
// protected ArgumentParser buildParser(ArgumentParser parser) {
// return null;
// }
//
// public abstract String getName();
// public abstract String help();
// public abstract void execute(Namespace args, PrintStream out) throws Exception;
// }
//
// Path: src/main/java/io/dashbase/clue/commands/CommandRegistrar.java
// @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = DefaultCommandRegistrar.class)
// @JsonSubTypes({
// @JsonSubTypes.Type(name = "default", value = DefaultCommandRegistrar.class)
// })
// public interface CommandRegistrar {
// void registerCommands(ClueContext ctx);
// }
//
// Path: src/main/java/io/dashbase/clue/commands/CommandRegistry.java
// public class CommandRegistry {
// private final SortedMap<String, ClueCommand> cmdMap = new TreeMap<String, ClueCommand>();
// private volatile boolean readonly = true;
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (cmdMap.containsKey(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// cmdMap.put(cmdName, cmd);
// }
//
// public Set<String> commandNames() {
// return cmdMap.keySet();
// }
//
// public boolean exists(String command) {
// return cmdMap.containsKey(command);
// }
//
// public void setReadonly(boolean readonly) {
// this.readonly = readonly;
// }
//
// public boolean isReadonly() {
// return this.readonly;
// }
//
// public Collection<ClueCommand> getAvailableCommands() {
// if (readonly) {
// return cmdMap.values().stream().filter(c -> c.getClass().isAnnotationPresent(Readonly.class)).collect(Collectors.toList());
// } else {
// return cmdMap.values();
// }
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
//
// ClueCommand command = cmdMap.get(cmd);
// if (command != null) {
// if (readonly) {
// if (!command.getClass().isAnnotationPresent(Readonly.class)) {
// command = new FilterCommand(command) {
// public void execute(Namespace args, PrintStream out) throws Exception {
// out.println("read-only mode, command: " + getName() + " is not allowed");
// }
// };
// }
// }
// return Optional.of(command);
// } else {
// return Optional.empty();
// }
// }
// }
| import io.dashbase.clue.commands.ClueCommand;
import io.dashbase.clue.commands.CommandRegistrar;
import io.dashbase.clue.commands.CommandRegistry;
import java.util.Optional; | package io.dashbase.clue;
public class ClueContext {
protected final CommandRegistry registry = new CommandRegistry();
private final boolean interactiveMode;
| // Path: src/main/java/io/dashbase/clue/commands/ClueCommand.java
// public abstract class ClueCommand {
//
// protected ClueContext ctx;
// private ArgumentParser parser;
//
// public ClueCommand(ClueContext ctx){
// this(ctx, false);
// }
//
// public ClueCommand(ClueContext ctx, boolean skipRegistration){
// this.ctx = ctx;
// if (!skipRegistration) {
// this.ctx.registerCommand(this);
// }
// }
//
// public final Namespace parseArgs(String[] args) throws ArgumentParserException {
// if (parser == null) {
// this.parser = buildParser(ArgumentParsers.newFor(getName())
// .build().defaultHelp(true).description(help()));
// if (parser == null) {
// return null;
// }
// }
// return parser.parseArgs(args);
// }
//
// public ClueContext getContext(){
// return ctx;
// }
//
// protected ArgumentParser buildParser(ArgumentParser parser) {
// return null;
// }
//
// public abstract String getName();
// public abstract String help();
// public abstract void execute(Namespace args, PrintStream out) throws Exception;
// }
//
// Path: src/main/java/io/dashbase/clue/commands/CommandRegistrar.java
// @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = DefaultCommandRegistrar.class)
// @JsonSubTypes({
// @JsonSubTypes.Type(name = "default", value = DefaultCommandRegistrar.class)
// })
// public interface CommandRegistrar {
// void registerCommands(ClueContext ctx);
// }
//
// Path: src/main/java/io/dashbase/clue/commands/CommandRegistry.java
// public class CommandRegistry {
// private final SortedMap<String, ClueCommand> cmdMap = new TreeMap<String, ClueCommand>();
// private volatile boolean readonly = true;
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (cmdMap.containsKey(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// cmdMap.put(cmdName, cmd);
// }
//
// public Set<String> commandNames() {
// return cmdMap.keySet();
// }
//
// public boolean exists(String command) {
// return cmdMap.containsKey(command);
// }
//
// public void setReadonly(boolean readonly) {
// this.readonly = readonly;
// }
//
// public boolean isReadonly() {
// return this.readonly;
// }
//
// public Collection<ClueCommand> getAvailableCommands() {
// if (readonly) {
// return cmdMap.values().stream().filter(c -> c.getClass().isAnnotationPresent(Readonly.class)).collect(Collectors.toList());
// } else {
// return cmdMap.values();
// }
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
//
// ClueCommand command = cmdMap.get(cmd);
// if (command != null) {
// if (readonly) {
// if (!command.getClass().isAnnotationPresent(Readonly.class)) {
// command = new FilterCommand(command) {
// public void execute(Namespace args, PrintStream out) throws Exception {
// out.println("read-only mode, command: " + getName() + " is not allowed");
// }
// };
// }
// }
// return Optional.of(command);
// } else {
// return Optional.empty();
// }
// }
// }
// Path: src/main/java/io/dashbase/clue/ClueContext.java
import io.dashbase.clue.commands.ClueCommand;
import io.dashbase.clue.commands.CommandRegistrar;
import io.dashbase.clue.commands.CommandRegistry;
import java.util.Optional;
package io.dashbase.clue;
public class ClueContext {
protected final CommandRegistry registry = new CommandRegistry();
private final boolean interactiveMode;
| public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) { |
javasoze/clue | src/main/java/io/dashbase/clue/ClueContext.java | // Path: src/main/java/io/dashbase/clue/commands/ClueCommand.java
// public abstract class ClueCommand {
//
// protected ClueContext ctx;
// private ArgumentParser parser;
//
// public ClueCommand(ClueContext ctx){
// this(ctx, false);
// }
//
// public ClueCommand(ClueContext ctx, boolean skipRegistration){
// this.ctx = ctx;
// if (!skipRegistration) {
// this.ctx.registerCommand(this);
// }
// }
//
// public final Namespace parseArgs(String[] args) throws ArgumentParserException {
// if (parser == null) {
// this.parser = buildParser(ArgumentParsers.newFor(getName())
// .build().defaultHelp(true).description(help()));
// if (parser == null) {
// return null;
// }
// }
// return parser.parseArgs(args);
// }
//
// public ClueContext getContext(){
// return ctx;
// }
//
// protected ArgumentParser buildParser(ArgumentParser parser) {
// return null;
// }
//
// public abstract String getName();
// public abstract String help();
// public abstract void execute(Namespace args, PrintStream out) throws Exception;
// }
//
// Path: src/main/java/io/dashbase/clue/commands/CommandRegistrar.java
// @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = DefaultCommandRegistrar.class)
// @JsonSubTypes({
// @JsonSubTypes.Type(name = "default", value = DefaultCommandRegistrar.class)
// })
// public interface CommandRegistrar {
// void registerCommands(ClueContext ctx);
// }
//
// Path: src/main/java/io/dashbase/clue/commands/CommandRegistry.java
// public class CommandRegistry {
// private final SortedMap<String, ClueCommand> cmdMap = new TreeMap<String, ClueCommand>();
// private volatile boolean readonly = true;
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (cmdMap.containsKey(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// cmdMap.put(cmdName, cmd);
// }
//
// public Set<String> commandNames() {
// return cmdMap.keySet();
// }
//
// public boolean exists(String command) {
// return cmdMap.containsKey(command);
// }
//
// public void setReadonly(boolean readonly) {
// this.readonly = readonly;
// }
//
// public boolean isReadonly() {
// return this.readonly;
// }
//
// public Collection<ClueCommand> getAvailableCommands() {
// if (readonly) {
// return cmdMap.values().stream().filter(c -> c.getClass().isAnnotationPresent(Readonly.class)).collect(Collectors.toList());
// } else {
// return cmdMap.values();
// }
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
//
// ClueCommand command = cmdMap.get(cmd);
// if (command != null) {
// if (readonly) {
// if (!command.getClass().isAnnotationPresent(Readonly.class)) {
// command = new FilterCommand(command) {
// public void execute(Namespace args, PrintStream out) throws Exception {
// out.println("read-only mode, command: " + getName() + " is not allowed");
// }
// };
// }
// }
// return Optional.of(command);
// } else {
// return Optional.empty();
// }
// }
// }
| import io.dashbase.clue.commands.ClueCommand;
import io.dashbase.clue.commands.CommandRegistrar;
import io.dashbase.clue.commands.CommandRegistry;
import java.util.Optional; | package io.dashbase.clue;
public class ClueContext {
protected final CommandRegistry registry = new CommandRegistry();
private final boolean interactiveMode;
public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
commandRegistrar.registerCommands(this);
this.interactiveMode = interactiveMode;
}
| // Path: src/main/java/io/dashbase/clue/commands/ClueCommand.java
// public abstract class ClueCommand {
//
// protected ClueContext ctx;
// private ArgumentParser parser;
//
// public ClueCommand(ClueContext ctx){
// this(ctx, false);
// }
//
// public ClueCommand(ClueContext ctx, boolean skipRegistration){
// this.ctx = ctx;
// if (!skipRegistration) {
// this.ctx.registerCommand(this);
// }
// }
//
// public final Namespace parseArgs(String[] args) throws ArgumentParserException {
// if (parser == null) {
// this.parser = buildParser(ArgumentParsers.newFor(getName())
// .build().defaultHelp(true).description(help()));
// if (parser == null) {
// return null;
// }
// }
// return parser.parseArgs(args);
// }
//
// public ClueContext getContext(){
// return ctx;
// }
//
// protected ArgumentParser buildParser(ArgumentParser parser) {
// return null;
// }
//
// public abstract String getName();
// public abstract String help();
// public abstract void execute(Namespace args, PrintStream out) throws Exception;
// }
//
// Path: src/main/java/io/dashbase/clue/commands/CommandRegistrar.java
// @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = DefaultCommandRegistrar.class)
// @JsonSubTypes({
// @JsonSubTypes.Type(name = "default", value = DefaultCommandRegistrar.class)
// })
// public interface CommandRegistrar {
// void registerCommands(ClueContext ctx);
// }
//
// Path: src/main/java/io/dashbase/clue/commands/CommandRegistry.java
// public class CommandRegistry {
// private final SortedMap<String, ClueCommand> cmdMap = new TreeMap<String, ClueCommand>();
// private volatile boolean readonly = true;
//
// public void registerCommand(ClueCommand cmd){
// String cmdName = cmd.getName();
// if (cmdMap.containsKey(cmdName)){
// throw new IllegalArgumentException(cmdName+" exists!");
// }
// cmdMap.put(cmdName, cmd);
// }
//
// public Set<String> commandNames() {
// return cmdMap.keySet();
// }
//
// public boolean exists(String command) {
// return cmdMap.containsKey(command);
// }
//
// public void setReadonly(boolean readonly) {
// this.readonly = readonly;
// }
//
// public boolean isReadonly() {
// return this.readonly;
// }
//
// public Collection<ClueCommand> getAvailableCommands() {
// if (readonly) {
// return cmdMap.values().stream().filter(c -> c.getClass().isAnnotationPresent(Readonly.class)).collect(Collectors.toList());
// } else {
// return cmdMap.values();
// }
// }
//
// public Optional<ClueCommand> getCommand(String cmd){
//
// ClueCommand command = cmdMap.get(cmd);
// if (command != null) {
// if (readonly) {
// if (!command.getClass().isAnnotationPresent(Readonly.class)) {
// command = new FilterCommand(command) {
// public void execute(Namespace args, PrintStream out) throws Exception {
// out.println("read-only mode, command: " + getName() + " is not allowed");
// }
// };
// }
// }
// return Optional.of(command);
// } else {
// return Optional.empty();
// }
// }
// }
// Path: src/main/java/io/dashbase/clue/ClueContext.java
import io.dashbase.clue.commands.ClueCommand;
import io.dashbase.clue.commands.CommandRegistrar;
import io.dashbase.clue.commands.CommandRegistry;
import java.util.Optional;
package io.dashbase.clue;
public class ClueContext {
protected final CommandRegistry registry = new CommandRegistry();
private final boolean interactiveMode;
public ClueContext(CommandRegistrar commandRegistrar, boolean interactiveMode) {
commandRegistrar.registerCommands(this);
this.interactiveMode = interactiveMode;
}
| public void registerCommand(ClueCommand cmd){ |
xzela/jastroblast | jastroblast-core/src/org/doublelong/jastroblast/controller/MenuController.java | // Path: jastroblast-core/src/org/doublelong/jastroblast/Inputs.java
// public class Inputs
// {
// public static final int MENU_UP = Keys.UP;
// public static final int MENU_DOWN = Keys.DOWN;
// public static final int MENU_SELECT = Keys.ENTER;
//
// public static final int PLAYER_LEFT = Keys.LEFT;
// public static final int PLAYER_RIGHT = Keys.RIGHT;
// public static final int PLAYER_THRUST = Keys.UP;
//
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Menu.java
// public abstract class Menu
// {
//
// public int currentMenuIndex;
// public List<MenuButton> elements;
// private Actor cursor;
// private AbstractScreen currentScreen;
// public AbstractScreen getCurrentScreen() { return this.currentScreen; }
//
// protected Table table;
// public Table getTable() { return this.table; }
//
//
// public Menu(Actor cursor)
// {
// this.currentMenuIndex = 0;
// this.cursor = cursor;
// }
//
// public void moveUp()
// {
// if(!this.atTop())
// {
// this.currentMenuIndex--;
// }
// }
//
// public void moveDown()
// {
// if(!this.atBottom())
// {
// this.currentMenuIndex++;
// }
// }
//
// public void updateCursor()
// {
// Label button = this.elements.get(this.currentMenuIndex).getLabel();
// this.setCursorPosition(button);
// //this.currentScreen = (AbstractScreen) this.elements.get(this.currentMenuIndex).getScreen();
// }
//
// public void setCursorPosition(Label element)
// {
// Vector2 pos = new Vector2(element.getX(), element.getY());
// this.cursor.setX(pos.x - (this.cursor.getWidth() + 10f));
// this.cursor.setY(pos.y + 5f);
// }
//
// private boolean atTop()
// {
// return this.currentMenuIndex == 0;
// }
//
// private boolean atBottom()
// {
// return this.currentMenuIndex == this.elements.size() - 1;
// }
//
// public void showScreen(Screens screen)
// {
// ScreenManager.getInstance().show(screen);
// }
//
// public Screen getScreen(Screens screen)
// {
// return ScreenManager.getInstance().get(screen);
// }
//
// protected void initializeTable()
// {
// //this.table.debug();
// this.table.setFillParent(true);
//
// for(MenuButton button : this.elements)
// {
// this.table.add(button.renderLabel()).left();
// this.table.row();
// }
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/screen/AbstractScreen.java
// public abstract class AbstractScreen implements Screen
// {
// protected Menu menu;
// public Menu getMenu() { return this.menu; }
//
// public AbstractScreen()
// {
// }
//
// public abstract void transitionScreen();
//
//
// @Override
// public void render(float delta) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resize(int width, int height) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void show() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void hide() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
//
// }
//
// }
| import org.doublelong.jastroblast.Inputs;
import org.doublelong.jastroblast.entity.Menu;
import org.doublelong.jastroblast.screen.AbstractScreen;
import com.badlogic.gdx.InputProcessor; | package org.doublelong.jastroblast.controller;
public class MenuController implements InputProcessor
{ | // Path: jastroblast-core/src/org/doublelong/jastroblast/Inputs.java
// public class Inputs
// {
// public static final int MENU_UP = Keys.UP;
// public static final int MENU_DOWN = Keys.DOWN;
// public static final int MENU_SELECT = Keys.ENTER;
//
// public static final int PLAYER_LEFT = Keys.LEFT;
// public static final int PLAYER_RIGHT = Keys.RIGHT;
// public static final int PLAYER_THRUST = Keys.UP;
//
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Menu.java
// public abstract class Menu
// {
//
// public int currentMenuIndex;
// public List<MenuButton> elements;
// private Actor cursor;
// private AbstractScreen currentScreen;
// public AbstractScreen getCurrentScreen() { return this.currentScreen; }
//
// protected Table table;
// public Table getTable() { return this.table; }
//
//
// public Menu(Actor cursor)
// {
// this.currentMenuIndex = 0;
// this.cursor = cursor;
// }
//
// public void moveUp()
// {
// if(!this.atTop())
// {
// this.currentMenuIndex--;
// }
// }
//
// public void moveDown()
// {
// if(!this.atBottom())
// {
// this.currentMenuIndex++;
// }
// }
//
// public void updateCursor()
// {
// Label button = this.elements.get(this.currentMenuIndex).getLabel();
// this.setCursorPosition(button);
// //this.currentScreen = (AbstractScreen) this.elements.get(this.currentMenuIndex).getScreen();
// }
//
// public void setCursorPosition(Label element)
// {
// Vector2 pos = new Vector2(element.getX(), element.getY());
// this.cursor.setX(pos.x - (this.cursor.getWidth() + 10f));
// this.cursor.setY(pos.y + 5f);
// }
//
// private boolean atTop()
// {
// return this.currentMenuIndex == 0;
// }
//
// private boolean atBottom()
// {
// return this.currentMenuIndex == this.elements.size() - 1;
// }
//
// public void showScreen(Screens screen)
// {
// ScreenManager.getInstance().show(screen);
// }
//
// public Screen getScreen(Screens screen)
// {
// return ScreenManager.getInstance().get(screen);
// }
//
// protected void initializeTable()
// {
// //this.table.debug();
// this.table.setFillParent(true);
//
// for(MenuButton button : this.elements)
// {
// this.table.add(button.renderLabel()).left();
// this.table.row();
// }
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/screen/AbstractScreen.java
// public abstract class AbstractScreen implements Screen
// {
// protected Menu menu;
// public Menu getMenu() { return this.menu; }
//
// public AbstractScreen()
// {
// }
//
// public abstract void transitionScreen();
//
//
// @Override
// public void render(float delta) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resize(int width, int height) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void show() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void hide() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
//
// }
//
// }
// Path: jastroblast-core/src/org/doublelong/jastroblast/controller/MenuController.java
import org.doublelong.jastroblast.Inputs;
import org.doublelong.jastroblast.entity.Menu;
import org.doublelong.jastroblast.screen.AbstractScreen;
import com.badlogic.gdx.InputProcessor;
package org.doublelong.jastroblast.controller;
public class MenuController implements InputProcessor
{ | private AbstractScreen screen; |
xzela/jastroblast | jastroblast-core/src/org/doublelong/jastroblast/controller/MenuController.java | // Path: jastroblast-core/src/org/doublelong/jastroblast/Inputs.java
// public class Inputs
// {
// public static final int MENU_UP = Keys.UP;
// public static final int MENU_DOWN = Keys.DOWN;
// public static final int MENU_SELECT = Keys.ENTER;
//
// public static final int PLAYER_LEFT = Keys.LEFT;
// public static final int PLAYER_RIGHT = Keys.RIGHT;
// public static final int PLAYER_THRUST = Keys.UP;
//
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Menu.java
// public abstract class Menu
// {
//
// public int currentMenuIndex;
// public List<MenuButton> elements;
// private Actor cursor;
// private AbstractScreen currentScreen;
// public AbstractScreen getCurrentScreen() { return this.currentScreen; }
//
// protected Table table;
// public Table getTable() { return this.table; }
//
//
// public Menu(Actor cursor)
// {
// this.currentMenuIndex = 0;
// this.cursor = cursor;
// }
//
// public void moveUp()
// {
// if(!this.atTop())
// {
// this.currentMenuIndex--;
// }
// }
//
// public void moveDown()
// {
// if(!this.atBottom())
// {
// this.currentMenuIndex++;
// }
// }
//
// public void updateCursor()
// {
// Label button = this.elements.get(this.currentMenuIndex).getLabel();
// this.setCursorPosition(button);
// //this.currentScreen = (AbstractScreen) this.elements.get(this.currentMenuIndex).getScreen();
// }
//
// public void setCursorPosition(Label element)
// {
// Vector2 pos = new Vector2(element.getX(), element.getY());
// this.cursor.setX(pos.x - (this.cursor.getWidth() + 10f));
// this.cursor.setY(pos.y + 5f);
// }
//
// private boolean atTop()
// {
// return this.currentMenuIndex == 0;
// }
//
// private boolean atBottom()
// {
// return this.currentMenuIndex == this.elements.size() - 1;
// }
//
// public void showScreen(Screens screen)
// {
// ScreenManager.getInstance().show(screen);
// }
//
// public Screen getScreen(Screens screen)
// {
// return ScreenManager.getInstance().get(screen);
// }
//
// protected void initializeTable()
// {
// //this.table.debug();
// this.table.setFillParent(true);
//
// for(MenuButton button : this.elements)
// {
// this.table.add(button.renderLabel()).left();
// this.table.row();
// }
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/screen/AbstractScreen.java
// public abstract class AbstractScreen implements Screen
// {
// protected Menu menu;
// public Menu getMenu() { return this.menu; }
//
// public AbstractScreen()
// {
// }
//
// public abstract void transitionScreen();
//
//
// @Override
// public void render(float delta) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resize(int width, int height) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void show() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void hide() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
//
// }
//
// }
| import org.doublelong.jastroblast.Inputs;
import org.doublelong.jastroblast.entity.Menu;
import org.doublelong.jastroblast.screen.AbstractScreen;
import com.badlogic.gdx.InputProcessor; | package org.doublelong.jastroblast.controller;
public class MenuController implements InputProcessor
{
private AbstractScreen screen; | // Path: jastroblast-core/src/org/doublelong/jastroblast/Inputs.java
// public class Inputs
// {
// public static final int MENU_UP = Keys.UP;
// public static final int MENU_DOWN = Keys.DOWN;
// public static final int MENU_SELECT = Keys.ENTER;
//
// public static final int PLAYER_LEFT = Keys.LEFT;
// public static final int PLAYER_RIGHT = Keys.RIGHT;
// public static final int PLAYER_THRUST = Keys.UP;
//
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Menu.java
// public abstract class Menu
// {
//
// public int currentMenuIndex;
// public List<MenuButton> elements;
// private Actor cursor;
// private AbstractScreen currentScreen;
// public AbstractScreen getCurrentScreen() { return this.currentScreen; }
//
// protected Table table;
// public Table getTable() { return this.table; }
//
//
// public Menu(Actor cursor)
// {
// this.currentMenuIndex = 0;
// this.cursor = cursor;
// }
//
// public void moveUp()
// {
// if(!this.atTop())
// {
// this.currentMenuIndex--;
// }
// }
//
// public void moveDown()
// {
// if(!this.atBottom())
// {
// this.currentMenuIndex++;
// }
// }
//
// public void updateCursor()
// {
// Label button = this.elements.get(this.currentMenuIndex).getLabel();
// this.setCursorPosition(button);
// //this.currentScreen = (AbstractScreen) this.elements.get(this.currentMenuIndex).getScreen();
// }
//
// public void setCursorPosition(Label element)
// {
// Vector2 pos = new Vector2(element.getX(), element.getY());
// this.cursor.setX(pos.x - (this.cursor.getWidth() + 10f));
// this.cursor.setY(pos.y + 5f);
// }
//
// private boolean atTop()
// {
// return this.currentMenuIndex == 0;
// }
//
// private boolean atBottom()
// {
// return this.currentMenuIndex == this.elements.size() - 1;
// }
//
// public void showScreen(Screens screen)
// {
// ScreenManager.getInstance().show(screen);
// }
//
// public Screen getScreen(Screens screen)
// {
// return ScreenManager.getInstance().get(screen);
// }
//
// protected void initializeTable()
// {
// //this.table.debug();
// this.table.setFillParent(true);
//
// for(MenuButton button : this.elements)
// {
// this.table.add(button.renderLabel()).left();
// this.table.row();
// }
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/screen/AbstractScreen.java
// public abstract class AbstractScreen implements Screen
// {
// protected Menu menu;
// public Menu getMenu() { return this.menu; }
//
// public AbstractScreen()
// {
// }
//
// public abstract void transitionScreen();
//
//
// @Override
// public void render(float delta) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resize(int width, int height) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void show() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void hide() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
//
// }
//
// }
// Path: jastroblast-core/src/org/doublelong/jastroblast/controller/MenuController.java
import org.doublelong.jastroblast.Inputs;
import org.doublelong.jastroblast.entity.Menu;
import org.doublelong.jastroblast.screen.AbstractScreen;
import com.badlogic.gdx.InputProcessor;
package org.doublelong.jastroblast.controller;
public class MenuController implements InputProcessor
{
private AbstractScreen screen; | private Menu menu; |
xzela/jastroblast | jastroblast-core/src/org/doublelong/jastroblast/controller/MenuController.java | // Path: jastroblast-core/src/org/doublelong/jastroblast/Inputs.java
// public class Inputs
// {
// public static final int MENU_UP = Keys.UP;
// public static final int MENU_DOWN = Keys.DOWN;
// public static final int MENU_SELECT = Keys.ENTER;
//
// public static final int PLAYER_LEFT = Keys.LEFT;
// public static final int PLAYER_RIGHT = Keys.RIGHT;
// public static final int PLAYER_THRUST = Keys.UP;
//
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Menu.java
// public abstract class Menu
// {
//
// public int currentMenuIndex;
// public List<MenuButton> elements;
// private Actor cursor;
// private AbstractScreen currentScreen;
// public AbstractScreen getCurrentScreen() { return this.currentScreen; }
//
// protected Table table;
// public Table getTable() { return this.table; }
//
//
// public Menu(Actor cursor)
// {
// this.currentMenuIndex = 0;
// this.cursor = cursor;
// }
//
// public void moveUp()
// {
// if(!this.atTop())
// {
// this.currentMenuIndex--;
// }
// }
//
// public void moveDown()
// {
// if(!this.atBottom())
// {
// this.currentMenuIndex++;
// }
// }
//
// public void updateCursor()
// {
// Label button = this.elements.get(this.currentMenuIndex).getLabel();
// this.setCursorPosition(button);
// //this.currentScreen = (AbstractScreen) this.elements.get(this.currentMenuIndex).getScreen();
// }
//
// public void setCursorPosition(Label element)
// {
// Vector2 pos = new Vector2(element.getX(), element.getY());
// this.cursor.setX(pos.x - (this.cursor.getWidth() + 10f));
// this.cursor.setY(pos.y + 5f);
// }
//
// private boolean atTop()
// {
// return this.currentMenuIndex == 0;
// }
//
// private boolean atBottom()
// {
// return this.currentMenuIndex == this.elements.size() - 1;
// }
//
// public void showScreen(Screens screen)
// {
// ScreenManager.getInstance().show(screen);
// }
//
// public Screen getScreen(Screens screen)
// {
// return ScreenManager.getInstance().get(screen);
// }
//
// protected void initializeTable()
// {
// //this.table.debug();
// this.table.setFillParent(true);
//
// for(MenuButton button : this.elements)
// {
// this.table.add(button.renderLabel()).left();
// this.table.row();
// }
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/screen/AbstractScreen.java
// public abstract class AbstractScreen implements Screen
// {
// protected Menu menu;
// public Menu getMenu() { return this.menu; }
//
// public AbstractScreen()
// {
// }
//
// public abstract void transitionScreen();
//
//
// @Override
// public void render(float delta) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resize(int width, int height) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void show() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void hide() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
//
// }
//
// }
| import org.doublelong.jastroblast.Inputs;
import org.doublelong.jastroblast.entity.Menu;
import org.doublelong.jastroblast.screen.AbstractScreen;
import com.badlogic.gdx.InputProcessor; | package org.doublelong.jastroblast.controller;
public class MenuController implements InputProcessor
{
private AbstractScreen screen;
private Menu menu;
public MenuController(AbstractScreen screen, Menu menu)
{
this.screen = screen;
this.menu = menu;
}
@Override
public boolean keyDown(int keycode) {
switch(keycode)
{ | // Path: jastroblast-core/src/org/doublelong/jastroblast/Inputs.java
// public class Inputs
// {
// public static final int MENU_UP = Keys.UP;
// public static final int MENU_DOWN = Keys.DOWN;
// public static final int MENU_SELECT = Keys.ENTER;
//
// public static final int PLAYER_LEFT = Keys.LEFT;
// public static final int PLAYER_RIGHT = Keys.RIGHT;
// public static final int PLAYER_THRUST = Keys.UP;
//
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Menu.java
// public abstract class Menu
// {
//
// public int currentMenuIndex;
// public List<MenuButton> elements;
// private Actor cursor;
// private AbstractScreen currentScreen;
// public AbstractScreen getCurrentScreen() { return this.currentScreen; }
//
// protected Table table;
// public Table getTable() { return this.table; }
//
//
// public Menu(Actor cursor)
// {
// this.currentMenuIndex = 0;
// this.cursor = cursor;
// }
//
// public void moveUp()
// {
// if(!this.atTop())
// {
// this.currentMenuIndex--;
// }
// }
//
// public void moveDown()
// {
// if(!this.atBottom())
// {
// this.currentMenuIndex++;
// }
// }
//
// public void updateCursor()
// {
// Label button = this.elements.get(this.currentMenuIndex).getLabel();
// this.setCursorPosition(button);
// //this.currentScreen = (AbstractScreen) this.elements.get(this.currentMenuIndex).getScreen();
// }
//
// public void setCursorPosition(Label element)
// {
// Vector2 pos = new Vector2(element.getX(), element.getY());
// this.cursor.setX(pos.x - (this.cursor.getWidth() + 10f));
// this.cursor.setY(pos.y + 5f);
// }
//
// private boolean atTop()
// {
// return this.currentMenuIndex == 0;
// }
//
// private boolean atBottom()
// {
// return this.currentMenuIndex == this.elements.size() - 1;
// }
//
// public void showScreen(Screens screen)
// {
// ScreenManager.getInstance().show(screen);
// }
//
// public Screen getScreen(Screens screen)
// {
// return ScreenManager.getInstance().get(screen);
// }
//
// protected void initializeTable()
// {
// //this.table.debug();
// this.table.setFillParent(true);
//
// for(MenuButton button : this.elements)
// {
// this.table.add(button.renderLabel()).left();
// this.table.row();
// }
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/screen/AbstractScreen.java
// public abstract class AbstractScreen implements Screen
// {
// protected Menu menu;
// public Menu getMenu() { return this.menu; }
//
// public AbstractScreen()
// {
// }
//
// public abstract void transitionScreen();
//
//
// @Override
// public void render(float delta) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resize(int width, int height) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void show() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void hide() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
//
// }
//
// }
// Path: jastroblast-core/src/org/doublelong/jastroblast/controller/MenuController.java
import org.doublelong.jastroblast.Inputs;
import org.doublelong.jastroblast.entity.Menu;
import org.doublelong.jastroblast.screen.AbstractScreen;
import com.badlogic.gdx.InputProcessor;
package org.doublelong.jastroblast.controller;
public class MenuController implements InputProcessor
{
private AbstractScreen screen;
private Menu menu;
public MenuController(AbstractScreen screen, Menu menu)
{
this.screen = screen;
this.menu = menu;
}
@Override
public boolean keyDown(int keycode) {
switch(keycode)
{ | case Inputs.MENU_UP: |
xzela/jastroblast | jastroblast-core/src/org/doublelong/jastroblast/entity/MenuButton.java | // Path: jastroblast-core/src/org/doublelong/jastroblast/JastroBlast.java
// public class JastroBlast extends Game
// {
// public final String WINDOW_TITLE = "jAstroBlast";
// public static final int WINDOW_WIDTH = 800;
// public static final int WINDOW_HEIGHT = 600;
//
// public static AssetManager manager = new AssetManager();
// public static final boolean DEBUG = true;
//
// @Override
// public void create()
// {
// ScreenManager.getInstance().initialize(this);
// Texture.setEnforcePotImages(false);
// ScreenManager.getInstance().show(Screens.LOADING);
// // ScreenManager.getInstance().show(Screens.GAME);
// }
//
// @Override
// public void dispose()
// {
// super.dispose();
// ScreenManager.getInstance().dispose();
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/managers/FontManager.java
// public class FontManager
// {
// public static final String BLOCK_FONT = "assets/fonts/kenpixel_blocks.ttf";
// }
| import org.doublelong.jastroblast.JastroBlast;
import org.doublelong.jastroblast.managers.FontManager;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle; | package org.doublelong.jastroblast.entity;
public class MenuButton
{
private Label label;
public Label getLabel() { return this.label; }
private String text;
public String getText() { return this.text;}
private Screens screen;
public Screens getScreen() { return this.screen; }
private BitmapFont font;
private Color color;
public MenuButton(String text, Screens screen)
{
this.text = text;
this.screen = screen; | // Path: jastroblast-core/src/org/doublelong/jastroblast/JastroBlast.java
// public class JastroBlast extends Game
// {
// public final String WINDOW_TITLE = "jAstroBlast";
// public static final int WINDOW_WIDTH = 800;
// public static final int WINDOW_HEIGHT = 600;
//
// public static AssetManager manager = new AssetManager();
// public static final boolean DEBUG = true;
//
// @Override
// public void create()
// {
// ScreenManager.getInstance().initialize(this);
// Texture.setEnforcePotImages(false);
// ScreenManager.getInstance().show(Screens.LOADING);
// // ScreenManager.getInstance().show(Screens.GAME);
// }
//
// @Override
// public void dispose()
// {
// super.dispose();
// ScreenManager.getInstance().dispose();
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/managers/FontManager.java
// public class FontManager
// {
// public static final String BLOCK_FONT = "assets/fonts/kenpixel_blocks.ttf";
// }
// Path: jastroblast-core/src/org/doublelong/jastroblast/entity/MenuButton.java
import org.doublelong.jastroblast.JastroBlast;
import org.doublelong.jastroblast.managers.FontManager;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
package org.doublelong.jastroblast.entity;
public class MenuButton
{
private Label label;
public Label getLabel() { return this.label; }
private String text;
public String getText() { return this.text;}
private Screens screen;
public Screens getScreen() { return this.screen; }
private BitmapFont font;
private Color color;
public MenuButton(String text, Screens screen)
{
this.text = text;
this.screen = screen; | this.font = JastroBlast.manager.get(FontManager.BLOCK_FONT, BitmapFont.class); |
xzela/jastroblast | jastroblast-core/src/org/doublelong/jastroblast/entity/MenuButton.java | // Path: jastroblast-core/src/org/doublelong/jastroblast/JastroBlast.java
// public class JastroBlast extends Game
// {
// public final String WINDOW_TITLE = "jAstroBlast";
// public static final int WINDOW_WIDTH = 800;
// public static final int WINDOW_HEIGHT = 600;
//
// public static AssetManager manager = new AssetManager();
// public static final boolean DEBUG = true;
//
// @Override
// public void create()
// {
// ScreenManager.getInstance().initialize(this);
// Texture.setEnforcePotImages(false);
// ScreenManager.getInstance().show(Screens.LOADING);
// // ScreenManager.getInstance().show(Screens.GAME);
// }
//
// @Override
// public void dispose()
// {
// super.dispose();
// ScreenManager.getInstance().dispose();
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/managers/FontManager.java
// public class FontManager
// {
// public static final String BLOCK_FONT = "assets/fonts/kenpixel_blocks.ttf";
// }
| import org.doublelong.jastroblast.JastroBlast;
import org.doublelong.jastroblast.managers.FontManager;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle; | package org.doublelong.jastroblast.entity;
public class MenuButton
{
private Label label;
public Label getLabel() { return this.label; }
private String text;
public String getText() { return this.text;}
private Screens screen;
public Screens getScreen() { return this.screen; }
private BitmapFont font;
private Color color;
public MenuButton(String text, Screens screen)
{
this.text = text;
this.screen = screen; | // Path: jastroblast-core/src/org/doublelong/jastroblast/JastroBlast.java
// public class JastroBlast extends Game
// {
// public final String WINDOW_TITLE = "jAstroBlast";
// public static final int WINDOW_WIDTH = 800;
// public static final int WINDOW_HEIGHT = 600;
//
// public static AssetManager manager = new AssetManager();
// public static final boolean DEBUG = true;
//
// @Override
// public void create()
// {
// ScreenManager.getInstance().initialize(this);
// Texture.setEnforcePotImages(false);
// ScreenManager.getInstance().show(Screens.LOADING);
// // ScreenManager.getInstance().show(Screens.GAME);
// }
//
// @Override
// public void dispose()
// {
// super.dispose();
// ScreenManager.getInstance().dispose();
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/managers/FontManager.java
// public class FontManager
// {
// public static final String BLOCK_FONT = "assets/fonts/kenpixel_blocks.ttf";
// }
// Path: jastroblast-core/src/org/doublelong/jastroblast/entity/MenuButton.java
import org.doublelong.jastroblast.JastroBlast;
import org.doublelong.jastroblast.managers.FontManager;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
package org.doublelong.jastroblast.entity;
public class MenuButton
{
private Label label;
public Label getLabel() { return this.label; }
private String text;
public String getText() { return this.text;}
private Screens screen;
public Screens getScreen() { return this.screen; }
private BitmapFont font;
private Color color;
public MenuButton(String text, Screens screen)
{
this.text = text;
this.screen = screen; | this.font = JastroBlast.manager.get(FontManager.BLOCK_FONT, BitmapFont.class); |
xzela/jastroblast | jastroblast-core/src/org/doublelong/jastroblast/entity/Menu.java | // Path: jastroblast-core/src/org/doublelong/jastroblast/managers/ScreenManager.java
// public final class ScreenManager
// {
// private static ScreenManager instance;
//
// private JastroBlast game;
//
// private IntMap<Screen> screens;
//
// private ScreenManager() {
// screens = new IntMap<Screen>();
// }
//
// public static ScreenManager getInstance()
// {
// if (null == instance)
// {
// instance = new ScreenManager();
// }
// return instance;
// }
//
// /**
// * Initializes the game property
// *
// * @param game
// */
// public void initialize(JastroBlast game)
// {
// this.game = game;
// }
//
// /**
// * Tells the game to switch screens
// *
// * @param screen
// */
// public void show(Screens screen)
// {
// if (null == game)
// {
// return;
// }
// if (!screens.containsKey(screen.ordinal()))
// {
// screens.put(screen.ordinal(), screen.getScreenInstance());
// }
// this.game.setScreen(screens.get(screen.ordinal()));
// }
//
// public Screen get(Screens screen)
// {
// if (!screens.containsKey(screen.ordinal()))
// {
// screens.put(screen.ordinal(), screen.getScreenInstance());
// }
// return screens.get(screen.ordinal());
// }
//
// public void dispose(Screens screen)
// {
// if(!screens.containsKey(screen.ordinal()))
// {
// return;
// }
// screens.remove(screen.ordinal()).dispose();
// }
//
// public void dispose()
// {
// for (Screen screen : screens.values())
// {
// screen.dispose();
// }
// screens.clear();
// instance = null;
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/screen/AbstractScreen.java
// public abstract class AbstractScreen implements Screen
// {
// protected Menu menu;
// public Menu getMenu() { return this.menu; }
//
// public AbstractScreen()
// {
// }
//
// public abstract void transitionScreen();
//
//
// @Override
// public void render(float delta) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resize(int width, int height) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void show() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void hide() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
//
// }
//
// }
| import java.util.List;
import org.doublelong.jastroblast.managers.ScreenManager;
import org.doublelong.jastroblast.screen.AbstractScreen;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table; | package org.doublelong.jastroblast.entity;
public abstract class Menu
{
public int currentMenuIndex;
public List<MenuButton> elements;
private Actor cursor; | // Path: jastroblast-core/src/org/doublelong/jastroblast/managers/ScreenManager.java
// public final class ScreenManager
// {
// private static ScreenManager instance;
//
// private JastroBlast game;
//
// private IntMap<Screen> screens;
//
// private ScreenManager() {
// screens = new IntMap<Screen>();
// }
//
// public static ScreenManager getInstance()
// {
// if (null == instance)
// {
// instance = new ScreenManager();
// }
// return instance;
// }
//
// /**
// * Initializes the game property
// *
// * @param game
// */
// public void initialize(JastroBlast game)
// {
// this.game = game;
// }
//
// /**
// * Tells the game to switch screens
// *
// * @param screen
// */
// public void show(Screens screen)
// {
// if (null == game)
// {
// return;
// }
// if (!screens.containsKey(screen.ordinal()))
// {
// screens.put(screen.ordinal(), screen.getScreenInstance());
// }
// this.game.setScreen(screens.get(screen.ordinal()));
// }
//
// public Screen get(Screens screen)
// {
// if (!screens.containsKey(screen.ordinal()))
// {
// screens.put(screen.ordinal(), screen.getScreenInstance());
// }
// return screens.get(screen.ordinal());
// }
//
// public void dispose(Screens screen)
// {
// if(!screens.containsKey(screen.ordinal()))
// {
// return;
// }
// screens.remove(screen.ordinal()).dispose();
// }
//
// public void dispose()
// {
// for (Screen screen : screens.values())
// {
// screen.dispose();
// }
// screens.clear();
// instance = null;
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/screen/AbstractScreen.java
// public abstract class AbstractScreen implements Screen
// {
// protected Menu menu;
// public Menu getMenu() { return this.menu; }
//
// public AbstractScreen()
// {
// }
//
// public abstract void transitionScreen();
//
//
// @Override
// public void render(float delta) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resize(int width, int height) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void show() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void hide() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
//
// }
//
// }
// Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Menu.java
import java.util.List;
import org.doublelong.jastroblast.managers.ScreenManager;
import org.doublelong.jastroblast.screen.AbstractScreen;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
package org.doublelong.jastroblast.entity;
public abstract class Menu
{
public int currentMenuIndex;
public List<MenuButton> elements;
private Actor cursor; | private AbstractScreen currentScreen; |
xzela/jastroblast | jastroblast-core/src/org/doublelong/jastroblast/entity/Menu.java | // Path: jastroblast-core/src/org/doublelong/jastroblast/managers/ScreenManager.java
// public final class ScreenManager
// {
// private static ScreenManager instance;
//
// private JastroBlast game;
//
// private IntMap<Screen> screens;
//
// private ScreenManager() {
// screens = new IntMap<Screen>();
// }
//
// public static ScreenManager getInstance()
// {
// if (null == instance)
// {
// instance = new ScreenManager();
// }
// return instance;
// }
//
// /**
// * Initializes the game property
// *
// * @param game
// */
// public void initialize(JastroBlast game)
// {
// this.game = game;
// }
//
// /**
// * Tells the game to switch screens
// *
// * @param screen
// */
// public void show(Screens screen)
// {
// if (null == game)
// {
// return;
// }
// if (!screens.containsKey(screen.ordinal()))
// {
// screens.put(screen.ordinal(), screen.getScreenInstance());
// }
// this.game.setScreen(screens.get(screen.ordinal()));
// }
//
// public Screen get(Screens screen)
// {
// if (!screens.containsKey(screen.ordinal()))
// {
// screens.put(screen.ordinal(), screen.getScreenInstance());
// }
// return screens.get(screen.ordinal());
// }
//
// public void dispose(Screens screen)
// {
// if(!screens.containsKey(screen.ordinal()))
// {
// return;
// }
// screens.remove(screen.ordinal()).dispose();
// }
//
// public void dispose()
// {
// for (Screen screen : screens.values())
// {
// screen.dispose();
// }
// screens.clear();
// instance = null;
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/screen/AbstractScreen.java
// public abstract class AbstractScreen implements Screen
// {
// protected Menu menu;
// public Menu getMenu() { return this.menu; }
//
// public AbstractScreen()
// {
// }
//
// public abstract void transitionScreen();
//
//
// @Override
// public void render(float delta) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resize(int width, int height) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void show() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void hide() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
//
// }
//
// }
| import java.util.List;
import org.doublelong.jastroblast.managers.ScreenManager;
import org.doublelong.jastroblast.screen.AbstractScreen;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table; | this.currentMenuIndex++;
}
}
public void updateCursor()
{
Label button = this.elements.get(this.currentMenuIndex).getLabel();
this.setCursorPosition(button);
//this.currentScreen = (AbstractScreen) this.elements.get(this.currentMenuIndex).getScreen();
}
public void setCursorPosition(Label element)
{
Vector2 pos = new Vector2(element.getX(), element.getY());
this.cursor.setX(pos.x - (this.cursor.getWidth() + 10f));
this.cursor.setY(pos.y + 5f);
}
private boolean atTop()
{
return this.currentMenuIndex == 0;
}
private boolean atBottom()
{
return this.currentMenuIndex == this.elements.size() - 1;
}
public void showScreen(Screens screen)
{ | // Path: jastroblast-core/src/org/doublelong/jastroblast/managers/ScreenManager.java
// public final class ScreenManager
// {
// private static ScreenManager instance;
//
// private JastroBlast game;
//
// private IntMap<Screen> screens;
//
// private ScreenManager() {
// screens = new IntMap<Screen>();
// }
//
// public static ScreenManager getInstance()
// {
// if (null == instance)
// {
// instance = new ScreenManager();
// }
// return instance;
// }
//
// /**
// * Initializes the game property
// *
// * @param game
// */
// public void initialize(JastroBlast game)
// {
// this.game = game;
// }
//
// /**
// * Tells the game to switch screens
// *
// * @param screen
// */
// public void show(Screens screen)
// {
// if (null == game)
// {
// return;
// }
// if (!screens.containsKey(screen.ordinal()))
// {
// screens.put(screen.ordinal(), screen.getScreenInstance());
// }
// this.game.setScreen(screens.get(screen.ordinal()));
// }
//
// public Screen get(Screens screen)
// {
// if (!screens.containsKey(screen.ordinal()))
// {
// screens.put(screen.ordinal(), screen.getScreenInstance());
// }
// return screens.get(screen.ordinal());
// }
//
// public void dispose(Screens screen)
// {
// if(!screens.containsKey(screen.ordinal()))
// {
// return;
// }
// screens.remove(screen.ordinal()).dispose();
// }
//
// public void dispose()
// {
// for (Screen screen : screens.values())
// {
// screen.dispose();
// }
// screens.clear();
// instance = null;
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/screen/AbstractScreen.java
// public abstract class AbstractScreen implements Screen
// {
// protected Menu menu;
// public Menu getMenu() { return this.menu; }
//
// public AbstractScreen()
// {
// }
//
// public abstract void transitionScreen();
//
//
// @Override
// public void render(float delta) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resize(int width, int height) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void show() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void hide() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void pause() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void dispose() {
// // TODO Auto-generated method stub
//
// }
//
// }
// Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Menu.java
import java.util.List;
import org.doublelong.jastroblast.managers.ScreenManager;
import org.doublelong.jastroblast.screen.AbstractScreen;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
this.currentMenuIndex++;
}
}
public void updateCursor()
{
Label button = this.elements.get(this.currentMenuIndex).getLabel();
this.setCursorPosition(button);
//this.currentScreen = (AbstractScreen) this.elements.get(this.currentMenuIndex).getScreen();
}
public void setCursorPosition(Label element)
{
Vector2 pos = new Vector2(element.getX(), element.getY());
this.cursor.setX(pos.x - (this.cursor.getWidth() + 10f));
this.cursor.setY(pos.y + 5f);
}
private boolean atTop()
{
return this.currentMenuIndex == 0;
}
private boolean atBottom()
{
return this.currentMenuIndex == this.elements.size() - 1;
}
public void showScreen(Screens screen)
{ | ScreenManager.getInstance().show(screen); |
xzela/jastroblast | jastroblast-core/src/org/doublelong/jastroblast/renderer/AsteroidRenderer.java | // Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Asteroid.java
// public class Asteroid
// {
//
// private final Space space;
// public final Space getSpace() {return this.space; }
//
// // TODO fix Height/Width, should be associated with the sprite
// private static final float WIDTH = 136f;
// private static final float HEIGHT = 111f;
//
// private final Vector2 position;
// public Vector2 getPosition() { return this.position; }
//
// private final Rectangle bounds;
// public Rectangle getBounds() { return this.bounds; }
//
// public float getWidth() { return this.bounds.width; }
// public float getHeight() { return this.bounds.height; }
//
// private final Vector2 velocity;
//
// private float angle;
// public float getAngle() { return this.angle; }
// public void setAngle(float angle) { this.angle = angle; }
//
// private final float spin;
// private final int direction;
//
// public AsteroidRenderer renderer;
//
// public Asteroid(Space space, Vector2 position)
// {
// this.space = space;
// this.position = position;
// this.velocity = new Vector2();
// this.bounds = new Rectangle(this.position.x, this.position.y, Asteroid.WIDTH, Asteroid.HEIGHT);
//
// this.spin = (float) Math.random() * 100;
// this.direction = new Random().nextBoolean() ? 1 : -1;
//
// this.renderer = new AsteroidRenderer(this);
// }
//
// public void render(SpriteBatch batch, OrthographicCamera cam)
// {
// this.renderer.render(batch, cam);
// }
//
// public void update(float delta)
// {
// //System.out.println(this.angle);
// if (Math.abs(this.angle) > 360)
// {
// this.angle = 0;
// }
// if(Math.abs(this.angle) < 0)
// {
// this.angle = 360 * this.direction;
// }
// this.angle += this.direction * this.spin * delta;
// //this.setAngle(this.direction * this.spin * delta);
//
// float scale_x = this.direction * (delta * 10f);
// float scale_y = this.direction * (delta * 10f);
//
// this.position.add(new Vector2(scale_x, scale_y));
// }
//
// public void dispose()
// {
// this.renderer.dispose();
// }
// }
| import org.doublelong.jastroblast.entity.Asteroid;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; | package org.doublelong.jastroblast.renderer;
public class AsteroidRenderer extends BaseRenderer
{
| // Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Asteroid.java
// public class Asteroid
// {
//
// private final Space space;
// public final Space getSpace() {return this.space; }
//
// // TODO fix Height/Width, should be associated with the sprite
// private static final float WIDTH = 136f;
// private static final float HEIGHT = 111f;
//
// private final Vector2 position;
// public Vector2 getPosition() { return this.position; }
//
// private final Rectangle bounds;
// public Rectangle getBounds() { return this.bounds; }
//
// public float getWidth() { return this.bounds.width; }
// public float getHeight() { return this.bounds.height; }
//
// private final Vector2 velocity;
//
// private float angle;
// public float getAngle() { return this.angle; }
// public void setAngle(float angle) { this.angle = angle; }
//
// private final float spin;
// private final int direction;
//
// public AsteroidRenderer renderer;
//
// public Asteroid(Space space, Vector2 position)
// {
// this.space = space;
// this.position = position;
// this.velocity = new Vector2();
// this.bounds = new Rectangle(this.position.x, this.position.y, Asteroid.WIDTH, Asteroid.HEIGHT);
//
// this.spin = (float) Math.random() * 100;
// this.direction = new Random().nextBoolean() ? 1 : -1;
//
// this.renderer = new AsteroidRenderer(this);
// }
//
// public void render(SpriteBatch batch, OrthographicCamera cam)
// {
// this.renderer.render(batch, cam);
// }
//
// public void update(float delta)
// {
// //System.out.println(this.angle);
// if (Math.abs(this.angle) > 360)
// {
// this.angle = 0;
// }
// if(Math.abs(this.angle) < 0)
// {
// this.angle = 360 * this.direction;
// }
// this.angle += this.direction * this.spin * delta;
// //this.setAngle(this.direction * this.spin * delta);
//
// float scale_x = this.direction * (delta * 10f);
// float scale_y = this.direction * (delta * 10f);
//
// this.position.add(new Vector2(scale_x, scale_y));
// }
//
// public void dispose()
// {
// this.renderer.dispose();
// }
// }
// Path: jastroblast-core/src/org/doublelong/jastroblast/renderer/AsteroidRenderer.java
import org.doublelong.jastroblast.entity.Asteroid;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
package org.doublelong.jastroblast.renderer;
public class AsteroidRenderer extends BaseRenderer
{
| private final Asteroid asteroid; |
xzela/jastroblast | jastroblast-desktop/src/org/doublelong/tests/Box2dTest.java | // Path: jastroblast-desktop/src/org/doublelong/tests/entities/Ship.java
// public class Ship
// {
// private final World world;
//
// public ShipController controller;
//
// private final Vector2[] vertices;
// public Vector2[] getVertices() { return this.vertices; }
//
// private final Body body;
// public Body getBody() { return this.body; }
//
// private final BodyDef bodyDef = new BodyDef();
// public BodyDef getBodyDef() { return this.bodyDef; }
//
// private final FixtureDef fixtureDef = new FixtureDef();
// public FixtureDef getFixtureDef() { return this.fixtureDef; }
//
// private final Fixture fixture;
// public Fixture getFixture() { return this.fixture; }
//
// private final PolygonShape shape = new PolygonShape();
// public PolygonShape getShape() { return this.shape; }
//
// public Ship(World world)
// {
// this.world = world;
// this.vertices = this.createVertices();
// this.bodyDef.type = BodyType.DynamicBody;
// this.bodyDef.position.set(new Vector2(125f,100f));
// //this.shape.set(this.vertices);
// this.shape.setAsBox(20f, 20f);
//
//
// this.fixtureDef.shape = this.shape;
// this.fixtureDef.density = .01f;
// this.fixtureDef.friction = .0f;
// this.fixtureDef.restitution = .5f;
//
// // set the world stuff
// this.body = this.world.createBody(bodyDef);
// // this.body.createFixture(this.shape, 0f);
// this.fixture = this.body.createFixture(this.fixtureDef);
//
//
// this.controller = new ShipController(this);
// }
//
// private Vector2[] createVertices()
// {
// Vector2[] vertices = new Vector2[3];
// vertices[0] = new Vector2(-20, 0);
// vertices[1] = new Vector2(10, 0);
// vertices[2] = new Vector2(0, 20);
// return vertices;
// }
//
// public void update()
// {
// // update logic here!
//
// }
//
// public void dispose()
// {
// this.shape.dispose();
// }
//
// public Vector2 getLocalVelocity()
// {
// return this.body.getLocalVector(this.body.getLinearVelocityFromLocalPoint(this.getBody().getPosition()));
// }
// }
| import org.doublelong.tests.entities.Ship;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World; | package org.doublelong.tests;
/**
* Stolen from: http://programmersweb.blogspot.com/2012/07/simple-libgdx-box2d-bouncing-ball.html
* http://www.badlogicgames.com/wordpress/?p=2017
*
*/
public class Box2dTest implements ApplicationListener
{
World world; | // Path: jastroblast-desktop/src/org/doublelong/tests/entities/Ship.java
// public class Ship
// {
// private final World world;
//
// public ShipController controller;
//
// private final Vector2[] vertices;
// public Vector2[] getVertices() { return this.vertices; }
//
// private final Body body;
// public Body getBody() { return this.body; }
//
// private final BodyDef bodyDef = new BodyDef();
// public BodyDef getBodyDef() { return this.bodyDef; }
//
// private final FixtureDef fixtureDef = new FixtureDef();
// public FixtureDef getFixtureDef() { return this.fixtureDef; }
//
// private final Fixture fixture;
// public Fixture getFixture() { return this.fixture; }
//
// private final PolygonShape shape = new PolygonShape();
// public PolygonShape getShape() { return this.shape; }
//
// public Ship(World world)
// {
// this.world = world;
// this.vertices = this.createVertices();
// this.bodyDef.type = BodyType.DynamicBody;
// this.bodyDef.position.set(new Vector2(125f,100f));
// //this.shape.set(this.vertices);
// this.shape.setAsBox(20f, 20f);
//
//
// this.fixtureDef.shape = this.shape;
// this.fixtureDef.density = .01f;
// this.fixtureDef.friction = .0f;
// this.fixtureDef.restitution = .5f;
//
// // set the world stuff
// this.body = this.world.createBody(bodyDef);
// // this.body.createFixture(this.shape, 0f);
// this.fixture = this.body.createFixture(this.fixtureDef);
//
//
// this.controller = new ShipController(this);
// }
//
// private Vector2[] createVertices()
// {
// Vector2[] vertices = new Vector2[3];
// vertices[0] = new Vector2(-20, 0);
// vertices[1] = new Vector2(10, 0);
// vertices[2] = new Vector2(0, 20);
// return vertices;
// }
//
// public void update()
// {
// // update logic here!
//
// }
//
// public void dispose()
// {
// this.shape.dispose();
// }
//
// public Vector2 getLocalVelocity()
// {
// return this.body.getLocalVector(this.body.getLinearVelocityFromLocalPoint(this.getBody().getPosition()));
// }
// }
// Path: jastroblast-desktop/src/org/doublelong/tests/Box2dTest.java
import org.doublelong.tests.entities.Ship;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World;
package org.doublelong.tests;
/**
* Stolen from: http://programmersweb.blogspot.com/2012/07/simple-libgdx-box2d-bouncing-ball.html
* http://www.badlogicgames.com/wordpress/?p=2017
*
*/
public class Box2dTest implements ApplicationListener
{
World world; | Ship ship; |
xzela/jastroblast | jastroblast-desktop/src/org/doublelong/tests/controller/ShipController.java | // Path: jastroblast-desktop/src/org/doublelong/tests/entities/Ship.java
// public class Ship
// {
// private final World world;
//
// public ShipController controller;
//
// private final Vector2[] vertices;
// public Vector2[] getVertices() { return this.vertices; }
//
// private final Body body;
// public Body getBody() { return this.body; }
//
// private final BodyDef bodyDef = new BodyDef();
// public BodyDef getBodyDef() { return this.bodyDef; }
//
// private final FixtureDef fixtureDef = new FixtureDef();
// public FixtureDef getFixtureDef() { return this.fixtureDef; }
//
// private final Fixture fixture;
// public Fixture getFixture() { return this.fixture; }
//
// private final PolygonShape shape = new PolygonShape();
// public PolygonShape getShape() { return this.shape; }
//
// public Ship(World world)
// {
// this.world = world;
// this.vertices = this.createVertices();
// this.bodyDef.type = BodyType.DynamicBody;
// this.bodyDef.position.set(new Vector2(125f,100f));
// //this.shape.set(this.vertices);
// this.shape.setAsBox(20f, 20f);
//
//
// this.fixtureDef.shape = this.shape;
// this.fixtureDef.density = .01f;
// this.fixtureDef.friction = .0f;
// this.fixtureDef.restitution = .5f;
//
// // set the world stuff
// this.body = this.world.createBody(bodyDef);
// // this.body.createFixture(this.shape, 0f);
// this.fixture = this.body.createFixture(this.fixtureDef);
//
//
// this.controller = new ShipController(this);
// }
//
// private Vector2[] createVertices()
// {
// Vector2[] vertices = new Vector2[3];
// vertices[0] = new Vector2(-20, 0);
// vertices[1] = new Vector2(10, 0);
// vertices[2] = new Vector2(0, 20);
// return vertices;
// }
//
// public void update()
// {
// // update logic here!
//
// }
//
// public void dispose()
// {
// this.shape.dispose();
// }
//
// public Vector2 getLocalVelocity()
// {
// return this.body.getLocalVector(this.body.getLinearVelocityFromLocalPoint(this.getBody().getPosition()));
// }
// }
| import org.doublelong.tests.entities.Ship;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.math.Vector2; | package org.doublelong.tests.controller;
public class ShipController extends InputAdapter
{
private final static float MAX_VELOCITY = 100f; | // Path: jastroblast-desktop/src/org/doublelong/tests/entities/Ship.java
// public class Ship
// {
// private final World world;
//
// public ShipController controller;
//
// private final Vector2[] vertices;
// public Vector2[] getVertices() { return this.vertices; }
//
// private final Body body;
// public Body getBody() { return this.body; }
//
// private final BodyDef bodyDef = new BodyDef();
// public BodyDef getBodyDef() { return this.bodyDef; }
//
// private final FixtureDef fixtureDef = new FixtureDef();
// public FixtureDef getFixtureDef() { return this.fixtureDef; }
//
// private final Fixture fixture;
// public Fixture getFixture() { return this.fixture; }
//
// private final PolygonShape shape = new PolygonShape();
// public PolygonShape getShape() { return this.shape; }
//
// public Ship(World world)
// {
// this.world = world;
// this.vertices = this.createVertices();
// this.bodyDef.type = BodyType.DynamicBody;
// this.bodyDef.position.set(new Vector2(125f,100f));
// //this.shape.set(this.vertices);
// this.shape.setAsBox(20f, 20f);
//
//
// this.fixtureDef.shape = this.shape;
// this.fixtureDef.density = .01f;
// this.fixtureDef.friction = .0f;
// this.fixtureDef.restitution = .5f;
//
// // set the world stuff
// this.body = this.world.createBody(bodyDef);
// // this.body.createFixture(this.shape, 0f);
// this.fixture = this.body.createFixture(this.fixtureDef);
//
//
// this.controller = new ShipController(this);
// }
//
// private Vector2[] createVertices()
// {
// Vector2[] vertices = new Vector2[3];
// vertices[0] = new Vector2(-20, 0);
// vertices[1] = new Vector2(10, 0);
// vertices[2] = new Vector2(0, 20);
// return vertices;
// }
//
// public void update()
// {
// // update logic here!
//
// }
//
// public void dispose()
// {
// this.shape.dispose();
// }
//
// public Vector2 getLocalVelocity()
// {
// return this.body.getLocalVector(this.body.getLinearVelocityFromLocalPoint(this.getBody().getPosition()));
// }
// }
// Path: jastroblast-desktop/src/org/doublelong/tests/controller/ShipController.java
import org.doublelong.tests.entities.Ship;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.math.Vector2;
package org.doublelong.tests.controller;
public class ShipController extends InputAdapter
{
private final static float MAX_VELOCITY = 100f; | private final Ship ship; |
xzela/jastroblast | jastroblast-core/src/org/doublelong/jastroblast/screen/AbstractScreen.java | // Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Menu.java
// public abstract class Menu
// {
//
// public int currentMenuIndex;
// public List<MenuButton> elements;
// private Actor cursor;
// private AbstractScreen currentScreen;
// public AbstractScreen getCurrentScreen() { return this.currentScreen; }
//
// protected Table table;
// public Table getTable() { return this.table; }
//
//
// public Menu(Actor cursor)
// {
// this.currentMenuIndex = 0;
// this.cursor = cursor;
// }
//
// public void moveUp()
// {
// if(!this.atTop())
// {
// this.currentMenuIndex--;
// }
// }
//
// public void moveDown()
// {
// if(!this.atBottom())
// {
// this.currentMenuIndex++;
// }
// }
//
// public void updateCursor()
// {
// Label button = this.elements.get(this.currentMenuIndex).getLabel();
// this.setCursorPosition(button);
// //this.currentScreen = (AbstractScreen) this.elements.get(this.currentMenuIndex).getScreen();
// }
//
// public void setCursorPosition(Label element)
// {
// Vector2 pos = new Vector2(element.getX(), element.getY());
// this.cursor.setX(pos.x - (this.cursor.getWidth() + 10f));
// this.cursor.setY(pos.y + 5f);
// }
//
// private boolean atTop()
// {
// return this.currentMenuIndex == 0;
// }
//
// private boolean atBottom()
// {
// return this.currentMenuIndex == this.elements.size() - 1;
// }
//
// public void showScreen(Screens screen)
// {
// ScreenManager.getInstance().show(screen);
// }
//
// public Screen getScreen(Screens screen)
// {
// return ScreenManager.getInstance().get(screen);
// }
//
// protected void initializeTable()
// {
// //this.table.debug();
// this.table.setFillParent(true);
//
// for(MenuButton button : this.elements)
// {
// this.table.add(button.renderLabel()).left();
// this.table.row();
// }
// }
// }
| import org.doublelong.jastroblast.entity.Menu;
import com.badlogic.gdx.Screen; | package org.doublelong.jastroblast.screen;
public abstract class AbstractScreen implements Screen
{ | // Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Menu.java
// public abstract class Menu
// {
//
// public int currentMenuIndex;
// public List<MenuButton> elements;
// private Actor cursor;
// private AbstractScreen currentScreen;
// public AbstractScreen getCurrentScreen() { return this.currentScreen; }
//
// protected Table table;
// public Table getTable() { return this.table; }
//
//
// public Menu(Actor cursor)
// {
// this.currentMenuIndex = 0;
// this.cursor = cursor;
// }
//
// public void moveUp()
// {
// if(!this.atTop())
// {
// this.currentMenuIndex--;
// }
// }
//
// public void moveDown()
// {
// if(!this.atBottom())
// {
// this.currentMenuIndex++;
// }
// }
//
// public void updateCursor()
// {
// Label button = this.elements.get(this.currentMenuIndex).getLabel();
// this.setCursorPosition(button);
// //this.currentScreen = (AbstractScreen) this.elements.get(this.currentMenuIndex).getScreen();
// }
//
// public void setCursorPosition(Label element)
// {
// Vector2 pos = new Vector2(element.getX(), element.getY());
// this.cursor.setX(pos.x - (this.cursor.getWidth() + 10f));
// this.cursor.setY(pos.y + 5f);
// }
//
// private boolean atTop()
// {
// return this.currentMenuIndex == 0;
// }
//
// private boolean atBottom()
// {
// return this.currentMenuIndex == this.elements.size() - 1;
// }
//
// public void showScreen(Screens screen)
// {
// ScreenManager.getInstance().show(screen);
// }
//
// public Screen getScreen(Screens screen)
// {
// return ScreenManager.getInstance().get(screen);
// }
//
// protected void initializeTable()
// {
// //this.table.debug();
// this.table.setFillParent(true);
//
// for(MenuButton button : this.elements)
// {
// this.table.add(button.renderLabel()).left();
// this.table.row();
// }
// }
// }
// Path: jastroblast-core/src/org/doublelong/jastroblast/screen/AbstractScreen.java
import org.doublelong.jastroblast.entity.Menu;
import com.badlogic.gdx.Screen;
package org.doublelong.jastroblast.screen;
public abstract class AbstractScreen implements Screen
{ | protected Menu menu; |
xzela/jastroblast | jastroblast-core/src/org/doublelong/jastroblast/JastroBlast.java | // Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Screens.java
// public enum Screens
// {
// LOADING {
// @Override
// public Screen getScreenInstance()
// {
// return new LoadingScreen();
// }
// },
// MAIN {
// @Override
// public Screen getScreenInstance()
// {
// return new MainScreen();
// }
// },
// GAME {
// @Override
// public Screen getScreenInstance()
// {
// return new JastroScreen();
// }
// },
// CREDITS {
// @Override
// public Screen getScreenInstance()
// {
// return new CreditsScreen();
// }
// },
// QUIT {
// @Override
// public Screen getScreenInstance()
// {
// return new QuitScreen();
// }
// };
//
// public abstract Screen getScreenInstance();
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/managers/ScreenManager.java
// public final class ScreenManager
// {
// private static ScreenManager instance;
//
// private JastroBlast game;
//
// private IntMap<Screen> screens;
//
// private ScreenManager() {
// screens = new IntMap<Screen>();
// }
//
// public static ScreenManager getInstance()
// {
// if (null == instance)
// {
// instance = new ScreenManager();
// }
// return instance;
// }
//
// /**
// * Initializes the game property
// *
// * @param game
// */
// public void initialize(JastroBlast game)
// {
// this.game = game;
// }
//
// /**
// * Tells the game to switch screens
// *
// * @param screen
// */
// public void show(Screens screen)
// {
// if (null == game)
// {
// return;
// }
// if (!screens.containsKey(screen.ordinal()))
// {
// screens.put(screen.ordinal(), screen.getScreenInstance());
// }
// this.game.setScreen(screens.get(screen.ordinal()));
// }
//
// public Screen get(Screens screen)
// {
// if (!screens.containsKey(screen.ordinal()))
// {
// screens.put(screen.ordinal(), screen.getScreenInstance());
// }
// return screens.get(screen.ordinal());
// }
//
// public void dispose(Screens screen)
// {
// if(!screens.containsKey(screen.ordinal()))
// {
// return;
// }
// screens.remove(screen.ordinal()).dispose();
// }
//
// public void dispose()
// {
// for (Screen screen : screens.values())
// {
// screen.dispose();
// }
// screens.clear();
// instance = null;
// }
// }
| import org.doublelong.jastroblast.entity.Screens;
import org.doublelong.jastroblast.managers.ScreenManager;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Texture; | package org.doublelong.jastroblast;
public class JastroBlast extends Game
{
public final String WINDOW_TITLE = "jAstroBlast";
public static final int WINDOW_WIDTH = 800;
public static final int WINDOW_HEIGHT = 600;
public static AssetManager manager = new AssetManager();
public static final boolean DEBUG = true;
@Override
public void create()
{ | // Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Screens.java
// public enum Screens
// {
// LOADING {
// @Override
// public Screen getScreenInstance()
// {
// return new LoadingScreen();
// }
// },
// MAIN {
// @Override
// public Screen getScreenInstance()
// {
// return new MainScreen();
// }
// },
// GAME {
// @Override
// public Screen getScreenInstance()
// {
// return new JastroScreen();
// }
// },
// CREDITS {
// @Override
// public Screen getScreenInstance()
// {
// return new CreditsScreen();
// }
// },
// QUIT {
// @Override
// public Screen getScreenInstance()
// {
// return new QuitScreen();
// }
// };
//
// public abstract Screen getScreenInstance();
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/managers/ScreenManager.java
// public final class ScreenManager
// {
// private static ScreenManager instance;
//
// private JastroBlast game;
//
// private IntMap<Screen> screens;
//
// private ScreenManager() {
// screens = new IntMap<Screen>();
// }
//
// public static ScreenManager getInstance()
// {
// if (null == instance)
// {
// instance = new ScreenManager();
// }
// return instance;
// }
//
// /**
// * Initializes the game property
// *
// * @param game
// */
// public void initialize(JastroBlast game)
// {
// this.game = game;
// }
//
// /**
// * Tells the game to switch screens
// *
// * @param screen
// */
// public void show(Screens screen)
// {
// if (null == game)
// {
// return;
// }
// if (!screens.containsKey(screen.ordinal()))
// {
// screens.put(screen.ordinal(), screen.getScreenInstance());
// }
// this.game.setScreen(screens.get(screen.ordinal()));
// }
//
// public Screen get(Screens screen)
// {
// if (!screens.containsKey(screen.ordinal()))
// {
// screens.put(screen.ordinal(), screen.getScreenInstance());
// }
// return screens.get(screen.ordinal());
// }
//
// public void dispose(Screens screen)
// {
// if(!screens.containsKey(screen.ordinal()))
// {
// return;
// }
// screens.remove(screen.ordinal()).dispose();
// }
//
// public void dispose()
// {
// for (Screen screen : screens.values())
// {
// screen.dispose();
// }
// screens.clear();
// instance = null;
// }
// }
// Path: jastroblast-core/src/org/doublelong/jastroblast/JastroBlast.java
import org.doublelong.jastroblast.entity.Screens;
import org.doublelong.jastroblast.managers.ScreenManager;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Texture;
package org.doublelong.jastroblast;
public class JastroBlast extends Game
{
public final String WINDOW_TITLE = "jAstroBlast";
public static final int WINDOW_WIDTH = 800;
public static final int WINDOW_HEIGHT = 600;
public static AssetManager manager = new AssetManager();
public static final boolean DEBUG = true;
@Override
public void create()
{ | ScreenManager.getInstance().initialize(this); |
xzela/jastroblast | jastroblast-core/src/org/doublelong/jastroblast/JastroBlast.java | // Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Screens.java
// public enum Screens
// {
// LOADING {
// @Override
// public Screen getScreenInstance()
// {
// return new LoadingScreen();
// }
// },
// MAIN {
// @Override
// public Screen getScreenInstance()
// {
// return new MainScreen();
// }
// },
// GAME {
// @Override
// public Screen getScreenInstance()
// {
// return new JastroScreen();
// }
// },
// CREDITS {
// @Override
// public Screen getScreenInstance()
// {
// return new CreditsScreen();
// }
// },
// QUIT {
// @Override
// public Screen getScreenInstance()
// {
// return new QuitScreen();
// }
// };
//
// public abstract Screen getScreenInstance();
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/managers/ScreenManager.java
// public final class ScreenManager
// {
// private static ScreenManager instance;
//
// private JastroBlast game;
//
// private IntMap<Screen> screens;
//
// private ScreenManager() {
// screens = new IntMap<Screen>();
// }
//
// public static ScreenManager getInstance()
// {
// if (null == instance)
// {
// instance = new ScreenManager();
// }
// return instance;
// }
//
// /**
// * Initializes the game property
// *
// * @param game
// */
// public void initialize(JastroBlast game)
// {
// this.game = game;
// }
//
// /**
// * Tells the game to switch screens
// *
// * @param screen
// */
// public void show(Screens screen)
// {
// if (null == game)
// {
// return;
// }
// if (!screens.containsKey(screen.ordinal()))
// {
// screens.put(screen.ordinal(), screen.getScreenInstance());
// }
// this.game.setScreen(screens.get(screen.ordinal()));
// }
//
// public Screen get(Screens screen)
// {
// if (!screens.containsKey(screen.ordinal()))
// {
// screens.put(screen.ordinal(), screen.getScreenInstance());
// }
// return screens.get(screen.ordinal());
// }
//
// public void dispose(Screens screen)
// {
// if(!screens.containsKey(screen.ordinal()))
// {
// return;
// }
// screens.remove(screen.ordinal()).dispose();
// }
//
// public void dispose()
// {
// for (Screen screen : screens.values())
// {
// screen.dispose();
// }
// screens.clear();
// instance = null;
// }
// }
| import org.doublelong.jastroblast.entity.Screens;
import org.doublelong.jastroblast.managers.ScreenManager;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Texture; | package org.doublelong.jastroblast;
public class JastroBlast extends Game
{
public final String WINDOW_TITLE = "jAstroBlast";
public static final int WINDOW_WIDTH = 800;
public static final int WINDOW_HEIGHT = 600;
public static AssetManager manager = new AssetManager();
public static final boolean DEBUG = true;
@Override
public void create()
{
ScreenManager.getInstance().initialize(this);
Texture.setEnforcePotImages(false); | // Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Screens.java
// public enum Screens
// {
// LOADING {
// @Override
// public Screen getScreenInstance()
// {
// return new LoadingScreen();
// }
// },
// MAIN {
// @Override
// public Screen getScreenInstance()
// {
// return new MainScreen();
// }
// },
// GAME {
// @Override
// public Screen getScreenInstance()
// {
// return new JastroScreen();
// }
// },
// CREDITS {
// @Override
// public Screen getScreenInstance()
// {
// return new CreditsScreen();
// }
// },
// QUIT {
// @Override
// public Screen getScreenInstance()
// {
// return new QuitScreen();
// }
// };
//
// public abstract Screen getScreenInstance();
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/managers/ScreenManager.java
// public final class ScreenManager
// {
// private static ScreenManager instance;
//
// private JastroBlast game;
//
// private IntMap<Screen> screens;
//
// private ScreenManager() {
// screens = new IntMap<Screen>();
// }
//
// public static ScreenManager getInstance()
// {
// if (null == instance)
// {
// instance = new ScreenManager();
// }
// return instance;
// }
//
// /**
// * Initializes the game property
// *
// * @param game
// */
// public void initialize(JastroBlast game)
// {
// this.game = game;
// }
//
// /**
// * Tells the game to switch screens
// *
// * @param screen
// */
// public void show(Screens screen)
// {
// if (null == game)
// {
// return;
// }
// if (!screens.containsKey(screen.ordinal()))
// {
// screens.put(screen.ordinal(), screen.getScreenInstance());
// }
// this.game.setScreen(screens.get(screen.ordinal()));
// }
//
// public Screen get(Screens screen)
// {
// if (!screens.containsKey(screen.ordinal()))
// {
// screens.put(screen.ordinal(), screen.getScreenInstance());
// }
// return screens.get(screen.ordinal());
// }
//
// public void dispose(Screens screen)
// {
// if(!screens.containsKey(screen.ordinal()))
// {
// return;
// }
// screens.remove(screen.ordinal()).dispose();
// }
//
// public void dispose()
// {
// for (Screen screen : screens.values())
// {
// screen.dispose();
// }
// screens.clear();
// instance = null;
// }
// }
// Path: jastroblast-core/src/org/doublelong/jastroblast/JastroBlast.java
import org.doublelong.jastroblast.entity.Screens;
import org.doublelong.jastroblast.managers.ScreenManager;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Texture;
package org.doublelong.jastroblast;
public class JastroBlast extends Game
{
public final String WINDOW_TITLE = "jAstroBlast";
public static final int WINDOW_WIDTH = 800;
public static final int WINDOW_HEIGHT = 600;
public static AssetManager manager = new AssetManager();
public static final boolean DEBUG = true;
@Override
public void create()
{
ScreenManager.getInstance().initialize(this);
Texture.setEnforcePotImages(false); | ScreenManager.getInstance().show(Screens.LOADING); |
xzela/jastroblast | jastroblast-core/src/org/doublelong/jastroblast/managers/ScreenManager.java | // Path: jastroblast-core/src/org/doublelong/jastroblast/JastroBlast.java
// public class JastroBlast extends Game
// {
// public final String WINDOW_TITLE = "jAstroBlast";
// public static final int WINDOW_WIDTH = 800;
// public static final int WINDOW_HEIGHT = 600;
//
// public static AssetManager manager = new AssetManager();
// public static final boolean DEBUG = true;
//
// @Override
// public void create()
// {
// ScreenManager.getInstance().initialize(this);
// Texture.setEnforcePotImages(false);
// ScreenManager.getInstance().show(Screens.LOADING);
// // ScreenManager.getInstance().show(Screens.GAME);
// }
//
// @Override
// public void dispose()
// {
// super.dispose();
// ScreenManager.getInstance().dispose();
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Screens.java
// public enum Screens
// {
// LOADING {
// @Override
// public Screen getScreenInstance()
// {
// return new LoadingScreen();
// }
// },
// MAIN {
// @Override
// public Screen getScreenInstance()
// {
// return new MainScreen();
// }
// },
// GAME {
// @Override
// public Screen getScreenInstance()
// {
// return new JastroScreen();
// }
// },
// CREDITS {
// @Override
// public Screen getScreenInstance()
// {
// return new CreditsScreen();
// }
// },
// QUIT {
// @Override
// public Screen getScreenInstance()
// {
// return new QuitScreen();
// }
// };
//
// public abstract Screen getScreenInstance();
// }
| import org.doublelong.jastroblast.JastroBlast;
import org.doublelong.jastroblast.entity.Screens;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.utils.IntMap; | package org.doublelong.jastroblast.managers;
public final class ScreenManager
{
private static ScreenManager instance;
| // Path: jastroblast-core/src/org/doublelong/jastroblast/JastroBlast.java
// public class JastroBlast extends Game
// {
// public final String WINDOW_TITLE = "jAstroBlast";
// public static final int WINDOW_WIDTH = 800;
// public static final int WINDOW_HEIGHT = 600;
//
// public static AssetManager manager = new AssetManager();
// public static final boolean DEBUG = true;
//
// @Override
// public void create()
// {
// ScreenManager.getInstance().initialize(this);
// Texture.setEnforcePotImages(false);
// ScreenManager.getInstance().show(Screens.LOADING);
// // ScreenManager.getInstance().show(Screens.GAME);
// }
//
// @Override
// public void dispose()
// {
// super.dispose();
// ScreenManager.getInstance().dispose();
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Screens.java
// public enum Screens
// {
// LOADING {
// @Override
// public Screen getScreenInstance()
// {
// return new LoadingScreen();
// }
// },
// MAIN {
// @Override
// public Screen getScreenInstance()
// {
// return new MainScreen();
// }
// },
// GAME {
// @Override
// public Screen getScreenInstance()
// {
// return new JastroScreen();
// }
// },
// CREDITS {
// @Override
// public Screen getScreenInstance()
// {
// return new CreditsScreen();
// }
// },
// QUIT {
// @Override
// public Screen getScreenInstance()
// {
// return new QuitScreen();
// }
// };
//
// public abstract Screen getScreenInstance();
// }
// Path: jastroblast-core/src/org/doublelong/jastroblast/managers/ScreenManager.java
import org.doublelong.jastroblast.JastroBlast;
import org.doublelong.jastroblast.entity.Screens;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.utils.IntMap;
package org.doublelong.jastroblast.managers;
public final class ScreenManager
{
private static ScreenManager instance;
| private JastroBlast game; |
xzela/jastroblast | jastroblast-core/src/org/doublelong/jastroblast/managers/ScreenManager.java | // Path: jastroblast-core/src/org/doublelong/jastroblast/JastroBlast.java
// public class JastroBlast extends Game
// {
// public final String WINDOW_TITLE = "jAstroBlast";
// public static final int WINDOW_WIDTH = 800;
// public static final int WINDOW_HEIGHT = 600;
//
// public static AssetManager manager = new AssetManager();
// public static final boolean DEBUG = true;
//
// @Override
// public void create()
// {
// ScreenManager.getInstance().initialize(this);
// Texture.setEnforcePotImages(false);
// ScreenManager.getInstance().show(Screens.LOADING);
// // ScreenManager.getInstance().show(Screens.GAME);
// }
//
// @Override
// public void dispose()
// {
// super.dispose();
// ScreenManager.getInstance().dispose();
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Screens.java
// public enum Screens
// {
// LOADING {
// @Override
// public Screen getScreenInstance()
// {
// return new LoadingScreen();
// }
// },
// MAIN {
// @Override
// public Screen getScreenInstance()
// {
// return new MainScreen();
// }
// },
// GAME {
// @Override
// public Screen getScreenInstance()
// {
// return new JastroScreen();
// }
// },
// CREDITS {
// @Override
// public Screen getScreenInstance()
// {
// return new CreditsScreen();
// }
// },
// QUIT {
// @Override
// public Screen getScreenInstance()
// {
// return new QuitScreen();
// }
// };
//
// public abstract Screen getScreenInstance();
// }
| import org.doublelong.jastroblast.JastroBlast;
import org.doublelong.jastroblast.entity.Screens;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.utils.IntMap; | package org.doublelong.jastroblast.managers;
public final class ScreenManager
{
private static ScreenManager instance;
private JastroBlast game;
private IntMap<Screen> screens;
private ScreenManager() {
screens = new IntMap<Screen>();
}
public static ScreenManager getInstance()
{
if (null == instance)
{
instance = new ScreenManager();
}
return instance;
}
/**
* Initializes the game property
*
* @param game
*/
public void initialize(JastroBlast game)
{
this.game = game;
}
/**
* Tells the game to switch screens
*
* @param screen
*/ | // Path: jastroblast-core/src/org/doublelong/jastroblast/JastroBlast.java
// public class JastroBlast extends Game
// {
// public final String WINDOW_TITLE = "jAstroBlast";
// public static final int WINDOW_WIDTH = 800;
// public static final int WINDOW_HEIGHT = 600;
//
// public static AssetManager manager = new AssetManager();
// public static final boolean DEBUG = true;
//
// @Override
// public void create()
// {
// ScreenManager.getInstance().initialize(this);
// Texture.setEnforcePotImages(false);
// ScreenManager.getInstance().show(Screens.LOADING);
// // ScreenManager.getInstance().show(Screens.GAME);
// }
//
// @Override
// public void dispose()
// {
// super.dispose();
// ScreenManager.getInstance().dispose();
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Screens.java
// public enum Screens
// {
// LOADING {
// @Override
// public Screen getScreenInstance()
// {
// return new LoadingScreen();
// }
// },
// MAIN {
// @Override
// public Screen getScreenInstance()
// {
// return new MainScreen();
// }
// },
// GAME {
// @Override
// public Screen getScreenInstance()
// {
// return new JastroScreen();
// }
// },
// CREDITS {
// @Override
// public Screen getScreenInstance()
// {
// return new CreditsScreen();
// }
// },
// QUIT {
// @Override
// public Screen getScreenInstance()
// {
// return new QuitScreen();
// }
// };
//
// public abstract Screen getScreenInstance();
// }
// Path: jastroblast-core/src/org/doublelong/jastroblast/managers/ScreenManager.java
import org.doublelong.jastroblast.JastroBlast;
import org.doublelong.jastroblast.entity.Screens;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.utils.IntMap;
package org.doublelong.jastroblast.managers;
public final class ScreenManager
{
private static ScreenManager instance;
private JastroBlast game;
private IntMap<Screen> screens;
private ScreenManager() {
screens = new IntMap<Screen>();
}
public static ScreenManager getInstance()
{
if (null == instance)
{
instance = new ScreenManager();
}
return instance;
}
/**
* Initializes the game property
*
* @param game
*/
public void initialize(JastroBlast game)
{
this.game = game;
}
/**
* Tells the game to switch screens
*
* @param screen
*/ | public void show(Screens screen) |
xzela/jastroblast | jastroblast-core/src/org/doublelong/jastroblast/entity/Hud.java | // Path: jastroblast-core/src/org/doublelong/jastroblast/JastroBlast.java
// public class JastroBlast extends Game
// {
// public final String WINDOW_TITLE = "jAstroBlast";
// public static final int WINDOW_WIDTH = 800;
// public static final int WINDOW_HEIGHT = 600;
//
// public static AssetManager manager = new AssetManager();
// public static final boolean DEBUG = true;
//
// @Override
// public void create()
// {
// ScreenManager.getInstance().initialize(this);
// Texture.setEnforcePotImages(false);
// ScreenManager.getInstance().show(Screens.LOADING);
// // ScreenManager.getInstance().show(Screens.GAME);
// }
//
// @Override
// public void dispose()
// {
// super.dispose();
// ScreenManager.getInstance().dispose();
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/managers/FontManager.java
// public class FontManager
// {
// public static final String BLOCK_FONT = "assets/fonts/kenpixel_blocks.ttf";
// }
| import org.doublelong.jastroblast.JastroBlast;
import org.doublelong.jastroblast.managers.FontManager;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle; | package org.doublelong.jastroblast.entity;
public class Hud
{
private Space space;
private Stage stage;
private Label label;
private BitmapFont font;
public Hud(Space space)
{
this.space = space;
this.stage = new Stage(); | // Path: jastroblast-core/src/org/doublelong/jastroblast/JastroBlast.java
// public class JastroBlast extends Game
// {
// public final String WINDOW_TITLE = "jAstroBlast";
// public static final int WINDOW_WIDTH = 800;
// public static final int WINDOW_HEIGHT = 600;
//
// public static AssetManager manager = new AssetManager();
// public static final boolean DEBUG = true;
//
// @Override
// public void create()
// {
// ScreenManager.getInstance().initialize(this);
// Texture.setEnforcePotImages(false);
// ScreenManager.getInstance().show(Screens.LOADING);
// // ScreenManager.getInstance().show(Screens.GAME);
// }
//
// @Override
// public void dispose()
// {
// super.dispose();
// ScreenManager.getInstance().dispose();
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/managers/FontManager.java
// public class FontManager
// {
// public static final String BLOCK_FONT = "assets/fonts/kenpixel_blocks.ttf";
// }
// Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Hud.java
import org.doublelong.jastroblast.JastroBlast;
import org.doublelong.jastroblast.managers.FontManager;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
package org.doublelong.jastroblast.entity;
public class Hud
{
private Space space;
private Stage stage;
private Label label;
private BitmapFont font;
public Hud(Space space)
{
this.space = space;
this.stage = new Stage(); | this.font = JastroBlast.manager.get(FontManager.BLOCK_FONT, BitmapFont.class); |
xzela/jastroblast | jastroblast-core/src/org/doublelong/jastroblast/entity/Hud.java | // Path: jastroblast-core/src/org/doublelong/jastroblast/JastroBlast.java
// public class JastroBlast extends Game
// {
// public final String WINDOW_TITLE = "jAstroBlast";
// public static final int WINDOW_WIDTH = 800;
// public static final int WINDOW_HEIGHT = 600;
//
// public static AssetManager manager = new AssetManager();
// public static final boolean DEBUG = true;
//
// @Override
// public void create()
// {
// ScreenManager.getInstance().initialize(this);
// Texture.setEnforcePotImages(false);
// ScreenManager.getInstance().show(Screens.LOADING);
// // ScreenManager.getInstance().show(Screens.GAME);
// }
//
// @Override
// public void dispose()
// {
// super.dispose();
// ScreenManager.getInstance().dispose();
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/managers/FontManager.java
// public class FontManager
// {
// public static final String BLOCK_FONT = "assets/fonts/kenpixel_blocks.ttf";
// }
| import org.doublelong.jastroblast.JastroBlast;
import org.doublelong.jastroblast.managers.FontManager;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle; | package org.doublelong.jastroblast.entity;
public class Hud
{
private Space space;
private Stage stage;
private Label label;
private BitmapFont font;
public Hud(Space space)
{
this.space = space;
this.stage = new Stage(); | // Path: jastroblast-core/src/org/doublelong/jastroblast/JastroBlast.java
// public class JastroBlast extends Game
// {
// public final String WINDOW_TITLE = "jAstroBlast";
// public static final int WINDOW_WIDTH = 800;
// public static final int WINDOW_HEIGHT = 600;
//
// public static AssetManager manager = new AssetManager();
// public static final boolean DEBUG = true;
//
// @Override
// public void create()
// {
// ScreenManager.getInstance().initialize(this);
// Texture.setEnforcePotImages(false);
// ScreenManager.getInstance().show(Screens.LOADING);
// // ScreenManager.getInstance().show(Screens.GAME);
// }
//
// @Override
// public void dispose()
// {
// super.dispose();
// ScreenManager.getInstance().dispose();
// }
// }
//
// Path: jastroblast-core/src/org/doublelong/jastroblast/managers/FontManager.java
// public class FontManager
// {
// public static final String BLOCK_FONT = "assets/fonts/kenpixel_blocks.ttf";
// }
// Path: jastroblast-core/src/org/doublelong/jastroblast/entity/Hud.java
import org.doublelong.jastroblast.JastroBlast;
import org.doublelong.jastroblast.managers.FontManager;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
package org.doublelong.jastroblast.entity;
public class Hud
{
private Space space;
private Stage stage;
private Label label;
private BitmapFont font;
public Hud(Space space)
{
this.space = space;
this.stage = new Stage(); | this.font = JastroBlast.manager.get(FontManager.BLOCK_FONT, BitmapFont.class); |
xzela/jastroblast | jastroblast-desktop/src/org/doublelong/tests/entities/Ship.java | // Path: jastroblast-desktop/src/org/doublelong/tests/controller/ShipController.java
// public class ShipController extends InputAdapter
// {
// private final static float MAX_VELOCITY = 100f;
// private final Ship ship;
// private float stillTime = 0f;
//
// public ShipController(Ship ship)
// {
// this.ship = ship;
// Gdx.input.setInputProcessor(this);
// }
//
//
// public void processControls()
// {
// Vector2 vel = this.ship.getBody().getLinearVelocity();
// Vector2 pos = this.ship.getBody().getPosition();
//
// // cap max velocity on x
// if(Math.abs(vel.x) > MAX_VELOCITY)
// {
// vel.x = Math.signum(vel.x) * MAX_VELOCITY;
// vel.y = Math.signum(vel.y) * MAX_VELOCITY;
// this.ship.getBody().setLinearVelocity(vel.x, vel.y);
// }
//
// // calculate stilltime & damp
// if(!Gdx.input.isKeyPressed(Keys.LEFT) && !Gdx.input.isKeyPressed(Keys.RIGHT)
// && !Gdx.input.isKeyPressed(Keys.UP) && !Gdx.input.isKeyPressed(Keys.DOWN))
// {
// this.stillTime += Gdx.graphics.getDeltaTime();
// this.ship.getBody().setLinearVelocity(vel.x * 0.99f, vel.y * 0.99f);
// this.ship.getBody().setAngularDamping(2f);
// }
// else
// {
// this.stillTime = 0;
// }
//
// if(!Gdx.input.isKeyPressed(Keys.LEFT) && !Gdx.input.isKeyPressed(Keys.RIGHT) && this.stillTime > 0.2)
// {
// this.ship.getFixture().setFriction(100f);
// // this.ship.getFixture().setFriction(100f);
// }
// else
// {
// this.ship.getFixture().setFriction(0.2f);
// // this.ship.getFixture().setFriction(0.2f);
// }
//
//
// // apply left impulse, but only if max velocity is not reached yet
// if(Gdx.input.isKeyPressed(Keys.LEFT) && vel.x > -MAX_VELOCITY)
// {
// this.ship.getBody().applyAngularImpulse(20f, false);
// //this.ship.getBody().applyLinearImpulse(-2f, 0, pos.x, pos.y);
// }
//
// // apply UP impulse
// if (Gdx.input.isKeyPressed(Keys.UP) && vel.y > -MAX_VELOCITY)
// {
// this.ship.getBody().applyLinearImpulse(0, 2f, pos.x, pos.y, true);
// }
//
// // apply UP impulse
// if (Gdx.input.isKeyPressed(Keys.DOWN) && vel.y < MAX_VELOCITY)
// {
// this.ship.getBody().applyLinearImpulse(0, -2f, pos.x, pos.y, true);
// }
//
// // apply right impulse, but only if max velocity is not reached yet
// if(Gdx.input.isKeyPressed(Keys.RIGHT) && vel.x < MAX_VELOCITY)
// {
// this.ship.getBody().applyLinearImpulse(2f, 0, pos.x, pos.y, true);
// }
// }
// }
| import org.doublelong.tests.controller.ShipController;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.badlogic.gdx.physics.box2d.Fixture;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World; | package org.doublelong.tests.entities;
public class Ship
{
private final World world;
| // Path: jastroblast-desktop/src/org/doublelong/tests/controller/ShipController.java
// public class ShipController extends InputAdapter
// {
// private final static float MAX_VELOCITY = 100f;
// private final Ship ship;
// private float stillTime = 0f;
//
// public ShipController(Ship ship)
// {
// this.ship = ship;
// Gdx.input.setInputProcessor(this);
// }
//
//
// public void processControls()
// {
// Vector2 vel = this.ship.getBody().getLinearVelocity();
// Vector2 pos = this.ship.getBody().getPosition();
//
// // cap max velocity on x
// if(Math.abs(vel.x) > MAX_VELOCITY)
// {
// vel.x = Math.signum(vel.x) * MAX_VELOCITY;
// vel.y = Math.signum(vel.y) * MAX_VELOCITY;
// this.ship.getBody().setLinearVelocity(vel.x, vel.y);
// }
//
// // calculate stilltime & damp
// if(!Gdx.input.isKeyPressed(Keys.LEFT) && !Gdx.input.isKeyPressed(Keys.RIGHT)
// && !Gdx.input.isKeyPressed(Keys.UP) && !Gdx.input.isKeyPressed(Keys.DOWN))
// {
// this.stillTime += Gdx.graphics.getDeltaTime();
// this.ship.getBody().setLinearVelocity(vel.x * 0.99f, vel.y * 0.99f);
// this.ship.getBody().setAngularDamping(2f);
// }
// else
// {
// this.stillTime = 0;
// }
//
// if(!Gdx.input.isKeyPressed(Keys.LEFT) && !Gdx.input.isKeyPressed(Keys.RIGHT) && this.stillTime > 0.2)
// {
// this.ship.getFixture().setFriction(100f);
// // this.ship.getFixture().setFriction(100f);
// }
// else
// {
// this.ship.getFixture().setFriction(0.2f);
// // this.ship.getFixture().setFriction(0.2f);
// }
//
//
// // apply left impulse, but only if max velocity is not reached yet
// if(Gdx.input.isKeyPressed(Keys.LEFT) && vel.x > -MAX_VELOCITY)
// {
// this.ship.getBody().applyAngularImpulse(20f, false);
// //this.ship.getBody().applyLinearImpulse(-2f, 0, pos.x, pos.y);
// }
//
// // apply UP impulse
// if (Gdx.input.isKeyPressed(Keys.UP) && vel.y > -MAX_VELOCITY)
// {
// this.ship.getBody().applyLinearImpulse(0, 2f, pos.x, pos.y, true);
// }
//
// // apply UP impulse
// if (Gdx.input.isKeyPressed(Keys.DOWN) && vel.y < MAX_VELOCITY)
// {
// this.ship.getBody().applyLinearImpulse(0, -2f, pos.x, pos.y, true);
// }
//
// // apply right impulse, but only if max velocity is not reached yet
// if(Gdx.input.isKeyPressed(Keys.RIGHT) && vel.x < MAX_VELOCITY)
// {
// this.ship.getBody().applyLinearImpulse(2f, 0, pos.x, pos.y, true);
// }
// }
// }
// Path: jastroblast-desktop/src/org/doublelong/tests/entities/Ship.java
import org.doublelong.tests.controller.ShipController;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.badlogic.gdx.physics.box2d.Fixture;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World;
package org.doublelong.tests.entities;
public class Ship
{
private final World world;
| public ShipController controller; |
RGreenlees/JUMI-Java-Model-Importer | src/com/jumi/fbx/objects/FBXProperty.java | // Path: src/com/jumi/fbx/node/FBXNode.java
// public abstract class FBXNode {
//
// public int endOffset;
// public int numProperties;
// public int propertyListLength;
// public int cursorPosition;
// public int nameLength;
// public String name;
// public int sizeInBytes;
//
// public ArrayList<FBXProperty> properties = new ArrayList();
//
// // Constructor. Sets up some useful info about the node
// public FBXNode(byte[] inputData, int propertyOffset) {
// sizeInBytes = inputData.length;
//
// numProperties = getNumProperties(inputData);
//
// int propertyStartOffset = propertyOffset;
//
// for (int i = 0; i < numProperties; i++) {
// FBXProperty newProp = new FBXProperty(inputData, propertyStartOffset);
// propertyStartOffset += newProp.dataLength;
// properties.add(newProp);
// }
//
// cursorPosition = propertyStartOffset;
// }
//
// public abstract void parseData(byte[] inputData, int propertyOffset);
//
// // Helper method to extract the data specific to this node
// public final byte[] extractRawData(byte[] inputData, int startPosition, int endOffset) {
// byte[] rawData = new byte[endOffset - startPosition];
//
// for (int i = 0; i < rawData.length; i++) {
// rawData[i] = inputData[startPosition + i];
// }
//
// return rawData;
// }
//
// public final int getNumProperties(byte[] inputData) {
// byte[] bytes = retrieveBytesFrom(inputData, 4, 4);
// return ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
// }
//
// public final int getNumProperties(byte[] inputData, int startPosition) {
// byte[] bytes = retrieveBytesFrom(inputData, 4, 4+startPosition);
// return ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
// }
//
// public final String getName(byte[] inputData) {
// nameLength = getNameLength(inputData);
// return new String(retrieveBytesFrom(inputData, nameLength, 13));
// }
//
// public final int getNameLength(byte[] inputData) {
// return inputData[12];
// }
//
// public final int getPropertyListLength(byte[] inputData) {
// byte[] bytes = retrieveBytesFrom(inputData, 4, 8);
// return ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
// }
//
// public final int getEndOffset(byte[] inputData, int startPosition) {
// byte[] result = retrieveBytesFrom(inputData, 4, startPosition);
// return ByteBuffer.wrap(result).order(ByteOrder.LITTLE_ENDIAN).getInt();
// }
//
// public final static byte[] retrieveBytesFrom(byte[] inputData, int numBytes, int offSet) {
// byte[] result = new byte[numBytes];
//
// for (int i = offSet; i < numBytes + offSet; i++) {
// result[i - offSet] = inputData[i];
// }
//
// return result;
// }
// }
| import com.jumi.fbx.node.FBXNode;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.DoubleBuffer;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
| dataSizeInBytes = 8;
parseArray(inputData);
break;
case 'l':
dataType = "Long Array";
dataSizeInBytes = 8;
parseArray(inputData);
break;
case 'b':
dataType = "Boolean Array";
dataSizeInBytes = 1;
parseArray(inputData);
break;
case 'S':
dataType = "String";
parseBinary(inputData);
break;
case 'R':
dataType = "Raw Binary Data";
parseBinary(inputData);
break;
default:
System.err.println("Unknown property type! " + typeCode);
System.exit(-1);
break;
}
}
/* Simply extract the binary data based on the data size */
private void parseValue(byte[] inputData) {
| // Path: src/com/jumi/fbx/node/FBXNode.java
// public abstract class FBXNode {
//
// public int endOffset;
// public int numProperties;
// public int propertyListLength;
// public int cursorPosition;
// public int nameLength;
// public String name;
// public int sizeInBytes;
//
// public ArrayList<FBXProperty> properties = new ArrayList();
//
// // Constructor. Sets up some useful info about the node
// public FBXNode(byte[] inputData, int propertyOffset) {
// sizeInBytes = inputData.length;
//
// numProperties = getNumProperties(inputData);
//
// int propertyStartOffset = propertyOffset;
//
// for (int i = 0; i < numProperties; i++) {
// FBXProperty newProp = new FBXProperty(inputData, propertyStartOffset);
// propertyStartOffset += newProp.dataLength;
// properties.add(newProp);
// }
//
// cursorPosition = propertyStartOffset;
// }
//
// public abstract void parseData(byte[] inputData, int propertyOffset);
//
// // Helper method to extract the data specific to this node
// public final byte[] extractRawData(byte[] inputData, int startPosition, int endOffset) {
// byte[] rawData = new byte[endOffset - startPosition];
//
// for (int i = 0; i < rawData.length; i++) {
// rawData[i] = inputData[startPosition + i];
// }
//
// return rawData;
// }
//
// public final int getNumProperties(byte[] inputData) {
// byte[] bytes = retrieveBytesFrom(inputData, 4, 4);
// return ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
// }
//
// public final int getNumProperties(byte[] inputData, int startPosition) {
// byte[] bytes = retrieveBytesFrom(inputData, 4, 4+startPosition);
// return ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
// }
//
// public final String getName(byte[] inputData) {
// nameLength = getNameLength(inputData);
// return new String(retrieveBytesFrom(inputData, nameLength, 13));
// }
//
// public final int getNameLength(byte[] inputData) {
// return inputData[12];
// }
//
// public final int getPropertyListLength(byte[] inputData) {
// byte[] bytes = retrieveBytesFrom(inputData, 4, 8);
// return ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
// }
//
// public final int getEndOffset(byte[] inputData, int startPosition) {
// byte[] result = retrieveBytesFrom(inputData, 4, startPosition);
// return ByteBuffer.wrap(result).order(ByteOrder.LITTLE_ENDIAN).getInt();
// }
//
// public final static byte[] retrieveBytesFrom(byte[] inputData, int numBytes, int offSet) {
// byte[] result = new byte[numBytes];
//
// for (int i = offSet; i < numBytes + offSet; i++) {
// result[i - offSet] = inputData[i];
// }
//
// return result;
// }
// }
// Path: src/com/jumi/fbx/objects/FBXProperty.java
import com.jumi.fbx.node.FBXNode;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.DoubleBuffer;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
dataSizeInBytes = 8;
parseArray(inputData);
break;
case 'l':
dataType = "Long Array";
dataSizeInBytes = 8;
parseArray(inputData);
break;
case 'b':
dataType = "Boolean Array";
dataSizeInBytes = 1;
parseArray(inputData);
break;
case 'S':
dataType = "String";
parseBinary(inputData);
break;
case 'R':
dataType = "Raw Binary Data";
parseBinary(inputData);
break;
default:
System.err.println("Unknown property type! " + typeCode);
System.exit(-1);
break;
}
}
/* Simply extract the binary data based on the data size */
private void parseValue(byte[] inputData) {
| binaryData = FBXNode.retrieveBytesFrom(inputData, dataSizeInBytes, startPosition + 1);
|
RGreenlees/JUMI-Java-Model-Importer | src/com/jumi/obj/objects/definitions/OBJMatLibDefinition.java | // Path: src/com/jumi/data/Color.java
// public class Color {
// public float r;
// public float g;
// public float b;
// public float a;
//
// public Color() {
// r = 0.0f;
// g = 0.0f;
// b = 0.0f;
// a = 1.0f;
// }
//
// public Color(float newR, float newG, float newB, float newA) {
// r = newR;
// g = newG;
// b = newB;
// a = newA;
// }
//
// public Color(float newR, float newG, float newB) {
// r = newR;
// g = newG;
// b = newB;
// a = 1.0f;
// }
//
// public String toString() {
// return "{ R=" + r + ", G=" + g + ", B=" + b + ", A=" + a + "}";
// }
// }
| import com.jumi.data.Color;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
| /*
* (C) Copyright 2015 Richard Greenlees
*
* 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:
*
* 1) The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* This library 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
* Lesser General Public License for more details.
*
*/
package com.jumi.obj.objects.definitions;
/**
*
* @author RGreenlees
*/
public class OBJMatLibDefinition {
public ArrayList<OBJMaterialDefinition> materials = new ArrayList();
private OBJMaterialDefinition currentMaterial = null;
public OBJMatLibDefinition() {
super();
}
// Parses the supplied MTL
public void parseMTL(String mtlLocation) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(mtlLocation));
String line;
while ((line = reader.readLine()) != null) {
String[] lineTokens = line.split(" ");
if (lineTokens.length == 0) {
continue;
}
// Get rid of those whitespaces!
switch (lineTokens[0].trim()) {
// New material definition, add it to the list and set it to be the current material
case "newmtl":
if (lineTokens.length > 1) {
OBJMaterialDefinition newMat = new OBJMaterialDefinition(lineTokens[1]);
materials.add(newMat);
currentMaterial = newMat;
}
break;
// Various attributes to be applied to whichever material is current
| // Path: src/com/jumi/data/Color.java
// public class Color {
// public float r;
// public float g;
// public float b;
// public float a;
//
// public Color() {
// r = 0.0f;
// g = 0.0f;
// b = 0.0f;
// a = 1.0f;
// }
//
// public Color(float newR, float newG, float newB, float newA) {
// r = newR;
// g = newG;
// b = newB;
// a = newA;
// }
//
// public Color(float newR, float newG, float newB) {
// r = newR;
// g = newG;
// b = newB;
// a = 1.0f;
// }
//
// public String toString() {
// return "{ R=" + r + ", G=" + g + ", B=" + b + ", A=" + a + "}";
// }
// }
// Path: src/com/jumi/obj/objects/definitions/OBJMatLibDefinition.java
import com.jumi.data.Color;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
/*
* (C) Copyright 2015 Richard Greenlees
*
* 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:
*
* 1) The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* This library 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
* Lesser General Public License for more details.
*
*/
package com.jumi.obj.objects.definitions;
/**
*
* @author RGreenlees
*/
public class OBJMatLibDefinition {
public ArrayList<OBJMaterialDefinition> materials = new ArrayList();
private OBJMaterialDefinition currentMaterial = null;
public OBJMatLibDefinition() {
super();
}
// Parses the supplied MTL
public void parseMTL(String mtlLocation) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(mtlLocation));
String line;
while ((line = reader.readLine()) != null) {
String[] lineTokens = line.split(" ");
if (lineTokens.length == 0) {
continue;
}
// Get rid of those whitespaces!
switch (lineTokens[0].trim()) {
// New material definition, add it to the list and set it to be the current material
case "newmtl":
if (lineTokens.length > 1) {
OBJMaterialDefinition newMat = new OBJMaterialDefinition(lineTokens[1]);
materials.add(newMat);
currentMaterial = newMat;
}
break;
// Various attributes to be applied to whichever material is current
| case "Ka": currentMaterial.ambientColour = new Color(Float.valueOf(lineTokens[1]), Float.valueOf(lineTokens[2]), Float.valueOf(lineTokens[3])); break;
|
RGreenlees/JUMI-Java-Model-Importer | src/com/jumi/scene/objects/JUMIMaterial.java | // Path: src/com/jumi/data/Color.java
// public class Color {
// public float r;
// public float g;
// public float b;
// public float a;
//
// public Color() {
// r = 0.0f;
// g = 0.0f;
// b = 0.0f;
// a = 1.0f;
// }
//
// public Color(float newR, float newG, float newB, float newA) {
// r = newR;
// g = newG;
// b = newB;
// a = newA;
// }
//
// public Color(float newR, float newG, float newB) {
// r = newR;
// g = newG;
// b = newB;
// a = 1.0f;
// }
//
// public String toString() {
// return "{ R=" + r + ", G=" + g + ", B=" + b + ", A=" + a + "}";
// }
// }
| import com.jumi.data.Color;
| /*
* (C) Copyright 2015 Richard Greenlees
*
* 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:
*
* 1) The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* This library 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
* Lesser General Public License for more details.
*
*/
package com.jumi.scene.objects;
/**
*
* @author RGreenlees
*/
public class JUMIMaterial {
public String name;
| // Path: src/com/jumi/data/Color.java
// public class Color {
// public float r;
// public float g;
// public float b;
// public float a;
//
// public Color() {
// r = 0.0f;
// g = 0.0f;
// b = 0.0f;
// a = 1.0f;
// }
//
// public Color(float newR, float newG, float newB, float newA) {
// r = newR;
// g = newG;
// b = newB;
// a = newA;
// }
//
// public Color(float newR, float newG, float newB) {
// r = newR;
// g = newG;
// b = newB;
// a = 1.0f;
// }
//
// public String toString() {
// return "{ R=" + r + ", G=" + g + ", B=" + b + ", A=" + a + "}";
// }
// }
// Path: src/com/jumi/scene/objects/JUMIMaterial.java
import com.jumi.data.Color;
/*
* (C) Copyright 2015 Richard Greenlees
*
* 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:
*
* 1) The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* This library 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
* Lesser General Public License for more details.
*
*/
package com.jumi.scene.objects;
/**
*
* @author RGreenlees
*/
public class JUMIMaterial {
public String name;
| public Color ambientColor = new Color();
|
RGreenlees/JUMI-Java-Model-Importer | src/com/jumi/scene/objects/JUMIBone.java | // Path: src/com/jumi/data/Vector3.java
// public class Vector3 {
// public float x;
// public float y;
// public float z;
//
// public Vector3(float newX, float newY, float newZ) {
// x = newX;
// y = newY;
// z = newZ;
// }
//
// public void set(float newX, float newY, float newZ) {
// x = newX;
// y = newY;
// z = newZ;
// }
//
// public Vector3() {
// super();
// }
//
// public String toString() {
// return "(" + x + ", " + y + ", " + z + ")";
// }
// }
| import com.jumi.data.Vector3;
import java.util.ArrayList;
| /*
* (C) Copyright 2015 Richard Greenlees
*
* 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:
*
* 1) The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* This library 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
* Lesser General Public License for more details.
*
*/
package com.jumi.scene.objects;
/**
*
* @author RGreenlees
*/
public class JUMIBone {
private int[] indices = new int[0];
private float[] weights = new float[0];
private float[] transforms = new float[0];
private float[] transformLinks = new float[0];
private JUMIBone parent;
private final ArrayList<JUMIBone> children = new ArrayList();
| // Path: src/com/jumi/data/Vector3.java
// public class Vector3 {
// public float x;
// public float y;
// public float z;
//
// public Vector3(float newX, float newY, float newZ) {
// x = newX;
// y = newY;
// z = newZ;
// }
//
// public void set(float newX, float newY, float newZ) {
// x = newX;
// y = newY;
// z = newZ;
// }
//
// public Vector3() {
// super();
// }
//
// public String toString() {
// return "(" + x + ", " + y + ", " + z + ")";
// }
// }
// Path: src/com/jumi/scene/objects/JUMIBone.java
import com.jumi.data.Vector3;
import java.util.ArrayList;
/*
* (C) Copyright 2015 Richard Greenlees
*
* 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:
*
* 1) The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* This library 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
* Lesser General Public License for more details.
*
*/
package com.jumi.scene.objects;
/**
*
* @author RGreenlees
*/
public class JUMIBone {
private int[] indices = new int[0];
private float[] weights = new float[0];
private float[] transforms = new float[0];
private float[] transformLinks = new float[0];
private JUMIBone parent;
private final ArrayList<JUMIBone> children = new ArrayList();
| private Vector3 localTranslation = new Vector3();
|
pnoker/mybatisGenerator | src/main/java/org/mybatis/generator/codegen/mybatis3/xmlmapper/elements/DeleteByExampleElementGenerator.java | // Path: src/main/java/org/mybatis/generator/api/dom/xml/TextElement.java
// public class TextElement extends Element {
//
// /** The content. */
// private String content;
//
// /**
// * Instantiates a new text element.
// *
// * @param content
// * the content
// */
// public TextElement(String content) {
// super();
// this.content = content;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append(content);
// return sb.toString();
// }
//
// /**
// * Gets the content.
// *
// * @return the content
// */
// public String getContent() {
// return content;
// }
// }
//
// Path: src/main/java/org/mybatis/generator/api/dom/xml/XmlElement.java
// public class XmlElement extends Element {
//
// /** The attributes. */
// private List<Attribute> attributes;
//
// /** The elements. */
// private List<Element> elements;
//
// /** The name. */
// private String name;
//
// /**
// * Instantiates a new xml element.
// *
// * @param name
// * the name
// */
// public XmlElement(String name) {
// super();
// attributes = new ArrayList<Attribute>();
// elements = new ArrayList<Element>();
// this.name = name;
// }
//
// /**
// * Copy constructor. Not a truly deep copy, but close enough for most purposes.
// *
// * @param original
// * the original
// */
// public XmlElement(XmlElement original) {
// super();
// attributes = new ArrayList<Attribute>();
// attributes.addAll(original.attributes);
// elements = new ArrayList<Element>();
// elements.addAll(original.elements);
// this.name = original.name;
// }
//
// /**
// * Gets the attributes.
// *
// * @return Returns the attributes.
// */
// public List<Attribute> getAttributes() {
// return attributes;
// }
//
// /**
// * Adds the attribute.
// *
// * @param attribute
// * the attribute
// */
// public void addAttribute(Attribute attribute) {
// attributes.add(attribute);
// }
//
// /**
// * Gets the elements.
// *
// * @return Returns the elements.
// */
// public List<Element> getElements() {
// return elements;
// }
//
// /**
// * Adds the element.
// *
// * @param element
// * the element
// */
// public void addElement(Element element) {
// elements.add(element);
// }
//
// /**
// * Adds the element.
// *
// * @param index
// * the index
// * @param element
// * the element
// */
// public void addElement(int index, Element element) {
// elements.add(index, element);
// }
//
// /**
// * Gets the name.
// *
// * @return Returns the name.
// */
// public String getName() {
// return name;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
//
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append('<');
// sb.append(name);
//
// Collections.sort(attributes);
// for (Attribute att : attributes) {
// sb.append(' ');
// sb.append(att.getFormattedContent());
// }
//
// if (elements.size() > 0) {
// sb.append(">"); //$NON-NLS-1$
// for (Element element : elements) {
// OutputUtilities.newLine(sb);
// sb.append(element.getFormattedContent(indentLevel + 1));
// }
// OutputUtilities.newLine(sb);
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append("</"); //$NON-NLS-1$
// sb.append(name);
// sb.append('>');
//
// } else {
// sb.append(" />"); //$NON-NLS-1$
// }
//
// return sb.toString();
// }
//
// /**
// * Sets the name.
// *
// * @param name
// * the new name
// */
// public void setName(String name) {
// this.name = name;
// }
// }
| import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.TextElement;
import org.mybatis.generator.api.dom.xml.XmlElement; | /**
* Copyright 2006-2016 the original author or authors.
*
* 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.mybatis.generator.codegen.mybatis3.xmlmapper.elements;
/**
*
* @author Jeff Butler
*
*/
public class DeleteByExampleElementGenerator extends
AbstractXmlElementGenerator {
public DeleteByExampleElementGenerator() {
super();
}
@Override | // Path: src/main/java/org/mybatis/generator/api/dom/xml/TextElement.java
// public class TextElement extends Element {
//
// /** The content. */
// private String content;
//
// /**
// * Instantiates a new text element.
// *
// * @param content
// * the content
// */
// public TextElement(String content) {
// super();
// this.content = content;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append(content);
// return sb.toString();
// }
//
// /**
// * Gets the content.
// *
// * @return the content
// */
// public String getContent() {
// return content;
// }
// }
//
// Path: src/main/java/org/mybatis/generator/api/dom/xml/XmlElement.java
// public class XmlElement extends Element {
//
// /** The attributes. */
// private List<Attribute> attributes;
//
// /** The elements. */
// private List<Element> elements;
//
// /** The name. */
// private String name;
//
// /**
// * Instantiates a new xml element.
// *
// * @param name
// * the name
// */
// public XmlElement(String name) {
// super();
// attributes = new ArrayList<Attribute>();
// elements = new ArrayList<Element>();
// this.name = name;
// }
//
// /**
// * Copy constructor. Not a truly deep copy, but close enough for most purposes.
// *
// * @param original
// * the original
// */
// public XmlElement(XmlElement original) {
// super();
// attributes = new ArrayList<Attribute>();
// attributes.addAll(original.attributes);
// elements = new ArrayList<Element>();
// elements.addAll(original.elements);
// this.name = original.name;
// }
//
// /**
// * Gets the attributes.
// *
// * @return Returns the attributes.
// */
// public List<Attribute> getAttributes() {
// return attributes;
// }
//
// /**
// * Adds the attribute.
// *
// * @param attribute
// * the attribute
// */
// public void addAttribute(Attribute attribute) {
// attributes.add(attribute);
// }
//
// /**
// * Gets the elements.
// *
// * @return Returns the elements.
// */
// public List<Element> getElements() {
// return elements;
// }
//
// /**
// * Adds the element.
// *
// * @param element
// * the element
// */
// public void addElement(Element element) {
// elements.add(element);
// }
//
// /**
// * Adds the element.
// *
// * @param index
// * the index
// * @param element
// * the element
// */
// public void addElement(int index, Element element) {
// elements.add(index, element);
// }
//
// /**
// * Gets the name.
// *
// * @return Returns the name.
// */
// public String getName() {
// return name;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
//
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append('<');
// sb.append(name);
//
// Collections.sort(attributes);
// for (Attribute att : attributes) {
// sb.append(' ');
// sb.append(att.getFormattedContent());
// }
//
// if (elements.size() > 0) {
// sb.append(">"); //$NON-NLS-1$
// for (Element element : elements) {
// OutputUtilities.newLine(sb);
// sb.append(element.getFormattedContent(indentLevel + 1));
// }
// OutputUtilities.newLine(sb);
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append("</"); //$NON-NLS-1$
// sb.append(name);
// sb.append('>');
//
// } else {
// sb.append(" />"); //$NON-NLS-1$
// }
//
// return sb.toString();
// }
//
// /**
// * Sets the name.
// *
// * @param name
// * the new name
// */
// public void setName(String name) {
// this.name = name;
// }
// }
// Path: src/main/java/org/mybatis/generator/codegen/mybatis3/xmlmapper/elements/DeleteByExampleElementGenerator.java
import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.TextElement;
import org.mybatis.generator.api.dom.xml.XmlElement;
/**
* Copyright 2006-2016 the original author or authors.
*
* 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.mybatis.generator.codegen.mybatis3.xmlmapper.elements;
/**
*
* @author Jeff Butler
*
*/
public class DeleteByExampleElementGenerator extends
AbstractXmlElementGenerator {
public DeleteByExampleElementGenerator() {
super();
}
@Override | public void addElements(XmlElement parentElement) { |
pnoker/mybatisGenerator | src/main/java/org/mybatis/generator/codegen/mybatis3/xmlmapper/elements/SelectByExampleWithoutBLOBsElementGenerator.java | // Path: src/main/java/org/mybatis/generator/api/dom/xml/TextElement.java
// public class TextElement extends Element {
//
// /** The content. */
// private String content;
//
// /**
// * Instantiates a new text element.
// *
// * @param content
// * the content
// */
// public TextElement(String content) {
// super();
// this.content = content;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append(content);
// return sb.toString();
// }
//
// /**
// * Gets the content.
// *
// * @return the content
// */
// public String getContent() {
// return content;
// }
// }
//
// Path: src/main/java/org/mybatis/generator/api/dom/xml/XmlElement.java
// public class XmlElement extends Element {
//
// /** The attributes. */
// private List<Attribute> attributes;
//
// /** The elements. */
// private List<Element> elements;
//
// /** The name. */
// private String name;
//
// /**
// * Instantiates a new xml element.
// *
// * @param name
// * the name
// */
// public XmlElement(String name) {
// super();
// attributes = new ArrayList<Attribute>();
// elements = new ArrayList<Element>();
// this.name = name;
// }
//
// /**
// * Copy constructor. Not a truly deep copy, but close enough for most purposes.
// *
// * @param original
// * the original
// */
// public XmlElement(XmlElement original) {
// super();
// attributes = new ArrayList<Attribute>();
// attributes.addAll(original.attributes);
// elements = new ArrayList<Element>();
// elements.addAll(original.elements);
// this.name = original.name;
// }
//
// /**
// * Gets the attributes.
// *
// * @return Returns the attributes.
// */
// public List<Attribute> getAttributes() {
// return attributes;
// }
//
// /**
// * Adds the attribute.
// *
// * @param attribute
// * the attribute
// */
// public void addAttribute(Attribute attribute) {
// attributes.add(attribute);
// }
//
// /**
// * Gets the elements.
// *
// * @return Returns the elements.
// */
// public List<Element> getElements() {
// return elements;
// }
//
// /**
// * Adds the element.
// *
// * @param element
// * the element
// */
// public void addElement(Element element) {
// elements.add(element);
// }
//
// /**
// * Adds the element.
// *
// * @param index
// * the index
// * @param element
// * the element
// */
// public void addElement(int index, Element element) {
// elements.add(index, element);
// }
//
// /**
// * Gets the name.
// *
// * @return Returns the name.
// */
// public String getName() {
// return name;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
//
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append('<');
// sb.append(name);
//
// Collections.sort(attributes);
// for (Attribute att : attributes) {
// sb.append(' ');
// sb.append(att.getFormattedContent());
// }
//
// if (elements.size() > 0) {
// sb.append(">"); //$NON-NLS-1$
// for (Element element : elements) {
// OutputUtilities.newLine(sb);
// sb.append(element.getFormattedContent(indentLevel + 1));
// }
// OutputUtilities.newLine(sb);
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append("</"); //$NON-NLS-1$
// sb.append(name);
// sb.append('>');
//
// } else {
// sb.append(" />"); //$NON-NLS-1$
// }
//
// return sb.toString();
// }
//
// /**
// * Sets the name.
// *
// * @param name
// * the new name
// */
// public void setName(String name) {
// this.name = name;
// }
// }
| import static org.mybatis.generator.internal.util.StringUtility.stringHasValue;
import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.TextElement;
import org.mybatis.generator.api.dom.xml.XmlElement; | /**
* Copyright 2006-2016 the original author or authors.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.mybatis.generator.codegen.mybatis3.xmlmapper.elements;
/**
* @author Jeff Butler
*/
public class SelectByExampleWithoutBLOBsElementGenerator extends
AbstractXmlElementGenerator {
public SelectByExampleWithoutBLOBsElementGenerator() {
super();
}
@Override | // Path: src/main/java/org/mybatis/generator/api/dom/xml/TextElement.java
// public class TextElement extends Element {
//
// /** The content. */
// private String content;
//
// /**
// * Instantiates a new text element.
// *
// * @param content
// * the content
// */
// public TextElement(String content) {
// super();
// this.content = content;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append(content);
// return sb.toString();
// }
//
// /**
// * Gets the content.
// *
// * @return the content
// */
// public String getContent() {
// return content;
// }
// }
//
// Path: src/main/java/org/mybatis/generator/api/dom/xml/XmlElement.java
// public class XmlElement extends Element {
//
// /** The attributes. */
// private List<Attribute> attributes;
//
// /** The elements. */
// private List<Element> elements;
//
// /** The name. */
// private String name;
//
// /**
// * Instantiates a new xml element.
// *
// * @param name
// * the name
// */
// public XmlElement(String name) {
// super();
// attributes = new ArrayList<Attribute>();
// elements = new ArrayList<Element>();
// this.name = name;
// }
//
// /**
// * Copy constructor. Not a truly deep copy, but close enough for most purposes.
// *
// * @param original
// * the original
// */
// public XmlElement(XmlElement original) {
// super();
// attributes = new ArrayList<Attribute>();
// attributes.addAll(original.attributes);
// elements = new ArrayList<Element>();
// elements.addAll(original.elements);
// this.name = original.name;
// }
//
// /**
// * Gets the attributes.
// *
// * @return Returns the attributes.
// */
// public List<Attribute> getAttributes() {
// return attributes;
// }
//
// /**
// * Adds the attribute.
// *
// * @param attribute
// * the attribute
// */
// public void addAttribute(Attribute attribute) {
// attributes.add(attribute);
// }
//
// /**
// * Gets the elements.
// *
// * @return Returns the elements.
// */
// public List<Element> getElements() {
// return elements;
// }
//
// /**
// * Adds the element.
// *
// * @param element
// * the element
// */
// public void addElement(Element element) {
// elements.add(element);
// }
//
// /**
// * Adds the element.
// *
// * @param index
// * the index
// * @param element
// * the element
// */
// public void addElement(int index, Element element) {
// elements.add(index, element);
// }
//
// /**
// * Gets the name.
// *
// * @return Returns the name.
// */
// public String getName() {
// return name;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
//
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append('<');
// sb.append(name);
//
// Collections.sort(attributes);
// for (Attribute att : attributes) {
// sb.append(' ');
// sb.append(att.getFormattedContent());
// }
//
// if (elements.size() > 0) {
// sb.append(">"); //$NON-NLS-1$
// for (Element element : elements) {
// OutputUtilities.newLine(sb);
// sb.append(element.getFormattedContent(indentLevel + 1));
// }
// OutputUtilities.newLine(sb);
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append("</"); //$NON-NLS-1$
// sb.append(name);
// sb.append('>');
//
// } else {
// sb.append(" />"); //$NON-NLS-1$
// }
//
// return sb.toString();
// }
//
// /**
// * Sets the name.
// *
// * @param name
// * the new name
// */
// public void setName(String name) {
// this.name = name;
// }
// }
// Path: src/main/java/org/mybatis/generator/codegen/mybatis3/xmlmapper/elements/SelectByExampleWithoutBLOBsElementGenerator.java
import static org.mybatis.generator.internal.util.StringUtility.stringHasValue;
import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.TextElement;
import org.mybatis.generator.api.dom.xml.XmlElement;
/**
* Copyright 2006-2016 the original author or authors.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.mybatis.generator.codegen.mybatis3.xmlmapper.elements;
/**
* @author Jeff Butler
*/
public class SelectByExampleWithoutBLOBsElementGenerator extends
AbstractXmlElementGenerator {
public SelectByExampleWithoutBLOBsElementGenerator() {
super();
}
@Override | public void addElements(XmlElement parentElement) { |
pnoker/mybatisGenerator | src/main/java/org/mybatis/generator/config/GeneratedKey.java | // Path: src/main/java/org/mybatis/generator/api/dom/xml/XmlElement.java
// public class XmlElement extends Element {
//
// /** The attributes. */
// private List<Attribute> attributes;
//
// /** The elements. */
// private List<Element> elements;
//
// /** The name. */
// private String name;
//
// /**
// * Instantiates a new xml element.
// *
// * @param name
// * the name
// */
// public XmlElement(String name) {
// super();
// attributes = new ArrayList<Attribute>();
// elements = new ArrayList<Element>();
// this.name = name;
// }
//
// /**
// * Copy constructor. Not a truly deep copy, but close enough for most purposes.
// *
// * @param original
// * the original
// */
// public XmlElement(XmlElement original) {
// super();
// attributes = new ArrayList<Attribute>();
// attributes.addAll(original.attributes);
// elements = new ArrayList<Element>();
// elements.addAll(original.elements);
// this.name = original.name;
// }
//
// /**
// * Gets the attributes.
// *
// * @return Returns the attributes.
// */
// public List<Attribute> getAttributes() {
// return attributes;
// }
//
// /**
// * Adds the attribute.
// *
// * @param attribute
// * the attribute
// */
// public void addAttribute(Attribute attribute) {
// attributes.add(attribute);
// }
//
// /**
// * Gets the elements.
// *
// * @return Returns the elements.
// */
// public List<Element> getElements() {
// return elements;
// }
//
// /**
// * Adds the element.
// *
// * @param element
// * the element
// */
// public void addElement(Element element) {
// elements.add(element);
// }
//
// /**
// * Adds the element.
// *
// * @param index
// * the index
// * @param element
// * the element
// */
// public void addElement(int index, Element element) {
// elements.add(index, element);
// }
//
// /**
// * Gets the name.
// *
// * @return Returns the name.
// */
// public String getName() {
// return name;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
//
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append('<');
// sb.append(name);
//
// Collections.sort(attributes);
// for (Attribute att : attributes) {
// sb.append(' ');
// sb.append(att.getFormattedContent());
// }
//
// if (elements.size() > 0) {
// sb.append(">"); //$NON-NLS-1$
// for (Element element : elements) {
// OutputUtilities.newLine(sb);
// sb.append(element.getFormattedContent(indentLevel + 1));
// }
// OutputUtilities.newLine(sb);
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append("</"); //$NON-NLS-1$
// sb.append(name);
// sb.append('>');
//
// } else {
// sb.append(" />"); //$NON-NLS-1$
// }
//
// return sb.toString();
// }
//
// /**
// * Sets the name.
// *
// * @param name
// * the new name
// */
// public void setName(String name) {
// this.name = name;
// }
// }
| import static org.mybatis.generator.internal.util.StringUtility.stringHasValue;
import static org.mybatis.generator.internal.util.messages.Messages.getString;
import java.util.List;
import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.XmlElement;
import org.mybatis.generator.internal.db.DatabaseDialects; | public String getRuntimeSqlStatement() {
return runtimeSqlStatement;
}
public String getType() {
return type;
}
/**
* This method is used by the iBATIS2 generators to know if the XML <selectKey> element should be placed before the
* insert SQL statement.
*
* @return true, if is placed before insert in ibatis2
*/
public boolean isPlacedBeforeInsertInIbatis2() {
boolean rc;
if (stringHasValue(type)) {
rc = true;
} else {
rc = !isIdentity;
}
return rc;
}
public String getMyBatis3Order() {
return isIdentity ? "AFTER" : "BEFORE"; //$NON-NLS-1$ //$NON-NLS-2$
}
| // Path: src/main/java/org/mybatis/generator/api/dom/xml/XmlElement.java
// public class XmlElement extends Element {
//
// /** The attributes. */
// private List<Attribute> attributes;
//
// /** The elements. */
// private List<Element> elements;
//
// /** The name. */
// private String name;
//
// /**
// * Instantiates a new xml element.
// *
// * @param name
// * the name
// */
// public XmlElement(String name) {
// super();
// attributes = new ArrayList<Attribute>();
// elements = new ArrayList<Element>();
// this.name = name;
// }
//
// /**
// * Copy constructor. Not a truly deep copy, but close enough for most purposes.
// *
// * @param original
// * the original
// */
// public XmlElement(XmlElement original) {
// super();
// attributes = new ArrayList<Attribute>();
// attributes.addAll(original.attributes);
// elements = new ArrayList<Element>();
// elements.addAll(original.elements);
// this.name = original.name;
// }
//
// /**
// * Gets the attributes.
// *
// * @return Returns the attributes.
// */
// public List<Attribute> getAttributes() {
// return attributes;
// }
//
// /**
// * Adds the attribute.
// *
// * @param attribute
// * the attribute
// */
// public void addAttribute(Attribute attribute) {
// attributes.add(attribute);
// }
//
// /**
// * Gets the elements.
// *
// * @return Returns the elements.
// */
// public List<Element> getElements() {
// return elements;
// }
//
// /**
// * Adds the element.
// *
// * @param element
// * the element
// */
// public void addElement(Element element) {
// elements.add(element);
// }
//
// /**
// * Adds the element.
// *
// * @param index
// * the index
// * @param element
// * the element
// */
// public void addElement(int index, Element element) {
// elements.add(index, element);
// }
//
// /**
// * Gets the name.
// *
// * @return Returns the name.
// */
// public String getName() {
// return name;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
//
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append('<');
// sb.append(name);
//
// Collections.sort(attributes);
// for (Attribute att : attributes) {
// sb.append(' ');
// sb.append(att.getFormattedContent());
// }
//
// if (elements.size() > 0) {
// sb.append(">"); //$NON-NLS-1$
// for (Element element : elements) {
// OutputUtilities.newLine(sb);
// sb.append(element.getFormattedContent(indentLevel + 1));
// }
// OutputUtilities.newLine(sb);
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append("</"); //$NON-NLS-1$
// sb.append(name);
// sb.append('>');
//
// } else {
// sb.append(" />"); //$NON-NLS-1$
// }
//
// return sb.toString();
// }
//
// /**
// * Sets the name.
// *
// * @param name
// * the new name
// */
// public void setName(String name) {
// this.name = name;
// }
// }
// Path: src/main/java/org/mybatis/generator/config/GeneratedKey.java
import static org.mybatis.generator.internal.util.StringUtility.stringHasValue;
import static org.mybatis.generator.internal.util.messages.Messages.getString;
import java.util.List;
import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.XmlElement;
import org.mybatis.generator.internal.db.DatabaseDialects;
public String getRuntimeSqlStatement() {
return runtimeSqlStatement;
}
public String getType() {
return type;
}
/**
* This method is used by the iBATIS2 generators to know if the XML <selectKey> element should be placed before the
* insert SQL statement.
*
* @return true, if is placed before insert in ibatis2
*/
public boolean isPlacedBeforeInsertInIbatis2() {
boolean rc;
if (stringHasValue(type)) {
rc = true;
} else {
rc = !isIdentity;
}
return rc;
}
public String getMyBatis3Order() {
return isIdentity ? "AFTER" : "BEFORE"; //$NON-NLS-1$ //$NON-NLS-2$
}
| public XmlElement toXmlElement() { |
pnoker/mybatisGenerator | src/main/java/org/mybatis/generator/codegen/mybatis3/javamapper/SimpleAnnotatedClientGenerator.java | // Path: src/main/java/org/mybatis/generator/api/dom/java/Interface.java
// public class Interface extends InnerInterface implements CompilationUnit {
//
// private Set<FullyQualifiedJavaType> importedTypes;
//
// private Set<String> staticImports;
//
// private List<String> fileCommentLines;
//
// public Interface(FullyQualifiedJavaType type) {
// super(type);
// importedTypes = new TreeSet<FullyQualifiedJavaType>();
// fileCommentLines = new ArrayList<String>();
// staticImports = new TreeSet<String>();
// }
//
// public Interface(String type) {
// this(new FullyQualifiedJavaType(type));
// }
//
// @Override
// public Set<FullyQualifiedJavaType> getImportedTypes() {
// return importedTypes;
// }
//
// @Override
// public void addImportedType(FullyQualifiedJavaType importedType) {
// if (importedType.isExplicitlyImported()
// && !importedType.getPackageName().equals(getType().getPackageName())) {
// importedTypes.add(importedType);
// }
// }
//
// @Override
// public String getFormattedContent() {
//
// return getFormattedContent(0, this);
// }
//
// @Override
// public String getFormattedContent(int indentLevel, CompilationUnit compilationUnit) {
// StringBuilder sb = new StringBuilder();
//
// for (String commentLine : fileCommentLines) {
// sb.append(commentLine);
// newLine(sb);
// }
//
// if (stringHasValue(getType().getPackageName())) {
// sb.append("package "); //$NON-NLS-1$
// sb.append(getType().getPackageName());
// sb.append(';');
// newLine(sb);
// newLine(sb);
// }
//
// for (String staticImport : staticImports) {
// sb.append("import static "); //$NON-NLS-1$
// sb.append(staticImport);
// sb.append(';');
// newLine(sb);
// }
//
// if (staticImports.size() > 0) {
// newLine(sb);
// }
//
// Set<String> importStrings = calculateImports(importedTypes);
// for (String importString : importStrings) {
// sb.append(importString);
// newLine(sb);
// }
//
// if (importStrings.size() > 0) {
// newLine(sb);
// }
//
// sb.append(super.getFormattedContent(0, this));
//
// return sb.toString();
// }
//
// @Override
// public void addFileCommentLine(String commentLine) {
// fileCommentLines.add(commentLine);
// }
//
// @Override
// public List<String> getFileCommentLines() {
// return fileCommentLines;
// }
//
// @Override
// public void addImportedTypes(Set<FullyQualifiedJavaType> importedTypes) {
// this.importedTypes.addAll(importedTypes);
// }
//
// @Override
// public Set<String> getStaticImports() {
// return staticImports;
// }
//
// @Override
// public void addStaticImport(String staticImport) {
// staticImports.add(staticImport);
// }
//
// @Override
// public void addStaticImports(Set<String> staticImports) {
// this.staticImports.addAll(staticImports);
// }
// }
| import org.mybatis.generator.api.dom.java.Interface;
import org.mybatis.generator.codegen.AbstractXmlGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.AbstractJavaMapperMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedDeleteByPrimaryKeyMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedInsertMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedSelectAllMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedSelectByPrimaryKeyMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedUpdateByPrimaryKeyWithoutBLOBsMethodGenerator; | /**
* Copyright 2006-2017 the original author or authors.
*
* 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.mybatis.generator.codegen.mybatis3.javamapper;
/**
* @author Jeff Butler
*
*/
public class SimpleAnnotatedClientGenerator extends SimpleJavaClientGenerator {
/**
*
*/
public SimpleAnnotatedClientGenerator() {
super(false);
}
@Override | // Path: src/main/java/org/mybatis/generator/api/dom/java/Interface.java
// public class Interface extends InnerInterface implements CompilationUnit {
//
// private Set<FullyQualifiedJavaType> importedTypes;
//
// private Set<String> staticImports;
//
// private List<String> fileCommentLines;
//
// public Interface(FullyQualifiedJavaType type) {
// super(type);
// importedTypes = new TreeSet<FullyQualifiedJavaType>();
// fileCommentLines = new ArrayList<String>();
// staticImports = new TreeSet<String>();
// }
//
// public Interface(String type) {
// this(new FullyQualifiedJavaType(type));
// }
//
// @Override
// public Set<FullyQualifiedJavaType> getImportedTypes() {
// return importedTypes;
// }
//
// @Override
// public void addImportedType(FullyQualifiedJavaType importedType) {
// if (importedType.isExplicitlyImported()
// && !importedType.getPackageName().equals(getType().getPackageName())) {
// importedTypes.add(importedType);
// }
// }
//
// @Override
// public String getFormattedContent() {
//
// return getFormattedContent(0, this);
// }
//
// @Override
// public String getFormattedContent(int indentLevel, CompilationUnit compilationUnit) {
// StringBuilder sb = new StringBuilder();
//
// for (String commentLine : fileCommentLines) {
// sb.append(commentLine);
// newLine(sb);
// }
//
// if (stringHasValue(getType().getPackageName())) {
// sb.append("package "); //$NON-NLS-1$
// sb.append(getType().getPackageName());
// sb.append(';');
// newLine(sb);
// newLine(sb);
// }
//
// for (String staticImport : staticImports) {
// sb.append("import static "); //$NON-NLS-1$
// sb.append(staticImport);
// sb.append(';');
// newLine(sb);
// }
//
// if (staticImports.size() > 0) {
// newLine(sb);
// }
//
// Set<String> importStrings = calculateImports(importedTypes);
// for (String importString : importStrings) {
// sb.append(importString);
// newLine(sb);
// }
//
// if (importStrings.size() > 0) {
// newLine(sb);
// }
//
// sb.append(super.getFormattedContent(0, this));
//
// return sb.toString();
// }
//
// @Override
// public void addFileCommentLine(String commentLine) {
// fileCommentLines.add(commentLine);
// }
//
// @Override
// public List<String> getFileCommentLines() {
// return fileCommentLines;
// }
//
// @Override
// public void addImportedTypes(Set<FullyQualifiedJavaType> importedTypes) {
// this.importedTypes.addAll(importedTypes);
// }
//
// @Override
// public Set<String> getStaticImports() {
// return staticImports;
// }
//
// @Override
// public void addStaticImport(String staticImport) {
// staticImports.add(staticImport);
// }
//
// @Override
// public void addStaticImports(Set<String> staticImports) {
// this.staticImports.addAll(staticImports);
// }
// }
// Path: src/main/java/org/mybatis/generator/codegen/mybatis3/javamapper/SimpleAnnotatedClientGenerator.java
import org.mybatis.generator.api.dom.java.Interface;
import org.mybatis.generator.codegen.AbstractXmlGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.AbstractJavaMapperMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedDeleteByPrimaryKeyMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedInsertMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedSelectAllMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedSelectByPrimaryKeyMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedUpdateByPrimaryKeyWithoutBLOBsMethodGenerator;
/**
* Copyright 2006-2017 the original author or authors.
*
* 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.mybatis.generator.codegen.mybatis3.javamapper;
/**
* @author Jeff Butler
*
*/
public class SimpleAnnotatedClientGenerator extends SimpleJavaClientGenerator {
/**
*
*/
public SimpleAnnotatedClientGenerator() {
super(false);
}
@Override | protected void addDeleteByPrimaryKeyMethod(Interface interfaze) { |
pnoker/mybatisGenerator | src/main/java/org/mybatis/generator/config/TableConfiguration.java | // Path: src/main/java/org/mybatis/generator/api/dom/xml/XmlElement.java
// public class XmlElement extends Element {
//
// /** The attributes. */
// private List<Attribute> attributes;
//
// /** The elements. */
// private List<Element> elements;
//
// /** The name. */
// private String name;
//
// /**
// * Instantiates a new xml element.
// *
// * @param name
// * the name
// */
// public XmlElement(String name) {
// super();
// attributes = new ArrayList<Attribute>();
// elements = new ArrayList<Element>();
// this.name = name;
// }
//
// /**
// * Copy constructor. Not a truly deep copy, but close enough for most purposes.
// *
// * @param original
// * the original
// */
// public XmlElement(XmlElement original) {
// super();
// attributes = new ArrayList<Attribute>();
// attributes.addAll(original.attributes);
// elements = new ArrayList<Element>();
// elements.addAll(original.elements);
// this.name = original.name;
// }
//
// /**
// * Gets the attributes.
// *
// * @return Returns the attributes.
// */
// public List<Attribute> getAttributes() {
// return attributes;
// }
//
// /**
// * Adds the attribute.
// *
// * @param attribute
// * the attribute
// */
// public void addAttribute(Attribute attribute) {
// attributes.add(attribute);
// }
//
// /**
// * Gets the elements.
// *
// * @return Returns the elements.
// */
// public List<Element> getElements() {
// return elements;
// }
//
// /**
// * Adds the element.
// *
// * @param element
// * the element
// */
// public void addElement(Element element) {
// elements.add(element);
// }
//
// /**
// * Adds the element.
// *
// * @param index
// * the index
// * @param element
// * the element
// */
// public void addElement(int index, Element element) {
// elements.add(index, element);
// }
//
// /**
// * Gets the name.
// *
// * @return Returns the name.
// */
// public String getName() {
// return name;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
//
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append('<');
// sb.append(name);
//
// Collections.sort(attributes);
// for (Attribute att : attributes) {
// sb.append(' ');
// sb.append(att.getFormattedContent());
// }
//
// if (elements.size() > 0) {
// sb.append(">"); //$NON-NLS-1$
// for (Element element : elements) {
// OutputUtilities.newLine(sb);
// sb.append(element.getFormattedContent(indentLevel + 1));
// }
// OutputUtilities.newLine(sb);
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append("</"); //$NON-NLS-1$
// sb.append(name);
// sb.append('>');
//
// } else {
// sb.append(" />"); //$NON-NLS-1$
// }
//
// return sb.toString();
// }
//
// /**
// * Sets the name.
// *
// * @param name
// * the new name
// */
// public void setName(String name) {
// this.name = name;
// }
// }
| import static org.mybatis.generator.internal.util.EqualsUtil.areEqual;
import static org.mybatis.generator.internal.util.HashCodeUtil.SEED;
import static org.mybatis.generator.internal.util.HashCodeUtil.hash;
import static org.mybatis.generator.internal.util.StringUtility.composeFullyQualifiedTableName;
import static org.mybatis.generator.internal.util.StringUtility.isTrue;
import static org.mybatis.generator.internal.util.StringUtility.stringHasValue;
import static org.mybatis.generator.internal.util.messages.Messages.getString;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.XmlElement; | public List<String> getIgnoredColumnsInError() {
List<String> answer = new ArrayList<String>();
for (Map.Entry<IgnoredColumn, Boolean> entry : ignoredColumns
.entrySet()) {
if (Boolean.FALSE.equals(entry.getValue())) {
answer.add(entry.getKey().getColumnName());
}
}
return answer;
}
public ModelType getModelType() {
return modelType;
}
public void setConfiguredModelType(String configuredModelType) {
this.configuredModelType = configuredModelType;
this.modelType = ModelType.getModelType(configuredModelType);
}
public boolean isWildcardEscapingEnabled() {
return wildcardEscapingEnabled;
}
public void setWildcardEscapingEnabled(boolean wildcardEscapingEnabled) {
this.wildcardEscapingEnabled = wildcardEscapingEnabled;
}
| // Path: src/main/java/org/mybatis/generator/api/dom/xml/XmlElement.java
// public class XmlElement extends Element {
//
// /** The attributes. */
// private List<Attribute> attributes;
//
// /** The elements. */
// private List<Element> elements;
//
// /** The name. */
// private String name;
//
// /**
// * Instantiates a new xml element.
// *
// * @param name
// * the name
// */
// public XmlElement(String name) {
// super();
// attributes = new ArrayList<Attribute>();
// elements = new ArrayList<Element>();
// this.name = name;
// }
//
// /**
// * Copy constructor. Not a truly deep copy, but close enough for most purposes.
// *
// * @param original
// * the original
// */
// public XmlElement(XmlElement original) {
// super();
// attributes = new ArrayList<Attribute>();
// attributes.addAll(original.attributes);
// elements = new ArrayList<Element>();
// elements.addAll(original.elements);
// this.name = original.name;
// }
//
// /**
// * Gets the attributes.
// *
// * @return Returns the attributes.
// */
// public List<Attribute> getAttributes() {
// return attributes;
// }
//
// /**
// * Adds the attribute.
// *
// * @param attribute
// * the attribute
// */
// public void addAttribute(Attribute attribute) {
// attributes.add(attribute);
// }
//
// /**
// * Gets the elements.
// *
// * @return Returns the elements.
// */
// public List<Element> getElements() {
// return elements;
// }
//
// /**
// * Adds the element.
// *
// * @param element
// * the element
// */
// public void addElement(Element element) {
// elements.add(element);
// }
//
// /**
// * Adds the element.
// *
// * @param index
// * the index
// * @param element
// * the element
// */
// public void addElement(int index, Element element) {
// elements.add(index, element);
// }
//
// /**
// * Gets the name.
// *
// * @return Returns the name.
// */
// public String getName() {
// return name;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
//
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append('<');
// sb.append(name);
//
// Collections.sort(attributes);
// for (Attribute att : attributes) {
// sb.append(' ');
// sb.append(att.getFormattedContent());
// }
//
// if (elements.size() > 0) {
// sb.append(">"); //$NON-NLS-1$
// for (Element element : elements) {
// OutputUtilities.newLine(sb);
// sb.append(element.getFormattedContent(indentLevel + 1));
// }
// OutputUtilities.newLine(sb);
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append("</"); //$NON-NLS-1$
// sb.append(name);
// sb.append('>');
//
// } else {
// sb.append(" />"); //$NON-NLS-1$
// }
//
// return sb.toString();
// }
//
// /**
// * Sets the name.
// *
// * @param name
// * the new name
// */
// public void setName(String name) {
// this.name = name;
// }
// }
// Path: src/main/java/org/mybatis/generator/config/TableConfiguration.java
import static org.mybatis.generator.internal.util.EqualsUtil.areEqual;
import static org.mybatis.generator.internal.util.HashCodeUtil.SEED;
import static org.mybatis.generator.internal.util.HashCodeUtil.hash;
import static org.mybatis.generator.internal.util.StringUtility.composeFullyQualifiedTableName;
import static org.mybatis.generator.internal.util.StringUtility.isTrue;
import static org.mybatis.generator.internal.util.StringUtility.stringHasValue;
import static org.mybatis.generator.internal.util.messages.Messages.getString;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.XmlElement;
public List<String> getIgnoredColumnsInError() {
List<String> answer = new ArrayList<String>();
for (Map.Entry<IgnoredColumn, Boolean> entry : ignoredColumns
.entrySet()) {
if (Boolean.FALSE.equals(entry.getValue())) {
answer.add(entry.getKey().getColumnName());
}
}
return answer;
}
public ModelType getModelType() {
return modelType;
}
public void setConfiguredModelType(String configuredModelType) {
this.configuredModelType = configuredModelType;
this.modelType = ModelType.getModelType(configuredModelType);
}
public boolean isWildcardEscapingEnabled() {
return wildcardEscapingEnabled;
}
public void setWildcardEscapingEnabled(boolean wildcardEscapingEnabled) {
this.wildcardEscapingEnabled = wildcardEscapingEnabled;
}
| public XmlElement toXmlElement() { |
pnoker/mybatisGenerator | src/main/java/org/mybatis/generator/codegen/mybatis3/xmlmapper/elements/SelectByExampleWithBLOBsElementGenerator.java | // Path: src/main/java/org/mybatis/generator/api/dom/xml/TextElement.java
// public class TextElement extends Element {
//
// /** The content. */
// private String content;
//
// /**
// * Instantiates a new text element.
// *
// * @param content
// * the content
// */
// public TextElement(String content) {
// super();
// this.content = content;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append(content);
// return sb.toString();
// }
//
// /**
// * Gets the content.
// *
// * @return the content
// */
// public String getContent() {
// return content;
// }
// }
//
// Path: src/main/java/org/mybatis/generator/api/dom/xml/XmlElement.java
// public class XmlElement extends Element {
//
// /** The attributes. */
// private List<Attribute> attributes;
//
// /** The elements. */
// private List<Element> elements;
//
// /** The name. */
// private String name;
//
// /**
// * Instantiates a new xml element.
// *
// * @param name
// * the name
// */
// public XmlElement(String name) {
// super();
// attributes = new ArrayList<Attribute>();
// elements = new ArrayList<Element>();
// this.name = name;
// }
//
// /**
// * Copy constructor. Not a truly deep copy, but close enough for most purposes.
// *
// * @param original
// * the original
// */
// public XmlElement(XmlElement original) {
// super();
// attributes = new ArrayList<Attribute>();
// attributes.addAll(original.attributes);
// elements = new ArrayList<Element>();
// elements.addAll(original.elements);
// this.name = original.name;
// }
//
// /**
// * Gets the attributes.
// *
// * @return Returns the attributes.
// */
// public List<Attribute> getAttributes() {
// return attributes;
// }
//
// /**
// * Adds the attribute.
// *
// * @param attribute
// * the attribute
// */
// public void addAttribute(Attribute attribute) {
// attributes.add(attribute);
// }
//
// /**
// * Gets the elements.
// *
// * @return Returns the elements.
// */
// public List<Element> getElements() {
// return elements;
// }
//
// /**
// * Adds the element.
// *
// * @param element
// * the element
// */
// public void addElement(Element element) {
// elements.add(element);
// }
//
// /**
// * Adds the element.
// *
// * @param index
// * the index
// * @param element
// * the element
// */
// public void addElement(int index, Element element) {
// elements.add(index, element);
// }
//
// /**
// * Gets the name.
// *
// * @return Returns the name.
// */
// public String getName() {
// return name;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
//
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append('<');
// sb.append(name);
//
// Collections.sort(attributes);
// for (Attribute att : attributes) {
// sb.append(' ');
// sb.append(att.getFormattedContent());
// }
//
// if (elements.size() > 0) {
// sb.append(">"); //$NON-NLS-1$
// for (Element element : elements) {
// OutputUtilities.newLine(sb);
// sb.append(element.getFormattedContent(indentLevel + 1));
// }
// OutputUtilities.newLine(sb);
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append("</"); //$NON-NLS-1$
// sb.append(name);
// sb.append('>');
//
// } else {
// sb.append(" />"); //$NON-NLS-1$
// }
//
// return sb.toString();
// }
//
// /**
// * Sets the name.
// *
// * @param name
// * the new name
// */
// public void setName(String name) {
// this.name = name;
// }
// }
| import static org.mybatis.generator.internal.util.StringUtility.stringHasValue;
import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.TextElement;
import org.mybatis.generator.api.dom.xml.XmlElement; | /**
* Copyright 2006-2016 the original author or authors.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.mybatis.generator.codegen.mybatis3.xmlmapper.elements;
/**
* @author Jeff Butler
*/
public class SelectByExampleWithBLOBsElementGenerator extends
AbstractXmlElementGenerator {
public SelectByExampleWithBLOBsElementGenerator() {
super();
}
@Override | // Path: src/main/java/org/mybatis/generator/api/dom/xml/TextElement.java
// public class TextElement extends Element {
//
// /** The content. */
// private String content;
//
// /**
// * Instantiates a new text element.
// *
// * @param content
// * the content
// */
// public TextElement(String content) {
// super();
// this.content = content;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append(content);
// return sb.toString();
// }
//
// /**
// * Gets the content.
// *
// * @return the content
// */
// public String getContent() {
// return content;
// }
// }
//
// Path: src/main/java/org/mybatis/generator/api/dom/xml/XmlElement.java
// public class XmlElement extends Element {
//
// /** The attributes. */
// private List<Attribute> attributes;
//
// /** The elements. */
// private List<Element> elements;
//
// /** The name. */
// private String name;
//
// /**
// * Instantiates a new xml element.
// *
// * @param name
// * the name
// */
// public XmlElement(String name) {
// super();
// attributes = new ArrayList<Attribute>();
// elements = new ArrayList<Element>();
// this.name = name;
// }
//
// /**
// * Copy constructor. Not a truly deep copy, but close enough for most purposes.
// *
// * @param original
// * the original
// */
// public XmlElement(XmlElement original) {
// super();
// attributes = new ArrayList<Attribute>();
// attributes.addAll(original.attributes);
// elements = new ArrayList<Element>();
// elements.addAll(original.elements);
// this.name = original.name;
// }
//
// /**
// * Gets the attributes.
// *
// * @return Returns the attributes.
// */
// public List<Attribute> getAttributes() {
// return attributes;
// }
//
// /**
// * Adds the attribute.
// *
// * @param attribute
// * the attribute
// */
// public void addAttribute(Attribute attribute) {
// attributes.add(attribute);
// }
//
// /**
// * Gets the elements.
// *
// * @return Returns the elements.
// */
// public List<Element> getElements() {
// return elements;
// }
//
// /**
// * Adds the element.
// *
// * @param element
// * the element
// */
// public void addElement(Element element) {
// elements.add(element);
// }
//
// /**
// * Adds the element.
// *
// * @param index
// * the index
// * @param element
// * the element
// */
// public void addElement(int index, Element element) {
// elements.add(index, element);
// }
//
// /**
// * Gets the name.
// *
// * @return Returns the name.
// */
// public String getName() {
// return name;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
//
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append('<');
// sb.append(name);
//
// Collections.sort(attributes);
// for (Attribute att : attributes) {
// sb.append(' ');
// sb.append(att.getFormattedContent());
// }
//
// if (elements.size() > 0) {
// sb.append(">"); //$NON-NLS-1$
// for (Element element : elements) {
// OutputUtilities.newLine(sb);
// sb.append(element.getFormattedContent(indentLevel + 1));
// }
// OutputUtilities.newLine(sb);
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append("</"); //$NON-NLS-1$
// sb.append(name);
// sb.append('>');
//
// } else {
// sb.append(" />"); //$NON-NLS-1$
// }
//
// return sb.toString();
// }
//
// /**
// * Sets the name.
// *
// * @param name
// * the new name
// */
// public void setName(String name) {
// this.name = name;
// }
// }
// Path: src/main/java/org/mybatis/generator/codegen/mybatis3/xmlmapper/elements/SelectByExampleWithBLOBsElementGenerator.java
import static org.mybatis.generator.internal.util.StringUtility.stringHasValue;
import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.TextElement;
import org.mybatis.generator.api.dom.xml.XmlElement;
/**
* Copyright 2006-2016 the original author or authors.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.mybatis.generator.codegen.mybatis3.xmlmapper.elements;
/**
* @author Jeff Butler
*/
public class SelectByExampleWithBLOBsElementGenerator extends
AbstractXmlElementGenerator {
public SelectByExampleWithBLOBsElementGenerator() {
super();
}
@Override | public void addElements(XmlElement parentElement) { |
pnoker/mybatisGenerator | src/main/java/org/mybatis/generator/codegen/mybatis3/xmlmapper/MixedMapperGenerator.java | // Path: src/main/java/org/mybatis/generator/api/dom/xml/XmlElement.java
// public class XmlElement extends Element {
//
// /** The attributes. */
// private List<Attribute> attributes;
//
// /** The elements. */
// private List<Element> elements;
//
// /** The name. */
// private String name;
//
// /**
// * Instantiates a new xml element.
// *
// * @param name
// * the name
// */
// public XmlElement(String name) {
// super();
// attributes = new ArrayList<Attribute>();
// elements = new ArrayList<Element>();
// this.name = name;
// }
//
// /**
// * Copy constructor. Not a truly deep copy, but close enough for most purposes.
// *
// * @param original
// * the original
// */
// public XmlElement(XmlElement original) {
// super();
// attributes = new ArrayList<Attribute>();
// attributes.addAll(original.attributes);
// elements = new ArrayList<Element>();
// elements.addAll(original.elements);
// this.name = original.name;
// }
//
// /**
// * Gets the attributes.
// *
// * @return Returns the attributes.
// */
// public List<Attribute> getAttributes() {
// return attributes;
// }
//
// /**
// * Adds the attribute.
// *
// * @param attribute
// * the attribute
// */
// public void addAttribute(Attribute attribute) {
// attributes.add(attribute);
// }
//
// /**
// * Gets the elements.
// *
// * @return Returns the elements.
// */
// public List<Element> getElements() {
// return elements;
// }
//
// /**
// * Adds the element.
// *
// * @param element
// * the element
// */
// public void addElement(Element element) {
// elements.add(element);
// }
//
// /**
// * Adds the element.
// *
// * @param index
// * the index
// * @param element
// * the element
// */
// public void addElement(int index, Element element) {
// elements.add(index, element);
// }
//
// /**
// * Gets the name.
// *
// * @return Returns the name.
// */
// public String getName() {
// return name;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
//
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append('<');
// sb.append(name);
//
// Collections.sort(attributes);
// for (Attribute att : attributes) {
// sb.append(' ');
// sb.append(att.getFormattedContent());
// }
//
// if (elements.size() > 0) {
// sb.append(">"); //$NON-NLS-1$
// for (Element element : elements) {
// OutputUtilities.newLine(sb);
// sb.append(element.getFormattedContent(indentLevel + 1));
// }
// OutputUtilities.newLine(sb);
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append("</"); //$NON-NLS-1$
// sb.append(name);
// sb.append('>');
//
// } else {
// sb.append(" />"); //$NON-NLS-1$
// }
//
// return sb.toString();
// }
//
// /**
// * Sets the name.
// *
// * @param name
// * the new name
// */
// public void setName(String name) {
// this.name = name;
// }
// }
| import org.mybatis.generator.api.dom.xml.XmlElement; | /**
* Copyright 2006-2016 the original author or authors.
*
* 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.mybatis.generator.codegen.mybatis3.xmlmapper;
/**
*
* @author Jeff Butler
*
*/
public class MixedMapperGenerator extends XMLMapperGenerator {
@Override | // Path: src/main/java/org/mybatis/generator/api/dom/xml/XmlElement.java
// public class XmlElement extends Element {
//
// /** The attributes. */
// private List<Attribute> attributes;
//
// /** The elements. */
// private List<Element> elements;
//
// /** The name. */
// private String name;
//
// /**
// * Instantiates a new xml element.
// *
// * @param name
// * the name
// */
// public XmlElement(String name) {
// super();
// attributes = new ArrayList<Attribute>();
// elements = new ArrayList<Element>();
// this.name = name;
// }
//
// /**
// * Copy constructor. Not a truly deep copy, but close enough for most purposes.
// *
// * @param original
// * the original
// */
// public XmlElement(XmlElement original) {
// super();
// attributes = new ArrayList<Attribute>();
// attributes.addAll(original.attributes);
// elements = new ArrayList<Element>();
// elements.addAll(original.elements);
// this.name = original.name;
// }
//
// /**
// * Gets the attributes.
// *
// * @return Returns the attributes.
// */
// public List<Attribute> getAttributes() {
// return attributes;
// }
//
// /**
// * Adds the attribute.
// *
// * @param attribute
// * the attribute
// */
// public void addAttribute(Attribute attribute) {
// attributes.add(attribute);
// }
//
// /**
// * Gets the elements.
// *
// * @return Returns the elements.
// */
// public List<Element> getElements() {
// return elements;
// }
//
// /**
// * Adds the element.
// *
// * @param element
// * the element
// */
// public void addElement(Element element) {
// elements.add(element);
// }
//
// /**
// * Adds the element.
// *
// * @param index
// * the index
// * @param element
// * the element
// */
// public void addElement(int index, Element element) {
// elements.add(index, element);
// }
//
// /**
// * Gets the name.
// *
// * @return Returns the name.
// */
// public String getName() {
// return name;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
//
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append('<');
// sb.append(name);
//
// Collections.sort(attributes);
// for (Attribute att : attributes) {
// sb.append(' ');
// sb.append(att.getFormattedContent());
// }
//
// if (elements.size() > 0) {
// sb.append(">"); //$NON-NLS-1$
// for (Element element : elements) {
// OutputUtilities.newLine(sb);
// sb.append(element.getFormattedContent(indentLevel + 1));
// }
// OutputUtilities.newLine(sb);
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append("</"); //$NON-NLS-1$
// sb.append(name);
// sb.append('>');
//
// } else {
// sb.append(" />"); //$NON-NLS-1$
// }
//
// return sb.toString();
// }
//
// /**
// * Sets the name.
// *
// * @param name
// * the new name
// */
// public void setName(String name) {
// this.name = name;
// }
// }
// Path: src/main/java/org/mybatis/generator/codegen/mybatis3/xmlmapper/MixedMapperGenerator.java
import org.mybatis.generator.api.dom.xml.XmlElement;
/**
* Copyright 2006-2016 the original author or authors.
*
* 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.mybatis.generator.codegen.mybatis3.xmlmapper;
/**
*
* @author Jeff Butler
*
*/
public class MixedMapperGenerator extends XMLMapperGenerator {
@Override | protected void addSelectByPrimaryKeyElement(XmlElement parentElement) { |
pnoker/mybatisGenerator | src/main/java/org/mybatis/generator/codegen/mybatis3/xmlmapper/elements/CountByExampleElementGenerator.java | // Path: src/main/java/org/mybatis/generator/api/dom/xml/TextElement.java
// public class TextElement extends Element {
//
// /** The content. */
// private String content;
//
// /**
// * Instantiates a new text element.
// *
// * @param content
// * the content
// */
// public TextElement(String content) {
// super();
// this.content = content;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append(content);
// return sb.toString();
// }
//
// /**
// * Gets the content.
// *
// * @return the content
// */
// public String getContent() {
// return content;
// }
// }
//
// Path: src/main/java/org/mybatis/generator/api/dom/xml/XmlElement.java
// public class XmlElement extends Element {
//
// /** The attributes. */
// private List<Attribute> attributes;
//
// /** The elements. */
// private List<Element> elements;
//
// /** The name. */
// private String name;
//
// /**
// * Instantiates a new xml element.
// *
// * @param name
// * the name
// */
// public XmlElement(String name) {
// super();
// attributes = new ArrayList<Attribute>();
// elements = new ArrayList<Element>();
// this.name = name;
// }
//
// /**
// * Copy constructor. Not a truly deep copy, but close enough for most purposes.
// *
// * @param original
// * the original
// */
// public XmlElement(XmlElement original) {
// super();
// attributes = new ArrayList<Attribute>();
// attributes.addAll(original.attributes);
// elements = new ArrayList<Element>();
// elements.addAll(original.elements);
// this.name = original.name;
// }
//
// /**
// * Gets the attributes.
// *
// * @return Returns the attributes.
// */
// public List<Attribute> getAttributes() {
// return attributes;
// }
//
// /**
// * Adds the attribute.
// *
// * @param attribute
// * the attribute
// */
// public void addAttribute(Attribute attribute) {
// attributes.add(attribute);
// }
//
// /**
// * Gets the elements.
// *
// * @return Returns the elements.
// */
// public List<Element> getElements() {
// return elements;
// }
//
// /**
// * Adds the element.
// *
// * @param element
// * the element
// */
// public void addElement(Element element) {
// elements.add(element);
// }
//
// /**
// * Adds the element.
// *
// * @param index
// * the index
// * @param element
// * the element
// */
// public void addElement(int index, Element element) {
// elements.add(index, element);
// }
//
// /**
// * Gets the name.
// *
// * @return Returns the name.
// */
// public String getName() {
// return name;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
//
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append('<');
// sb.append(name);
//
// Collections.sort(attributes);
// for (Attribute att : attributes) {
// sb.append(' ');
// sb.append(att.getFormattedContent());
// }
//
// if (elements.size() > 0) {
// sb.append(">"); //$NON-NLS-1$
// for (Element element : elements) {
// OutputUtilities.newLine(sb);
// sb.append(element.getFormattedContent(indentLevel + 1));
// }
// OutputUtilities.newLine(sb);
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append("</"); //$NON-NLS-1$
// sb.append(name);
// sb.append('>');
//
// } else {
// sb.append(" />"); //$NON-NLS-1$
// }
//
// return sb.toString();
// }
//
// /**
// * Sets the name.
// *
// * @param name
// * the new name
// */
// public void setName(String name) {
// this.name = name;
// }
// }
| import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.TextElement;
import org.mybatis.generator.api.dom.xml.XmlElement; | /**
* Copyright 2006-2016 the original author or authors.
*
* 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.mybatis.generator.codegen.mybatis3.xmlmapper.elements;
/**
*
* @author Jeff Butler
*
*/
public class CountByExampleElementGenerator extends AbstractXmlElementGenerator {
public CountByExampleElementGenerator() {
super();
}
@Override | // Path: src/main/java/org/mybatis/generator/api/dom/xml/TextElement.java
// public class TextElement extends Element {
//
// /** The content. */
// private String content;
//
// /**
// * Instantiates a new text element.
// *
// * @param content
// * the content
// */
// public TextElement(String content) {
// super();
// this.content = content;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append(content);
// return sb.toString();
// }
//
// /**
// * Gets the content.
// *
// * @return the content
// */
// public String getContent() {
// return content;
// }
// }
//
// Path: src/main/java/org/mybatis/generator/api/dom/xml/XmlElement.java
// public class XmlElement extends Element {
//
// /** The attributes. */
// private List<Attribute> attributes;
//
// /** The elements. */
// private List<Element> elements;
//
// /** The name. */
// private String name;
//
// /**
// * Instantiates a new xml element.
// *
// * @param name
// * the name
// */
// public XmlElement(String name) {
// super();
// attributes = new ArrayList<Attribute>();
// elements = new ArrayList<Element>();
// this.name = name;
// }
//
// /**
// * Copy constructor. Not a truly deep copy, but close enough for most purposes.
// *
// * @param original
// * the original
// */
// public XmlElement(XmlElement original) {
// super();
// attributes = new ArrayList<Attribute>();
// attributes.addAll(original.attributes);
// elements = new ArrayList<Element>();
// elements.addAll(original.elements);
// this.name = original.name;
// }
//
// /**
// * Gets the attributes.
// *
// * @return Returns the attributes.
// */
// public List<Attribute> getAttributes() {
// return attributes;
// }
//
// /**
// * Adds the attribute.
// *
// * @param attribute
// * the attribute
// */
// public void addAttribute(Attribute attribute) {
// attributes.add(attribute);
// }
//
// /**
// * Gets the elements.
// *
// * @return Returns the elements.
// */
// public List<Element> getElements() {
// return elements;
// }
//
// /**
// * Adds the element.
// *
// * @param element
// * the element
// */
// public void addElement(Element element) {
// elements.add(element);
// }
//
// /**
// * Adds the element.
// *
// * @param index
// * the index
// * @param element
// * the element
// */
// public void addElement(int index, Element element) {
// elements.add(index, element);
// }
//
// /**
// * Gets the name.
// *
// * @return Returns the name.
// */
// public String getName() {
// return name;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.dom.xml.Element#getFormattedContent(int)
// */
// @Override
// public String getFormattedContent(int indentLevel) {
// StringBuilder sb = new StringBuilder();
//
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append('<');
// sb.append(name);
//
// Collections.sort(attributes);
// for (Attribute att : attributes) {
// sb.append(' ');
// sb.append(att.getFormattedContent());
// }
//
// if (elements.size() > 0) {
// sb.append(">"); //$NON-NLS-1$
// for (Element element : elements) {
// OutputUtilities.newLine(sb);
// sb.append(element.getFormattedContent(indentLevel + 1));
// }
// OutputUtilities.newLine(sb);
// OutputUtilities.xmlIndent(sb, indentLevel);
// sb.append("</"); //$NON-NLS-1$
// sb.append(name);
// sb.append('>');
//
// } else {
// sb.append(" />"); //$NON-NLS-1$
// }
//
// return sb.toString();
// }
//
// /**
// * Sets the name.
// *
// * @param name
// * the new name
// */
// public void setName(String name) {
// this.name = name;
// }
// }
// Path: src/main/java/org/mybatis/generator/codegen/mybatis3/xmlmapper/elements/CountByExampleElementGenerator.java
import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.TextElement;
import org.mybatis.generator.api.dom.xml.XmlElement;
/**
* Copyright 2006-2016 the original author or authors.
*
* 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.mybatis.generator.codegen.mybatis3.xmlmapper.elements;
/**
*
* @author Jeff Butler
*
*/
public class CountByExampleElementGenerator extends AbstractXmlElementGenerator {
public CountByExampleElementGenerator() {
super();
}
@Override | public void addElements(XmlElement parentElement) { |
pnoker/mybatisGenerator | src/main/java/org/mybatis/generator/codegen/mybatis3/javamapper/MixedClientGenerator.java | // Path: src/main/java/org/mybatis/generator/api/dom/java/Interface.java
// public class Interface extends InnerInterface implements CompilationUnit {
//
// private Set<FullyQualifiedJavaType> importedTypes;
//
// private Set<String> staticImports;
//
// private List<String> fileCommentLines;
//
// public Interface(FullyQualifiedJavaType type) {
// super(type);
// importedTypes = new TreeSet<FullyQualifiedJavaType>();
// fileCommentLines = new ArrayList<String>();
// staticImports = new TreeSet<String>();
// }
//
// public Interface(String type) {
// this(new FullyQualifiedJavaType(type));
// }
//
// @Override
// public Set<FullyQualifiedJavaType> getImportedTypes() {
// return importedTypes;
// }
//
// @Override
// public void addImportedType(FullyQualifiedJavaType importedType) {
// if (importedType.isExplicitlyImported()
// && !importedType.getPackageName().equals(getType().getPackageName())) {
// importedTypes.add(importedType);
// }
// }
//
// @Override
// public String getFormattedContent() {
//
// return getFormattedContent(0, this);
// }
//
// @Override
// public String getFormattedContent(int indentLevel, CompilationUnit compilationUnit) {
// StringBuilder sb = new StringBuilder();
//
// for (String commentLine : fileCommentLines) {
// sb.append(commentLine);
// newLine(sb);
// }
//
// if (stringHasValue(getType().getPackageName())) {
// sb.append("package "); //$NON-NLS-1$
// sb.append(getType().getPackageName());
// sb.append(';');
// newLine(sb);
// newLine(sb);
// }
//
// for (String staticImport : staticImports) {
// sb.append("import static "); //$NON-NLS-1$
// sb.append(staticImport);
// sb.append(';');
// newLine(sb);
// }
//
// if (staticImports.size() > 0) {
// newLine(sb);
// }
//
// Set<String> importStrings = calculateImports(importedTypes);
// for (String importString : importStrings) {
// sb.append(importString);
// newLine(sb);
// }
//
// if (importStrings.size() > 0) {
// newLine(sb);
// }
//
// sb.append(super.getFormattedContent(0, this));
//
// return sb.toString();
// }
//
// @Override
// public void addFileCommentLine(String commentLine) {
// fileCommentLines.add(commentLine);
// }
//
// @Override
// public List<String> getFileCommentLines() {
// return fileCommentLines;
// }
//
// @Override
// public void addImportedTypes(Set<FullyQualifiedJavaType> importedTypes) {
// this.importedTypes.addAll(importedTypes);
// }
//
// @Override
// public Set<String> getStaticImports() {
// return staticImports;
// }
//
// @Override
// public void addStaticImport(String staticImport) {
// staticImports.add(staticImport);
// }
//
// @Override
// public void addStaticImports(Set<String> staticImports) {
// this.staticImports.addAll(staticImports);
// }
// }
//
// Path: src/main/java/org/mybatis/generator/codegen/mybatis3/xmlmapper/MixedMapperGenerator.java
// public class MixedMapperGenerator extends XMLMapperGenerator {
//
// @Override
// protected void addSelectByPrimaryKeyElement(XmlElement parentElement) {
// }
//
// @Override
// protected void addDeleteByPrimaryKeyElement(XmlElement parentElement) {
// }
//
// @Override
// protected void addInsertElement(XmlElement parentElement) {
// }
//
// @Override
// protected void addUpdateByPrimaryKeyWithBLOBsElement(
// XmlElement parentElement) {
// }
//
// @Override
// protected void addUpdateByPrimaryKeyWithoutBLOBsElement(
// XmlElement parentElement) {
// }
// }
| import org.mybatis.generator.api.dom.java.Interface;
import org.mybatis.generator.codegen.AbstractXmlGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.AbstractJavaMapperMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedDeleteByPrimaryKeyMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedInsertMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedSelectByPrimaryKeyMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedUpdateByPrimaryKeyWithBLOBsMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedUpdateByPrimaryKeyWithoutBLOBsMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.xmlmapper.MixedMapperGenerator; | /**
* Copyright 2006-2017 the original author or authors.
*
* 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.mybatis.generator.codegen.mybatis3.javamapper;
/**
* This class overrides the base mapper to provide annotated methods for the
* methods that don't require SQL provider support
*
* @author Jeff Butler
*
*/
public class MixedClientGenerator extends JavaMapperGenerator {
public MixedClientGenerator() {
super(true);
}
@Override | // Path: src/main/java/org/mybatis/generator/api/dom/java/Interface.java
// public class Interface extends InnerInterface implements CompilationUnit {
//
// private Set<FullyQualifiedJavaType> importedTypes;
//
// private Set<String> staticImports;
//
// private List<String> fileCommentLines;
//
// public Interface(FullyQualifiedJavaType type) {
// super(type);
// importedTypes = new TreeSet<FullyQualifiedJavaType>();
// fileCommentLines = new ArrayList<String>();
// staticImports = new TreeSet<String>();
// }
//
// public Interface(String type) {
// this(new FullyQualifiedJavaType(type));
// }
//
// @Override
// public Set<FullyQualifiedJavaType> getImportedTypes() {
// return importedTypes;
// }
//
// @Override
// public void addImportedType(FullyQualifiedJavaType importedType) {
// if (importedType.isExplicitlyImported()
// && !importedType.getPackageName().equals(getType().getPackageName())) {
// importedTypes.add(importedType);
// }
// }
//
// @Override
// public String getFormattedContent() {
//
// return getFormattedContent(0, this);
// }
//
// @Override
// public String getFormattedContent(int indentLevel, CompilationUnit compilationUnit) {
// StringBuilder sb = new StringBuilder();
//
// for (String commentLine : fileCommentLines) {
// sb.append(commentLine);
// newLine(sb);
// }
//
// if (stringHasValue(getType().getPackageName())) {
// sb.append("package "); //$NON-NLS-1$
// sb.append(getType().getPackageName());
// sb.append(';');
// newLine(sb);
// newLine(sb);
// }
//
// for (String staticImport : staticImports) {
// sb.append("import static "); //$NON-NLS-1$
// sb.append(staticImport);
// sb.append(';');
// newLine(sb);
// }
//
// if (staticImports.size() > 0) {
// newLine(sb);
// }
//
// Set<String> importStrings = calculateImports(importedTypes);
// for (String importString : importStrings) {
// sb.append(importString);
// newLine(sb);
// }
//
// if (importStrings.size() > 0) {
// newLine(sb);
// }
//
// sb.append(super.getFormattedContent(0, this));
//
// return sb.toString();
// }
//
// @Override
// public void addFileCommentLine(String commentLine) {
// fileCommentLines.add(commentLine);
// }
//
// @Override
// public List<String> getFileCommentLines() {
// return fileCommentLines;
// }
//
// @Override
// public void addImportedTypes(Set<FullyQualifiedJavaType> importedTypes) {
// this.importedTypes.addAll(importedTypes);
// }
//
// @Override
// public Set<String> getStaticImports() {
// return staticImports;
// }
//
// @Override
// public void addStaticImport(String staticImport) {
// staticImports.add(staticImport);
// }
//
// @Override
// public void addStaticImports(Set<String> staticImports) {
// this.staticImports.addAll(staticImports);
// }
// }
//
// Path: src/main/java/org/mybatis/generator/codegen/mybatis3/xmlmapper/MixedMapperGenerator.java
// public class MixedMapperGenerator extends XMLMapperGenerator {
//
// @Override
// protected void addSelectByPrimaryKeyElement(XmlElement parentElement) {
// }
//
// @Override
// protected void addDeleteByPrimaryKeyElement(XmlElement parentElement) {
// }
//
// @Override
// protected void addInsertElement(XmlElement parentElement) {
// }
//
// @Override
// protected void addUpdateByPrimaryKeyWithBLOBsElement(
// XmlElement parentElement) {
// }
//
// @Override
// protected void addUpdateByPrimaryKeyWithoutBLOBsElement(
// XmlElement parentElement) {
// }
// }
// Path: src/main/java/org/mybatis/generator/codegen/mybatis3/javamapper/MixedClientGenerator.java
import org.mybatis.generator.api.dom.java.Interface;
import org.mybatis.generator.codegen.AbstractXmlGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.AbstractJavaMapperMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedDeleteByPrimaryKeyMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedInsertMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedSelectByPrimaryKeyMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedUpdateByPrimaryKeyWithBLOBsMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedUpdateByPrimaryKeyWithoutBLOBsMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.xmlmapper.MixedMapperGenerator;
/**
* Copyright 2006-2017 the original author or authors.
*
* 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.mybatis.generator.codegen.mybatis3.javamapper;
/**
* This class overrides the base mapper to provide annotated methods for the
* methods that don't require SQL provider support
*
* @author Jeff Butler
*
*/
public class MixedClientGenerator extends JavaMapperGenerator {
public MixedClientGenerator() {
super(true);
}
@Override | protected void addDeleteByPrimaryKeyMethod(Interface interfaze) { |
pnoker/mybatisGenerator | src/main/java/org/mybatis/generator/codegen/mybatis3/javamapper/MixedClientGenerator.java | // Path: src/main/java/org/mybatis/generator/api/dom/java/Interface.java
// public class Interface extends InnerInterface implements CompilationUnit {
//
// private Set<FullyQualifiedJavaType> importedTypes;
//
// private Set<String> staticImports;
//
// private List<String> fileCommentLines;
//
// public Interface(FullyQualifiedJavaType type) {
// super(type);
// importedTypes = new TreeSet<FullyQualifiedJavaType>();
// fileCommentLines = new ArrayList<String>();
// staticImports = new TreeSet<String>();
// }
//
// public Interface(String type) {
// this(new FullyQualifiedJavaType(type));
// }
//
// @Override
// public Set<FullyQualifiedJavaType> getImportedTypes() {
// return importedTypes;
// }
//
// @Override
// public void addImportedType(FullyQualifiedJavaType importedType) {
// if (importedType.isExplicitlyImported()
// && !importedType.getPackageName().equals(getType().getPackageName())) {
// importedTypes.add(importedType);
// }
// }
//
// @Override
// public String getFormattedContent() {
//
// return getFormattedContent(0, this);
// }
//
// @Override
// public String getFormattedContent(int indentLevel, CompilationUnit compilationUnit) {
// StringBuilder sb = new StringBuilder();
//
// for (String commentLine : fileCommentLines) {
// sb.append(commentLine);
// newLine(sb);
// }
//
// if (stringHasValue(getType().getPackageName())) {
// sb.append("package "); //$NON-NLS-1$
// sb.append(getType().getPackageName());
// sb.append(';');
// newLine(sb);
// newLine(sb);
// }
//
// for (String staticImport : staticImports) {
// sb.append("import static "); //$NON-NLS-1$
// sb.append(staticImport);
// sb.append(';');
// newLine(sb);
// }
//
// if (staticImports.size() > 0) {
// newLine(sb);
// }
//
// Set<String> importStrings = calculateImports(importedTypes);
// for (String importString : importStrings) {
// sb.append(importString);
// newLine(sb);
// }
//
// if (importStrings.size() > 0) {
// newLine(sb);
// }
//
// sb.append(super.getFormattedContent(0, this));
//
// return sb.toString();
// }
//
// @Override
// public void addFileCommentLine(String commentLine) {
// fileCommentLines.add(commentLine);
// }
//
// @Override
// public List<String> getFileCommentLines() {
// return fileCommentLines;
// }
//
// @Override
// public void addImportedTypes(Set<FullyQualifiedJavaType> importedTypes) {
// this.importedTypes.addAll(importedTypes);
// }
//
// @Override
// public Set<String> getStaticImports() {
// return staticImports;
// }
//
// @Override
// public void addStaticImport(String staticImport) {
// staticImports.add(staticImport);
// }
//
// @Override
// public void addStaticImports(Set<String> staticImports) {
// this.staticImports.addAll(staticImports);
// }
// }
//
// Path: src/main/java/org/mybatis/generator/codegen/mybatis3/xmlmapper/MixedMapperGenerator.java
// public class MixedMapperGenerator extends XMLMapperGenerator {
//
// @Override
// protected void addSelectByPrimaryKeyElement(XmlElement parentElement) {
// }
//
// @Override
// protected void addDeleteByPrimaryKeyElement(XmlElement parentElement) {
// }
//
// @Override
// protected void addInsertElement(XmlElement parentElement) {
// }
//
// @Override
// protected void addUpdateByPrimaryKeyWithBLOBsElement(
// XmlElement parentElement) {
// }
//
// @Override
// protected void addUpdateByPrimaryKeyWithoutBLOBsElement(
// XmlElement parentElement) {
// }
// }
| import org.mybatis.generator.api.dom.java.Interface;
import org.mybatis.generator.codegen.AbstractXmlGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.AbstractJavaMapperMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedDeleteByPrimaryKeyMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedInsertMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedSelectByPrimaryKeyMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedUpdateByPrimaryKeyWithBLOBsMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedUpdateByPrimaryKeyWithoutBLOBsMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.xmlmapper.MixedMapperGenerator; |
@Override
protected void addSelectByPrimaryKeyMethod(Interface interfaze) {
if (introspectedTable.getRules().generateSelectByPrimaryKey()) {
AbstractJavaMapperMethodGenerator methodGenerator =
new AnnotatedSelectByPrimaryKeyMethodGenerator(true, false);
initializeAndExecuteGenerator(methodGenerator, interfaze);
}
}
@Override
protected void addUpdateByPrimaryKeyWithBLOBsMethod(Interface interfaze) {
if (introspectedTable.getRules().generateUpdateByPrimaryKeyWithBLOBs()) {
AbstractJavaMapperMethodGenerator methodGenerator =
new AnnotatedUpdateByPrimaryKeyWithBLOBsMethodGenerator();
initializeAndExecuteGenerator(methodGenerator, interfaze);
}
}
@Override
protected void addUpdateByPrimaryKeyWithoutBLOBsMethod(Interface interfaze) {
if (introspectedTable.getRules().generateUpdateByPrimaryKeyWithoutBLOBs()) {
AbstractJavaMapperMethodGenerator methodGenerator =
new AnnotatedUpdateByPrimaryKeyWithoutBLOBsMethodGenerator(false);
initializeAndExecuteGenerator(methodGenerator, interfaze);
}
}
@Override
public AbstractXmlGenerator getMatchedXMLGenerator() { | // Path: src/main/java/org/mybatis/generator/api/dom/java/Interface.java
// public class Interface extends InnerInterface implements CompilationUnit {
//
// private Set<FullyQualifiedJavaType> importedTypes;
//
// private Set<String> staticImports;
//
// private List<String> fileCommentLines;
//
// public Interface(FullyQualifiedJavaType type) {
// super(type);
// importedTypes = new TreeSet<FullyQualifiedJavaType>();
// fileCommentLines = new ArrayList<String>();
// staticImports = new TreeSet<String>();
// }
//
// public Interface(String type) {
// this(new FullyQualifiedJavaType(type));
// }
//
// @Override
// public Set<FullyQualifiedJavaType> getImportedTypes() {
// return importedTypes;
// }
//
// @Override
// public void addImportedType(FullyQualifiedJavaType importedType) {
// if (importedType.isExplicitlyImported()
// && !importedType.getPackageName().equals(getType().getPackageName())) {
// importedTypes.add(importedType);
// }
// }
//
// @Override
// public String getFormattedContent() {
//
// return getFormattedContent(0, this);
// }
//
// @Override
// public String getFormattedContent(int indentLevel, CompilationUnit compilationUnit) {
// StringBuilder sb = new StringBuilder();
//
// for (String commentLine : fileCommentLines) {
// sb.append(commentLine);
// newLine(sb);
// }
//
// if (stringHasValue(getType().getPackageName())) {
// sb.append("package "); //$NON-NLS-1$
// sb.append(getType().getPackageName());
// sb.append(';');
// newLine(sb);
// newLine(sb);
// }
//
// for (String staticImport : staticImports) {
// sb.append("import static "); //$NON-NLS-1$
// sb.append(staticImport);
// sb.append(';');
// newLine(sb);
// }
//
// if (staticImports.size() > 0) {
// newLine(sb);
// }
//
// Set<String> importStrings = calculateImports(importedTypes);
// for (String importString : importStrings) {
// sb.append(importString);
// newLine(sb);
// }
//
// if (importStrings.size() > 0) {
// newLine(sb);
// }
//
// sb.append(super.getFormattedContent(0, this));
//
// return sb.toString();
// }
//
// @Override
// public void addFileCommentLine(String commentLine) {
// fileCommentLines.add(commentLine);
// }
//
// @Override
// public List<String> getFileCommentLines() {
// return fileCommentLines;
// }
//
// @Override
// public void addImportedTypes(Set<FullyQualifiedJavaType> importedTypes) {
// this.importedTypes.addAll(importedTypes);
// }
//
// @Override
// public Set<String> getStaticImports() {
// return staticImports;
// }
//
// @Override
// public void addStaticImport(String staticImport) {
// staticImports.add(staticImport);
// }
//
// @Override
// public void addStaticImports(Set<String> staticImports) {
// this.staticImports.addAll(staticImports);
// }
// }
//
// Path: src/main/java/org/mybatis/generator/codegen/mybatis3/xmlmapper/MixedMapperGenerator.java
// public class MixedMapperGenerator extends XMLMapperGenerator {
//
// @Override
// protected void addSelectByPrimaryKeyElement(XmlElement parentElement) {
// }
//
// @Override
// protected void addDeleteByPrimaryKeyElement(XmlElement parentElement) {
// }
//
// @Override
// protected void addInsertElement(XmlElement parentElement) {
// }
//
// @Override
// protected void addUpdateByPrimaryKeyWithBLOBsElement(
// XmlElement parentElement) {
// }
//
// @Override
// protected void addUpdateByPrimaryKeyWithoutBLOBsElement(
// XmlElement parentElement) {
// }
// }
// Path: src/main/java/org/mybatis/generator/codegen/mybatis3/javamapper/MixedClientGenerator.java
import org.mybatis.generator.api.dom.java.Interface;
import org.mybatis.generator.codegen.AbstractXmlGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.AbstractJavaMapperMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedDeleteByPrimaryKeyMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedInsertMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedSelectByPrimaryKeyMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedUpdateByPrimaryKeyWithBLOBsMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.javamapper.elements.annotated.AnnotatedUpdateByPrimaryKeyWithoutBLOBsMethodGenerator;
import org.mybatis.generator.codegen.mybatis3.xmlmapper.MixedMapperGenerator;
@Override
protected void addSelectByPrimaryKeyMethod(Interface interfaze) {
if (introspectedTable.getRules().generateSelectByPrimaryKey()) {
AbstractJavaMapperMethodGenerator methodGenerator =
new AnnotatedSelectByPrimaryKeyMethodGenerator(true, false);
initializeAndExecuteGenerator(methodGenerator, interfaze);
}
}
@Override
protected void addUpdateByPrimaryKeyWithBLOBsMethod(Interface interfaze) {
if (introspectedTable.getRules().generateUpdateByPrimaryKeyWithBLOBs()) {
AbstractJavaMapperMethodGenerator methodGenerator =
new AnnotatedUpdateByPrimaryKeyWithBLOBsMethodGenerator();
initializeAndExecuteGenerator(methodGenerator, interfaze);
}
}
@Override
protected void addUpdateByPrimaryKeyWithoutBLOBsMethod(Interface interfaze) {
if (introspectedTable.getRules().generateUpdateByPrimaryKeyWithoutBLOBs()) {
AbstractJavaMapperMethodGenerator methodGenerator =
new AnnotatedUpdateByPrimaryKeyWithoutBLOBsMethodGenerator(false);
initializeAndExecuteGenerator(methodGenerator, interfaze);
}
}
@Override
public AbstractXmlGenerator getMatchedXMLGenerator() { | return new MixedMapperGenerator(); |
pnoker/mybatisGenerator | src/main/java/org/mybatis/generator/internal/XmlFileMergerJaxp.java | // Path: src/main/java/org/mybatis/generator/api/GeneratedXmlFile.java
// public class GeneratedXmlFile extends GeneratedFile {
//
// /** The document. */
// private Document document;
//
// /** The file name. */
// private String fileName;
//
// /** The target package. */
// private String targetPackage;
//
// /** The is mergeable. */
// private boolean isMergeable;
//
// /** The xml formatter. */
// private XmlFormatter xmlFormatter;
//
// /**
// * Instantiates a new generated xml file.
// *
// * @param document
// * the document
// * @param fileName
// * the file name
// * @param targetPackage
// * the target package
// * @param targetProject
// * the target project
// * @param isMergeable
// * true if the file can be merged by the built in XML file merger.
// * @param xmlFormatter
// * the xml formatter
// */
// public GeneratedXmlFile(Document document, String fileName,
// String targetPackage, String targetProject, boolean isMergeable,
// XmlFormatter xmlFormatter) {
// super(targetProject);
// this.document = document;
// this.fileName = fileName;
// this.targetPackage = targetPackage;
// this.isMergeable = isMergeable;
// this.xmlFormatter = xmlFormatter;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.GeneratedFile#getFormattedContent()
// */
// @Override
// public String getFormattedContent() {
// return xmlFormatter.getFormattedContent(document);
// }
//
// /**
// * Gets the file name.
// *
// * @return Returns the fileName.
// */
// @Override
// public String getFileName() {
// return fileName;
// }
//
// /**
// * Gets the target package.
// *
// * @return Returns the targetPackage.
// */
// @Override
// public String getTargetPackage() {
// return targetPackage;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.GeneratedFile#isMergeable()
// */
// @Override
// public boolean isMergeable() {
// return isMergeable;
// }
//
// public void setMergeable(boolean isMergeable) {
// this.isMergeable = isMergeable;
// }
// }
| import static org.mybatis.generator.internal.util.messages.Messages.getString;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.mybatis.generator.api.GeneratedXmlFile;
import org.mybatis.generator.config.MergeConstants;
import org.mybatis.generator.exception.ShellException;
import org.w3c.dom.Comment;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException; | /**
* Copyright 2006-2017 the original author or authors.
*
* 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.mybatis.generator.internal;
/**
* This class handles the task of merging changes into an existing XML file.
*
* @author Jeff Butler
*/
public class XmlFileMergerJaxp {
private static class NullEntityResolver implements EntityResolver {
/**
* returns an empty reader. This is done so that the parser doesn't
* attempt to read a DTD. We don't need that support for the merge and
* it can cause problems on systems that aren't Internet connected.
*/
@Override
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, IOException {
StringReader sr = new StringReader(""); //$NON-NLS-1$
return new InputSource(sr);
}
}
/**
* Utility class - no instances allowed
*/
private XmlFileMergerJaxp() {
super();
}
| // Path: src/main/java/org/mybatis/generator/api/GeneratedXmlFile.java
// public class GeneratedXmlFile extends GeneratedFile {
//
// /** The document. */
// private Document document;
//
// /** The file name. */
// private String fileName;
//
// /** The target package. */
// private String targetPackage;
//
// /** The is mergeable. */
// private boolean isMergeable;
//
// /** The xml formatter. */
// private XmlFormatter xmlFormatter;
//
// /**
// * Instantiates a new generated xml file.
// *
// * @param document
// * the document
// * @param fileName
// * the file name
// * @param targetPackage
// * the target package
// * @param targetProject
// * the target project
// * @param isMergeable
// * true if the file can be merged by the built in XML file merger.
// * @param xmlFormatter
// * the xml formatter
// */
// public GeneratedXmlFile(Document document, String fileName,
// String targetPackage, String targetProject, boolean isMergeable,
// XmlFormatter xmlFormatter) {
// super(targetProject);
// this.document = document;
// this.fileName = fileName;
// this.targetPackage = targetPackage;
// this.isMergeable = isMergeable;
// this.xmlFormatter = xmlFormatter;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.GeneratedFile#getFormattedContent()
// */
// @Override
// public String getFormattedContent() {
// return xmlFormatter.getFormattedContent(document);
// }
//
// /**
// * Gets the file name.
// *
// * @return Returns the fileName.
// */
// @Override
// public String getFileName() {
// return fileName;
// }
//
// /**
// * Gets the target package.
// *
// * @return Returns the targetPackage.
// */
// @Override
// public String getTargetPackage() {
// return targetPackage;
// }
//
// /* (non-Javadoc)
// * @see org.mybatis.generator.api.GeneratedFile#isMergeable()
// */
// @Override
// public boolean isMergeable() {
// return isMergeable;
// }
//
// public void setMergeable(boolean isMergeable) {
// this.isMergeable = isMergeable;
// }
// }
// Path: src/main/java/org/mybatis/generator/internal/XmlFileMergerJaxp.java
import static org.mybatis.generator.internal.util.messages.Messages.getString;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.mybatis.generator.api.GeneratedXmlFile;
import org.mybatis.generator.config.MergeConstants;
import org.mybatis.generator.exception.ShellException;
import org.w3c.dom.Comment;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
* Copyright 2006-2017 the original author or authors.
*
* 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.mybatis.generator.internal;
/**
* This class handles the task of merging changes into an existing XML file.
*
* @author Jeff Butler
*/
public class XmlFileMergerJaxp {
private static class NullEntityResolver implements EntityResolver {
/**
* returns an empty reader. This is done so that the parser doesn't
* attempt to read a DTD. We don't need that support for the merge and
* it can cause problems on systems that aren't Internet connected.
*/
@Override
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, IOException {
StringReader sr = new StringReader(""); //$NON-NLS-1$
return new InputSource(sr);
}
}
/**
* Utility class - no instances allowed
*/
private XmlFileMergerJaxp() {
super();
}
| public static String getMergedSource(GeneratedXmlFile generatedXmlFile, |
franmontiel/LocaleChanger | sample/src/androidTest/java/com/franmontiel/localechanger/sample/SampleScreenTestDelegate.java | // Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/pageobjects/SampleScreen.java
// public class SampleScreen {
//
// private final static int LOCALE_SPINNER_ID = R.id.localeSpinner;
// private final static int UPDATE_BUTTON_ID = R.id.localeUpdate;
//
// private ActivityTestRule<? extends Activity> activityRule;
//
// public SampleScreen(Class<? extends Activity> activityClass) {
// this.activityRule = new ActivityTestRule<>(activityClass, false, false);
// }
//
// public SampleScreen launch() {
// activityRule.launchActivity(null);
// return this;
// }
//
// public SampleScreen changeLocale(Locale locale) {
// onView(withId(LOCALE_SPINNER_ID)).perform(click());
// onData(allOf(is(instanceOf(Locale.class)), is(locale))).perform(click());
//
// onView(withId(UPDATE_BUTTON_ID)).perform(click());
// SystemClock.sleep(500);
//
// return this;
// }
//
// public SampleScreen openNewScreen() {
// onView(allOf(withId(R.id.openNewScreen), withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))).perform(click());
// return this;
// }
//
// public SampleScreen verifyLocaleChanged(Locale expectedLocale) {
// onView(withId(R.id.currentLocale)).check(matches(withText(expectedLocale.toString())));
// return this;
// }
//
// public SampleScreen verifyDate(String expectedDateFormat) {
// onView(withId(R.id.date)).check(matches(withText(expectedDateFormat)));
// return this;
// }
//
// public SampleScreen verifyUpdateButtonText(String expectedText) {
// onView(withId(R.id.localeUpdate)).check(matches(withText(expectedText)));
// return this;
// }
//
// public SampleScreen verifyOverflowSettingsItemTitle(String expectedTitle) {
// openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
//
// // The MenuItem id and the View id is not the same. It is needed to use another matcher.
// onView(withText(expectedTitle)).check(matches(isDisplayed()));
//
// return this;
// }
//
// public SampleScreen verifyLayoutDirectionRTL() {
// onView(withId(R.id.currentLocale)).check(isCompletelyLeftOf(withId(R.id.currentLocaleTitle)));
//
// return this;
// }
//
// public SampleScreen verifyLayoutDirectionLTR() {
// onView(withId(R.id.currentLocale)).check(isCompletelyRightOf(withId(R.id.currentLocaleTitle)));
//
// return this;
// }
//
// public SampleScreen changeOrientationToLandscape() {
// onView(isRoot()).perform(orientationLandscape());
// SystemClock.sleep(500);
// return this;
// }
//
// public SampleScreen changeOrientationToPortrait() {
// onView(isRoot()).perform(orientationPortrait());
// SystemClock.sleep(500);
// return this;
// }
//
// public SampleScreen pressBack() {
// Espresso.pressBack();
// return this;
// }
// }
| import com.franmontiel.localechanger.sample.pageobjects.SampleScreen;
import java.util.Locale; | /*
* Copyright (c) 2018 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger.sample;
/**
* Advice: It is recommended to run the tests with a system locale configured not listed in the supported ones (to avoid false positives).
*/
final public class SampleScreenTestDelegate {
private final Locale LOCALE_EN_EN = new Locale("en", "US");
private final Locale LOCALE_ES_ES = new Locale("es", "ES");
private static final Locale LOCALE_AR_JO = new Locale("ar", "JO");
private final String BUTTON_TEXT_ES = "Actualizar Locale";
private static final String SETTINGS_ITEM_TITLE_ES = "Preferencias";
| // Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/pageobjects/SampleScreen.java
// public class SampleScreen {
//
// private final static int LOCALE_SPINNER_ID = R.id.localeSpinner;
// private final static int UPDATE_BUTTON_ID = R.id.localeUpdate;
//
// private ActivityTestRule<? extends Activity> activityRule;
//
// public SampleScreen(Class<? extends Activity> activityClass) {
// this.activityRule = new ActivityTestRule<>(activityClass, false, false);
// }
//
// public SampleScreen launch() {
// activityRule.launchActivity(null);
// return this;
// }
//
// public SampleScreen changeLocale(Locale locale) {
// onView(withId(LOCALE_SPINNER_ID)).perform(click());
// onData(allOf(is(instanceOf(Locale.class)), is(locale))).perform(click());
//
// onView(withId(UPDATE_BUTTON_ID)).perform(click());
// SystemClock.sleep(500);
//
// return this;
// }
//
// public SampleScreen openNewScreen() {
// onView(allOf(withId(R.id.openNewScreen), withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))).perform(click());
// return this;
// }
//
// public SampleScreen verifyLocaleChanged(Locale expectedLocale) {
// onView(withId(R.id.currentLocale)).check(matches(withText(expectedLocale.toString())));
// return this;
// }
//
// public SampleScreen verifyDate(String expectedDateFormat) {
// onView(withId(R.id.date)).check(matches(withText(expectedDateFormat)));
// return this;
// }
//
// public SampleScreen verifyUpdateButtonText(String expectedText) {
// onView(withId(R.id.localeUpdate)).check(matches(withText(expectedText)));
// return this;
// }
//
// public SampleScreen verifyOverflowSettingsItemTitle(String expectedTitle) {
// openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
//
// // The MenuItem id and the View id is not the same. It is needed to use another matcher.
// onView(withText(expectedTitle)).check(matches(isDisplayed()));
//
// return this;
// }
//
// public SampleScreen verifyLayoutDirectionRTL() {
// onView(withId(R.id.currentLocale)).check(isCompletelyLeftOf(withId(R.id.currentLocaleTitle)));
//
// return this;
// }
//
// public SampleScreen verifyLayoutDirectionLTR() {
// onView(withId(R.id.currentLocale)).check(isCompletelyRightOf(withId(R.id.currentLocaleTitle)));
//
// return this;
// }
//
// public SampleScreen changeOrientationToLandscape() {
// onView(isRoot()).perform(orientationLandscape());
// SystemClock.sleep(500);
// return this;
// }
//
// public SampleScreen changeOrientationToPortrait() {
// onView(isRoot()).perform(orientationPortrait());
// SystemClock.sleep(500);
// return this;
// }
//
// public SampleScreen pressBack() {
// Espresso.pressBack();
// return this;
// }
// }
// Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/SampleScreenTestDelegate.java
import com.franmontiel.localechanger.sample.pageobjects.SampleScreen;
import java.util.Locale;
/*
* Copyright (c) 2018 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger.sample;
/**
* Advice: It is recommended to run the tests with a system locale configured not listed in the supported ones (to avoid false positives).
*/
final public class SampleScreenTestDelegate {
private final Locale LOCALE_EN_EN = new Locale("en", "US");
private final Locale LOCALE_ES_ES = new Locale("es", "ES");
private static final Locale LOCALE_AR_JO = new Locale("ar", "JO");
private final String BUTTON_TEXT_ES = "Actualizar Locale";
private static final String SETTINGS_ITEM_TITLE_ES = "Preferencias";
| private SampleScreen sampleScreen; |
franmontiel/LocaleChanger | library/src/main/java/com/franmontiel/localechanger/LocaleChanger.java | // Path: library/src/main/java/com/franmontiel/localechanger/matcher/LanguageMatchingAlgorithm.java
// public final class LanguageMatchingAlgorithm implements MatchingAlgorithm {
//
// @Override
// public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
// MatchingLocales matchingPair = null;
// for (Locale systemLocale : systemLocales) {
// Locale matchingSupportedLocale = findMatchingLocale(systemLocale, supportedLocales);
// if (matchingSupportedLocale != null) {
// matchingPair = new MatchingLocales(matchingSupportedLocale, systemLocale);
// break;
// }
// }
// return matchingPair;
// }
//
// @Override
// public MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales) {
// Locale matchingSystemLocale = findMatchingLocale(supportedLocale, systemLocales);
// return matchingSystemLocale != null ?
// new MatchingLocales(supportedLocale, matchingSystemLocale) :
// null;
// }
//
// private static Locale findMatchingLocale(Locale localeToMatch, List<Locale> candidates) {
// Locale matchingLocale = null;
// for (Locale candidate : candidates) {
// LocaleMatcher.MatchLevel matchLevel = LocaleMatcher.match(localeToMatch, candidate);
//
// if (matchLevel != LocaleMatcher.MatchLevel.NoMatch) {
// matchingLocale = candidate;
// break;
// }
// }
// return matchingLocale;
// }
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/utils/SystemLocaleRetriever.java
// public class SystemLocaleRetriever {
//
// private SystemLocaleRetriever() {
// }
//
// public static List<Locale> retrieve() {
// List<Locale> systemLocales;
//
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// systemLocales = mapToListOfLocales(LocaleList.getDefault());
// } else {
// systemLocales = Collections.singletonList(Locale.getDefault());
// }
// return systemLocales;
// }
//
// @RequiresApi(api = Build.VERSION_CODES.N)
// private static List<Locale> mapToListOfLocales(LocaleList localeList) {
// List<Locale> locales = new ArrayList<>();
// for (int i = 0; i < localeList.size(); i++) {
// locales.add(localeList.get(i));
// }
// return locales;
// }
// }
| import android.content.Context;
import com.franmontiel.localechanger.matcher.LanguageMatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import com.franmontiel.localechanger.utils.SystemLocaleRetriever;
import java.util.List;
import java.util.Locale; | /*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger;
public class LocaleChanger {
private static LocaleChangerDelegate delegate;
private LocaleChanger() {
}
/**
* Initialize the LocaleChanger, this method needs to be called before calling any other method.
* <p>
* If this method was never invoked before it sets a Locale from the supported list if a language match is found with the system Locales,
* if no match is found the first Locale in the list will be set.<p>
* If this method was invoked before it will load a Locale previously set.
* <p>
* If this method is invoked when the library is already initialized the new settings will be applied from now on.
*
* @param context
* @param supportedLocales a list of your app supported Locales
* @throws IllegalStateException if the LocaleChanger is already initialized
*/
public static void initialize(Context context, List<Locale> supportedLocales) {
initialize(context,
supportedLocales, | // Path: library/src/main/java/com/franmontiel/localechanger/matcher/LanguageMatchingAlgorithm.java
// public final class LanguageMatchingAlgorithm implements MatchingAlgorithm {
//
// @Override
// public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
// MatchingLocales matchingPair = null;
// for (Locale systemLocale : systemLocales) {
// Locale matchingSupportedLocale = findMatchingLocale(systemLocale, supportedLocales);
// if (matchingSupportedLocale != null) {
// matchingPair = new MatchingLocales(matchingSupportedLocale, systemLocale);
// break;
// }
// }
// return matchingPair;
// }
//
// @Override
// public MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales) {
// Locale matchingSystemLocale = findMatchingLocale(supportedLocale, systemLocales);
// return matchingSystemLocale != null ?
// new MatchingLocales(supportedLocale, matchingSystemLocale) :
// null;
// }
//
// private static Locale findMatchingLocale(Locale localeToMatch, List<Locale> candidates) {
// Locale matchingLocale = null;
// for (Locale candidate : candidates) {
// LocaleMatcher.MatchLevel matchLevel = LocaleMatcher.match(localeToMatch, candidate);
//
// if (matchLevel != LocaleMatcher.MatchLevel.NoMatch) {
// matchingLocale = candidate;
// break;
// }
// }
// return matchingLocale;
// }
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/utils/SystemLocaleRetriever.java
// public class SystemLocaleRetriever {
//
// private SystemLocaleRetriever() {
// }
//
// public static List<Locale> retrieve() {
// List<Locale> systemLocales;
//
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// systemLocales = mapToListOfLocales(LocaleList.getDefault());
// } else {
// systemLocales = Collections.singletonList(Locale.getDefault());
// }
// return systemLocales;
// }
//
// @RequiresApi(api = Build.VERSION_CODES.N)
// private static List<Locale> mapToListOfLocales(LocaleList localeList) {
// List<Locale> locales = new ArrayList<>();
// for (int i = 0; i < localeList.size(); i++) {
// locales.add(localeList.get(i));
// }
// return locales;
// }
// }
// Path: library/src/main/java/com/franmontiel/localechanger/LocaleChanger.java
import android.content.Context;
import com.franmontiel.localechanger.matcher.LanguageMatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import com.franmontiel.localechanger.utils.SystemLocaleRetriever;
import java.util.List;
import java.util.Locale;
/*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger;
public class LocaleChanger {
private static LocaleChangerDelegate delegate;
private LocaleChanger() {
}
/**
* Initialize the LocaleChanger, this method needs to be called before calling any other method.
* <p>
* If this method was never invoked before it sets a Locale from the supported list if a language match is found with the system Locales,
* if no match is found the first Locale in the list will be set.<p>
* If this method was invoked before it will load a Locale previously set.
* <p>
* If this method is invoked when the library is already initialized the new settings will be applied from now on.
*
* @param context
* @param supportedLocales a list of your app supported Locales
* @throws IllegalStateException if the LocaleChanger is already initialized
*/
public static void initialize(Context context, List<Locale> supportedLocales) {
initialize(context,
supportedLocales, | new LanguageMatchingAlgorithm(), |
franmontiel/LocaleChanger | library/src/main/java/com/franmontiel/localechanger/LocaleChanger.java | // Path: library/src/main/java/com/franmontiel/localechanger/matcher/LanguageMatchingAlgorithm.java
// public final class LanguageMatchingAlgorithm implements MatchingAlgorithm {
//
// @Override
// public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
// MatchingLocales matchingPair = null;
// for (Locale systemLocale : systemLocales) {
// Locale matchingSupportedLocale = findMatchingLocale(systemLocale, supportedLocales);
// if (matchingSupportedLocale != null) {
// matchingPair = new MatchingLocales(matchingSupportedLocale, systemLocale);
// break;
// }
// }
// return matchingPair;
// }
//
// @Override
// public MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales) {
// Locale matchingSystemLocale = findMatchingLocale(supportedLocale, systemLocales);
// return matchingSystemLocale != null ?
// new MatchingLocales(supportedLocale, matchingSystemLocale) :
// null;
// }
//
// private static Locale findMatchingLocale(Locale localeToMatch, List<Locale> candidates) {
// Locale matchingLocale = null;
// for (Locale candidate : candidates) {
// LocaleMatcher.MatchLevel matchLevel = LocaleMatcher.match(localeToMatch, candidate);
//
// if (matchLevel != LocaleMatcher.MatchLevel.NoMatch) {
// matchingLocale = candidate;
// break;
// }
// }
// return matchingLocale;
// }
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/utils/SystemLocaleRetriever.java
// public class SystemLocaleRetriever {
//
// private SystemLocaleRetriever() {
// }
//
// public static List<Locale> retrieve() {
// List<Locale> systemLocales;
//
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// systemLocales = mapToListOfLocales(LocaleList.getDefault());
// } else {
// systemLocales = Collections.singletonList(Locale.getDefault());
// }
// return systemLocales;
// }
//
// @RequiresApi(api = Build.VERSION_CODES.N)
// private static List<Locale> mapToListOfLocales(LocaleList localeList) {
// List<Locale> locales = new ArrayList<>();
// for (int i = 0; i < localeList.size(); i++) {
// locales.add(localeList.get(i));
// }
// return locales;
// }
// }
| import android.content.Context;
import com.franmontiel.localechanger.matcher.LanguageMatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import com.franmontiel.localechanger.utils.SystemLocaleRetriever;
import java.util.List;
import java.util.Locale; | /*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger;
public class LocaleChanger {
private static LocaleChangerDelegate delegate;
private LocaleChanger() {
}
/**
* Initialize the LocaleChanger, this method needs to be called before calling any other method.
* <p>
* If this method was never invoked before it sets a Locale from the supported list if a language match is found with the system Locales,
* if no match is found the first Locale in the list will be set.<p>
* If this method was invoked before it will load a Locale previously set.
* <p>
* If this method is invoked when the library is already initialized the new settings will be applied from now on.
*
* @param context
* @param supportedLocales a list of your app supported Locales
* @throws IllegalStateException if the LocaleChanger is already initialized
*/
public static void initialize(Context context, List<Locale> supportedLocales) {
initialize(context,
supportedLocales,
new LanguageMatchingAlgorithm(),
LocalePreference.PreferSupportedLocale);
}
/**
* Initialize the LocaleChanger, this method needs to be called before calling any other method.
* <p>
* If this method was never invoked before it sets a Locale resolved using the provided {@link MatchingAlgorithm} and {@link LocalePreference}.<p>
* If this method was invoked before it will load a Locale previously set.
* <p>
* If this method is invoked when the library is already initialized the new settings will be applied from now on.
*
* @param context
* @param supportedLocales a list of your app supported Locales
* @param matchingAlgorithm used to find a match between supported and system Locales
* @param preference used to indicate what Locale is preferred to load in case of a match
*/
public static void initialize(Context context,
List<Locale> supportedLocales, | // Path: library/src/main/java/com/franmontiel/localechanger/matcher/LanguageMatchingAlgorithm.java
// public final class LanguageMatchingAlgorithm implements MatchingAlgorithm {
//
// @Override
// public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
// MatchingLocales matchingPair = null;
// for (Locale systemLocale : systemLocales) {
// Locale matchingSupportedLocale = findMatchingLocale(systemLocale, supportedLocales);
// if (matchingSupportedLocale != null) {
// matchingPair = new MatchingLocales(matchingSupportedLocale, systemLocale);
// break;
// }
// }
// return matchingPair;
// }
//
// @Override
// public MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales) {
// Locale matchingSystemLocale = findMatchingLocale(supportedLocale, systemLocales);
// return matchingSystemLocale != null ?
// new MatchingLocales(supportedLocale, matchingSystemLocale) :
// null;
// }
//
// private static Locale findMatchingLocale(Locale localeToMatch, List<Locale> candidates) {
// Locale matchingLocale = null;
// for (Locale candidate : candidates) {
// LocaleMatcher.MatchLevel matchLevel = LocaleMatcher.match(localeToMatch, candidate);
//
// if (matchLevel != LocaleMatcher.MatchLevel.NoMatch) {
// matchingLocale = candidate;
// break;
// }
// }
// return matchingLocale;
// }
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/utils/SystemLocaleRetriever.java
// public class SystemLocaleRetriever {
//
// private SystemLocaleRetriever() {
// }
//
// public static List<Locale> retrieve() {
// List<Locale> systemLocales;
//
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// systemLocales = mapToListOfLocales(LocaleList.getDefault());
// } else {
// systemLocales = Collections.singletonList(Locale.getDefault());
// }
// return systemLocales;
// }
//
// @RequiresApi(api = Build.VERSION_CODES.N)
// private static List<Locale> mapToListOfLocales(LocaleList localeList) {
// List<Locale> locales = new ArrayList<>();
// for (int i = 0; i < localeList.size(); i++) {
// locales.add(localeList.get(i));
// }
// return locales;
// }
// }
// Path: library/src/main/java/com/franmontiel/localechanger/LocaleChanger.java
import android.content.Context;
import com.franmontiel.localechanger.matcher.LanguageMatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import com.franmontiel.localechanger.utils.SystemLocaleRetriever;
import java.util.List;
import java.util.Locale;
/*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger;
public class LocaleChanger {
private static LocaleChangerDelegate delegate;
private LocaleChanger() {
}
/**
* Initialize the LocaleChanger, this method needs to be called before calling any other method.
* <p>
* If this method was never invoked before it sets a Locale from the supported list if a language match is found with the system Locales,
* if no match is found the first Locale in the list will be set.<p>
* If this method was invoked before it will load a Locale previously set.
* <p>
* If this method is invoked when the library is already initialized the new settings will be applied from now on.
*
* @param context
* @param supportedLocales a list of your app supported Locales
* @throws IllegalStateException if the LocaleChanger is already initialized
*/
public static void initialize(Context context, List<Locale> supportedLocales) {
initialize(context,
supportedLocales,
new LanguageMatchingAlgorithm(),
LocalePreference.PreferSupportedLocale);
}
/**
* Initialize the LocaleChanger, this method needs to be called before calling any other method.
* <p>
* If this method was never invoked before it sets a Locale resolved using the provided {@link MatchingAlgorithm} and {@link LocalePreference}.<p>
* If this method was invoked before it will load a Locale previously set.
* <p>
* If this method is invoked when the library is already initialized the new settings will be applied from now on.
*
* @param context
* @param supportedLocales a list of your app supported Locales
* @param matchingAlgorithm used to find a match between supported and system Locales
* @param preference used to indicate what Locale is preferred to load in case of a match
*/
public static void initialize(Context context,
List<Locale> supportedLocales, | MatchingAlgorithm matchingAlgorithm, |
franmontiel/LocaleChanger | library/src/main/java/com/franmontiel/localechanger/LocaleChanger.java | // Path: library/src/main/java/com/franmontiel/localechanger/matcher/LanguageMatchingAlgorithm.java
// public final class LanguageMatchingAlgorithm implements MatchingAlgorithm {
//
// @Override
// public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
// MatchingLocales matchingPair = null;
// for (Locale systemLocale : systemLocales) {
// Locale matchingSupportedLocale = findMatchingLocale(systemLocale, supportedLocales);
// if (matchingSupportedLocale != null) {
// matchingPair = new MatchingLocales(matchingSupportedLocale, systemLocale);
// break;
// }
// }
// return matchingPair;
// }
//
// @Override
// public MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales) {
// Locale matchingSystemLocale = findMatchingLocale(supportedLocale, systemLocales);
// return matchingSystemLocale != null ?
// new MatchingLocales(supportedLocale, matchingSystemLocale) :
// null;
// }
//
// private static Locale findMatchingLocale(Locale localeToMatch, List<Locale> candidates) {
// Locale matchingLocale = null;
// for (Locale candidate : candidates) {
// LocaleMatcher.MatchLevel matchLevel = LocaleMatcher.match(localeToMatch, candidate);
//
// if (matchLevel != LocaleMatcher.MatchLevel.NoMatch) {
// matchingLocale = candidate;
// break;
// }
// }
// return matchingLocale;
// }
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/utils/SystemLocaleRetriever.java
// public class SystemLocaleRetriever {
//
// private SystemLocaleRetriever() {
// }
//
// public static List<Locale> retrieve() {
// List<Locale> systemLocales;
//
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// systemLocales = mapToListOfLocales(LocaleList.getDefault());
// } else {
// systemLocales = Collections.singletonList(Locale.getDefault());
// }
// return systemLocales;
// }
//
// @RequiresApi(api = Build.VERSION_CODES.N)
// private static List<Locale> mapToListOfLocales(LocaleList localeList) {
// List<Locale> locales = new ArrayList<>();
// for (int i = 0; i < localeList.size(); i++) {
// locales.add(localeList.get(i));
// }
// return locales;
// }
// }
| import android.content.Context;
import com.franmontiel.localechanger.matcher.LanguageMatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import com.franmontiel.localechanger.utils.SystemLocaleRetriever;
import java.util.List;
import java.util.Locale; | /*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger;
public class LocaleChanger {
private static LocaleChangerDelegate delegate;
private LocaleChanger() {
}
/**
* Initialize the LocaleChanger, this method needs to be called before calling any other method.
* <p>
* If this method was never invoked before it sets a Locale from the supported list if a language match is found with the system Locales,
* if no match is found the first Locale in the list will be set.<p>
* If this method was invoked before it will load a Locale previously set.
* <p>
* If this method is invoked when the library is already initialized the new settings will be applied from now on.
*
* @param context
* @param supportedLocales a list of your app supported Locales
* @throws IllegalStateException if the LocaleChanger is already initialized
*/
public static void initialize(Context context, List<Locale> supportedLocales) {
initialize(context,
supportedLocales,
new LanguageMatchingAlgorithm(),
LocalePreference.PreferSupportedLocale);
}
/**
* Initialize the LocaleChanger, this method needs to be called before calling any other method.
* <p>
* If this method was never invoked before it sets a Locale resolved using the provided {@link MatchingAlgorithm} and {@link LocalePreference}.<p>
* If this method was invoked before it will load a Locale previously set.
* <p>
* If this method is invoked when the library is already initialized the new settings will be applied from now on.
*
* @param context
* @param supportedLocales a list of your app supported Locales
* @param matchingAlgorithm used to find a match between supported and system Locales
* @param preference used to indicate what Locale is preferred to load in case of a match
*/
public static void initialize(Context context,
List<Locale> supportedLocales,
MatchingAlgorithm matchingAlgorithm,
LocalePreference preference) {
delegate = new LocaleChangerDelegate(
new LocalePersistor(context),
new LocaleResolver(supportedLocales, | // Path: library/src/main/java/com/franmontiel/localechanger/matcher/LanguageMatchingAlgorithm.java
// public final class LanguageMatchingAlgorithm implements MatchingAlgorithm {
//
// @Override
// public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
// MatchingLocales matchingPair = null;
// for (Locale systemLocale : systemLocales) {
// Locale matchingSupportedLocale = findMatchingLocale(systemLocale, supportedLocales);
// if (matchingSupportedLocale != null) {
// matchingPair = new MatchingLocales(matchingSupportedLocale, systemLocale);
// break;
// }
// }
// return matchingPair;
// }
//
// @Override
// public MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales) {
// Locale matchingSystemLocale = findMatchingLocale(supportedLocale, systemLocales);
// return matchingSystemLocale != null ?
// new MatchingLocales(supportedLocale, matchingSystemLocale) :
// null;
// }
//
// private static Locale findMatchingLocale(Locale localeToMatch, List<Locale> candidates) {
// Locale matchingLocale = null;
// for (Locale candidate : candidates) {
// LocaleMatcher.MatchLevel matchLevel = LocaleMatcher.match(localeToMatch, candidate);
//
// if (matchLevel != LocaleMatcher.MatchLevel.NoMatch) {
// matchingLocale = candidate;
// break;
// }
// }
// return matchingLocale;
// }
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/utils/SystemLocaleRetriever.java
// public class SystemLocaleRetriever {
//
// private SystemLocaleRetriever() {
// }
//
// public static List<Locale> retrieve() {
// List<Locale> systemLocales;
//
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// systemLocales = mapToListOfLocales(LocaleList.getDefault());
// } else {
// systemLocales = Collections.singletonList(Locale.getDefault());
// }
// return systemLocales;
// }
//
// @RequiresApi(api = Build.VERSION_CODES.N)
// private static List<Locale> mapToListOfLocales(LocaleList localeList) {
// List<Locale> locales = new ArrayList<>();
// for (int i = 0; i < localeList.size(); i++) {
// locales.add(localeList.get(i));
// }
// return locales;
// }
// }
// Path: library/src/main/java/com/franmontiel/localechanger/LocaleChanger.java
import android.content.Context;
import com.franmontiel.localechanger.matcher.LanguageMatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import com.franmontiel.localechanger.utils.SystemLocaleRetriever;
import java.util.List;
import java.util.Locale;
/*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger;
public class LocaleChanger {
private static LocaleChangerDelegate delegate;
private LocaleChanger() {
}
/**
* Initialize the LocaleChanger, this method needs to be called before calling any other method.
* <p>
* If this method was never invoked before it sets a Locale from the supported list if a language match is found with the system Locales,
* if no match is found the first Locale in the list will be set.<p>
* If this method was invoked before it will load a Locale previously set.
* <p>
* If this method is invoked when the library is already initialized the new settings will be applied from now on.
*
* @param context
* @param supportedLocales a list of your app supported Locales
* @throws IllegalStateException if the LocaleChanger is already initialized
*/
public static void initialize(Context context, List<Locale> supportedLocales) {
initialize(context,
supportedLocales,
new LanguageMatchingAlgorithm(),
LocalePreference.PreferSupportedLocale);
}
/**
* Initialize the LocaleChanger, this method needs to be called before calling any other method.
* <p>
* If this method was never invoked before it sets a Locale resolved using the provided {@link MatchingAlgorithm} and {@link LocalePreference}.<p>
* If this method was invoked before it will load a Locale previously set.
* <p>
* If this method is invoked when the library is already initialized the new settings will be applied from now on.
*
* @param context
* @param supportedLocales a list of your app supported Locales
* @param matchingAlgorithm used to find a match between supported and system Locales
* @param preference used to indicate what Locale is preferred to load in case of a match
*/
public static void initialize(Context context,
List<Locale> supportedLocales,
MatchingAlgorithm matchingAlgorithm,
LocalePreference preference) {
delegate = new LocaleChangerDelegate(
new LocalePersistor(context),
new LocaleResolver(supportedLocales, | SystemLocaleRetriever.retrieve(), |
franmontiel/LocaleChanger | library/src/main/java/com/franmontiel/localechanger/base/LocaleChangerBaseApplication.java | // Path: library/src/main/java/com/franmontiel/localechanger/LocaleChanger.java
// public class LocaleChanger {
//
// private static LocaleChangerDelegate delegate;
//
// private LocaleChanger() {
// }
//
// /**
// * Initialize the LocaleChanger, this method needs to be called before calling any other method.
// * <p>
// * If this method was never invoked before it sets a Locale from the supported list if a language match is found with the system Locales,
// * if no match is found the first Locale in the list will be set.<p>
// * If this method was invoked before it will load a Locale previously set.
// * <p>
// * If this method is invoked when the library is already initialized the new settings will be applied from now on.
// *
// * @param context
// * @param supportedLocales a list of your app supported Locales
// * @throws IllegalStateException if the LocaleChanger is already initialized
// */
// public static void initialize(Context context, List<Locale> supportedLocales) {
// initialize(context,
// supportedLocales,
// new LanguageMatchingAlgorithm(),
// LocalePreference.PreferSupportedLocale);
// }
//
// /**
// * Initialize the LocaleChanger, this method needs to be called before calling any other method.
// * <p>
// * If this method was never invoked before it sets a Locale resolved using the provided {@link MatchingAlgorithm} and {@link LocalePreference}.<p>
// * If this method was invoked before it will load a Locale previously set.
// * <p>
// * If this method is invoked when the library is already initialized the new settings will be applied from now on.
// *
// * @param context
// * @param supportedLocales a list of your app supported Locales
// * @param matchingAlgorithm used to find a match between supported and system Locales
// * @param preference used to indicate what Locale is preferred to load in case of a match
// */
// public static void initialize(Context context,
// List<Locale> supportedLocales,
// MatchingAlgorithm matchingAlgorithm,
// LocalePreference preference) {
//
// delegate = new LocaleChangerDelegate(
// new LocalePersistor(context),
// new LocaleResolver(supportedLocales,
// SystemLocaleRetriever.retrieve(),
// matchingAlgorithm,
// preference),
// new AppLocaleChanger(context)
// );
//
// delegate.initialize();
// }
//
// private static void checkInitialization() {
// if (delegate == null)
// throw new IllegalStateException("LocaleChanger is not initialized. Please first call LocaleChanger.initialize");
// }
//
// /**
// * Clears any Locale set and resolve and load a new default one.
// * This method can be useful if the app implements new supported Locales and it is needed to reload the default one in case there is a best match.
// */
// public static void resetLocale() {
// checkInitialization();
// delegate.resetLocale();
// }
//
// /**
// * Sets a new default app Locale that will be resolved from the one provided.
// *
// * @param supportedLocale a supported Locale that will be used to resolve the Locale to set.
// */
// public static void setLocale(Locale supportedLocale) {
// checkInitialization();
// delegate.setLocale(supportedLocale);
// }
//
// /**
// * Gets the supported Locale that has been used to set the app Locale.
// *
// * @return
// */
// public static Locale getLocale() {
// checkInitialization();
// return delegate.getLocale();
// }
//
// /**
// * This method should be used inside the Activity attachBaseContext.
// * The returned Context should be used as argument for the super method call.
// *
// * @param context
// * @return the resulting context that should be provided to the super method call.
// */
// public static Context configureBaseContext(Context context) {
// checkInitialization();
// return delegate.configureBaseContext(context);
// }
//
// /**
// * This method should be called from Application#onConfigurationChanged()
// */
// public static void onConfigurationChanged() {
// checkInitialization();
// delegate.onConfigurationChanged();
// }
// }
| import android.app.Application;
import android.content.Context;
import android.content.res.Configuration;
import androidx.annotation.NonNull;
import com.franmontiel.localechanger.LocaleChanger;
import java.util.List; | package com.franmontiel.localechanger.base;
/**
* Base {@link Application} class to inherit from with all needed configuration.
*/
public abstract class LocaleChangerBaseApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
this.initializeLocaleChanger();
}
/**
* Call {@link LocaleChanger#initialize(Context, List)} in here
*/
public abstract void initializeLocaleChanger();
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig); | // Path: library/src/main/java/com/franmontiel/localechanger/LocaleChanger.java
// public class LocaleChanger {
//
// private static LocaleChangerDelegate delegate;
//
// private LocaleChanger() {
// }
//
// /**
// * Initialize the LocaleChanger, this method needs to be called before calling any other method.
// * <p>
// * If this method was never invoked before it sets a Locale from the supported list if a language match is found with the system Locales,
// * if no match is found the first Locale in the list will be set.<p>
// * If this method was invoked before it will load a Locale previously set.
// * <p>
// * If this method is invoked when the library is already initialized the new settings will be applied from now on.
// *
// * @param context
// * @param supportedLocales a list of your app supported Locales
// * @throws IllegalStateException if the LocaleChanger is already initialized
// */
// public static void initialize(Context context, List<Locale> supportedLocales) {
// initialize(context,
// supportedLocales,
// new LanguageMatchingAlgorithm(),
// LocalePreference.PreferSupportedLocale);
// }
//
// /**
// * Initialize the LocaleChanger, this method needs to be called before calling any other method.
// * <p>
// * If this method was never invoked before it sets a Locale resolved using the provided {@link MatchingAlgorithm} and {@link LocalePreference}.<p>
// * If this method was invoked before it will load a Locale previously set.
// * <p>
// * If this method is invoked when the library is already initialized the new settings will be applied from now on.
// *
// * @param context
// * @param supportedLocales a list of your app supported Locales
// * @param matchingAlgorithm used to find a match between supported and system Locales
// * @param preference used to indicate what Locale is preferred to load in case of a match
// */
// public static void initialize(Context context,
// List<Locale> supportedLocales,
// MatchingAlgorithm matchingAlgorithm,
// LocalePreference preference) {
//
// delegate = new LocaleChangerDelegate(
// new LocalePersistor(context),
// new LocaleResolver(supportedLocales,
// SystemLocaleRetriever.retrieve(),
// matchingAlgorithm,
// preference),
// new AppLocaleChanger(context)
// );
//
// delegate.initialize();
// }
//
// private static void checkInitialization() {
// if (delegate == null)
// throw new IllegalStateException("LocaleChanger is not initialized. Please first call LocaleChanger.initialize");
// }
//
// /**
// * Clears any Locale set and resolve and load a new default one.
// * This method can be useful if the app implements new supported Locales and it is needed to reload the default one in case there is a best match.
// */
// public static void resetLocale() {
// checkInitialization();
// delegate.resetLocale();
// }
//
// /**
// * Sets a new default app Locale that will be resolved from the one provided.
// *
// * @param supportedLocale a supported Locale that will be used to resolve the Locale to set.
// */
// public static void setLocale(Locale supportedLocale) {
// checkInitialization();
// delegate.setLocale(supportedLocale);
// }
//
// /**
// * Gets the supported Locale that has been used to set the app Locale.
// *
// * @return
// */
// public static Locale getLocale() {
// checkInitialization();
// return delegate.getLocale();
// }
//
// /**
// * This method should be used inside the Activity attachBaseContext.
// * The returned Context should be used as argument for the super method call.
// *
// * @param context
// * @return the resulting context that should be provided to the super method call.
// */
// public static Context configureBaseContext(Context context) {
// checkInitialization();
// return delegate.configureBaseContext(context);
// }
//
// /**
// * This method should be called from Application#onConfigurationChanged()
// */
// public static void onConfigurationChanged() {
// checkInitialization();
// delegate.onConfigurationChanged();
// }
// }
// Path: library/src/main/java/com/franmontiel/localechanger/base/LocaleChangerBaseApplication.java
import android.app.Application;
import android.content.Context;
import android.content.res.Configuration;
import androidx.annotation.NonNull;
import com.franmontiel.localechanger.LocaleChanger;
import java.util.List;
package com.franmontiel.localechanger.base;
/**
* Base {@link Application} class to inherit from with all needed configuration.
*/
public abstract class LocaleChangerBaseApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
this.initializeLocaleChanger();
}
/**
* Call {@link LocaleChanger#initialize(Context, List)} in here
*/
public abstract void initializeLocaleChanger();
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig); | LocaleChanger.onConfigurationChanged(); |
franmontiel/LocaleChanger | library/src/test/java/com/franmontiel/localechanger/LocaleResolverTest.java | // Path: library/src/main/java/com/franmontiel/localechanger/matcher/LanguageMatchingAlgorithm.java
// public final class LanguageMatchingAlgorithm implements MatchingAlgorithm {
//
// @Override
// public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
// MatchingLocales matchingPair = null;
// for (Locale systemLocale : systemLocales) {
// Locale matchingSupportedLocale = findMatchingLocale(systemLocale, supportedLocales);
// if (matchingSupportedLocale != null) {
// matchingPair = new MatchingLocales(matchingSupportedLocale, systemLocale);
// break;
// }
// }
// return matchingPair;
// }
//
// @Override
// public MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales) {
// Locale matchingSystemLocale = findMatchingLocale(supportedLocale, systemLocales);
// return matchingSystemLocale != null ?
// new MatchingLocales(supportedLocale, matchingSystemLocale) :
// null;
// }
//
// private static Locale findMatchingLocale(Locale localeToMatch, List<Locale> candidates) {
// Locale matchingLocale = null;
// for (Locale candidate : candidates) {
// LocaleMatcher.MatchLevel matchLevel = LocaleMatcher.match(localeToMatch, candidate);
//
// if (matchLevel != LocaleMatcher.MatchLevel.NoMatch) {
// matchingLocale = candidate;
// break;
// }
// }
// return matchingLocale;
// }
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
| import com.franmontiel.localechanger.matcher.LanguageMatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import junit.framework.Assert;
import org.junit.Test;
import java.util.Arrays;
import java.util.Locale;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; | /*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger;
public class LocaleResolverTest {
private static final Locale LOCALE_ES_ES = new Locale("es", "ES");
private static final Locale LOCALE_IT_IT = new Locale("it", "IT");
private static final Locale LOCALE_EN_US = new Locale("en", "US");
private static final Locale LOCALE_FR_FR = new Locale("fr", "FR");
private static final LocalePreference ANY_PREFERENCE = LocalePreference.PreferSystemLocale;
@Test
public void ShouldResolveFirstSupportedLocaleAsDefault_WhenResolveDefaultLocale_GivenNonMatchingLocales() {
// Given
LocaleResolver sut = new LocaleResolver(
Arrays.asList(LOCALE_ES_ES, LOCALE_IT_IT),
Arrays.asList(LOCALE_EN_US, LOCALE_FR_FR), | // Path: library/src/main/java/com/franmontiel/localechanger/matcher/LanguageMatchingAlgorithm.java
// public final class LanguageMatchingAlgorithm implements MatchingAlgorithm {
//
// @Override
// public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
// MatchingLocales matchingPair = null;
// for (Locale systemLocale : systemLocales) {
// Locale matchingSupportedLocale = findMatchingLocale(systemLocale, supportedLocales);
// if (matchingSupportedLocale != null) {
// matchingPair = new MatchingLocales(matchingSupportedLocale, systemLocale);
// break;
// }
// }
// return matchingPair;
// }
//
// @Override
// public MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales) {
// Locale matchingSystemLocale = findMatchingLocale(supportedLocale, systemLocales);
// return matchingSystemLocale != null ?
// new MatchingLocales(supportedLocale, matchingSystemLocale) :
// null;
// }
//
// private static Locale findMatchingLocale(Locale localeToMatch, List<Locale> candidates) {
// Locale matchingLocale = null;
// for (Locale candidate : candidates) {
// LocaleMatcher.MatchLevel matchLevel = LocaleMatcher.match(localeToMatch, candidate);
//
// if (matchLevel != LocaleMatcher.MatchLevel.NoMatch) {
// matchingLocale = candidate;
// break;
// }
// }
// return matchingLocale;
// }
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
// Path: library/src/test/java/com/franmontiel/localechanger/LocaleResolverTest.java
import com.franmontiel.localechanger.matcher.LanguageMatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import junit.framework.Assert;
import org.junit.Test;
import java.util.Arrays;
import java.util.Locale;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
/*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger;
public class LocaleResolverTest {
private static final Locale LOCALE_ES_ES = new Locale("es", "ES");
private static final Locale LOCALE_IT_IT = new Locale("it", "IT");
private static final Locale LOCALE_EN_US = new Locale("en", "US");
private static final Locale LOCALE_FR_FR = new Locale("fr", "FR");
private static final LocalePreference ANY_PREFERENCE = LocalePreference.PreferSystemLocale;
@Test
public void ShouldResolveFirstSupportedLocaleAsDefault_WhenResolveDefaultLocale_GivenNonMatchingLocales() {
// Given
LocaleResolver sut = new LocaleResolver(
Arrays.asList(LOCALE_ES_ES, LOCALE_IT_IT),
Arrays.asList(LOCALE_EN_US, LOCALE_FR_FR), | new LanguageMatchingAlgorithm(), |
franmontiel/LocaleChanger | library/src/test/java/com/franmontiel/localechanger/LocaleResolverTest.java | // Path: library/src/main/java/com/franmontiel/localechanger/matcher/LanguageMatchingAlgorithm.java
// public final class LanguageMatchingAlgorithm implements MatchingAlgorithm {
//
// @Override
// public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
// MatchingLocales matchingPair = null;
// for (Locale systemLocale : systemLocales) {
// Locale matchingSupportedLocale = findMatchingLocale(systemLocale, supportedLocales);
// if (matchingSupportedLocale != null) {
// matchingPair = new MatchingLocales(matchingSupportedLocale, systemLocale);
// break;
// }
// }
// return matchingPair;
// }
//
// @Override
// public MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales) {
// Locale matchingSystemLocale = findMatchingLocale(supportedLocale, systemLocales);
// return matchingSystemLocale != null ?
// new MatchingLocales(supportedLocale, matchingSystemLocale) :
// null;
// }
//
// private static Locale findMatchingLocale(Locale localeToMatch, List<Locale> candidates) {
// Locale matchingLocale = null;
// for (Locale candidate : candidates) {
// LocaleMatcher.MatchLevel matchLevel = LocaleMatcher.match(localeToMatch, candidate);
//
// if (matchLevel != LocaleMatcher.MatchLevel.NoMatch) {
// matchingLocale = candidate;
// break;
// }
// }
// return matchingLocale;
// }
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
| import com.franmontiel.localechanger.matcher.LanguageMatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import junit.framework.Assert;
import org.junit.Test;
import java.util.Arrays;
import java.util.Locale;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; | ANY_PREFERENCE
);
// When
DefaultResolvedLocalePair defaultResolvedLocalePair = sut.resolveDefault();
// Then
Assert.assertEquals(LOCALE_ES_ES, defaultResolvedLocalePair.getResolvedLocale());
}
@Test
public void ShouldResolveGivenSupportedLocaleAsDefault_WhenResolveLocale_GivenNonMatchingLocales() throws UnsupportedLocaleException {
// Given
LocaleResolver sut = new LocaleResolver(
Arrays.asList(LOCALE_ES_ES, LOCALE_IT_IT),
Arrays.asList(LOCALE_EN_US, LOCALE_FR_FR),
new LanguageMatchingAlgorithm(),
ANY_PREFERENCE
);
// When
Locale resolvedLocale = sut.resolve(LOCALE_IT_IT);
// Then
Assert.assertEquals(LOCALE_IT_IT, resolvedLocale);
}
@Test
public void ShouldResolveGivenSupportedLocaleDirectly_WhenResolveLocale_PreferringSupportedLocale() throws UnsupportedLocaleException {
// Given | // Path: library/src/main/java/com/franmontiel/localechanger/matcher/LanguageMatchingAlgorithm.java
// public final class LanguageMatchingAlgorithm implements MatchingAlgorithm {
//
// @Override
// public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
// MatchingLocales matchingPair = null;
// for (Locale systemLocale : systemLocales) {
// Locale matchingSupportedLocale = findMatchingLocale(systemLocale, supportedLocales);
// if (matchingSupportedLocale != null) {
// matchingPair = new MatchingLocales(matchingSupportedLocale, systemLocale);
// break;
// }
// }
// return matchingPair;
// }
//
// @Override
// public MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales) {
// Locale matchingSystemLocale = findMatchingLocale(supportedLocale, systemLocales);
// return matchingSystemLocale != null ?
// new MatchingLocales(supportedLocale, matchingSystemLocale) :
// null;
// }
//
// private static Locale findMatchingLocale(Locale localeToMatch, List<Locale> candidates) {
// Locale matchingLocale = null;
// for (Locale candidate : candidates) {
// LocaleMatcher.MatchLevel matchLevel = LocaleMatcher.match(localeToMatch, candidate);
//
// if (matchLevel != LocaleMatcher.MatchLevel.NoMatch) {
// matchingLocale = candidate;
// break;
// }
// }
// return matchingLocale;
// }
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
// Path: library/src/test/java/com/franmontiel/localechanger/LocaleResolverTest.java
import com.franmontiel.localechanger.matcher.LanguageMatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import junit.framework.Assert;
import org.junit.Test;
import java.util.Arrays;
import java.util.Locale;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
ANY_PREFERENCE
);
// When
DefaultResolvedLocalePair defaultResolvedLocalePair = sut.resolveDefault();
// Then
Assert.assertEquals(LOCALE_ES_ES, defaultResolvedLocalePair.getResolvedLocale());
}
@Test
public void ShouldResolveGivenSupportedLocaleAsDefault_WhenResolveLocale_GivenNonMatchingLocales() throws UnsupportedLocaleException {
// Given
LocaleResolver sut = new LocaleResolver(
Arrays.asList(LOCALE_ES_ES, LOCALE_IT_IT),
Arrays.asList(LOCALE_EN_US, LOCALE_FR_FR),
new LanguageMatchingAlgorithm(),
ANY_PREFERENCE
);
// When
Locale resolvedLocale = sut.resolve(LOCALE_IT_IT);
// Then
Assert.assertEquals(LOCALE_IT_IT, resolvedLocale);
}
@Test
public void ShouldResolveGivenSupportedLocaleDirectly_WhenResolveLocale_PreferringSupportedLocale() throws UnsupportedLocaleException {
// Given | MatchingAlgorithm matchingAlgorithm = mock(MatchingAlgorithm.class); |
franmontiel/LocaleChanger | library/src/main/java/com/franmontiel/localechanger/LocaleResolver.java | // Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingLocales.java
// public final class MatchingLocales {
// private Locale supportedLocale;
// private Locale systemLocale;
//
// public MatchingLocales(Locale supportedLocale, Locale systemLocale) {
// this.supportedLocale = supportedLocale;
// this.systemLocale = systemLocale;
// }
//
// public Locale getSupportedLocale() {
// return supportedLocale;
// }
//
// public Locale getSystemLocale() {
// return systemLocale;
// }
//
// public Locale getPreferredLocale(LocalePreference preference) {
// return preference.equals(LocalePreference.PreferSupportedLocale) ?
// supportedLocale :
// systemLocale;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// MatchingLocales that = (MatchingLocales) o;
//
// return supportedLocale.equals(that.supportedLocale)
// && systemLocale.equals(that.systemLocale);
// }
//
// @Override
// public int hashCode() {
// int result = supportedLocale.hashCode();
// result = 31 * result + systemLocale.hashCode();
// return result;
// }
//
// @Override
// public String toString() {
// return supportedLocale.toString() + ", " + systemLocale.toString();
// }
// }
| import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingLocales;
import java.util.List;
import java.util.Locale; | /*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger;
/**
* Class that uses a {@link MatchingAlgorithm} and a {@link LocalePreference} to resolve a Locale to be set.
*/
class LocaleResolver {
private List<Locale> supportedLocales;
private List<Locale> systemLocales; | // Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingLocales.java
// public final class MatchingLocales {
// private Locale supportedLocale;
// private Locale systemLocale;
//
// public MatchingLocales(Locale supportedLocale, Locale systemLocale) {
// this.supportedLocale = supportedLocale;
// this.systemLocale = systemLocale;
// }
//
// public Locale getSupportedLocale() {
// return supportedLocale;
// }
//
// public Locale getSystemLocale() {
// return systemLocale;
// }
//
// public Locale getPreferredLocale(LocalePreference preference) {
// return preference.equals(LocalePreference.PreferSupportedLocale) ?
// supportedLocale :
// systemLocale;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// MatchingLocales that = (MatchingLocales) o;
//
// return supportedLocale.equals(that.supportedLocale)
// && systemLocale.equals(that.systemLocale);
// }
//
// @Override
// public int hashCode() {
// int result = supportedLocale.hashCode();
// result = 31 * result + systemLocale.hashCode();
// return result;
// }
//
// @Override
// public String toString() {
// return supportedLocale.toString() + ", " + systemLocale.toString();
// }
// }
// Path: library/src/main/java/com/franmontiel/localechanger/LocaleResolver.java
import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingLocales;
import java.util.List;
import java.util.Locale;
/*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger;
/**
* Class that uses a {@link MatchingAlgorithm} and a {@link LocalePreference} to resolve a Locale to be set.
*/
class LocaleResolver {
private List<Locale> supportedLocales;
private List<Locale> systemLocales; | private MatchingAlgorithm matchingAlgorithm; |
franmontiel/LocaleChanger | library/src/main/java/com/franmontiel/localechanger/LocaleResolver.java | // Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingLocales.java
// public final class MatchingLocales {
// private Locale supportedLocale;
// private Locale systemLocale;
//
// public MatchingLocales(Locale supportedLocale, Locale systemLocale) {
// this.supportedLocale = supportedLocale;
// this.systemLocale = systemLocale;
// }
//
// public Locale getSupportedLocale() {
// return supportedLocale;
// }
//
// public Locale getSystemLocale() {
// return systemLocale;
// }
//
// public Locale getPreferredLocale(LocalePreference preference) {
// return preference.equals(LocalePreference.PreferSupportedLocale) ?
// supportedLocale :
// systemLocale;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// MatchingLocales that = (MatchingLocales) o;
//
// return supportedLocale.equals(that.supportedLocale)
// && systemLocale.equals(that.systemLocale);
// }
//
// @Override
// public int hashCode() {
// int result = supportedLocale.hashCode();
// result = 31 * result + systemLocale.hashCode();
// return result;
// }
//
// @Override
// public String toString() {
// return supportedLocale.toString() + ", " + systemLocale.toString();
// }
// }
| import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingLocales;
import java.util.List;
import java.util.Locale; | /*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger;
/**
* Class that uses a {@link MatchingAlgorithm} and a {@link LocalePreference} to resolve a Locale to be set.
*/
class LocaleResolver {
private List<Locale> supportedLocales;
private List<Locale> systemLocales;
private MatchingAlgorithm matchingAlgorithm;
private LocalePreference preference;
LocaleResolver(List<Locale> supportedLocales,
List<Locale> systemLocales,
MatchingAlgorithm matchingAlgorithm,
LocalePreference preference) {
this.supportedLocales = supportedLocales;
this.systemLocales = systemLocales;
this.matchingAlgorithm = matchingAlgorithm;
this.preference = preference;
}
DefaultResolvedLocalePair resolveDefault() {
| // Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingLocales.java
// public final class MatchingLocales {
// private Locale supportedLocale;
// private Locale systemLocale;
//
// public MatchingLocales(Locale supportedLocale, Locale systemLocale) {
// this.supportedLocale = supportedLocale;
// this.systemLocale = systemLocale;
// }
//
// public Locale getSupportedLocale() {
// return supportedLocale;
// }
//
// public Locale getSystemLocale() {
// return systemLocale;
// }
//
// public Locale getPreferredLocale(LocalePreference preference) {
// return preference.equals(LocalePreference.PreferSupportedLocale) ?
// supportedLocale :
// systemLocale;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// MatchingLocales that = (MatchingLocales) o;
//
// return supportedLocale.equals(that.supportedLocale)
// && systemLocale.equals(that.systemLocale);
// }
//
// @Override
// public int hashCode() {
// int result = supportedLocale.hashCode();
// result = 31 * result + systemLocale.hashCode();
// return result;
// }
//
// @Override
// public String toString() {
// return supportedLocale.toString() + ", " + systemLocale.toString();
// }
// }
// Path: library/src/main/java/com/franmontiel/localechanger/LocaleResolver.java
import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingLocales;
import java.util.List;
import java.util.Locale;
/*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger;
/**
* Class that uses a {@link MatchingAlgorithm} and a {@link LocalePreference} to resolve a Locale to be set.
*/
class LocaleResolver {
private List<Locale> supportedLocales;
private List<Locale> systemLocales;
private MatchingAlgorithm matchingAlgorithm;
private LocalePreference preference;
LocaleResolver(List<Locale> supportedLocales,
List<Locale> systemLocales,
MatchingAlgorithm matchingAlgorithm,
LocalePreference preference) {
this.supportedLocales = supportedLocales;
this.systemLocales = systemLocales;
this.matchingAlgorithm = matchingAlgorithm;
this.preference = preference;
}
DefaultResolvedLocalePair resolveDefault() {
| MatchingLocales matchingPair = matchingAlgorithm.findDefaultMatch(supportedLocales, systemLocales); |
franmontiel/LocaleChanger | library/src/main/java/com/franmontiel/localechanger/matcher/ClosestMatchingAlgorithm.java | // Path: library/src/main/java/com/franmontiel/localechanger/utils/LocaleMatcher.java
// public class LocaleMatcher {
//
// /**
// * Enum representing the level of matching of two Locales.
// */
// public enum MatchLevel {
// NoMatch,
// LanguageMatch,
// LanguageAndCountryMatch,
// CompleteMatch
// }
//
// private LocaleMatcher() {
// }
//
// /**
// * Method to determine the level of matching of two Locales.
// * @param l1
// * @param l2
// * @return
// */
// public static MatchLevel match(Locale l1, Locale l2) {
// MatchLevel matchLevel = NoMatch;
// if (l1.equals(l2)) {
// matchLevel = MatchLevel.CompleteMatch;
// } else if (l1.getLanguage().equals(l2.getLanguage()) && l1.getCountry().equals(l2.getCountry())) {
// return MatchLevel.LanguageAndCountryMatch;
// } else if (l1.getLanguage().equals(l2.getLanguage())) {
// return MatchLevel.LanguageMatch;
// }
// return matchLevel;
// }
// }
| import com.franmontiel.localechanger.utils.LocaleMatcher;
import java.util.List;
import java.util.Locale; | /*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger.matcher;
/**
* An algorithm that matches the Locales with most attributes in common.
*/
public final class ClosestMatchingAlgorithm implements MatchingAlgorithm {
@Override
public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
MatchingLocales bestMatchingLocalePair = null;
MatchingLocales languageAndCountryMatchingLocalePair = null;
MatchingLocales languageMatchingLocalePair = null;
for (Locale systemLocale : systemLocales) {
for (Locale supportedLocale : supportedLocales) {
| // Path: library/src/main/java/com/franmontiel/localechanger/utils/LocaleMatcher.java
// public class LocaleMatcher {
//
// /**
// * Enum representing the level of matching of two Locales.
// */
// public enum MatchLevel {
// NoMatch,
// LanguageMatch,
// LanguageAndCountryMatch,
// CompleteMatch
// }
//
// private LocaleMatcher() {
// }
//
// /**
// * Method to determine the level of matching of two Locales.
// * @param l1
// * @param l2
// * @return
// */
// public static MatchLevel match(Locale l1, Locale l2) {
// MatchLevel matchLevel = NoMatch;
// if (l1.equals(l2)) {
// matchLevel = MatchLevel.CompleteMatch;
// } else if (l1.getLanguage().equals(l2.getLanguage()) && l1.getCountry().equals(l2.getCountry())) {
// return MatchLevel.LanguageAndCountryMatch;
// } else if (l1.getLanguage().equals(l2.getLanguage())) {
// return MatchLevel.LanguageMatch;
// }
// return matchLevel;
// }
// }
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/ClosestMatchingAlgorithm.java
import com.franmontiel.localechanger.utils.LocaleMatcher;
import java.util.List;
import java.util.Locale;
/*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger.matcher;
/**
* An algorithm that matches the Locales with most attributes in common.
*/
public final class ClosestMatchingAlgorithm implements MatchingAlgorithm {
@Override
public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
MatchingLocales bestMatchingLocalePair = null;
MatchingLocales languageAndCountryMatchingLocalePair = null;
MatchingLocales languageMatchingLocalePair = null;
for (Locale systemLocale : systemLocales) {
for (Locale supportedLocale : supportedLocales) {
| LocaleMatcher.MatchLevel match = LocaleMatcher.match(systemLocale, supportedLocale); |
franmontiel/LocaleChanger | library/src/test/java/com/franmontiel/localechanger/LanguageMatchingAlgorithmTest.java | // Path: library/src/main/java/com/franmontiel/localechanger/matcher/LanguageMatchingAlgorithm.java
// public final class LanguageMatchingAlgorithm implements MatchingAlgorithm {
//
// @Override
// public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
// MatchingLocales matchingPair = null;
// for (Locale systemLocale : systemLocales) {
// Locale matchingSupportedLocale = findMatchingLocale(systemLocale, supportedLocales);
// if (matchingSupportedLocale != null) {
// matchingPair = new MatchingLocales(matchingSupportedLocale, systemLocale);
// break;
// }
// }
// return matchingPair;
// }
//
// @Override
// public MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales) {
// Locale matchingSystemLocale = findMatchingLocale(supportedLocale, systemLocales);
// return matchingSystemLocale != null ?
// new MatchingLocales(supportedLocale, matchingSystemLocale) :
// null;
// }
//
// private static Locale findMatchingLocale(Locale localeToMatch, List<Locale> candidates) {
// Locale matchingLocale = null;
// for (Locale candidate : candidates) {
// LocaleMatcher.MatchLevel matchLevel = LocaleMatcher.match(localeToMatch, candidate);
//
// if (matchLevel != LocaleMatcher.MatchLevel.NoMatch) {
// matchingLocale = candidate;
// break;
// }
// }
// return matchingLocale;
// }
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingLocales.java
// public final class MatchingLocales {
// private Locale supportedLocale;
// private Locale systemLocale;
//
// public MatchingLocales(Locale supportedLocale, Locale systemLocale) {
// this.supportedLocale = supportedLocale;
// this.systemLocale = systemLocale;
// }
//
// public Locale getSupportedLocale() {
// return supportedLocale;
// }
//
// public Locale getSystemLocale() {
// return systemLocale;
// }
//
// public Locale getPreferredLocale(LocalePreference preference) {
// return preference.equals(LocalePreference.PreferSupportedLocale) ?
// supportedLocale :
// systemLocale;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// MatchingLocales that = (MatchingLocales) o;
//
// return supportedLocale.equals(that.supportedLocale)
// && systemLocale.equals(that.systemLocale);
// }
//
// @Override
// public int hashCode() {
// int result = supportedLocale.hashCode();
// result = 31 * result + systemLocale.hashCode();
// return result;
// }
//
// @Override
// public String toString() {
// return supportedLocale.toString() + ", " + systemLocale.toString();
// }
// }
| import com.franmontiel.localechanger.matcher.LanguageMatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingLocales;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import java.util.Locale; | /*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger;
public class LanguageMatchingAlgorithmTest {
private static final Locale LOCALE_ES_ES = new Locale("es", "ES");
private static final Locale LOCALE_IT_IT = new Locale("it", "IT");
private static final Locale LOCALE_FR_CA = new Locale("fr", "CA");
private static final Locale LOCALE_EN_GB = new Locale("en", "GB");
private static final Locale LOCALE_EN_US = new Locale("en", "US");
private static final Locale LOCALE_FR_FR = new Locale("fr", "FR");
private static final List<Locale> SYSTEM_LOCALES = Arrays.asList(LOCALE_EN_US, LOCALE_FR_FR);
| // Path: library/src/main/java/com/franmontiel/localechanger/matcher/LanguageMatchingAlgorithm.java
// public final class LanguageMatchingAlgorithm implements MatchingAlgorithm {
//
// @Override
// public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
// MatchingLocales matchingPair = null;
// for (Locale systemLocale : systemLocales) {
// Locale matchingSupportedLocale = findMatchingLocale(systemLocale, supportedLocales);
// if (matchingSupportedLocale != null) {
// matchingPair = new MatchingLocales(matchingSupportedLocale, systemLocale);
// break;
// }
// }
// return matchingPair;
// }
//
// @Override
// public MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales) {
// Locale matchingSystemLocale = findMatchingLocale(supportedLocale, systemLocales);
// return matchingSystemLocale != null ?
// new MatchingLocales(supportedLocale, matchingSystemLocale) :
// null;
// }
//
// private static Locale findMatchingLocale(Locale localeToMatch, List<Locale> candidates) {
// Locale matchingLocale = null;
// for (Locale candidate : candidates) {
// LocaleMatcher.MatchLevel matchLevel = LocaleMatcher.match(localeToMatch, candidate);
//
// if (matchLevel != LocaleMatcher.MatchLevel.NoMatch) {
// matchingLocale = candidate;
// break;
// }
// }
// return matchingLocale;
// }
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingLocales.java
// public final class MatchingLocales {
// private Locale supportedLocale;
// private Locale systemLocale;
//
// public MatchingLocales(Locale supportedLocale, Locale systemLocale) {
// this.supportedLocale = supportedLocale;
// this.systemLocale = systemLocale;
// }
//
// public Locale getSupportedLocale() {
// return supportedLocale;
// }
//
// public Locale getSystemLocale() {
// return systemLocale;
// }
//
// public Locale getPreferredLocale(LocalePreference preference) {
// return preference.equals(LocalePreference.PreferSupportedLocale) ?
// supportedLocale :
// systemLocale;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// MatchingLocales that = (MatchingLocales) o;
//
// return supportedLocale.equals(that.supportedLocale)
// && systemLocale.equals(that.systemLocale);
// }
//
// @Override
// public int hashCode() {
// int result = supportedLocale.hashCode();
// result = 31 * result + systemLocale.hashCode();
// return result;
// }
//
// @Override
// public String toString() {
// return supportedLocale.toString() + ", " + systemLocale.toString();
// }
// }
// Path: library/src/test/java/com/franmontiel/localechanger/LanguageMatchingAlgorithmTest.java
import com.franmontiel.localechanger.matcher.LanguageMatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingLocales;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
/*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger;
public class LanguageMatchingAlgorithmTest {
private static final Locale LOCALE_ES_ES = new Locale("es", "ES");
private static final Locale LOCALE_IT_IT = new Locale("it", "IT");
private static final Locale LOCALE_FR_CA = new Locale("fr", "CA");
private static final Locale LOCALE_EN_GB = new Locale("en", "GB");
private static final Locale LOCALE_EN_US = new Locale("en", "US");
private static final Locale LOCALE_FR_FR = new Locale("fr", "FR");
private static final List<Locale> SYSTEM_LOCALES = Arrays.asList(LOCALE_EN_US, LOCALE_FR_FR);
| private MatchingAlgorithm sut; |
franmontiel/LocaleChanger | library/src/test/java/com/franmontiel/localechanger/LanguageMatchingAlgorithmTest.java | // Path: library/src/main/java/com/franmontiel/localechanger/matcher/LanguageMatchingAlgorithm.java
// public final class LanguageMatchingAlgorithm implements MatchingAlgorithm {
//
// @Override
// public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
// MatchingLocales matchingPair = null;
// for (Locale systemLocale : systemLocales) {
// Locale matchingSupportedLocale = findMatchingLocale(systemLocale, supportedLocales);
// if (matchingSupportedLocale != null) {
// matchingPair = new MatchingLocales(matchingSupportedLocale, systemLocale);
// break;
// }
// }
// return matchingPair;
// }
//
// @Override
// public MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales) {
// Locale matchingSystemLocale = findMatchingLocale(supportedLocale, systemLocales);
// return matchingSystemLocale != null ?
// new MatchingLocales(supportedLocale, matchingSystemLocale) :
// null;
// }
//
// private static Locale findMatchingLocale(Locale localeToMatch, List<Locale> candidates) {
// Locale matchingLocale = null;
// for (Locale candidate : candidates) {
// LocaleMatcher.MatchLevel matchLevel = LocaleMatcher.match(localeToMatch, candidate);
//
// if (matchLevel != LocaleMatcher.MatchLevel.NoMatch) {
// matchingLocale = candidate;
// break;
// }
// }
// return matchingLocale;
// }
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingLocales.java
// public final class MatchingLocales {
// private Locale supportedLocale;
// private Locale systemLocale;
//
// public MatchingLocales(Locale supportedLocale, Locale systemLocale) {
// this.supportedLocale = supportedLocale;
// this.systemLocale = systemLocale;
// }
//
// public Locale getSupportedLocale() {
// return supportedLocale;
// }
//
// public Locale getSystemLocale() {
// return systemLocale;
// }
//
// public Locale getPreferredLocale(LocalePreference preference) {
// return preference.equals(LocalePreference.PreferSupportedLocale) ?
// supportedLocale :
// systemLocale;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// MatchingLocales that = (MatchingLocales) o;
//
// return supportedLocale.equals(that.supportedLocale)
// && systemLocale.equals(that.systemLocale);
// }
//
// @Override
// public int hashCode() {
// int result = supportedLocale.hashCode();
// result = 31 * result + systemLocale.hashCode();
// return result;
// }
//
// @Override
// public String toString() {
// return supportedLocale.toString() + ", " + systemLocale.toString();
// }
// }
| import com.franmontiel.localechanger.matcher.LanguageMatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingLocales;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import java.util.Locale; | /*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger;
public class LanguageMatchingAlgorithmTest {
private static final Locale LOCALE_ES_ES = new Locale("es", "ES");
private static final Locale LOCALE_IT_IT = new Locale("it", "IT");
private static final Locale LOCALE_FR_CA = new Locale("fr", "CA");
private static final Locale LOCALE_EN_GB = new Locale("en", "GB");
private static final Locale LOCALE_EN_US = new Locale("en", "US");
private static final Locale LOCALE_FR_FR = new Locale("fr", "FR");
private static final List<Locale> SYSTEM_LOCALES = Arrays.asList(LOCALE_EN_US, LOCALE_FR_FR);
private MatchingAlgorithm sut;
@Before
public void setUp() throws Exception { | // Path: library/src/main/java/com/franmontiel/localechanger/matcher/LanguageMatchingAlgorithm.java
// public final class LanguageMatchingAlgorithm implements MatchingAlgorithm {
//
// @Override
// public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
// MatchingLocales matchingPair = null;
// for (Locale systemLocale : systemLocales) {
// Locale matchingSupportedLocale = findMatchingLocale(systemLocale, supportedLocales);
// if (matchingSupportedLocale != null) {
// matchingPair = new MatchingLocales(matchingSupportedLocale, systemLocale);
// break;
// }
// }
// return matchingPair;
// }
//
// @Override
// public MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales) {
// Locale matchingSystemLocale = findMatchingLocale(supportedLocale, systemLocales);
// return matchingSystemLocale != null ?
// new MatchingLocales(supportedLocale, matchingSystemLocale) :
// null;
// }
//
// private static Locale findMatchingLocale(Locale localeToMatch, List<Locale> candidates) {
// Locale matchingLocale = null;
// for (Locale candidate : candidates) {
// LocaleMatcher.MatchLevel matchLevel = LocaleMatcher.match(localeToMatch, candidate);
//
// if (matchLevel != LocaleMatcher.MatchLevel.NoMatch) {
// matchingLocale = candidate;
// break;
// }
// }
// return matchingLocale;
// }
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingLocales.java
// public final class MatchingLocales {
// private Locale supportedLocale;
// private Locale systemLocale;
//
// public MatchingLocales(Locale supportedLocale, Locale systemLocale) {
// this.supportedLocale = supportedLocale;
// this.systemLocale = systemLocale;
// }
//
// public Locale getSupportedLocale() {
// return supportedLocale;
// }
//
// public Locale getSystemLocale() {
// return systemLocale;
// }
//
// public Locale getPreferredLocale(LocalePreference preference) {
// return preference.equals(LocalePreference.PreferSupportedLocale) ?
// supportedLocale :
// systemLocale;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// MatchingLocales that = (MatchingLocales) o;
//
// return supportedLocale.equals(that.supportedLocale)
// && systemLocale.equals(that.systemLocale);
// }
//
// @Override
// public int hashCode() {
// int result = supportedLocale.hashCode();
// result = 31 * result + systemLocale.hashCode();
// return result;
// }
//
// @Override
// public String toString() {
// return supportedLocale.toString() + ", " + systemLocale.toString();
// }
// }
// Path: library/src/test/java/com/franmontiel/localechanger/LanguageMatchingAlgorithmTest.java
import com.franmontiel.localechanger.matcher.LanguageMatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingLocales;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
/*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger;
public class LanguageMatchingAlgorithmTest {
private static final Locale LOCALE_ES_ES = new Locale("es", "ES");
private static final Locale LOCALE_IT_IT = new Locale("it", "IT");
private static final Locale LOCALE_FR_CA = new Locale("fr", "CA");
private static final Locale LOCALE_EN_GB = new Locale("en", "GB");
private static final Locale LOCALE_EN_US = new Locale("en", "US");
private static final Locale LOCALE_FR_FR = new Locale("fr", "FR");
private static final List<Locale> SYSTEM_LOCALES = Arrays.asList(LOCALE_EN_US, LOCALE_FR_FR);
private MatchingAlgorithm sut;
@Before
public void setUp() throws Exception { | sut = new LanguageMatchingAlgorithm(); |
franmontiel/LocaleChanger | library/src/test/java/com/franmontiel/localechanger/LanguageMatchingAlgorithmTest.java | // Path: library/src/main/java/com/franmontiel/localechanger/matcher/LanguageMatchingAlgorithm.java
// public final class LanguageMatchingAlgorithm implements MatchingAlgorithm {
//
// @Override
// public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
// MatchingLocales matchingPair = null;
// for (Locale systemLocale : systemLocales) {
// Locale matchingSupportedLocale = findMatchingLocale(systemLocale, supportedLocales);
// if (matchingSupportedLocale != null) {
// matchingPair = new MatchingLocales(matchingSupportedLocale, systemLocale);
// break;
// }
// }
// return matchingPair;
// }
//
// @Override
// public MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales) {
// Locale matchingSystemLocale = findMatchingLocale(supportedLocale, systemLocales);
// return matchingSystemLocale != null ?
// new MatchingLocales(supportedLocale, matchingSystemLocale) :
// null;
// }
//
// private static Locale findMatchingLocale(Locale localeToMatch, List<Locale> candidates) {
// Locale matchingLocale = null;
// for (Locale candidate : candidates) {
// LocaleMatcher.MatchLevel matchLevel = LocaleMatcher.match(localeToMatch, candidate);
//
// if (matchLevel != LocaleMatcher.MatchLevel.NoMatch) {
// matchingLocale = candidate;
// break;
// }
// }
// return matchingLocale;
// }
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingLocales.java
// public final class MatchingLocales {
// private Locale supportedLocale;
// private Locale systemLocale;
//
// public MatchingLocales(Locale supportedLocale, Locale systemLocale) {
// this.supportedLocale = supportedLocale;
// this.systemLocale = systemLocale;
// }
//
// public Locale getSupportedLocale() {
// return supportedLocale;
// }
//
// public Locale getSystemLocale() {
// return systemLocale;
// }
//
// public Locale getPreferredLocale(LocalePreference preference) {
// return preference.equals(LocalePreference.PreferSupportedLocale) ?
// supportedLocale :
// systemLocale;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// MatchingLocales that = (MatchingLocales) o;
//
// return supportedLocale.equals(that.supportedLocale)
// && systemLocale.equals(that.systemLocale);
// }
//
// @Override
// public int hashCode() {
// int result = supportedLocale.hashCode();
// result = 31 * result + systemLocale.hashCode();
// return result;
// }
//
// @Override
// public String toString() {
// return supportedLocale.toString() + ", " + systemLocale.toString();
// }
// }
| import com.franmontiel.localechanger.matcher.LanguageMatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingLocales;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import java.util.Locale; | /*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger;
public class LanguageMatchingAlgorithmTest {
private static final Locale LOCALE_ES_ES = new Locale("es", "ES");
private static final Locale LOCALE_IT_IT = new Locale("it", "IT");
private static final Locale LOCALE_FR_CA = new Locale("fr", "CA");
private static final Locale LOCALE_EN_GB = new Locale("en", "GB");
private static final Locale LOCALE_EN_US = new Locale("en", "US");
private static final Locale LOCALE_FR_FR = new Locale("fr", "FR");
private static final List<Locale> SYSTEM_LOCALES = Arrays.asList(LOCALE_EN_US, LOCALE_FR_FR);
private MatchingAlgorithm sut;
@Before
public void setUp() throws Exception {
sut = new LanguageMatchingAlgorithm();
}
@Test
public void ShouldNotFindMatchingLocales_WhenFindDefaultMatch_GivenNonMatchingLocales() {
// Given
List<Locale> supportedLocalesNotMatching = Arrays.asList(LOCALE_ES_ES, LOCALE_IT_IT);
// When | // Path: library/src/main/java/com/franmontiel/localechanger/matcher/LanguageMatchingAlgorithm.java
// public final class LanguageMatchingAlgorithm implements MatchingAlgorithm {
//
// @Override
// public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
// MatchingLocales matchingPair = null;
// for (Locale systemLocale : systemLocales) {
// Locale matchingSupportedLocale = findMatchingLocale(systemLocale, supportedLocales);
// if (matchingSupportedLocale != null) {
// matchingPair = new MatchingLocales(matchingSupportedLocale, systemLocale);
// break;
// }
// }
// return matchingPair;
// }
//
// @Override
// public MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales) {
// Locale matchingSystemLocale = findMatchingLocale(supportedLocale, systemLocales);
// return matchingSystemLocale != null ?
// new MatchingLocales(supportedLocale, matchingSystemLocale) :
// null;
// }
//
// private static Locale findMatchingLocale(Locale localeToMatch, List<Locale> candidates) {
// Locale matchingLocale = null;
// for (Locale candidate : candidates) {
// LocaleMatcher.MatchLevel matchLevel = LocaleMatcher.match(localeToMatch, candidate);
//
// if (matchLevel != LocaleMatcher.MatchLevel.NoMatch) {
// matchingLocale = candidate;
// break;
// }
// }
// return matchingLocale;
// }
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingAlgorithm.java
// public interface MatchingAlgorithm {
//
// /**
// * Method that implements the algorithm to find two matching Locales between a list of supported and system Locales.
// *
// * @param supportedLocales a list of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales);
//
// /**
// * Method that implements the algorithm to find a matching Locale between the supported Locale and system Locales.
// *
// * @param supportedLocale one of your app supported locales
// * @param systemLocales a list of the configured locales in system preferences
// * @return a {@link MatchingLocales} containing the pair of matching locales. If no match is found null is returned
// */
// MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales);
// }
//
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingLocales.java
// public final class MatchingLocales {
// private Locale supportedLocale;
// private Locale systemLocale;
//
// public MatchingLocales(Locale supportedLocale, Locale systemLocale) {
// this.supportedLocale = supportedLocale;
// this.systemLocale = systemLocale;
// }
//
// public Locale getSupportedLocale() {
// return supportedLocale;
// }
//
// public Locale getSystemLocale() {
// return systemLocale;
// }
//
// public Locale getPreferredLocale(LocalePreference preference) {
// return preference.equals(LocalePreference.PreferSupportedLocale) ?
// supportedLocale :
// systemLocale;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// MatchingLocales that = (MatchingLocales) o;
//
// return supportedLocale.equals(that.supportedLocale)
// && systemLocale.equals(that.systemLocale);
// }
//
// @Override
// public int hashCode() {
// int result = supportedLocale.hashCode();
// result = 31 * result + systemLocale.hashCode();
// return result;
// }
//
// @Override
// public String toString() {
// return supportedLocale.toString() + ", " + systemLocale.toString();
// }
// }
// Path: library/src/test/java/com/franmontiel/localechanger/LanguageMatchingAlgorithmTest.java
import com.franmontiel.localechanger.matcher.LanguageMatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingAlgorithm;
import com.franmontiel.localechanger.matcher.MatchingLocales;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
/*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger;
public class LanguageMatchingAlgorithmTest {
private static final Locale LOCALE_ES_ES = new Locale("es", "ES");
private static final Locale LOCALE_IT_IT = new Locale("it", "IT");
private static final Locale LOCALE_FR_CA = new Locale("fr", "CA");
private static final Locale LOCALE_EN_GB = new Locale("en", "GB");
private static final Locale LOCALE_EN_US = new Locale("en", "US");
private static final Locale LOCALE_FR_FR = new Locale("fr", "FR");
private static final List<Locale> SYSTEM_LOCALES = Arrays.asList(LOCALE_EN_US, LOCALE_FR_FR);
private MatchingAlgorithm sut;
@Before
public void setUp() throws Exception {
sut = new LanguageMatchingAlgorithm();
}
@Test
public void ShouldNotFindMatchingLocales_WhenFindDefaultMatch_GivenNonMatchingLocales() {
// Given
List<Locale> supportedLocalesNotMatching = Arrays.asList(LOCALE_ES_ES, LOCALE_IT_IT);
// When | MatchingLocales matchingLocales = sut.findDefaultMatch(supportedLocalesNotMatching, SYSTEM_LOCALES); |
franmontiel/LocaleChanger | sample/src/androidTest/java/com/franmontiel/localechanger/sample/SampleActivityTest.java | // Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/pageobjects/SampleScreen.java
// public class SampleScreen {
//
// private final static int LOCALE_SPINNER_ID = R.id.localeSpinner;
// private final static int UPDATE_BUTTON_ID = R.id.localeUpdate;
//
// private ActivityTestRule<? extends Activity> activityRule;
//
// public SampleScreen(Class<? extends Activity> activityClass) {
// this.activityRule = new ActivityTestRule<>(activityClass, false, false);
// }
//
// public SampleScreen launch() {
// activityRule.launchActivity(null);
// return this;
// }
//
// public SampleScreen changeLocale(Locale locale) {
// onView(withId(LOCALE_SPINNER_ID)).perform(click());
// onData(allOf(is(instanceOf(Locale.class)), is(locale))).perform(click());
//
// onView(withId(UPDATE_BUTTON_ID)).perform(click());
// SystemClock.sleep(500);
//
// return this;
// }
//
// public SampleScreen openNewScreen() {
// onView(allOf(withId(R.id.openNewScreen), withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))).perform(click());
// return this;
// }
//
// public SampleScreen verifyLocaleChanged(Locale expectedLocale) {
// onView(withId(R.id.currentLocale)).check(matches(withText(expectedLocale.toString())));
// return this;
// }
//
// public SampleScreen verifyDate(String expectedDateFormat) {
// onView(withId(R.id.date)).check(matches(withText(expectedDateFormat)));
// return this;
// }
//
// public SampleScreen verifyUpdateButtonText(String expectedText) {
// onView(withId(R.id.localeUpdate)).check(matches(withText(expectedText)));
// return this;
// }
//
// public SampleScreen verifyOverflowSettingsItemTitle(String expectedTitle) {
// openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
//
// // The MenuItem id and the View id is not the same. It is needed to use another matcher.
// onView(withText(expectedTitle)).check(matches(isDisplayed()));
//
// return this;
// }
//
// public SampleScreen verifyLayoutDirectionRTL() {
// onView(withId(R.id.currentLocale)).check(isCompletelyLeftOf(withId(R.id.currentLocaleTitle)));
//
// return this;
// }
//
// public SampleScreen verifyLayoutDirectionLTR() {
// onView(withId(R.id.currentLocale)).check(isCompletelyRightOf(withId(R.id.currentLocaleTitle)));
//
// return this;
// }
//
// public SampleScreen changeOrientationToLandscape() {
// onView(isRoot()).perform(orientationLandscape());
// SystemClock.sleep(500);
// return this;
// }
//
// public SampleScreen changeOrientationToPortrait() {
// onView(isRoot()).perform(orientationPortrait());
// SystemClock.sleep(500);
// return this;
// }
//
// public SampleScreen pressBack() {
// Espresso.pressBack();
// return this;
// }
// }
| import androidx.test.espresso.Espresso;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.franmontiel.localechanger.sample.pageobjects.SampleScreen;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith; | /*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger.sample;
/**
* Advice: It is recommended to run the tests with a system locale configured not listed in the supported ones (to avoid false positives).
*/
@RunWith(AndroidJUnit4.class)
public class SampleActivityTest {
private SampleScreenTestDelegate sampleScreenTestDelegate = new SampleScreenTestDelegate();
@Before
public void setUp() { | // Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/pageobjects/SampleScreen.java
// public class SampleScreen {
//
// private final static int LOCALE_SPINNER_ID = R.id.localeSpinner;
// private final static int UPDATE_BUTTON_ID = R.id.localeUpdate;
//
// private ActivityTestRule<? extends Activity> activityRule;
//
// public SampleScreen(Class<? extends Activity> activityClass) {
// this.activityRule = new ActivityTestRule<>(activityClass, false, false);
// }
//
// public SampleScreen launch() {
// activityRule.launchActivity(null);
// return this;
// }
//
// public SampleScreen changeLocale(Locale locale) {
// onView(withId(LOCALE_SPINNER_ID)).perform(click());
// onData(allOf(is(instanceOf(Locale.class)), is(locale))).perform(click());
//
// onView(withId(UPDATE_BUTTON_ID)).perform(click());
// SystemClock.sleep(500);
//
// return this;
// }
//
// public SampleScreen openNewScreen() {
// onView(allOf(withId(R.id.openNewScreen), withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))).perform(click());
// return this;
// }
//
// public SampleScreen verifyLocaleChanged(Locale expectedLocale) {
// onView(withId(R.id.currentLocale)).check(matches(withText(expectedLocale.toString())));
// return this;
// }
//
// public SampleScreen verifyDate(String expectedDateFormat) {
// onView(withId(R.id.date)).check(matches(withText(expectedDateFormat)));
// return this;
// }
//
// public SampleScreen verifyUpdateButtonText(String expectedText) {
// onView(withId(R.id.localeUpdate)).check(matches(withText(expectedText)));
// return this;
// }
//
// public SampleScreen verifyOverflowSettingsItemTitle(String expectedTitle) {
// openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
//
// // The MenuItem id and the View id is not the same. It is needed to use another matcher.
// onView(withText(expectedTitle)).check(matches(isDisplayed()));
//
// return this;
// }
//
// public SampleScreen verifyLayoutDirectionRTL() {
// onView(withId(R.id.currentLocale)).check(isCompletelyLeftOf(withId(R.id.currentLocaleTitle)));
//
// return this;
// }
//
// public SampleScreen verifyLayoutDirectionLTR() {
// onView(withId(R.id.currentLocale)).check(isCompletelyRightOf(withId(R.id.currentLocaleTitle)));
//
// return this;
// }
//
// public SampleScreen changeOrientationToLandscape() {
// onView(isRoot()).perform(orientationLandscape());
// SystemClock.sleep(500);
// return this;
// }
//
// public SampleScreen changeOrientationToPortrait() {
// onView(isRoot()).perform(orientationPortrait());
// SystemClock.sleep(500);
// return this;
// }
//
// public SampleScreen pressBack() {
// Espresso.pressBack();
// return this;
// }
// }
// Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/SampleActivityTest.java
import androidx.test.espresso.Espresso;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.franmontiel.localechanger.sample.pageobjects.SampleScreen;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
/*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger.sample;
/**
* Advice: It is recommended to run the tests with a system locale configured not listed in the supported ones (to avoid false positives).
*/
@RunWith(AndroidJUnit4.class)
public class SampleActivityTest {
private SampleScreenTestDelegate sampleScreenTestDelegate = new SampleScreenTestDelegate();
@Before
public void setUp() { | sampleScreenTestDelegate.setUp(new SampleScreen(SampleActivity.class)); |
franmontiel/LocaleChanger | sample/src/main/java/com/franmontiel/localechanger/sample/SampleApplication.java | // Path: library/src/main/java/com/franmontiel/localechanger/LocaleChanger.java
// public class LocaleChanger {
//
// private static LocaleChangerDelegate delegate;
//
// private LocaleChanger() {
// }
//
// /**
// * Initialize the LocaleChanger, this method needs to be called before calling any other method.
// * <p>
// * If this method was never invoked before it sets a Locale from the supported list if a language match is found with the system Locales,
// * if no match is found the first Locale in the list will be set.<p>
// * If this method was invoked before it will load a Locale previously set.
// * <p>
// * If this method is invoked when the library is already initialized the new settings will be applied from now on.
// *
// * @param context
// * @param supportedLocales a list of your app supported Locales
// * @throws IllegalStateException if the LocaleChanger is already initialized
// */
// public static void initialize(Context context, List<Locale> supportedLocales) {
// initialize(context,
// supportedLocales,
// new LanguageMatchingAlgorithm(),
// LocalePreference.PreferSupportedLocale);
// }
//
// /**
// * Initialize the LocaleChanger, this method needs to be called before calling any other method.
// * <p>
// * If this method was never invoked before it sets a Locale resolved using the provided {@link MatchingAlgorithm} and {@link LocalePreference}.<p>
// * If this method was invoked before it will load a Locale previously set.
// * <p>
// * If this method is invoked when the library is already initialized the new settings will be applied from now on.
// *
// * @param context
// * @param supportedLocales a list of your app supported Locales
// * @param matchingAlgorithm used to find a match between supported and system Locales
// * @param preference used to indicate what Locale is preferred to load in case of a match
// */
// public static void initialize(Context context,
// List<Locale> supportedLocales,
// MatchingAlgorithm matchingAlgorithm,
// LocalePreference preference) {
//
// delegate = new LocaleChangerDelegate(
// new LocalePersistor(context),
// new LocaleResolver(supportedLocales,
// SystemLocaleRetriever.retrieve(),
// matchingAlgorithm,
// preference),
// new AppLocaleChanger(context)
// );
//
// delegate.initialize();
// }
//
// private static void checkInitialization() {
// if (delegate == null)
// throw new IllegalStateException("LocaleChanger is not initialized. Please first call LocaleChanger.initialize");
// }
//
// /**
// * Clears any Locale set and resolve and load a new default one.
// * This method can be useful if the app implements new supported Locales and it is needed to reload the default one in case there is a best match.
// */
// public static void resetLocale() {
// checkInitialization();
// delegate.resetLocale();
// }
//
// /**
// * Sets a new default app Locale that will be resolved from the one provided.
// *
// * @param supportedLocale a supported Locale that will be used to resolve the Locale to set.
// */
// public static void setLocale(Locale supportedLocale) {
// checkInitialization();
// delegate.setLocale(supportedLocale);
// }
//
// /**
// * Gets the supported Locale that has been used to set the app Locale.
// *
// * @return
// */
// public static Locale getLocale() {
// checkInitialization();
// return delegate.getLocale();
// }
//
// /**
// * This method should be used inside the Activity attachBaseContext.
// * The returned Context should be used as argument for the super method call.
// *
// * @param context
// * @return the resulting context that should be provided to the super method call.
// */
// public static Context configureBaseContext(Context context) {
// checkInitialization();
// return delegate.configureBaseContext(context);
// }
//
// /**
// * This method should be called from Application#onConfigurationChanged()
// */
// public static void onConfigurationChanged() {
// checkInitialization();
// delegate.onConfigurationChanged();
// }
// }
| import android.app.Application;
import android.content.res.Configuration;
import com.franmontiel.localechanger.LocaleChanger;
import java.util.Arrays;
import java.util.List;
import java.util.Locale; | /*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger.sample;
public class SampleApplication extends Application {
public static final List<Locale> SUPPORTED_LOCALES =
Arrays.asList(
new Locale("en", "US"),
new Locale("es", "ES"),
new Locale("fr", "FR"),
new Locale("ar", "JO")
);
@Override
public void onCreate() {
super.onCreate(); | // Path: library/src/main/java/com/franmontiel/localechanger/LocaleChanger.java
// public class LocaleChanger {
//
// private static LocaleChangerDelegate delegate;
//
// private LocaleChanger() {
// }
//
// /**
// * Initialize the LocaleChanger, this method needs to be called before calling any other method.
// * <p>
// * If this method was never invoked before it sets a Locale from the supported list if a language match is found with the system Locales,
// * if no match is found the first Locale in the list will be set.<p>
// * If this method was invoked before it will load a Locale previously set.
// * <p>
// * If this method is invoked when the library is already initialized the new settings will be applied from now on.
// *
// * @param context
// * @param supportedLocales a list of your app supported Locales
// * @throws IllegalStateException if the LocaleChanger is already initialized
// */
// public static void initialize(Context context, List<Locale> supportedLocales) {
// initialize(context,
// supportedLocales,
// new LanguageMatchingAlgorithm(),
// LocalePreference.PreferSupportedLocale);
// }
//
// /**
// * Initialize the LocaleChanger, this method needs to be called before calling any other method.
// * <p>
// * If this method was never invoked before it sets a Locale resolved using the provided {@link MatchingAlgorithm} and {@link LocalePreference}.<p>
// * If this method was invoked before it will load a Locale previously set.
// * <p>
// * If this method is invoked when the library is already initialized the new settings will be applied from now on.
// *
// * @param context
// * @param supportedLocales a list of your app supported Locales
// * @param matchingAlgorithm used to find a match between supported and system Locales
// * @param preference used to indicate what Locale is preferred to load in case of a match
// */
// public static void initialize(Context context,
// List<Locale> supportedLocales,
// MatchingAlgorithm matchingAlgorithm,
// LocalePreference preference) {
//
// delegate = new LocaleChangerDelegate(
// new LocalePersistor(context),
// new LocaleResolver(supportedLocales,
// SystemLocaleRetriever.retrieve(),
// matchingAlgorithm,
// preference),
// new AppLocaleChanger(context)
// );
//
// delegate.initialize();
// }
//
// private static void checkInitialization() {
// if (delegate == null)
// throw new IllegalStateException("LocaleChanger is not initialized. Please first call LocaleChanger.initialize");
// }
//
// /**
// * Clears any Locale set and resolve and load a new default one.
// * This method can be useful if the app implements new supported Locales and it is needed to reload the default one in case there is a best match.
// */
// public static void resetLocale() {
// checkInitialization();
// delegate.resetLocale();
// }
//
// /**
// * Sets a new default app Locale that will be resolved from the one provided.
// *
// * @param supportedLocale a supported Locale that will be used to resolve the Locale to set.
// */
// public static void setLocale(Locale supportedLocale) {
// checkInitialization();
// delegate.setLocale(supportedLocale);
// }
//
// /**
// * Gets the supported Locale that has been used to set the app Locale.
// *
// * @return
// */
// public static Locale getLocale() {
// checkInitialization();
// return delegate.getLocale();
// }
//
// /**
// * This method should be used inside the Activity attachBaseContext.
// * The returned Context should be used as argument for the super method call.
// *
// * @param context
// * @return the resulting context that should be provided to the super method call.
// */
// public static Context configureBaseContext(Context context) {
// checkInitialization();
// return delegate.configureBaseContext(context);
// }
//
// /**
// * This method should be called from Application#onConfigurationChanged()
// */
// public static void onConfigurationChanged() {
// checkInitialization();
// delegate.onConfigurationChanged();
// }
// }
// Path: sample/src/main/java/com/franmontiel/localechanger/sample/SampleApplication.java
import android.app.Application;
import android.content.res.Configuration;
import com.franmontiel.localechanger.LocaleChanger;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
/*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger.sample;
public class SampleApplication extends Application {
public static final List<Locale> SUPPORTED_LOCALES =
Arrays.asList(
new Locale("en", "US"),
new Locale("es", "ES"),
new Locale("fr", "FR"),
new Locale("ar", "JO")
);
@Override
public void onCreate() {
super.onCreate(); | LocaleChanger.initialize(getApplicationContext(), SUPPORTED_LOCALES); |
franmontiel/LocaleChanger | sample/src/androidTest/java/com/franmontiel/localechanger/sample/pageobjects/SampleScreen.java | // Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/OrientationChangeAction.java
// public static ViewAction orientationLandscape() {
// return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
// }
//
// Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/OrientationChangeAction.java
// public static ViewAction orientationPortrait() {
// return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
// }
| import android.app.Activity;
import android.os.SystemClock;
import androidx.test.espresso.Espresso;
import androidx.test.espresso.matcher.ViewMatchers;
import androidx.test.rule.ActivityTestRule;
import com.franmontiel.localechanger.sample.R;
import java.util.Locale;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static androidx.test.espresso.Espresso.onData;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.scrollTo;
import static androidx.test.espresso.assertion.PositionAssertions.isCompletelyLeftOf;
import static androidx.test.espresso.assertion.PositionAssertions.isCompletelyRightOf;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.isRoot;
import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.franmontiel.localechanger.sample.OrientationChangeAction.orientationLandscape;
import static com.franmontiel.localechanger.sample.OrientationChangeAction.orientationPortrait;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is; | return this;
}
public SampleScreen verifyUpdateButtonText(String expectedText) {
onView(withId(R.id.localeUpdate)).check(matches(withText(expectedText)));
return this;
}
public SampleScreen verifyOverflowSettingsItemTitle(String expectedTitle) {
openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
// The MenuItem id and the View id is not the same. It is needed to use another matcher.
onView(withText(expectedTitle)).check(matches(isDisplayed()));
return this;
}
public SampleScreen verifyLayoutDirectionRTL() {
onView(withId(R.id.currentLocale)).check(isCompletelyLeftOf(withId(R.id.currentLocaleTitle)));
return this;
}
public SampleScreen verifyLayoutDirectionLTR() {
onView(withId(R.id.currentLocale)).check(isCompletelyRightOf(withId(R.id.currentLocaleTitle)));
return this;
}
public SampleScreen changeOrientationToLandscape() { | // Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/OrientationChangeAction.java
// public static ViewAction orientationLandscape() {
// return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
// }
//
// Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/OrientationChangeAction.java
// public static ViewAction orientationPortrait() {
// return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
// }
// Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/pageobjects/SampleScreen.java
import android.app.Activity;
import android.os.SystemClock;
import androidx.test.espresso.Espresso;
import androidx.test.espresso.matcher.ViewMatchers;
import androidx.test.rule.ActivityTestRule;
import com.franmontiel.localechanger.sample.R;
import java.util.Locale;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static androidx.test.espresso.Espresso.onData;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.scrollTo;
import static androidx.test.espresso.assertion.PositionAssertions.isCompletelyLeftOf;
import static androidx.test.espresso.assertion.PositionAssertions.isCompletelyRightOf;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.isRoot;
import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.franmontiel.localechanger.sample.OrientationChangeAction.orientationLandscape;
import static com.franmontiel.localechanger.sample.OrientationChangeAction.orientationPortrait;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
return this;
}
public SampleScreen verifyUpdateButtonText(String expectedText) {
onView(withId(R.id.localeUpdate)).check(matches(withText(expectedText)));
return this;
}
public SampleScreen verifyOverflowSettingsItemTitle(String expectedTitle) {
openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
// The MenuItem id and the View id is not the same. It is needed to use another matcher.
onView(withText(expectedTitle)).check(matches(isDisplayed()));
return this;
}
public SampleScreen verifyLayoutDirectionRTL() {
onView(withId(R.id.currentLocale)).check(isCompletelyLeftOf(withId(R.id.currentLocaleTitle)));
return this;
}
public SampleScreen verifyLayoutDirectionLTR() {
onView(withId(R.id.currentLocale)).check(isCompletelyRightOf(withId(R.id.currentLocaleTitle)));
return this;
}
public SampleScreen changeOrientationToLandscape() { | onView(isRoot()).perform(orientationLandscape()); |
franmontiel/LocaleChanger | sample/src/androidTest/java/com/franmontiel/localechanger/sample/pageobjects/SampleScreen.java | // Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/OrientationChangeAction.java
// public static ViewAction orientationLandscape() {
// return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
// }
//
// Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/OrientationChangeAction.java
// public static ViewAction orientationPortrait() {
// return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
// }
| import android.app.Activity;
import android.os.SystemClock;
import androidx.test.espresso.Espresso;
import androidx.test.espresso.matcher.ViewMatchers;
import androidx.test.rule.ActivityTestRule;
import com.franmontiel.localechanger.sample.R;
import java.util.Locale;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static androidx.test.espresso.Espresso.onData;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.scrollTo;
import static androidx.test.espresso.assertion.PositionAssertions.isCompletelyLeftOf;
import static androidx.test.espresso.assertion.PositionAssertions.isCompletelyRightOf;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.isRoot;
import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.franmontiel.localechanger.sample.OrientationChangeAction.orientationLandscape;
import static com.franmontiel.localechanger.sample.OrientationChangeAction.orientationPortrait;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is; | }
public SampleScreen verifyOverflowSettingsItemTitle(String expectedTitle) {
openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
// The MenuItem id and the View id is not the same. It is needed to use another matcher.
onView(withText(expectedTitle)).check(matches(isDisplayed()));
return this;
}
public SampleScreen verifyLayoutDirectionRTL() {
onView(withId(R.id.currentLocale)).check(isCompletelyLeftOf(withId(R.id.currentLocaleTitle)));
return this;
}
public SampleScreen verifyLayoutDirectionLTR() {
onView(withId(R.id.currentLocale)).check(isCompletelyRightOf(withId(R.id.currentLocaleTitle)));
return this;
}
public SampleScreen changeOrientationToLandscape() {
onView(isRoot()).perform(orientationLandscape());
SystemClock.sleep(500);
return this;
}
public SampleScreen changeOrientationToPortrait() { | // Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/OrientationChangeAction.java
// public static ViewAction orientationLandscape() {
// return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
// }
//
// Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/OrientationChangeAction.java
// public static ViewAction orientationPortrait() {
// return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
// }
// Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/pageobjects/SampleScreen.java
import android.app.Activity;
import android.os.SystemClock;
import androidx.test.espresso.Espresso;
import androidx.test.espresso.matcher.ViewMatchers;
import androidx.test.rule.ActivityTestRule;
import com.franmontiel.localechanger.sample.R;
import java.util.Locale;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static androidx.test.espresso.Espresso.onData;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.scrollTo;
import static androidx.test.espresso.assertion.PositionAssertions.isCompletelyLeftOf;
import static androidx.test.espresso.assertion.PositionAssertions.isCompletelyRightOf;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.isRoot;
import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.franmontiel.localechanger.sample.OrientationChangeAction.orientationLandscape;
import static com.franmontiel.localechanger.sample.OrientationChangeAction.orientationPortrait;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
}
public SampleScreen verifyOverflowSettingsItemTitle(String expectedTitle) {
openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
// The MenuItem id and the View id is not the same. It is needed to use another matcher.
onView(withText(expectedTitle)).check(matches(isDisplayed()));
return this;
}
public SampleScreen verifyLayoutDirectionRTL() {
onView(withId(R.id.currentLocale)).check(isCompletelyLeftOf(withId(R.id.currentLocaleTitle)));
return this;
}
public SampleScreen verifyLayoutDirectionLTR() {
onView(withId(R.id.currentLocale)).check(isCompletelyRightOf(withId(R.id.currentLocaleTitle)));
return this;
}
public SampleScreen changeOrientationToLandscape() {
onView(isRoot()).perform(orientationLandscape());
SystemClock.sleep(500);
return this;
}
public SampleScreen changeOrientationToPortrait() { | onView(isRoot()).perform(orientationPortrait()); |
franmontiel/LocaleChanger | library/src/main/java/androidx/appcompat/app/LocaleChangerAppCompatDelegate.java | // Path: library/src/main/java/com/franmontiel/localechanger/LocaleChanger.java
// public class LocaleChanger {
//
// private static LocaleChangerDelegate delegate;
//
// private LocaleChanger() {
// }
//
// /**
// * Initialize the LocaleChanger, this method needs to be called before calling any other method.
// * <p>
// * If this method was never invoked before it sets a Locale from the supported list if a language match is found with the system Locales,
// * if no match is found the first Locale in the list will be set.<p>
// * If this method was invoked before it will load a Locale previously set.
// * <p>
// * If this method is invoked when the library is already initialized the new settings will be applied from now on.
// *
// * @param context
// * @param supportedLocales a list of your app supported Locales
// * @throws IllegalStateException if the LocaleChanger is already initialized
// */
// public static void initialize(Context context, List<Locale> supportedLocales) {
// initialize(context,
// supportedLocales,
// new LanguageMatchingAlgorithm(),
// LocalePreference.PreferSupportedLocale);
// }
//
// /**
// * Initialize the LocaleChanger, this method needs to be called before calling any other method.
// * <p>
// * If this method was never invoked before it sets a Locale resolved using the provided {@link MatchingAlgorithm} and {@link LocalePreference}.<p>
// * If this method was invoked before it will load a Locale previously set.
// * <p>
// * If this method is invoked when the library is already initialized the new settings will be applied from now on.
// *
// * @param context
// * @param supportedLocales a list of your app supported Locales
// * @param matchingAlgorithm used to find a match between supported and system Locales
// * @param preference used to indicate what Locale is preferred to load in case of a match
// */
// public static void initialize(Context context,
// List<Locale> supportedLocales,
// MatchingAlgorithm matchingAlgorithm,
// LocalePreference preference) {
//
// delegate = new LocaleChangerDelegate(
// new LocalePersistor(context),
// new LocaleResolver(supportedLocales,
// SystemLocaleRetriever.retrieve(),
// matchingAlgorithm,
// preference),
// new AppLocaleChanger(context)
// );
//
// delegate.initialize();
// }
//
// private static void checkInitialization() {
// if (delegate == null)
// throw new IllegalStateException("LocaleChanger is not initialized. Please first call LocaleChanger.initialize");
// }
//
// /**
// * Clears any Locale set and resolve and load a new default one.
// * This method can be useful if the app implements new supported Locales and it is needed to reload the default one in case there is a best match.
// */
// public static void resetLocale() {
// checkInitialization();
// delegate.resetLocale();
// }
//
// /**
// * Sets a new default app Locale that will be resolved from the one provided.
// *
// * @param supportedLocale a supported Locale that will be used to resolve the Locale to set.
// */
// public static void setLocale(Locale supportedLocale) {
// checkInitialization();
// delegate.setLocale(supportedLocale);
// }
//
// /**
// * Gets the supported Locale that has been used to set the app Locale.
// *
// * @return
// */
// public static Locale getLocale() {
// checkInitialization();
// return delegate.getLocale();
// }
//
// /**
// * This method should be used inside the Activity attachBaseContext.
// * The returned Context should be used as argument for the super method call.
// *
// * @param context
// * @return the resulting context that should be provided to the super method call.
// */
// public static Context configureBaseContext(Context context) {
// checkInitialization();
// return delegate.configureBaseContext(context);
// }
//
// /**
// * This method should be called from Application#onConfigurationChanged()
// */
// public static void onConfigurationChanged() {
// checkInitialization();
// delegate.onConfigurationChanged();
// }
// }
| import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.view.ActionMode;
import androidx.appcompat.widget.Toolbar;
import com.franmontiel.localechanger.LocaleChanger; | package androidx.appcompat.app;
public class LocaleChangerAppCompatDelegate extends AppCompatDelegate {
private final AppCompatDelegate delegate;
public LocaleChangerAppCompatDelegate(AppCompatDelegate delegate) {
this.delegate = delegate;
}
@NonNull
@Override
public Context attachBaseContext2(@NonNull Context context) { | // Path: library/src/main/java/com/franmontiel/localechanger/LocaleChanger.java
// public class LocaleChanger {
//
// private static LocaleChangerDelegate delegate;
//
// private LocaleChanger() {
// }
//
// /**
// * Initialize the LocaleChanger, this method needs to be called before calling any other method.
// * <p>
// * If this method was never invoked before it sets a Locale from the supported list if a language match is found with the system Locales,
// * if no match is found the first Locale in the list will be set.<p>
// * If this method was invoked before it will load a Locale previously set.
// * <p>
// * If this method is invoked when the library is already initialized the new settings will be applied from now on.
// *
// * @param context
// * @param supportedLocales a list of your app supported Locales
// * @throws IllegalStateException if the LocaleChanger is already initialized
// */
// public static void initialize(Context context, List<Locale> supportedLocales) {
// initialize(context,
// supportedLocales,
// new LanguageMatchingAlgorithm(),
// LocalePreference.PreferSupportedLocale);
// }
//
// /**
// * Initialize the LocaleChanger, this method needs to be called before calling any other method.
// * <p>
// * If this method was never invoked before it sets a Locale resolved using the provided {@link MatchingAlgorithm} and {@link LocalePreference}.<p>
// * If this method was invoked before it will load a Locale previously set.
// * <p>
// * If this method is invoked when the library is already initialized the new settings will be applied from now on.
// *
// * @param context
// * @param supportedLocales a list of your app supported Locales
// * @param matchingAlgorithm used to find a match between supported and system Locales
// * @param preference used to indicate what Locale is preferred to load in case of a match
// */
// public static void initialize(Context context,
// List<Locale> supportedLocales,
// MatchingAlgorithm matchingAlgorithm,
// LocalePreference preference) {
//
// delegate = new LocaleChangerDelegate(
// new LocalePersistor(context),
// new LocaleResolver(supportedLocales,
// SystemLocaleRetriever.retrieve(),
// matchingAlgorithm,
// preference),
// new AppLocaleChanger(context)
// );
//
// delegate.initialize();
// }
//
// private static void checkInitialization() {
// if (delegate == null)
// throw new IllegalStateException("LocaleChanger is not initialized. Please first call LocaleChanger.initialize");
// }
//
// /**
// * Clears any Locale set and resolve and load a new default one.
// * This method can be useful if the app implements new supported Locales and it is needed to reload the default one in case there is a best match.
// */
// public static void resetLocale() {
// checkInitialization();
// delegate.resetLocale();
// }
//
// /**
// * Sets a new default app Locale that will be resolved from the one provided.
// *
// * @param supportedLocale a supported Locale that will be used to resolve the Locale to set.
// */
// public static void setLocale(Locale supportedLocale) {
// checkInitialization();
// delegate.setLocale(supportedLocale);
// }
//
// /**
// * Gets the supported Locale that has been used to set the app Locale.
// *
// * @return
// */
// public static Locale getLocale() {
// checkInitialization();
// return delegate.getLocale();
// }
//
// /**
// * This method should be used inside the Activity attachBaseContext.
// * The returned Context should be used as argument for the super method call.
// *
// * @param context
// * @return the resulting context that should be provided to the super method call.
// */
// public static Context configureBaseContext(Context context) {
// checkInitialization();
// return delegate.configureBaseContext(context);
// }
//
// /**
// * This method should be called from Application#onConfigurationChanged()
// */
// public static void onConfigurationChanged() {
// checkInitialization();
// delegate.onConfigurationChanged();
// }
// }
// Path: library/src/main/java/androidx/appcompat/app/LocaleChangerAppCompatDelegate.java
import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.view.ActionMode;
import androidx.appcompat.widget.Toolbar;
import com.franmontiel.localechanger.LocaleChanger;
package androidx.appcompat.app;
public class LocaleChangerAppCompatDelegate extends AppCompatDelegate {
private final AppCompatDelegate delegate;
public LocaleChangerAppCompatDelegate(AppCompatDelegate delegate) {
this.delegate = delegate;
}
@NonNull
@Override
public Context attachBaseContext2(@NonNull Context context) { | return super.attachBaseContext2(LocaleChanger.configureBaseContext(context)); |
franmontiel/LocaleChanger | library/src/main/java/com/franmontiel/localechanger/matcher/MatchingLocales.java | // Path: library/src/main/java/com/franmontiel/localechanger/LocalePreference.java
// public enum LocalePreference {
// PreferSupportedLocale,
// PreferSystemLocale
// }
| import com.franmontiel.localechanger.LocalePreference;
import java.util.Locale; | /*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger.matcher;
/**
* This class represents a pair of matching locales between a supported and a system Locale.
*/
public final class MatchingLocales {
private Locale supportedLocale;
private Locale systemLocale;
public MatchingLocales(Locale supportedLocale, Locale systemLocale) {
this.supportedLocale = supportedLocale;
this.systemLocale = systemLocale;
}
public Locale getSupportedLocale() {
return supportedLocale;
}
public Locale getSystemLocale() {
return systemLocale;
}
| // Path: library/src/main/java/com/franmontiel/localechanger/LocalePreference.java
// public enum LocalePreference {
// PreferSupportedLocale,
// PreferSystemLocale
// }
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/MatchingLocales.java
import com.franmontiel.localechanger.LocalePreference;
import java.util.Locale;
/*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger.matcher;
/**
* This class represents a pair of matching locales between a supported and a system Locale.
*/
public final class MatchingLocales {
private Locale supportedLocale;
private Locale systemLocale;
public MatchingLocales(Locale supportedLocale, Locale systemLocale) {
this.supportedLocale = supportedLocale;
this.systemLocale = systemLocale;
}
public Locale getSupportedLocale() {
return supportedLocale;
}
public Locale getSystemLocale() {
return systemLocale;
}
| public Locale getPreferredLocale(LocalePreference preference) { |
franmontiel/LocaleChanger | library/src/main/java/com/franmontiel/localechanger/matcher/LanguageMatchingAlgorithm.java | // Path: library/src/main/java/com/franmontiel/localechanger/utils/LocaleMatcher.java
// public class LocaleMatcher {
//
// /**
// * Enum representing the level of matching of two Locales.
// */
// public enum MatchLevel {
// NoMatch,
// LanguageMatch,
// LanguageAndCountryMatch,
// CompleteMatch
// }
//
// private LocaleMatcher() {
// }
//
// /**
// * Method to determine the level of matching of two Locales.
// * @param l1
// * @param l2
// * @return
// */
// public static MatchLevel match(Locale l1, Locale l2) {
// MatchLevel matchLevel = NoMatch;
// if (l1.equals(l2)) {
// matchLevel = MatchLevel.CompleteMatch;
// } else if (l1.getLanguage().equals(l2.getLanguage()) && l1.getCountry().equals(l2.getCountry())) {
// return MatchLevel.LanguageAndCountryMatch;
// } else if (l1.getLanguage().equals(l2.getLanguage())) {
// return MatchLevel.LanguageMatch;
// }
// return matchLevel;
// }
// }
| import com.franmontiel.localechanger.utils.LocaleMatcher;
import java.util.List;
import java.util.Locale; | /*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger.matcher;
/**
* An algorithm that match the Locales the same language in common.
*/
public final class LanguageMatchingAlgorithm implements MatchingAlgorithm {
@Override
public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
MatchingLocales matchingPair = null;
for (Locale systemLocale : systemLocales) {
Locale matchingSupportedLocale = findMatchingLocale(systemLocale, supportedLocales);
if (matchingSupportedLocale != null) {
matchingPair = new MatchingLocales(matchingSupportedLocale, systemLocale);
break;
}
}
return matchingPair;
}
@Override
public MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales) {
Locale matchingSystemLocale = findMatchingLocale(supportedLocale, systemLocales);
return matchingSystemLocale != null ?
new MatchingLocales(supportedLocale, matchingSystemLocale) :
null;
}
private static Locale findMatchingLocale(Locale localeToMatch, List<Locale> candidates) {
Locale matchingLocale = null;
for (Locale candidate : candidates) { | // Path: library/src/main/java/com/franmontiel/localechanger/utils/LocaleMatcher.java
// public class LocaleMatcher {
//
// /**
// * Enum representing the level of matching of two Locales.
// */
// public enum MatchLevel {
// NoMatch,
// LanguageMatch,
// LanguageAndCountryMatch,
// CompleteMatch
// }
//
// private LocaleMatcher() {
// }
//
// /**
// * Method to determine the level of matching of two Locales.
// * @param l1
// * @param l2
// * @return
// */
// public static MatchLevel match(Locale l1, Locale l2) {
// MatchLevel matchLevel = NoMatch;
// if (l1.equals(l2)) {
// matchLevel = MatchLevel.CompleteMatch;
// } else if (l1.getLanguage().equals(l2.getLanguage()) && l1.getCountry().equals(l2.getCountry())) {
// return MatchLevel.LanguageAndCountryMatch;
// } else if (l1.getLanguage().equals(l2.getLanguage())) {
// return MatchLevel.LanguageMatch;
// }
// return matchLevel;
// }
// }
// Path: library/src/main/java/com/franmontiel/localechanger/matcher/LanguageMatchingAlgorithm.java
import com.franmontiel.localechanger.utils.LocaleMatcher;
import java.util.List;
import java.util.Locale;
/*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger.matcher;
/**
* An algorithm that match the Locales the same language in common.
*/
public final class LanguageMatchingAlgorithm implements MatchingAlgorithm {
@Override
public MatchingLocales findDefaultMatch(List<Locale> supportedLocales, List<Locale> systemLocales) {
MatchingLocales matchingPair = null;
for (Locale systemLocale : systemLocales) {
Locale matchingSupportedLocale = findMatchingLocale(systemLocale, supportedLocales);
if (matchingSupportedLocale != null) {
matchingPair = new MatchingLocales(matchingSupportedLocale, systemLocale);
break;
}
}
return matchingPair;
}
@Override
public MatchingLocales findMatch(Locale supportedLocale, List<Locale> systemLocales) {
Locale matchingSystemLocale = findMatchingLocale(supportedLocale, systemLocales);
return matchingSystemLocale != null ?
new MatchingLocales(supportedLocale, matchingSystemLocale) :
null;
}
private static Locale findMatchingLocale(Locale localeToMatch, List<Locale> candidates) {
Locale matchingLocale = null;
for (Locale candidate : candidates) { | LocaleMatcher.MatchLevel matchLevel = LocaleMatcher.match(localeToMatch, candidate); |
franmontiel/LocaleChanger | sample/src/androidTest/java/com/franmontiel/localechanger/sample/SampleFragmentTest.java | // Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/pageobjects/SampleScreen.java
// public class SampleScreen {
//
// private final static int LOCALE_SPINNER_ID = R.id.localeSpinner;
// private final static int UPDATE_BUTTON_ID = R.id.localeUpdate;
//
// private ActivityTestRule<? extends Activity> activityRule;
//
// public SampleScreen(Class<? extends Activity> activityClass) {
// this.activityRule = new ActivityTestRule<>(activityClass, false, false);
// }
//
// public SampleScreen launch() {
// activityRule.launchActivity(null);
// return this;
// }
//
// public SampleScreen changeLocale(Locale locale) {
// onView(withId(LOCALE_SPINNER_ID)).perform(click());
// onData(allOf(is(instanceOf(Locale.class)), is(locale))).perform(click());
//
// onView(withId(UPDATE_BUTTON_ID)).perform(click());
// SystemClock.sleep(500);
//
// return this;
// }
//
// public SampleScreen openNewScreen() {
// onView(allOf(withId(R.id.openNewScreen), withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))).perform(click());
// return this;
// }
//
// public SampleScreen verifyLocaleChanged(Locale expectedLocale) {
// onView(withId(R.id.currentLocale)).check(matches(withText(expectedLocale.toString())));
// return this;
// }
//
// public SampleScreen verifyDate(String expectedDateFormat) {
// onView(withId(R.id.date)).check(matches(withText(expectedDateFormat)));
// return this;
// }
//
// public SampleScreen verifyUpdateButtonText(String expectedText) {
// onView(withId(R.id.localeUpdate)).check(matches(withText(expectedText)));
// return this;
// }
//
// public SampleScreen verifyOverflowSettingsItemTitle(String expectedTitle) {
// openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
//
// // The MenuItem id and the View id is not the same. It is needed to use another matcher.
// onView(withText(expectedTitle)).check(matches(isDisplayed()));
//
// return this;
// }
//
// public SampleScreen verifyLayoutDirectionRTL() {
// onView(withId(R.id.currentLocale)).check(isCompletelyLeftOf(withId(R.id.currentLocaleTitle)));
//
// return this;
// }
//
// public SampleScreen verifyLayoutDirectionLTR() {
// onView(withId(R.id.currentLocale)).check(isCompletelyRightOf(withId(R.id.currentLocaleTitle)));
//
// return this;
// }
//
// public SampleScreen changeOrientationToLandscape() {
// onView(isRoot()).perform(orientationLandscape());
// SystemClock.sleep(500);
// return this;
// }
//
// public SampleScreen changeOrientationToPortrait() {
// onView(isRoot()).perform(orientationPortrait());
// SystemClock.sleep(500);
// return this;
// }
//
// public SampleScreen pressBack() {
// Espresso.pressBack();
// return this;
// }
// }
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.franmontiel.localechanger.sample.pageobjects.SampleScreen;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith; | /*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger.sample;
/**
* Advice: It is recommended to run the tests with a system locale configured not listed in the supported ones (to avoid false positives).
*/
@RunWith(AndroidJUnit4.class)
public class SampleFragmentTest {
private SampleScreenTestDelegate sampleScreenTestDelegate = new SampleScreenTestDelegate();
@Before
public void setUp() { | // Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/pageobjects/SampleScreen.java
// public class SampleScreen {
//
// private final static int LOCALE_SPINNER_ID = R.id.localeSpinner;
// private final static int UPDATE_BUTTON_ID = R.id.localeUpdate;
//
// private ActivityTestRule<? extends Activity> activityRule;
//
// public SampleScreen(Class<? extends Activity> activityClass) {
// this.activityRule = new ActivityTestRule<>(activityClass, false, false);
// }
//
// public SampleScreen launch() {
// activityRule.launchActivity(null);
// return this;
// }
//
// public SampleScreen changeLocale(Locale locale) {
// onView(withId(LOCALE_SPINNER_ID)).perform(click());
// onData(allOf(is(instanceOf(Locale.class)), is(locale))).perform(click());
//
// onView(withId(UPDATE_BUTTON_ID)).perform(click());
// SystemClock.sleep(500);
//
// return this;
// }
//
// public SampleScreen openNewScreen() {
// onView(allOf(withId(R.id.openNewScreen), withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))).perform(click());
// return this;
// }
//
// public SampleScreen verifyLocaleChanged(Locale expectedLocale) {
// onView(withId(R.id.currentLocale)).check(matches(withText(expectedLocale.toString())));
// return this;
// }
//
// public SampleScreen verifyDate(String expectedDateFormat) {
// onView(withId(R.id.date)).check(matches(withText(expectedDateFormat)));
// return this;
// }
//
// public SampleScreen verifyUpdateButtonText(String expectedText) {
// onView(withId(R.id.localeUpdate)).check(matches(withText(expectedText)));
// return this;
// }
//
// public SampleScreen verifyOverflowSettingsItemTitle(String expectedTitle) {
// openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
//
// // The MenuItem id and the View id is not the same. It is needed to use another matcher.
// onView(withText(expectedTitle)).check(matches(isDisplayed()));
//
// return this;
// }
//
// public SampleScreen verifyLayoutDirectionRTL() {
// onView(withId(R.id.currentLocale)).check(isCompletelyLeftOf(withId(R.id.currentLocaleTitle)));
//
// return this;
// }
//
// public SampleScreen verifyLayoutDirectionLTR() {
// onView(withId(R.id.currentLocale)).check(isCompletelyRightOf(withId(R.id.currentLocaleTitle)));
//
// return this;
// }
//
// public SampleScreen changeOrientationToLandscape() {
// onView(isRoot()).perform(orientationLandscape());
// SystemClock.sleep(500);
// return this;
// }
//
// public SampleScreen changeOrientationToPortrait() {
// onView(isRoot()).perform(orientationPortrait());
// SystemClock.sleep(500);
// return this;
// }
//
// public SampleScreen pressBack() {
// Espresso.pressBack();
// return this;
// }
// }
// Path: sample/src/androidTest/java/com/franmontiel/localechanger/sample/SampleFragmentTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.franmontiel.localechanger.sample.pageobjects.SampleScreen;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
/*
* Copyright (c) 2017 Francisco José Montiel Navarro.
*
* 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 com.franmontiel.localechanger.sample;
/**
* Advice: It is recommended to run the tests with a system locale configured not listed in the supported ones (to avoid false positives).
*/
@RunWith(AndroidJUnit4.class)
public class SampleFragmentTest {
private SampleScreenTestDelegate sampleScreenTestDelegate = new SampleScreenTestDelegate();
@Before
public void setUp() { | sampleScreenTestDelegate.setUp(new SampleScreen(SampleFragmentContainerActivity.class)); |
54cgt/weixin | 微信/src/net/cgt/weixin/utils/AppUtil.java | // Path: 微信/src/net/cgt/weixin/app/App.java
// public class App extends Application {
//
// private static final String LOGTAG = LogUtil.makeLogTag(App.class);
//
// private static App instance;
//
// @Override
// public void onCreate() {
// instance = this;
// super.onCreate();
//
// // 异常处理,不需要处理时注释掉这两句即可!
// CrashHandler crashHandler = CrashHandler.getInstance();
// // 注册crashHandler
// crashHandler.init(getApplicationContext());
// }
//
// @Override
// public void onTerminate() {
// }
//
// /**
// * Global context
// *
// * @return
// */
// public static App getContext() {
// return instance;
// }
//
// /**
// * 获取版本name
// *
// * @return
// */
// public static String getVersionName() {
// PackageManager packageManager = instance.getPackageManager();
// PackageInfo packageInfo = null;
// try {
// packageInfo = packageManager.getPackageInfo(instance.getPackageName(), 0);
// } catch (NameNotFoundException e) {
// e.printStackTrace();
// }
// return packageInfo.versionName;
// }
//
// /**
// * 获取版本code
// *
// * @return
// */
// public static int getVersionCode() {
// PackageManager packageManager = instance.getPackageManager();
// PackageInfo packageInfo = null;
// try {
// packageInfo = packageManager.getPackageInfo(instance.getPackageName(), 0);
// } catch (NameNotFoundException e) {
// e.printStackTrace();
// }
// return packageInfo.versionCode;
// }
// }
| import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.cgt.weixin.app.App;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import android.util.Log;
import android.widget.FrameLayout;
| package net.cgt.weixin.utils;
/**
* 全局工具类
*
* @author lijian
* @date 2015-01-03 12:51:27
*/
public class AppUtil {
private static final String LOGTAG = LogUtil.makeLogTag(AppUtil.class);
/**
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
*
* @param context 上下文
* @param dpValue 单位dip的数据
* @return
*/
public static int dip2px(Context context, float dpValue) {
| // Path: 微信/src/net/cgt/weixin/app/App.java
// public class App extends Application {
//
// private static final String LOGTAG = LogUtil.makeLogTag(App.class);
//
// private static App instance;
//
// @Override
// public void onCreate() {
// instance = this;
// super.onCreate();
//
// // 异常处理,不需要处理时注释掉这两句即可!
// CrashHandler crashHandler = CrashHandler.getInstance();
// // 注册crashHandler
// crashHandler.init(getApplicationContext());
// }
//
// @Override
// public void onTerminate() {
// }
//
// /**
// * Global context
// *
// * @return
// */
// public static App getContext() {
// return instance;
// }
//
// /**
// * 获取版本name
// *
// * @return
// */
// public static String getVersionName() {
// PackageManager packageManager = instance.getPackageManager();
// PackageInfo packageInfo = null;
// try {
// packageInfo = packageManager.getPackageInfo(instance.getPackageName(), 0);
// } catch (NameNotFoundException e) {
// e.printStackTrace();
// }
// return packageInfo.versionName;
// }
//
// /**
// * 获取版本code
// *
// * @return
// */
// public static int getVersionCode() {
// PackageManager packageManager = instance.getPackageManager();
// PackageInfo packageInfo = null;
// try {
// packageInfo = packageManager.getPackageInfo(instance.getPackageName(), 0);
// } catch (NameNotFoundException e) {
// e.printStackTrace();
// }
// return packageInfo.versionCode;
// }
// }
// Path: 微信/src/net/cgt/weixin/utils/AppUtil.java
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.cgt.weixin.app.App;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import android.util.Log;
import android.widget.FrameLayout;
package net.cgt.weixin.utils;
/**
* 全局工具类
*
* @author lijian
* @date 2015-01-03 12:51:27
*/
public class AppUtil {
private static final String LOGTAG = LogUtil.makeLogTag(AppUtil.class);
/**
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
*
* @param context 上下文
* @param dpValue 单位dip的数据
* @return
*/
public static int dip2px(Context context, float dpValue) {
| final float scale = App.getContext().getResources().getDisplayMetrics().density;
|
54cgt/weixin | 微信/src/net/cgt/weixin/fragment/FindFragment.java | // Path: 微信/src/net/cgt/weixin/utils/AppToast.java
// public class AppToast extends Toast {
//
// private static AppToast instance = null;
// private View layout;
// private TextView text;
//
// private AppToast() {
// super(GlobalParams.activity);
// init();
// }
//
// public static AppToast getToast() {
// if (instance == null) {
// instance = new AppToast();
// }
// return instance;
// }
//
// private void init() {
// LayoutInflater inflate = (LayoutInflater) GlobalParams.activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// layout = inflate.inflate(R.layout.cgt_transient_notification, null);
// text = (TextView) layout.findViewById(R.id.message);
// this.setView(layout);
// }
//
// public void show(String msg) {
// text.setText(msg);
// this.setDuration(Toast.LENGTH_SHORT);
// this.show();
// }
//
// public void show(int msg) {
// text.setText(msg);
// this.setDuration(Toast.LENGTH_SHORT);
// this.show();
// }
//
// }
//
// Path: 微信/src/net/cgt/weixin/utils/L.java
// public class L {
// private static final boolean flag = true;
//
// public static void i(String tag, String msg) {
// if (flag)
// Log.i(tag, msg);
// }
//
// public static void d(String tag, String msg) {
// if (flag)
// Log.d(tag, msg);
// }
//
// public static void e(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void e(String tag, String msg, Throwable tr) {
// if (flag)
// Log.e(tag, msg, tr);
// }
//
// public static void v(String tag, String msg) {
// if (flag)
// Log.v(tag, msg);
// }
//
// public static void m(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void w(String tag, String msg) {
// if (flag)
// Log.w(tag, msg);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/LogUtil.java
// public class LogUtil {
//
// @SuppressWarnings("unchecked")
// public static String makeLogTag(Class cls) {
// return "Weixin_" + cls.getSimpleName();
// }
//
// }
| import net.cgt.weixin.R;
import net.cgt.weixin.utils.AppToast;
import net.cgt.weixin.utils.L;
import net.cgt.weixin.utils.LogUtil;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
| initView(v);
initData();
}
private void initView(View v) {
LinearLayout mLl_friends = (LinearLayout) v.findViewById(R.id.cgt_ll_find_friends);
LinearLayout mLl_sweep = (LinearLayout) v.findViewById(R.id.cgt_ll_find_sweep);
LinearLayout mLl_shake = (LinearLayout) v.findViewById(R.id.cgt_ll_find_shake);
LinearLayout mLl_nearbyPeople = (LinearLayout) v.findViewById(R.id.cgt_ll_find_nearbyPeople);
LinearLayout mLl_driftBottle = (LinearLayout) v.findViewById(R.id.cgt_ll_find_driftBottle);
LinearLayout mLl_shopping = (LinearLayout) v.findViewById(R.id.cgt_ll_find_shopping);
LinearLayout mLl_game = (LinearLayout) v.findViewById(R.id.cgt_ll_find_game);
mLl_friends.setOnClickListener(this);
mLl_sweep.setOnClickListener(this);
mLl_shake.setOnClickListener(this);
mLl_nearbyPeople.setOnClickListener(this);
mLl_driftBottle.setOnClickListener(this);
mLl_shopping.setOnClickListener(this);
mLl_game.setOnClickListener(this);
}
private void initData() {
// TODO Auto-generated method stub
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.cgt_ll_find_friends:
| // Path: 微信/src/net/cgt/weixin/utils/AppToast.java
// public class AppToast extends Toast {
//
// private static AppToast instance = null;
// private View layout;
// private TextView text;
//
// private AppToast() {
// super(GlobalParams.activity);
// init();
// }
//
// public static AppToast getToast() {
// if (instance == null) {
// instance = new AppToast();
// }
// return instance;
// }
//
// private void init() {
// LayoutInflater inflate = (LayoutInflater) GlobalParams.activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// layout = inflate.inflate(R.layout.cgt_transient_notification, null);
// text = (TextView) layout.findViewById(R.id.message);
// this.setView(layout);
// }
//
// public void show(String msg) {
// text.setText(msg);
// this.setDuration(Toast.LENGTH_SHORT);
// this.show();
// }
//
// public void show(int msg) {
// text.setText(msg);
// this.setDuration(Toast.LENGTH_SHORT);
// this.show();
// }
//
// }
//
// Path: 微信/src/net/cgt/weixin/utils/L.java
// public class L {
// private static final boolean flag = true;
//
// public static void i(String tag, String msg) {
// if (flag)
// Log.i(tag, msg);
// }
//
// public static void d(String tag, String msg) {
// if (flag)
// Log.d(tag, msg);
// }
//
// public static void e(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void e(String tag, String msg, Throwable tr) {
// if (flag)
// Log.e(tag, msg, tr);
// }
//
// public static void v(String tag, String msg) {
// if (flag)
// Log.v(tag, msg);
// }
//
// public static void m(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void w(String tag, String msg) {
// if (flag)
// Log.w(tag, msg);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/LogUtil.java
// public class LogUtil {
//
// @SuppressWarnings("unchecked")
// public static String makeLogTag(Class cls) {
// return "Weixin_" + cls.getSimpleName();
// }
//
// }
// Path: 微信/src/net/cgt/weixin/fragment/FindFragment.java
import net.cgt.weixin.R;
import net.cgt.weixin.utils.AppToast;
import net.cgt.weixin.utils.L;
import net.cgt.weixin.utils.LogUtil;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
initView(v);
initData();
}
private void initView(View v) {
LinearLayout mLl_friends = (LinearLayout) v.findViewById(R.id.cgt_ll_find_friends);
LinearLayout mLl_sweep = (LinearLayout) v.findViewById(R.id.cgt_ll_find_sweep);
LinearLayout mLl_shake = (LinearLayout) v.findViewById(R.id.cgt_ll_find_shake);
LinearLayout mLl_nearbyPeople = (LinearLayout) v.findViewById(R.id.cgt_ll_find_nearbyPeople);
LinearLayout mLl_driftBottle = (LinearLayout) v.findViewById(R.id.cgt_ll_find_driftBottle);
LinearLayout mLl_shopping = (LinearLayout) v.findViewById(R.id.cgt_ll_find_shopping);
LinearLayout mLl_game = (LinearLayout) v.findViewById(R.id.cgt_ll_find_game);
mLl_friends.setOnClickListener(this);
mLl_sweep.setOnClickListener(this);
mLl_shake.setOnClickListener(this);
mLl_nearbyPeople.setOnClickListener(this);
mLl_driftBottle.setOnClickListener(this);
mLl_shopping.setOnClickListener(this);
mLl_game.setOnClickListener(this);
}
private void initData() {
// TODO Auto-generated method stub
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.cgt_ll_find_friends:
| AppToast.getToast().show(R.string.text_find_friends);
|
54cgt/weixin | 微信/src/net/cgt/weixin/fragment/FindFragment.java | // Path: 微信/src/net/cgt/weixin/utils/AppToast.java
// public class AppToast extends Toast {
//
// private static AppToast instance = null;
// private View layout;
// private TextView text;
//
// private AppToast() {
// super(GlobalParams.activity);
// init();
// }
//
// public static AppToast getToast() {
// if (instance == null) {
// instance = new AppToast();
// }
// return instance;
// }
//
// private void init() {
// LayoutInflater inflate = (LayoutInflater) GlobalParams.activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// layout = inflate.inflate(R.layout.cgt_transient_notification, null);
// text = (TextView) layout.findViewById(R.id.message);
// this.setView(layout);
// }
//
// public void show(String msg) {
// text.setText(msg);
// this.setDuration(Toast.LENGTH_SHORT);
// this.show();
// }
//
// public void show(int msg) {
// text.setText(msg);
// this.setDuration(Toast.LENGTH_SHORT);
// this.show();
// }
//
// }
//
// Path: 微信/src/net/cgt/weixin/utils/L.java
// public class L {
// private static final boolean flag = true;
//
// public static void i(String tag, String msg) {
// if (flag)
// Log.i(tag, msg);
// }
//
// public static void d(String tag, String msg) {
// if (flag)
// Log.d(tag, msg);
// }
//
// public static void e(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void e(String tag, String msg, Throwable tr) {
// if (flag)
// Log.e(tag, msg, tr);
// }
//
// public static void v(String tag, String msg) {
// if (flag)
// Log.v(tag, msg);
// }
//
// public static void m(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void w(String tag, String msg) {
// if (flag)
// Log.w(tag, msg);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/LogUtil.java
// public class LogUtil {
//
// @SuppressWarnings("unchecked")
// public static String makeLogTag(Class cls) {
// return "Weixin_" + cls.getSimpleName();
// }
//
// }
| import net.cgt.weixin.R;
import net.cgt.weixin.utils.AppToast;
import net.cgt.weixin.utils.L;
import net.cgt.weixin.utils.LogUtil;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
| initData();
}
private void initView(View v) {
LinearLayout mLl_friends = (LinearLayout) v.findViewById(R.id.cgt_ll_find_friends);
LinearLayout mLl_sweep = (LinearLayout) v.findViewById(R.id.cgt_ll_find_sweep);
LinearLayout mLl_shake = (LinearLayout) v.findViewById(R.id.cgt_ll_find_shake);
LinearLayout mLl_nearbyPeople = (LinearLayout) v.findViewById(R.id.cgt_ll_find_nearbyPeople);
LinearLayout mLl_driftBottle = (LinearLayout) v.findViewById(R.id.cgt_ll_find_driftBottle);
LinearLayout mLl_shopping = (LinearLayout) v.findViewById(R.id.cgt_ll_find_shopping);
LinearLayout mLl_game = (LinearLayout) v.findViewById(R.id.cgt_ll_find_game);
mLl_friends.setOnClickListener(this);
mLl_sweep.setOnClickListener(this);
mLl_shake.setOnClickListener(this);
mLl_nearbyPeople.setOnClickListener(this);
mLl_driftBottle.setOnClickListener(this);
mLl_shopping.setOnClickListener(this);
mLl_game.setOnClickListener(this);
}
private void initData() {
// TODO Auto-generated method stub
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.cgt_ll_find_friends:
AppToast.getToast().show(R.string.text_find_friends);
| // Path: 微信/src/net/cgt/weixin/utils/AppToast.java
// public class AppToast extends Toast {
//
// private static AppToast instance = null;
// private View layout;
// private TextView text;
//
// private AppToast() {
// super(GlobalParams.activity);
// init();
// }
//
// public static AppToast getToast() {
// if (instance == null) {
// instance = new AppToast();
// }
// return instance;
// }
//
// private void init() {
// LayoutInflater inflate = (LayoutInflater) GlobalParams.activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// layout = inflate.inflate(R.layout.cgt_transient_notification, null);
// text = (TextView) layout.findViewById(R.id.message);
// this.setView(layout);
// }
//
// public void show(String msg) {
// text.setText(msg);
// this.setDuration(Toast.LENGTH_SHORT);
// this.show();
// }
//
// public void show(int msg) {
// text.setText(msg);
// this.setDuration(Toast.LENGTH_SHORT);
// this.show();
// }
//
// }
//
// Path: 微信/src/net/cgt/weixin/utils/L.java
// public class L {
// private static final boolean flag = true;
//
// public static void i(String tag, String msg) {
// if (flag)
// Log.i(tag, msg);
// }
//
// public static void d(String tag, String msg) {
// if (flag)
// Log.d(tag, msg);
// }
//
// public static void e(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void e(String tag, String msg, Throwable tr) {
// if (flag)
// Log.e(tag, msg, tr);
// }
//
// public static void v(String tag, String msg) {
// if (flag)
// Log.v(tag, msg);
// }
//
// public static void m(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void w(String tag, String msg) {
// if (flag)
// Log.w(tag, msg);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/LogUtil.java
// public class LogUtil {
//
// @SuppressWarnings("unchecked")
// public static String makeLogTag(Class cls) {
// return "Weixin_" + cls.getSimpleName();
// }
//
// }
// Path: 微信/src/net/cgt/weixin/fragment/FindFragment.java
import net.cgt.weixin.R;
import net.cgt.weixin.utils.AppToast;
import net.cgt.weixin.utils.L;
import net.cgt.weixin.utils.LogUtil;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
initData();
}
private void initView(View v) {
LinearLayout mLl_friends = (LinearLayout) v.findViewById(R.id.cgt_ll_find_friends);
LinearLayout mLl_sweep = (LinearLayout) v.findViewById(R.id.cgt_ll_find_sweep);
LinearLayout mLl_shake = (LinearLayout) v.findViewById(R.id.cgt_ll_find_shake);
LinearLayout mLl_nearbyPeople = (LinearLayout) v.findViewById(R.id.cgt_ll_find_nearbyPeople);
LinearLayout mLl_driftBottle = (LinearLayout) v.findViewById(R.id.cgt_ll_find_driftBottle);
LinearLayout mLl_shopping = (LinearLayout) v.findViewById(R.id.cgt_ll_find_shopping);
LinearLayout mLl_game = (LinearLayout) v.findViewById(R.id.cgt_ll_find_game);
mLl_friends.setOnClickListener(this);
mLl_sweep.setOnClickListener(this);
mLl_shake.setOnClickListener(this);
mLl_nearbyPeople.setOnClickListener(this);
mLl_driftBottle.setOnClickListener(this);
mLl_shopping.setOnClickListener(this);
mLl_game.setOnClickListener(this);
}
private void initData() {
// TODO Auto-generated method stub
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.cgt_ll_find_friends:
AppToast.getToast().show(R.string.text_find_friends);
| L.i(LOGTAG, "朋友圈");
|
54cgt/weixin | 微信/src/net/cgt/weixin/view/dialog/WXProgressDialog.java | // Path: 微信/src/net/cgt/weixin/utils/L.java
// public class L {
// private static final boolean flag = true;
//
// public static void i(String tag, String msg) {
// if (flag)
// Log.i(tag, msg);
// }
//
// public static void d(String tag, String msg) {
// if (flag)
// Log.d(tag, msg);
// }
//
// public static void e(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void e(String tag, String msg, Throwable tr) {
// if (flag)
// Log.e(tag, msg, tr);
// }
//
// public static void v(String tag, String msg) {
// if (flag)
// Log.v(tag, msg);
// }
//
// public static void m(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void w(String tag, String msg) {
// if (flag)
// Log.w(tag, msg);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/LogUtil.java
// public class LogUtil {
//
// @SuppressWarnings("unchecked")
// public static String makeLogTag(Class cls) {
// return "Weixin_" + cls.getSimpleName();
// }
//
// }
| import android.app.ProgressDialog;
import android.content.Context;
import net.cgt.weixin.R;
import net.cgt.weixin.utils.L;
import net.cgt.weixin.utils.LogUtil; | package net.cgt.weixin.view.dialog;
/**
* 自定义进度对话框
*
* @author lijian
* @date 2015-01-11 18:31:59
*/
public class WXProgressDialog {
private static final String LOGTAG = LogUtil.makeLogTag(WXProgressDialog.class);
private Context mContext;
private ProgressDialog dialog;
public WXProgressDialog(Context context) {
this.mContext = context;
initDialog();
}
/**
* 得到进度对话框
*
* @return
*/
public ProgressDialog getDialog() {
return dialog;
}
/**
* 初始化进度对话框
*/
private void initDialog() {
dialog = new ProgressDialog(mContext, ProgressDialog.THEME_HOLO_LIGHT);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);//转圈圈的进度条
dialog.setCancelable(false);//不可被取消
dialog.setMessage(mContext.getString(R.string.text_NetProgressDialogMsg));
}
/**
* 显示进度对话框
*/
public void show() {
if (!dialog.isShowing()) {
dialog.show();
}
}
/**
* 设置进度对话框的消息
*
* @param message
*/
public void setContent(CharSequence message) {
dialog.setMessage(message);
}
/**
* 取消进度对话框
*/
public void cancel() {
if (dialog == null) { | // Path: 微信/src/net/cgt/weixin/utils/L.java
// public class L {
// private static final boolean flag = true;
//
// public static void i(String tag, String msg) {
// if (flag)
// Log.i(tag, msg);
// }
//
// public static void d(String tag, String msg) {
// if (flag)
// Log.d(tag, msg);
// }
//
// public static void e(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void e(String tag, String msg, Throwable tr) {
// if (flag)
// Log.e(tag, msg, tr);
// }
//
// public static void v(String tag, String msg) {
// if (flag)
// Log.v(tag, msg);
// }
//
// public static void m(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void w(String tag, String msg) {
// if (flag)
// Log.w(tag, msg);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/LogUtil.java
// public class LogUtil {
//
// @SuppressWarnings("unchecked")
// public static String makeLogTag(Class cls) {
// return "Weixin_" + cls.getSimpleName();
// }
//
// }
// Path: 微信/src/net/cgt/weixin/view/dialog/WXProgressDialog.java
import android.app.ProgressDialog;
import android.content.Context;
import net.cgt.weixin.R;
import net.cgt.weixin.utils.L;
import net.cgt.weixin.utils.LogUtil;
package net.cgt.weixin.view.dialog;
/**
* 自定义进度对话框
*
* @author lijian
* @date 2015-01-11 18:31:59
*/
public class WXProgressDialog {
private static final String LOGTAG = LogUtil.makeLogTag(WXProgressDialog.class);
private Context mContext;
private ProgressDialog dialog;
public WXProgressDialog(Context context) {
this.mContext = context;
initDialog();
}
/**
* 得到进度对话框
*
* @return
*/
public ProgressDialog getDialog() {
return dialog;
}
/**
* 初始化进度对话框
*/
private void initDialog() {
dialog = new ProgressDialog(mContext, ProgressDialog.THEME_HOLO_LIGHT);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);//转圈圈的进度条
dialog.setCancelable(false);//不可被取消
dialog.setMessage(mContext.getString(R.string.text_NetProgressDialogMsg));
}
/**
* 显示进度对话框
*/
public void show() {
if (!dialog.isShowing()) {
dialog.show();
}
}
/**
* 设置进度对话框的消息
*
* @param message
*/
public void setContent(CharSequence message) {
dialog.setMessage(message);
}
/**
* 取消进度对话框
*/
public void cancel() {
if (dialog == null) { | L.i(LOGTAG, "dialog==null"); |
54cgt/weixin | 微信/src/net/cgt/weixin/app/CrashHandler.java | // Path: 微信/src/net/cgt/weixin/utils/L.java
// public class L {
// private static final boolean flag = true;
//
// public static void i(String tag, String msg) {
// if (flag)
// Log.i(tag, msg);
// }
//
// public static void d(String tag, String msg) {
// if (flag)
// Log.d(tag, msg);
// }
//
// public static void e(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void e(String tag, String msg, Throwable tr) {
// if (flag)
// Log.e(tag, msg, tr);
// }
//
// public static void v(String tag, String msg) {
// if (flag)
// Log.v(tag, msg);
// }
//
// public static void m(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void w(String tag, String msg) {
// if (flag)
// Log.w(tag, msg);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/LogUtil.java
// public class LogUtil {
//
// @SuppressWarnings("unchecked")
// public static String makeLogTag(Class cls) {
// return "Weixin_" + cls.getSimpleName();
// }
//
// }
| import java.io.File;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.Thread.UncaughtExceptionHandler;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Properties;
import java.util.TreeSet;
import net.cgt.weixin.utils.L;
import net.cgt.weixin.utils.LogUtil;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import android.os.Environment;
import android.os.Looper;
import android.text.format.Time;
import android.util.Log;
| package net.cgt.weixin.app;
/**
* 测序崩溃处理程序
*
* @author lijian
* @date 2015-01-03 17:00:07
*/
public class CrashHandler implements UncaughtExceptionHandler {
/** Debug Log tag */
public static final String LOGTAG = LogUtil.makeLogTag(CrashHandler.class);
/**
* 是否开启日志输出,在Debug状态下开启, 在Release状态下关闭以提示程序性能
* */
public static final boolean DEBUG = false;
/** 系统默认的UncaughtException处理类 */
private Thread.UncaughtExceptionHandler mDefaultHandler;
/** CrashHandler实例 */
private static CrashHandler INSTANCE;
/** 程序的Context对象 */
private Context mContext;
/** 使用Properties来保存设备的信息和错误堆栈信息 */
private Properties mDeviceCrashInfo = new Properties();
private static final String VERSION_NAME = "versionName";
private static final String VERSION_CODE = "versionCode";
private static final String STACK_TRACE = "STACK_TRACE";
/** 错误报告文件的扩展名 */
private static final String CRASH_REPORTER_EXTENSION = ".dat";
/** SD卡错误报告文件路径 */
private static String SDCARD_PATH = "/sdcard/data/sxc/";
/** 保证只有一个CrashHandler实例 */
private CrashHandler() {
initAddress();
}
private void initAddress() {
SDCARD_PATH = Environment.getExternalStorageDirectory() + "/";// +"/data/sxc/";
| // Path: 微信/src/net/cgt/weixin/utils/L.java
// public class L {
// private static final boolean flag = true;
//
// public static void i(String tag, String msg) {
// if (flag)
// Log.i(tag, msg);
// }
//
// public static void d(String tag, String msg) {
// if (flag)
// Log.d(tag, msg);
// }
//
// public static void e(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void e(String tag, String msg, Throwable tr) {
// if (flag)
// Log.e(tag, msg, tr);
// }
//
// public static void v(String tag, String msg) {
// if (flag)
// Log.v(tag, msg);
// }
//
// public static void m(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void w(String tag, String msg) {
// if (flag)
// Log.w(tag, msg);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/LogUtil.java
// public class LogUtil {
//
// @SuppressWarnings("unchecked")
// public static String makeLogTag(Class cls) {
// return "Weixin_" + cls.getSimpleName();
// }
//
// }
// Path: 微信/src/net/cgt/weixin/app/CrashHandler.java
import java.io.File;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.Thread.UncaughtExceptionHandler;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Properties;
import java.util.TreeSet;
import net.cgt.weixin.utils.L;
import net.cgt.weixin.utils.LogUtil;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import android.os.Environment;
import android.os.Looper;
import android.text.format.Time;
import android.util.Log;
package net.cgt.weixin.app;
/**
* 测序崩溃处理程序
*
* @author lijian
* @date 2015-01-03 17:00:07
*/
public class CrashHandler implements UncaughtExceptionHandler {
/** Debug Log tag */
public static final String LOGTAG = LogUtil.makeLogTag(CrashHandler.class);
/**
* 是否开启日志输出,在Debug状态下开启, 在Release状态下关闭以提示程序性能
* */
public static final boolean DEBUG = false;
/** 系统默认的UncaughtException处理类 */
private Thread.UncaughtExceptionHandler mDefaultHandler;
/** CrashHandler实例 */
private static CrashHandler INSTANCE;
/** 程序的Context对象 */
private Context mContext;
/** 使用Properties来保存设备的信息和错误堆栈信息 */
private Properties mDeviceCrashInfo = new Properties();
private static final String VERSION_NAME = "versionName";
private static final String VERSION_CODE = "versionCode";
private static final String STACK_TRACE = "STACK_TRACE";
/** 错误报告文件的扩展名 */
private static final String CRASH_REPORTER_EXTENSION = ".dat";
/** SD卡错误报告文件路径 */
private static String SDCARD_PATH = "/sdcard/data/sxc/";
/** 保证只有一个CrashHandler实例 */
private CrashHandler() {
initAddress();
}
private void initAddress() {
SDCARD_PATH = Environment.getExternalStorageDirectory() + "/";// +"/data/sxc/";
| L.e(LOGTAG, "SDCARD_PATH>>" + SDCARD_PATH);
|
54cgt/weixin | 微信/src/net/cgt/weixin/view/load/LoadingView.java | // Path: 微信/src/net/cgt/weixin/control/ViewCallBack.java
// public interface onRefreshCallBack {
// /**
// * 刷新数据
// */
// void onRefreshCallBack();
// }
| import net.cgt.weixin.R;
import net.cgt.weixin.control.ViewCallBack.onRefreshCallBack;
import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView; | package net.cgt.weixin.view.load;
/**
* 加载中...
*
* @author lijian
* @date 2015-01-11 19:44:26
*/
public class LoadingView implements OnClickListener {
private Activity mActivity;
/** 回调 **/ | // Path: 微信/src/net/cgt/weixin/control/ViewCallBack.java
// public interface onRefreshCallBack {
// /**
// * 刷新数据
// */
// void onRefreshCallBack();
// }
// Path: 微信/src/net/cgt/weixin/view/load/LoadingView.java
import net.cgt.weixin.R;
import net.cgt.weixin.control.ViewCallBack.onRefreshCallBack;
import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
package net.cgt.weixin.view.load;
/**
* 加载中...
*
* @author lijian
* @date 2015-01-11 19:44:26
*/
public class LoadingView implements OnClickListener {
private Activity mActivity;
/** 回调 **/ | private onRefreshCallBack mCallBack; |
54cgt/weixin | 微信/src/net/cgt/weixin/view/adapter/EmojiAdapter.java | // Path: 微信/src/net/cgt/weixin/domain/ChatEmoji.java
// public class ChatEmoji {
//
// /**
// * 表情资源图片对应的ID
// */
// private int id;
// /**
// * 表情资源对应的文字描述
// */
// private String description;
// /**
// * 表情资源的文件名
// */
// private String faceName;
//
// /** 表情资源图片对应的ID */
// public int getId() {
// return id;
// }
//
// /** 表情资源图片对应的ID */
// public void setId(int id) {
// this.id = id;
// }
//
// /** 表情资源对应的文字描述 */
// public String getDescription() {
// return description;
// }
//
// /** 表情资源对应的文字描述 */
// public void setDescription(String character) {
// this.description = character;
// }
//
// /** 表情资源的文件名 */
// public String getFaceName() {
// return faceName;
// }
//
// /** 表情资源的文件名 */
// public void setFaceName(String faceName) {
// this.faceName = faceName;
// }
// }
| import java.util.List;
import net.cgt.weixin.R;
import net.cgt.weixin.domain.ChatEmoji;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
| package net.cgt.weixin.view.adapter;
/**
* 表情填充器
*
* @author lijian
* @date 2014-12-13 17:59:13
*/
public class EmojiAdapter extends BaseAdapter {
/**
* 上下文
*/
private Context mContext;
/**
* 表情集合
*/
| // Path: 微信/src/net/cgt/weixin/domain/ChatEmoji.java
// public class ChatEmoji {
//
// /**
// * 表情资源图片对应的ID
// */
// private int id;
// /**
// * 表情资源对应的文字描述
// */
// private String description;
// /**
// * 表情资源的文件名
// */
// private String faceName;
//
// /** 表情资源图片对应的ID */
// public int getId() {
// return id;
// }
//
// /** 表情资源图片对应的ID */
// public void setId(int id) {
// this.id = id;
// }
//
// /** 表情资源对应的文字描述 */
// public String getDescription() {
// return description;
// }
//
// /** 表情资源对应的文字描述 */
// public void setDescription(String character) {
// this.description = character;
// }
//
// /** 表情资源的文件名 */
// public String getFaceName() {
// return faceName;
// }
//
// /** 表情资源的文件名 */
// public void setFaceName(String faceName) {
// this.faceName = faceName;
// }
// }
// Path: 微信/src/net/cgt/weixin/view/adapter/EmojiAdapter.java
import java.util.List;
import net.cgt.weixin.R;
import net.cgt.weixin.domain.ChatEmoji;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
package net.cgt.weixin.view.adapter;
/**
* 表情填充器
*
* @author lijian
* @date 2014-12-13 17:59:13
*/
public class EmojiAdapter extends BaseAdapter {
/**
* 上下文
*/
private Context mContext;
/**
* 表情集合
*/
| private List<ChatEmoji> mList_chatEmoji;
|
54cgt/weixin | 微信/src/net/cgt/weixin/utils/AppToast.java | // Path: 微信/src/net/cgt/weixin/GlobalParams.java
// public class GlobalParams {
//
// /** 全局的activity **/
// public static Activity activity = null;
//
// /**
// * 代理的ip
// */
// public static String PROXY_IP = "";
// /**
// * 代理的端口
// */
// public static int PROXY_PORT = 0;
// /**
// * 屏幕宽度
// */
// public static int WIN_WIDTH = 0;
// /**
// * 登录的状态
// */
// public static boolean ISLOGIN = false;
// /**
// * 用户的余额
// */
// public static Float MONEY = null;
// /**
// * 用户名
// */
// public static String USERNAME = "";
// }
| import net.cgt.weixin.GlobalParams;
import net.cgt.weixin.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast; | package net.cgt.weixin.utils;
public class AppToast extends Toast {
private static AppToast instance = null;
private View layout;
private TextView text;
private AppToast() { | // Path: 微信/src/net/cgt/weixin/GlobalParams.java
// public class GlobalParams {
//
// /** 全局的activity **/
// public static Activity activity = null;
//
// /**
// * 代理的ip
// */
// public static String PROXY_IP = "";
// /**
// * 代理的端口
// */
// public static int PROXY_PORT = 0;
// /**
// * 屏幕宽度
// */
// public static int WIN_WIDTH = 0;
// /**
// * 登录的状态
// */
// public static boolean ISLOGIN = false;
// /**
// * 用户的余额
// */
// public static Float MONEY = null;
// /**
// * 用户名
// */
// public static String USERNAME = "";
// }
// Path: 微信/src/net/cgt/weixin/utils/AppToast.java
import net.cgt.weixin.GlobalParams;
import net.cgt.weixin.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
package net.cgt.weixin.utils;
public class AppToast extends Toast {
private static AppToast instance = null;
private View layout;
private TextView text;
private AppToast() { | super(GlobalParams.activity); |
54cgt/weixin | 微信/src/net/cgt/weixin/view/adapter/RosterAdapter.java | // Path: 微信/src/net/cgt/weixin/domain/User.java
// public class User implements Parcelable {
// private String userPhote;
// private String userAccount;
// private String personalizedSignature;
// private String date;
// private Drawable userImage;
//
// public String getUserPhote() {
// return userPhote;
// }
//
// public void setUserPhote(String userPhote) {
// this.userPhote = userPhote;
// }
//
// public String getUserAccount() {
// return userAccount;
// }
//
// public void setUserAccount(String userAccount) {
// this.userAccount = userAccount;
// }
//
// public String getPersonalizedSignature() {
// return personalizedSignature;
// }
//
// public void setPersonalizedSignature(String personalizedSignature) {
// this.personalizedSignature = personalizedSignature;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public Drawable getUserImage() {
// return userImage;
// }
//
// public void setUserImage(Drawable userImage) {
// this.userImage = userImage;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(userPhote);
// dest.writeString(userAccount);
// dest.writeString(date);
// dest.writeString(personalizedSignature);
// dest.writeValue(userImage);
// }
//
// public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>() {
// /**
// * Return a new point from the data in the specified parcel.
// */
// public User createFromParcel(Parcel in) {
// User u = new User();
// u.readFromParcel(in);
// return u;
// }
//
// /**
// * Return an array of rectangles of the specified size.
// */
// public User[] newArray(int size) {
// return new User[size];
// }
// };
//
// /**
// * Set the point's coordinates from the data stored in the specified parcel.
// * To write a point to a parcel, call writeToParcel().
// *
// * @param in The parcel to read the point's coordinates from
// */
// public void readFromParcel(Parcel in) {
// userPhote = in.readString();
// userAccount = in.readString();
// date = in.readString();
// personalizedSignature = in.readString();
// ClassLoader Drawable = ClassLoader.getSystemClassLoader();
// userImage = (android.graphics.drawable.Drawable) in.readValue(Drawable);
// }
// }
| import java.util.List;
import net.cgt.weixin.R;
import net.cgt.weixin.domain.User;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView; | package net.cgt.weixin.view.adapter;
/**
* 用户列表适配器
*
* @author lijian
*
*/
public class RosterAdapter extends BaseAdapter {
private Context mContext; | // Path: 微信/src/net/cgt/weixin/domain/User.java
// public class User implements Parcelable {
// private String userPhote;
// private String userAccount;
// private String personalizedSignature;
// private String date;
// private Drawable userImage;
//
// public String getUserPhote() {
// return userPhote;
// }
//
// public void setUserPhote(String userPhote) {
// this.userPhote = userPhote;
// }
//
// public String getUserAccount() {
// return userAccount;
// }
//
// public void setUserAccount(String userAccount) {
// this.userAccount = userAccount;
// }
//
// public String getPersonalizedSignature() {
// return personalizedSignature;
// }
//
// public void setPersonalizedSignature(String personalizedSignature) {
// this.personalizedSignature = personalizedSignature;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public Drawable getUserImage() {
// return userImage;
// }
//
// public void setUserImage(Drawable userImage) {
// this.userImage = userImage;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(userPhote);
// dest.writeString(userAccount);
// dest.writeString(date);
// dest.writeString(personalizedSignature);
// dest.writeValue(userImage);
// }
//
// public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>() {
// /**
// * Return a new point from the data in the specified parcel.
// */
// public User createFromParcel(Parcel in) {
// User u = new User();
// u.readFromParcel(in);
// return u;
// }
//
// /**
// * Return an array of rectangles of the specified size.
// */
// public User[] newArray(int size) {
// return new User[size];
// }
// };
//
// /**
// * Set the point's coordinates from the data stored in the specified parcel.
// * To write a point to a parcel, call writeToParcel().
// *
// * @param in The parcel to read the point's coordinates from
// */
// public void readFromParcel(Parcel in) {
// userPhote = in.readString();
// userAccount = in.readString();
// date = in.readString();
// personalizedSignature = in.readString();
// ClassLoader Drawable = ClassLoader.getSystemClassLoader();
// userImage = (android.graphics.drawable.Drawable) in.readValue(Drawable);
// }
// }
// Path: 微信/src/net/cgt/weixin/view/adapter/RosterAdapter.java
import java.util.List;
import net.cgt.weixin.R;
import net.cgt.weixin.domain.User;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
package net.cgt.weixin.view.adapter;
/**
* 用户列表适配器
*
* @author lijian
*
*/
public class RosterAdapter extends BaseAdapter {
private Context mContext; | private List<User> mList; |
54cgt/weixin | 微信/src/net/cgt/weixin/activity/GalleryImageActivity.java | // Path: 微信/src/net/cgt/weixin/domain/User.java
// public class User implements Parcelable {
// private String userPhote;
// private String userAccount;
// private String personalizedSignature;
// private String date;
// private Drawable userImage;
//
// public String getUserPhote() {
// return userPhote;
// }
//
// public void setUserPhote(String userPhote) {
// this.userPhote = userPhote;
// }
//
// public String getUserAccount() {
// return userAccount;
// }
//
// public void setUserAccount(String userAccount) {
// this.userAccount = userAccount;
// }
//
// public String getPersonalizedSignature() {
// return personalizedSignature;
// }
//
// public void setPersonalizedSignature(String personalizedSignature) {
// this.personalizedSignature = personalizedSignature;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public Drawable getUserImage() {
// return userImage;
// }
//
// public void setUserImage(Drawable userImage) {
// this.userImage = userImage;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(userPhote);
// dest.writeString(userAccount);
// dest.writeString(date);
// dest.writeString(personalizedSignature);
// dest.writeValue(userImage);
// }
//
// public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>() {
// /**
// * Return a new point from the data in the specified parcel.
// */
// public User createFromParcel(Parcel in) {
// User u = new User();
// u.readFromParcel(in);
// return u;
// }
//
// /**
// * Return an array of rectangles of the specified size.
// */
// public User[] newArray(int size) {
// return new User[size];
// }
// };
//
// /**
// * Set the point's coordinates from the data stored in the specified parcel.
// * To write a point to a parcel, call writeToParcel().
// *
// * @param in The parcel to read the point's coordinates from
// */
// public void readFromParcel(Parcel in) {
// userPhote = in.readString();
// userAccount = in.readString();
// date = in.readString();
// personalizedSignature = in.readString();
// ClassLoader Drawable = ClassLoader.getSystemClassLoader();
// userImage = (android.graphics.drawable.Drawable) in.readValue(Drawable);
// }
// }
| import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.cgt.weixin.R;
import net.cgt.weixin.domain.User;
import ru.truba.touchgallery.GalleryWidget.BasePagerAdapter.OnItemChangeListener;
import ru.truba.touchgallery.GalleryWidget.FilePagerAdapter;
import ru.truba.touchgallery.GalleryWidget.GalleryViewPager;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast; | package net.cgt.weixin.activity;
/**
* 图片查看器
*
* @author lijian
* @date 2014-11-30
*/
public class GalleryImageActivity extends Activity {
private GalleryViewPager mViewPager; | // Path: 微信/src/net/cgt/weixin/domain/User.java
// public class User implements Parcelable {
// private String userPhote;
// private String userAccount;
// private String personalizedSignature;
// private String date;
// private Drawable userImage;
//
// public String getUserPhote() {
// return userPhote;
// }
//
// public void setUserPhote(String userPhote) {
// this.userPhote = userPhote;
// }
//
// public String getUserAccount() {
// return userAccount;
// }
//
// public void setUserAccount(String userAccount) {
// this.userAccount = userAccount;
// }
//
// public String getPersonalizedSignature() {
// return personalizedSignature;
// }
//
// public void setPersonalizedSignature(String personalizedSignature) {
// this.personalizedSignature = personalizedSignature;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public Drawable getUserImage() {
// return userImage;
// }
//
// public void setUserImage(Drawable userImage) {
// this.userImage = userImage;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(userPhote);
// dest.writeString(userAccount);
// dest.writeString(date);
// dest.writeString(personalizedSignature);
// dest.writeValue(userImage);
// }
//
// public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>() {
// /**
// * Return a new point from the data in the specified parcel.
// */
// public User createFromParcel(Parcel in) {
// User u = new User();
// u.readFromParcel(in);
// return u;
// }
//
// /**
// * Return an array of rectangles of the specified size.
// */
// public User[] newArray(int size) {
// return new User[size];
// }
// };
//
// /**
// * Set the point's coordinates from the data stored in the specified parcel.
// * To write a point to a parcel, call writeToParcel().
// *
// * @param in The parcel to read the point's coordinates from
// */
// public void readFromParcel(Parcel in) {
// userPhote = in.readString();
// userAccount = in.readString();
// date = in.readString();
// personalizedSignature = in.readString();
// ClassLoader Drawable = ClassLoader.getSystemClassLoader();
// userImage = (android.graphics.drawable.Drawable) in.readValue(Drawable);
// }
// }
// Path: 微信/src/net/cgt/weixin/activity/GalleryImageActivity.java
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.cgt.weixin.R;
import net.cgt.weixin.domain.User;
import ru.truba.touchgallery.GalleryWidget.BasePagerAdapter.OnItemChangeListener;
import ru.truba.touchgallery.GalleryWidget.FilePagerAdapter;
import ru.truba.touchgallery.GalleryWidget.GalleryViewPager;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
package net.cgt.weixin.activity;
/**
* 图片查看器
*
* @author lijian
* @date 2014-11-30
*/
public class GalleryImageActivity extends Activity {
private GalleryViewPager mViewPager; | private User user; |
54cgt/weixin | 微信/src/net/cgt/weixin/utils/map/sort/HashList.java | // Path: 微信/src/net/cgt/weixin/domain/User.java
// public class User implements Parcelable {
// private String userPhote;
// private String userAccount;
// private String personalizedSignature;
// private String date;
// private Drawable userImage;
//
// public String getUserPhote() {
// return userPhote;
// }
//
// public void setUserPhote(String userPhote) {
// this.userPhote = userPhote;
// }
//
// public String getUserAccount() {
// return userAccount;
// }
//
// public void setUserAccount(String userAccount) {
// this.userAccount = userAccount;
// }
//
// public String getPersonalizedSignature() {
// return personalizedSignature;
// }
//
// public void setPersonalizedSignature(String personalizedSignature) {
// this.personalizedSignature = personalizedSignature;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public Drawable getUserImage() {
// return userImage;
// }
//
// public void setUserImage(Drawable userImage) {
// this.userImage = userImage;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(userPhote);
// dest.writeString(userAccount);
// dest.writeString(date);
// dest.writeString(personalizedSignature);
// dest.writeValue(userImage);
// }
//
// public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>() {
// /**
// * Return a new point from the data in the specified parcel.
// */
// public User createFromParcel(Parcel in) {
// User u = new User();
// u.readFromParcel(in);
// return u;
// }
//
// /**
// * Return an array of rectangles of the specified size.
// */
// public User[] newArray(int size) {
// return new User[size];
// }
// };
//
// /**
// * Set the point's coordinates from the data stored in the specified parcel.
// * To write a point to a parcel, call writeToParcel().
// *
// * @param in The parcel to read the point's coordinates from
// */
// public void readFromParcel(Parcel in) {
// userPhote = in.readString();
// userAccount = in.readString();
// date = in.readString();
// personalizedSignature = in.readString();
// ClassLoader Drawable = ClassLoader.getSystemClassLoader();
// userImage = (android.graphics.drawable.Drawable) in.readValue(Drawable);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/L.java
// public class L {
// private static final boolean flag = true;
//
// public static void i(String tag, String msg) {
// if (flag)
// Log.i(tag, msg);
// }
//
// public static void d(String tag, String msg) {
// if (flag)
// Log.d(tag, msg);
// }
//
// public static void e(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void e(String tag, String msg, Throwable tr) {
// if (flag)
// Log.e(tag, msg, tr);
// }
//
// public static void v(String tag, String msg) {
// if (flag)
// Log.v(tag, msg);
// }
//
// public static void m(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void w(String tag, String msg) {
// if (flag)
// Log.w(tag, msg);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/LogUtil.java
// public class LogUtil {
//
// @SuppressWarnings("unchecked")
// public static String makeLogTag(Class cls) {
// return "Weixin_" + cls.getSimpleName();
// }
//
// }
| import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import net.cgt.weixin.domain.User;
import net.cgt.weixin.utils.L;
import net.cgt.weixin.utils.LogUtil; | /**
* 将"键集合"转为数组(Group)
*
* @return
*/
public Object[] toArray() {
return mList_key.toArray();
}
/**
* 将"键集合"转为数组(Group)
*
* @param array 数组
* @return
*/
public Object[] toArray(Object[] array) {
return mList_key.toArray(array);
}
/**
* 给集合添加值
*
* @param object
* @return
*/
public boolean add(Object object) {
V v = (V) object;
K key = getKey(v);
if (!mMap.containsKey(key)) {
List<V> list = new ArrayList<V>(); | // Path: 微信/src/net/cgt/weixin/domain/User.java
// public class User implements Parcelable {
// private String userPhote;
// private String userAccount;
// private String personalizedSignature;
// private String date;
// private Drawable userImage;
//
// public String getUserPhote() {
// return userPhote;
// }
//
// public void setUserPhote(String userPhote) {
// this.userPhote = userPhote;
// }
//
// public String getUserAccount() {
// return userAccount;
// }
//
// public void setUserAccount(String userAccount) {
// this.userAccount = userAccount;
// }
//
// public String getPersonalizedSignature() {
// return personalizedSignature;
// }
//
// public void setPersonalizedSignature(String personalizedSignature) {
// this.personalizedSignature = personalizedSignature;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public Drawable getUserImage() {
// return userImage;
// }
//
// public void setUserImage(Drawable userImage) {
// this.userImage = userImage;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(userPhote);
// dest.writeString(userAccount);
// dest.writeString(date);
// dest.writeString(personalizedSignature);
// dest.writeValue(userImage);
// }
//
// public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>() {
// /**
// * Return a new point from the data in the specified parcel.
// */
// public User createFromParcel(Parcel in) {
// User u = new User();
// u.readFromParcel(in);
// return u;
// }
//
// /**
// * Return an array of rectangles of the specified size.
// */
// public User[] newArray(int size) {
// return new User[size];
// }
// };
//
// /**
// * Set the point's coordinates from the data stored in the specified parcel.
// * To write a point to a parcel, call writeToParcel().
// *
// * @param in The parcel to read the point's coordinates from
// */
// public void readFromParcel(Parcel in) {
// userPhote = in.readString();
// userAccount = in.readString();
// date = in.readString();
// personalizedSignature = in.readString();
// ClassLoader Drawable = ClassLoader.getSystemClassLoader();
// userImage = (android.graphics.drawable.Drawable) in.readValue(Drawable);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/L.java
// public class L {
// private static final boolean flag = true;
//
// public static void i(String tag, String msg) {
// if (flag)
// Log.i(tag, msg);
// }
//
// public static void d(String tag, String msg) {
// if (flag)
// Log.d(tag, msg);
// }
//
// public static void e(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void e(String tag, String msg, Throwable tr) {
// if (flag)
// Log.e(tag, msg, tr);
// }
//
// public static void v(String tag, String msg) {
// if (flag)
// Log.v(tag, msg);
// }
//
// public static void m(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void w(String tag, String msg) {
// if (flag)
// Log.w(tag, msg);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/LogUtil.java
// public class LogUtil {
//
// @SuppressWarnings("unchecked")
// public static String makeLogTag(Class cls) {
// return "Weixin_" + cls.getSimpleName();
// }
//
// }
// Path: 微信/src/net/cgt/weixin/utils/map/sort/HashList.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import net.cgt.weixin.domain.User;
import net.cgt.weixin.utils.L;
import net.cgt.weixin.utils.LogUtil;
/**
* 将"键集合"转为数组(Group)
*
* @return
*/
public Object[] toArray() {
return mList_key.toArray();
}
/**
* 将"键集合"转为数组(Group)
*
* @param array 数组
* @return
*/
public Object[] toArray(Object[] array) {
return mList_key.toArray(array);
}
/**
* 给集合添加值
*
* @param object
* @return
*/
public boolean add(Object object) {
V v = (V) object;
K key = getKey(v);
if (!mMap.containsKey(key)) {
List<V> list = new ArrayList<V>(); | L.i(LOGTAG, "HashList--->key=" + key + "--------------------Value=" + ((User)v).getUserAccount()); |
54cgt/weixin | 微信/src/net/cgt/weixin/utils/map/sort/HashList.java | // Path: 微信/src/net/cgt/weixin/domain/User.java
// public class User implements Parcelable {
// private String userPhote;
// private String userAccount;
// private String personalizedSignature;
// private String date;
// private Drawable userImage;
//
// public String getUserPhote() {
// return userPhote;
// }
//
// public void setUserPhote(String userPhote) {
// this.userPhote = userPhote;
// }
//
// public String getUserAccount() {
// return userAccount;
// }
//
// public void setUserAccount(String userAccount) {
// this.userAccount = userAccount;
// }
//
// public String getPersonalizedSignature() {
// return personalizedSignature;
// }
//
// public void setPersonalizedSignature(String personalizedSignature) {
// this.personalizedSignature = personalizedSignature;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public Drawable getUserImage() {
// return userImage;
// }
//
// public void setUserImage(Drawable userImage) {
// this.userImage = userImage;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(userPhote);
// dest.writeString(userAccount);
// dest.writeString(date);
// dest.writeString(personalizedSignature);
// dest.writeValue(userImage);
// }
//
// public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>() {
// /**
// * Return a new point from the data in the specified parcel.
// */
// public User createFromParcel(Parcel in) {
// User u = new User();
// u.readFromParcel(in);
// return u;
// }
//
// /**
// * Return an array of rectangles of the specified size.
// */
// public User[] newArray(int size) {
// return new User[size];
// }
// };
//
// /**
// * Set the point's coordinates from the data stored in the specified parcel.
// * To write a point to a parcel, call writeToParcel().
// *
// * @param in The parcel to read the point's coordinates from
// */
// public void readFromParcel(Parcel in) {
// userPhote = in.readString();
// userAccount = in.readString();
// date = in.readString();
// personalizedSignature = in.readString();
// ClassLoader Drawable = ClassLoader.getSystemClassLoader();
// userImage = (android.graphics.drawable.Drawable) in.readValue(Drawable);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/L.java
// public class L {
// private static final boolean flag = true;
//
// public static void i(String tag, String msg) {
// if (flag)
// Log.i(tag, msg);
// }
//
// public static void d(String tag, String msg) {
// if (flag)
// Log.d(tag, msg);
// }
//
// public static void e(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void e(String tag, String msg, Throwable tr) {
// if (flag)
// Log.e(tag, msg, tr);
// }
//
// public static void v(String tag, String msg) {
// if (flag)
// Log.v(tag, msg);
// }
//
// public static void m(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void w(String tag, String msg) {
// if (flag)
// Log.w(tag, msg);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/LogUtil.java
// public class LogUtil {
//
// @SuppressWarnings("unchecked")
// public static String makeLogTag(Class cls) {
// return "Weixin_" + cls.getSimpleName();
// }
//
// }
| import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import net.cgt.weixin.domain.User;
import net.cgt.weixin.utils.L;
import net.cgt.weixin.utils.LogUtil; | /**
* 将"键集合"转为数组(Group)
*
* @return
*/
public Object[] toArray() {
return mList_key.toArray();
}
/**
* 将"键集合"转为数组(Group)
*
* @param array 数组
* @return
*/
public Object[] toArray(Object[] array) {
return mList_key.toArray(array);
}
/**
* 给集合添加值
*
* @param object
* @return
*/
public boolean add(Object object) {
V v = (V) object;
K key = getKey(v);
if (!mMap.containsKey(key)) {
List<V> list = new ArrayList<V>(); | // Path: 微信/src/net/cgt/weixin/domain/User.java
// public class User implements Parcelable {
// private String userPhote;
// private String userAccount;
// private String personalizedSignature;
// private String date;
// private Drawable userImage;
//
// public String getUserPhote() {
// return userPhote;
// }
//
// public void setUserPhote(String userPhote) {
// this.userPhote = userPhote;
// }
//
// public String getUserAccount() {
// return userAccount;
// }
//
// public void setUserAccount(String userAccount) {
// this.userAccount = userAccount;
// }
//
// public String getPersonalizedSignature() {
// return personalizedSignature;
// }
//
// public void setPersonalizedSignature(String personalizedSignature) {
// this.personalizedSignature = personalizedSignature;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public Drawable getUserImage() {
// return userImage;
// }
//
// public void setUserImage(Drawable userImage) {
// this.userImage = userImage;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(userPhote);
// dest.writeString(userAccount);
// dest.writeString(date);
// dest.writeString(personalizedSignature);
// dest.writeValue(userImage);
// }
//
// public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>() {
// /**
// * Return a new point from the data in the specified parcel.
// */
// public User createFromParcel(Parcel in) {
// User u = new User();
// u.readFromParcel(in);
// return u;
// }
//
// /**
// * Return an array of rectangles of the specified size.
// */
// public User[] newArray(int size) {
// return new User[size];
// }
// };
//
// /**
// * Set the point's coordinates from the data stored in the specified parcel.
// * To write a point to a parcel, call writeToParcel().
// *
// * @param in The parcel to read the point's coordinates from
// */
// public void readFromParcel(Parcel in) {
// userPhote = in.readString();
// userAccount = in.readString();
// date = in.readString();
// personalizedSignature = in.readString();
// ClassLoader Drawable = ClassLoader.getSystemClassLoader();
// userImage = (android.graphics.drawable.Drawable) in.readValue(Drawable);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/L.java
// public class L {
// private static final boolean flag = true;
//
// public static void i(String tag, String msg) {
// if (flag)
// Log.i(tag, msg);
// }
//
// public static void d(String tag, String msg) {
// if (flag)
// Log.d(tag, msg);
// }
//
// public static void e(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void e(String tag, String msg, Throwable tr) {
// if (flag)
// Log.e(tag, msg, tr);
// }
//
// public static void v(String tag, String msg) {
// if (flag)
// Log.v(tag, msg);
// }
//
// public static void m(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void w(String tag, String msg) {
// if (flag)
// Log.w(tag, msg);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/LogUtil.java
// public class LogUtil {
//
// @SuppressWarnings("unchecked")
// public static String makeLogTag(Class cls) {
// return "Weixin_" + cls.getSimpleName();
// }
//
// }
// Path: 微信/src/net/cgt/weixin/utils/map/sort/HashList.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import net.cgt.weixin.domain.User;
import net.cgt.weixin.utils.L;
import net.cgt.weixin.utils.LogUtil;
/**
* 将"键集合"转为数组(Group)
*
* @return
*/
public Object[] toArray() {
return mList_key.toArray();
}
/**
* 将"键集合"转为数组(Group)
*
* @param array 数组
* @return
*/
public Object[] toArray(Object[] array) {
return mList_key.toArray(array);
}
/**
* 给集合添加值
*
* @param object
* @return
*/
public boolean add(Object object) {
V v = (V) object;
K key = getKey(v);
if (!mMap.containsKey(key)) {
List<V> list = new ArrayList<V>(); | L.i(LOGTAG, "HashList--->key=" + key + "--------------------Value=" + ((User)v).getUserAccount()); |
54cgt/weixin | 微信/src/net/cgt/weixin/utils/SpUtil.java | // Path: 微信/src/net/cgt/weixin/Constants.java
// public interface Constants {
//
// /** SharedPreferences 文件名 **/
// String SHARED_PREFERENCE_NAME = "client_preferences";
//
// /********************************** 用户登陆管理 ***************************************************************************************************/
//
// /** 用户最后登陆时间 **/
// String LAST_TIME = "LAST_TIME";
//
// /** 一个月内自动登陆 : 60 * 60 * 24 * 30 = 2592000 **/
// long AUTO_LOGIN = 2592000;
//
// /** 记录上次退出时页面 **/
// String PAGENUMBER = "PAGENUMBER";
//
// /********************************** 偏好设置 ***************************************************************************************************/
//
// /** 回调Activity的包名 **/
// String CALLBACK_ACTIVITY_PACKAGE_NAME = "CALLBACK_ACTIVITY_PACKAGE_NAME";
//
// /** 回调Activity的全类名 **/
// String CALLBACK_ACTIVITY_CLASS_NAME = "CALLBACK_ACTIVITY_CLASS_NAME";
//
// /** XMPP密钥 **/
// String API_KEY = "API_KEY";
//
// /** 版本号 **/
// String VERSION = "VERSION";
//
// /** XMPP的IP **/
// String XMPP_HOST = "XMPP_HOST";
//
// /** XMPP的端口 **/
// String XMPP_PORT = "XMPP_PORT";
//
// /** XMPP的用户名 **/
// String XMPP_USERNAME = "XMPP_USERNAME";
//
// /** XMPP的密码 **/
// String XMPP_PASSWORD = "XMPP_PASSWORD";
//
// // String USER_KEY = "USER_KEY";
//
// /** 设备ID(手机*#06#) **/
// String DEVICE_ID = "DEVICE_ID";
//
// /** 模拟器ID **/
// String EMULATOR_DEVICE_ID = "EMULATOR_DEVICE_ID";
//
// /** 通知的logo图片 **/
// String NOTIFICATION_ICON = "NOTIFICATION_ICON";
//
// /** 是否显示推送的通知 **/
// String SETTINGS_NOTIFICATION_ENABLED = "SETTINGS_NOTIFICATION_ENABLED";
//
// /** 当接到推送通知-->是否播放通知声音 **/
// String SETTINGS_SOUND_ENABLED = "SETTINGS_SOUND_ENABLED";
//
// /** 当接到推送通知-->是否震动手机 **/
// String SETTINGS_VIBRATE_ENABLED = "SETTINGS_VIBRATE_ENABLED";
//
// /** 当接到推送通知-->是否显示吐司 **/
// String SETTINGS_TOAST_ENABLED = "SETTINGS_TOAST_ENABLED";
//
// /********************************** 通知 ***************************************************************************************************/
//
// /** 通知的ID **/
// String NOTIFICATION_ID = "NOTIFICATION_ID";
//
// /** 通知的密钥 **/
// String NOTIFICATION_API_KEY = "NOTIFICATION_API_KEY";
//
// /** 通知的标题 **/
// String NOTIFICATION_TITLE = "NOTIFICATION_TITLE";
//
// /** 通知的正文 **/
// String NOTIFICATION_MESSAGE = "NOTIFICATION_MESSAGE";
//
// /** 通知的Url **/
// String NOTIFICATION_URI = "NOTIFICATION_URI";
//
// /********************************** intent动作 ***************************************************************************************************/
//
// /** 显示通知 **/
// String ACTION_SHOW_NOTIFICATION = "org.androidpn.client.SHOW_NOTIFICATION";
//
// /** 通知被点击 **/
// String ACTION_NOTIFICATION_CLICKED = "org.androidpn.client.NOTIFICATION_CLICKED";
//
// /** 清除通知 **/
// String ACTION_NOTIFICATION_CLEARED = "org.androidpn.client.NOTIFICATION_CLEARED";
//
// }
| import java.util.Map;
import java.util.Set;
import net.cgt.weixin.Constants;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences; | package net.cgt.weixin.utils;
/**
* SharedPreferences
*
* @author lijian
*
*/
public class SpUtil {
private SharedPreferences sp;
public SpUtil(Context context) { | // Path: 微信/src/net/cgt/weixin/Constants.java
// public interface Constants {
//
// /** SharedPreferences 文件名 **/
// String SHARED_PREFERENCE_NAME = "client_preferences";
//
// /********************************** 用户登陆管理 ***************************************************************************************************/
//
// /** 用户最后登陆时间 **/
// String LAST_TIME = "LAST_TIME";
//
// /** 一个月内自动登陆 : 60 * 60 * 24 * 30 = 2592000 **/
// long AUTO_LOGIN = 2592000;
//
// /** 记录上次退出时页面 **/
// String PAGENUMBER = "PAGENUMBER";
//
// /********************************** 偏好设置 ***************************************************************************************************/
//
// /** 回调Activity的包名 **/
// String CALLBACK_ACTIVITY_PACKAGE_NAME = "CALLBACK_ACTIVITY_PACKAGE_NAME";
//
// /** 回调Activity的全类名 **/
// String CALLBACK_ACTIVITY_CLASS_NAME = "CALLBACK_ACTIVITY_CLASS_NAME";
//
// /** XMPP密钥 **/
// String API_KEY = "API_KEY";
//
// /** 版本号 **/
// String VERSION = "VERSION";
//
// /** XMPP的IP **/
// String XMPP_HOST = "XMPP_HOST";
//
// /** XMPP的端口 **/
// String XMPP_PORT = "XMPP_PORT";
//
// /** XMPP的用户名 **/
// String XMPP_USERNAME = "XMPP_USERNAME";
//
// /** XMPP的密码 **/
// String XMPP_PASSWORD = "XMPP_PASSWORD";
//
// // String USER_KEY = "USER_KEY";
//
// /** 设备ID(手机*#06#) **/
// String DEVICE_ID = "DEVICE_ID";
//
// /** 模拟器ID **/
// String EMULATOR_DEVICE_ID = "EMULATOR_DEVICE_ID";
//
// /** 通知的logo图片 **/
// String NOTIFICATION_ICON = "NOTIFICATION_ICON";
//
// /** 是否显示推送的通知 **/
// String SETTINGS_NOTIFICATION_ENABLED = "SETTINGS_NOTIFICATION_ENABLED";
//
// /** 当接到推送通知-->是否播放通知声音 **/
// String SETTINGS_SOUND_ENABLED = "SETTINGS_SOUND_ENABLED";
//
// /** 当接到推送通知-->是否震动手机 **/
// String SETTINGS_VIBRATE_ENABLED = "SETTINGS_VIBRATE_ENABLED";
//
// /** 当接到推送通知-->是否显示吐司 **/
// String SETTINGS_TOAST_ENABLED = "SETTINGS_TOAST_ENABLED";
//
// /********************************** 通知 ***************************************************************************************************/
//
// /** 通知的ID **/
// String NOTIFICATION_ID = "NOTIFICATION_ID";
//
// /** 通知的密钥 **/
// String NOTIFICATION_API_KEY = "NOTIFICATION_API_KEY";
//
// /** 通知的标题 **/
// String NOTIFICATION_TITLE = "NOTIFICATION_TITLE";
//
// /** 通知的正文 **/
// String NOTIFICATION_MESSAGE = "NOTIFICATION_MESSAGE";
//
// /** 通知的Url **/
// String NOTIFICATION_URI = "NOTIFICATION_URI";
//
// /********************************** intent动作 ***************************************************************************************************/
//
// /** 显示通知 **/
// String ACTION_SHOW_NOTIFICATION = "org.androidpn.client.SHOW_NOTIFICATION";
//
// /** 通知被点击 **/
// String ACTION_NOTIFICATION_CLICKED = "org.androidpn.client.NOTIFICATION_CLICKED";
//
// /** 清除通知 **/
// String ACTION_NOTIFICATION_CLEARED = "org.androidpn.client.NOTIFICATION_CLEARED";
//
// }
// Path: 微信/src/net/cgt/weixin/utils/SpUtil.java
import java.util.Map;
import java.util.Set;
import net.cgt.weixin.Constants;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
package net.cgt.weixin.utils;
/**
* SharedPreferences
*
* @author lijian
*
*/
public class SpUtil {
private SharedPreferences sp;
public SpUtil(Context context) { | sp = context.getSharedPreferences(Constants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE); |
54cgt/weixin | 微信/src/net/cgt/weixin/domain/pinyin/LanguageComparator_CN.java | // Path: 微信/src/net/cgt/weixin/domain/User.java
// public class User implements Parcelable {
// private String userPhote;
// private String userAccount;
// private String personalizedSignature;
// private String date;
// private Drawable userImage;
//
// public String getUserPhote() {
// return userPhote;
// }
//
// public void setUserPhote(String userPhote) {
// this.userPhote = userPhote;
// }
//
// public String getUserAccount() {
// return userAccount;
// }
//
// public void setUserAccount(String userAccount) {
// this.userAccount = userAccount;
// }
//
// public String getPersonalizedSignature() {
// return personalizedSignature;
// }
//
// public void setPersonalizedSignature(String personalizedSignature) {
// this.personalizedSignature = personalizedSignature;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public Drawable getUserImage() {
// return userImage;
// }
//
// public void setUserImage(Drawable userImage) {
// this.userImage = userImage;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(userPhote);
// dest.writeString(userAccount);
// dest.writeString(date);
// dest.writeString(personalizedSignature);
// dest.writeValue(userImage);
// }
//
// public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>() {
// /**
// * Return a new point from the data in the specified parcel.
// */
// public User createFromParcel(Parcel in) {
// User u = new User();
// u.readFromParcel(in);
// return u;
// }
//
// /**
// * Return an array of rectangles of the specified size.
// */
// public User[] newArray(int size) {
// return new User[size];
// }
// };
//
// /**
// * Set the point's coordinates from the data stored in the specified parcel.
// * To write a point to a parcel, call writeToParcel().
// *
// * @param in The parcel to read the point's coordinates from
// */
// public void readFromParcel(Parcel in) {
// userPhote = in.readString();
// userAccount = in.readString();
// date = in.readString();
// personalizedSignature = in.readString();
// ClassLoader Drawable = ClassLoader.getSystemClassLoader();
// userImage = (android.graphics.drawable.Drawable) in.readValue(Drawable);
// }
// }
| import java.util.Comparator;
import net.cgt.weixin.domain.User;
import net.sourceforge.pinyin4j.PinyinHelper; | package net.cgt.weixin.domain.pinyin;
/**
* 汉字排序
*
* @author lijian
* @date 2014-11-29
* @param <T>
*/
public class LanguageComparator_CN<T> implements Comparator<T> {
@Override
public int compare(T lhs, T rhs) {
| // Path: 微信/src/net/cgt/weixin/domain/User.java
// public class User implements Parcelable {
// private String userPhote;
// private String userAccount;
// private String personalizedSignature;
// private String date;
// private Drawable userImage;
//
// public String getUserPhote() {
// return userPhote;
// }
//
// public void setUserPhote(String userPhote) {
// this.userPhote = userPhote;
// }
//
// public String getUserAccount() {
// return userAccount;
// }
//
// public void setUserAccount(String userAccount) {
// this.userAccount = userAccount;
// }
//
// public String getPersonalizedSignature() {
// return personalizedSignature;
// }
//
// public void setPersonalizedSignature(String personalizedSignature) {
// this.personalizedSignature = personalizedSignature;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public Drawable getUserImage() {
// return userImage;
// }
//
// public void setUserImage(Drawable userImage) {
// this.userImage = userImage;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(userPhote);
// dest.writeString(userAccount);
// dest.writeString(date);
// dest.writeString(personalizedSignature);
// dest.writeValue(userImage);
// }
//
// public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>() {
// /**
// * Return a new point from the data in the specified parcel.
// */
// public User createFromParcel(Parcel in) {
// User u = new User();
// u.readFromParcel(in);
// return u;
// }
//
// /**
// * Return an array of rectangles of the specified size.
// */
// public User[] newArray(int size) {
// return new User[size];
// }
// };
//
// /**
// * Set the point's coordinates from the data stored in the specified parcel.
// * To write a point to a parcel, call writeToParcel().
// *
// * @param in The parcel to read the point's coordinates from
// */
// public void readFromParcel(Parcel in) {
// userPhote = in.readString();
// userAccount = in.readString();
// date = in.readString();
// personalizedSignature = in.readString();
// ClassLoader Drawable = ClassLoader.getSystemClassLoader();
// userImage = (android.graphics.drawable.Drawable) in.readValue(Drawable);
// }
// }
// Path: 微信/src/net/cgt/weixin/domain/pinyin/LanguageComparator_CN.java
import java.util.Comparator;
import net.cgt.weixin.domain.User;
import net.sourceforge.pinyin4j.PinyinHelper;
package net.cgt.weixin.domain.pinyin;
/**
* 汉字排序
*
* @author lijian
* @date 2014-11-29
* @param <T>
*/
public class LanguageComparator_CN<T> implements Comparator<T> {
@Override
public int compare(T lhs, T rhs) {
| if (lhs instanceof User && rhs instanceof User) { |
54cgt/weixin | 微信/src/net/cgt/weixin/fragment/MeFragment.java | // Path: 微信/src/net/cgt/weixin/utils/AppToast.java
// public class AppToast extends Toast {
//
// private static AppToast instance = null;
// private View layout;
// private TextView text;
//
// private AppToast() {
// super(GlobalParams.activity);
// init();
// }
//
// public static AppToast getToast() {
// if (instance == null) {
// instance = new AppToast();
// }
// return instance;
// }
//
// private void init() {
// LayoutInflater inflate = (LayoutInflater) GlobalParams.activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// layout = inflate.inflate(R.layout.cgt_transient_notification, null);
// text = (TextView) layout.findViewById(R.id.message);
// this.setView(layout);
// }
//
// public void show(String msg) {
// text.setText(msg);
// this.setDuration(Toast.LENGTH_SHORT);
// this.show();
// }
//
// public void show(int msg) {
// text.setText(msg);
// this.setDuration(Toast.LENGTH_SHORT);
// this.show();
// }
//
// }
//
// Path: 微信/src/net/cgt/weixin/utils/L.java
// public class L {
// private static final boolean flag = true;
//
// public static void i(String tag, String msg) {
// if (flag)
// Log.i(tag, msg);
// }
//
// public static void d(String tag, String msg) {
// if (flag)
// Log.d(tag, msg);
// }
//
// public static void e(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void e(String tag, String msg, Throwable tr) {
// if (flag)
// Log.e(tag, msg, tr);
// }
//
// public static void v(String tag, String msg) {
// if (flag)
// Log.v(tag, msg);
// }
//
// public static void m(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void w(String tag, String msg) {
// if (flag)
// Log.w(tag, msg);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/LogUtil.java
// public class LogUtil {
//
// @SuppressWarnings("unchecked")
// public static String makeLogTag(Class cls) {
// return "Weixin_" + cls.getSimpleName();
// }
//
// }
| import net.cgt.weixin.R;
import net.cgt.weixin.utils.AppToast;
import net.cgt.weixin.utils.L;
import net.cgt.weixin.utils.LogUtil;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
| private void initView(View v) {
LinearLayout mLl_userInfo = (LinearLayout) v.findViewById(R.id.cgt_ll_me_userInfo);
mIv_userPic = (ImageView) v.findViewById(R.id.cgt_iv_me_userPic);
mTv_userName = (TextView) v.findViewById(R.id.cgt_tv_me_userName);
mTv_weixinNum = (TextView) v.findViewById(R.id.cgt_tv_me_weixinNum);
ImageButton mIb_qrCOde = (ImageButton) v.findViewById(R.id.cgt_ib_me_qrCode);
LinearLayout mLl_photo = (LinearLayout) v.findViewById(R.id.cgt_ll_me_photo);
LinearLayout mLl_collect = (LinearLayout) v.findViewById(R.id.cgt_ll_me_collect);
LinearLayout mLl_wallet = (LinearLayout) v.findViewById(R.id.cgt_ll_me_wallet);
LinearLayout mLl_set = (LinearLayout) v.findViewById(R.id.cgt_ll_me_set);
mLl_userInfo.setOnClickListener(this);
mIb_qrCOde.setOnClickListener(this);
mLl_photo.setOnClickListener(this);
mLl_collect.setOnClickListener(this);
mLl_wallet.setOnClickListener(this);
mLl_set.setOnClickListener(this);
}
private void initData() {
mIv_userPic.setImageResource(R.drawable.user_picture);
mTv_userName.setText("深情小建");
mTv_weixinNum.setText("微信号:lijian374452668");
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.cgt_ll_me_userInfo:
| // Path: 微信/src/net/cgt/weixin/utils/AppToast.java
// public class AppToast extends Toast {
//
// private static AppToast instance = null;
// private View layout;
// private TextView text;
//
// private AppToast() {
// super(GlobalParams.activity);
// init();
// }
//
// public static AppToast getToast() {
// if (instance == null) {
// instance = new AppToast();
// }
// return instance;
// }
//
// private void init() {
// LayoutInflater inflate = (LayoutInflater) GlobalParams.activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// layout = inflate.inflate(R.layout.cgt_transient_notification, null);
// text = (TextView) layout.findViewById(R.id.message);
// this.setView(layout);
// }
//
// public void show(String msg) {
// text.setText(msg);
// this.setDuration(Toast.LENGTH_SHORT);
// this.show();
// }
//
// public void show(int msg) {
// text.setText(msg);
// this.setDuration(Toast.LENGTH_SHORT);
// this.show();
// }
//
// }
//
// Path: 微信/src/net/cgt/weixin/utils/L.java
// public class L {
// private static final boolean flag = true;
//
// public static void i(String tag, String msg) {
// if (flag)
// Log.i(tag, msg);
// }
//
// public static void d(String tag, String msg) {
// if (flag)
// Log.d(tag, msg);
// }
//
// public static void e(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void e(String tag, String msg, Throwable tr) {
// if (flag)
// Log.e(tag, msg, tr);
// }
//
// public static void v(String tag, String msg) {
// if (flag)
// Log.v(tag, msg);
// }
//
// public static void m(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void w(String tag, String msg) {
// if (flag)
// Log.w(tag, msg);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/LogUtil.java
// public class LogUtil {
//
// @SuppressWarnings("unchecked")
// public static String makeLogTag(Class cls) {
// return "Weixin_" + cls.getSimpleName();
// }
//
// }
// Path: 微信/src/net/cgt/weixin/fragment/MeFragment.java
import net.cgt.weixin.R;
import net.cgt.weixin.utils.AppToast;
import net.cgt.weixin.utils.L;
import net.cgt.weixin.utils.LogUtil;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
private void initView(View v) {
LinearLayout mLl_userInfo = (LinearLayout) v.findViewById(R.id.cgt_ll_me_userInfo);
mIv_userPic = (ImageView) v.findViewById(R.id.cgt_iv_me_userPic);
mTv_userName = (TextView) v.findViewById(R.id.cgt_tv_me_userName);
mTv_weixinNum = (TextView) v.findViewById(R.id.cgt_tv_me_weixinNum);
ImageButton mIb_qrCOde = (ImageButton) v.findViewById(R.id.cgt_ib_me_qrCode);
LinearLayout mLl_photo = (LinearLayout) v.findViewById(R.id.cgt_ll_me_photo);
LinearLayout mLl_collect = (LinearLayout) v.findViewById(R.id.cgt_ll_me_collect);
LinearLayout mLl_wallet = (LinearLayout) v.findViewById(R.id.cgt_ll_me_wallet);
LinearLayout mLl_set = (LinearLayout) v.findViewById(R.id.cgt_ll_me_set);
mLl_userInfo.setOnClickListener(this);
mIb_qrCOde.setOnClickListener(this);
mLl_photo.setOnClickListener(this);
mLl_collect.setOnClickListener(this);
mLl_wallet.setOnClickListener(this);
mLl_set.setOnClickListener(this);
}
private void initData() {
mIv_userPic.setImageResource(R.drawable.user_picture);
mTv_userName.setText("深情小建");
mTv_weixinNum.setText("微信号:lijian374452668");
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.cgt_ll_me_userInfo:
| AppToast.getToast().show("用户信息");
|
54cgt/weixin | 微信/src/net/cgt/weixin/fragment/MeFragment.java | // Path: 微信/src/net/cgt/weixin/utils/AppToast.java
// public class AppToast extends Toast {
//
// private static AppToast instance = null;
// private View layout;
// private TextView text;
//
// private AppToast() {
// super(GlobalParams.activity);
// init();
// }
//
// public static AppToast getToast() {
// if (instance == null) {
// instance = new AppToast();
// }
// return instance;
// }
//
// private void init() {
// LayoutInflater inflate = (LayoutInflater) GlobalParams.activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// layout = inflate.inflate(R.layout.cgt_transient_notification, null);
// text = (TextView) layout.findViewById(R.id.message);
// this.setView(layout);
// }
//
// public void show(String msg) {
// text.setText(msg);
// this.setDuration(Toast.LENGTH_SHORT);
// this.show();
// }
//
// public void show(int msg) {
// text.setText(msg);
// this.setDuration(Toast.LENGTH_SHORT);
// this.show();
// }
//
// }
//
// Path: 微信/src/net/cgt/weixin/utils/L.java
// public class L {
// private static final boolean flag = true;
//
// public static void i(String tag, String msg) {
// if (flag)
// Log.i(tag, msg);
// }
//
// public static void d(String tag, String msg) {
// if (flag)
// Log.d(tag, msg);
// }
//
// public static void e(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void e(String tag, String msg, Throwable tr) {
// if (flag)
// Log.e(tag, msg, tr);
// }
//
// public static void v(String tag, String msg) {
// if (flag)
// Log.v(tag, msg);
// }
//
// public static void m(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void w(String tag, String msg) {
// if (flag)
// Log.w(tag, msg);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/LogUtil.java
// public class LogUtil {
//
// @SuppressWarnings("unchecked")
// public static String makeLogTag(Class cls) {
// return "Weixin_" + cls.getSimpleName();
// }
//
// }
| import net.cgt.weixin.R;
import net.cgt.weixin.utils.AppToast;
import net.cgt.weixin.utils.L;
import net.cgt.weixin.utils.LogUtil;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
| LinearLayout mLl_userInfo = (LinearLayout) v.findViewById(R.id.cgt_ll_me_userInfo);
mIv_userPic = (ImageView) v.findViewById(R.id.cgt_iv_me_userPic);
mTv_userName = (TextView) v.findViewById(R.id.cgt_tv_me_userName);
mTv_weixinNum = (TextView) v.findViewById(R.id.cgt_tv_me_weixinNum);
ImageButton mIb_qrCOde = (ImageButton) v.findViewById(R.id.cgt_ib_me_qrCode);
LinearLayout mLl_photo = (LinearLayout) v.findViewById(R.id.cgt_ll_me_photo);
LinearLayout mLl_collect = (LinearLayout) v.findViewById(R.id.cgt_ll_me_collect);
LinearLayout mLl_wallet = (LinearLayout) v.findViewById(R.id.cgt_ll_me_wallet);
LinearLayout mLl_set = (LinearLayout) v.findViewById(R.id.cgt_ll_me_set);
mLl_userInfo.setOnClickListener(this);
mIb_qrCOde.setOnClickListener(this);
mLl_photo.setOnClickListener(this);
mLl_collect.setOnClickListener(this);
mLl_wallet.setOnClickListener(this);
mLl_set.setOnClickListener(this);
}
private void initData() {
mIv_userPic.setImageResource(R.drawable.user_picture);
mTv_userName.setText("深情小建");
mTv_weixinNum.setText("微信号:lijian374452668");
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.cgt_ll_me_userInfo:
AppToast.getToast().show("用户信息");
| // Path: 微信/src/net/cgt/weixin/utils/AppToast.java
// public class AppToast extends Toast {
//
// private static AppToast instance = null;
// private View layout;
// private TextView text;
//
// private AppToast() {
// super(GlobalParams.activity);
// init();
// }
//
// public static AppToast getToast() {
// if (instance == null) {
// instance = new AppToast();
// }
// return instance;
// }
//
// private void init() {
// LayoutInflater inflate = (LayoutInflater) GlobalParams.activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// layout = inflate.inflate(R.layout.cgt_transient_notification, null);
// text = (TextView) layout.findViewById(R.id.message);
// this.setView(layout);
// }
//
// public void show(String msg) {
// text.setText(msg);
// this.setDuration(Toast.LENGTH_SHORT);
// this.show();
// }
//
// public void show(int msg) {
// text.setText(msg);
// this.setDuration(Toast.LENGTH_SHORT);
// this.show();
// }
//
// }
//
// Path: 微信/src/net/cgt/weixin/utils/L.java
// public class L {
// private static final boolean flag = true;
//
// public static void i(String tag, String msg) {
// if (flag)
// Log.i(tag, msg);
// }
//
// public static void d(String tag, String msg) {
// if (flag)
// Log.d(tag, msg);
// }
//
// public static void e(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void e(String tag, String msg, Throwable tr) {
// if (flag)
// Log.e(tag, msg, tr);
// }
//
// public static void v(String tag, String msg) {
// if (flag)
// Log.v(tag, msg);
// }
//
// public static void m(String tag, String msg) {
// if (flag)
// Log.e(tag, msg);
// }
//
// public static void w(String tag, String msg) {
// if (flag)
// Log.w(tag, msg);
// }
// }
//
// Path: 微信/src/net/cgt/weixin/utils/LogUtil.java
// public class LogUtil {
//
// @SuppressWarnings("unchecked")
// public static String makeLogTag(Class cls) {
// return "Weixin_" + cls.getSimpleName();
// }
//
// }
// Path: 微信/src/net/cgt/weixin/fragment/MeFragment.java
import net.cgt.weixin.R;
import net.cgt.weixin.utils.AppToast;
import net.cgt.weixin.utils.L;
import net.cgt.weixin.utils.LogUtil;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
LinearLayout mLl_userInfo = (LinearLayout) v.findViewById(R.id.cgt_ll_me_userInfo);
mIv_userPic = (ImageView) v.findViewById(R.id.cgt_iv_me_userPic);
mTv_userName = (TextView) v.findViewById(R.id.cgt_tv_me_userName);
mTv_weixinNum = (TextView) v.findViewById(R.id.cgt_tv_me_weixinNum);
ImageButton mIb_qrCOde = (ImageButton) v.findViewById(R.id.cgt_ib_me_qrCode);
LinearLayout mLl_photo = (LinearLayout) v.findViewById(R.id.cgt_ll_me_photo);
LinearLayout mLl_collect = (LinearLayout) v.findViewById(R.id.cgt_ll_me_collect);
LinearLayout mLl_wallet = (LinearLayout) v.findViewById(R.id.cgt_ll_me_wallet);
LinearLayout mLl_set = (LinearLayout) v.findViewById(R.id.cgt_ll_me_set);
mLl_userInfo.setOnClickListener(this);
mIb_qrCOde.setOnClickListener(this);
mLl_photo.setOnClickListener(this);
mLl_collect.setOnClickListener(this);
mLl_wallet.setOnClickListener(this);
mLl_set.setOnClickListener(this);
}
private void initData() {
mIv_userPic.setImageResource(R.drawable.user_picture);
mTv_userName.setText("深情小建");
mTv_weixinNum.setText("微信号:lijian374452668");
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.cgt_ll_me_userInfo:
AppToast.getToast().show("用户信息");
| L.i(LOGTAG, "用户信息");
|
54cgt/weixin | 微信/src/net/cgt/weixin/utils/FaceConversionUtil.java | // Path: 微信/src/net/cgt/weixin/domain/ChatEmoji.java
// public class ChatEmoji {
//
// /**
// * 表情资源图片对应的ID
// */
// private int id;
// /**
// * 表情资源对应的文字描述
// */
// private String description;
// /**
// * 表情资源的文件名
// */
// private String faceName;
//
// /** 表情资源图片对应的ID */
// public int getId() {
// return id;
// }
//
// /** 表情资源图片对应的ID */
// public void setId(int id) {
// this.id = id;
// }
//
// /** 表情资源对应的文字描述 */
// public String getDescription() {
// return description;
// }
//
// /** 表情资源对应的文字描述 */
// public void setDescription(String character) {
// this.description = character;
// }
//
// /** 表情资源的文件名 */
// public String getFaceName() {
// return faceName;
// }
//
// /** 表情资源的文件名 */
// public void setFaceName(String faceName) {
// this.faceName = faceName;
// }
// }
| import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.cgt.weixin.R;
import net.cgt.weixin.domain.ChatEmoji;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ImageSpan; | package net.cgt.weixin.utils;
/**
* 表情转换工具
*
* @author lijian
* @date 2014-12-11 22:59:16
*/
public class FaceConversionUtil {
private static final String LOGTAG = LogUtil.makeLogTag(FaceConversionUtil.class);
/** 每一页表情的个数 */
private int pageSize = 20;
private static FaceConversionUtil mFaceConversionUtil;
/** 保存于内存中的表情HashMap(key:[可爱]; value:emoji_1) */
private HashMap<String, String> mMap_emoji = new HashMap<String, String>();
/** 保存于内存中的表情集合 */ | // Path: 微信/src/net/cgt/weixin/domain/ChatEmoji.java
// public class ChatEmoji {
//
// /**
// * 表情资源图片对应的ID
// */
// private int id;
// /**
// * 表情资源对应的文字描述
// */
// private String description;
// /**
// * 表情资源的文件名
// */
// private String faceName;
//
// /** 表情资源图片对应的ID */
// public int getId() {
// return id;
// }
//
// /** 表情资源图片对应的ID */
// public void setId(int id) {
// this.id = id;
// }
//
// /** 表情资源对应的文字描述 */
// public String getDescription() {
// return description;
// }
//
// /** 表情资源对应的文字描述 */
// public void setDescription(String character) {
// this.description = character;
// }
//
// /** 表情资源的文件名 */
// public String getFaceName() {
// return faceName;
// }
//
// /** 表情资源的文件名 */
// public void setFaceName(String faceName) {
// this.faceName = faceName;
// }
// }
// Path: 微信/src/net/cgt/weixin/utils/FaceConversionUtil.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.cgt.weixin.R;
import net.cgt.weixin.domain.ChatEmoji;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ImageSpan;
package net.cgt.weixin.utils;
/**
* 表情转换工具
*
* @author lijian
* @date 2014-12-11 22:59:16
*/
public class FaceConversionUtil {
private static final String LOGTAG = LogUtil.makeLogTag(FaceConversionUtil.class);
/** 每一页表情的个数 */
private int pageSize = 20;
private static FaceConversionUtil mFaceConversionUtil;
/** 保存于内存中的表情HashMap(key:[可爱]; value:emoji_1) */
private HashMap<String, String> mMap_emoji = new HashMap<String, String>();
/** 保存于内存中的表情集合 */ | private List<ChatEmoji> mList_emoji = new ArrayList<ChatEmoji>(); |
irufus/gdax-java | api/src/test/java/com/coinbase/exchange/api/accounts/AccountsIntegrationTest.java | // Path: api/src/test/java/com/coinbase/exchange/api/BaseIntegrationTest.java
// @SpringBootTest(properties = {
// "spring.profiles.active=test"
// })
// public abstract class BaseIntegrationTest {
//
// @Autowired
// public CoinbaseExchange exchange;
// }
//
// Path: api/src/test/java/com/coinbase/exchange/api/config/IntegrationTestConfiguration.java
// @SpringBootConfiguration
// public class IntegrationTestConfiguration {
//
// @Bean
// public ObjectMapper objectMapper() {
// return new ObjectMapper().registerModule(new JavaTimeModule());
// }
//
// @Bean
// public CoinbaseExchange coinbaseExchange(@Value("${exchange.key}") String apiKey,
// @Value("${exchange.passphrase}") String passphrase,
// @Value("${exchange.api.baseUrl}") String baseUrl,
// @Value("${exchange.secret}") String secretKey,
// ObjectMapper objectMapper) {
// return new CoinbaseExchangeImpl(apiKey,
// passphrase,
// baseUrl,
// new Signature(secretKey),
// objectMapper);
// }
//
// }
| import com.coinbase.exchange.api.BaseIntegrationTest;
import com.coinbase.exchange.api.config.IntegrationTestConfiguration;
import com.coinbase.exchange.model.Hold;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue; | package com.coinbase.exchange.api.accounts;
/**
* See class doc for BaseIntegrationTest
*
* Created by robevansuk on 03/02/2017.
*/
@ExtendWith(SpringExtension.class)
@Import({IntegrationTestConfiguration.class}) | // Path: api/src/test/java/com/coinbase/exchange/api/BaseIntegrationTest.java
// @SpringBootTest(properties = {
// "spring.profiles.active=test"
// })
// public abstract class BaseIntegrationTest {
//
// @Autowired
// public CoinbaseExchange exchange;
// }
//
// Path: api/src/test/java/com/coinbase/exchange/api/config/IntegrationTestConfiguration.java
// @SpringBootConfiguration
// public class IntegrationTestConfiguration {
//
// @Bean
// public ObjectMapper objectMapper() {
// return new ObjectMapper().registerModule(new JavaTimeModule());
// }
//
// @Bean
// public CoinbaseExchange coinbaseExchange(@Value("${exchange.key}") String apiKey,
// @Value("${exchange.passphrase}") String passphrase,
// @Value("${exchange.api.baseUrl}") String baseUrl,
// @Value("${exchange.secret}") String secretKey,
// ObjectMapper objectMapper) {
// return new CoinbaseExchangeImpl(apiKey,
// passphrase,
// baseUrl,
// new Signature(secretKey),
// objectMapper);
// }
//
// }
// Path: api/src/test/java/com/coinbase/exchange/api/accounts/AccountsIntegrationTest.java
import com.coinbase.exchange.api.BaseIntegrationTest;
import com.coinbase.exchange.api.config.IntegrationTestConfiguration;
import com.coinbase.exchange.model.Hold;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
package com.coinbase.exchange.api.accounts;
/**
* See class doc for BaseIntegrationTest
*
* Created by robevansuk on 03/02/2017.
*/
@ExtendWith(SpringExtension.class)
@Import({IntegrationTestConfiguration.class}) | public class AccountsIntegrationTest extends BaseIntegrationTest { |
irufus/gdax-java | api/src/main/java/com/coinbase/exchange/api/products/ProductService.java | // Path: model/src/main/java/com/coinbase/exchange/model/Candles.java
// public class Candles {
//
// List<Candle> candleList;
//
// public Candles(List<String[]> candles) {
// this.candleList = candles.stream().map(Candle::new).collect(Collectors.toList());
// }
//
// public List<Candle> getCandleList() {
// return candleList;
// }
// }
//
// Path: model/src/main/java/com/coinbase/exchange/model/Granularity.java
// public enum Granularity {
// ONE_DAY("1d"),
// SIX_HOURS("6h"),
// ONE_HOUR("1h"),
// FIFTEEN_MIN("15m"),
// FIVE_MIN("5m"),
// ONE_MIN("1m");
//
// private String granularity;
//
// Granularity(String granularity) {
// this.granularity = granularity;
// }
//
// /**
// * The granularity field must be one of the following values:
// * {60, 300, 900, 3600, 21600, 86400}.
// */
// public String get(){
// switch(granularity) {
// case "1d": return "86400";
// case "6h": return "21600";
// case "1h": return "3600";
// case "15m": return "900";
// case "5m": return "300";
// case "1m": return "60";
// }
// return "";
// }
// }
| import com.coinbase.exchange.api.exchange.CoinbaseExchange;
import com.coinbase.exchange.model.Candles;
import com.coinbase.exchange.model.Granularity;
import com.coinbase.exchange.model.Product;
import org.springframework.core.ParameterizedTypeReference;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static java.util.stream.Collectors.joining; | package com.coinbase.exchange.api.products;
/**
* Created by robevansuk on 03/02/2017.
*/
public class ProductService {
public static final String PRODUCTS_ENDPOINT = "/products";
final CoinbaseExchange exchange;
public ProductService(final CoinbaseExchange exchange) {
this.exchange = exchange;
}
// no paged products necessary
public List<Product> getProducts() {
return exchange.getAsList(PRODUCTS_ENDPOINT, new ParameterizedTypeReference<Product[]>() {
});
}
| // Path: model/src/main/java/com/coinbase/exchange/model/Candles.java
// public class Candles {
//
// List<Candle> candleList;
//
// public Candles(List<String[]> candles) {
// this.candleList = candles.stream().map(Candle::new).collect(Collectors.toList());
// }
//
// public List<Candle> getCandleList() {
// return candleList;
// }
// }
//
// Path: model/src/main/java/com/coinbase/exchange/model/Granularity.java
// public enum Granularity {
// ONE_DAY("1d"),
// SIX_HOURS("6h"),
// ONE_HOUR("1h"),
// FIFTEEN_MIN("15m"),
// FIVE_MIN("5m"),
// ONE_MIN("1m");
//
// private String granularity;
//
// Granularity(String granularity) {
// this.granularity = granularity;
// }
//
// /**
// * The granularity field must be one of the following values:
// * {60, 300, 900, 3600, 21600, 86400}.
// */
// public String get(){
// switch(granularity) {
// case "1d": return "86400";
// case "6h": return "21600";
// case "1h": return "3600";
// case "15m": return "900";
// case "5m": return "300";
// case "1m": return "60";
// }
// return "";
// }
// }
// Path: api/src/main/java/com/coinbase/exchange/api/products/ProductService.java
import com.coinbase.exchange.api.exchange.CoinbaseExchange;
import com.coinbase.exchange.model.Candles;
import com.coinbase.exchange.model.Granularity;
import com.coinbase.exchange.model.Product;
import org.springframework.core.ParameterizedTypeReference;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static java.util.stream.Collectors.joining;
package com.coinbase.exchange.api.products;
/**
* Created by robevansuk on 03/02/2017.
*/
public class ProductService {
public static final String PRODUCTS_ENDPOINT = "/products";
final CoinbaseExchange exchange;
public ProductService(final CoinbaseExchange exchange) {
this.exchange = exchange;
}
// no paged products necessary
public List<Product> getProducts() {
return exchange.getAsList(PRODUCTS_ENDPOINT, new ParameterizedTypeReference<Product[]>() {
});
}
| public Candles getCandles(String productId) { |
irufus/gdax-java | api/src/main/java/com/coinbase/exchange/api/products/ProductService.java | // Path: model/src/main/java/com/coinbase/exchange/model/Candles.java
// public class Candles {
//
// List<Candle> candleList;
//
// public Candles(List<String[]> candles) {
// this.candleList = candles.stream().map(Candle::new).collect(Collectors.toList());
// }
//
// public List<Candle> getCandleList() {
// return candleList;
// }
// }
//
// Path: model/src/main/java/com/coinbase/exchange/model/Granularity.java
// public enum Granularity {
// ONE_DAY("1d"),
// SIX_HOURS("6h"),
// ONE_HOUR("1h"),
// FIFTEEN_MIN("15m"),
// FIVE_MIN("5m"),
// ONE_MIN("1m");
//
// private String granularity;
//
// Granularity(String granularity) {
// this.granularity = granularity;
// }
//
// /**
// * The granularity field must be one of the following values:
// * {60, 300, 900, 3600, 21600, 86400}.
// */
// public String get(){
// switch(granularity) {
// case "1d": return "86400";
// case "6h": return "21600";
// case "1h": return "3600";
// case "15m": return "900";
// case "5m": return "300";
// case "1m": return "60";
// }
// return "";
// }
// }
| import com.coinbase.exchange.api.exchange.CoinbaseExchange;
import com.coinbase.exchange.model.Candles;
import com.coinbase.exchange.model.Granularity;
import com.coinbase.exchange.model.Product;
import org.springframework.core.ParameterizedTypeReference;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static java.util.stream.Collectors.joining; | package com.coinbase.exchange.api.products;
/**
* Created by robevansuk on 03/02/2017.
*/
public class ProductService {
public static final String PRODUCTS_ENDPOINT = "/products";
final CoinbaseExchange exchange;
public ProductService(final CoinbaseExchange exchange) {
this.exchange = exchange;
}
// no paged products necessary
public List<Product> getProducts() {
return exchange.getAsList(PRODUCTS_ENDPOINT, new ParameterizedTypeReference<Product[]>() {
});
}
public Candles getCandles(String productId) {
return new Candles(exchange.get(PRODUCTS_ENDPOINT + "/" + productId + "/candles", new ParameterizedTypeReference<List<String[]>>() {
}));
}
public Candles getCandles(String productId, Map<String, String> queryParams) {
StringBuffer url = new StringBuffer(PRODUCTS_ENDPOINT + "/" + productId + "/candles");
if (queryParams != null && queryParams.size() != 0) {
url.append("?");
url.append(queryParams.entrySet().stream()
.map(entry -> entry.getKey() + "=" + entry.getValue())
.collect(joining("&")));
}
return new Candles(exchange.get(url.toString(), new ParameterizedTypeReference<List<String[]>>() {}));
}
/**
* If either one of the start or end fields are not provided then both fields will be ignored.
* If a custom time range is not declared then one ending now is selected.
*/ | // Path: model/src/main/java/com/coinbase/exchange/model/Candles.java
// public class Candles {
//
// List<Candle> candleList;
//
// public Candles(List<String[]> candles) {
// this.candleList = candles.stream().map(Candle::new).collect(Collectors.toList());
// }
//
// public List<Candle> getCandleList() {
// return candleList;
// }
// }
//
// Path: model/src/main/java/com/coinbase/exchange/model/Granularity.java
// public enum Granularity {
// ONE_DAY("1d"),
// SIX_HOURS("6h"),
// ONE_HOUR("1h"),
// FIFTEEN_MIN("15m"),
// FIVE_MIN("5m"),
// ONE_MIN("1m");
//
// private String granularity;
//
// Granularity(String granularity) {
// this.granularity = granularity;
// }
//
// /**
// * The granularity field must be one of the following values:
// * {60, 300, 900, 3600, 21600, 86400}.
// */
// public String get(){
// switch(granularity) {
// case "1d": return "86400";
// case "6h": return "21600";
// case "1h": return "3600";
// case "15m": return "900";
// case "5m": return "300";
// case "1m": return "60";
// }
// return "";
// }
// }
// Path: api/src/main/java/com/coinbase/exchange/api/products/ProductService.java
import com.coinbase.exchange.api.exchange.CoinbaseExchange;
import com.coinbase.exchange.model.Candles;
import com.coinbase.exchange.model.Granularity;
import com.coinbase.exchange.model.Product;
import org.springframework.core.ParameterizedTypeReference;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static java.util.stream.Collectors.joining;
package com.coinbase.exchange.api.products;
/**
* Created by robevansuk on 03/02/2017.
*/
public class ProductService {
public static final String PRODUCTS_ENDPOINT = "/products";
final CoinbaseExchange exchange;
public ProductService(final CoinbaseExchange exchange) {
this.exchange = exchange;
}
// no paged products necessary
public List<Product> getProducts() {
return exchange.getAsList(PRODUCTS_ENDPOINT, new ParameterizedTypeReference<Product[]>() {
});
}
public Candles getCandles(String productId) {
return new Candles(exchange.get(PRODUCTS_ENDPOINT + "/" + productId + "/candles", new ParameterizedTypeReference<List<String[]>>() {
}));
}
public Candles getCandles(String productId, Map<String, String> queryParams) {
StringBuffer url = new StringBuffer(PRODUCTS_ENDPOINT + "/" + productId + "/candles");
if (queryParams != null && queryParams.size() != 0) {
url.append("?");
url.append(queryParams.entrySet().stream()
.map(entry -> entry.getKey() + "=" + entry.getValue())
.collect(joining("&")));
}
return new Candles(exchange.get(url.toString(), new ParameterizedTypeReference<List<String[]>>() {}));
}
/**
* If either one of the start or end fields are not provided then both fields will be ignored.
* If a custom time range is not declared then one ending now is selected.
*/ | public Candles getCandles(String productId, Instant startTime, Instant endTime, Granularity granularity) { |
irufus/gdax-java | api/src/test/java/com/coinbase/exchange/api/orders/OrderIntegrationTest.java | // Path: api/src/test/java/com/coinbase/exchange/api/BaseIntegrationTest.java
// @SpringBootTest(properties = {
// "spring.profiles.active=test"
// })
// public abstract class BaseIntegrationTest {
//
// @Autowired
// public CoinbaseExchange exchange;
// }
//
// Path: api/src/test/java/com/coinbase/exchange/api/config/IntegrationTestConfiguration.java
// @SpringBootConfiguration
// public class IntegrationTestConfiguration {
//
// @Bean
// public ObjectMapper objectMapper() {
// return new ObjectMapper().registerModule(new JavaTimeModule());
// }
//
// @Bean
// public CoinbaseExchange coinbaseExchange(@Value("${exchange.key}") String apiKey,
// @Value("${exchange.passphrase}") String passphrase,
// @Value("${exchange.api.baseUrl}") String baseUrl,
// @Value("${exchange.secret}") String secretKey,
// ObjectMapper objectMapper) {
// return new CoinbaseExchangeImpl(apiKey,
// passphrase,
// baseUrl,
// new Signature(secretKey),
// objectMapper);
// }
//
// }
//
// Path: api/src/main/java/com/coinbase/exchange/api/products/ProductService.java
// public class ProductService {
//
// public static final String PRODUCTS_ENDPOINT = "/products";
//
// final CoinbaseExchange exchange;
//
// public ProductService(final CoinbaseExchange exchange) {
// this.exchange = exchange;
// }
//
// // no paged products necessary
// public List<Product> getProducts() {
// return exchange.getAsList(PRODUCTS_ENDPOINT, new ParameterizedTypeReference<Product[]>() {
// });
// }
//
// public Candles getCandles(String productId) {
// return new Candles(exchange.get(PRODUCTS_ENDPOINT + "/" + productId + "/candles", new ParameterizedTypeReference<List<String[]>>() {
// }));
// }
//
// public Candles getCandles(String productId, Map<String, String> queryParams) {
// StringBuffer url = new StringBuffer(PRODUCTS_ENDPOINT + "/" + productId + "/candles");
// if (queryParams != null && queryParams.size() != 0) {
// url.append("?");
// url.append(queryParams.entrySet().stream()
// .map(entry -> entry.getKey() + "=" + entry.getValue())
// .collect(joining("&")));
// }
// return new Candles(exchange.get(url.toString(), new ParameterizedTypeReference<List<String[]>>() {}));
// }
//
// /**
// * If either one of the start or end fields are not provided then both fields will be ignored.
// * If a custom time range is not declared then one ending now is selected.
// */
// public Candles getCandles(String productId, Instant startTime, Instant endTime, Granularity granularity) {
//
// Map<String, String> queryParams = new HashMap<>();
//
// if (startTime != null) {
// queryParams.put("start", startTime.toString());
// }
// if (endTime != null) {
// queryParams.put("end", endTime.toString());
// }
// if (granularity != null) {
// queryParams.put("granularity", granularity.get());
// }
//
// return getCandles(productId, queryParams);
// }
//
// /**
// * The granularity field must be one of the following values: {60, 300, 900, 3600, 21600, 86400}
// */
// public Candles getCandles(String productId, Granularity granularity) {
// return getCandles(productId, null, null, granularity);
// }
//
// /**
// * If either one of the start or end fields are not provided then both fields will be ignored.
// */
// public Candles getCandles(String productId, Instant start, Instant end) {
// return getCandles(productId, start, end, null);
// }
// }
| import com.coinbase.exchange.api.BaseIntegrationTest;
import com.coinbase.exchange.api.accounts.Account;
import com.coinbase.exchange.api.accounts.AccountService;
import com.coinbase.exchange.api.config.IntegrationTestConfiguration;
import com.coinbase.exchange.api.marketdata.MarketData;
import com.coinbase.exchange.api.marketdata.MarketDataService;
import com.coinbase.exchange.api.products.ProductService;
import com.coinbase.exchange.model.Fill;
import com.coinbase.exchange.model.NewLimitOrderSingle;
import com.coinbase.exchange.model.NewMarketOrderSingle;
import org.junit.Ignore;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import java.util.Optional;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue; | package com.coinbase.exchange.api.orders;
/**
* See class doc for BaseIntegrationTest
*
* Created by Ishmael (sakamura@gmail.com) on 6/18/2016.
*/
@ExtendWith(SpringExtension.class)
@Import({IntegrationTestConfiguration.class}) | // Path: api/src/test/java/com/coinbase/exchange/api/BaseIntegrationTest.java
// @SpringBootTest(properties = {
// "spring.profiles.active=test"
// })
// public abstract class BaseIntegrationTest {
//
// @Autowired
// public CoinbaseExchange exchange;
// }
//
// Path: api/src/test/java/com/coinbase/exchange/api/config/IntegrationTestConfiguration.java
// @SpringBootConfiguration
// public class IntegrationTestConfiguration {
//
// @Bean
// public ObjectMapper objectMapper() {
// return new ObjectMapper().registerModule(new JavaTimeModule());
// }
//
// @Bean
// public CoinbaseExchange coinbaseExchange(@Value("${exchange.key}") String apiKey,
// @Value("${exchange.passphrase}") String passphrase,
// @Value("${exchange.api.baseUrl}") String baseUrl,
// @Value("${exchange.secret}") String secretKey,
// ObjectMapper objectMapper) {
// return new CoinbaseExchangeImpl(apiKey,
// passphrase,
// baseUrl,
// new Signature(secretKey),
// objectMapper);
// }
//
// }
//
// Path: api/src/main/java/com/coinbase/exchange/api/products/ProductService.java
// public class ProductService {
//
// public static final String PRODUCTS_ENDPOINT = "/products";
//
// final CoinbaseExchange exchange;
//
// public ProductService(final CoinbaseExchange exchange) {
// this.exchange = exchange;
// }
//
// // no paged products necessary
// public List<Product> getProducts() {
// return exchange.getAsList(PRODUCTS_ENDPOINT, new ParameterizedTypeReference<Product[]>() {
// });
// }
//
// public Candles getCandles(String productId) {
// return new Candles(exchange.get(PRODUCTS_ENDPOINT + "/" + productId + "/candles", new ParameterizedTypeReference<List<String[]>>() {
// }));
// }
//
// public Candles getCandles(String productId, Map<String, String> queryParams) {
// StringBuffer url = new StringBuffer(PRODUCTS_ENDPOINT + "/" + productId + "/candles");
// if (queryParams != null && queryParams.size() != 0) {
// url.append("?");
// url.append(queryParams.entrySet().stream()
// .map(entry -> entry.getKey() + "=" + entry.getValue())
// .collect(joining("&")));
// }
// return new Candles(exchange.get(url.toString(), new ParameterizedTypeReference<List<String[]>>() {}));
// }
//
// /**
// * If either one of the start or end fields are not provided then both fields will be ignored.
// * If a custom time range is not declared then one ending now is selected.
// */
// public Candles getCandles(String productId, Instant startTime, Instant endTime, Granularity granularity) {
//
// Map<String, String> queryParams = new HashMap<>();
//
// if (startTime != null) {
// queryParams.put("start", startTime.toString());
// }
// if (endTime != null) {
// queryParams.put("end", endTime.toString());
// }
// if (granularity != null) {
// queryParams.put("granularity", granularity.get());
// }
//
// return getCandles(productId, queryParams);
// }
//
// /**
// * The granularity field must be one of the following values: {60, 300, 900, 3600, 21600, 86400}
// */
// public Candles getCandles(String productId, Granularity granularity) {
// return getCandles(productId, null, null, granularity);
// }
//
// /**
// * If either one of the start or end fields are not provided then both fields will be ignored.
// */
// public Candles getCandles(String productId, Instant start, Instant end) {
// return getCandles(productId, start, end, null);
// }
// }
// Path: api/src/test/java/com/coinbase/exchange/api/orders/OrderIntegrationTest.java
import com.coinbase.exchange.api.BaseIntegrationTest;
import com.coinbase.exchange.api.accounts.Account;
import com.coinbase.exchange.api.accounts.AccountService;
import com.coinbase.exchange.api.config.IntegrationTestConfiguration;
import com.coinbase.exchange.api.marketdata.MarketData;
import com.coinbase.exchange.api.marketdata.MarketDataService;
import com.coinbase.exchange.api.products.ProductService;
import com.coinbase.exchange.model.Fill;
import com.coinbase.exchange.model.NewLimitOrderSingle;
import com.coinbase.exchange.model.NewMarketOrderSingle;
import org.junit.Ignore;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import java.util.Optional;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
package com.coinbase.exchange.api.orders;
/**
* See class doc for BaseIntegrationTest
*
* Created by Ishmael (sakamura@gmail.com) on 6/18/2016.
*/
@ExtendWith(SpringExtension.class)
@Import({IntegrationTestConfiguration.class}) | public class OrderIntegrationTest extends BaseIntegrationTest { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.