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
protonail/bolt-jna
bolt-jna-core/src/main/java/com/protonail/bolt/jna/Bolt.java
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/BoltNative.java // public class BoltNative { // static { // Native.register("bolt"); // } // // // Common // // public static native void DoNothing(); // // public static native void Free(Pointer pointer); // // public static native void Result_Free(Result.ByValue result); // // public static native void Error_Free(Error.ByValue error); // // public static native void Sequence_Free(Sequence.ByValue error); // // // Options // // public static native long BoltDBOptions_Create(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize); // // public static native void BoltDBOptions_Free(long optionsObjectId); // // // BoltDB // // public static native Result.ByValue BoltDB_Open(String databaseFileName, int fileMode, long optionsObjectId); // // public static native void BoltDB_Close(long boltObjectId); // // public static native Result.ByValue BoltDB_Begin(long boltObjectId, boolean writeable); // // public static native Stats.ByValue BoltDB_Stats(long boltObjectId); // // // Transaction // // public static native Error.ByValue BoltDBTransaction_Commit(long transactionObjectId); // // public static native Error.ByValue BoltDBTransaction_Rollback(long transactionObjectId); // // public static native int BoltDBTransaction_GetId(long transactionObjectId); // // public static native long BoltDBTransaction_Size(long transactionObjectId); // // public static native Result.ByValue BoltDBTransaction_CreateBucket(long transactionObjectId, byte[] name, int nameLength); // // public static native Result.ByValue BoltDBTransaction_CreateBucketIfNotExists(long transactionObjectId, byte[] name, int nameLength); // // public static native Error.ByValue BoltDBTransaction_DeleteBucket(long transactionObjectId, byte[] name, int nameLength); // // public static native Result.ByValue BoltDBTransaction_Bucket(long transactionObjectId, byte[] name, int nameLength); // // public static native long BoltDBTransaction_Cursor(long transactionObjectId); // // public static native TransactionStats.ByValue BoltDBTransaction_Stats(long transactionObjectId); // // // Bucket // // public static native void BoltDBBucket_Free(long bucketObjectId); // // public static native Value.ByValue BoltDBBucket_Get(long bucketObjectId, byte[] key, int keyLength); // // public static native Error.ByValue BoltDBBucket_Put(long bucketObjectId, byte[] key, int keyLength, byte[] value, int valueLength); // // public static native Error.ByValue BoltDBBucket_Delete(long bucketObjectId, byte[] key, int keyLength); // // public static native Result.ByValue BoltDBBucket_CreateBucket(long bucketObjectId, byte[] name, int nameLength); // // public static native Result.ByValue BoltDBBucket_CreateBucketIfNotExists(long bucketObjectId, byte[] name, int nameLength); // // public static native Error.ByValue BoltDBBucket_DeleteBucket(long bucketObjectId, byte[] name, int nameLength); // // public static native Result.ByValue BoltDBBucket_Bucket(long bucketObjectId, byte[] name, int nameLength); // // public static native long BoltDBBucket_Cursor(long bucketObjectId); // // public static native Sequence.ByValue BoltDBBucket_NextSequence(long bucketObjectId); // // public static native BucketStats.ByValue BoltDBBucket_Stats(long bucketObjectId); // // // Cursor // // public static native void BoltDBCursor_Free(long cursorObjectId); // // public static native KeyValue.ByValue BoltDBCursor_First(long cursorObjectId); // // public static native KeyValue.ByValue BoltDBCursor_Last(long cursorObjectId); // // public static native KeyValue.ByValue BoltDBCursor_Next(long cursorObjectId); // // public static native KeyValue.ByValue BoltDBCursor_Prev(long cursorObjectId); // // public static native KeyValue.ByValue BoltDBCursor_Seek(long cursorObjectId, byte[] seek, int seekLength); // // public static native Error.ByValue BoltDBCursor_Delete(long cursorObjectId); // } // // Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Result.java // public class Result extends Structure { // public static class ByValue extends Result implements Structure.ByValue { // public void checkError() { // if (error != null) { // BoltNative.Result_Free(this); // throw new BoltException(error); // } // } // } // // public long objectId; // public String error; // // @Override // protected List<String> getFieldOrder() { // return Arrays.asList("objectId", "error"); // } // }
import com.protonail.bolt.jna.impl.BoltNative; import com.protonail.bolt.jna.impl.Result; import java.util.EnumSet; import java.util.function.Consumer;
package com.protonail.bolt.jna; public class Bolt implements AutoCloseable { private long objectId; public Bolt(String databaseFileName) { this(databaseFileName, BoltFileMode.DEFAULT, null); } public Bolt(String databaseFileName, EnumSet<BoltFileMode> fileMode) { this(databaseFileName, fileMode, null); } public Bolt(String databaseFileName, EnumSet<BoltFileMode> fileMode, BoltOptions options) { long optionsObjectId = options != null ? options.objectId : 0;
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/BoltNative.java // public class BoltNative { // static { // Native.register("bolt"); // } // // // Common // // public static native void DoNothing(); // // public static native void Free(Pointer pointer); // // public static native void Result_Free(Result.ByValue result); // // public static native void Error_Free(Error.ByValue error); // // public static native void Sequence_Free(Sequence.ByValue error); // // // Options // // public static native long BoltDBOptions_Create(long timeout, boolean noGrowSync, boolean readOnly, int mmapFlags, int initialMmapSize); // // public static native void BoltDBOptions_Free(long optionsObjectId); // // // BoltDB // // public static native Result.ByValue BoltDB_Open(String databaseFileName, int fileMode, long optionsObjectId); // // public static native void BoltDB_Close(long boltObjectId); // // public static native Result.ByValue BoltDB_Begin(long boltObjectId, boolean writeable); // // public static native Stats.ByValue BoltDB_Stats(long boltObjectId); // // // Transaction // // public static native Error.ByValue BoltDBTransaction_Commit(long transactionObjectId); // // public static native Error.ByValue BoltDBTransaction_Rollback(long transactionObjectId); // // public static native int BoltDBTransaction_GetId(long transactionObjectId); // // public static native long BoltDBTransaction_Size(long transactionObjectId); // // public static native Result.ByValue BoltDBTransaction_CreateBucket(long transactionObjectId, byte[] name, int nameLength); // // public static native Result.ByValue BoltDBTransaction_CreateBucketIfNotExists(long transactionObjectId, byte[] name, int nameLength); // // public static native Error.ByValue BoltDBTransaction_DeleteBucket(long transactionObjectId, byte[] name, int nameLength); // // public static native Result.ByValue BoltDBTransaction_Bucket(long transactionObjectId, byte[] name, int nameLength); // // public static native long BoltDBTransaction_Cursor(long transactionObjectId); // // public static native TransactionStats.ByValue BoltDBTransaction_Stats(long transactionObjectId); // // // Bucket // // public static native void BoltDBBucket_Free(long bucketObjectId); // // public static native Value.ByValue BoltDBBucket_Get(long bucketObjectId, byte[] key, int keyLength); // // public static native Error.ByValue BoltDBBucket_Put(long bucketObjectId, byte[] key, int keyLength, byte[] value, int valueLength); // // public static native Error.ByValue BoltDBBucket_Delete(long bucketObjectId, byte[] key, int keyLength); // // public static native Result.ByValue BoltDBBucket_CreateBucket(long bucketObjectId, byte[] name, int nameLength); // // public static native Result.ByValue BoltDBBucket_CreateBucketIfNotExists(long bucketObjectId, byte[] name, int nameLength); // // public static native Error.ByValue BoltDBBucket_DeleteBucket(long bucketObjectId, byte[] name, int nameLength); // // public static native Result.ByValue BoltDBBucket_Bucket(long bucketObjectId, byte[] name, int nameLength); // // public static native long BoltDBBucket_Cursor(long bucketObjectId); // // public static native Sequence.ByValue BoltDBBucket_NextSequence(long bucketObjectId); // // public static native BucketStats.ByValue BoltDBBucket_Stats(long bucketObjectId); // // // Cursor // // public static native void BoltDBCursor_Free(long cursorObjectId); // // public static native KeyValue.ByValue BoltDBCursor_First(long cursorObjectId); // // public static native KeyValue.ByValue BoltDBCursor_Last(long cursorObjectId); // // public static native KeyValue.ByValue BoltDBCursor_Next(long cursorObjectId); // // public static native KeyValue.ByValue BoltDBCursor_Prev(long cursorObjectId); // // public static native KeyValue.ByValue BoltDBCursor_Seek(long cursorObjectId, byte[] seek, int seekLength); // // public static native Error.ByValue BoltDBCursor_Delete(long cursorObjectId); // } // // Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Result.java // public class Result extends Structure { // public static class ByValue extends Result implements Structure.ByValue { // public void checkError() { // if (error != null) { // BoltNative.Result_Free(this); // throw new BoltException(error); // } // } // } // // public long objectId; // public String error; // // @Override // protected List<String> getFieldOrder() { // return Arrays.asList("objectId", "error"); // } // } // Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/Bolt.java import com.protonail.bolt.jna.impl.BoltNative; import com.protonail.bolt.jna.impl.Result; import java.util.EnumSet; import java.util.function.Consumer; package com.protonail.bolt.jna; public class Bolt implements AutoCloseable { private long objectId; public Bolt(String databaseFileName) { this(databaseFileName, BoltFileMode.DEFAULT, null); } public Bolt(String databaseFileName, EnumSet<BoltFileMode> fileMode) { this(databaseFileName, fileMode, null); } public Bolt(String databaseFileName, EnumSet<BoltFileMode> fileMode, BoltOptions options) { long optionsObjectId = options != null ? options.objectId : 0;
Result.ByValue result = BoltNative.BoltDB_Open(databaseFileName, BoltFileMode.toFlag(fileMode), optionsObjectId);
protonail/bolt-jna
bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltStats.java
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Stats.java // public class Stats extends Structure { // public static class ByValue extends Stats implements Structure.ByValue {} // // public int freePageN; // public int pendingPageN; // public int freeAlloc; // public int freelistInUse; // // public int txN; // public int openTxN; // public TransactionStats.ByValue txStats; // // @Override // protected List<String> getFieldOrder() { // return Arrays.asList( // "freePageN", // "pendingPageN", // "freeAlloc", // "freelistInUse", // "txN", // "openTxN", // "txStats" // ); // } // }
import com.protonail.bolt.jna.impl.Stats;
package com.protonail.bolt.jna; public class BoltStats { private int freePageN; private int pendingPageN; private int freeAlloc; private int freelistInUse; private int transactionN; private int openTransactionN; private BoltTransactionStats transactionStats;
// Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/impl/Stats.java // public class Stats extends Structure { // public static class ByValue extends Stats implements Structure.ByValue {} // // public int freePageN; // public int pendingPageN; // public int freeAlloc; // public int freelistInUse; // // public int txN; // public int openTxN; // public TransactionStats.ByValue txStats; // // @Override // protected List<String> getFieldOrder() { // return Arrays.asList( // "freePageN", // "pendingPageN", // "freeAlloc", // "freelistInUse", // "txN", // "openTxN", // "txStats" // ); // } // } // Path: bolt-jna-core/src/main/java/com/protonail/bolt/jna/BoltStats.java import com.protonail.bolt.jna.impl.Stats; package com.protonail.bolt.jna; public class BoltStats { private int freePageN; private int pendingPageN; private int freeAlloc; private int freelistInUse; private int transactionN; private int openTransactionN; private BoltTransactionStats transactionStats;
public BoltStats(Stats.ByValue stats) {
liquibase/liquibase-oracle
src/main/java/liquibase/ext/ora/createtrigger/CreateTriggerChange.java
// Path: src/main/java/liquibase/ext/ora/droptrigger/DropTriggerChange.java // @DatabaseChange(name="dropTrigger", description = "Drop trigger", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class DropTriggerChange extends AbstractChange { // private String triggerName; // private String schemaName; // // public String getTriggerName() { // return triggerName; // } // // public void setTriggerName(String triggerName) { // this.triggerName = triggerName; // } // // public String getSchemaName() { // return schemaName; // } // // public void setSchemaName(String schemaName) { // this.schemaName = schemaName; // } // // public String getConfirmationMessage() { // return "Trigger" + getTriggerName() + " has been droped"; // } // // public SqlStatement[] generateStatements(Database database) { // // // String schemaName = getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(); // // DropTriggerStatement statement = new DropTriggerStatement(schemaName, getTriggerName()); // // return new SqlStatement[]{ // statement // }; // } // // }
import liquibase.change.AbstractChange; import liquibase.change.Change; import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.change.DatabaseChangeProperty; import liquibase.database.Database; import liquibase.ext.ora.droptrigger.DropTriggerChange; import liquibase.serializer.LiquibaseSerializable; import liquibase.statement.SqlStatement;
public String getNestedTableColumn() { return nestedTableColumn; } public void setNestedTableColumn(String nestedTableColumn) { this.nestedTableColumn = nestedTableColumn; } public String getWhenCondition() { return whenCondition; } public void setWhenCondition(String whenCondition) { this.whenCondition = whenCondition; } public String getProcedure() { return procedure; } public void setProcedure(String procedure) { this.procedure = procedure; } public String getConfirmationMessage() { return "Trigger " + getTriggerName() + " has been created"; } protected Change[] createInverses() {
// Path: src/main/java/liquibase/ext/ora/droptrigger/DropTriggerChange.java // @DatabaseChange(name="dropTrigger", description = "Drop trigger", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class DropTriggerChange extends AbstractChange { // private String triggerName; // private String schemaName; // // public String getTriggerName() { // return triggerName; // } // // public void setTriggerName(String triggerName) { // this.triggerName = triggerName; // } // // public String getSchemaName() { // return schemaName; // } // // public void setSchemaName(String schemaName) { // this.schemaName = schemaName; // } // // public String getConfirmationMessage() { // return "Trigger" + getTriggerName() + " has been droped"; // } // // public SqlStatement[] generateStatements(Database database) { // // // String schemaName = getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(); // // DropTriggerStatement statement = new DropTriggerStatement(schemaName, getTriggerName()); // // return new SqlStatement[]{ // statement // }; // } // // } // Path: src/main/java/liquibase/ext/ora/createtrigger/CreateTriggerChange.java import liquibase.change.AbstractChange; import liquibase.change.Change; import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.change.DatabaseChangeProperty; import liquibase.database.Database; import liquibase.ext.ora.droptrigger.DropTriggerChange; import liquibase.serializer.LiquibaseSerializable; import liquibase.statement.SqlStatement; public String getNestedTableColumn() { return nestedTableColumn; } public void setNestedTableColumn(String nestedTableColumn) { this.nestedTableColumn = nestedTableColumn; } public String getWhenCondition() { return whenCondition; } public void setWhenCondition(String whenCondition) { this.whenCondition = whenCondition; } public String getProcedure() { return procedure; } public void setProcedure(String procedure) { this.procedure = procedure; } public String getConfirmationMessage() { return "Trigger " + getTriggerName() + " has been created"; } protected Change[] createInverses() {
DropTriggerChange inverse = new DropTriggerChange();
liquibase/liquibase-oracle
src/main/java/liquibase/ext/ora/createSynonym/CreateSynonymChange.java
// Path: src/main/java/liquibase/ext/ora/dropSynonym/DropSynonymChange.java // @DatabaseChange(name = "dropSynonym", description = "Drop synonym", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class DropSynonymChange extends AbstractChange { // // private Boolean isPublic = false; // private String synonymSchemaName; // private String synonymName; // private Boolean force; // // public Boolean isPublic() { // return isPublic; // } // // public void setPublic(Boolean isPublic) { // this.isPublic = isPublic; // } // // public String getSynonymName() { // return synonymName; // } // // public void setSynonymName(String synonymName) { // this.synonymName = synonymName; // } // // public String getSynonymSchemaName() { // return synonymSchemaName; // } // // public void setSynonymSchemaName(String synonymSchemaName) { // this.synonymSchemaName = synonymSchemaName; // } // // public Boolean isForce() { // return force; // } // // public void setForce(Boolean force) { // this.force = force; // } // // @Override // public String getConfirmationMessage() { // return MessageFormat.format("Synonym {0} dropped", getSynonymName()); // } // // @Override // public SqlStatement[] generateStatements(Database database) { // DropSynonymStatement statement = new DropSynonymStatement(); // statement.setForce(isForce()); // statement.setSynonymName(getSynonymName()); // statement.setSynonymSchemaName(getSynonymSchemaName()); // statement.setPublic(isPublic()); // return new SqlStatement[] { statement }; // } // // }
import java.text.MessageFormat; import liquibase.change.AbstractChange; import liquibase.change.Change; import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.database.Database; import liquibase.ext.ora.dropSynonym.DropSynonymChange; import liquibase.statement.SqlStatement;
return objectSchemaName; } public void setObjectSchemaName(String objectSchemaName) { this.objectSchemaName = objectSchemaName; } public String getSynonymName() { return synonymName; } public void setSynonymName(String synonymName) { this.synonymName = synonymName; } public String getSynonymSchemaName() { return synonymSchemaName; } public void setSynonymSchemaName(String synonymSchemaName) { this.synonymSchemaName = synonymSchemaName; } @Override public String getConfirmationMessage() { return MessageFormat.format("Synonym {0} created", getSynonymName()); } @Override protected Change[] createInverses() {
// Path: src/main/java/liquibase/ext/ora/dropSynonym/DropSynonymChange.java // @DatabaseChange(name = "dropSynonym", description = "Drop synonym", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class DropSynonymChange extends AbstractChange { // // private Boolean isPublic = false; // private String synonymSchemaName; // private String synonymName; // private Boolean force; // // public Boolean isPublic() { // return isPublic; // } // // public void setPublic(Boolean isPublic) { // this.isPublic = isPublic; // } // // public String getSynonymName() { // return synonymName; // } // // public void setSynonymName(String synonymName) { // this.synonymName = synonymName; // } // // public String getSynonymSchemaName() { // return synonymSchemaName; // } // // public void setSynonymSchemaName(String synonymSchemaName) { // this.synonymSchemaName = synonymSchemaName; // } // // public Boolean isForce() { // return force; // } // // public void setForce(Boolean force) { // this.force = force; // } // // @Override // public String getConfirmationMessage() { // return MessageFormat.format("Synonym {0} dropped", getSynonymName()); // } // // @Override // public SqlStatement[] generateStatements(Database database) { // DropSynonymStatement statement = new DropSynonymStatement(); // statement.setForce(isForce()); // statement.setSynonymName(getSynonymName()); // statement.setSynonymSchemaName(getSynonymSchemaName()); // statement.setPublic(isPublic()); // return new SqlStatement[] { statement }; // } // // } // Path: src/main/java/liquibase/ext/ora/createSynonym/CreateSynonymChange.java import java.text.MessageFormat; import liquibase.change.AbstractChange; import liquibase.change.Change; import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.database.Database; import liquibase.ext.ora.dropSynonym.DropSynonymChange; import liquibase.statement.SqlStatement; return objectSchemaName; } public void setObjectSchemaName(String objectSchemaName) { this.objectSchemaName = objectSchemaName; } public String getSynonymName() { return synonymName; } public void setSynonymName(String synonymName) { this.synonymName = synonymName; } public String getSynonymSchemaName() { return synonymSchemaName; } public void setSynonymSchemaName(String synonymSchemaName) { this.synonymSchemaName = synonymSchemaName; } @Override public String getConfirmationMessage() { return MessageFormat.format("Synonym {0} created", getSynonymName()); } @Override protected Change[] createInverses() {
DropSynonymChange inverse = new DropSynonymChange();
liquibase/liquibase-oracle
src/main/java/liquibase/ext/ora/addcheck/AddCheckChange.java
// Path: src/main/java/liquibase/ext/ora/check/CheckAttribute.java // public abstract class CheckAttribute extends AbstractChange { // // private String tableName; // private String tablespace; // private String schemaName; // private String constraintName; // private String condition; // private Boolean disable; // private Boolean deferrable; // private Boolean initiallyDeferred; // private Boolean rely; // private Boolean validate; // // public void setTableName(String tableName) { // this.tableName = tableName; // } // // public String getTableName() { // return tableName; // } // // public void setTablespace(String tablespace) { // this.tablespace = tablespace; // } // // public String getTablespace() { // return tablespace; // } // // public String getSchemaName() { // return schemaName; // } // // public void setSchemaName(String schemaName) { // this.schemaName = StringUtil.trimToNull(schemaName); // } // // public void setConstraintName(String constraintName) { // this.constraintName = constraintName; // } // // public String getConstraintName() { // return constraintName; // } // // public String getCondition() { // return condition; // } // // public void setCondition(String condition) { // this.condition = condition; // } // // public Boolean getDisable() { // return disable; // } // // public void setDisable(Boolean disable) { // this.disable = disable; // } // // public Boolean getDeferrable() { // return deferrable; // } // // public void setDeferrable(Boolean deferrable) { // this.deferrable = deferrable; // } // // public Boolean getInitiallyDeferred() { // return initiallyDeferred; // } // // public void setInitiallyDeferred(Boolean initiallyDeferred) { // this.initiallyDeferred = initiallyDeferred; // } // // public Boolean getValidate() { // return validate; // } // // public void setValidate(Boolean validate) { // this.validate = validate; // } // // public Boolean getRely() { // return rely; // } // // public void setRely(Boolean rely) { // this.rely = rely; // } // // public SqlStatement[] generateStatements(Database database) { // // return null; // } // // public String getConfirmationMessage() { // return null; // } // // } // // Path: src/main/java/liquibase/ext/ora/dropcheck/DropCheckChange.java // @DatabaseChange(name="dropCheck", description = "Drop check", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class DropCheckChange extends CheckAttribute { // // public DropCheckChange() { // } // // // public SqlStatement[] generateStatements(Database database) { // // String schemaname = getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(); // // DropCheckStatement statement = new DropCheckStatement(schemaname, getTableName(), getConstraintName()); // // return new SqlStatement[] // { // statement // }; // } // // public String getConfirmationMessage() { // return getConstraintName() + " check DROPPED from " + getTableName(); // } // // }
import liquibase.change.DatabaseChange; import liquibase.database.Database; import liquibase.ext.ora.check.CheckAttribute; import liquibase.ext.ora.dropcheck.DropCheckChange; import liquibase.statement.SqlStatement; import liquibase.change.Change; import liquibase.change.ChangeMetaData;
package liquibase.ext.ora.addcheck; @DatabaseChange(name="addCheck", description = "Add Check", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) public class AddCheckChange extends CheckAttribute { public AddCheckChange() { } public SqlStatement[] generateStatements(Database database) { String schemaName = getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(); AddCheckStatement statement = new AddCheckStatement(schemaName, getTableName(), getConstraintName(), getCondition()); statement.setTablespace(getTablespace()); statement.setDisable(getDisable()); statement.setDeferrable(getDeferrable()); statement.setInitiallyDeferred(getInitiallyDeferred()); statement.setRely(getRely()); statement.setValidate(getValidate()); return new SqlStatement[]{statement}; } public String getConfirmationMessage() { return "Constraint check " + getConstraintName() + " has been added to " + getTableName(); } protected Change[] createInverses() { if (getConstraintName() == null) { return null; }
// Path: src/main/java/liquibase/ext/ora/check/CheckAttribute.java // public abstract class CheckAttribute extends AbstractChange { // // private String tableName; // private String tablespace; // private String schemaName; // private String constraintName; // private String condition; // private Boolean disable; // private Boolean deferrable; // private Boolean initiallyDeferred; // private Boolean rely; // private Boolean validate; // // public void setTableName(String tableName) { // this.tableName = tableName; // } // // public String getTableName() { // return tableName; // } // // public void setTablespace(String tablespace) { // this.tablespace = tablespace; // } // // public String getTablespace() { // return tablespace; // } // // public String getSchemaName() { // return schemaName; // } // // public void setSchemaName(String schemaName) { // this.schemaName = StringUtil.trimToNull(schemaName); // } // // public void setConstraintName(String constraintName) { // this.constraintName = constraintName; // } // // public String getConstraintName() { // return constraintName; // } // // public String getCondition() { // return condition; // } // // public void setCondition(String condition) { // this.condition = condition; // } // // public Boolean getDisable() { // return disable; // } // // public void setDisable(Boolean disable) { // this.disable = disable; // } // // public Boolean getDeferrable() { // return deferrable; // } // // public void setDeferrable(Boolean deferrable) { // this.deferrable = deferrable; // } // // public Boolean getInitiallyDeferred() { // return initiallyDeferred; // } // // public void setInitiallyDeferred(Boolean initiallyDeferred) { // this.initiallyDeferred = initiallyDeferred; // } // // public Boolean getValidate() { // return validate; // } // // public void setValidate(Boolean validate) { // this.validate = validate; // } // // public Boolean getRely() { // return rely; // } // // public void setRely(Boolean rely) { // this.rely = rely; // } // // public SqlStatement[] generateStatements(Database database) { // // return null; // } // // public String getConfirmationMessage() { // return null; // } // // } // // Path: src/main/java/liquibase/ext/ora/dropcheck/DropCheckChange.java // @DatabaseChange(name="dropCheck", description = "Drop check", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class DropCheckChange extends CheckAttribute { // // public DropCheckChange() { // } // // // public SqlStatement[] generateStatements(Database database) { // // String schemaname = getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(); // // DropCheckStatement statement = new DropCheckStatement(schemaname, getTableName(), getConstraintName()); // // return new SqlStatement[] // { // statement // }; // } // // public String getConfirmationMessage() { // return getConstraintName() + " check DROPPED from " + getTableName(); // } // // } // Path: src/main/java/liquibase/ext/ora/addcheck/AddCheckChange.java import liquibase.change.DatabaseChange; import liquibase.database.Database; import liquibase.ext.ora.check.CheckAttribute; import liquibase.ext.ora.dropcheck.DropCheckChange; import liquibase.statement.SqlStatement; import liquibase.change.Change; import liquibase.change.ChangeMetaData; package liquibase.ext.ora.addcheck; @DatabaseChange(name="addCheck", description = "Add Check", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) public class AddCheckChange extends CheckAttribute { public AddCheckChange() { } public SqlStatement[] generateStatements(Database database) { String schemaName = getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(); AddCheckStatement statement = new AddCheckStatement(schemaName, getTableName(), getConstraintName(), getCondition()); statement.setTablespace(getTablespace()); statement.setDisable(getDisable()); statement.setDeferrable(getDeferrable()); statement.setInitiallyDeferred(getInitiallyDeferred()); statement.setRely(getRely()); statement.setValidate(getValidate()); return new SqlStatement[]{statement}; } public String getConfirmationMessage() { return "Constraint check " + getConstraintName() + " has been added to " + getTableName(); } protected Change[] createInverses() { if (getConstraintName() == null) { return null; }
DropCheckChange inverse = new DropCheckChange();
liquibase/liquibase-oracle
src/main/java/liquibase/ext/ora/grant/revokegrant/RevokeObjectPermissionChange.java
// Path: src/main/java/liquibase/ext/ora/grant/addgrant/GrantObjectPermissionChange.java // @DatabaseChange(name="grantObjectPermission", description = "Grant Schema Object Permission", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class GrantObjectPermissionChange extends AbstractObjectPermissionChange { // // private Boolean grantOption = Boolean.FALSE; // // public GrantObjectPermissionChange() {} // // public GrantObjectPermissionChange( AbstractObjectPermissionChange other ) { // super(other); // } // // public Boolean getGrantOption() { // return grantOption; // } // // public void setGrantOption(final Boolean grantOption) { // this.grantOption = grantOption; // } // @Override // public SqlStatement[] generateStatements(Database database) { // String schemaName = getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(); // // GrantObjectPermissionStatement statement = new GrantObjectPermissionStatement(schemaName, getObjectName(), getRecipientList()); // statement.setSelect(getSelect()); // statement.setUpdate(getUpdate()); // statement.setInsert(getInsert()); // statement.setDelete(getDelete()); // statement.setExecute(getExecute()); // statement.setReferences(getReferences()); // statement.setIndex(getIndex()); // statement.setGrantOption(getGrantOption()); // // return new SqlStatement[]{statement}; // } // // @Override // public String getConfirmationMessage() { // return "Grants on " + getObjectName() + " have been given to " + getRecipientList(); // } // // @Override // protected Change[] createInverses() { // RevokeObjectPermissionChange inverse = new RevokeObjectPermissionChange(this); // return new Change[]{inverse}; // } // // }
import liquibase.change.Change; import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.database.Database; import liquibase.ext.ora.grant.AbstractObjectPermissionChange; import liquibase.ext.ora.grant.addgrant.GrantObjectPermissionChange; import liquibase.statement.SqlStatement;
package liquibase.ext.ora.grant.revokegrant; @DatabaseChange(name="revokeObjectPermission", description = "Revoke Schema Object Permission", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) public class RevokeObjectPermissionChange extends AbstractObjectPermissionChange { public RevokeObjectPermissionChange() {} public RevokeObjectPermissionChange( AbstractObjectPermissionChange other ) { super(other); } @Override public SqlStatement[] generateStatements(Database database) { String schemaName = getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(); RevokeObjectPermissionStatement statement = new RevokeObjectPermissionStatement(schemaName, getObjectName(), getRecipientList()); statement.setSelect(getSelect()); statement.setUpdate(getUpdate()); statement.setInsert(getInsert()); statement.setDelete(getDelete()); statement.setExecute(getExecute()); statement.setIndex(getIndex()); statement.setReferences(getReferences()); return new SqlStatement[]{statement}; } @Override public String getConfirmationMessage() { return "Revoking grants on " + getObjectName() + " that had been given to " + getRecipientList(); } @Override protected Change[] createInverses() {
// Path: src/main/java/liquibase/ext/ora/grant/addgrant/GrantObjectPermissionChange.java // @DatabaseChange(name="grantObjectPermission", description = "Grant Schema Object Permission", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class GrantObjectPermissionChange extends AbstractObjectPermissionChange { // // private Boolean grantOption = Boolean.FALSE; // // public GrantObjectPermissionChange() {} // // public GrantObjectPermissionChange( AbstractObjectPermissionChange other ) { // super(other); // } // // public Boolean getGrantOption() { // return grantOption; // } // // public void setGrantOption(final Boolean grantOption) { // this.grantOption = grantOption; // } // @Override // public SqlStatement[] generateStatements(Database database) { // String schemaName = getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(); // // GrantObjectPermissionStatement statement = new GrantObjectPermissionStatement(schemaName, getObjectName(), getRecipientList()); // statement.setSelect(getSelect()); // statement.setUpdate(getUpdate()); // statement.setInsert(getInsert()); // statement.setDelete(getDelete()); // statement.setExecute(getExecute()); // statement.setReferences(getReferences()); // statement.setIndex(getIndex()); // statement.setGrantOption(getGrantOption()); // // return new SqlStatement[]{statement}; // } // // @Override // public String getConfirmationMessage() { // return "Grants on " + getObjectName() + " have been given to " + getRecipientList(); // } // // @Override // protected Change[] createInverses() { // RevokeObjectPermissionChange inverse = new RevokeObjectPermissionChange(this); // return new Change[]{inverse}; // } // // } // Path: src/main/java/liquibase/ext/ora/grant/revokegrant/RevokeObjectPermissionChange.java import liquibase.change.Change; import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.database.Database; import liquibase.ext.ora.grant.AbstractObjectPermissionChange; import liquibase.ext.ora.grant.addgrant.GrantObjectPermissionChange; import liquibase.statement.SqlStatement; package liquibase.ext.ora.grant.revokegrant; @DatabaseChange(name="revokeObjectPermission", description = "Revoke Schema Object Permission", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) public class RevokeObjectPermissionChange extends AbstractObjectPermissionChange { public RevokeObjectPermissionChange() {} public RevokeObjectPermissionChange( AbstractObjectPermissionChange other ) { super(other); } @Override public SqlStatement[] generateStatements(Database database) { String schemaName = getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(); RevokeObjectPermissionStatement statement = new RevokeObjectPermissionStatement(schemaName, getObjectName(), getRecipientList()); statement.setSelect(getSelect()); statement.setUpdate(getUpdate()); statement.setInsert(getInsert()); statement.setDelete(getDelete()); statement.setExecute(getExecute()); statement.setIndex(getIndex()); statement.setReferences(getReferences()); return new SqlStatement[]{statement}; } @Override public String getConfirmationMessage() { return "Revoking grants on " + getObjectName() + " that had been given to " + getRecipientList(); } @Override protected Change[] createInverses() {
GrantObjectPermissionChange inverse = new GrantObjectPermissionChange(this);
liquibase/liquibase-oracle
src/main/java/liquibase/ext/ora/creatematerializedview/CreateMaterializedViewChange.java
// Path: src/main/java/liquibase/ext/ora/dropmaterializedview/DropMaterializedViewChange.java // @DatabaseChange(name="dropMaterializedView", description = "Drop Materialized View", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class DropMaterializedViewChange extends AbstractChange { // // private String schemaName; // private String viewName; // // public String getSchemaName() { // return schemaName; // } // // public void setSchemaName(String schemaName) { // this.schemaName = schemaName; // } // // public String getViewName() { // return viewName; // } // // public void setViewName(String viewName) { // this.viewName = viewName; // } // // public String getConfirmationMessage() { // return "Materialized view " + getViewName() + " has been droped"; // } // // public SqlStatement[] generateStatements(Database database) { // DropMaterializedViewStatement statement = new DropMaterializedViewStatement(getViewName()); // statement.setSchemaName(getSchemaName()); // // return new SqlStatement[]{statement}; // } // }
import liquibase.change.AbstractChange; import liquibase.change.Change; import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.database.Database; import liquibase.statement.SqlStatement; import liquibase.ext.ora.dropmaterializedview.DropMaterializedViewChange;
public Boolean getForUpdate() { return forUpdate; } public void setForUpdate(Boolean forUpdate) { this.forUpdate = forUpdate; } public String getQueryRewrite() { return queryRewrite; } public void setQueryRewrite(String queryRewrite) { this.queryRewrite = queryRewrite; } public String getSubquery() { return subquery; } public void setSubquery(String subquery) { this.subquery = subquery; } public String getConfirmationMessage() { return "Materialized view " + getViewName() + " has been created"; } protected Change[] createInverses() {
// Path: src/main/java/liquibase/ext/ora/dropmaterializedview/DropMaterializedViewChange.java // @DatabaseChange(name="dropMaterializedView", description = "Drop Materialized View", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class DropMaterializedViewChange extends AbstractChange { // // private String schemaName; // private String viewName; // // public String getSchemaName() { // return schemaName; // } // // public void setSchemaName(String schemaName) { // this.schemaName = schemaName; // } // // public String getViewName() { // return viewName; // } // // public void setViewName(String viewName) { // this.viewName = viewName; // } // // public String getConfirmationMessage() { // return "Materialized view " + getViewName() + " has been droped"; // } // // public SqlStatement[] generateStatements(Database database) { // DropMaterializedViewStatement statement = new DropMaterializedViewStatement(getViewName()); // statement.setSchemaName(getSchemaName()); // // return new SqlStatement[]{statement}; // } // } // Path: src/main/java/liquibase/ext/ora/creatematerializedview/CreateMaterializedViewChange.java import liquibase.change.AbstractChange; import liquibase.change.Change; import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.database.Database; import liquibase.statement.SqlStatement; import liquibase.ext.ora.dropmaterializedview.DropMaterializedViewChange; public Boolean getForUpdate() { return forUpdate; } public void setForUpdate(Boolean forUpdate) { this.forUpdate = forUpdate; } public String getQueryRewrite() { return queryRewrite; } public void setQueryRewrite(String queryRewrite) { this.queryRewrite = queryRewrite; } public String getSubquery() { return subquery; } public void setSubquery(String subquery) { this.subquery = subquery; } public String getConfirmationMessage() { return "Materialized view " + getViewName() + " has been created"; } protected Change[] createInverses() {
DropMaterializedViewChange inverse = new DropMaterializedViewChange();
liquibase/liquibase-oracle
src/main/java/liquibase/ext/ora/enabletrigger/EnableTriggerChange.java
// Path: src/main/java/liquibase/ext/ora/disabletrigger/DisableTriggerChange.java // @DatabaseChange(name="disableTrigger", description = "Disable Trigger", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class DisableTriggerChange extends AbstractChange { // // private String schemaName; // private String triggerName; // // public String getSchemaName() { // return schemaName; // } // // public void setSchemaName(String schemaName) { // this.schemaName = schemaName; // } // // public String getTriggerName() { // return triggerName; // } // // public void setTriggerName(String triggerName) { // this.triggerName = triggerName; // } // // public String getConfirmationMessage() { // return "Trigger has been disabled."; // } // // @Override // protected Change[] createInverses() { // EnableTriggerChange inverse = new EnableTriggerChange(); // inverse.setSchemaName(getSchemaName()); // inverse.setTriggerName(getTriggerName()); // return new Change[]{inverse,}; // } // // public SqlStatement[] generateStatements(Database database) { // DisableTriggerStatement statement = new DisableTriggerStatement(getSchemaName(), getTriggerName()); // // return new SqlStatement[]{statement}; // } // // }
import liquibase.change.AbstractChange; import liquibase.change.Change; import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.database.Database; import liquibase.ext.ora.disabletrigger.DisableTriggerChange; import liquibase.statement.SqlStatement;
package liquibase.ext.ora.enabletrigger; @DatabaseChange(name="enableTrigger", description = "Enable Trigger", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) public class EnableTriggerChange extends AbstractChange { private String schemaName; private String triggerName; public String getSchemaName() { return schemaName; } public void setSchemaName(String schemaName) { this.schemaName = schemaName; } public String getTriggerName() { return triggerName; } public void setTriggerName(String triggerName) { this.triggerName = triggerName; } public String getConfirmationMessage() { return "Trigger has been enabled."; } @Override protected Change[] createInverses() {
// Path: src/main/java/liquibase/ext/ora/disabletrigger/DisableTriggerChange.java // @DatabaseChange(name="disableTrigger", description = "Disable Trigger", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class DisableTriggerChange extends AbstractChange { // // private String schemaName; // private String triggerName; // // public String getSchemaName() { // return schemaName; // } // // public void setSchemaName(String schemaName) { // this.schemaName = schemaName; // } // // public String getTriggerName() { // return triggerName; // } // // public void setTriggerName(String triggerName) { // this.triggerName = triggerName; // } // // public String getConfirmationMessage() { // return "Trigger has been disabled."; // } // // @Override // protected Change[] createInverses() { // EnableTriggerChange inverse = new EnableTriggerChange(); // inverse.setSchemaName(getSchemaName()); // inverse.setTriggerName(getTriggerName()); // return new Change[]{inverse,}; // } // // public SqlStatement[] generateStatements(Database database) { // DisableTriggerStatement statement = new DisableTriggerStatement(getSchemaName(), getTriggerName()); // // return new SqlStatement[]{statement}; // } // // } // Path: src/main/java/liquibase/ext/ora/enabletrigger/EnableTriggerChange.java import liquibase.change.AbstractChange; import liquibase.change.Change; import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.database.Database; import liquibase.ext.ora.disabletrigger.DisableTriggerChange; import liquibase.statement.SqlStatement; package liquibase.ext.ora.enabletrigger; @DatabaseChange(name="enableTrigger", description = "Enable Trigger", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) public class EnableTriggerChange extends AbstractChange { private String schemaName; private String triggerName; public String getSchemaName() { return schemaName; } public void setSchemaName(String schemaName) { this.schemaName = schemaName; } public String getTriggerName() { return triggerName; } public void setTriggerName(String triggerName) { this.triggerName = triggerName; } public String getConfirmationMessage() { return "Trigger has been enabled."; } @Override protected Change[] createInverses() {
DisableTriggerChange inverse = new DisableTriggerChange();
liquibase/liquibase-oracle
src/test/java/liquibase/ext/ora/synonym/createSynonym/CreateSynonymTest.java
// Path: src/main/java/liquibase/ext/ora/createSynonym/CreateSynonymChange.java // @DatabaseChange(name = "createSynonym", description = "Create synonym", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class CreateSynonymChange extends AbstractChange { // // private Boolean replace; // private Boolean isPublic; // private String objectName; // private String objectSchemaName; // // private String synonymName; // private String synonymSchemaName; // // public Boolean isReplace() { // return replace; // } // // public void setReplace(Boolean replace) { // this.replace = replace; // } // // public Boolean isPublic() { // return isPublic; // } // // public void setPublic(Boolean isPublic) { // this.isPublic = isPublic; // } // // public String getObjectName() { // return objectName; // } // // public void setObjectName(String objectName) { // this.objectName = objectName; // } // // public String getObjectSchemaName() { // return objectSchemaName; // } // // public void setObjectSchemaName(String objectSchemaName) { // this.objectSchemaName = objectSchemaName; // } // // public String getSynonymName() { // return synonymName; // } // // public void setSynonymName(String synonymName) { // this.synonymName = synonymName; // } // // public String getSynonymSchemaName() { // return synonymSchemaName; // } // // public void setSynonymSchemaName(String synonymSchemaName) { // this.synonymSchemaName = synonymSchemaName; // } // // @Override // public String getConfirmationMessage() { // return MessageFormat.format("Synonym {0} created", getSynonymName()); // } // // @Override // protected Change[] createInverses() { // DropSynonymChange inverse = new DropSynonymChange(); // inverse.setPublic(isPublic()); // inverse.setSynonymName(getSynonymName()); // inverse.setSynonymSchemaName(getSynonymSchemaName()); // return new Change[] { inverse }; // } // // @Override // public SqlStatement[] generateStatements(Database database) { // CreateSynonymStatement statement = new CreateSynonymStatement(); // // statement.setObjectName(getObjectName()); // statement.setObjectSchemaName(getObjectSchemaName()); // statement.setSynonymName(getSynonymName()); // statement.setSynonymSchemaName(getSynonymSchemaName()); // // statement.setReplace(isReplace()); // statement.setPublic(isPublic()); // return new SqlStatement[] { statement }; // } // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.List; import liquibase.Contexts; import liquibase.LabelExpression; import liquibase.Scope; import liquibase.change.Change; import liquibase.change.ChangeFactory; import liquibase.change.ChangeMetaData; import liquibase.changelog.ChangeLogParameters; import liquibase.changelog.ChangeSet; import liquibase.changelog.DatabaseChangeLog; import liquibase.database.Database; import liquibase.database.core.OracleDatabase; import liquibase.ext.ora.createSynonym.CreateSynonymChange; import liquibase.ext.ora.createSynonym.CreateSynonymStatement; import liquibase.ext.ora.testing.BaseTestCase; import liquibase.parser.ChangeLogParserFactory; import liquibase.resource.ClassLoaderResourceAccessor; import liquibase.resource.ResourceAccessor; import liquibase.sql.Sql; import liquibase.sqlgenerator.SqlGeneratorFactory; import liquibase.statement.SqlStatement; import org.junit.Before; import org.junit.Test;
package liquibase.ext.ora.synonym.createSynonym; public class CreateSynonymTest extends BaseTestCase { private static final String OBJECT_SCHEMA = "object_schema"; private static final String OBJECT_NAME = "object"; private static final String SYNONYM_NAME = "synonym_name"; private static final String SYNONYM_SCHEMA = "synonym_schema"; @Before public void setUp() throws Exception { changeLogFile = "liquibase/ext/ora/synonym/createSynonym/changelog.text.xml"; connectToDB(); cleanDB(); } @Test public void getChangeMetaData() {
// Path: src/main/java/liquibase/ext/ora/createSynonym/CreateSynonymChange.java // @DatabaseChange(name = "createSynonym", description = "Create synonym", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class CreateSynonymChange extends AbstractChange { // // private Boolean replace; // private Boolean isPublic; // private String objectName; // private String objectSchemaName; // // private String synonymName; // private String synonymSchemaName; // // public Boolean isReplace() { // return replace; // } // // public void setReplace(Boolean replace) { // this.replace = replace; // } // // public Boolean isPublic() { // return isPublic; // } // // public void setPublic(Boolean isPublic) { // this.isPublic = isPublic; // } // // public String getObjectName() { // return objectName; // } // // public void setObjectName(String objectName) { // this.objectName = objectName; // } // // public String getObjectSchemaName() { // return objectSchemaName; // } // // public void setObjectSchemaName(String objectSchemaName) { // this.objectSchemaName = objectSchemaName; // } // // public String getSynonymName() { // return synonymName; // } // // public void setSynonymName(String synonymName) { // this.synonymName = synonymName; // } // // public String getSynonymSchemaName() { // return synonymSchemaName; // } // // public void setSynonymSchemaName(String synonymSchemaName) { // this.synonymSchemaName = synonymSchemaName; // } // // @Override // public String getConfirmationMessage() { // return MessageFormat.format("Synonym {0} created", getSynonymName()); // } // // @Override // protected Change[] createInverses() { // DropSynonymChange inverse = new DropSynonymChange(); // inverse.setPublic(isPublic()); // inverse.setSynonymName(getSynonymName()); // inverse.setSynonymSchemaName(getSynonymSchemaName()); // return new Change[] { inverse }; // } // // @Override // public SqlStatement[] generateStatements(Database database) { // CreateSynonymStatement statement = new CreateSynonymStatement(); // // statement.setObjectName(getObjectName()); // statement.setObjectSchemaName(getObjectSchemaName()); // statement.setSynonymName(getSynonymName()); // statement.setSynonymSchemaName(getSynonymSchemaName()); // // statement.setReplace(isReplace()); // statement.setPublic(isPublic()); // return new SqlStatement[] { statement }; // } // // } // Path: src/test/java/liquibase/ext/ora/synonym/createSynonym/CreateSynonymTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.List; import liquibase.Contexts; import liquibase.LabelExpression; import liquibase.Scope; import liquibase.change.Change; import liquibase.change.ChangeFactory; import liquibase.change.ChangeMetaData; import liquibase.changelog.ChangeLogParameters; import liquibase.changelog.ChangeSet; import liquibase.changelog.DatabaseChangeLog; import liquibase.database.Database; import liquibase.database.core.OracleDatabase; import liquibase.ext.ora.createSynonym.CreateSynonymChange; import liquibase.ext.ora.createSynonym.CreateSynonymStatement; import liquibase.ext.ora.testing.BaseTestCase; import liquibase.parser.ChangeLogParserFactory; import liquibase.resource.ClassLoaderResourceAccessor; import liquibase.resource.ResourceAccessor; import liquibase.sql.Sql; import liquibase.sqlgenerator.SqlGeneratorFactory; import liquibase.statement.SqlStatement; import org.junit.Before; import org.junit.Test; package liquibase.ext.ora.synonym.createSynonym; public class CreateSynonymTest extends BaseTestCase { private static final String OBJECT_SCHEMA = "object_schema"; private static final String OBJECT_NAME = "object"; private static final String SYNONYM_NAME = "synonym_name"; private static final String SYNONYM_SCHEMA = "synonym_schema"; @Before public void setUp() throws Exception { changeLogFile = "liquibase/ext/ora/synonym/createSynonym/changelog.text.xml"; connectToDB(); cleanDB(); } @Test public void getChangeMetaData() {
CreateSynonymChange createSynonymChange = new CreateSynonymChange();
liquibase/liquibase-oracle
src/main/java/liquibase/ext/ora/enableconstraint/EnableConstraintChange.java
// Path: src/main/java/liquibase/ext/ora/check/CheckAttribute.java // public abstract class CheckAttribute extends AbstractChange { // // private String tableName; // private String tablespace; // private String schemaName; // private String constraintName; // private String condition; // private Boolean disable; // private Boolean deferrable; // private Boolean initiallyDeferred; // private Boolean rely; // private Boolean validate; // // public void setTableName(String tableName) { // this.tableName = tableName; // } // // public String getTableName() { // return tableName; // } // // public void setTablespace(String tablespace) { // this.tablespace = tablespace; // } // // public String getTablespace() { // return tablespace; // } // // public String getSchemaName() { // return schemaName; // } // // public void setSchemaName(String schemaName) { // this.schemaName = StringUtil.trimToNull(schemaName); // } // // public void setConstraintName(String constraintName) { // this.constraintName = constraintName; // } // // public String getConstraintName() { // return constraintName; // } // // public String getCondition() { // return condition; // } // // public void setCondition(String condition) { // this.condition = condition; // } // // public Boolean getDisable() { // return disable; // } // // public void setDisable(Boolean disable) { // this.disable = disable; // } // // public Boolean getDeferrable() { // return deferrable; // } // // public void setDeferrable(Boolean deferrable) { // this.deferrable = deferrable; // } // // public Boolean getInitiallyDeferred() { // return initiallyDeferred; // } // // public void setInitiallyDeferred(Boolean initiallyDeferred) { // this.initiallyDeferred = initiallyDeferred; // } // // public Boolean getValidate() { // return validate; // } // // public void setValidate(Boolean validate) { // this.validate = validate; // } // // public Boolean getRely() { // return rely; // } // // public void setRely(Boolean rely) { // this.rely = rely; // } // // public SqlStatement[] generateStatements(Database database) { // // return null; // } // // public String getConfirmationMessage() { // return null; // } // // } // // Path: src/main/java/liquibase/ext/ora/disableconstraint/DisableConstraintChange.java // @DatabaseChange(name="disableConstraint", description = "Disable constraint", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class DisableConstraintChange extends CheckAttribute { // // public DisableConstraintChange() { // } // // @Override // public SqlStatement[] generateStatements(Database database) { // // String schemaName = getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(); // // DisableConstraintStatement statement = new DisableConstraintStatement(schemaName, getTableName(), // getConstraintName()); // statement.setTablespace(getTablespace()); // return new SqlStatement[]{statement}; // } // // @Override // public String getConfirmationMessage() { // // return "constraint " + getConstraintName() + " DISABLED in " + getTableName(); // } // // @Override // protected Change[] createInverses() { // EnableConstraintChange inverse = new EnableConstraintChange(); // inverse.setSchemaName(getSchemaName()); // inverse.setTableName(getTableName()); // inverse.setConstraintName(getConstraintName()); // // return new Change[]{inverse}; // } // // }
import liquibase.change.Change; import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.database.Database; import liquibase.ext.ora.check.CheckAttribute; import liquibase.ext.ora.disableconstraint.DisableConstraintChange; import liquibase.statement.SqlStatement;
package liquibase.ext.ora.enableconstraint; @DatabaseChange(name="enableConstraint", description = "Enable constraint", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) public class EnableConstraintChange extends CheckAttribute { public EnableConstraintChange() { } @Override public SqlStatement[] generateStatements(Database database) { String schemaName = getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(); EnableConstraintStatement statement = new EnableConstraintStatement(getTableName(), schemaName, getConstraintName()); statement.setTablespace(getTablespace()); return new SqlStatement[]{statement}; } @Override public String getConfirmationMessage() { return "Constraint " + getConstraintName() + " ENABLED in " + getTableName(); } @Override protected Change[] createInverses() {
// Path: src/main/java/liquibase/ext/ora/check/CheckAttribute.java // public abstract class CheckAttribute extends AbstractChange { // // private String tableName; // private String tablespace; // private String schemaName; // private String constraintName; // private String condition; // private Boolean disable; // private Boolean deferrable; // private Boolean initiallyDeferred; // private Boolean rely; // private Boolean validate; // // public void setTableName(String tableName) { // this.tableName = tableName; // } // // public String getTableName() { // return tableName; // } // // public void setTablespace(String tablespace) { // this.tablespace = tablespace; // } // // public String getTablespace() { // return tablespace; // } // // public String getSchemaName() { // return schemaName; // } // // public void setSchemaName(String schemaName) { // this.schemaName = StringUtil.trimToNull(schemaName); // } // // public void setConstraintName(String constraintName) { // this.constraintName = constraintName; // } // // public String getConstraintName() { // return constraintName; // } // // public String getCondition() { // return condition; // } // // public void setCondition(String condition) { // this.condition = condition; // } // // public Boolean getDisable() { // return disable; // } // // public void setDisable(Boolean disable) { // this.disable = disable; // } // // public Boolean getDeferrable() { // return deferrable; // } // // public void setDeferrable(Boolean deferrable) { // this.deferrable = deferrable; // } // // public Boolean getInitiallyDeferred() { // return initiallyDeferred; // } // // public void setInitiallyDeferred(Boolean initiallyDeferred) { // this.initiallyDeferred = initiallyDeferred; // } // // public Boolean getValidate() { // return validate; // } // // public void setValidate(Boolean validate) { // this.validate = validate; // } // // public Boolean getRely() { // return rely; // } // // public void setRely(Boolean rely) { // this.rely = rely; // } // // public SqlStatement[] generateStatements(Database database) { // // return null; // } // // public String getConfirmationMessage() { // return null; // } // // } // // Path: src/main/java/liquibase/ext/ora/disableconstraint/DisableConstraintChange.java // @DatabaseChange(name="disableConstraint", description = "Disable constraint", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class DisableConstraintChange extends CheckAttribute { // // public DisableConstraintChange() { // } // // @Override // public SqlStatement[] generateStatements(Database database) { // // String schemaName = getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(); // // DisableConstraintStatement statement = new DisableConstraintStatement(schemaName, getTableName(), // getConstraintName()); // statement.setTablespace(getTablespace()); // return new SqlStatement[]{statement}; // } // // @Override // public String getConfirmationMessage() { // // return "constraint " + getConstraintName() + " DISABLED in " + getTableName(); // } // // @Override // protected Change[] createInverses() { // EnableConstraintChange inverse = new EnableConstraintChange(); // inverse.setSchemaName(getSchemaName()); // inverse.setTableName(getTableName()); // inverse.setConstraintName(getConstraintName()); // // return new Change[]{inverse}; // } // // } // Path: src/main/java/liquibase/ext/ora/enableconstraint/EnableConstraintChange.java import liquibase.change.Change; import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.database.Database; import liquibase.ext.ora.check.CheckAttribute; import liquibase.ext.ora.disableconstraint.DisableConstraintChange; import liquibase.statement.SqlStatement; package liquibase.ext.ora.enableconstraint; @DatabaseChange(name="enableConstraint", description = "Enable constraint", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) public class EnableConstraintChange extends CheckAttribute { public EnableConstraintChange() { } @Override public SqlStatement[] generateStatements(Database database) { String schemaName = getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(); EnableConstraintStatement statement = new EnableConstraintStatement(getTableName(), schemaName, getConstraintName()); statement.setTablespace(getTablespace()); return new SqlStatement[]{statement}; } @Override public String getConfirmationMessage() { return "Constraint " + getConstraintName() + " ENABLED in " + getTableName(); } @Override protected Change[] createInverses() {
DisableConstraintChange inverse = new DisableConstraintChange();
liquibase/liquibase-oracle
src/main/java/liquibase/ext/ora/disabletrigger/DisableTriggerChange.java
// Path: src/main/java/liquibase/ext/ora/enabletrigger/EnableTriggerChange.java // @DatabaseChange(name="enableTrigger", description = "Enable Trigger", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class EnableTriggerChange extends AbstractChange { // // private String schemaName; // private String triggerName; // // public String getSchemaName() { // return schemaName; // } // // public void setSchemaName(String schemaName) { // this.schemaName = schemaName; // } // // public String getTriggerName() { // return triggerName; // } // // public void setTriggerName(String triggerName) { // this.triggerName = triggerName; // } // // public String getConfirmationMessage() { // return "Trigger has been enabled."; // } // // @Override // protected Change[] createInverses() { // DisableTriggerChange inverse = new DisableTriggerChange(); // inverse.setSchemaName(getSchemaName()); // inverse.setTriggerName(getTriggerName()); // return new Change[]{inverse,}; // } // // public SqlStatement[] generateStatements(Database database) { // EnableTriggerStatement statement = new EnableTriggerStatement(getSchemaName(), getTriggerName()); // // return new SqlStatement[]{statement}; // } // // }
import liquibase.change.AbstractChange; import liquibase.change.Change; import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.database.Database; import liquibase.ext.ora.enabletrigger.EnableTriggerChange; import liquibase.statement.SqlStatement;
package liquibase.ext.ora.disabletrigger; @DatabaseChange(name="disableTrigger", description = "Disable Trigger", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) public class DisableTriggerChange extends AbstractChange { private String schemaName; private String triggerName; public String getSchemaName() { return schemaName; } public void setSchemaName(String schemaName) { this.schemaName = schemaName; } public String getTriggerName() { return triggerName; } public void setTriggerName(String triggerName) { this.triggerName = triggerName; } public String getConfirmationMessage() { return "Trigger has been disabled."; } @Override protected Change[] createInverses() {
// Path: src/main/java/liquibase/ext/ora/enabletrigger/EnableTriggerChange.java // @DatabaseChange(name="enableTrigger", description = "Enable Trigger", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class EnableTriggerChange extends AbstractChange { // // private String schemaName; // private String triggerName; // // public String getSchemaName() { // return schemaName; // } // // public void setSchemaName(String schemaName) { // this.schemaName = schemaName; // } // // public String getTriggerName() { // return triggerName; // } // // public void setTriggerName(String triggerName) { // this.triggerName = triggerName; // } // // public String getConfirmationMessage() { // return "Trigger has been enabled."; // } // // @Override // protected Change[] createInverses() { // DisableTriggerChange inverse = new DisableTriggerChange(); // inverse.setSchemaName(getSchemaName()); // inverse.setTriggerName(getTriggerName()); // return new Change[]{inverse,}; // } // // public SqlStatement[] generateStatements(Database database) { // EnableTriggerStatement statement = new EnableTriggerStatement(getSchemaName(), getTriggerName()); // // return new SqlStatement[]{statement}; // } // // } // Path: src/main/java/liquibase/ext/ora/disabletrigger/DisableTriggerChange.java import liquibase.change.AbstractChange; import liquibase.change.Change; import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.database.Database; import liquibase.ext.ora.enabletrigger.EnableTriggerChange; import liquibase.statement.SqlStatement; package liquibase.ext.ora.disabletrigger; @DatabaseChange(name="disableTrigger", description = "Disable Trigger", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) public class DisableTriggerChange extends AbstractChange { private String schemaName; private String triggerName; public String getSchemaName() { return schemaName; } public void setSchemaName(String schemaName) { this.schemaName = schemaName; } public String getTriggerName() { return triggerName; } public void setTriggerName(String triggerName) { this.triggerName = triggerName; } public String getConfirmationMessage() { return "Trigger has been disabled."; } @Override protected Change[] createInverses() {
EnableTriggerChange inverse = new EnableTriggerChange();
liquibase/liquibase-oracle
src/test/java/liquibase/ext/ora/synonym/dropSynonym/DropSynonymTest.java
// Path: src/main/java/liquibase/ext/ora/dropSynonym/DropSynonymChange.java // @DatabaseChange(name = "dropSynonym", description = "Drop synonym", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class DropSynonymChange extends AbstractChange { // // private Boolean isPublic = false; // private String synonymSchemaName; // private String synonymName; // private Boolean force; // // public Boolean isPublic() { // return isPublic; // } // // public void setPublic(Boolean isPublic) { // this.isPublic = isPublic; // } // // public String getSynonymName() { // return synonymName; // } // // public void setSynonymName(String synonymName) { // this.synonymName = synonymName; // } // // public String getSynonymSchemaName() { // return synonymSchemaName; // } // // public void setSynonymSchemaName(String synonymSchemaName) { // this.synonymSchemaName = synonymSchemaName; // } // // public Boolean isForce() { // return force; // } // // public void setForce(Boolean force) { // this.force = force; // } // // @Override // public String getConfirmationMessage() { // return MessageFormat.format("Synonym {0} dropped", getSynonymName()); // } // // @Override // public SqlStatement[] generateStatements(Database database) { // DropSynonymStatement statement = new DropSynonymStatement(); // statement.setForce(isForce()); // statement.setSynonymName(getSynonymName()); // statement.setSynonymSchemaName(getSynonymSchemaName()); // statement.setPublic(isPublic()); // return new SqlStatement[] { statement }; // } // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.List; import liquibase.Contexts; import liquibase.LabelExpression; import liquibase.Scope; import liquibase.change.Change; import liquibase.change.ChangeFactory; import liquibase.change.ChangeMetaData; import liquibase.changelog.ChangeLogParameters; import liquibase.changelog.ChangeSet; import liquibase.changelog.DatabaseChangeLog; import liquibase.database.Database; import liquibase.database.core.OracleDatabase; import liquibase.ext.ora.dropSynonym.DropSynonymChange; import liquibase.ext.ora.dropSynonym.DropSynonymStatement; import liquibase.ext.ora.testing.BaseTestCase; import liquibase.parser.ChangeLogParserFactory; import liquibase.resource.ClassLoaderResourceAccessor; import liquibase.resource.ResourceAccessor; import liquibase.sql.Sql; import liquibase.sqlgenerator.SqlGeneratorFactory; import liquibase.statement.SqlStatement; import org.junit.Before; import org.junit.Test;
package liquibase.ext.ora.synonym.dropSynonym; public class DropSynonymTest extends BaseTestCase { private static final String SYNONYM_NAME = "synonym_name"; private static final String SYNONYM_SCHEMA = "synonym_schema"; @Before public void setUp() throws Exception { changeLogFile = "liquibase/ext/ora/synonym/dropSynonym/changelog.text.xml"; connectToDB(); cleanDB(); } @Test public void getChangeMetaData() {
// Path: src/main/java/liquibase/ext/ora/dropSynonym/DropSynonymChange.java // @DatabaseChange(name = "dropSynonym", description = "Drop synonym", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class DropSynonymChange extends AbstractChange { // // private Boolean isPublic = false; // private String synonymSchemaName; // private String synonymName; // private Boolean force; // // public Boolean isPublic() { // return isPublic; // } // // public void setPublic(Boolean isPublic) { // this.isPublic = isPublic; // } // // public String getSynonymName() { // return synonymName; // } // // public void setSynonymName(String synonymName) { // this.synonymName = synonymName; // } // // public String getSynonymSchemaName() { // return synonymSchemaName; // } // // public void setSynonymSchemaName(String synonymSchemaName) { // this.synonymSchemaName = synonymSchemaName; // } // // public Boolean isForce() { // return force; // } // // public void setForce(Boolean force) { // this.force = force; // } // // @Override // public String getConfirmationMessage() { // return MessageFormat.format("Synonym {0} dropped", getSynonymName()); // } // // @Override // public SqlStatement[] generateStatements(Database database) { // DropSynonymStatement statement = new DropSynonymStatement(); // statement.setForce(isForce()); // statement.setSynonymName(getSynonymName()); // statement.setSynonymSchemaName(getSynonymSchemaName()); // statement.setPublic(isPublic()); // return new SqlStatement[] { statement }; // } // // } // Path: src/test/java/liquibase/ext/ora/synonym/dropSynonym/DropSynonymTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.List; import liquibase.Contexts; import liquibase.LabelExpression; import liquibase.Scope; import liquibase.change.Change; import liquibase.change.ChangeFactory; import liquibase.change.ChangeMetaData; import liquibase.changelog.ChangeLogParameters; import liquibase.changelog.ChangeSet; import liquibase.changelog.DatabaseChangeLog; import liquibase.database.Database; import liquibase.database.core.OracleDatabase; import liquibase.ext.ora.dropSynonym.DropSynonymChange; import liquibase.ext.ora.dropSynonym.DropSynonymStatement; import liquibase.ext.ora.testing.BaseTestCase; import liquibase.parser.ChangeLogParserFactory; import liquibase.resource.ClassLoaderResourceAccessor; import liquibase.resource.ResourceAccessor; import liquibase.sql.Sql; import liquibase.sqlgenerator.SqlGeneratorFactory; import liquibase.statement.SqlStatement; import org.junit.Before; import org.junit.Test; package liquibase.ext.ora.synonym.dropSynonym; public class DropSynonymTest extends BaseTestCase { private static final String SYNONYM_NAME = "synonym_name"; private static final String SYNONYM_SCHEMA = "synonym_schema"; @Before public void setUp() throws Exception { changeLogFile = "liquibase/ext/ora/synonym/dropSynonym/changelog.text.xml"; connectToDB(); cleanDB(); } @Test public void getChangeMetaData() {
DropSynonymChange change = new DropSynonymChange();
liquibase/liquibase-oracle
src/main/java/liquibase/ext/ora/disableconstraint/DisableConstraintChange.java
// Path: src/main/java/liquibase/ext/ora/check/CheckAttribute.java // public abstract class CheckAttribute extends AbstractChange { // // private String tableName; // private String tablespace; // private String schemaName; // private String constraintName; // private String condition; // private Boolean disable; // private Boolean deferrable; // private Boolean initiallyDeferred; // private Boolean rely; // private Boolean validate; // // public void setTableName(String tableName) { // this.tableName = tableName; // } // // public String getTableName() { // return tableName; // } // // public void setTablespace(String tablespace) { // this.tablespace = tablespace; // } // // public String getTablespace() { // return tablespace; // } // // public String getSchemaName() { // return schemaName; // } // // public void setSchemaName(String schemaName) { // this.schemaName = StringUtil.trimToNull(schemaName); // } // // public void setConstraintName(String constraintName) { // this.constraintName = constraintName; // } // // public String getConstraintName() { // return constraintName; // } // // public String getCondition() { // return condition; // } // // public void setCondition(String condition) { // this.condition = condition; // } // // public Boolean getDisable() { // return disable; // } // // public void setDisable(Boolean disable) { // this.disable = disable; // } // // public Boolean getDeferrable() { // return deferrable; // } // // public void setDeferrable(Boolean deferrable) { // this.deferrable = deferrable; // } // // public Boolean getInitiallyDeferred() { // return initiallyDeferred; // } // // public void setInitiallyDeferred(Boolean initiallyDeferred) { // this.initiallyDeferred = initiallyDeferred; // } // // public Boolean getValidate() { // return validate; // } // // public void setValidate(Boolean validate) { // this.validate = validate; // } // // public Boolean getRely() { // return rely; // } // // public void setRely(Boolean rely) { // this.rely = rely; // } // // public SqlStatement[] generateStatements(Database database) { // // return null; // } // // public String getConfirmationMessage() { // return null; // } // // } // // Path: src/main/java/liquibase/ext/ora/enableconstraint/EnableConstraintChange.java // @DatabaseChange(name="enableConstraint", description = "Enable constraint", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class EnableConstraintChange extends CheckAttribute { // // public EnableConstraintChange() { // } // // @Override // public SqlStatement[] generateStatements(Database database) { // // String schemaName = getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(); // // EnableConstraintStatement statement = new EnableConstraintStatement(getTableName(), schemaName, getConstraintName()); // statement.setTablespace(getTablespace()); // // return new SqlStatement[]{statement}; // } // // @Override // public String getConfirmationMessage() { // return "Constraint " + getConstraintName() + " ENABLED in " + getTableName(); // } // // @Override // protected Change[] createInverses() { // DisableConstraintChange inverse = new DisableConstraintChange(); // inverse.setSchemaName(getSchemaName()); // inverse.setTableName(getTableName()); // inverse.setConstraintName(getConstraintName()); // // return new Change[]{inverse}; // } // // }
import liquibase.change.Change; import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.database.Database; import liquibase.ext.ora.check.CheckAttribute; import liquibase.ext.ora.enableconstraint.EnableConstraintChange; import liquibase.statement.SqlStatement;
package liquibase.ext.ora.disableconstraint; @DatabaseChange(name="disableConstraint", description = "Disable constraint", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) public class DisableConstraintChange extends CheckAttribute { public DisableConstraintChange() { } @Override public SqlStatement[] generateStatements(Database database) { String schemaName = getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(); DisableConstraintStatement statement = new DisableConstraintStatement(schemaName, getTableName(), getConstraintName()); statement.setTablespace(getTablespace()); return new SqlStatement[]{statement}; } @Override public String getConfirmationMessage() { return "constraint " + getConstraintName() + " DISABLED in " + getTableName(); } @Override protected Change[] createInverses() {
// Path: src/main/java/liquibase/ext/ora/check/CheckAttribute.java // public abstract class CheckAttribute extends AbstractChange { // // private String tableName; // private String tablespace; // private String schemaName; // private String constraintName; // private String condition; // private Boolean disable; // private Boolean deferrable; // private Boolean initiallyDeferred; // private Boolean rely; // private Boolean validate; // // public void setTableName(String tableName) { // this.tableName = tableName; // } // // public String getTableName() { // return tableName; // } // // public void setTablespace(String tablespace) { // this.tablespace = tablespace; // } // // public String getTablespace() { // return tablespace; // } // // public String getSchemaName() { // return schemaName; // } // // public void setSchemaName(String schemaName) { // this.schemaName = StringUtil.trimToNull(schemaName); // } // // public void setConstraintName(String constraintName) { // this.constraintName = constraintName; // } // // public String getConstraintName() { // return constraintName; // } // // public String getCondition() { // return condition; // } // // public void setCondition(String condition) { // this.condition = condition; // } // // public Boolean getDisable() { // return disable; // } // // public void setDisable(Boolean disable) { // this.disable = disable; // } // // public Boolean getDeferrable() { // return deferrable; // } // // public void setDeferrable(Boolean deferrable) { // this.deferrable = deferrable; // } // // public Boolean getInitiallyDeferred() { // return initiallyDeferred; // } // // public void setInitiallyDeferred(Boolean initiallyDeferred) { // this.initiallyDeferred = initiallyDeferred; // } // // public Boolean getValidate() { // return validate; // } // // public void setValidate(Boolean validate) { // this.validate = validate; // } // // public Boolean getRely() { // return rely; // } // // public void setRely(Boolean rely) { // this.rely = rely; // } // // public SqlStatement[] generateStatements(Database database) { // // return null; // } // // public String getConfirmationMessage() { // return null; // } // // } // // Path: src/main/java/liquibase/ext/ora/enableconstraint/EnableConstraintChange.java // @DatabaseChange(name="enableConstraint", description = "Enable constraint", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) // public class EnableConstraintChange extends CheckAttribute { // // public EnableConstraintChange() { // } // // @Override // public SqlStatement[] generateStatements(Database database) { // // String schemaName = getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(); // // EnableConstraintStatement statement = new EnableConstraintStatement(getTableName(), schemaName, getConstraintName()); // statement.setTablespace(getTablespace()); // // return new SqlStatement[]{statement}; // } // // @Override // public String getConfirmationMessage() { // return "Constraint " + getConstraintName() + " ENABLED in " + getTableName(); // } // // @Override // protected Change[] createInverses() { // DisableConstraintChange inverse = new DisableConstraintChange(); // inverse.setSchemaName(getSchemaName()); // inverse.setTableName(getTableName()); // inverse.setConstraintName(getConstraintName()); // // return new Change[]{inverse}; // } // // } // Path: src/main/java/liquibase/ext/ora/disableconstraint/DisableConstraintChange.java import liquibase.change.Change; import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.database.Database; import liquibase.ext.ora.check.CheckAttribute; import liquibase.ext.ora.enableconstraint.EnableConstraintChange; import liquibase.statement.SqlStatement; package liquibase.ext.ora.disableconstraint; @DatabaseChange(name="disableConstraint", description = "Disable constraint", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) public class DisableConstraintChange extends CheckAttribute { public DisableConstraintChange() { } @Override public SqlStatement[] generateStatements(Database database) { String schemaName = getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(); DisableConstraintStatement statement = new DisableConstraintStatement(schemaName, getTableName(), getConstraintName()); statement.setTablespace(getTablespace()); return new SqlStatement[]{statement}; } @Override public String getConfirmationMessage() { return "constraint " + getConstraintName() + " DISABLED in " + getTableName(); } @Override protected Change[] createInverses() {
EnableConstraintChange inverse = new EnableConstraintChange();
MiWy/CourierApplication
app/src/main/java/com/tryouts/courierapplication/fragments/CurrentOrderFragment.java
// Path: app/src/main/java/com/tryouts/courierapplication/presenters/CurrentOrderPresenter.java // public class CurrentOrderPresenter { // // private CurrentOrderFragment mView; // private CurrentOrderInteractor mInteractor; // // public CurrentOrderPresenter(CurrentOrderFragment fragment) { // this.mView = fragment; // this.mInteractor = new CurrentOrderInteractor(this); // setInteractorContext(); // } // // /** // * Detaches this presenter from the view. // */ // public void detachView() { // this.mView = null; // } // // /** // * Initial method. // * Informs the view to show progress dialog while loading the data. // * Sends request to interactor for data about current order, providing // * interactor with order's timestamp. // * Sends request to interactor to check whether user is a courier. // */ // public void initialize() { // mView.showProgressDialog(); // mInteractor.getOrderData(mView.getOrderTimeStamp()); // mInteractor.checkWhetherLoggedUserIsCourier(); // } // // /** // * Upon receiving order strings, sends it to view in order to display them to the user. // * @param from // * @param to // * @param distance // * @param phone // * @param date // * @param additionalOne // * @param additionalTwo // * @param additionalThree // */ // public void onOrderStringsReceived(String from, String to, String distance, String phone, // String date, boolean additionalOne, boolean additionalTwo, // boolean additionalThree) { // mView.setViewsWithData(from, to, distance, phone, date, additionalOne, // additionalTwo, additionalThree); // mView.hideProgressDialog(); // } // // /** // * Informs view that it needs to inflate courier buttons // */ // public void inflateCourierButtons() { // mView.onInflateCourierButtonsCall(); // } // // /** // * Informs interactor that one of the (whichButton) courier buttons was pressed. // */ // public void onCourierButtonClick(int whichButton) { // mInteractor.checkIfSureToChangeOrderStatus(mView.getFragmentContext(), // mView.getOrderTimeStamp(), whichButton); // } // /** // * Receives a call when alertdialog is ready for the view. // * Informs the view to show alertdialog from the interactor. // */ // public void onCreatedAlertDialog() { // mView.showDialog(mInteractor.getAlertDialog()); // } // // /** // * Receives a call from the interactor when the order is either canceled or finished. // * Informs the view in order for order's timestamp removal from the sharedpreferences. // */ // public void removeOrderFromSharedPreferences() { // mView.removeOrderFromSharedPreferences(); // } // // /** // * Receives a call from the interactor when toast should be displayed. // * Specifies what kind of toast it should be with @param. // * @param whichType // */ // public void sendToast(String whichType) { // mView.makeToast(whichType); // } // // public void hideProgressDialog() { // mView.hideProgressDialog(); // } // // /** // * Sends context to interactor // */ // private void setInteractorContext() { // mInteractor.setInteractorContext(mView.getContext()); // } // // // }
import android.app.ProgressDialog; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.app.AlertDialog; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.CheckedTextView; import android.widget.TextView; import android.widget.Toast; import com.tryouts.courierapplication.presenters.CurrentOrderPresenter; import com.tryouts.courierapplication.R;
package com.tryouts.courierapplication.fragments; public class CurrentOrderFragment extends Fragment { private static final String PREFERENCES_NAME = "SharePref"; private static final String PREFERENCES_TEXT_FIELD = "orderTimeStamp"; private static final String PREFERENCES_EMPTY = "empty"; private String orderTimeStamp; private SharedPreferences mSharedPreferences; private TextView mDateTextView; private TextView mFromTextView; private TextView mToTextView; private TextView mDistanceTextView; private TextView mPhoneTextView; private CheckedTextView mFirstAdditionalServiceTextView; private CheckedTextView mSecondAdditionalServiceTextView; private CheckedTextView mThirdAdditionalServiceTextView; private ProgressDialog mProgressDialog;
// Path: app/src/main/java/com/tryouts/courierapplication/presenters/CurrentOrderPresenter.java // public class CurrentOrderPresenter { // // private CurrentOrderFragment mView; // private CurrentOrderInteractor mInteractor; // // public CurrentOrderPresenter(CurrentOrderFragment fragment) { // this.mView = fragment; // this.mInteractor = new CurrentOrderInteractor(this); // setInteractorContext(); // } // // /** // * Detaches this presenter from the view. // */ // public void detachView() { // this.mView = null; // } // // /** // * Initial method. // * Informs the view to show progress dialog while loading the data. // * Sends request to interactor for data about current order, providing // * interactor with order's timestamp. // * Sends request to interactor to check whether user is a courier. // */ // public void initialize() { // mView.showProgressDialog(); // mInteractor.getOrderData(mView.getOrderTimeStamp()); // mInteractor.checkWhetherLoggedUserIsCourier(); // } // // /** // * Upon receiving order strings, sends it to view in order to display them to the user. // * @param from // * @param to // * @param distance // * @param phone // * @param date // * @param additionalOne // * @param additionalTwo // * @param additionalThree // */ // public void onOrderStringsReceived(String from, String to, String distance, String phone, // String date, boolean additionalOne, boolean additionalTwo, // boolean additionalThree) { // mView.setViewsWithData(from, to, distance, phone, date, additionalOne, // additionalTwo, additionalThree); // mView.hideProgressDialog(); // } // // /** // * Informs view that it needs to inflate courier buttons // */ // public void inflateCourierButtons() { // mView.onInflateCourierButtonsCall(); // } // // /** // * Informs interactor that one of the (whichButton) courier buttons was pressed. // */ // public void onCourierButtonClick(int whichButton) { // mInteractor.checkIfSureToChangeOrderStatus(mView.getFragmentContext(), // mView.getOrderTimeStamp(), whichButton); // } // /** // * Receives a call when alertdialog is ready for the view. // * Informs the view to show alertdialog from the interactor. // */ // public void onCreatedAlertDialog() { // mView.showDialog(mInteractor.getAlertDialog()); // } // // /** // * Receives a call from the interactor when the order is either canceled or finished. // * Informs the view in order for order's timestamp removal from the sharedpreferences. // */ // public void removeOrderFromSharedPreferences() { // mView.removeOrderFromSharedPreferences(); // } // // /** // * Receives a call from the interactor when toast should be displayed. // * Specifies what kind of toast it should be with @param. // * @param whichType // */ // public void sendToast(String whichType) { // mView.makeToast(whichType); // } // // public void hideProgressDialog() { // mView.hideProgressDialog(); // } // // /** // * Sends context to interactor // */ // private void setInteractorContext() { // mInteractor.setInteractorContext(mView.getContext()); // } // // // } // Path: app/src/main/java/com/tryouts/courierapplication/fragments/CurrentOrderFragment.java import android.app.ProgressDialog; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.app.AlertDialog; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.CheckedTextView; import android.widget.TextView; import android.widget.Toast; import com.tryouts.courierapplication.presenters.CurrentOrderPresenter; import com.tryouts.courierapplication.R; package com.tryouts.courierapplication.fragments; public class CurrentOrderFragment extends Fragment { private static final String PREFERENCES_NAME = "SharePref"; private static final String PREFERENCES_TEXT_FIELD = "orderTimeStamp"; private static final String PREFERENCES_EMPTY = "empty"; private String orderTimeStamp; private SharedPreferences mSharedPreferences; private TextView mDateTextView; private TextView mFromTextView; private TextView mToTextView; private TextView mDistanceTextView; private TextView mPhoneTextView; private CheckedTextView mFirstAdditionalServiceTextView; private CheckedTextView mSecondAdditionalServiceTextView; private CheckedTextView mThirdAdditionalServiceTextView; private ProgressDialog mProgressDialog;
private CurrentOrderPresenter mPresenter;
MiWy/CourierApplication
app/src/main/java/com/tryouts/courierapplication/presenters/PricelistPresenter.java
// Path: app/src/main/java/com/tryouts/courierapplication/fragments/PricelistFragment.java // public class PricelistFragment extends Fragment { // // private RecyclerView mRecyclerView; // private PricelistPresenter mPresenter; // // public PricelistFragment() { // } // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // } // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, // Bundle savedInstanceState) { // return inflater.inflate(R.layout.fragment_pricelist, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // mRecyclerView = (RecyclerView) view.findViewById(R.id.pricelist_recyclerview); // // mPresenter = new PricelistPresenter(this); // mPresenter.initialize(); // } // // public RecyclerView getRecyclerView() { // return mRecyclerView; // } // // public Context getContextFromFragment() { // return getContext(); // } // // @Override // public void onDestroy() { // super.onDestroy(); // mPresenter.detachView(); // } // // } // // Path: app/src/main/java/com/tryouts/courierapplication/interactors/PricelistInteractor.java // public class PricelistInteractor { // // private Context mContext; // // public PricelistInteractor(PricelistPresenter presenter) { // PricelistPresenter mPresenter = presenter; // } // // /** // * Prepares List with priceitems in correct order. // * Dummy list within PriceList.class. // * @return // */ // private List<PriceItem> preparePrices() { // PriceList priceList = PriceList.get(); // return priceList.getPrices(); // } // // public void onPrepareRecyclerView(RecyclerView recyclerView) { // recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); // recyclerView.setAdapter(prepareAdapter()); // } // // /** // * Called from this interactor. // * Creates and returns an adapter (calls getPriceItemList to prepare data) // * @return // */ // private BasePriceAdapterByGenre prepareAdapter() { // return new BasePriceAdapterByGenre(getPriceItemList()); // } // // /** // * Called from this presenter. // * Retrieves priceitems list from PricelistInteractor. // * @return // */ // private List<PriceItem> getPriceItemList() { // return preparePrices(); // } // // public void setContext(Context context) { // this.mContext = context; // } // // private Context getContext() { // return mContext; // } // // // }
import com.tryouts.courierapplication.fragments.PricelistFragment; import com.tryouts.courierapplication.interactors.PricelistInteractor;
package com.tryouts.courierapplication.presenters; public class PricelistPresenter { private PricelistInteractor mModel;
// Path: app/src/main/java/com/tryouts/courierapplication/fragments/PricelistFragment.java // public class PricelistFragment extends Fragment { // // private RecyclerView mRecyclerView; // private PricelistPresenter mPresenter; // // public PricelistFragment() { // } // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // } // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, // Bundle savedInstanceState) { // return inflater.inflate(R.layout.fragment_pricelist, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // mRecyclerView = (RecyclerView) view.findViewById(R.id.pricelist_recyclerview); // // mPresenter = new PricelistPresenter(this); // mPresenter.initialize(); // } // // public RecyclerView getRecyclerView() { // return mRecyclerView; // } // // public Context getContextFromFragment() { // return getContext(); // } // // @Override // public void onDestroy() { // super.onDestroy(); // mPresenter.detachView(); // } // // } // // Path: app/src/main/java/com/tryouts/courierapplication/interactors/PricelistInteractor.java // public class PricelistInteractor { // // private Context mContext; // // public PricelistInteractor(PricelistPresenter presenter) { // PricelistPresenter mPresenter = presenter; // } // // /** // * Prepares List with priceitems in correct order. // * Dummy list within PriceList.class. // * @return // */ // private List<PriceItem> preparePrices() { // PriceList priceList = PriceList.get(); // return priceList.getPrices(); // } // // public void onPrepareRecyclerView(RecyclerView recyclerView) { // recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); // recyclerView.setAdapter(prepareAdapter()); // } // // /** // * Called from this interactor. // * Creates and returns an adapter (calls getPriceItemList to prepare data) // * @return // */ // private BasePriceAdapterByGenre prepareAdapter() { // return new BasePriceAdapterByGenre(getPriceItemList()); // } // // /** // * Called from this presenter. // * Retrieves priceitems list from PricelistInteractor. // * @return // */ // private List<PriceItem> getPriceItemList() { // return preparePrices(); // } // // public void setContext(Context context) { // this.mContext = context; // } // // private Context getContext() { // return mContext; // } // // // } // Path: app/src/main/java/com/tryouts/courierapplication/presenters/PricelistPresenter.java import com.tryouts.courierapplication.fragments.PricelistFragment; import com.tryouts.courierapplication.interactors.PricelistInteractor; package com.tryouts.courierapplication.presenters; public class PricelistPresenter { private PricelistInteractor mModel;
private PricelistFragment mView;
MiWy/CourierApplication
app/src/main/java/com/tryouts/courierapplication/RegisterActivity.java
// Path: app/src/main/java/com/tryouts/courierapplication/items/User.java // public class User { // // private String mEmail; // private String mUid; // private String mName; // private String mPhone; // private String mRole; // private String mInstanceId; // // public User() { // } // // public User(String email) { // this.mEmail = email; // } // // public User(String email, String role) { // this.mEmail = email; // this.mRole = role; // } // // public String getEmail() { // return mEmail; // } // // public String getRole() { // return mRole; // } // // public void setEmail(String email) { // mEmail = email; // } // // public void setRole(String role) { // mRole = role; // } // // public String getName() { // return mName; // } // // public void setName(String name) { // mName = name; // } // // public String getPhone() { // return mPhone; // } // // public void setPhone(String phone) { // mPhone = phone; // } // // public String getUid() { // return mUid; // } // // public void setUid(String uid) { // mUid = uid; // } // // public String getInstanceId() { // return mInstanceId; // } // // public void setInstanceId(String instanceId) { // mInstanceId = instanceId; // } // }
import android.app.ProgressDialog; import android.content.Intent; import android.support.annotation.NonNull; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.TextUtils; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.OnFailureListener; import com.google.android.gms.tasks.Task; import com.google.firebase.auth.AuthResult; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException; import com.google.firebase.auth.FirebaseAuthUserCollisionException; import com.google.firebase.auth.FirebaseAuthWeakPasswordException; import com.google.firebase.auth.FirebaseUser; import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; import com.google.firebase.database.ValueEventListener; import com.tryouts.courierapplication.items.User;
Toast.makeText(this,getString(R.string.login_hint_email), Toast.LENGTH_LONG).show(); return; } if(TextUtils.isEmpty(mPass)){ Toast.makeText(this,getString(R.string.login_hint_password),Toast.LENGTH_LONG).show(); return; } if(TextUtils.isEmpty(mPhone) || mPhone.length()<9){ Toast.makeText(this,getString(R.string.hint_phone),Toast.LENGTH_SHORT).show(); return; } if(TextUtils.isEmpty(mName)){ Toast.makeText(this,getString(R.string.hint_name),Toast.LENGTH_SHORT).show(); return; } // If the email and password are not empty // display progress dialog mProgressDialog.setMessage(getString(R.string.login_progressbar_register)); mProgressDialog.show(); // Create a new User mAuth.createUserWithEmailAndPassword(mEmail, mPass) .addOnCompleteListener(new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if(task.isSuccessful()) { final DatabaseReference mDatabaseReference = FirebaseDatabase.getInstance().getReference(); mDatabaseReference.child("users").child(mAuth.getCurrentUser().getUid()) .addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) {
// Path: app/src/main/java/com/tryouts/courierapplication/items/User.java // public class User { // // private String mEmail; // private String mUid; // private String mName; // private String mPhone; // private String mRole; // private String mInstanceId; // // public User() { // } // // public User(String email) { // this.mEmail = email; // } // // public User(String email, String role) { // this.mEmail = email; // this.mRole = role; // } // // public String getEmail() { // return mEmail; // } // // public String getRole() { // return mRole; // } // // public void setEmail(String email) { // mEmail = email; // } // // public void setRole(String role) { // mRole = role; // } // // public String getName() { // return mName; // } // // public void setName(String name) { // mName = name; // } // // public String getPhone() { // return mPhone; // } // // public void setPhone(String phone) { // mPhone = phone; // } // // public String getUid() { // return mUid; // } // // public void setUid(String uid) { // mUid = uid; // } // // public String getInstanceId() { // return mInstanceId; // } // // public void setInstanceId(String instanceId) { // mInstanceId = instanceId; // } // } // Path: app/src/main/java/com/tryouts/courierapplication/RegisterActivity.java import android.app.ProgressDialog; import android.content.Intent; import android.support.annotation.NonNull; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.TextUtils; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.OnFailureListener; import com.google.android.gms.tasks.Task; import com.google.firebase.auth.AuthResult; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException; import com.google.firebase.auth.FirebaseAuthUserCollisionException; import com.google.firebase.auth.FirebaseAuthWeakPasswordException; import com.google.firebase.auth.FirebaseUser; import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; import com.google.firebase.database.ValueEventListener; import com.tryouts.courierapplication.items.User; Toast.makeText(this,getString(R.string.login_hint_email), Toast.LENGTH_LONG).show(); return; } if(TextUtils.isEmpty(mPass)){ Toast.makeText(this,getString(R.string.login_hint_password),Toast.LENGTH_LONG).show(); return; } if(TextUtils.isEmpty(mPhone) || mPhone.length()<9){ Toast.makeText(this,getString(R.string.hint_phone),Toast.LENGTH_SHORT).show(); return; } if(TextUtils.isEmpty(mName)){ Toast.makeText(this,getString(R.string.hint_name),Toast.LENGTH_SHORT).show(); return; } // If the email and password are not empty // display progress dialog mProgressDialog.setMessage(getString(R.string.login_progressbar_register)); mProgressDialog.show(); // Create a new User mAuth.createUserWithEmailAndPassword(mEmail, mPass) .addOnCompleteListener(new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if(task.isSuccessful()) { final DatabaseReference mDatabaseReference = FirebaseDatabase.getInstance().getReference(); mDatabaseReference.child("users").child(mAuth.getCurrentUser().getUid()) .addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) {
User mUser = new User();
MiWy/CourierApplication
app/src/main/java/com/tryouts/courierapplication/fragments/NewOrderFragment.java
// Path: app/src/main/java/com/tryouts/courierapplication/presenters/NewOrderPresenter.java // public class NewOrderPresenter { // // private NewOrderInteractor mModel; // private NewOrderFragment view; // private static final int RESULT_OK = -1; // private static final int RESULT_CANCELED = 0; // public static final int RESULT_ERROR = 2; // private static final int MODE_FULLSCREEN = 1; // private static final int MODE_OVERLAY = 2; // // public NewOrderPresenter(NewOrderFragment view) { // this.mModel = new NewOrderInteractor(this); // this.view = view; // } // // public void createListenerForCall() { // if(mModel.isOrderReadyToSubmit()) { // mModel.createAndSendOrderToDb(); // } else { // // We dont have all details needed for order's submission. // view.makeToast(mModel.getNotReadyString()); // } // } // // /** // * Data received from Google Places // * // */ // public void onActivityResultCalled(int requestCode, int resultCode) { // if(requestCode == 1) { // if(resultCode == RESULT_OK) { // mModel.onActivityResultSuccesful(1, view.getOnActivityResultIntent()); // } else if(resultCode == RESULT_ERROR) { // view.makeToast(mModel.getStringFromXml(RESULT_ERROR)); // } else if(resultCode == RESULT_CANCELED) { // // The user cancelled the operation. // } // } else if(requestCode == 2) { // if(resultCode == RESULT_OK) { // mModel.onActivityResultSuccesful(2, view.getOnActivityResultIntent()); // } else if(resultCode == RESULT_ERROR) { // view.makeToast(mModel.getStringFromXml(RESULT_ERROR)); // } else if(resultCode == RESULT_CANCELED) { // // The user cancelled the operation. // } // } // } // // public void onReadyFromText(String addressFrom) { // view.setFromText(addressFrom); // } // // public void onReadyToText(String addressTo) { // view.setToText(addressTo); // } // /** // * Methods for Google Maps and related views management // */ // // public void setMapView() { // view.setMapClear(); // if(!mModel.areFromToReceived()) { // view.moveCameraTo(mModel.getDefaultLatitude(), mModel.getDefaultLongitude()); // } else { // mModel.prepareMapVariables(); // } // } // // public void onMapPolylineReady() { // view.onMapPolylineAdded(mModel.getPolylineOptions()); // } // // public void onCameraUpdateReady() { // view.animateCamera(mModel.getCameraUpdate()); // } // // public void setGMapsUrl(String gMapsKey) { // mModel.setGMapKey(gMapsKey); // } // // public void onMapAsyncCall() { // view.mapAsyncCall(); // } // // public void onMapUpdatedShowDistance() { // view.setDistanceView(mModel.getDistanceString()); // } // // /** // * Methods for listeners management // */ // // public void createListenerForCalculate() { // onMapAsyncCall(); // } // // public void createListenerForAdditionalServices() { // view.showAlertDialog(mModel.sendAdditionalAlertDialog()); // } // // public void createListenerForPlaceAutocompleteCall(int requestCode) { // mModel.onPlaceAutocompleteCall(requestCode); // } // // public void sendFragmentActivityToInteractor() { // mModel.setFragmentActivity(view.getParentActivity()); // } // // public void onReadyStartActivityForResult(int requestCode) { // view.startActivityForResult(mModel.getPlacesAutocompleteIntent(), requestCode); // } // // public void detachView() { // view = null; // } // // // // }
import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v7.app.AlertDialog; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import com.google.android.gms.maps.CameraUpdate; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.MapView; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.model.CameraPosition; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.LatLngBounds; import com.google.android.gms.maps.model.PolylineOptions; import com.tryouts.courierapplication.presenters.NewOrderPresenter; import com.tryouts.courierapplication.R;
package com.tryouts.courierapplication.fragments; public class NewOrderFragment extends Fragment implements OnMapReadyCallback { private MapView mMapView;
// Path: app/src/main/java/com/tryouts/courierapplication/presenters/NewOrderPresenter.java // public class NewOrderPresenter { // // private NewOrderInteractor mModel; // private NewOrderFragment view; // private static final int RESULT_OK = -1; // private static final int RESULT_CANCELED = 0; // public static final int RESULT_ERROR = 2; // private static final int MODE_FULLSCREEN = 1; // private static final int MODE_OVERLAY = 2; // // public NewOrderPresenter(NewOrderFragment view) { // this.mModel = new NewOrderInteractor(this); // this.view = view; // } // // public void createListenerForCall() { // if(mModel.isOrderReadyToSubmit()) { // mModel.createAndSendOrderToDb(); // } else { // // We dont have all details needed for order's submission. // view.makeToast(mModel.getNotReadyString()); // } // } // // /** // * Data received from Google Places // * // */ // public void onActivityResultCalled(int requestCode, int resultCode) { // if(requestCode == 1) { // if(resultCode == RESULT_OK) { // mModel.onActivityResultSuccesful(1, view.getOnActivityResultIntent()); // } else if(resultCode == RESULT_ERROR) { // view.makeToast(mModel.getStringFromXml(RESULT_ERROR)); // } else if(resultCode == RESULT_CANCELED) { // // The user cancelled the operation. // } // } else if(requestCode == 2) { // if(resultCode == RESULT_OK) { // mModel.onActivityResultSuccesful(2, view.getOnActivityResultIntent()); // } else if(resultCode == RESULT_ERROR) { // view.makeToast(mModel.getStringFromXml(RESULT_ERROR)); // } else if(resultCode == RESULT_CANCELED) { // // The user cancelled the operation. // } // } // } // // public void onReadyFromText(String addressFrom) { // view.setFromText(addressFrom); // } // // public void onReadyToText(String addressTo) { // view.setToText(addressTo); // } // /** // * Methods for Google Maps and related views management // */ // // public void setMapView() { // view.setMapClear(); // if(!mModel.areFromToReceived()) { // view.moveCameraTo(mModel.getDefaultLatitude(), mModel.getDefaultLongitude()); // } else { // mModel.prepareMapVariables(); // } // } // // public void onMapPolylineReady() { // view.onMapPolylineAdded(mModel.getPolylineOptions()); // } // // public void onCameraUpdateReady() { // view.animateCamera(mModel.getCameraUpdate()); // } // // public void setGMapsUrl(String gMapsKey) { // mModel.setGMapKey(gMapsKey); // } // // public void onMapAsyncCall() { // view.mapAsyncCall(); // } // // public void onMapUpdatedShowDistance() { // view.setDistanceView(mModel.getDistanceString()); // } // // /** // * Methods for listeners management // */ // // public void createListenerForCalculate() { // onMapAsyncCall(); // } // // public void createListenerForAdditionalServices() { // view.showAlertDialog(mModel.sendAdditionalAlertDialog()); // } // // public void createListenerForPlaceAutocompleteCall(int requestCode) { // mModel.onPlaceAutocompleteCall(requestCode); // } // // public void sendFragmentActivityToInteractor() { // mModel.setFragmentActivity(view.getParentActivity()); // } // // public void onReadyStartActivityForResult(int requestCode) { // view.startActivityForResult(mModel.getPlacesAutocompleteIntent(), requestCode); // } // // public void detachView() { // view = null; // } // // // // } // Path: app/src/main/java/com/tryouts/courierapplication/fragments/NewOrderFragment.java import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v7.app.AlertDialog; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import com.google.android.gms.maps.CameraUpdate; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.MapView; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.model.CameraPosition; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.LatLngBounds; import com.google.android.gms.maps.model.PolylineOptions; import com.tryouts.courierapplication.presenters.NewOrderPresenter; import com.tryouts.courierapplication.R; package com.tryouts.courierapplication.fragments; public class NewOrderFragment extends Fragment implements OnMapReadyCallback { private MapView mMapView;
private NewOrderPresenter mPresenter;
MiWy/CourierApplication
app/src/main/java/com/tryouts/courierapplication/presenters/ProfilePresenter.java
// Path: app/src/main/java/com/tryouts/courierapplication/fragments/ProfileFragment.java // public class ProfileFragment extends Fragment { // // private TextView mName; // private TextView mPhone; // private TextView mMail; // private ProgressDialog mProgressDialog; // private ProfilePresenter mPresenter; // // public ProfileFragment() { // } // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // } // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, // Bundle savedInstanceState) { // return inflater.inflate(R.layout.fragment_profile, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // mName = (TextView) view.findViewById(R.id.name_text_view); // mPhone = (TextView) view.findViewById(R.id.telephone_text_view); // mMail = (TextView) view.findViewById(R.id.mail_text_view); // // mPresenter = new ProfilePresenter(this); // mPresenter.onUserDetailsRequired(); // } // // public void setTexts(String name, String phone, String mail) { // mName.setText(name); // mPhone.setText(phone); // mMail.setText(mail); // } // // /** // * Prepares and shows ProgressDialog upon call (while the data is loading). // */ // public void showProgressDialog() { // if(mProgressDialog == null) { // mProgressDialog = new ProgressDialog(getContext()); // mProgressDialog.setMessage(getString(R.string.progress_dialog_loading)); // mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); // mProgressDialog.setIndeterminate(true); // mProgressDialog.show(); // } // } // // public void hideProgressDialog() { // mProgressDialog.hide(); // } // // @Override // public void onDestroy() { // super.onDestroy(); // mPresenter.detachView(); // } // } // // Path: app/src/main/java/com/tryouts/courierapplication/interactors/ProfileInteractor.java // public class ProfileInteractor { // // private ProfilePresenter mPresenter; // private DatabaseReference mDatabaseReference; // private User mUser; // // // public ProfileInteractor(ProfilePresenter mPresenter) { // this.mPresenter = mPresenter; // mDatabaseReference = FirebaseDatabase.getInstance().getReference(); // } // // /** // * Get logged user data from DB, called from the profilePresenter which is called // * from the ProfileFragment onViewCreated. // * Returns user data to the presenter. // */ // public void getUserDataFromDb() { // FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); // final String uid = user.getUid(); // mUser = new User(); // mDatabaseReference.child("users").child(uid).addListenerForSingleValueEvent( // new ValueEventListener() { // @Override // public void onDataChange(DataSnapshot dataSnapshot) { // if(dataSnapshot.exists()) { // mUser.setName(String.valueOf(dataSnapshot.child("name").getValue())); // mUser.setPhone(String.valueOf(dataSnapshot.child("phone").getValue())); // mUser.setEmail(String.valueOf(dataSnapshot.child("email").getValue())); // mUser.setUid(uid); // mUser.setRole(String.valueOf(dataSnapshot.child("role").getValue())); // checkAndSetCurrentUserToken(uid); // mPresenter.onReceivedUserDataFromDb(mUser); // } // } // // @Override // public void onCancelled(DatabaseError databaseError) { // // } // } // ); // } // // // Precaution, in case user's token get changed or removed // private String checkAndSetCurrentUserToken(String userUid) { // String instanceId = FirebaseInstanceId.getInstance().getToken(); // if(instanceId != null) { // DatabaseReference mDatabaseReference = FirebaseDatabase.getInstance().getReference(); // mDatabaseReference.child("users") // .child(userUid) // .child("instanceId") // .setValue(instanceId); // } // return instanceId; // } // // } // // Path: app/src/main/java/com/tryouts/courierapplication/items/User.java // public class User { // // private String mEmail; // private String mUid; // private String mName; // private String mPhone; // private String mRole; // private String mInstanceId; // // public User() { // } // // public User(String email) { // this.mEmail = email; // } // // public User(String email, String role) { // this.mEmail = email; // this.mRole = role; // } // // public String getEmail() { // return mEmail; // } // // public String getRole() { // return mRole; // } // // public void setEmail(String email) { // mEmail = email; // } // // public void setRole(String role) { // mRole = role; // } // // public String getName() { // return mName; // } // // public void setName(String name) { // mName = name; // } // // public String getPhone() { // return mPhone; // } // // public void setPhone(String phone) { // mPhone = phone; // } // // public String getUid() { // return mUid; // } // // public void setUid(String uid) { // mUid = uid; // } // // public String getInstanceId() { // return mInstanceId; // } // // public void setInstanceId(String instanceId) { // mInstanceId = instanceId; // } // }
import com.tryouts.courierapplication.fragments.ProfileFragment; import com.tryouts.courierapplication.interactors.ProfileInteractor; import com.tryouts.courierapplication.items.User;
package com.tryouts.courierapplication.presenters; public class ProfilePresenter { private ProfileInteractor mModel;
// Path: app/src/main/java/com/tryouts/courierapplication/fragments/ProfileFragment.java // public class ProfileFragment extends Fragment { // // private TextView mName; // private TextView mPhone; // private TextView mMail; // private ProgressDialog mProgressDialog; // private ProfilePresenter mPresenter; // // public ProfileFragment() { // } // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // } // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, // Bundle savedInstanceState) { // return inflater.inflate(R.layout.fragment_profile, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // mName = (TextView) view.findViewById(R.id.name_text_view); // mPhone = (TextView) view.findViewById(R.id.telephone_text_view); // mMail = (TextView) view.findViewById(R.id.mail_text_view); // // mPresenter = new ProfilePresenter(this); // mPresenter.onUserDetailsRequired(); // } // // public void setTexts(String name, String phone, String mail) { // mName.setText(name); // mPhone.setText(phone); // mMail.setText(mail); // } // // /** // * Prepares and shows ProgressDialog upon call (while the data is loading). // */ // public void showProgressDialog() { // if(mProgressDialog == null) { // mProgressDialog = new ProgressDialog(getContext()); // mProgressDialog.setMessage(getString(R.string.progress_dialog_loading)); // mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); // mProgressDialog.setIndeterminate(true); // mProgressDialog.show(); // } // } // // public void hideProgressDialog() { // mProgressDialog.hide(); // } // // @Override // public void onDestroy() { // super.onDestroy(); // mPresenter.detachView(); // } // } // // Path: app/src/main/java/com/tryouts/courierapplication/interactors/ProfileInteractor.java // public class ProfileInteractor { // // private ProfilePresenter mPresenter; // private DatabaseReference mDatabaseReference; // private User mUser; // // // public ProfileInteractor(ProfilePresenter mPresenter) { // this.mPresenter = mPresenter; // mDatabaseReference = FirebaseDatabase.getInstance().getReference(); // } // // /** // * Get logged user data from DB, called from the profilePresenter which is called // * from the ProfileFragment onViewCreated. // * Returns user data to the presenter. // */ // public void getUserDataFromDb() { // FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); // final String uid = user.getUid(); // mUser = new User(); // mDatabaseReference.child("users").child(uid).addListenerForSingleValueEvent( // new ValueEventListener() { // @Override // public void onDataChange(DataSnapshot dataSnapshot) { // if(dataSnapshot.exists()) { // mUser.setName(String.valueOf(dataSnapshot.child("name").getValue())); // mUser.setPhone(String.valueOf(dataSnapshot.child("phone").getValue())); // mUser.setEmail(String.valueOf(dataSnapshot.child("email").getValue())); // mUser.setUid(uid); // mUser.setRole(String.valueOf(dataSnapshot.child("role").getValue())); // checkAndSetCurrentUserToken(uid); // mPresenter.onReceivedUserDataFromDb(mUser); // } // } // // @Override // public void onCancelled(DatabaseError databaseError) { // // } // } // ); // } // // // Precaution, in case user's token get changed or removed // private String checkAndSetCurrentUserToken(String userUid) { // String instanceId = FirebaseInstanceId.getInstance().getToken(); // if(instanceId != null) { // DatabaseReference mDatabaseReference = FirebaseDatabase.getInstance().getReference(); // mDatabaseReference.child("users") // .child(userUid) // .child("instanceId") // .setValue(instanceId); // } // return instanceId; // } // // } // // Path: app/src/main/java/com/tryouts/courierapplication/items/User.java // public class User { // // private String mEmail; // private String mUid; // private String mName; // private String mPhone; // private String mRole; // private String mInstanceId; // // public User() { // } // // public User(String email) { // this.mEmail = email; // } // // public User(String email, String role) { // this.mEmail = email; // this.mRole = role; // } // // public String getEmail() { // return mEmail; // } // // public String getRole() { // return mRole; // } // // public void setEmail(String email) { // mEmail = email; // } // // public void setRole(String role) { // mRole = role; // } // // public String getName() { // return mName; // } // // public void setName(String name) { // mName = name; // } // // public String getPhone() { // return mPhone; // } // // public void setPhone(String phone) { // mPhone = phone; // } // // public String getUid() { // return mUid; // } // // public void setUid(String uid) { // mUid = uid; // } // // public String getInstanceId() { // return mInstanceId; // } // // public void setInstanceId(String instanceId) { // mInstanceId = instanceId; // } // } // Path: app/src/main/java/com/tryouts/courierapplication/presenters/ProfilePresenter.java import com.tryouts.courierapplication.fragments.ProfileFragment; import com.tryouts.courierapplication.interactors.ProfileInteractor; import com.tryouts.courierapplication.items.User; package com.tryouts.courierapplication.presenters; public class ProfilePresenter { private ProfileInteractor mModel;
private ProfileFragment mView;
MiWy/CourierApplication
app/src/main/java/com/tryouts/courierapplication/fragments/PreviousOrdersFragment.java
// Path: app/src/main/java/com/tryouts/courierapplication/adapters/OrdersAdapter.java // public class OrdersAdapter extends ArrayAdapter<OrderReceived> { // // private class ViewHolder { // TextView mDate; // TextView mFrom; // TextView mTo; // TextView mType; // } // // public OrdersAdapter(ArrayList<OrderReceived> data, Context context) { // super(context, R.layout.item_previous_orders_listview, data); // ArrayList<OrderReceived> orderSet = data; // Context context1 = context; // } // // @Override // public View getView(int position, View convertView, ViewGroup parent) { // // Get the data item for this position // OrderReceived order = getItem(position); // // Check if an existing view is being reused, otherwise inflate the view // OrdersAdapter.ViewHolder viewHolder; // view lookup cache stored in tag // final View result; // // if(convertView == null) { // viewHolder = new OrdersAdapter.ViewHolder(); // LayoutInflater inflater = LayoutInflater.from(getContext()); // convertView = inflater.inflate(R.layout.item_previous_orders_listview, parent, false); // viewHolder.mDate = (TextView) convertView.findViewById(R.id.order_date); // viewHolder.mFrom = (TextView) convertView.findViewById(R.id.order_from); // viewHolder.mTo = (TextView) convertView.findViewById(R.id.order_to); // viewHolder.mType = (TextView) convertView.findViewById(R.id.order_status); // // result = convertView; // convertView.setTag(viewHolder); // } else { // viewHolder = (OrdersAdapter.ViewHolder) convertView.getTag(); // result = convertView; // } // // viewHolder.mDate.setText(order.getDate()); // viewHolder.mFrom.setText(order.getFrom()); // viewHolder.mTo.setText(order.getTo()); // String type = order.getType(); // switch (type) { // case "finished": // viewHolder.mType.setText(getContext().getString(R.string.type_finished)); // break; // case "new": // viewHolder.mType.setText(getContext().getString(R.string.type_new)); // break; // case "canceled": // viewHolder.mType.setText(getContext().getString(R.string.type_canceled)); // break; // case "taken": // viewHolder.mType.setText(getContext().getString(R.string.type_taken)); // break; // default: // viewHolder.mType.setText(""); // break; // } // return convertView; // } // } // // Path: app/src/main/java/com/tryouts/courierapplication/presenters/PreviousOrderPresenter.java // public class PreviousOrderPresenter { // // private PreviousOrdersFragment mView; // private PreviousOrderInteractor mInteractor; // // public PreviousOrderPresenter(PreviousOrdersFragment fragment) { // this.mView = fragment; // this.mInteractor = new PreviousOrderInteractor(this); // } // // public void initialize() { // mInteractor.fetchPreviousOrdersData(); // } // // public void sendContext() { // mInteractor.setInteractorContext(mView.getFragmentContext()); // } // // public void onAdapterReady() { // mView.setListViewWithAdapter(mInteractor.sendOrdersAdapter()); // } // // public void detachView() { // mView = null; // } // // }
import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; import com.tryouts.courierapplication.adapters.OrdersAdapter; import com.tryouts.courierapplication.presenters.PreviousOrderPresenter; import com.tryouts.courierapplication.R;
package com.tryouts.courierapplication.fragments; public class PreviousOrdersFragment extends Fragment { private ListView mListView;
// Path: app/src/main/java/com/tryouts/courierapplication/adapters/OrdersAdapter.java // public class OrdersAdapter extends ArrayAdapter<OrderReceived> { // // private class ViewHolder { // TextView mDate; // TextView mFrom; // TextView mTo; // TextView mType; // } // // public OrdersAdapter(ArrayList<OrderReceived> data, Context context) { // super(context, R.layout.item_previous_orders_listview, data); // ArrayList<OrderReceived> orderSet = data; // Context context1 = context; // } // // @Override // public View getView(int position, View convertView, ViewGroup parent) { // // Get the data item for this position // OrderReceived order = getItem(position); // // Check if an existing view is being reused, otherwise inflate the view // OrdersAdapter.ViewHolder viewHolder; // view lookup cache stored in tag // final View result; // // if(convertView == null) { // viewHolder = new OrdersAdapter.ViewHolder(); // LayoutInflater inflater = LayoutInflater.from(getContext()); // convertView = inflater.inflate(R.layout.item_previous_orders_listview, parent, false); // viewHolder.mDate = (TextView) convertView.findViewById(R.id.order_date); // viewHolder.mFrom = (TextView) convertView.findViewById(R.id.order_from); // viewHolder.mTo = (TextView) convertView.findViewById(R.id.order_to); // viewHolder.mType = (TextView) convertView.findViewById(R.id.order_status); // // result = convertView; // convertView.setTag(viewHolder); // } else { // viewHolder = (OrdersAdapter.ViewHolder) convertView.getTag(); // result = convertView; // } // // viewHolder.mDate.setText(order.getDate()); // viewHolder.mFrom.setText(order.getFrom()); // viewHolder.mTo.setText(order.getTo()); // String type = order.getType(); // switch (type) { // case "finished": // viewHolder.mType.setText(getContext().getString(R.string.type_finished)); // break; // case "new": // viewHolder.mType.setText(getContext().getString(R.string.type_new)); // break; // case "canceled": // viewHolder.mType.setText(getContext().getString(R.string.type_canceled)); // break; // case "taken": // viewHolder.mType.setText(getContext().getString(R.string.type_taken)); // break; // default: // viewHolder.mType.setText(""); // break; // } // return convertView; // } // } // // Path: app/src/main/java/com/tryouts/courierapplication/presenters/PreviousOrderPresenter.java // public class PreviousOrderPresenter { // // private PreviousOrdersFragment mView; // private PreviousOrderInteractor mInteractor; // // public PreviousOrderPresenter(PreviousOrdersFragment fragment) { // this.mView = fragment; // this.mInteractor = new PreviousOrderInteractor(this); // } // // public void initialize() { // mInteractor.fetchPreviousOrdersData(); // } // // public void sendContext() { // mInteractor.setInteractorContext(mView.getFragmentContext()); // } // // public void onAdapterReady() { // mView.setListViewWithAdapter(mInteractor.sendOrdersAdapter()); // } // // public void detachView() { // mView = null; // } // // } // Path: app/src/main/java/com/tryouts/courierapplication/fragments/PreviousOrdersFragment.java import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; import com.tryouts.courierapplication.adapters.OrdersAdapter; import com.tryouts.courierapplication.presenters.PreviousOrderPresenter; import com.tryouts.courierapplication.R; package com.tryouts.courierapplication.fragments; public class PreviousOrdersFragment extends Fragment { private ListView mListView;
private PreviousOrderPresenter mPresenter;
MiWy/CourierApplication
app/src/main/java/com/tryouts/courierapplication/fragments/PreviousOrdersFragment.java
// Path: app/src/main/java/com/tryouts/courierapplication/adapters/OrdersAdapter.java // public class OrdersAdapter extends ArrayAdapter<OrderReceived> { // // private class ViewHolder { // TextView mDate; // TextView mFrom; // TextView mTo; // TextView mType; // } // // public OrdersAdapter(ArrayList<OrderReceived> data, Context context) { // super(context, R.layout.item_previous_orders_listview, data); // ArrayList<OrderReceived> orderSet = data; // Context context1 = context; // } // // @Override // public View getView(int position, View convertView, ViewGroup parent) { // // Get the data item for this position // OrderReceived order = getItem(position); // // Check if an existing view is being reused, otherwise inflate the view // OrdersAdapter.ViewHolder viewHolder; // view lookup cache stored in tag // final View result; // // if(convertView == null) { // viewHolder = new OrdersAdapter.ViewHolder(); // LayoutInflater inflater = LayoutInflater.from(getContext()); // convertView = inflater.inflate(R.layout.item_previous_orders_listview, parent, false); // viewHolder.mDate = (TextView) convertView.findViewById(R.id.order_date); // viewHolder.mFrom = (TextView) convertView.findViewById(R.id.order_from); // viewHolder.mTo = (TextView) convertView.findViewById(R.id.order_to); // viewHolder.mType = (TextView) convertView.findViewById(R.id.order_status); // // result = convertView; // convertView.setTag(viewHolder); // } else { // viewHolder = (OrdersAdapter.ViewHolder) convertView.getTag(); // result = convertView; // } // // viewHolder.mDate.setText(order.getDate()); // viewHolder.mFrom.setText(order.getFrom()); // viewHolder.mTo.setText(order.getTo()); // String type = order.getType(); // switch (type) { // case "finished": // viewHolder.mType.setText(getContext().getString(R.string.type_finished)); // break; // case "new": // viewHolder.mType.setText(getContext().getString(R.string.type_new)); // break; // case "canceled": // viewHolder.mType.setText(getContext().getString(R.string.type_canceled)); // break; // case "taken": // viewHolder.mType.setText(getContext().getString(R.string.type_taken)); // break; // default: // viewHolder.mType.setText(""); // break; // } // return convertView; // } // } // // Path: app/src/main/java/com/tryouts/courierapplication/presenters/PreviousOrderPresenter.java // public class PreviousOrderPresenter { // // private PreviousOrdersFragment mView; // private PreviousOrderInteractor mInteractor; // // public PreviousOrderPresenter(PreviousOrdersFragment fragment) { // this.mView = fragment; // this.mInteractor = new PreviousOrderInteractor(this); // } // // public void initialize() { // mInteractor.fetchPreviousOrdersData(); // } // // public void sendContext() { // mInteractor.setInteractorContext(mView.getFragmentContext()); // } // // public void onAdapterReady() { // mView.setListViewWithAdapter(mInteractor.sendOrdersAdapter()); // } // // public void detachView() { // mView = null; // } // // }
import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; import com.tryouts.courierapplication.adapters.OrdersAdapter; import com.tryouts.courierapplication.presenters.PreviousOrderPresenter; import com.tryouts.courierapplication.R;
package com.tryouts.courierapplication.fragments; public class PreviousOrdersFragment extends Fragment { private ListView mListView; private PreviousOrderPresenter mPresenter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_previous_orders, container, false); } @Override public void onViewCreated(View view, Bundle savedInstanceState) { mListView = (ListView) view.findViewById(R.id.previous_orders_listview); mPresenter = new PreviousOrderPresenter(this); mPresenter.initialize(); } public Context getFragmentContext() { return getContext(); }
// Path: app/src/main/java/com/tryouts/courierapplication/adapters/OrdersAdapter.java // public class OrdersAdapter extends ArrayAdapter<OrderReceived> { // // private class ViewHolder { // TextView mDate; // TextView mFrom; // TextView mTo; // TextView mType; // } // // public OrdersAdapter(ArrayList<OrderReceived> data, Context context) { // super(context, R.layout.item_previous_orders_listview, data); // ArrayList<OrderReceived> orderSet = data; // Context context1 = context; // } // // @Override // public View getView(int position, View convertView, ViewGroup parent) { // // Get the data item for this position // OrderReceived order = getItem(position); // // Check if an existing view is being reused, otherwise inflate the view // OrdersAdapter.ViewHolder viewHolder; // view lookup cache stored in tag // final View result; // // if(convertView == null) { // viewHolder = new OrdersAdapter.ViewHolder(); // LayoutInflater inflater = LayoutInflater.from(getContext()); // convertView = inflater.inflate(R.layout.item_previous_orders_listview, parent, false); // viewHolder.mDate = (TextView) convertView.findViewById(R.id.order_date); // viewHolder.mFrom = (TextView) convertView.findViewById(R.id.order_from); // viewHolder.mTo = (TextView) convertView.findViewById(R.id.order_to); // viewHolder.mType = (TextView) convertView.findViewById(R.id.order_status); // // result = convertView; // convertView.setTag(viewHolder); // } else { // viewHolder = (OrdersAdapter.ViewHolder) convertView.getTag(); // result = convertView; // } // // viewHolder.mDate.setText(order.getDate()); // viewHolder.mFrom.setText(order.getFrom()); // viewHolder.mTo.setText(order.getTo()); // String type = order.getType(); // switch (type) { // case "finished": // viewHolder.mType.setText(getContext().getString(R.string.type_finished)); // break; // case "new": // viewHolder.mType.setText(getContext().getString(R.string.type_new)); // break; // case "canceled": // viewHolder.mType.setText(getContext().getString(R.string.type_canceled)); // break; // case "taken": // viewHolder.mType.setText(getContext().getString(R.string.type_taken)); // break; // default: // viewHolder.mType.setText(""); // break; // } // return convertView; // } // } // // Path: app/src/main/java/com/tryouts/courierapplication/presenters/PreviousOrderPresenter.java // public class PreviousOrderPresenter { // // private PreviousOrdersFragment mView; // private PreviousOrderInteractor mInteractor; // // public PreviousOrderPresenter(PreviousOrdersFragment fragment) { // this.mView = fragment; // this.mInteractor = new PreviousOrderInteractor(this); // } // // public void initialize() { // mInteractor.fetchPreviousOrdersData(); // } // // public void sendContext() { // mInteractor.setInteractorContext(mView.getFragmentContext()); // } // // public void onAdapterReady() { // mView.setListViewWithAdapter(mInteractor.sendOrdersAdapter()); // } // // public void detachView() { // mView = null; // } // // } // Path: app/src/main/java/com/tryouts/courierapplication/fragments/PreviousOrdersFragment.java import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; import com.tryouts.courierapplication.adapters.OrdersAdapter; import com.tryouts.courierapplication.presenters.PreviousOrderPresenter; import com.tryouts.courierapplication.R; package com.tryouts.courierapplication.fragments; public class PreviousOrdersFragment extends Fragment { private ListView mListView; private PreviousOrderPresenter mPresenter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_previous_orders, container, false); } @Override public void onViewCreated(View view, Bundle savedInstanceState) { mListView = (ListView) view.findViewById(R.id.previous_orders_listview); mPresenter = new PreviousOrderPresenter(this); mPresenter.initialize(); } public Context getFragmentContext() { return getContext(); }
public void setListViewWithAdapter(OrdersAdapter ordersAdapter) {
MiWy/CourierApplication
app/src/main/java/com/tryouts/courierapplication/presenters/PreviousOrderPresenter.java
// Path: app/src/main/java/com/tryouts/courierapplication/fragments/PreviousOrdersFragment.java // public class PreviousOrdersFragment extends Fragment { // // private ListView mListView; // private PreviousOrderPresenter mPresenter; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // } // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, // Bundle savedInstanceState) { // return inflater.inflate(R.layout.fragment_previous_orders, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // mListView = (ListView) view.findViewById(R.id.previous_orders_listview); // // mPresenter = new PreviousOrderPresenter(this); // mPresenter.initialize(); // } // // public Context getFragmentContext() { // return getContext(); // } // // public void setListViewWithAdapter(OrdersAdapter ordersAdapter) { // mListView.setAdapter(ordersAdapter); // } // // @Override // public void onDestroy() { // super.onDestroy(); // mPresenter.detachView(); // } // } // // Path: app/src/main/java/com/tryouts/courierapplication/interactors/PreviousOrderInteractor.java // public class PreviousOrderInteractor { // // private PreviousOrderPresenter mPresenter; // private Context context; // private OrdersAdapter mOrdersAdapter; // // public PreviousOrderInteractor(PreviousOrderPresenter presenter) { // this.mPresenter = presenter; // } // // public void fetchPreviousOrdersData() { // FirebaseOpsHelper fbHelper = new FirebaseOpsHelper(); // fbHelper.onPreviousOrdersCall(this); // } // // public void onReceivedPreviousOrdersData(ArrayList<OrderReceived> orderList) { // mPresenter.sendContext(); // mOrdersAdapter = new OrdersAdapter(orderList, context); // mPresenter.onAdapterReady(); // } // // public void setInteractorContext(Context context) { // this.context = context; // } // // public OrdersAdapter sendOrdersAdapter() { // return mOrdersAdapter; // } // // }
import com.tryouts.courierapplication.fragments.PreviousOrdersFragment; import com.tryouts.courierapplication.interactors.PreviousOrderInteractor;
package com.tryouts.courierapplication.presenters; public class PreviousOrderPresenter { private PreviousOrdersFragment mView;
// Path: app/src/main/java/com/tryouts/courierapplication/fragments/PreviousOrdersFragment.java // public class PreviousOrdersFragment extends Fragment { // // private ListView mListView; // private PreviousOrderPresenter mPresenter; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // } // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, // Bundle savedInstanceState) { // return inflater.inflate(R.layout.fragment_previous_orders, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // mListView = (ListView) view.findViewById(R.id.previous_orders_listview); // // mPresenter = new PreviousOrderPresenter(this); // mPresenter.initialize(); // } // // public Context getFragmentContext() { // return getContext(); // } // // public void setListViewWithAdapter(OrdersAdapter ordersAdapter) { // mListView.setAdapter(ordersAdapter); // } // // @Override // public void onDestroy() { // super.onDestroy(); // mPresenter.detachView(); // } // } // // Path: app/src/main/java/com/tryouts/courierapplication/interactors/PreviousOrderInteractor.java // public class PreviousOrderInteractor { // // private PreviousOrderPresenter mPresenter; // private Context context; // private OrdersAdapter mOrdersAdapter; // // public PreviousOrderInteractor(PreviousOrderPresenter presenter) { // this.mPresenter = presenter; // } // // public void fetchPreviousOrdersData() { // FirebaseOpsHelper fbHelper = new FirebaseOpsHelper(); // fbHelper.onPreviousOrdersCall(this); // } // // public void onReceivedPreviousOrdersData(ArrayList<OrderReceived> orderList) { // mPresenter.sendContext(); // mOrdersAdapter = new OrdersAdapter(orderList, context); // mPresenter.onAdapterReady(); // } // // public void setInteractorContext(Context context) { // this.context = context; // } // // public OrdersAdapter sendOrdersAdapter() { // return mOrdersAdapter; // } // // } // Path: app/src/main/java/com/tryouts/courierapplication/presenters/PreviousOrderPresenter.java import com.tryouts.courierapplication.fragments.PreviousOrdersFragment; import com.tryouts.courierapplication.interactors.PreviousOrderInteractor; package com.tryouts.courierapplication.presenters; public class PreviousOrderPresenter { private PreviousOrdersFragment mView;
private PreviousOrderInteractor mInteractor;
MiWy/CourierApplication
app/src/main/java/com/tryouts/courierapplication/adapters/BasePriceAdapter.java
// Path: app/src/main/java/com/tryouts/courierapplication/items/PriceItem.java // public class PriceItem { // private String mDescription; // private String mPrice; // private String mGenre; // // public PriceItem() { // this("", "", ""); // } // // public PriceItem(String description, String price, String genre) { // this.mDescription = description; // this.mPrice = price; // this.mGenre = genre; // } // // public String getDescription() { // return mDescription; // } // // public String getPrice() { // return mPrice; // } // // public String getGenre() { // return mGenre; // } // // public void setGenre(String genre) { // mGenre = genre; // } // // public void setDescription(String description) { // mDescription = description; // } // // public void setPrice(String price) { // mPrice = price; // } // // // }
import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.tryouts.courierapplication.items.PriceItem; import com.tryouts.courierapplication.R; import com.zhukic.sectionedrecyclerview.SectionedRecyclerAdapter; import java.util.List;
package com.tryouts.courierapplication.adapters; public abstract class BasePriceAdapter extends SectionedRecyclerAdapter<BasePriceAdapter.SubheaderViewHolder, BasePriceAdapter.PriceItemViewHolder> { public interface OnItemClickListener { void onItemClicked(int adapterPosition, int positionInCollection); }
// Path: app/src/main/java/com/tryouts/courierapplication/items/PriceItem.java // public class PriceItem { // private String mDescription; // private String mPrice; // private String mGenre; // // public PriceItem() { // this("", "", ""); // } // // public PriceItem(String description, String price, String genre) { // this.mDescription = description; // this.mPrice = price; // this.mGenre = genre; // } // // public String getDescription() { // return mDescription; // } // // public String getPrice() { // return mPrice; // } // // public String getGenre() { // return mGenre; // } // // public void setGenre(String genre) { // mGenre = genre; // } // // public void setDescription(String description) { // mDescription = description; // } // // public void setPrice(String price) { // mPrice = price; // } // // // } // Path: app/src/main/java/com/tryouts/courierapplication/adapters/BasePriceAdapter.java import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.tryouts.courierapplication.items.PriceItem; import com.tryouts.courierapplication.R; import com.zhukic.sectionedrecyclerview.SectionedRecyclerAdapter; import java.util.List; package com.tryouts.courierapplication.adapters; public abstract class BasePriceAdapter extends SectionedRecyclerAdapter<BasePriceAdapter.SubheaderViewHolder, BasePriceAdapter.PriceItemViewHolder> { public interface OnItemClickListener { void onItemClicked(int adapterPosition, int positionInCollection); }
List<PriceItem> priceList;
MiWy/CourierApplication
app/src/main/java/com/tryouts/courierapplication/fragments/PricelistFragment.java
// Path: app/src/main/java/com/tryouts/courierapplication/presenters/PricelistPresenter.java // public class PricelistPresenter { // // private PricelistInteractor mModel; // private PricelistFragment mView; // // public PricelistPresenter(PricelistFragment pricelistFragment) { // this.mModel = new PricelistInteractor(this); // this.mView = pricelistFragment; // } // // /** // * Called from PricelistFragment // * Sets adapter for @param. // * @param // */ // public void initialize() { // mModel.setContext(mView.getContextFromFragment()); // mModel.onPrepareRecyclerView(mView.getRecyclerView()); // } // // public void detachView() { // mView = null; // } // // }
import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.tryouts.courierapplication.presenters.PricelistPresenter; import com.tryouts.courierapplication.R;
package com.tryouts.courierapplication.fragments; public class PricelistFragment extends Fragment { private RecyclerView mRecyclerView;
// Path: app/src/main/java/com/tryouts/courierapplication/presenters/PricelistPresenter.java // public class PricelistPresenter { // // private PricelistInteractor mModel; // private PricelistFragment mView; // // public PricelistPresenter(PricelistFragment pricelistFragment) { // this.mModel = new PricelistInteractor(this); // this.mView = pricelistFragment; // } // // /** // * Called from PricelistFragment // * Sets adapter for @param. // * @param // */ // public void initialize() { // mModel.setContext(mView.getContextFromFragment()); // mModel.onPrepareRecyclerView(mView.getRecyclerView()); // } // // public void detachView() { // mView = null; // } // // } // Path: app/src/main/java/com/tryouts/courierapplication/fragments/PricelistFragment.java import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.tryouts.courierapplication.presenters.PricelistPresenter; import com.tryouts.courierapplication.R; package com.tryouts.courierapplication.fragments; public class PricelistFragment extends Fragment { private RecyclerView mRecyclerView;
private PricelistPresenter mPresenter;
MiWy/CourierApplication
app/src/main/java/com/tryouts/courierapplication/fragments/ProfileFragment.java
// Path: app/src/main/java/com/tryouts/courierapplication/presenters/ProfilePresenter.java // public class ProfilePresenter { // // private ProfileInteractor mModel; // private ProfileFragment mView; // // public ProfilePresenter(ProfileFragment view) { // this.mModel = new ProfileInteractor(this); // this.mView = view; // } // // /** // * Called by fragment instantiation {ProfileFragment} // * Sends a request for user data from db based on his UID // */ // public void onUserDetailsRequired() { // mView.showProgressDialog(); // mModel.getUserDataFromDb(); // } // // // RETURNING FROM MODEL // // /** // * Receives call from the model when User data is acquired from db // */ // public void onReceivedUserDataFromDb(User user) { // showUserDataInViews(user); // } // // /** // * Sends user details to the view's textfields. // * @param user // */ // private void showUserDataInViews(User user) { // mView.setTexts(user.getName(), user.getPhone(), user.getEmail()); // hideProgressDialog(); // } // // private void hideProgressDialog() { // mView.hideProgressDialog(); // } // // public void detachView() { // mView = null; // } // // // }
import android.app.ProgressDialog; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.tryouts.courierapplication.presenters.ProfilePresenter; import com.tryouts.courierapplication.R;
package com.tryouts.courierapplication.fragments; public class ProfileFragment extends Fragment { private TextView mName; private TextView mPhone; private TextView mMail; private ProgressDialog mProgressDialog;
// Path: app/src/main/java/com/tryouts/courierapplication/presenters/ProfilePresenter.java // public class ProfilePresenter { // // private ProfileInteractor mModel; // private ProfileFragment mView; // // public ProfilePresenter(ProfileFragment view) { // this.mModel = new ProfileInteractor(this); // this.mView = view; // } // // /** // * Called by fragment instantiation {ProfileFragment} // * Sends a request for user data from db based on his UID // */ // public void onUserDetailsRequired() { // mView.showProgressDialog(); // mModel.getUserDataFromDb(); // } // // // RETURNING FROM MODEL // // /** // * Receives call from the model when User data is acquired from db // */ // public void onReceivedUserDataFromDb(User user) { // showUserDataInViews(user); // } // // /** // * Sends user details to the view's textfields. // * @param user // */ // private void showUserDataInViews(User user) { // mView.setTexts(user.getName(), user.getPhone(), user.getEmail()); // hideProgressDialog(); // } // // private void hideProgressDialog() { // mView.hideProgressDialog(); // } // // public void detachView() { // mView = null; // } // // // } // Path: app/src/main/java/com/tryouts/courierapplication/fragments/ProfileFragment.java import android.app.ProgressDialog; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.tryouts.courierapplication.presenters.ProfilePresenter; import com.tryouts.courierapplication.R; package com.tryouts.courierapplication.fragments; public class ProfileFragment extends Fragment { private TextView mName; private TextView mPhone; private TextView mMail; private ProgressDialog mProgressDialog;
private ProfilePresenter mPresenter;
jawher/litil
src/main/java/litil/ast/DestructuringLetBinding.java
// Path: src/main/java/litil/Utils.java // public class Utils { // public static String tab(int depth) { // return ntimes(depth, "\t"); // } // // public static String ntimes(int count, String s) { // StringBuilder res = new StringBuilder(""); // for (int i = 0; i < count; i++) { // res.append(s); // } // // return res.toString(); // } // // public static PrintStream indenting(String pkg) { // return new PrintStream(System.out) { // @Override // public void println(String s) { // super.println(s); // } // }; // } // }
import litil.Utils; import java.util.List;
package litil.ast; public class DestructuringLetBinding extends Instruction { public final Pattern main; public final List<Pattern> args; public final List<Instruction> instructions; public DestructuringLetBinding(Pattern main, List<Pattern> args, List<Instruction> instructions) { this.main = main; this.args = args; this.instructions = instructions; } @Override public String repr(int indent) {
// Path: src/main/java/litil/Utils.java // public class Utils { // public static String tab(int depth) { // return ntimes(depth, "\t"); // } // // public static String ntimes(int count, String s) { // StringBuilder res = new StringBuilder(""); // for (int i = 0; i < count; i++) { // res.append(s); // } // // return res.toString(); // } // // public static PrintStream indenting(String pkg) { // return new PrintStream(System.out) { // @Override // public void println(String s) { // super.println(s); // } // }; // } // } // Path: src/main/java/litil/ast/DestructuringLetBinding.java import litil.Utils; import java.util.List; package litil.ast; public class DestructuringLetBinding extends Instruction { public final Pattern main; public final List<Pattern> args; public final List<Instruction> instructions; public DestructuringLetBinding(Pattern main, List<Pattern> args, List<Instruction> instructions) { this.main = main; this.args = args; this.instructions = instructions; } @Override public String repr(int indent) {
StringBuilder res = new StringBuilder(Utils.tab(indent));
jawher/litil
src/main/java/litil/ast/LetBinding.java
// Path: src/main/java/litil/Utils.java // public class Utils { // public static String tab(int depth) { // return ntimes(depth, "\t"); // } // // public static String ntimes(int count, String s) { // StringBuilder res = new StringBuilder(""); // for (int i = 0; i < count; i++) { // res.append(s); // } // // return res.toString(); // } // // public static PrintStream indenting(String pkg) { // return new PrintStream(System.out) { // @Override // public void println(String s) { // super.println(s); // } // }; // } // }
import litil.Utils; import java.util.List;
package litil.ast; public class LetBinding extends Instruction { public final String name; public final Type type; public final List<Named> args; public final List<Instruction> instructions; public LetBinding(String name, Type type, List<Named> args, List<Instruction> instructions) { this.type = type; this.args = args; this.name = name; this.instructions = instructions; } @Override public String repr(int indent) {
// Path: src/main/java/litil/Utils.java // public class Utils { // public static String tab(int depth) { // return ntimes(depth, "\t"); // } // // public static String ntimes(int count, String s) { // StringBuilder res = new StringBuilder(""); // for (int i = 0; i < count; i++) { // res.append(s); // } // // return res.toString(); // } // // public static PrintStream indenting(String pkg) { // return new PrintStream(System.out) { // @Override // public void println(String s) { // super.println(s); // } // }; // } // } // Path: src/main/java/litil/ast/LetBinding.java import litil.Utils; import java.util.List; package litil.ast; public class LetBinding extends Instruction { public final String name; public final Type type; public final List<Named> args; public final List<Instruction> instructions; public LetBinding(String name, Type type, List<Named> args, List<Instruction> instructions) { this.type = type; this.args = args; this.name = name; this.instructions = instructions; } @Override public String repr(int indent) {
StringBuilder res = new StringBuilder(Utils.tab(indent));
jawher/litil
src/main/java/litil/lexer/BaseLexer.java
// Path: src/main/java/litil/Utils.java // public class Utils { // public static String tab(int depth) { // return ntimes(depth, "\t"); // } // // public static String ntimes(int count, String s) { // StringBuilder res = new StringBuilder(""); // for (int i = 0; i < count; i++) { // res.append(s); // } // // return res.toString(); // } // // public static PrintStream indenting(String pkg) { // return new PrintStream(System.out) { // @Override // public void println(String s) { // super.println(s); // } // }; // } // }
import litil.Utils; import java.io.BufferedReader; import java.io.IOException; import java.io.Reader; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map;
private static final List<String> BOOLS = Arrays.asList("true", "false"); private static final List<String> KEYWORDS = Arrays.asList("let", "if", "then", "else", "and", "or", "not", "data", "match", "exception", "try", "catch", "throw"); private int row = 1, col = 0; private String currentLine = null; private int lastIndentLength = 0; private boolean newLine = false; private Token eof = null; public BaseLexer(Reader reader) { this.reader = new BufferedReader(reader); } public Token pop() throws LexingException { if (eof != null) { return eof; } if (currentLine == null) { currentLine = readLine(); if (currentLine == null) { eof = new Token(Token.Type.EOF, "$", row, col); return eof; } else { //compute the indent size consumeWhite(); if (col == lastIndentLength) { lastIndentLength = col; return new Token(Token.Type.NEWLINE, "\\n1", row + 1, 1); } else if (col > lastIndentLength) { lastIndentLength = col; newLine = true;
// Path: src/main/java/litil/Utils.java // public class Utils { // public static String tab(int depth) { // return ntimes(depth, "\t"); // } // // public static String ntimes(int count, String s) { // StringBuilder res = new StringBuilder(""); // for (int i = 0; i < count; i++) { // res.append(s); // } // // return res.toString(); // } // // public static PrintStream indenting(String pkg) { // return new PrintStream(System.out) { // @Override // public void println(String s) { // super.println(s); // } // }; // } // } // Path: src/main/java/litil/lexer/BaseLexer.java import litil.Utils; import java.io.BufferedReader; import java.io.IOException; import java.io.Reader; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; private static final List<String> BOOLS = Arrays.asList("true", "false"); private static final List<String> KEYWORDS = Arrays.asList("let", "if", "then", "else", "and", "or", "not", "data", "match", "exception", "try", "catch", "throw"); private int row = 1, col = 0; private String currentLine = null; private int lastIndentLength = 0; private boolean newLine = false; private Token eof = null; public BaseLexer(Reader reader) { this.reader = new BufferedReader(reader); } public Token pop() throws LexingException { if (eof != null) { return eof; } if (currentLine == null) { currentLine = readLine(); if (currentLine == null) { eof = new Token(Token.Type.EOF, "$", row, col); return eof; } else { //compute the indent size consumeWhite(); if (col == lastIndentLength) { lastIndentLength = col; return new Token(Token.Type.NEWLINE, "\\n1", row + 1, 1); } else if (col > lastIndentLength) { lastIndentLength = col; newLine = true;
return new Token(Token.Type.INDENT, Utils.ntimes(col, " "), row, 1);
jawher/litil
src/main/java/litil/parser/BaseParser.java
// Path: src/main/java/litil/lexer/LookaheadLexer.java // public interface LookaheadLexer extends Lexer { // // Token peek(int lookahead) throws LexingException; // } // // Path: src/main/java/litil/lexer/Token.java // public class Token { // public enum Type { // NEWLINE, INDENT, DEINDENT, NAME, NUM, STRING, CHAR, SYM, BOOL, KEYWORD, EOF // } // public final Type type; // public final String text; // public final int row, col; // // public Token(Type type, String text, int row, int col) { // this.type = type; // this.text = text; // this.row = row; // this.col = col; // } // // @Override // public String toString() { // return String.format("%s ('%s') @ %d:%d", type, text, row, col); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Token token = (Token) o; // // if (col != token.col) return false; // if (row != token.row) return false; // if (text != null ? !text.equals(token.text) : token.text != null) return false; // if (type != token.type) return false; // // return true; // } // // @Override // public int hashCode() { // int result = type != null ? type.hashCode() : 0; // result = 31 * result + (text != null ? text.hashCode() : 0); // result = 31 * result + row; // result = 31 * result + col; // return result; // } // }
import litil.lexer.LookaheadLexer; import litil.lexer.Token;
package litil.parser; public class BaseParser { protected LookaheadLexer lexer;
// Path: src/main/java/litil/lexer/LookaheadLexer.java // public interface LookaheadLexer extends Lexer { // // Token peek(int lookahead) throws LexingException; // } // // Path: src/main/java/litil/lexer/Token.java // public class Token { // public enum Type { // NEWLINE, INDENT, DEINDENT, NAME, NUM, STRING, CHAR, SYM, BOOL, KEYWORD, EOF // } // public final Type type; // public final String text; // public final int row, col; // // public Token(Type type, String text, int row, int col) { // this.type = type; // this.text = text; // this.row = row; // this.col = col; // } // // @Override // public String toString() { // return String.format("%s ('%s') @ %d:%d", type, text, row, col); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Token token = (Token) o; // // if (col != token.col) return false; // if (row != token.row) return false; // if (text != null ? !text.equals(token.text) : token.text != null) return false; // if (type != token.type) return false; // // return true; // } // // @Override // public int hashCode() { // int result = type != null ? type.hashCode() : 0; // result = 31 * result + (text != null ? text.hashCode() : 0); // result = 31 * result + row; // result = 31 * result + col; // return result; // } // } // Path: src/main/java/litil/parser/BaseParser.java import litil.lexer.LookaheadLexer; import litil.lexer.Token; package litil.parser; public class BaseParser { protected LookaheadLexer lexer;
protected Token token;
jawher/litil
src/main/java/litil/ast/DataDecl.java
// Path: src/main/java/litil/Utils.java // public class Utils { // public static String tab(int depth) { // return ntimes(depth, "\t"); // } // // public static String ntimes(int count, String s) { // StringBuilder res = new StringBuilder(""); // for (int i = 0; i < count; i++) { // res.append(s); // } // // return res.toString(); // } // // public static PrintStream indenting(String pkg) { // return new PrintStream(System.out) { // @Override // public void println(String s) { // super.println(s); // } // }; // } // }
import litil.Utils; import java.util.Collections; import java.util.List;
package litil.ast; public class DataDecl extends Instruction { public static final class TypeConstructor { public final String name; public final List<Type> types; public TypeConstructor(String name, List<Type> types) { this.name = name; this.types = types; } public TypeConstructor(String name) { this.name = name; this.types = Collections.emptyList(); } } public final String name; public final Type type; public final List<Type.Variable> typesVariables; public final List<TypeConstructor> typeConstructors; public DataDecl(String name, Type type, List<Type.Variable> typesVariables, List<TypeConstructor> typeConstructors) { this.name = name; this.type = type; this.typesVariables = typesVariables; this.typeConstructors = typeConstructors; } @Override public String repr(int indent) {
// Path: src/main/java/litil/Utils.java // public class Utils { // public static String tab(int depth) { // return ntimes(depth, "\t"); // } // // public static String ntimes(int count, String s) { // StringBuilder res = new StringBuilder(""); // for (int i = 0; i < count; i++) { // res.append(s); // } // // return res.toString(); // } // // public static PrintStream indenting(String pkg) { // return new PrintStream(System.out) { // @Override // public void println(String s) { // super.println(s); // } // }; // } // } // Path: src/main/java/litil/ast/DataDecl.java import litil.Utils; import java.util.Collections; import java.util.List; package litil.ast; public class DataDecl extends Instruction { public static final class TypeConstructor { public final String name; public final List<Type> types; public TypeConstructor(String name, List<Type> types) { this.name = name; this.types = types; } public TypeConstructor(String name) { this.name = name; this.types = Collections.emptyList(); } } public final String name; public final Type type; public final List<Type.Variable> typesVariables; public final List<TypeConstructor> typeConstructors; public DataDecl(String name, Type type, List<Type.Variable> typesVariables, List<TypeConstructor> typeConstructors) { this.name = name; this.type = type; this.typesVariables = typesVariables; this.typeConstructors = typeConstructors; } @Override public String repr(int indent) {
StringBuilder res = new StringBuilder(Utils.tab(indent));
jawher/litil
src/main/java/litil/cg/DeasmTester.java
// Path: src/main/java/litil/cg/samples/Sample4Dump.java // public class Sample4Dump implements Opcodes { // // public static byte[] dump() throws Exception { // // ClassWriter cw = new ClassWriter(0); // FieldVisitor fv; // MethodVisitor mv; // AnnotationVisitor av0; // // cw.visit(V1_6, ACC_PUBLIC + ACC_SUPER, "litil/cg/samples/Sample4", null, "java/lang/Object", null); // // cw.visitSource("Sample4.java", null); // // { // fv = cw.visitField(ACC_PUBLIC, "x", "Ljava/lang/String;", null, null); // fv.visitEnd(); // } // { // mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); // mv.visitCode(); // Label l0 = new Label(); // mv.visitLabel(l0); // mv.visitLineNumber(3, l0); // mv.visitVarInsn(ALOAD, 0); // mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V"); // mv.visitInsn(RETURN); // Label l1 = new Label(); // mv.visitLabel(l1); // mv.visitLocalVariable("this", "Llitil/cg/samples/Sample4;", null, l0, l1, 0); // mv.visitMaxs(1, 1); // mv.visitEnd(); // } // { // mv = cw.visitMethod(ACC_PUBLIC, "test", "()I", null, null); // mv.visitCode(); // Label l0 = new Label(); // mv.visitLabel(l0); // mv.visitLineNumber(7, l0); // mv.visitVarInsn(ALOAD, 0); // mv.visitLdcInsn("ohai"); // mv.visitFieldInsn(PUTFIELD, "litil/cg/samples/Sample4", "x", "Ljava/lang/String;"); // Label l1 = new Label(); // mv.visitLabel(l1); // mv.visitLineNumber(8, l1); // mv.visitVarInsn(ALOAD, 0); // mv.visitFieldInsn(GETFIELD, "litil/cg/samples/Sample4", "x", "Ljava/lang/String;"); // mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "length", "()I"); // mv.visitInsn(IRETURN); // Label l2 = new Label(); // mv.visitLabel(l2); // mv.visitLocalVariable("this", "Llitil/cg/samples/Sample4;", null, l0, l2, 0); // mv.visitMaxs(2, 1); // mv.visitEnd(); // } // cw.visitEnd(); // // return cw.toByteArray(); // } // }
import litil.cg.samples.Sample4Dump; import java.lang.reflect.Method; import java.util.Arrays;
package litil.cg; public class DeasmTester { private static class ExprClassLoader extends ClassLoader { public Class<?> loadClass(String name, byte[] classData) throws ClassNotFoundException { return defineClass(name, classData, 0, classData.length); } } public static void main(String[] args) throws Exception {
// Path: src/main/java/litil/cg/samples/Sample4Dump.java // public class Sample4Dump implements Opcodes { // // public static byte[] dump() throws Exception { // // ClassWriter cw = new ClassWriter(0); // FieldVisitor fv; // MethodVisitor mv; // AnnotationVisitor av0; // // cw.visit(V1_6, ACC_PUBLIC + ACC_SUPER, "litil/cg/samples/Sample4", null, "java/lang/Object", null); // // cw.visitSource("Sample4.java", null); // // { // fv = cw.visitField(ACC_PUBLIC, "x", "Ljava/lang/String;", null, null); // fv.visitEnd(); // } // { // mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); // mv.visitCode(); // Label l0 = new Label(); // mv.visitLabel(l0); // mv.visitLineNumber(3, l0); // mv.visitVarInsn(ALOAD, 0); // mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V"); // mv.visitInsn(RETURN); // Label l1 = new Label(); // mv.visitLabel(l1); // mv.visitLocalVariable("this", "Llitil/cg/samples/Sample4;", null, l0, l1, 0); // mv.visitMaxs(1, 1); // mv.visitEnd(); // } // { // mv = cw.visitMethod(ACC_PUBLIC, "test", "()I", null, null); // mv.visitCode(); // Label l0 = new Label(); // mv.visitLabel(l0); // mv.visitLineNumber(7, l0); // mv.visitVarInsn(ALOAD, 0); // mv.visitLdcInsn("ohai"); // mv.visitFieldInsn(PUTFIELD, "litil/cg/samples/Sample4", "x", "Ljava/lang/String;"); // Label l1 = new Label(); // mv.visitLabel(l1); // mv.visitLineNumber(8, l1); // mv.visitVarInsn(ALOAD, 0); // mv.visitFieldInsn(GETFIELD, "litil/cg/samples/Sample4", "x", "Ljava/lang/String;"); // mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "length", "()I"); // mv.visitInsn(IRETURN); // Label l2 = new Label(); // mv.visitLabel(l2); // mv.visitLocalVariable("this", "Llitil/cg/samples/Sample4;", null, l0, l2, 0); // mv.visitMaxs(2, 1); // mv.visitEnd(); // } // cw.visitEnd(); // // return cw.toByteArray(); // } // } // Path: src/main/java/litil/cg/DeasmTester.java import litil.cg.samples.Sample4Dump; import java.lang.reflect.Method; import java.util.Arrays; package litil.cg; public class DeasmTester { private static class ExprClassLoader extends ClassLoader { public Class<?> loadClass(String name, byte[] classData) throws ClassNotFoundException { return defineClass(name, classData, 0, classData.length); } } public static void main(String[] args) throws Exception {
byte[] cdef = Sample4Dump.dump();
jawher/litil
src/main/java/litil/ast/ExceptionDecl.java
// Path: src/main/java/litil/Utils.java // public class Utils { // public static String tab(int depth) { // return ntimes(depth, "\t"); // } // // public static String ntimes(int count, String s) { // StringBuilder res = new StringBuilder(""); // for (int i = 0; i < count; i++) { // res.append(s); // } // // return res.toString(); // } // // public static PrintStream indenting(String pkg) { // return new PrintStream(System.out) { // @Override // public void println(String s) { // super.println(s); // } // }; // } // }
import litil.Utils; import java.util.Collections; import java.util.List;
package litil.ast; public class ExceptionDecl extends Instruction { public final String name; public final List<Type> types; public ExceptionDecl(String name, List<Type> types) { this.name = name; this.types = types; } @Override public String repr(int indent) {
// Path: src/main/java/litil/Utils.java // public class Utils { // public static String tab(int depth) { // return ntimes(depth, "\t"); // } // // public static String ntimes(int count, String s) { // StringBuilder res = new StringBuilder(""); // for (int i = 0; i < count; i++) { // res.append(s); // } // // return res.toString(); // } // // public static PrintStream indenting(String pkg) { // return new PrintStream(System.out) { // @Override // public void println(String s) { // super.println(s); // } // }; // } // } // Path: src/main/java/litil/ast/ExceptionDecl.java import litil.Utils; import java.util.Collections; import java.util.List; package litil.ast; public class ExceptionDecl extends Instruction { public final String name; public final List<Type> types; public ExceptionDecl(String name, List<Type> types) { this.name = name; this.types = types; } @Override public String repr(int indent) {
StringBuilder res = new StringBuilder(Utils.tab(indent));
jawher/litil
src/main/java/litil/tc/HMTypeChecker.java
// Path: src/main/java/litil/TypeScope.java // public class TypeScope { // // private final Map<String, Type> scope; // private final TypeScope parent; // // private TypeScope(TypeScope parent, Map<String, Type> scope) { // this.parent = parent; // this.scope = scope; // } // // public TypeScope(TypeScope parent) { // this(parent, new HashMap<String, Type>()); // } // // public TypeScope() { // this(null, new HashMap<String, Type>()); // } // // public void define(String name, Type type) { // scope.put(name, type); // } // // public Type get(String name) { // Type res = scope.get(name); // if (res == null && parent != null) { // res = parent.get(name); // } // return res; // } // // public TypeScope child() { // return new TypeScope(this); // } // // @Override // public String toString() { // return scope + (parent == null ? "-|" : "->" + parent); // } // }
import litil.TypeScope; import litil.ast.*; import java.util.*;
package litil.tc; public class HMTypeChecker { private static int _id = 0;
// Path: src/main/java/litil/TypeScope.java // public class TypeScope { // // private final Map<String, Type> scope; // private final TypeScope parent; // // private TypeScope(TypeScope parent, Map<String, Type> scope) { // this.parent = parent; // this.scope = scope; // } // // public TypeScope(TypeScope parent) { // this(parent, new HashMap<String, Type>()); // } // // public TypeScope() { // this(null, new HashMap<String, Type>()); // } // // public void define(String name, Type type) { // scope.put(name, type); // } // // public Type get(String name) { // Type res = scope.get(name); // if (res == null && parent != null) { // res = parent.get(name); // } // return res; // } // // public TypeScope child() { // return new TypeScope(this); // } // // @Override // public String toString() { // return scope + (parent == null ? "-|" : "->" + parent); // } // } // Path: src/main/java/litil/tc/HMTypeChecker.java import litil.TypeScope; import litil.ast.*; import java.util.*; package litil.tc; public class HMTypeChecker { private static int _id = 0;
public Type analyze(AstNode node, TypeScope env) {
jawher/litil
src/main/java/litil/ast/Expr.java
// Path: src/main/java/litil/TypeScope.java // public class TypeScope { // // private final Map<String, Type> scope; // private final TypeScope parent; // // private TypeScope(TypeScope parent, Map<String, Type> scope) { // this.parent = parent; // this.scope = scope; // } // // public TypeScope(TypeScope parent) { // this(parent, new HashMap<String, Type>()); // } // // public TypeScope() { // this(null, new HashMap<String, Type>()); // } // // public void define(String name, Type type) { // scope.put(name, type); // } // // public Type get(String name) { // Type res = scope.get(name); // if (res == null && parent != null) { // res = parent.get(name); // } // return res; // } // // public TypeScope child() { // return new TypeScope(this); // } // // @Override // public String toString() { // return scope + (parent == null ? "-|" : "->" + parent); // } // } // // Path: src/main/java/litil/Utils.java // public class Utils { // public static String tab(int depth) { // return ntimes(depth, "\t"); // } // // public static String ntimes(int count, String s) { // StringBuilder res = new StringBuilder(""); // for (int i = 0; i < count; i++) { // res.append(s); // } // // return res.toString(); // } // // public static PrintStream indenting(String pkg) { // return new PrintStream(System.out) { // @Override // public void println(String s) { // super.println(s); // } // }; // } // }
import litil.TypeScope; import litil.Utils; import java.util.List; import java.util.Map;
package litil.ast; public abstract class Expr extends Instruction { public static final class EName extends Expr { public final String name; public EName(String name) { this.name = name; }
// Path: src/main/java/litil/TypeScope.java // public class TypeScope { // // private final Map<String, Type> scope; // private final TypeScope parent; // // private TypeScope(TypeScope parent, Map<String, Type> scope) { // this.parent = parent; // this.scope = scope; // } // // public TypeScope(TypeScope parent) { // this(parent, new HashMap<String, Type>()); // } // // public TypeScope() { // this(null, new HashMap<String, Type>()); // } // // public void define(String name, Type type) { // scope.put(name, type); // } // // public Type get(String name) { // Type res = scope.get(name); // if (res == null && parent != null) { // res = parent.get(name); // } // return res; // } // // public TypeScope child() { // return new TypeScope(this); // } // // @Override // public String toString() { // return scope + (parent == null ? "-|" : "->" + parent); // } // } // // Path: src/main/java/litil/Utils.java // public class Utils { // public static String tab(int depth) { // return ntimes(depth, "\t"); // } // // public static String ntimes(int count, String s) { // StringBuilder res = new StringBuilder(""); // for (int i = 0; i < count; i++) { // res.append(s); // } // // return res.toString(); // } // // public static PrintStream indenting(String pkg) { // return new PrintStream(System.out) { // @Override // public void println(String s) { // super.println(s); // } // }; // } // } // Path: src/main/java/litil/ast/Expr.java import litil.TypeScope; import litil.Utils; import java.util.List; import java.util.Map; package litil.ast; public abstract class Expr extends Instruction { public static final class EName extends Expr { public final String name; public EName(String name) { this.name = name; }
public EName(String name, TypeScope scope) {
jawher/litil
src/main/java/litil/ast/Expr.java
// Path: src/main/java/litil/TypeScope.java // public class TypeScope { // // private final Map<String, Type> scope; // private final TypeScope parent; // // private TypeScope(TypeScope parent, Map<String, Type> scope) { // this.parent = parent; // this.scope = scope; // } // // public TypeScope(TypeScope parent) { // this(parent, new HashMap<String, Type>()); // } // // public TypeScope() { // this(null, new HashMap<String, Type>()); // } // // public void define(String name, Type type) { // scope.put(name, type); // } // // public Type get(String name) { // Type res = scope.get(name); // if (res == null && parent != null) { // res = parent.get(name); // } // return res; // } // // public TypeScope child() { // return new TypeScope(this); // } // // @Override // public String toString() { // return scope + (parent == null ? "-|" : "->" + parent); // } // } // // Path: src/main/java/litil/Utils.java // public class Utils { // public static String tab(int depth) { // return ntimes(depth, "\t"); // } // // public static String ntimes(int count, String s) { // StringBuilder res = new StringBuilder(""); // for (int i = 0; i < count; i++) { // res.append(s); // } // // return res.toString(); // } // // public static PrintStream indenting(String pkg) { // return new PrintStream(System.out) { // @Override // public void println(String s) { // super.println(s); // } // }; // } // }
import litil.TypeScope; import litil.Utils; import java.util.List; import java.util.Map;
package litil.ast; public abstract class Expr extends Instruction { public static final class EName extends Expr { public final String name; public EName(String name) { this.name = name; } public EName(String name, TypeScope scope) { this.name = name; this.scope = scope; } @Override public String repr(int indent) {
// Path: src/main/java/litil/TypeScope.java // public class TypeScope { // // private final Map<String, Type> scope; // private final TypeScope parent; // // private TypeScope(TypeScope parent, Map<String, Type> scope) { // this.parent = parent; // this.scope = scope; // } // // public TypeScope(TypeScope parent) { // this(parent, new HashMap<String, Type>()); // } // // public TypeScope() { // this(null, new HashMap<String, Type>()); // } // // public void define(String name, Type type) { // scope.put(name, type); // } // // public Type get(String name) { // Type res = scope.get(name); // if (res == null && parent != null) { // res = parent.get(name); // } // return res; // } // // public TypeScope child() { // return new TypeScope(this); // } // // @Override // public String toString() { // return scope + (parent == null ? "-|" : "->" + parent); // } // } // // Path: src/main/java/litil/Utils.java // public class Utils { // public static String tab(int depth) { // return ntimes(depth, "\t"); // } // // public static String ntimes(int count, String s) { // StringBuilder res = new StringBuilder(""); // for (int i = 0; i < count; i++) { // res.append(s); // } // // return res.toString(); // } // // public static PrintStream indenting(String pkg) { // return new PrintStream(System.out) { // @Override // public void println(String s) { // super.println(s); // } // }; // } // } // Path: src/main/java/litil/ast/Expr.java import litil.TypeScope; import litil.Utils; import java.util.List; import java.util.Map; package litil.ast; public abstract class Expr extends Instruction { public static final class EName extends Expr { public final String name; public EName(String name) { this.name = name; } public EName(String name, TypeScope scope) { this.name = name; this.scope = scope; } @Override public String repr(int indent) {
return Utils.tab(indent) + name;
linheimx/LChart
app/src/main/java/com/linheimx/app/lchart/TouchProcessActivity.java
// Path: app/src/main/java/com/linheimx/app/lchart/fragment/LineChartFragment.java // public class LineChartFragment extends Fragment { // // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // View view = inflater.inflate(R.layout.fragment_line_chart, container, false); // LineChart lineChart = (LineChart) view.findViewById(R.id.chart); // // setChartData(lineChart); // return view; // } // // // private void setChartData(LineChart lineChart) { // // // 高亮 // HighLight highLight = lineChart.get_HighLight1(); // highLight.setEnable(true);// 启用高亮显示 默认为启用状态 // highLight.setxValueAdapter(new IValueAdapter() { // @Override // public String value2String(double value) { // return "X:" + value; // } // }); // highLight.setyValueAdapter(new IValueAdapter() { // @Override // public String value2String(double value) { // return "Y:" + value; // } // }); // // // x,y轴上的单位 // XAxis xAxis = lineChart.get_XAxis(); // xAxis.set_unit("单位:s"); // xAxis.set_ValueAdapter(new DefaultValueAdapter(1)); // // YAxis yAxis = lineChart.get_YAxis(); // yAxis.set_unit("单位:m"); // yAxis.set_ValueAdapter(new DefaultValueAdapter(3));// 默认精度到小数点后2位,现在修改为3位精度 // // // 数据 // Line line = new Line(); // List<Entry> list = new ArrayList<>(); // list.add(new Entry(1, 5)); // list.add(new Entry(2, 4)); // list.add(new Entry(3, 2)); // list.add(new Entry(4, 3)); // list.add(new Entry(10, 8)); // line.setEntries(list); // // Lines lines = new Lines(); // lines.addLine(line); // // // lineChart.setLines(lines); // } // } // // Path: app/src/main/java/com/linheimx/app/lchart/fragment/ScrollView_Fragment.java // public class ScrollView_Fragment extends Fragment { // // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, // Bundle savedInstanceState) { // // View view = inflater.inflate(R.layout.fragment_scroll_view_, container, false); // return view; // } // // } // // Path: app/src/main/java/com/linheimx/app/lchart/fragment/ViewPager_Fragment.java // public class ViewPager_Fragment extends Fragment { // // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, // Bundle savedInstanceState) { // // View view = inflater.inflate(R.layout.fragment_view_pager_, container, false); // // TabLayout tabLayout = (TabLayout) view.findViewById(R.id.tab); // ViewPager viewPager = (ViewPager) view.findViewById(R.id.viewpager); // // viewPager.setOffscreenPageLimit(2); // viewPager.setAdapter(new Adapter(getChildFragmentManager())); // tabLayout.setupWithViewPager(viewPager); // // return view; // } // // // class Adapter extends FragmentStatePagerAdapter { // // List<Fragment> list; // // public Adapter(FragmentManager fm) { // super(fm); // // list = new ArrayList<>(); // list.add(new LineChartFragment()); // list.add(new LineChartFragment()); // list.add(new LineChartFragment()); // } // // @Override // public int getCount() { // return list.size(); // } // // @Override // public Fragment getItem(int position) { // return list.get(position); // } // // @Override // public CharSequence getPageTitle(int position) { // return "chart " + position; // } // } // }
import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import com.linheimx.app.lchart.fragment.LineChartFragment; import com.linheimx.app.lchart.fragment.ScrollView_Fragment; import com.linheimx.app.lchart.fragment.ViewPager_Fragment; import java.util.ArrayList; import java.util.List;
package com.linheimx.app.lchart; public class TouchProcessActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_touch_process); getSupportActionBar().setTitle("滑动冲突的处理"); } public void btn_vp(View view) { FragmentManager fm = getSupportFragmentManager(); fm.beginTransaction()
// Path: app/src/main/java/com/linheimx/app/lchart/fragment/LineChartFragment.java // public class LineChartFragment extends Fragment { // // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // View view = inflater.inflate(R.layout.fragment_line_chart, container, false); // LineChart lineChart = (LineChart) view.findViewById(R.id.chart); // // setChartData(lineChart); // return view; // } // // // private void setChartData(LineChart lineChart) { // // // 高亮 // HighLight highLight = lineChart.get_HighLight1(); // highLight.setEnable(true);// 启用高亮显示 默认为启用状态 // highLight.setxValueAdapter(new IValueAdapter() { // @Override // public String value2String(double value) { // return "X:" + value; // } // }); // highLight.setyValueAdapter(new IValueAdapter() { // @Override // public String value2String(double value) { // return "Y:" + value; // } // }); // // // x,y轴上的单位 // XAxis xAxis = lineChart.get_XAxis(); // xAxis.set_unit("单位:s"); // xAxis.set_ValueAdapter(new DefaultValueAdapter(1)); // // YAxis yAxis = lineChart.get_YAxis(); // yAxis.set_unit("单位:m"); // yAxis.set_ValueAdapter(new DefaultValueAdapter(3));// 默认精度到小数点后2位,现在修改为3位精度 // // // 数据 // Line line = new Line(); // List<Entry> list = new ArrayList<>(); // list.add(new Entry(1, 5)); // list.add(new Entry(2, 4)); // list.add(new Entry(3, 2)); // list.add(new Entry(4, 3)); // list.add(new Entry(10, 8)); // line.setEntries(list); // // Lines lines = new Lines(); // lines.addLine(line); // // // lineChart.setLines(lines); // } // } // // Path: app/src/main/java/com/linheimx/app/lchart/fragment/ScrollView_Fragment.java // public class ScrollView_Fragment extends Fragment { // // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, // Bundle savedInstanceState) { // // View view = inflater.inflate(R.layout.fragment_scroll_view_, container, false); // return view; // } // // } // // Path: app/src/main/java/com/linheimx/app/lchart/fragment/ViewPager_Fragment.java // public class ViewPager_Fragment extends Fragment { // // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, // Bundle savedInstanceState) { // // View view = inflater.inflate(R.layout.fragment_view_pager_, container, false); // // TabLayout tabLayout = (TabLayout) view.findViewById(R.id.tab); // ViewPager viewPager = (ViewPager) view.findViewById(R.id.viewpager); // // viewPager.setOffscreenPageLimit(2); // viewPager.setAdapter(new Adapter(getChildFragmentManager())); // tabLayout.setupWithViewPager(viewPager); // // return view; // } // // // class Adapter extends FragmentStatePagerAdapter { // // List<Fragment> list; // // public Adapter(FragmentManager fm) { // super(fm); // // list = new ArrayList<>(); // list.add(new LineChartFragment()); // list.add(new LineChartFragment()); // list.add(new LineChartFragment()); // } // // @Override // public int getCount() { // return list.size(); // } // // @Override // public Fragment getItem(int position) { // return list.get(position); // } // // @Override // public CharSequence getPageTitle(int position) { // return "chart " + position; // } // } // } // Path: app/src/main/java/com/linheimx/app/lchart/TouchProcessActivity.java import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import com.linheimx.app.lchart.fragment.LineChartFragment; import com.linheimx.app.lchart.fragment.ScrollView_Fragment; import com.linheimx.app.lchart.fragment.ViewPager_Fragment; import java.util.ArrayList; import java.util.List; package com.linheimx.app.lchart; public class TouchProcessActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_touch_process); getSupportActionBar().setTitle("滑动冲突的处理"); } public void btn_vp(View view) { FragmentManager fm = getSupportFragmentManager(); fm.beginTransaction()
.replace(R.id.content, new ViewPager_Fragment())
linheimx/LChart
app/src/main/java/com/linheimx/app/lchart/TouchProcessActivity.java
// Path: app/src/main/java/com/linheimx/app/lchart/fragment/LineChartFragment.java // public class LineChartFragment extends Fragment { // // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // View view = inflater.inflate(R.layout.fragment_line_chart, container, false); // LineChart lineChart = (LineChart) view.findViewById(R.id.chart); // // setChartData(lineChart); // return view; // } // // // private void setChartData(LineChart lineChart) { // // // 高亮 // HighLight highLight = lineChart.get_HighLight1(); // highLight.setEnable(true);// 启用高亮显示 默认为启用状态 // highLight.setxValueAdapter(new IValueAdapter() { // @Override // public String value2String(double value) { // return "X:" + value; // } // }); // highLight.setyValueAdapter(new IValueAdapter() { // @Override // public String value2String(double value) { // return "Y:" + value; // } // }); // // // x,y轴上的单位 // XAxis xAxis = lineChart.get_XAxis(); // xAxis.set_unit("单位:s"); // xAxis.set_ValueAdapter(new DefaultValueAdapter(1)); // // YAxis yAxis = lineChart.get_YAxis(); // yAxis.set_unit("单位:m"); // yAxis.set_ValueAdapter(new DefaultValueAdapter(3));// 默认精度到小数点后2位,现在修改为3位精度 // // // 数据 // Line line = new Line(); // List<Entry> list = new ArrayList<>(); // list.add(new Entry(1, 5)); // list.add(new Entry(2, 4)); // list.add(new Entry(3, 2)); // list.add(new Entry(4, 3)); // list.add(new Entry(10, 8)); // line.setEntries(list); // // Lines lines = new Lines(); // lines.addLine(line); // // // lineChart.setLines(lines); // } // } // // Path: app/src/main/java/com/linheimx/app/lchart/fragment/ScrollView_Fragment.java // public class ScrollView_Fragment extends Fragment { // // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, // Bundle savedInstanceState) { // // View view = inflater.inflate(R.layout.fragment_scroll_view_, container, false); // return view; // } // // } // // Path: app/src/main/java/com/linheimx/app/lchart/fragment/ViewPager_Fragment.java // public class ViewPager_Fragment extends Fragment { // // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, // Bundle savedInstanceState) { // // View view = inflater.inflate(R.layout.fragment_view_pager_, container, false); // // TabLayout tabLayout = (TabLayout) view.findViewById(R.id.tab); // ViewPager viewPager = (ViewPager) view.findViewById(R.id.viewpager); // // viewPager.setOffscreenPageLimit(2); // viewPager.setAdapter(new Adapter(getChildFragmentManager())); // tabLayout.setupWithViewPager(viewPager); // // return view; // } // // // class Adapter extends FragmentStatePagerAdapter { // // List<Fragment> list; // // public Adapter(FragmentManager fm) { // super(fm); // // list = new ArrayList<>(); // list.add(new LineChartFragment()); // list.add(new LineChartFragment()); // list.add(new LineChartFragment()); // } // // @Override // public int getCount() { // return list.size(); // } // // @Override // public Fragment getItem(int position) { // return list.get(position); // } // // @Override // public CharSequence getPageTitle(int position) { // return "chart " + position; // } // } // }
import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import com.linheimx.app.lchart.fragment.LineChartFragment; import com.linheimx.app.lchart.fragment.ScrollView_Fragment; import com.linheimx.app.lchart.fragment.ViewPager_Fragment; import java.util.ArrayList; import java.util.List;
package com.linheimx.app.lchart; public class TouchProcessActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_touch_process); getSupportActionBar().setTitle("滑动冲突的处理"); } public void btn_vp(View view) { FragmentManager fm = getSupportFragmentManager(); fm.beginTransaction() .replace(R.id.content, new ViewPager_Fragment()) .commit(); } public void btn_sv(View view) { FragmentManager fm = getSupportFragmentManager(); fm.beginTransaction()
// Path: app/src/main/java/com/linheimx/app/lchart/fragment/LineChartFragment.java // public class LineChartFragment extends Fragment { // // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // View view = inflater.inflate(R.layout.fragment_line_chart, container, false); // LineChart lineChart = (LineChart) view.findViewById(R.id.chart); // // setChartData(lineChart); // return view; // } // // // private void setChartData(LineChart lineChart) { // // // 高亮 // HighLight highLight = lineChart.get_HighLight1(); // highLight.setEnable(true);// 启用高亮显示 默认为启用状态 // highLight.setxValueAdapter(new IValueAdapter() { // @Override // public String value2String(double value) { // return "X:" + value; // } // }); // highLight.setyValueAdapter(new IValueAdapter() { // @Override // public String value2String(double value) { // return "Y:" + value; // } // }); // // // x,y轴上的单位 // XAxis xAxis = lineChart.get_XAxis(); // xAxis.set_unit("单位:s"); // xAxis.set_ValueAdapter(new DefaultValueAdapter(1)); // // YAxis yAxis = lineChart.get_YAxis(); // yAxis.set_unit("单位:m"); // yAxis.set_ValueAdapter(new DefaultValueAdapter(3));// 默认精度到小数点后2位,现在修改为3位精度 // // // 数据 // Line line = new Line(); // List<Entry> list = new ArrayList<>(); // list.add(new Entry(1, 5)); // list.add(new Entry(2, 4)); // list.add(new Entry(3, 2)); // list.add(new Entry(4, 3)); // list.add(new Entry(10, 8)); // line.setEntries(list); // // Lines lines = new Lines(); // lines.addLine(line); // // // lineChart.setLines(lines); // } // } // // Path: app/src/main/java/com/linheimx/app/lchart/fragment/ScrollView_Fragment.java // public class ScrollView_Fragment extends Fragment { // // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, // Bundle savedInstanceState) { // // View view = inflater.inflate(R.layout.fragment_scroll_view_, container, false); // return view; // } // // } // // Path: app/src/main/java/com/linheimx/app/lchart/fragment/ViewPager_Fragment.java // public class ViewPager_Fragment extends Fragment { // // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, // Bundle savedInstanceState) { // // View view = inflater.inflate(R.layout.fragment_view_pager_, container, false); // // TabLayout tabLayout = (TabLayout) view.findViewById(R.id.tab); // ViewPager viewPager = (ViewPager) view.findViewById(R.id.viewpager); // // viewPager.setOffscreenPageLimit(2); // viewPager.setAdapter(new Adapter(getChildFragmentManager())); // tabLayout.setupWithViewPager(viewPager); // // return view; // } // // // class Adapter extends FragmentStatePagerAdapter { // // List<Fragment> list; // // public Adapter(FragmentManager fm) { // super(fm); // // list = new ArrayList<>(); // list.add(new LineChartFragment()); // list.add(new LineChartFragment()); // list.add(new LineChartFragment()); // } // // @Override // public int getCount() { // return list.size(); // } // // @Override // public Fragment getItem(int position) { // return list.get(position); // } // // @Override // public CharSequence getPageTitle(int position) { // return "chart " + position; // } // } // } // Path: app/src/main/java/com/linheimx/app/lchart/TouchProcessActivity.java import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import com.linheimx.app.lchart.fragment.LineChartFragment; import com.linheimx.app.lchart.fragment.ScrollView_Fragment; import com.linheimx.app.lchart.fragment.ViewPager_Fragment; import java.util.ArrayList; import java.util.List; package com.linheimx.app.lchart; public class TouchProcessActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_touch_process); getSupportActionBar().setTitle("滑动冲突的处理"); } public void btn_vp(View view) { FragmentManager fm = getSupportFragmentManager(); fm.beginTransaction() .replace(R.id.content, new ViewPager_Fragment()) .commit(); } public void btn_sv(View view) { FragmentManager fm = getSupportFragmentManager(); fm.beginTransaction()
.replace(R.id.content, new ScrollView_Fragment())
linheimx/LChart
library/src/main/java/com/linheimx/app/library/model/YAxis.java
// Path: library/src/main/java/com/linheimx/app/library/utils/Utils.java // public class Utils { // // public static float dp2px(float dp) { // return (int) (dp * Resources.getSystem().getDisplayMetrics().density); // } // // public static float textWidth(Paint paint, String txt) { // return paint.measureText(txt); // } // // private static Paint.FontMetrics mFontMetrics = new Paint.FontMetrics(); // // public static int textHeightAsc(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent)); // } // // public static int textHeight(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent) + Math.abs(mFontMetrics.descent)); // } // // /** // * 将杂乱的数字变成里程碑。 // * // * @param number // * @return // */ // public static float roundNumber2One(double number) { // if (Double.isInfinite(number) || // Double.isNaN(number) || // number == 0.0) // return 0; // // final float d = (float) Math.ceil((float) Math.log10(number < 0 ? -number : number));//有几位? // final int pw = 1 - (int) d; // final float magnitude = (float) Math.pow(10, pw); // final long shifted = Math.round(number * magnitude); // return shifted / magnitude; // } // // // }
import com.linheimx.app.library.utils.Utils;
package com.linheimx.app.library.model; /** * Created by lijian on 2016/12/5. */ public class YAxis extends Axis { public static final float AREA_UNIT = 14;// unit 区域的高 public static final float AREA_LABEL = 14;// label 区域的高 public YAxis() { super();
// Path: library/src/main/java/com/linheimx/app/library/utils/Utils.java // public class Utils { // // public static float dp2px(float dp) { // return (int) (dp * Resources.getSystem().getDisplayMetrics().density); // } // // public static float textWidth(Paint paint, String txt) { // return paint.measureText(txt); // } // // private static Paint.FontMetrics mFontMetrics = new Paint.FontMetrics(); // // public static int textHeightAsc(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent)); // } // // public static int textHeight(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent) + Math.abs(mFontMetrics.descent)); // } // // /** // * 将杂乱的数字变成里程碑。 // * // * @param number // * @return // */ // public static float roundNumber2One(double number) { // if (Double.isInfinite(number) || // Double.isNaN(number) || // number == 0.0) // return 0; // // final float d = (float) Math.ceil((float) Math.log10(number < 0 ? -number : number));//有几位? // final int pw = 1 - (int) d; // final float magnitude = (float) Math.pow(10, pw); // final long shifted = Math.round(number * magnitude); // return shifted / magnitude; // } // // // } // Path: library/src/main/java/com/linheimx/app/library/model/YAxis.java import com.linheimx.app.library.utils.Utils; package com.linheimx.app.library.model; /** * Created by lijian on 2016/12/5. */ public class YAxis extends Axis { public static final float AREA_UNIT = 14;// unit 区域的高 public static final float AREA_LABEL = 14;// label 区域的高 public YAxis() { super();
labelDimen = Utils.dp2px(AREA_LABEL);
linheimx/LChart
library/src/main/java/com/linheimx/app/library/model/HighLight.java
// Path: library/src/main/java/com/linheimx/app/library/adapter/DefaultHighLightValueAdapter.java // public class DefaultHighLightValueAdapter implements IValueAdapter { // // public DefaultHighLightValueAdapter() { // // } // // @Override // public String value2String(double value) { // return value + ""; // } // // } // // Path: library/src/main/java/com/linheimx/app/library/adapter/IValueAdapter.java // public interface IValueAdapter { // String value2String(double value); // } // // Path: library/src/main/java/com/linheimx/app/library/utils/Utils.java // public class Utils { // // public static float dp2px(float dp) { // return (int) (dp * Resources.getSystem().getDisplayMetrics().density); // } // // public static float textWidth(Paint paint, String txt) { // return paint.measureText(txt); // } // // private static Paint.FontMetrics mFontMetrics = new Paint.FontMetrics(); // // public static int textHeightAsc(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent)); // } // // public static int textHeight(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent) + Math.abs(mFontMetrics.descent)); // } // // /** // * 将杂乱的数字变成里程碑。 // * // * @param number // * @return // */ // public static float roundNumber2One(double number) { // if (Double.isInfinite(number) || // Double.isNaN(number) || // number == 0.0) // return 0; // // final float d = (float) Math.ceil((float) Math.log10(number < 0 ? -number : number));//有几位? // final int pw = 1 - (int) d; // final float magnitude = (float) Math.pow(10, pw); // final long shifted = Math.round(number * magnitude); // return shifted / magnitude; // } // // // }
import android.graphics.Color; import com.linheimx.app.library.adapter.DefaultHighLightValueAdapter; import com.linheimx.app.library.adapter.IValueAdapter; import com.linheimx.app.library.utils.Utils;
package com.linheimx.app.library.model; /** * Created by lijian on 2016/12/15. */ public class HighLight { public static final float D_HIGHLIGHT_WIDTH = 1; public static final float D_HINT_TEXT_SIZE = 15; //////////////////////// high light //////////////////////// int highLightColor = Color.RED; float highLightWidth; //////////////////////// hint //////////////////////// int hintColor = Color.BLACK; float hintTextSize; boolean enable = false; boolean isDrawHighLine = true; boolean isDrawHint = true;
// Path: library/src/main/java/com/linheimx/app/library/adapter/DefaultHighLightValueAdapter.java // public class DefaultHighLightValueAdapter implements IValueAdapter { // // public DefaultHighLightValueAdapter() { // // } // // @Override // public String value2String(double value) { // return value + ""; // } // // } // // Path: library/src/main/java/com/linheimx/app/library/adapter/IValueAdapter.java // public interface IValueAdapter { // String value2String(double value); // } // // Path: library/src/main/java/com/linheimx/app/library/utils/Utils.java // public class Utils { // // public static float dp2px(float dp) { // return (int) (dp * Resources.getSystem().getDisplayMetrics().density); // } // // public static float textWidth(Paint paint, String txt) { // return paint.measureText(txt); // } // // private static Paint.FontMetrics mFontMetrics = new Paint.FontMetrics(); // // public static int textHeightAsc(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent)); // } // // public static int textHeight(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent) + Math.abs(mFontMetrics.descent)); // } // // /** // * 将杂乱的数字变成里程碑。 // * // * @param number // * @return // */ // public static float roundNumber2One(double number) { // if (Double.isInfinite(number) || // Double.isNaN(number) || // number == 0.0) // return 0; // // final float d = (float) Math.ceil((float) Math.log10(number < 0 ? -number : number));//有几位? // final int pw = 1 - (int) d; // final float magnitude = (float) Math.pow(10, pw); // final long shifted = Math.round(number * magnitude); // return shifted / magnitude; // } // // // } // Path: library/src/main/java/com/linheimx/app/library/model/HighLight.java import android.graphics.Color; import com.linheimx.app.library.adapter.DefaultHighLightValueAdapter; import com.linheimx.app.library.adapter.IValueAdapter; import com.linheimx.app.library.utils.Utils; package com.linheimx.app.library.model; /** * Created by lijian on 2016/12/15. */ public class HighLight { public static final float D_HIGHLIGHT_WIDTH = 1; public static final float D_HINT_TEXT_SIZE = 15; //////////////////////// high light //////////////////////// int highLightColor = Color.RED; float highLightWidth; //////////////////////// hint //////////////////////// int hintColor = Color.BLACK; float hintTextSize; boolean enable = false; boolean isDrawHighLine = true; boolean isDrawHint = true;
protected IValueAdapter xValueAdapter;// 高亮时,x应该如何显示?
linheimx/LChart
library/src/main/java/com/linheimx/app/library/model/HighLight.java
// Path: library/src/main/java/com/linheimx/app/library/adapter/DefaultHighLightValueAdapter.java // public class DefaultHighLightValueAdapter implements IValueAdapter { // // public DefaultHighLightValueAdapter() { // // } // // @Override // public String value2String(double value) { // return value + ""; // } // // } // // Path: library/src/main/java/com/linheimx/app/library/adapter/IValueAdapter.java // public interface IValueAdapter { // String value2String(double value); // } // // Path: library/src/main/java/com/linheimx/app/library/utils/Utils.java // public class Utils { // // public static float dp2px(float dp) { // return (int) (dp * Resources.getSystem().getDisplayMetrics().density); // } // // public static float textWidth(Paint paint, String txt) { // return paint.measureText(txt); // } // // private static Paint.FontMetrics mFontMetrics = new Paint.FontMetrics(); // // public static int textHeightAsc(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent)); // } // // public static int textHeight(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent) + Math.abs(mFontMetrics.descent)); // } // // /** // * 将杂乱的数字变成里程碑。 // * // * @param number // * @return // */ // public static float roundNumber2One(double number) { // if (Double.isInfinite(number) || // Double.isNaN(number) || // number == 0.0) // return 0; // // final float d = (float) Math.ceil((float) Math.log10(number < 0 ? -number : number));//有几位? // final int pw = 1 - (int) d; // final float magnitude = (float) Math.pow(10, pw); // final long shifted = Math.round(number * magnitude); // return shifted / magnitude; // } // // // }
import android.graphics.Color; import com.linheimx.app.library.adapter.DefaultHighLightValueAdapter; import com.linheimx.app.library.adapter.IValueAdapter; import com.linheimx.app.library.utils.Utils;
package com.linheimx.app.library.model; /** * Created by lijian on 2016/12/15. */ public class HighLight { public static final float D_HIGHLIGHT_WIDTH = 1; public static final float D_HINT_TEXT_SIZE = 15; //////////////////////// high light //////////////////////// int highLightColor = Color.RED; float highLightWidth; //////////////////////// hint //////////////////////// int hintColor = Color.BLACK; float hintTextSize; boolean enable = false; boolean isDrawHighLine = true; boolean isDrawHint = true; protected IValueAdapter xValueAdapter;// 高亮时,x应该如何显示? protected IValueAdapter yValueAdapter;// 高亮时,y应该如何显示? public HighLight() {
// Path: library/src/main/java/com/linheimx/app/library/adapter/DefaultHighLightValueAdapter.java // public class DefaultHighLightValueAdapter implements IValueAdapter { // // public DefaultHighLightValueAdapter() { // // } // // @Override // public String value2String(double value) { // return value + ""; // } // // } // // Path: library/src/main/java/com/linheimx/app/library/adapter/IValueAdapter.java // public interface IValueAdapter { // String value2String(double value); // } // // Path: library/src/main/java/com/linheimx/app/library/utils/Utils.java // public class Utils { // // public static float dp2px(float dp) { // return (int) (dp * Resources.getSystem().getDisplayMetrics().density); // } // // public static float textWidth(Paint paint, String txt) { // return paint.measureText(txt); // } // // private static Paint.FontMetrics mFontMetrics = new Paint.FontMetrics(); // // public static int textHeightAsc(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent)); // } // // public static int textHeight(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent) + Math.abs(mFontMetrics.descent)); // } // // /** // * 将杂乱的数字变成里程碑。 // * // * @param number // * @return // */ // public static float roundNumber2One(double number) { // if (Double.isInfinite(number) || // Double.isNaN(number) || // number == 0.0) // return 0; // // final float d = (float) Math.ceil((float) Math.log10(number < 0 ? -number : number));//有几位? // final int pw = 1 - (int) d; // final float magnitude = (float) Math.pow(10, pw); // final long shifted = Math.round(number * magnitude); // return shifted / magnitude; // } // // // } // Path: library/src/main/java/com/linheimx/app/library/model/HighLight.java import android.graphics.Color; import com.linheimx.app.library.adapter.DefaultHighLightValueAdapter; import com.linheimx.app.library.adapter.IValueAdapter; import com.linheimx.app.library.utils.Utils; package com.linheimx.app.library.model; /** * Created by lijian on 2016/12/15. */ public class HighLight { public static final float D_HIGHLIGHT_WIDTH = 1; public static final float D_HINT_TEXT_SIZE = 15; //////////////////////// high light //////////////////////// int highLightColor = Color.RED; float highLightWidth; //////////////////////// hint //////////////////////// int hintColor = Color.BLACK; float hintTextSize; boolean enable = false; boolean isDrawHighLine = true; boolean isDrawHint = true; protected IValueAdapter xValueAdapter;// 高亮时,x应该如何显示? protected IValueAdapter yValueAdapter;// 高亮时,y应该如何显示? public HighLight() {
highLightWidth = Utils.dp2px(D_HIGHLIGHT_WIDTH);
linheimx/LChart
library/src/main/java/com/linheimx/app/library/model/HighLight.java
// Path: library/src/main/java/com/linheimx/app/library/adapter/DefaultHighLightValueAdapter.java // public class DefaultHighLightValueAdapter implements IValueAdapter { // // public DefaultHighLightValueAdapter() { // // } // // @Override // public String value2String(double value) { // return value + ""; // } // // } // // Path: library/src/main/java/com/linheimx/app/library/adapter/IValueAdapter.java // public interface IValueAdapter { // String value2String(double value); // } // // Path: library/src/main/java/com/linheimx/app/library/utils/Utils.java // public class Utils { // // public static float dp2px(float dp) { // return (int) (dp * Resources.getSystem().getDisplayMetrics().density); // } // // public static float textWidth(Paint paint, String txt) { // return paint.measureText(txt); // } // // private static Paint.FontMetrics mFontMetrics = new Paint.FontMetrics(); // // public static int textHeightAsc(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent)); // } // // public static int textHeight(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent) + Math.abs(mFontMetrics.descent)); // } // // /** // * 将杂乱的数字变成里程碑。 // * // * @param number // * @return // */ // public static float roundNumber2One(double number) { // if (Double.isInfinite(number) || // Double.isNaN(number) || // number == 0.0) // return 0; // // final float d = (float) Math.ceil((float) Math.log10(number < 0 ? -number : number));//有几位? // final int pw = 1 - (int) d; // final float magnitude = (float) Math.pow(10, pw); // final long shifted = Math.round(number * magnitude); // return shifted / magnitude; // } // // // }
import android.graphics.Color; import com.linheimx.app.library.adapter.DefaultHighLightValueAdapter; import com.linheimx.app.library.adapter.IValueAdapter; import com.linheimx.app.library.utils.Utils;
package com.linheimx.app.library.model; /** * Created by lijian on 2016/12/15. */ public class HighLight { public static final float D_HIGHLIGHT_WIDTH = 1; public static final float D_HINT_TEXT_SIZE = 15; //////////////////////// high light //////////////////////// int highLightColor = Color.RED; float highLightWidth; //////////////////////// hint //////////////////////// int hintColor = Color.BLACK; float hintTextSize; boolean enable = false; boolean isDrawHighLine = true; boolean isDrawHint = true; protected IValueAdapter xValueAdapter;// 高亮时,x应该如何显示? protected IValueAdapter yValueAdapter;// 高亮时,y应该如何显示? public HighLight() { highLightWidth = Utils.dp2px(D_HIGHLIGHT_WIDTH); hintTextSize = Utils.dp2px(D_HINT_TEXT_SIZE);
// Path: library/src/main/java/com/linheimx/app/library/adapter/DefaultHighLightValueAdapter.java // public class DefaultHighLightValueAdapter implements IValueAdapter { // // public DefaultHighLightValueAdapter() { // // } // // @Override // public String value2String(double value) { // return value + ""; // } // // } // // Path: library/src/main/java/com/linheimx/app/library/adapter/IValueAdapter.java // public interface IValueAdapter { // String value2String(double value); // } // // Path: library/src/main/java/com/linheimx/app/library/utils/Utils.java // public class Utils { // // public static float dp2px(float dp) { // return (int) (dp * Resources.getSystem().getDisplayMetrics().density); // } // // public static float textWidth(Paint paint, String txt) { // return paint.measureText(txt); // } // // private static Paint.FontMetrics mFontMetrics = new Paint.FontMetrics(); // // public static int textHeightAsc(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent)); // } // // public static int textHeight(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent) + Math.abs(mFontMetrics.descent)); // } // // /** // * 将杂乱的数字变成里程碑。 // * // * @param number // * @return // */ // public static float roundNumber2One(double number) { // if (Double.isInfinite(number) || // Double.isNaN(number) || // number == 0.0) // return 0; // // final float d = (float) Math.ceil((float) Math.log10(number < 0 ? -number : number));//有几位? // final int pw = 1 - (int) d; // final float magnitude = (float) Math.pow(10, pw); // final long shifted = Math.round(number * magnitude); // return shifted / magnitude; // } // // // } // Path: library/src/main/java/com/linheimx/app/library/model/HighLight.java import android.graphics.Color; import com.linheimx.app.library.adapter.DefaultHighLightValueAdapter; import com.linheimx.app.library.adapter.IValueAdapter; import com.linheimx.app.library.utils.Utils; package com.linheimx.app.library.model; /** * Created by lijian on 2016/12/15. */ public class HighLight { public static final float D_HIGHLIGHT_WIDTH = 1; public static final float D_HINT_TEXT_SIZE = 15; //////////////////////// high light //////////////////////// int highLightColor = Color.RED; float highLightWidth; //////////////////////// hint //////////////////////// int hintColor = Color.BLACK; float hintTextSize; boolean enable = false; boolean isDrawHighLine = true; boolean isDrawHint = true; protected IValueAdapter xValueAdapter;// 高亮时,x应该如何显示? protected IValueAdapter yValueAdapter;// 高亮时,y应该如何显示? public HighLight() { highLightWidth = Utils.dp2px(D_HIGHLIGHT_WIDTH); hintTextSize = Utils.dp2px(D_HINT_TEXT_SIZE);
xValueAdapter = new DefaultHighLightValueAdapter();
linheimx/LChart
library/src/main/java/com/linheimx/app/library/model/XAxis.java
// Path: library/src/main/java/com/linheimx/app/library/utils/Utils.java // public class Utils { // // public static float dp2px(float dp) { // return (int) (dp * Resources.getSystem().getDisplayMetrics().density); // } // // public static float textWidth(Paint paint, String txt) { // return paint.measureText(txt); // } // // private static Paint.FontMetrics mFontMetrics = new Paint.FontMetrics(); // // public static int textHeightAsc(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent)); // } // // public static int textHeight(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent) + Math.abs(mFontMetrics.descent)); // } // // /** // * 将杂乱的数字变成里程碑。 // * // * @param number // * @return // */ // public static float roundNumber2One(double number) { // if (Double.isInfinite(number) || // Double.isNaN(number) || // number == 0.0) // return 0; // // final float d = (float) Math.ceil((float) Math.log10(number < 0 ? -number : number));//有几位? // final int pw = 1 - (int) d; // final float magnitude = (float) Math.pow(10, pw); // final long shifted = Math.round(number * magnitude); // return shifted / magnitude; // } // // // }
import com.linheimx.app.library.utils.Utils;
package com.linheimx.app.library.model; /** * Created by lijian on 2016/12/5. */ public class XAxis extends Axis { public static final float AREA_UNIT = 14;// unit 区域的高 public static final float AREA_LABEL = 14;// label 区域的高 public XAxis() { super();
// Path: library/src/main/java/com/linheimx/app/library/utils/Utils.java // public class Utils { // // public static float dp2px(float dp) { // return (int) (dp * Resources.getSystem().getDisplayMetrics().density); // } // // public static float textWidth(Paint paint, String txt) { // return paint.measureText(txt); // } // // private static Paint.FontMetrics mFontMetrics = new Paint.FontMetrics(); // // public static int textHeightAsc(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent)); // } // // public static int textHeight(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent) + Math.abs(mFontMetrics.descent)); // } // // /** // * 将杂乱的数字变成里程碑。 // * // * @param number // * @return // */ // public static float roundNumber2One(double number) { // if (Double.isInfinite(number) || // Double.isNaN(number) || // number == 0.0) // return 0; // // final float d = (float) Math.ceil((float) Math.log10(number < 0 ? -number : number));//有几位? // final int pw = 1 - (int) d; // final float magnitude = (float) Math.pow(10, pw); // final long shifted = Math.round(number * magnitude); // return shifted / magnitude; // } // // // } // Path: library/src/main/java/com/linheimx/app/library/model/XAxis.java import com.linheimx.app.library.utils.Utils; package com.linheimx.app.library.model; /** * Created by lijian on 2016/12/5. */ public class XAxis extends Axis { public static final float AREA_UNIT = 14;// unit 区域的高 public static final float AREA_LABEL = 14;// label 区域的高 public XAxis() { super();
labelDimen = Utils.dp2px(AREA_LABEL);
linheimx/LChart
library/src/main/java/com/linheimx/app/library/model/WarnLine.java
// Path: library/src/main/java/com/linheimx/app/library/utils/Utils.java // public class Utils { // // public static float dp2px(float dp) { // return (int) (dp * Resources.getSystem().getDisplayMetrics().density); // } // // public static float textWidth(Paint paint, String txt) { // return paint.measureText(txt); // } // // private static Paint.FontMetrics mFontMetrics = new Paint.FontMetrics(); // // public static int textHeightAsc(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent)); // } // // public static int textHeight(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent) + Math.abs(mFontMetrics.descent)); // } // // /** // * 将杂乱的数字变成里程碑。 // * // * @param number // * @return // */ // public static float roundNumber2One(double number) { // if (Double.isInfinite(number) || // Double.isNaN(number) || // number == 0.0) // return 0; // // final float d = (float) Math.ceil((float) Math.log10(number < 0 ? -number : number));//有几位? // final int pw = 1 - (int) d; // final float magnitude = (float) Math.pow(10, pw); // final long shifted = Math.round(number * magnitude); // return shifted / magnitude; // } // // // }
import android.graphics.Color; import com.linheimx.app.library.utils.Utils;
package com.linheimx.app.library.model; /** * Created by lijian on 2017/2/18. */ public class WarnLine { public static final float D_WARN_WIDTH = 2; public static final float D_WARN_TXT_SIZE = 15; int warnColor = Color.RED; float warnLineWidth; float txtSize ; boolean enable = true; double value;//预警数值 public WarnLine(double value) { this.value = value;
// Path: library/src/main/java/com/linheimx/app/library/utils/Utils.java // public class Utils { // // public static float dp2px(float dp) { // return (int) (dp * Resources.getSystem().getDisplayMetrics().density); // } // // public static float textWidth(Paint paint, String txt) { // return paint.measureText(txt); // } // // private static Paint.FontMetrics mFontMetrics = new Paint.FontMetrics(); // // public static int textHeightAsc(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent)); // } // // public static int textHeight(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent) + Math.abs(mFontMetrics.descent)); // } // // /** // * 将杂乱的数字变成里程碑。 // * // * @param number // * @return // */ // public static float roundNumber2One(double number) { // if (Double.isInfinite(number) || // Double.isNaN(number) || // number == 0.0) // return 0; // // final float d = (float) Math.ceil((float) Math.log10(number < 0 ? -number : number));//有几位? // final int pw = 1 - (int) d; // final float magnitude = (float) Math.pow(10, pw); // final long shifted = Math.round(number * magnitude); // return shifted / magnitude; // } // // // } // Path: library/src/main/java/com/linheimx/app/library/model/WarnLine.java import android.graphics.Color; import com.linheimx.app.library.utils.Utils; package com.linheimx.app.library.model; /** * Created by lijian on 2017/2/18. */ public class WarnLine { public static final float D_WARN_WIDTH = 2; public static final float D_WARN_TXT_SIZE = 15; int warnColor = Color.RED; float warnLineWidth; float txtSize ; boolean enable = true; double value;//预警数值 public WarnLine(double value) { this.value = value;
warnLineWidth = Utils.dp2px(D_WARN_WIDTH);
linheimx/LChart
library/src/main/java/com/linheimx/app/library/manager/MappingManager.java
// Path: library/src/main/java/com/linheimx/app/library/data/Entry.java // public class Entry { // // double x; // double y; // // boolean isNull_Y = false; // // public Entry(double x, double y) { // this.x = x; // this.y = y; // } // // // public double getX() { // return x; // } // // public Entry setX(double x) { // this.x = x; // return this; // } // // public double getY() { // return y; // } // // public Entry setY(double y) { // this.y = y; // return this; // } // // public boolean isNull_Y() { // return isNull_Y; // } // // public Entry setNull_Y() { // isNull_Y = true; // return this; // } // // @Override // public String toString() { // return "entry x:" + x + " y:" + y; // } // } // // Path: library/src/main/java/com/linheimx/app/library/utils/RectD.java // public class RectD { // // public double left; // public double top; // public double right; // public double bottom; // // public RectD() { // } // // public RectD(double left, double top, double right, double bottom) { // this.left = left; // this.top = top; // this.right = right; // this.bottom = bottom; // } // // public RectD(RectD rectD) { // setRectD(rectD); // } // // public void setRectD(RectD rectD) { // left = rectD.left; // top = rectD.top; // right = rectD.right; // bottom = rectD.bottom; // } // // public double width() { // return right - left; // } // // public double height() { // return top - bottom; // } // // // public String toString() { // return "RectD(" + left + ", " + top + ", " // + right + ", " + bottom + ")"; // } // } // // Path: library/src/main/java/com/linheimx/app/library/utils/SingleD_XY.java // public class SingleD_XY { // private double x; // private double y; // // private static SingleD_XY value; // // private SingleD_XY() { // // } // // public synchronized static SingleD_XY getInstance() { // if (value == null) { // value = new SingleD_XY(); // } // return value; // } // // public double getX() { // return x; // } // // public SingleD_XY setX(double x) { // this.x = x; // return this; // } // // public double getY() { // return y; // } // // public SingleD_XY setY(double y) { // this.y = y; // return this; // } // // @Override // public String toString() { // return "U_XY x: " + x + " y:" + y; // } // } // // Path: library/src/main/java/com/linheimx/app/library/utils/SingleF_XY.java // public class SingleF_XY { // private float x; // private float y; // // private static SingleF_XY value; // // private SingleF_XY() { // // } // // public synchronized static SingleF_XY getInstance() { // if (value == null) { // value = new SingleF_XY(); // } // return value; // } // // public float getX() { // return x; // } // // public SingleF_XY setX(float x) { // this.x = x; // return this; // } // // public float getY() { // return y; // } // // public SingleF_XY setY(float y) { // this.y = y; // return this; // } // // @Override // public String toString() { // return "U_XY x: " + x + " y:" + y; // } // }
import android.graphics.RectF; import com.linheimx.app.library.data.Entry; import com.linheimx.app.library.utils.RectD; import com.linheimx.app.library.utils.SingleD_XY; import com.linheimx.app.library.utils.SingleF_XY;
package com.linheimx.app.library.manager; /** * 数据源与绘出来的图之间的映射关系 * ------------------- * 人与照片直接的映射关系 * <p> * Created by lijian on 2016/11/13. */ public class MappingManager { /** * 区域视图 */ RectF _contentRect; /** * 数据视图 */
// Path: library/src/main/java/com/linheimx/app/library/data/Entry.java // public class Entry { // // double x; // double y; // // boolean isNull_Y = false; // // public Entry(double x, double y) { // this.x = x; // this.y = y; // } // // // public double getX() { // return x; // } // // public Entry setX(double x) { // this.x = x; // return this; // } // // public double getY() { // return y; // } // // public Entry setY(double y) { // this.y = y; // return this; // } // // public boolean isNull_Y() { // return isNull_Y; // } // // public Entry setNull_Y() { // isNull_Y = true; // return this; // } // // @Override // public String toString() { // return "entry x:" + x + " y:" + y; // } // } // // Path: library/src/main/java/com/linheimx/app/library/utils/RectD.java // public class RectD { // // public double left; // public double top; // public double right; // public double bottom; // // public RectD() { // } // // public RectD(double left, double top, double right, double bottom) { // this.left = left; // this.top = top; // this.right = right; // this.bottom = bottom; // } // // public RectD(RectD rectD) { // setRectD(rectD); // } // // public void setRectD(RectD rectD) { // left = rectD.left; // top = rectD.top; // right = rectD.right; // bottom = rectD.bottom; // } // // public double width() { // return right - left; // } // // public double height() { // return top - bottom; // } // // // public String toString() { // return "RectD(" + left + ", " + top + ", " // + right + ", " + bottom + ")"; // } // } // // Path: library/src/main/java/com/linheimx/app/library/utils/SingleD_XY.java // public class SingleD_XY { // private double x; // private double y; // // private static SingleD_XY value; // // private SingleD_XY() { // // } // // public synchronized static SingleD_XY getInstance() { // if (value == null) { // value = new SingleD_XY(); // } // return value; // } // // public double getX() { // return x; // } // // public SingleD_XY setX(double x) { // this.x = x; // return this; // } // // public double getY() { // return y; // } // // public SingleD_XY setY(double y) { // this.y = y; // return this; // } // // @Override // public String toString() { // return "U_XY x: " + x + " y:" + y; // } // } // // Path: library/src/main/java/com/linheimx/app/library/utils/SingleF_XY.java // public class SingleF_XY { // private float x; // private float y; // // private static SingleF_XY value; // // private SingleF_XY() { // // } // // public synchronized static SingleF_XY getInstance() { // if (value == null) { // value = new SingleF_XY(); // } // return value; // } // // public float getX() { // return x; // } // // public SingleF_XY setX(float x) { // this.x = x; // return this; // } // // public float getY() { // return y; // } // // public SingleF_XY setY(float y) { // this.y = y; // return this; // } // // @Override // public String toString() { // return "U_XY x: " + x + " y:" + y; // } // } // Path: library/src/main/java/com/linheimx/app/library/manager/MappingManager.java import android.graphics.RectF; import com.linheimx.app.library.data.Entry; import com.linheimx.app.library.utils.RectD; import com.linheimx.app.library.utils.SingleD_XY; import com.linheimx.app.library.utils.SingleF_XY; package com.linheimx.app.library.manager; /** * 数据源与绘出来的图之间的映射关系 * ------------------- * 人与照片直接的映射关系 * <p> * Created by lijian on 2016/11/13. */ public class MappingManager { /** * 区域视图 */ RectF _contentRect; /** * 数据视图 */
RectD _maxViewPort;
linheimx/LChart
library/src/main/java/com/linheimx/app/library/manager/MappingManager.java
// Path: library/src/main/java/com/linheimx/app/library/data/Entry.java // public class Entry { // // double x; // double y; // // boolean isNull_Y = false; // // public Entry(double x, double y) { // this.x = x; // this.y = y; // } // // // public double getX() { // return x; // } // // public Entry setX(double x) { // this.x = x; // return this; // } // // public double getY() { // return y; // } // // public Entry setY(double y) { // this.y = y; // return this; // } // // public boolean isNull_Y() { // return isNull_Y; // } // // public Entry setNull_Y() { // isNull_Y = true; // return this; // } // // @Override // public String toString() { // return "entry x:" + x + " y:" + y; // } // } // // Path: library/src/main/java/com/linheimx/app/library/utils/RectD.java // public class RectD { // // public double left; // public double top; // public double right; // public double bottom; // // public RectD() { // } // // public RectD(double left, double top, double right, double bottom) { // this.left = left; // this.top = top; // this.right = right; // this.bottom = bottom; // } // // public RectD(RectD rectD) { // setRectD(rectD); // } // // public void setRectD(RectD rectD) { // left = rectD.left; // top = rectD.top; // right = rectD.right; // bottom = rectD.bottom; // } // // public double width() { // return right - left; // } // // public double height() { // return top - bottom; // } // // // public String toString() { // return "RectD(" + left + ", " + top + ", " // + right + ", " + bottom + ")"; // } // } // // Path: library/src/main/java/com/linheimx/app/library/utils/SingleD_XY.java // public class SingleD_XY { // private double x; // private double y; // // private static SingleD_XY value; // // private SingleD_XY() { // // } // // public synchronized static SingleD_XY getInstance() { // if (value == null) { // value = new SingleD_XY(); // } // return value; // } // // public double getX() { // return x; // } // // public SingleD_XY setX(double x) { // this.x = x; // return this; // } // // public double getY() { // return y; // } // // public SingleD_XY setY(double y) { // this.y = y; // return this; // } // // @Override // public String toString() { // return "U_XY x: " + x + " y:" + y; // } // } // // Path: library/src/main/java/com/linheimx/app/library/utils/SingleF_XY.java // public class SingleF_XY { // private float x; // private float y; // // private static SingleF_XY value; // // private SingleF_XY() { // // } // // public synchronized static SingleF_XY getInstance() { // if (value == null) { // value = new SingleF_XY(); // } // return value; // } // // public float getX() { // return x; // } // // public SingleF_XY setX(float x) { // this.x = x; // return this; // } // // public float getY() { // return y; // } // // public SingleF_XY setY(float y) { // this.y = y; // return this; // } // // @Override // public String toString() { // return "U_XY x: " + x + " y:" + y; // } // }
import android.graphics.RectF; import com.linheimx.app.library.data.Entry; import com.linheimx.app.library.utils.RectD; import com.linheimx.app.library.utils.SingleD_XY; import com.linheimx.app.library.utils.SingleF_XY;
package com.linheimx.app.library.manager; /** * 数据源与绘出来的图之间的映射关系 * ------------------- * 人与照片直接的映射关系 * <p> * Created by lijian on 2016/11/13. */ public class MappingManager { /** * 区域视图 */ RectF _contentRect; /** * 数据视图 */ RectD _maxViewPort; RectD _currentViewPort; /** * 数据视图的约束 */ float fatFactor = 1.3f;//肥胖因子 RectD _constrainViewPort; boolean current2Fat; // 当前视图是否跟约束视图一样大 public MappingManager(RectF rectMain) { _contentRect = rectMain; _maxViewPort = new RectD(); _currentViewPort = new RectD(); _constrainViewPort = new RectD(); } public void prepareRelation(double xMin, double xMax, double yMin, double yMax) { _maxViewPort.left = xMin; _maxViewPort.right = xMax; _maxViewPort.bottom = yMin; _maxViewPort.top = yMax; _currentViewPort.setRectD(_maxViewPort); setFatFactor(fatFactor); } /** * 根据像素位置变换成数值 * * @param x * @param y * @return */
// Path: library/src/main/java/com/linheimx/app/library/data/Entry.java // public class Entry { // // double x; // double y; // // boolean isNull_Y = false; // // public Entry(double x, double y) { // this.x = x; // this.y = y; // } // // // public double getX() { // return x; // } // // public Entry setX(double x) { // this.x = x; // return this; // } // // public double getY() { // return y; // } // // public Entry setY(double y) { // this.y = y; // return this; // } // // public boolean isNull_Y() { // return isNull_Y; // } // // public Entry setNull_Y() { // isNull_Y = true; // return this; // } // // @Override // public String toString() { // return "entry x:" + x + " y:" + y; // } // } // // Path: library/src/main/java/com/linheimx/app/library/utils/RectD.java // public class RectD { // // public double left; // public double top; // public double right; // public double bottom; // // public RectD() { // } // // public RectD(double left, double top, double right, double bottom) { // this.left = left; // this.top = top; // this.right = right; // this.bottom = bottom; // } // // public RectD(RectD rectD) { // setRectD(rectD); // } // // public void setRectD(RectD rectD) { // left = rectD.left; // top = rectD.top; // right = rectD.right; // bottom = rectD.bottom; // } // // public double width() { // return right - left; // } // // public double height() { // return top - bottom; // } // // // public String toString() { // return "RectD(" + left + ", " + top + ", " // + right + ", " + bottom + ")"; // } // } // // Path: library/src/main/java/com/linheimx/app/library/utils/SingleD_XY.java // public class SingleD_XY { // private double x; // private double y; // // private static SingleD_XY value; // // private SingleD_XY() { // // } // // public synchronized static SingleD_XY getInstance() { // if (value == null) { // value = new SingleD_XY(); // } // return value; // } // // public double getX() { // return x; // } // // public SingleD_XY setX(double x) { // this.x = x; // return this; // } // // public double getY() { // return y; // } // // public SingleD_XY setY(double y) { // this.y = y; // return this; // } // // @Override // public String toString() { // return "U_XY x: " + x + " y:" + y; // } // } // // Path: library/src/main/java/com/linheimx/app/library/utils/SingleF_XY.java // public class SingleF_XY { // private float x; // private float y; // // private static SingleF_XY value; // // private SingleF_XY() { // // } // // public synchronized static SingleF_XY getInstance() { // if (value == null) { // value = new SingleF_XY(); // } // return value; // } // // public float getX() { // return x; // } // // public SingleF_XY setX(float x) { // this.x = x; // return this; // } // // public float getY() { // return y; // } // // public SingleF_XY setY(float y) { // this.y = y; // return this; // } // // @Override // public String toString() { // return "U_XY x: " + x + " y:" + y; // } // } // Path: library/src/main/java/com/linheimx/app/library/manager/MappingManager.java import android.graphics.RectF; import com.linheimx.app.library.data.Entry; import com.linheimx.app.library.utils.RectD; import com.linheimx.app.library.utils.SingleD_XY; import com.linheimx.app.library.utils.SingleF_XY; package com.linheimx.app.library.manager; /** * 数据源与绘出来的图之间的映射关系 * ------------------- * 人与照片直接的映射关系 * <p> * Created by lijian on 2016/11/13. */ public class MappingManager { /** * 区域视图 */ RectF _contentRect; /** * 数据视图 */ RectD _maxViewPort; RectD _currentViewPort; /** * 数据视图的约束 */ float fatFactor = 1.3f;//肥胖因子 RectD _constrainViewPort; boolean current2Fat; // 当前视图是否跟约束视图一样大 public MappingManager(RectF rectMain) { _contentRect = rectMain; _maxViewPort = new RectD(); _currentViewPort = new RectD(); _constrainViewPort = new RectD(); } public void prepareRelation(double xMin, double xMax, double yMin, double yMax) { _maxViewPort.left = xMin; _maxViewPort.right = xMax; _maxViewPort.bottom = yMin; _maxViewPort.top = yMax; _currentViewPort.setRectD(_maxViewPort); setFatFactor(fatFactor); } /** * 根据像素位置变换成数值 * * @param x * @param y * @return */
public SingleD_XY getValueByPx(float x, float y) {
linheimx/LChart
library/src/main/java/com/linheimx/app/library/data/Line.java
// Path: library/src/main/java/com/linheimx/app/library/utils/Utils.java // public class Utils { // // public static float dp2px(float dp) { // return (int) (dp * Resources.getSystem().getDisplayMetrics().density); // } // // public static float textWidth(Paint paint, String txt) { // return paint.measureText(txt); // } // // private static Paint.FontMetrics mFontMetrics = new Paint.FontMetrics(); // // public static int textHeightAsc(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent)); // } // // public static int textHeight(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent) + Math.abs(mFontMetrics.descent)); // } // // /** // * 将杂乱的数字变成里程碑。 // * // * @param number // * @return // */ // public static float roundNumber2One(double number) { // if (Double.isInfinite(number) || // Double.isNaN(number) || // number == 0.0) // return 0; // // final float d = (float) Math.ceil((float) Math.log10(number < 0 ? -number : number));//有几位? // final int pw = 1 - (int) d; // final float magnitude = (float) Math.pow(10, pw); // final long shifted = Math.round(number * magnitude); // return shifted / magnitude; // } // // // }
import android.graphics.Color; import com.linheimx.app.library.utils.Utils; import java.util.ArrayList; import java.util.List;
package com.linheimx.app.library.data; /** * Created by Administrator on 2016/11/13. */ public class Line { private List<Entry> entries = new ArrayList<>(); private double mYMax = Double.MIN_VALUE; private double mYMin = Double.MAX_VALUE; private double mXMax = Double.MIN_VALUE; private double mXMin = Double.MAX_VALUE; private int lineColor = Color.BLACK; private int lineWidth = 1; private int circleColor = Color.RED; private int circleR = 4; private boolean isFilled = false; private int lineAlpha = 50; private boolean isEnable = true; private boolean isDrawCircle = true; private boolean isDrawLegend = false; private int legendWidth = 50; private int legendHeight = 17; private int legendTextSize = 8; private String name = "line"; private CallBack_OnEntryClick onEntryClick; public Line() { this(null); } public Line(List<Entry> entries) {
// Path: library/src/main/java/com/linheimx/app/library/utils/Utils.java // public class Utils { // // public static float dp2px(float dp) { // return (int) (dp * Resources.getSystem().getDisplayMetrics().density); // } // // public static float textWidth(Paint paint, String txt) { // return paint.measureText(txt); // } // // private static Paint.FontMetrics mFontMetrics = new Paint.FontMetrics(); // // public static int textHeightAsc(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent)); // } // // public static int textHeight(Paint paint) { // paint.getFontMetrics(mFontMetrics); // return (int) (Math.abs(mFontMetrics.ascent) + Math.abs(mFontMetrics.descent)); // } // // /** // * 将杂乱的数字变成里程碑。 // * // * @param number // * @return // */ // public static float roundNumber2One(double number) { // if (Double.isInfinite(number) || // Double.isNaN(number) || // number == 0.0) // return 0; // // final float d = (float) Math.ceil((float) Math.log10(number < 0 ? -number : number));//有几位? // final int pw = 1 - (int) d; // final float magnitude = (float) Math.pow(10, pw); // final long shifted = Math.round(number * magnitude); // return shifted / magnitude; // } // // // } // Path: library/src/main/java/com/linheimx/app/library/data/Line.java import android.graphics.Color; import com.linheimx.app.library.utils.Utils; import java.util.ArrayList; import java.util.List; package com.linheimx.app.library.data; /** * Created by Administrator on 2016/11/13. */ public class Line { private List<Entry> entries = new ArrayList<>(); private double mYMax = Double.MIN_VALUE; private double mYMin = Double.MAX_VALUE; private double mXMax = Double.MIN_VALUE; private double mXMin = Double.MAX_VALUE; private int lineColor = Color.BLACK; private int lineWidth = 1; private int circleColor = Color.RED; private int circleR = 4; private boolean isFilled = false; private int lineAlpha = 50; private boolean isEnable = true; private boolean isDrawCircle = true; private boolean isDrawLegend = false; private int legendWidth = 50; private int legendHeight = 17; private int legendTextSize = 8; private String name = "line"; private CallBack_OnEntryClick onEntryClick; public Line() { this(null); } public Line(List<Entry> entries) {
circleR = (int) Utils.dp2px(circleR);
tmills/PaperManager
src/filters/TitleNameFilter.java
// Path: src/papers/Paper.java // public class Paper { // BibEntry bib=null; // HashSet<Tag> tags=null; // String summary=null; // File fp=null; // // public Paper(){ // bib = new BibEntry(); // tags = new LinkedHashSet<Tag>(); // } // // public Set<String> getFields(){ // return bib.getFields().keySet(); // } // // public String getType(){ // return bib.getType(); // } // public void setType(String t){ // bib.setType(t); // } // // public String getLabel(){ // return bib.getLabel(); // } // // public void setLabel(String l){ // bib.setLabel(l); // } // // public BibEntry getEntry(){ // return bib; // } // // public void addTag(String t){ // tags.add(new Tag(t)); // } // // public Set<Tag> getTags(){ // return tags; // } // // public void setSummary(String s){ // summary = s; // } // // public String getSummary(){ // return summary; // } // // public void setField(String key, String val){ // bib.setField(key, val); // } // // public String getField(String key){ // String ret = bib.getField(key); // if(ret == null) return ""; // return bib.getField(key); // } // // public String getVenue(){ // if(bib.getType().equalsIgnoreCase("article")){ // return bib.getField("journal"); // }else if(bib.getType().equalsIgnoreCase("book")){ // return bib.getField("publisher"); // }else if(bib.getType().equalsIgnoreCase("inproceedings")){ // return bib.getField("booktitle"); // }else if(bib.getType().equalsIgnoreCase("phdthesis")){ // return bib.getField("school"); // }else if(bib.getType().equalsIgnoreCase("techreport")){ // return bib.getField("institution"); // }else{ // return ""; // } // } // // public void setVenue(String v){ // if(bib.getType().equalsIgnoreCase("article")){ // bib.setField("journal",v); // }else if(bib.getType().equalsIgnoreCase("book")){ // bib.setField("publisher",v); // }else if(bib.getType().equalsIgnoreCase("inproceedings")){ // bib.setField("booktitle",v); // }else if(bib.getType().equalsIgnoreCase("phdthesis")){ // bib.setField("school",v); // }else if(bib.getType().equalsIgnoreCase("techreport")){ // bib.setField("institution",v); // } // } // // public File getFile(){ // return fp; // } // // public void setFile(File f){ // fp = f; // } // // public String toXML(){ // StringBuilder out = new StringBuilder(); // HashMap<String,String> fields = bib.getFields(); // out.append("<paper>\n"); // out.append("\t<bibentry>\n"); // out.append("\t\t<type>" + escape(bib.getType()) + "</type>\n"); // out.append("\t\t<label>" + escape(bib.getLabel()) + "</label>\n"); // for(String key : fields.keySet()){ // out.append("\t\t<" + key + ">" + escape(fields.get(key)) + "</" + key + ">\n"); // } // out.append("\t</bibentry>\n"); // if(summary != null){ // out.append("\t<summary>" + escape(summary) + "</summary>\n"); // } // if(tags.size() > 0){ // out.append("\t<taglist>\n"); // for(Tag tag : tags){ // out.append("\t\t<tag>" + escape(tag.getTag()) + "</tag>\n"); // } // out.append("\t</taglist>\n"); // } // if(fp != null){ // out.append("\t<filename>" + escape(fp.getName()) + "</filename>\n"); // } // out.append("</paper>"); // return out.toString(); // } // // private String escape(String s){ // return s.replaceAll("&", "&amp;"); // } // }
import java.util.ArrayList; import java.util.List; import papers.Paper;
package filters; public class TitleNameFilter extends PaperStringFilter { private ArrayList<String> titleStrings = null;
// Path: src/papers/Paper.java // public class Paper { // BibEntry bib=null; // HashSet<Tag> tags=null; // String summary=null; // File fp=null; // // public Paper(){ // bib = new BibEntry(); // tags = new LinkedHashSet<Tag>(); // } // // public Set<String> getFields(){ // return bib.getFields().keySet(); // } // // public String getType(){ // return bib.getType(); // } // public void setType(String t){ // bib.setType(t); // } // // public String getLabel(){ // return bib.getLabel(); // } // // public void setLabel(String l){ // bib.setLabel(l); // } // // public BibEntry getEntry(){ // return bib; // } // // public void addTag(String t){ // tags.add(new Tag(t)); // } // // public Set<Tag> getTags(){ // return tags; // } // // public void setSummary(String s){ // summary = s; // } // // public String getSummary(){ // return summary; // } // // public void setField(String key, String val){ // bib.setField(key, val); // } // // public String getField(String key){ // String ret = bib.getField(key); // if(ret == null) return ""; // return bib.getField(key); // } // // public String getVenue(){ // if(bib.getType().equalsIgnoreCase("article")){ // return bib.getField("journal"); // }else if(bib.getType().equalsIgnoreCase("book")){ // return bib.getField("publisher"); // }else if(bib.getType().equalsIgnoreCase("inproceedings")){ // return bib.getField("booktitle"); // }else if(bib.getType().equalsIgnoreCase("phdthesis")){ // return bib.getField("school"); // }else if(bib.getType().equalsIgnoreCase("techreport")){ // return bib.getField("institution"); // }else{ // return ""; // } // } // // public void setVenue(String v){ // if(bib.getType().equalsIgnoreCase("article")){ // bib.setField("journal",v); // }else if(bib.getType().equalsIgnoreCase("book")){ // bib.setField("publisher",v); // }else if(bib.getType().equalsIgnoreCase("inproceedings")){ // bib.setField("booktitle",v); // }else if(bib.getType().equalsIgnoreCase("phdthesis")){ // bib.setField("school",v); // }else if(bib.getType().equalsIgnoreCase("techreport")){ // bib.setField("institution",v); // } // } // // public File getFile(){ // return fp; // } // // public void setFile(File f){ // fp = f; // } // // public String toXML(){ // StringBuilder out = new StringBuilder(); // HashMap<String,String> fields = bib.getFields(); // out.append("<paper>\n"); // out.append("\t<bibentry>\n"); // out.append("\t\t<type>" + escape(bib.getType()) + "</type>\n"); // out.append("\t\t<label>" + escape(bib.getLabel()) + "</label>\n"); // for(String key : fields.keySet()){ // out.append("\t\t<" + key + ">" + escape(fields.get(key)) + "</" + key + ">\n"); // } // out.append("\t</bibentry>\n"); // if(summary != null){ // out.append("\t<summary>" + escape(summary) + "</summary>\n"); // } // if(tags.size() > 0){ // out.append("\t<taglist>\n"); // for(Tag tag : tags){ // out.append("\t\t<tag>" + escape(tag.getTag()) + "</tag>\n"); // } // out.append("\t</taglist>\n"); // } // if(fp != null){ // out.append("\t<filename>" + escape(fp.getName()) + "</filename>\n"); // } // out.append("</paper>"); // return out.toString(); // } // // private String escape(String s){ // return s.replaceAll("&", "&amp;"); // } // } // Path: src/filters/TitleNameFilter.java import java.util.ArrayList; import java.util.List; import papers.Paper; package filters; public class TitleNameFilter extends PaperStringFilter { private ArrayList<String> titleStrings = null;
public TitleNameFilter(List<Paper> paperList) {
tmills/PaperManager
src/papers/Paper.java
// Path: src/tags/Tag.java // public class Tag { // private String tag; // // /** // * @return the tag // */ // public String getTag() { // return tag; // } // // /** // * @param tag the tag to set // */ // public void setTag(String tag) { // this.tag = tag; // } // // public Tag(String t){ // tag = t; // } // // public String toString(){ // return tag; // } // } // // Path: src/bib/BibEntry.java // public class BibEntry { // String label=""; // String type=""; // // HashMap<String,String> fields = new LinkedHashMap<String,String>(); // // public String getLabel() { // return label; // } // /** // * @param label the label to set // */ // public void setLabel(String label) { // this.label = label; // } // /** // * @return the type // */ // public String getType() { // return type; // } // /** // * @param type the type to set // */ // public void setType(String type) { // this.type = type; // } // // public void setField(String key, String value){ // fields.put(key, value); // } // // public String getField(String key){ // return fields.get(key); // } // // public HashMap<String,String> getFields(){ // return fields; // } // }
import java.io.File; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Set; import tags.Tag; import bib.BibEntry;
/* * Copyright 2010 Tim Miller * This file is part of PaperManager * PaperManager is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package papers; public class Paper { BibEntry bib=null;
// Path: src/tags/Tag.java // public class Tag { // private String tag; // // /** // * @return the tag // */ // public String getTag() { // return tag; // } // // /** // * @param tag the tag to set // */ // public void setTag(String tag) { // this.tag = tag; // } // // public Tag(String t){ // tag = t; // } // // public String toString(){ // return tag; // } // } // // Path: src/bib/BibEntry.java // public class BibEntry { // String label=""; // String type=""; // // HashMap<String,String> fields = new LinkedHashMap<String,String>(); // // public String getLabel() { // return label; // } // /** // * @param label the label to set // */ // public void setLabel(String label) { // this.label = label; // } // /** // * @return the type // */ // public String getType() { // return type; // } // /** // * @param type the type to set // */ // public void setType(String type) { // this.type = type; // } // // public void setField(String key, String value){ // fields.put(key, value); // } // // public String getField(String key){ // return fields.get(key); // } // // public HashMap<String,String> getFields(){ // return fields; // } // } // Path: src/papers/Paper.java import java.io.File; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Set; import tags.Tag; import bib.BibEntry; /* * Copyright 2010 Tim Miller * This file is part of PaperManager * PaperManager is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package papers; public class Paper { BibEntry bib=null;
HashSet<Tag> tags=null;
tmills/PaperManager
src/bibtex/dom/BibtexFile.java
// Path: src/bibtex/Assertions.java // public class Assertions { // // public static final boolean ENABLE_EXPENSIVE_ASSERTIONS = true; // // }
import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import bibtex.Assertions;
/* * Created on Mar 17, 2003 * * @author [email protected] * */ package bibtex.dom; /** * This is the root of a bibtex DOM tree and the factory for any bibtex model - * the only way to create nodes. For an example, check out the documentation for * the constructor of BibtexNode. * * @author henkel */ public final class BibtexFile extends BibtexNode { private final ArrayList entries = new ArrayList(); public BibtexFile() { super(null); } public void addEntry(BibtexAbstractEntry entry) { assert entry != null : "entry parameter may not be null.";
// Path: src/bibtex/Assertions.java // public class Assertions { // // public static final boolean ENABLE_EXPENSIVE_ASSERTIONS = true; // // } // Path: src/bibtex/dom/BibtexFile.java import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import bibtex.Assertions; /* * Created on Mar 17, 2003 * * @author [email protected] * */ package bibtex.dom; /** * This is the root of a bibtex DOM tree and the factory for any bibtex model - * the only way to create nodes. For an example, check out the documentation for * the constructor of BibtexNode. * * @author henkel */ public final class BibtexFile extends BibtexNode { private final ArrayList entries = new ArrayList(); public BibtexFile() { super(null); } public void addEntry(BibtexAbstractEntry entry) { assert entry != null : "entry parameter may not be null.";
assert !Assertions.ENABLE_EXPENSIVE_ASSERTIONS || !this.entries.contains(entry) :
tmills/PaperManager
src/bibtex/dom/BibtexMultipleValues.java
// Path: src/bibtex/Assertions.java // public class Assertions { // // public static final boolean ENABLE_EXPENSIVE_ASSERTIONS = true; // // }
import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import bibtex.Assertions;
/* * Created on Jul 14, 2004 * * @author [email protected] * */ package bibtex.dom; /** * Some bibtex files have multiple values per field - this is a container that * contains these values. For example, the following BibtexEntry has multiple * values for the url field: * * <pre> * &#064;inproceedings{diwan98typebased, * year=1998, * pages={106-117}, * title={Type-Based Alias Analysis}, * url={citeseer.nj.nec.com/diwan98typebased.html}, * booktitle={SIGPLAN Conference on Programming Language Design and Implementation}, * author={Amer Diwan and Kathryn S. McKinley and J. Eliot B. Moss}, * url={http://www-plan.cs.colorado.edu/diwan/}, * } * </pre> * * Note that the bibtex parser in this package will discard duplicate values * unless you set the appropriate policy * with BibtexParser.setMultipleFieldValuesPolicy(int). * * @see bibtex.parser.BibtexParser#setMultipleFieldValuesPolicy(int) * @see bibtex.parser.BibtexMultipleFieldValuesPolicy#KEEP_ALL * * @author henkel */ public final class BibtexMultipleValues extends BibtexAbstractValue { private final ArrayList values = new ArrayList(3); /** * @param bibtexFile */ BibtexMultipleValues(BibtexFile bibtexFile) { super(bibtexFile); } /** * This will add the value object to this BibtexMultipleValues object. Do * not try to add the same object multiple times. * * @param value * is the value you want to add to this instance. Note that this * may be anything but another BibtexAbstractValue instance - we * don't want to have nested BibtexMultipleValue instances. */ public void addValue(BibtexAbstractValue value) { assert value != null : "value parameter may not be null."; assert !(value instanceof BibtexMultipleValues) : "You cannot add a BibtexMultipleValues instance to a BibtexMultipleValues instance.";
// Path: src/bibtex/Assertions.java // public class Assertions { // // public static final boolean ENABLE_EXPENSIVE_ASSERTIONS = true; // // } // Path: src/bibtex/dom/BibtexMultipleValues.java import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import bibtex.Assertions; /* * Created on Jul 14, 2004 * * @author [email protected] * */ package bibtex.dom; /** * Some bibtex files have multiple values per field - this is a container that * contains these values. For example, the following BibtexEntry has multiple * values for the url field: * * <pre> * &#064;inproceedings{diwan98typebased, * year=1998, * pages={106-117}, * title={Type-Based Alias Analysis}, * url={citeseer.nj.nec.com/diwan98typebased.html}, * booktitle={SIGPLAN Conference on Programming Language Design and Implementation}, * author={Amer Diwan and Kathryn S. McKinley and J. Eliot B. Moss}, * url={http://www-plan.cs.colorado.edu/diwan/}, * } * </pre> * * Note that the bibtex parser in this package will discard duplicate values * unless you set the appropriate policy * with BibtexParser.setMultipleFieldValuesPolicy(int). * * @see bibtex.parser.BibtexParser#setMultipleFieldValuesPolicy(int) * @see bibtex.parser.BibtexMultipleFieldValuesPolicy#KEEP_ALL * * @author henkel */ public final class BibtexMultipleValues extends BibtexAbstractValue { private final ArrayList values = new ArrayList(3); /** * @param bibtexFile */ BibtexMultipleValues(BibtexFile bibtexFile) { super(bibtexFile); } /** * This will add the value object to this BibtexMultipleValues object. Do * not try to add the same object multiple times. * * @param value * is the value you want to add to this instance. Note that this * may be anything but another BibtexAbstractValue instance - we * don't want to have nested BibtexMultipleValue instances. */ public void addValue(BibtexAbstractValue value) { assert value != null : "value parameter may not be null."; assert !(value instanceof BibtexMultipleValues) : "You cannot add a BibtexMultipleValues instance to a BibtexMultipleValues instance.";
assert !Assertions.ENABLE_EXPENSIVE_ASSERTIONS || !values.contains(value) : "value is already contained in this BibtexMultipleValues object.";
tmills/PaperManager
src/bibtex/expansions/BibtexPersonListParser.java
// Path: src/bibtex/dom/BibtexString.java // public class BibtexString extends BibtexAbstractValue { // // // content does not include the quotes or curly braces around the string! // private String content; // // /** // * content includes the quotes or curly braces around the string! // * // * @param content // */ // BibtexString(BibtexFile file, String content) { // super(file); // this.content = content; // } // // /** // * content includes the quotes or curly braces around the string! // * // * @return String // */ // public String getContent() { // return content; // } // // /** // * Sets the content. // * @param content The content to set // */ // public void setContent(String content) { // // assert content!=null: "content parameter may not be null."; // // this.content = content; // } // // /* (non-Javadoc) // * @see bibtex.dom.BibtexNode#printBibtex(java.io.PrintWriter) // */ // public void printBibtex(PrintWriter writer) { // // assert writer!=null: "writer parameter may not be null."; // // // is this really a number? // try { // Integer.parseInt(content); // writer.print(content); // } catch (NumberFormatException nfe) { // writer.print('{'); // // for (int begin = 0; begin < content.length();) { // // int end = content.indexOf('\n', begin); // // if (end < 0) { // // if (begin > 0) // // writer.print(content.substring(begin, content.length())); // // else // // writer.print(content); // // // // break; // // } // // writer.println(content.substring(begin, end)); // // writer.print("\t\t"); // // begin = end + 1; // // } // writer.print(content); // writer.print('}'); // } // } // // }
import java.util.LinkedList; import java.util.List; import bibtex.dom.*; import bibtex.dom.BibtexString;
/* * Created on Mar 27, 2003 * * @author [email protected] * */ package bibtex.expansions; /** * @author henkel */ final class BibtexPersonListParser { static final class StringIterator { private final char[] chars; private int pos; StringIterator(String string) { chars = string.toCharArray(); pos = 0; } char next() { return chars[pos++]; } char current() { return chars[pos]; } void step() { pos++; } void skipWhiteSpace() { while (pos < chars.length && Character.isWhitespace(chars[pos])) pos++; } boolean hasNext() { return pos + 1 < chars.length; } }
// Path: src/bibtex/dom/BibtexString.java // public class BibtexString extends BibtexAbstractValue { // // // content does not include the quotes or curly braces around the string! // private String content; // // /** // * content includes the quotes or curly braces around the string! // * // * @param content // */ // BibtexString(BibtexFile file, String content) { // super(file); // this.content = content; // } // // /** // * content includes the quotes or curly braces around the string! // * // * @return String // */ // public String getContent() { // return content; // } // // /** // * Sets the content. // * @param content The content to set // */ // public void setContent(String content) { // // assert content!=null: "content parameter may not be null."; // // this.content = content; // } // // /* (non-Javadoc) // * @see bibtex.dom.BibtexNode#printBibtex(java.io.PrintWriter) // */ // public void printBibtex(PrintWriter writer) { // // assert writer!=null: "writer parameter may not be null."; // // // is this really a number? // try { // Integer.parseInt(content); // writer.print(content); // } catch (NumberFormatException nfe) { // writer.print('{'); // // for (int begin = 0; begin < content.length();) { // // int end = content.indexOf('\n', begin); // // if (end < 0) { // // if (begin > 0) // // writer.print(content.substring(begin, content.length())); // // else // // writer.print(content); // // // // break; // // } // // writer.println(content.substring(begin, end)); // // writer.print("\t\t"); // // begin = end + 1; // // } // writer.print(content); // writer.print('}'); // } // } // // } // Path: src/bibtex/expansions/BibtexPersonListParser.java import java.util.LinkedList; import java.util.List; import bibtex.dom.*; import bibtex.dom.BibtexString; /* * Created on Mar 27, 2003 * * @author [email protected] * */ package bibtex.expansions; /** * @author henkel */ final class BibtexPersonListParser { static final class StringIterator { private final char[] chars; private int pos; StringIterator(String string) { chars = string.toCharArray(); pos = 0; } char next() { return chars[pos++]; } char current() { return chars[pos]; } void step() { pos++; } void skipWhiteSpace() { while (pos < chars.length && Character.isWhitespace(chars[pos])) pos++; } boolean hasNext() { return pos + 1 < chars.length; } }
public static BibtexPersonList parse(BibtexString personList,String entryKey) throws PersonListParserException {
tmills/PaperManager
src/filters/AuthorNameFilter.java
// Path: src/papers/Paper.java // public class Paper { // BibEntry bib=null; // HashSet<Tag> tags=null; // String summary=null; // File fp=null; // // public Paper(){ // bib = new BibEntry(); // tags = new LinkedHashSet<Tag>(); // } // // public Set<String> getFields(){ // return bib.getFields().keySet(); // } // // public String getType(){ // return bib.getType(); // } // public void setType(String t){ // bib.setType(t); // } // // public String getLabel(){ // return bib.getLabel(); // } // // public void setLabel(String l){ // bib.setLabel(l); // } // // public BibEntry getEntry(){ // return bib; // } // // public void addTag(String t){ // tags.add(new Tag(t)); // } // // public Set<Tag> getTags(){ // return tags; // } // // public void setSummary(String s){ // summary = s; // } // // public String getSummary(){ // return summary; // } // // public void setField(String key, String val){ // bib.setField(key, val); // } // // public String getField(String key){ // String ret = bib.getField(key); // if(ret == null) return ""; // return bib.getField(key); // } // // public String getVenue(){ // if(bib.getType().equalsIgnoreCase("article")){ // return bib.getField("journal"); // }else if(bib.getType().equalsIgnoreCase("book")){ // return bib.getField("publisher"); // }else if(bib.getType().equalsIgnoreCase("inproceedings")){ // return bib.getField("booktitle"); // }else if(bib.getType().equalsIgnoreCase("phdthesis")){ // return bib.getField("school"); // }else if(bib.getType().equalsIgnoreCase("techreport")){ // return bib.getField("institution"); // }else{ // return ""; // } // } // // public void setVenue(String v){ // if(bib.getType().equalsIgnoreCase("article")){ // bib.setField("journal",v); // }else if(bib.getType().equalsIgnoreCase("book")){ // bib.setField("publisher",v); // }else if(bib.getType().equalsIgnoreCase("inproceedings")){ // bib.setField("booktitle",v); // }else if(bib.getType().equalsIgnoreCase("phdthesis")){ // bib.setField("school",v); // }else if(bib.getType().equalsIgnoreCase("techreport")){ // bib.setField("institution",v); // } // } // // public File getFile(){ // return fp; // } // // public void setFile(File f){ // fp = f; // } // // public String toXML(){ // StringBuilder out = new StringBuilder(); // HashMap<String,String> fields = bib.getFields(); // out.append("<paper>\n"); // out.append("\t<bibentry>\n"); // out.append("\t\t<type>" + escape(bib.getType()) + "</type>\n"); // out.append("\t\t<label>" + escape(bib.getLabel()) + "</label>\n"); // for(String key : fields.keySet()){ // out.append("\t\t<" + key + ">" + escape(fields.get(key)) + "</" + key + ">\n"); // } // out.append("\t</bibentry>\n"); // if(summary != null){ // out.append("\t<summary>" + escape(summary) + "</summary>\n"); // } // if(tags.size() > 0){ // out.append("\t<taglist>\n"); // for(Tag tag : tags){ // out.append("\t\t<tag>" + escape(tag.getTag()) + "</tag>\n"); // } // out.append("\t</taglist>\n"); // } // if(fp != null){ // out.append("\t<filename>" + escape(fp.getName()) + "</filename>\n"); // } // out.append("</paper>"); // return out.toString(); // } // // private String escape(String s){ // return s.replaceAll("&", "&amp;"); // } // }
import java.util.ArrayList; import java.util.List; import papers.Paper;
package filters; public class AuthorNameFilter extends PaperStringFilter { private ArrayList<String> authorStrings = null;
// Path: src/papers/Paper.java // public class Paper { // BibEntry bib=null; // HashSet<Tag> tags=null; // String summary=null; // File fp=null; // // public Paper(){ // bib = new BibEntry(); // tags = new LinkedHashSet<Tag>(); // } // // public Set<String> getFields(){ // return bib.getFields().keySet(); // } // // public String getType(){ // return bib.getType(); // } // public void setType(String t){ // bib.setType(t); // } // // public String getLabel(){ // return bib.getLabel(); // } // // public void setLabel(String l){ // bib.setLabel(l); // } // // public BibEntry getEntry(){ // return bib; // } // // public void addTag(String t){ // tags.add(new Tag(t)); // } // // public Set<Tag> getTags(){ // return tags; // } // // public void setSummary(String s){ // summary = s; // } // // public String getSummary(){ // return summary; // } // // public void setField(String key, String val){ // bib.setField(key, val); // } // // public String getField(String key){ // String ret = bib.getField(key); // if(ret == null) return ""; // return bib.getField(key); // } // // public String getVenue(){ // if(bib.getType().equalsIgnoreCase("article")){ // return bib.getField("journal"); // }else if(bib.getType().equalsIgnoreCase("book")){ // return bib.getField("publisher"); // }else if(bib.getType().equalsIgnoreCase("inproceedings")){ // return bib.getField("booktitle"); // }else if(bib.getType().equalsIgnoreCase("phdthesis")){ // return bib.getField("school"); // }else if(bib.getType().equalsIgnoreCase("techreport")){ // return bib.getField("institution"); // }else{ // return ""; // } // } // // public void setVenue(String v){ // if(bib.getType().equalsIgnoreCase("article")){ // bib.setField("journal",v); // }else if(bib.getType().equalsIgnoreCase("book")){ // bib.setField("publisher",v); // }else if(bib.getType().equalsIgnoreCase("inproceedings")){ // bib.setField("booktitle",v); // }else if(bib.getType().equalsIgnoreCase("phdthesis")){ // bib.setField("school",v); // }else if(bib.getType().equalsIgnoreCase("techreport")){ // bib.setField("institution",v); // } // } // // public File getFile(){ // return fp; // } // // public void setFile(File f){ // fp = f; // } // // public String toXML(){ // StringBuilder out = new StringBuilder(); // HashMap<String,String> fields = bib.getFields(); // out.append("<paper>\n"); // out.append("\t<bibentry>\n"); // out.append("\t\t<type>" + escape(bib.getType()) + "</type>\n"); // out.append("\t\t<label>" + escape(bib.getLabel()) + "</label>\n"); // for(String key : fields.keySet()){ // out.append("\t\t<" + key + ">" + escape(fields.get(key)) + "</" + key + ">\n"); // } // out.append("\t</bibentry>\n"); // if(summary != null){ // out.append("\t<summary>" + escape(summary) + "</summary>\n"); // } // if(tags.size() > 0){ // out.append("\t<taglist>\n"); // for(Tag tag : tags){ // out.append("\t\t<tag>" + escape(tag.getTag()) + "</tag>\n"); // } // out.append("\t</taglist>\n"); // } // if(fp != null){ // out.append("\t<filename>" + escape(fp.getName()) + "</filename>\n"); // } // out.append("</paper>"); // return out.toString(); // } // // private String escape(String s){ // return s.replaceAll("&", "&amp;"); // } // } // Path: src/filters/AuthorNameFilter.java import java.util.ArrayList; import java.util.List; import papers.Paper; package filters; public class AuthorNameFilter extends PaperStringFilter { private ArrayList<String> authorStrings = null;
public AuthorNameFilter(List<Paper> paperList) {
Sleaker/jlibnoise
src/main/java/net/jlibnoise/combiner/Power.java
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // }
import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException;
/* Copyright (C) 2011 Garrett Fleenor This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. 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 (COPYING.txt) for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA This is a port of libnoise ( http://libnoise.sourceforge.net/index.html ). Original implementation by Jason Bevins */ package net.jlibnoise.combiner; public class Power extends Module { public Power() { super(2); } @Override public int getSourceModuleCount() { return 2; } @Override public double getValue(double x, double y, double z) { if (sourceModule[0] == null)
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // } // Path: src/main/java/net/jlibnoise/combiner/Power.java import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException; /* Copyright (C) 2011 Garrett Fleenor This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. 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 (COPYING.txt) for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA This is a port of libnoise ( http://libnoise.sourceforge.net/index.html ). Original implementation by Jason Bevins */ package net.jlibnoise.combiner; public class Power extends Module { public Power() { super(2); } @Override public int getSourceModuleCount() { return 2; } @Override public double getValue(double x, double y, double z) { if (sourceModule[0] == null)
throw new NoModuleException();
Sleaker/jlibnoise
src/main/java/net/jlibnoise/model/Line.java
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // }
import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException;
/* Copyright (C) 2011 Garrett Fleenor This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. 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 (COPYING.txt) for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA This is a port of libnoise ( http://libnoise.sourceforge.net/index.html ). Original implementation by Jason Bevins */ package net.jlibnoise.model; /** * Model that defines the displacement of a line segment. * * This model returns an output value from a noise module given the * one-dimensional coordinate of an input value located on a line segment, which * can be used as displacements. * * This class is useful for creating: - roads and rivers - disaffected college * students * * To generate an output value, pass an input value between 0.0 and 1.0 to the * GetValue() method. 0.0 represents the start position of the line segment and * 1.0 represents the end position of the line segment. */ public class Line { // A flag that specifies whether the value is to be attenuated // (moved toward 0.0) as the ends of the line segment are approached. boolean attenuate = false; // A pointer to the noise module used to generate the output values.
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // } // Path: src/main/java/net/jlibnoise/model/Line.java import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException; /* Copyright (C) 2011 Garrett Fleenor This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. 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 (COPYING.txt) for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA This is a port of libnoise ( http://libnoise.sourceforge.net/index.html ). Original implementation by Jason Bevins */ package net.jlibnoise.model; /** * Model that defines the displacement of a line segment. * * This model returns an output value from a noise module given the * one-dimensional coordinate of an input value located on a line segment, which * can be used as displacements. * * This class is useful for creating: - roads and rivers - disaffected college * students * * To generate an output value, pass an input value between 0.0 and 1.0 to the * GetValue() method. 0.0 represents the start position of the line segment and * 1.0 represents the end position of the line segment. */ public class Line { // A flag that specifies whether the value is to be attenuated // (moved toward 0.0) as the ends of the line segment are approached. boolean attenuate = false; // A pointer to the noise module used to generate the output values.
Module module;
Sleaker/jlibnoise
src/main/java/net/jlibnoise/model/Line.java
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // }
import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException;
* * This noise module must exist for the lifetime of this object, * until you pass a new noise module to this method. */ public void setModule(Module module) { if (module == null) throw new IllegalArgumentException("module cannot be null"); this.module = module; } /** * Returns the output value from the noise module given the one-dimensional * coordinate of the specified input value located on the line segment. * * @param p The distance along the line segment (ranges from 0.0 to 1.0) * @return The output value from the noise module. * @pre A noise module was passed to the SetModule() method. * @pre The start and end points of the line segment were specified. * * The output value is generated by the noise module passed to the * SetModule() method. This value may be attenuated (moved toward 0.0) * as @a p approaches either end of the line segment; this is the * default behavior. * * If the value is not to be attenuated, @a p can safely range outside * the 0.0 to 1.0 range; the output value will be extrapolated along * the line that this segment is part of. */ public double getValue(double p) { if (module == null)
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // } // Path: src/main/java/net/jlibnoise/model/Line.java import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException; * * This noise module must exist for the lifetime of this object, * until you pass a new noise module to this method. */ public void setModule(Module module) { if (module == null) throw new IllegalArgumentException("module cannot be null"); this.module = module; } /** * Returns the output value from the noise module given the one-dimensional * coordinate of the specified input value located on the line segment. * * @param p The distance along the line segment (ranges from 0.0 to 1.0) * @return The output value from the noise module. * @pre A noise module was passed to the SetModule() method. * @pre The start and end points of the line segment were specified. * * The output value is generated by the noise module passed to the * SetModule() method. This value may be attenuated (moved toward 0.0) * as @a p approaches either end of the line segment; this is the * default behavior. * * If the value is not to be attenuated, @a p can safely range outside * the 0.0 to 1.0 range; the output value will be extrapolated along * the line that this segment is part of. */ public double getValue(double p) { if (module == null)
throw new NoModuleException();
Sleaker/jlibnoise
src/main/java/net/jlibnoise/combiner/Multiply.java
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // }
import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException;
/* Copyright (C) 2011 Garrett Fleenor This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. 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 (COPYING.txt) for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA This is a port of libnoise ( http://libnoise.sourceforge.net/index.html ). Original implementation by Jason Bevins */ package net.jlibnoise.combiner; public class Multiply extends Module { public Multiply() { super(2); } @Override public int getSourceModuleCount() { return 2; } @Override public double getValue(double x, double y, double z) { if (sourceModule[0] == null)
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // } // Path: src/main/java/net/jlibnoise/combiner/Multiply.java import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException; /* Copyright (C) 2011 Garrett Fleenor This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. 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 (COPYING.txt) for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA This is a port of libnoise ( http://libnoise.sourceforge.net/index.html ). Original implementation by Jason Bevins */ package net.jlibnoise.combiner; public class Multiply extends Module { public Multiply() { super(2); } @Override public int getSourceModuleCount() { return 2; } @Override public double getValue(double x, double y, double z) { if (sourceModule[0] == null)
throw new NoModuleException();
Sleaker/jlibnoise
src/main/java/net/jlibnoise/modifier/Abs.java
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // }
import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException;
/* Copyright (C) 2011 Garrett Fleenor This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. 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 (COPYING.txt) for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA This is a port of libnoise ( http://libnoise.sourceforge.net/index.html ). Original implementation by Jason Bevins */ package net.jlibnoise.modifier; public class Abs extends Module { public Abs() { super(1); } @Override public int getSourceModuleCount() { return 1; } @Override public double getValue(double x, double y, double z) { if (sourceModule == null)
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // } // Path: src/main/java/net/jlibnoise/modifier/Abs.java import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException; /* Copyright (C) 2011 Garrett Fleenor This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. 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 (COPYING.txt) for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA This is a port of libnoise ( http://libnoise.sourceforge.net/index.html ). Original implementation by Jason Bevins */ package net.jlibnoise.modifier; public class Abs extends Module { public Abs() { super(1); } @Override public int getSourceModuleCount() { return 1; } @Override public double getValue(double x, double y, double z) { if (sourceModule == null)
throw new NoModuleException();
Sleaker/jlibnoise
src/main/java/net/jlibnoise/modifier/Exponent.java
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // }
import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException;
/* Copyright (C) 2011 Garrett Fleenor This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. 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 (COPYING.txt) for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA This is a port of libnoise ( http://libnoise.sourceforge.net/index.html ). Original implementation by Jason Bevins */ package net.jlibnoise.modifier; public class Exponent extends Module { public static final double DEFAULT_EXPONENT = 1.0; protected double exponent = DEFAULT_EXPONENT; public Exponent() { super(1); } public double getExponent() { return exponent; } public void setExponent(double exponent) { this.exponent = exponent; } @Override public int getSourceModuleCount() { return 1; } @Override public double getValue(double x, double y, double z) { if (sourceModule[0] == null)
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // } // Path: src/main/java/net/jlibnoise/modifier/Exponent.java import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException; /* Copyright (C) 2011 Garrett Fleenor This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. 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 (COPYING.txt) for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA This is a port of libnoise ( http://libnoise.sourceforge.net/index.html ). Original implementation by Jason Bevins */ package net.jlibnoise.modifier; public class Exponent extends Module { public static final double DEFAULT_EXPONENT = 1.0; protected double exponent = DEFAULT_EXPONENT; public Exponent() { super(1); } public double getExponent() { return exponent; } public void setExponent(double exponent) { this.exponent = exponent; } @Override public int getSourceModuleCount() { return 1; } @Override public double getValue(double x, double y, double z) { if (sourceModule[0] == null)
throw new NoModuleException();
Sleaker/jlibnoise
src/main/java/net/jlibnoise/modifier/Invert.java
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // }
import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException;
/* Copyright (C) 2011 Garrett Fleenor This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. 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 (COPYING.txt) for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA This is a port of libnoise ( http://libnoise.sourceforge.net/index.html ). Original implementation by Jason Bevins */ package net.jlibnoise.modifier; public class Invert extends Module { public Invert() { super(1); } @Override public int getSourceModuleCount() { return 1; } @Override public double getValue(double x, double y, double z) { if (sourceModule[0] == null)
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // } // Path: src/main/java/net/jlibnoise/modifier/Invert.java import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException; /* Copyright (C) 2011 Garrett Fleenor This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. 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 (COPYING.txt) for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA This is a port of libnoise ( http://libnoise.sourceforge.net/index.html ). Original implementation by Jason Bevins */ package net.jlibnoise.modifier; public class Invert extends Module { public Invert() { super(1); } @Override public int getSourceModuleCount() { return 1; } @Override public double getValue(double x, double y, double z) { if (sourceModule[0] == null)
throw new NoModuleException();
Sleaker/jlibnoise
src/main/java/net/jlibnoise/transformer/TranslatePoint.java
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // }
import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException;
public double getYTranslation() { return yTranslation; } public void setYTranslation(double yTranslation) { this.yTranslation = yTranslation; } public double getZTranslation() { return zTranslation; } public void setZTranslation(double zTranslation) { this.zTranslation = zTranslation; } public void setTranslations(double x, double y, double z) { setXTranslation(x); setYTranslation(y); setZTranslation(z); } @Override public int getSourceModuleCount() { return 1; } @Override public double getValue(double x, double y, double z) { if (sourceModule[0] == null)
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // } // Path: src/main/java/net/jlibnoise/transformer/TranslatePoint.java import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException; public double getYTranslation() { return yTranslation; } public void setYTranslation(double yTranslation) { this.yTranslation = yTranslation; } public double getZTranslation() { return zTranslation; } public void setZTranslation(double zTranslation) { this.zTranslation = zTranslation; } public void setTranslations(double x, double y, double z) { setXTranslation(x); setYTranslation(y); setZTranslation(z); } @Override public int getSourceModuleCount() { return 1; } @Override public double getValue(double x, double y, double z) { if (sourceModule[0] == null)
throw new NoModuleException();
Sleaker/jlibnoise
src/main/java/net/jlibnoise/modifier/ScaleBias.java
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // }
import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException;
/* Copyright (C) 2011 Garrett Fleenor This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. 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 (COPYING.txt) for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA This is a port of libnoise ( http://libnoise.sourceforge.net/index.html ). Original implementation by Jason Bevins */ package net.jlibnoise.modifier; public class ScaleBias extends Module { /// Default bias for the noise::module::ScaleBias noise module. public static final double DEFAULT_BIAS = 0.0; /// Default scale for the noise::module::ScaleBias noise module. public static final double DEFAULT_SCALE = 1.0; /// Bias to apply to the scaled output value from the source module. double bias = DEFAULT_BIAS; /// Scaling factor to apply to the output value from the source /// module. double scale = DEFAULT_SCALE; public ScaleBias() { super(1); } public double getBias() { return bias; } public void setBias(double bias) { this.bias = bias; } public double getScale() { return scale; } public void setScale(double scale) { this.scale = scale; } @Override public int getSourceModuleCount() { return 1; } @Override public double getValue(double x, double y, double z) { if (sourceModule[0] == null)
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // } // Path: src/main/java/net/jlibnoise/modifier/ScaleBias.java import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException; /* Copyright (C) 2011 Garrett Fleenor This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. 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 (COPYING.txt) for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA This is a port of libnoise ( http://libnoise.sourceforge.net/index.html ). Original implementation by Jason Bevins */ package net.jlibnoise.modifier; public class ScaleBias extends Module { /// Default bias for the noise::module::ScaleBias noise module. public static final double DEFAULT_BIAS = 0.0; /// Default scale for the noise::module::ScaleBias noise module. public static final double DEFAULT_SCALE = 1.0; /// Bias to apply to the scaled output value from the source module. double bias = DEFAULT_BIAS; /// Scaling factor to apply to the output value from the source /// module. double scale = DEFAULT_SCALE; public ScaleBias() { super(1); } public double getBias() { return bias; } public void setBias(double bias) { this.bias = bias; } public double getScale() { return scale; } public void setScale(double scale) { this.scale = scale; } @Override public int getSourceModuleCount() { return 1; } @Override public double getValue(double x, double y, double z) { if (sourceModule[0] == null)
throw new NoModuleException();
Sleaker/jlibnoise
src/main/java/net/jlibnoise/combiner/Displace.java
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // }
import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException;
/* Copyright (C) 2011 Garrett Fleenor This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. 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 (COPYING.txt) for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA This is a port of libnoise ( http://libnoise.sourceforge.net/index.html ). Original implementation by Jason Bevins */ package net.jlibnoise.combiner; public class Displace extends Module { public Displace() { super(4); } @Override public int getSourceModuleCount() { return 4; } public Module GetXDisplaceModule() { if (sourceModule == null || sourceModule[1] == null) {
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // } // Path: src/main/java/net/jlibnoise/combiner/Displace.java import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException; /* Copyright (C) 2011 Garrett Fleenor This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. 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 (COPYING.txt) for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA This is a port of libnoise ( http://libnoise.sourceforge.net/index.html ). Original implementation by Jason Bevins */ package net.jlibnoise.combiner; public class Displace extends Module { public Displace() { super(4); } @Override public int getSourceModuleCount() { return 4; } public Module GetXDisplaceModule() { if (sourceModule == null || sourceModule[1] == null) {
throw new NoModuleException();
Sleaker/jlibnoise
src/main/java/net/jlibnoise/transformer/ScalePoint.java
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // }
import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException;
} public void setxScale(double xScale) { this.xScale = xScale; } public double getyScale() { return yScale; } public void setyScale(double yScale) { this.yScale = yScale; } public double getzScale() { return zScale; } public void setzScale(double zScale) { this.zScale = zScale; } @Override public int getSourceModuleCount() { return 1; } @Override public double getValue(double x, double y, double z) { if (sourceModule[0] == null)
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // } // Path: src/main/java/net/jlibnoise/transformer/ScalePoint.java import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException; } public void setxScale(double xScale) { this.xScale = xScale; } public double getyScale() { return yScale; } public void setyScale(double yScale) { this.yScale = yScale; } public double getzScale() { return zScale; } public void setzScale(double zScale) { this.zScale = zScale; } @Override public int getSourceModuleCount() { return 1; } @Override public double getValue(double x, double y, double z) { if (sourceModule[0] == null)
throw new NoModuleException();
Sleaker/jlibnoise
src/main/java/net/jlibnoise/combiner/Add.java
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // }
import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException;
/* Copyright (C) 2011 Garrett Fleenor This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. 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 (COPYING.txt) for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA This is a port of libnoise ( http://libnoise.sourceforge.net/index.html ). Original implementation by Jason Bevins */ package net.jlibnoise.combiner; public class Add extends Module { public Add() { super(2); } @Override public int getSourceModuleCount() { return 2; } @Override public double getValue(double x, double y, double z) { if (sourceModule[0] == null)
// Path: src/main/java/net/jlibnoise/Module.java // public abstract class Module { // protected Module[] sourceModule; // // public Module(int sourceModuleCount) { // sourceModule = null; // // // Create an array of pointers to all source modules required by this // // noise module. Set these pointers to NULL. // if (sourceModuleCount > 0) { // sourceModule = new Module[sourceModuleCount]; // for (int i = 0; i < sourceModuleCount; i++) { // sourceModule[i] = null; // } // } else { // sourceModule = null; // } // // } // // /** // * Returns a reference to a source module connected to this noise module. // * <p/> // * Each noise module requires the attachment of a certain number of // * source modules before an application can call the getValue() // * method. // * // * @param index The index value assigned to the source module. // * @return A reference to the source module. // * @throws NoModuleException See the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // * @pre A source module with the specified index value has been added // * to this noise module via a call to SetSourceModule(). // */ // public Module getSourceModule(int index) { // if (index >= getSourceModuleCount() || index < 0 || sourceModule[index] == null) { // throw new NoModuleException(); // } // return (sourceModule[index]); // // } // // /** // * Connects a source module to this noise module. // * // * A noise module mathematically combines the output values from the // * source modules to generate the value returned by getValue(). // * // * The index value to assign a source module is a unique identifier // * for that source module. If an index value has already been // * assigned to a source module, this noise module replaces the old // * source module with the new source module. // * // * Before an application can call the GetValue() method, it must // * first connect all required source modules. To determine the // * number of source modules required by this noise module, call the // * getSourceModuleCount() method. // * // * This source module must exist throughout the lifetime of this // * noise module unless another source module replaces that source // * module. // * // * A noise module does not modify a source module; it only modifies // * its output values. // * @param index An index value to assign to this source module. // * @param sourceModule The source module to attach. // * @throws IllegalArgumentException An invalid parameter was // * specified; see the preconditions for more information. // * @pre The index value ranges from 0 to one less than the number of // * source modules required by this noise module. // */ // public void setSourceModule(int index, Module sourceModule) { // if (this.sourceModule == null) // return; // if (index >= getSourceModuleCount() || index < 0) { // throw new IllegalArgumentException("Index must be between 0 and getSourceModuleCount()"); // } // this.sourceModule[index] = sourceModule; // } // // /** // * Returns the number of source modules required by this noise // * module. // * // * @return The number of source modules required by this noise module. // */ // public abstract int getSourceModuleCount(); // // /** // * Generates an output value given the coordinates of the specified // * input value. // * <p/> // * Before an application can call this method, it must first connect // * all required source modules via the SetSourceModule() method. If // * these source modules are not connected to this noise module, this // * method raises a debug assertion. // * <p/> // * To determine the number of source modules required by this noise // * module, call the getSourceModuleCount() method. // * // * // * @param x The @a x coordinate of the input value. // * @param y The @a y coordinate of the input value. // * @param z The @a z coordinate of the input value. // * @return The output value. // * @pre All source modules required by this noise module have been // * passed to the SetSourceModule() method. // */ // public abstract double getValue(double x, double y, double z); // } // // Path: src/main/java/net/jlibnoise/exception/NoModuleException.java // public class NoModuleException extends NoiseException { // private static final long serialVersionUID = 1L; // // } // Path: src/main/java/net/jlibnoise/combiner/Add.java import net.jlibnoise.Module; import net.jlibnoise.exception.NoModuleException; /* Copyright (C) 2011 Garrett Fleenor This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. 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 (COPYING.txt) for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA This is a port of libnoise ( http://libnoise.sourceforge.net/index.html ). Original implementation by Jason Bevins */ package net.jlibnoise.combiner; public class Add extends Module { public Add() { super(2); } @Override public int getSourceModuleCount() { return 2; } @Override public double getValue(double x, double y, double z) { if (sourceModule[0] == null)
throw new NoModuleException();
c0d1ngb4d/ASA
ASA/src/com/thesis/asa/mainui/AdvancedSettingsController.java
// Path: ASA/src/com/thesis/asa/Data.java // public class Data { // private static SparseArray<List<String>> permissions; // // public enum SecurityMode { // PERMISSIVE, SECURE, PARANOID; // // public static int toInteger(SecurityMode mode) { // switch(mode) { // case PERMISSIVE: // return 0; // case SECURE: // return 1; // case PARANOID: // return 2; // } // Log.d(Utilities.ERROR, "No int found for security mode: "+mode); // return -1; // } // // public static SecurityMode fromInteger(int mode) { // switch(mode) { // case 0: // return PERMISSIVE; // case 1: // return SECURE; // case 2: // return PARANOID; // } // // Log.d(Utilities.ERROR, "No security mode found for int: "+mode); // return PARANOID; // } // // } // // static // { // permissions = new SparseArray< List<String> >(); // permissions.put(0, Arrays.asList(Manifest.permission.READ_CONTACTS)); // permissions.put(1, Arrays.asList(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION)); // permissions.put(2, Arrays.asList(Manifest.permission.READ_PHONE_STATE)); // permissions.put(3, Arrays.asList(Manifest.permission.ACCESS_WIFI_STATE)); // permissions.put(4, Arrays.asList(Manifest.permission.INTERNET)); // } // // public static List<String> permissionsForPage(Integer page) { // return permissions.get(page); // } // // private static SparseArray<String> titles; // static // { // titles = new SparseArray<String>(); // titles.put(0, "Contacts"); // titles.put(1, "Location"); // titles.put(2, "Device data"); // titles.put(3, "Wifi info"); // titles.put(4, "Internet access"); // } // // public static String titleForPage(Integer page) { // return titles.get(page); // } // // private static Map<Integer, String> resourceClasses; // // static // { // resourceClasses = new HashMap<Integer, String>(); // resourceClasses.put(0, "com.thesis.asa.contacts.ContactsSettings"); // resourceClasses.put(1, "com.thesis.asa.location.LocationSettings"); // resourceClasses.put(2, "com.thesis.asa.devicedata.DeviceDataSettings"); // resourceClasses.put(3, "com.thesis.asa.wifi.WifiSettings"); // resourceClasses.put(4, "com.thesis.asa.internet.InternetSettings"); // } // // public static String getResourceFor(Integer page) { // return resourceClasses.get(page); // } // // public static Collection<String> resources() { // return resourceClasses.values(); // } // } // // Path: ASA/src/com/thesis/asa/resourcemvc/DefaultResourceActivity.java // public class DefaultResourceActivity extends ResourceActivity // { // protected void loadSettings() { // loadDefaultSettings(); // } // // @Override // public String getSelectedApplication() throws Exception { // throw new Exception("The activity has no reference to the package Name"); // } // // protected void loadIntent(Bundle extras) { // isSystem = extras.getInt(AdvancedSettingsActivity.SYSTEM, -1); // } // // @Override // protected OnClickListener getController() { // return new DefaultResourceController(view,resource); // } // // }
import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceClickListener; import com.thesis.asa.Data; import com.thesis.asa.resourcemvc.DefaultResourceActivity; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle;
/******************************************************************************* * Copyright (c) 2014 CodingBad. * All rights reserved. This file is part of ASA. * * ASA is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ASA is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ASA. If not, see <http://www.gnu.org/licenses/>. * * Contributors: * Ayelén Chavez - [email protected] * Joaquín Rinaudo - [email protected] ******************************************************************************/ package com.thesis.asa.mainui; public class AdvancedSettingsController implements OnPreferenceChangeListener, OnPreferenceClickListener { private AdvancedSettingsActivity activity; public AdvancedSettingsController(AdvancedSettingsActivity a) { activity = a; } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { boolean checked = Boolean.valueOf(newValue.toString()); SlidePageFragment.ADVANCED_DISPLAYED = checked; return true; } @Override public boolean onPreferenceClick(Preference preference) { if (preference.getKey().equals("system_key")) openActivity(preference.getContext(), 1); else if (preference.getKey().equals("third_key")) { openActivity(preference.getContext(), 0); } return true; } private void openActivity(Context context, int isSystem) { Intent intent = new Intent(context,
// Path: ASA/src/com/thesis/asa/Data.java // public class Data { // private static SparseArray<List<String>> permissions; // // public enum SecurityMode { // PERMISSIVE, SECURE, PARANOID; // // public static int toInteger(SecurityMode mode) { // switch(mode) { // case PERMISSIVE: // return 0; // case SECURE: // return 1; // case PARANOID: // return 2; // } // Log.d(Utilities.ERROR, "No int found for security mode: "+mode); // return -1; // } // // public static SecurityMode fromInteger(int mode) { // switch(mode) { // case 0: // return PERMISSIVE; // case 1: // return SECURE; // case 2: // return PARANOID; // } // // Log.d(Utilities.ERROR, "No security mode found for int: "+mode); // return PARANOID; // } // // } // // static // { // permissions = new SparseArray< List<String> >(); // permissions.put(0, Arrays.asList(Manifest.permission.READ_CONTACTS)); // permissions.put(1, Arrays.asList(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION)); // permissions.put(2, Arrays.asList(Manifest.permission.READ_PHONE_STATE)); // permissions.put(3, Arrays.asList(Manifest.permission.ACCESS_WIFI_STATE)); // permissions.put(4, Arrays.asList(Manifest.permission.INTERNET)); // } // // public static List<String> permissionsForPage(Integer page) { // return permissions.get(page); // } // // private static SparseArray<String> titles; // static // { // titles = new SparseArray<String>(); // titles.put(0, "Contacts"); // titles.put(1, "Location"); // titles.put(2, "Device data"); // titles.put(3, "Wifi info"); // titles.put(4, "Internet access"); // } // // public static String titleForPage(Integer page) { // return titles.get(page); // } // // private static Map<Integer, String> resourceClasses; // // static // { // resourceClasses = new HashMap<Integer, String>(); // resourceClasses.put(0, "com.thesis.asa.contacts.ContactsSettings"); // resourceClasses.put(1, "com.thesis.asa.location.LocationSettings"); // resourceClasses.put(2, "com.thesis.asa.devicedata.DeviceDataSettings"); // resourceClasses.put(3, "com.thesis.asa.wifi.WifiSettings"); // resourceClasses.put(4, "com.thesis.asa.internet.InternetSettings"); // } // // public static String getResourceFor(Integer page) { // return resourceClasses.get(page); // } // // public static Collection<String> resources() { // return resourceClasses.values(); // } // } // // Path: ASA/src/com/thesis/asa/resourcemvc/DefaultResourceActivity.java // public class DefaultResourceActivity extends ResourceActivity // { // protected void loadSettings() { // loadDefaultSettings(); // } // // @Override // public String getSelectedApplication() throws Exception { // throw new Exception("The activity has no reference to the package Name"); // } // // protected void loadIntent(Bundle extras) { // isSystem = extras.getInt(AdvancedSettingsActivity.SYSTEM, -1); // } // // @Override // protected OnClickListener getController() { // return new DefaultResourceController(view,resource); // } // // } // Path: ASA/src/com/thesis/asa/mainui/AdvancedSettingsController.java import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceClickListener; import com.thesis.asa.Data; import com.thesis.asa.resourcemvc.DefaultResourceActivity; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; /******************************************************************************* * Copyright (c) 2014 CodingBad. * All rights reserved. This file is part of ASA. * * ASA is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ASA is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ASA. If not, see <http://www.gnu.org/licenses/>. * * Contributors: * Ayelén Chavez - [email protected] * Joaquín Rinaudo - [email protected] ******************************************************************************/ package com.thesis.asa.mainui; public class AdvancedSettingsController implements OnPreferenceChangeListener, OnPreferenceClickListener { private AdvancedSettingsActivity activity; public AdvancedSettingsController(AdvancedSettingsActivity a) { activity = a; } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { boolean checked = Boolean.valueOf(newValue.toString()); SlidePageFragment.ADVANCED_DISPLAYED = checked; return true; } @Override public boolean onPreferenceClick(Preference preference) { if (preference.getKey().equals("system_key")) openActivity(preference.getContext(), 1); else if (preference.getKey().equals("third_key")) { openActivity(preference.getContext(), 0); } return true; } private void openActivity(Context context, int isSystem) { Intent intent = new Intent(context,
DefaultResourceActivity.class);
c0d1ngb4d/ASA
ASA/src/com/thesis/asa/mainui/AdvancedSettingsController.java
// Path: ASA/src/com/thesis/asa/Data.java // public class Data { // private static SparseArray<List<String>> permissions; // // public enum SecurityMode { // PERMISSIVE, SECURE, PARANOID; // // public static int toInteger(SecurityMode mode) { // switch(mode) { // case PERMISSIVE: // return 0; // case SECURE: // return 1; // case PARANOID: // return 2; // } // Log.d(Utilities.ERROR, "No int found for security mode: "+mode); // return -1; // } // // public static SecurityMode fromInteger(int mode) { // switch(mode) { // case 0: // return PERMISSIVE; // case 1: // return SECURE; // case 2: // return PARANOID; // } // // Log.d(Utilities.ERROR, "No security mode found for int: "+mode); // return PARANOID; // } // // } // // static // { // permissions = new SparseArray< List<String> >(); // permissions.put(0, Arrays.asList(Manifest.permission.READ_CONTACTS)); // permissions.put(1, Arrays.asList(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION)); // permissions.put(2, Arrays.asList(Manifest.permission.READ_PHONE_STATE)); // permissions.put(3, Arrays.asList(Manifest.permission.ACCESS_WIFI_STATE)); // permissions.put(4, Arrays.asList(Manifest.permission.INTERNET)); // } // // public static List<String> permissionsForPage(Integer page) { // return permissions.get(page); // } // // private static SparseArray<String> titles; // static // { // titles = new SparseArray<String>(); // titles.put(0, "Contacts"); // titles.put(1, "Location"); // titles.put(2, "Device data"); // titles.put(3, "Wifi info"); // titles.put(4, "Internet access"); // } // // public static String titleForPage(Integer page) { // return titles.get(page); // } // // private static Map<Integer, String> resourceClasses; // // static // { // resourceClasses = new HashMap<Integer, String>(); // resourceClasses.put(0, "com.thesis.asa.contacts.ContactsSettings"); // resourceClasses.put(1, "com.thesis.asa.location.LocationSettings"); // resourceClasses.put(2, "com.thesis.asa.devicedata.DeviceDataSettings"); // resourceClasses.put(3, "com.thesis.asa.wifi.WifiSettings"); // resourceClasses.put(4, "com.thesis.asa.internet.InternetSettings"); // } // // public static String getResourceFor(Integer page) { // return resourceClasses.get(page); // } // // public static Collection<String> resources() { // return resourceClasses.values(); // } // } // // Path: ASA/src/com/thesis/asa/resourcemvc/DefaultResourceActivity.java // public class DefaultResourceActivity extends ResourceActivity // { // protected void loadSettings() { // loadDefaultSettings(); // } // // @Override // public String getSelectedApplication() throws Exception { // throw new Exception("The activity has no reference to the package Name"); // } // // protected void loadIntent(Bundle extras) { // isSystem = extras.getInt(AdvancedSettingsActivity.SYSTEM, -1); // } // // @Override // protected OnClickListener getController() { // return new DefaultResourceController(view,resource); // } // // }
import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceClickListener; import com.thesis.asa.Data; import com.thesis.asa.resourcemvc.DefaultResourceActivity; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle;
/******************************************************************************* * Copyright (c) 2014 CodingBad. * All rights reserved. This file is part of ASA. * * ASA is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ASA is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ASA. If not, see <http://www.gnu.org/licenses/>. * * Contributors: * Ayelén Chavez - [email protected] * Joaquín Rinaudo - [email protected] ******************************************************************************/ package com.thesis.asa.mainui; public class AdvancedSettingsController implements OnPreferenceChangeListener, OnPreferenceClickListener { private AdvancedSettingsActivity activity; public AdvancedSettingsController(AdvancedSettingsActivity a) { activity = a; } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { boolean checked = Boolean.valueOf(newValue.toString()); SlidePageFragment.ADVANCED_DISPLAYED = checked; return true; } @Override public boolean onPreferenceClick(Preference preference) { if (preference.getKey().equals("system_key")) openActivity(preference.getContext(), 1); else if (preference.getKey().equals("third_key")) { openActivity(preference.getContext(), 0); } return true; } private void openActivity(Context context, int isSystem) { Intent intent = new Intent(context, DefaultResourceActivity.class); Bundle extras = new Bundle(); extras.putInt(AdvancedSettingsActivity.SYSTEM, isSystem); extras.putString(SlidePageFragment.RESOURCE,
// Path: ASA/src/com/thesis/asa/Data.java // public class Data { // private static SparseArray<List<String>> permissions; // // public enum SecurityMode { // PERMISSIVE, SECURE, PARANOID; // // public static int toInteger(SecurityMode mode) { // switch(mode) { // case PERMISSIVE: // return 0; // case SECURE: // return 1; // case PARANOID: // return 2; // } // Log.d(Utilities.ERROR, "No int found for security mode: "+mode); // return -1; // } // // public static SecurityMode fromInteger(int mode) { // switch(mode) { // case 0: // return PERMISSIVE; // case 1: // return SECURE; // case 2: // return PARANOID; // } // // Log.d(Utilities.ERROR, "No security mode found for int: "+mode); // return PARANOID; // } // // } // // static // { // permissions = new SparseArray< List<String> >(); // permissions.put(0, Arrays.asList(Manifest.permission.READ_CONTACTS)); // permissions.put(1, Arrays.asList(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION)); // permissions.put(2, Arrays.asList(Manifest.permission.READ_PHONE_STATE)); // permissions.put(3, Arrays.asList(Manifest.permission.ACCESS_WIFI_STATE)); // permissions.put(4, Arrays.asList(Manifest.permission.INTERNET)); // } // // public static List<String> permissionsForPage(Integer page) { // return permissions.get(page); // } // // private static SparseArray<String> titles; // static // { // titles = new SparseArray<String>(); // titles.put(0, "Contacts"); // titles.put(1, "Location"); // titles.put(2, "Device data"); // titles.put(3, "Wifi info"); // titles.put(4, "Internet access"); // } // // public static String titleForPage(Integer page) { // return titles.get(page); // } // // private static Map<Integer, String> resourceClasses; // // static // { // resourceClasses = new HashMap<Integer, String>(); // resourceClasses.put(0, "com.thesis.asa.contacts.ContactsSettings"); // resourceClasses.put(1, "com.thesis.asa.location.LocationSettings"); // resourceClasses.put(2, "com.thesis.asa.devicedata.DeviceDataSettings"); // resourceClasses.put(3, "com.thesis.asa.wifi.WifiSettings"); // resourceClasses.put(4, "com.thesis.asa.internet.InternetSettings"); // } // // public static String getResourceFor(Integer page) { // return resourceClasses.get(page); // } // // public static Collection<String> resources() { // return resourceClasses.values(); // } // } // // Path: ASA/src/com/thesis/asa/resourcemvc/DefaultResourceActivity.java // public class DefaultResourceActivity extends ResourceActivity // { // protected void loadSettings() { // loadDefaultSettings(); // } // // @Override // public String getSelectedApplication() throws Exception { // throw new Exception("The activity has no reference to the package Name"); // } // // protected void loadIntent(Bundle extras) { // isSystem = extras.getInt(AdvancedSettingsActivity.SYSTEM, -1); // } // // @Override // protected OnClickListener getController() { // return new DefaultResourceController(view,resource); // } // // } // Path: ASA/src/com/thesis/asa/mainui/AdvancedSettingsController.java import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceClickListener; import com.thesis.asa.Data; import com.thesis.asa.resourcemvc.DefaultResourceActivity; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; /******************************************************************************* * Copyright (c) 2014 CodingBad. * All rights reserved. This file is part of ASA. * * ASA is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ASA is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ASA. If not, see <http://www.gnu.org/licenses/>. * * Contributors: * Ayelén Chavez - [email protected] * Joaquín Rinaudo - [email protected] ******************************************************************************/ package com.thesis.asa.mainui; public class AdvancedSettingsController implements OnPreferenceChangeListener, OnPreferenceClickListener { private AdvancedSettingsActivity activity; public AdvancedSettingsController(AdvancedSettingsActivity a) { activity = a; } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { boolean checked = Boolean.valueOf(newValue.toString()); SlidePageFragment.ADVANCED_DISPLAYED = checked; return true; } @Override public boolean onPreferenceClick(Preference preference) { if (preference.getKey().equals("system_key")) openActivity(preference.getContext(), 1); else if (preference.getKey().equals("third_key")) { openActivity(preference.getContext(), 0); } return true; } private void openActivity(Context context, int isSystem) { Intent intent = new Intent(context, DefaultResourceActivity.class); Bundle extras = new Bundle(); extras.putInt(AdvancedSettingsActivity.SYSTEM, isSystem); extras.putString(SlidePageFragment.RESOURCE,
Data.getResourceFor(activity.getPageNumber()));
c0d1ngb4d/ASA
ASA/src/com/thesis/asa/mainui/AdvancedSettingsActivity.java
// Path: ASA/src/com/thesis/asa/Data.java // public class Data { // private static SparseArray<List<String>> permissions; // // public enum SecurityMode { // PERMISSIVE, SECURE, PARANOID; // // public static int toInteger(SecurityMode mode) { // switch(mode) { // case PERMISSIVE: // return 0; // case SECURE: // return 1; // case PARANOID: // return 2; // } // Log.d(Utilities.ERROR, "No int found for security mode: "+mode); // return -1; // } // // public static SecurityMode fromInteger(int mode) { // switch(mode) { // case 0: // return PERMISSIVE; // case 1: // return SECURE; // case 2: // return PARANOID; // } // // Log.d(Utilities.ERROR, "No security mode found for int: "+mode); // return PARANOID; // } // // } // // static // { // permissions = new SparseArray< List<String> >(); // permissions.put(0, Arrays.asList(Manifest.permission.READ_CONTACTS)); // permissions.put(1, Arrays.asList(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION)); // permissions.put(2, Arrays.asList(Manifest.permission.READ_PHONE_STATE)); // permissions.put(3, Arrays.asList(Manifest.permission.ACCESS_WIFI_STATE)); // permissions.put(4, Arrays.asList(Manifest.permission.INTERNET)); // } // // public static List<String> permissionsForPage(Integer page) { // return permissions.get(page); // } // // private static SparseArray<String> titles; // static // { // titles = new SparseArray<String>(); // titles.put(0, "Contacts"); // titles.put(1, "Location"); // titles.put(2, "Device data"); // titles.put(3, "Wifi info"); // titles.put(4, "Internet access"); // } // // public static String titleForPage(Integer page) { // return titles.get(page); // } // // private static Map<Integer, String> resourceClasses; // // static // { // resourceClasses = new HashMap<Integer, String>(); // resourceClasses.put(0, "com.thesis.asa.contacts.ContactsSettings"); // resourceClasses.put(1, "com.thesis.asa.location.LocationSettings"); // resourceClasses.put(2, "com.thesis.asa.devicedata.DeviceDataSettings"); // resourceClasses.put(3, "com.thesis.asa.wifi.WifiSettings"); // resourceClasses.put(4, "com.thesis.asa.internet.InternetSettings"); // } // // public static String getResourceFor(Integer page) { // return resourceClasses.get(page); // } // // public static Collection<String> resources() { // return resourceClasses.values(); // } // }
import android.preference.CheckBoxPreference; import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.PreferenceCategory; import com.google.android.gms.location.LocationClient; import com.thesis.asa.Data; import com.thesis.asa.R; import android.Manifest; import android.content.Intent; import android.os.Bundle;
/******************************************************************************* * Copyright (c) 2014 CodingBad. * All rights reserved. This file is part of ASA. * * ASA is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ASA is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ASA. If not, see <http://www.gnu.org/licenses/>. * * Contributors: * Ayelén Chavez - [email protected] * Joaquín Rinaudo - [email protected] ******************************************************************************/ package com.thesis.asa.mainui; public class AdvancedSettingsActivity extends PreferenceActivity { public static String SYSTEM = "is_system_app"; private int pageNumber; private AdvancedSettingsController controller; private AdvancedLocationSettingsController locationController; private AdvancedWifiSettingsController wifiController; private LocationClient locationClient; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); pageNumber = intent.getIntExtra(SlidePageFragment.PAGE_NUMBER, -1); addPreferencesFromResource(R.layout.settings_layout); controller = new AdvancedSettingsController(this);
// Path: ASA/src/com/thesis/asa/Data.java // public class Data { // private static SparseArray<List<String>> permissions; // // public enum SecurityMode { // PERMISSIVE, SECURE, PARANOID; // // public static int toInteger(SecurityMode mode) { // switch(mode) { // case PERMISSIVE: // return 0; // case SECURE: // return 1; // case PARANOID: // return 2; // } // Log.d(Utilities.ERROR, "No int found for security mode: "+mode); // return -1; // } // // public static SecurityMode fromInteger(int mode) { // switch(mode) { // case 0: // return PERMISSIVE; // case 1: // return SECURE; // case 2: // return PARANOID; // } // // Log.d(Utilities.ERROR, "No security mode found for int: "+mode); // return PARANOID; // } // // } // // static // { // permissions = new SparseArray< List<String> >(); // permissions.put(0, Arrays.asList(Manifest.permission.READ_CONTACTS)); // permissions.put(1, Arrays.asList(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION)); // permissions.put(2, Arrays.asList(Manifest.permission.READ_PHONE_STATE)); // permissions.put(3, Arrays.asList(Manifest.permission.ACCESS_WIFI_STATE)); // permissions.put(4, Arrays.asList(Manifest.permission.INTERNET)); // } // // public static List<String> permissionsForPage(Integer page) { // return permissions.get(page); // } // // private static SparseArray<String> titles; // static // { // titles = new SparseArray<String>(); // titles.put(0, "Contacts"); // titles.put(1, "Location"); // titles.put(2, "Device data"); // titles.put(3, "Wifi info"); // titles.put(4, "Internet access"); // } // // public static String titleForPage(Integer page) { // return titles.get(page); // } // // private static Map<Integer, String> resourceClasses; // // static // { // resourceClasses = new HashMap<Integer, String>(); // resourceClasses.put(0, "com.thesis.asa.contacts.ContactsSettings"); // resourceClasses.put(1, "com.thesis.asa.location.LocationSettings"); // resourceClasses.put(2, "com.thesis.asa.devicedata.DeviceDataSettings"); // resourceClasses.put(3, "com.thesis.asa.wifi.WifiSettings"); // resourceClasses.put(4, "com.thesis.asa.internet.InternetSettings"); // } // // public static String getResourceFor(Integer page) { // return resourceClasses.get(page); // } // // public static Collection<String> resources() { // return resourceClasses.values(); // } // } // Path: ASA/src/com/thesis/asa/mainui/AdvancedSettingsActivity.java import android.preference.CheckBoxPreference; import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.PreferenceCategory; import com.google.android.gms.location.LocationClient; import com.thesis.asa.Data; import com.thesis.asa.R; import android.Manifest; import android.content.Intent; import android.os.Bundle; /******************************************************************************* * Copyright (c) 2014 CodingBad. * All rights reserved. This file is part of ASA. * * ASA is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ASA is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ASA. If not, see <http://www.gnu.org/licenses/>. * * Contributors: * Ayelén Chavez - [email protected] * Joaquín Rinaudo - [email protected] ******************************************************************************/ package com.thesis.asa.mainui; public class AdvancedSettingsActivity extends PreferenceActivity { public static String SYSTEM = "is_system_app"; private int pageNumber; private AdvancedSettingsController controller; private AdvancedLocationSettingsController locationController; private AdvancedWifiSettingsController wifiController; private LocationClient locationClient; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); pageNumber = intent.getIntExtra(SlidePageFragment.PAGE_NUMBER, -1); addPreferencesFromResource(R.layout.settings_layout); controller = new AdvancedSettingsController(this);
if (Data.permissionsForPage(pageNumber).contains(
c0d1ngb4d/ASA
ASA/src/com/thesis/asa/devicedata/EditDeviceDataDialog.java
// Path: ASA/src/com/thesis/asa/resourcemvc/ResourceActivity.java // public abstract class ResourceActivity extends android.support.v4.app.FragmentActivity // { // protected int isSystem; // protected Resource resource; // protected ResourceView view; // // public int isSystem(){ // return isSystem; // } // // public abstract String getSelectedApplication() throws Exception; // // public void loadDefaultSettings() { // Object defaultConfiguration = resource.defaultConfiguration(isSystem); // Object[] settings = resource.loadSettingsFromConfiguration(defaultConfiguration); // view.displaySettingsFromConfiguration(settings); // } // // protected abstract void loadIntent(Bundle extras); // // protected abstract OnClickListener getController(); // // @Override // public void onCreate(Bundle bundle) // { // super.onCreate(bundle); // // Intent intent = getIntent(); // Bundle extras = intent.getExtras(); // String name = extras.getString(SlidePageFragment.RESOURCE); // try { // // resource = (Resource) Class.forName(name).getDeclaredConstructor(Context.class).newInstance(this); // view = (ResourceView) Class.forName(name+"View").getDeclaredConstructor(ResourceActivity.class, Resource.class).newInstance(this, resource); // } // catch (Exception e) { // Log.d(Utilities.ERROR,"ERROR AT LOADING CLASS OR CLASS OBJECT INITIALIZATION"+name+"View"); // Log.d(Utilities.ERROR,Log.getStackTraceString(e)); // } // // loadIntent(extras); // // // Sets the View Layer // view.showResourceViewIn(); // // loadSettings(); // // Button apply = (Button) findViewById(R.id.applyButton); // OnClickListener controller = getController(); // apply.setOnClickListener(controller); // // Button cancel = (Button) findViewById(R.id.cancelButton); // cancel.setOnClickListener(controller); // } // // protected abstract void loadSettings(); // }
import android.widget.EditText; import android.widget.TextView; import com.thesis.asa.R; import com.thesis.asa.resourcemvc.ResourceActivity; import android.app.Activity; import android.app.AlertDialog; import android.text.InputFilter; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.widget.Button;
/******************************************************************************* * Copyright (c) 2014 CodingBad. * All rights reserved. This file is part of ASA. * * ASA is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ASA is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ASA. If not, see <http://www.gnu.org/licenses/>. * * Contributors: * Ayelén Chavez - [email protected] * Joaquín Rinaudo - [email protected] ******************************************************************************/ package com.thesis.asa.devicedata; public class EditDeviceDataDialog { private AlertDialog view; private Activity activity; private DeviceDataInfoItem selectedItem; private View layout; private final EditText editAndroidId; private final EditText editDeviceId; private final EditText editSubscriberId; private final EditText editSimSerialNumber; private final EditText editLine1Number; private final Button applyButton; private int androidIdLenght; private int deviceIdLenght; private int subscriberIdLenght; private int simSerialNumberLenght; private int line1NumberLenght; private DeviceDataSettings model; private boolean hasPlus = false;
// Path: ASA/src/com/thesis/asa/resourcemvc/ResourceActivity.java // public abstract class ResourceActivity extends android.support.v4.app.FragmentActivity // { // protected int isSystem; // protected Resource resource; // protected ResourceView view; // // public int isSystem(){ // return isSystem; // } // // public abstract String getSelectedApplication() throws Exception; // // public void loadDefaultSettings() { // Object defaultConfiguration = resource.defaultConfiguration(isSystem); // Object[] settings = resource.loadSettingsFromConfiguration(defaultConfiguration); // view.displaySettingsFromConfiguration(settings); // } // // protected abstract void loadIntent(Bundle extras); // // protected abstract OnClickListener getController(); // // @Override // public void onCreate(Bundle bundle) // { // super.onCreate(bundle); // // Intent intent = getIntent(); // Bundle extras = intent.getExtras(); // String name = extras.getString(SlidePageFragment.RESOURCE); // try { // // resource = (Resource) Class.forName(name).getDeclaredConstructor(Context.class).newInstance(this); // view = (ResourceView) Class.forName(name+"View").getDeclaredConstructor(ResourceActivity.class, Resource.class).newInstance(this, resource); // } // catch (Exception e) { // Log.d(Utilities.ERROR,"ERROR AT LOADING CLASS OR CLASS OBJECT INITIALIZATION"+name+"View"); // Log.d(Utilities.ERROR,Log.getStackTraceString(e)); // } // // loadIntent(extras); // // // Sets the View Layer // view.showResourceViewIn(); // // loadSettings(); // // Button apply = (Button) findViewById(R.id.applyButton); // OnClickListener controller = getController(); // apply.setOnClickListener(controller); // // Button cancel = (Button) findViewById(R.id.cancelButton); // cancel.setOnClickListener(controller); // } // // protected abstract void loadSettings(); // } // Path: ASA/src/com/thesis/asa/devicedata/EditDeviceDataDialog.java import android.widget.EditText; import android.widget.TextView; import com.thesis.asa.R; import com.thesis.asa.resourcemvc.ResourceActivity; import android.app.Activity; import android.app.AlertDialog; import android.text.InputFilter; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.widget.Button; /******************************************************************************* * Copyright (c) 2014 CodingBad. * All rights reserved. This file is part of ASA. * * ASA is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ASA is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ASA. If not, see <http://www.gnu.org/licenses/>. * * Contributors: * Ayelén Chavez - [email protected] * Joaquín Rinaudo - [email protected] ******************************************************************************/ package com.thesis.asa.devicedata; public class EditDeviceDataDialog { private AlertDialog view; private Activity activity; private DeviceDataInfoItem selectedItem; private View layout; private final EditText editAndroidId; private final EditText editDeviceId; private final EditText editSubscriberId; private final EditText editSimSerialNumber; private final EditText editLine1Number; private final Button applyButton; private int androidIdLenght; private int deviceIdLenght; private int subscriberIdLenght; private int simSerialNumberLenght; private int line1NumberLenght; private DeviceDataSettings model; private boolean hasPlus = false;
public EditDeviceDataDialog(ResourceActivity a, DeviceDataSettings m, DeviceDataInfoItem item) {
c0d1ngb4d/ASA
ASA/src/com/thesis/asa/hook/ContactsHook.java
// Path: ASA/src/com/thesis/asa/contacts/ContactsSettings.java // public class ContactsSettings extends Resource { // // public ContactsSettings(Context c) { // super(c); // } // // public String tableName() { // return SettingsDB.CONTACTS_TABLE; // } // // public ContentValues createDBEntry(String pkgName, String processes, Object[] selectedConfigurations) { // ContentValues values = new ContentValues(); // // values.put(SettingsDB.COL_PKG_NAME, pkgName); // values.put(SettingsDB.COL_PROCESSES_NAMES, processes); // Integer[] selectedConfigurationInt = new Integer[selectedConfigurations.length]; // // for(int i = 0; i < selectedConfigurations.length; i++){ // selectedConfigurationInt[i] = Integer.parseInt(""+selectedConfigurations[i]); // } // // values.put(SettingsDB.COL_GROUPS, Arrays.toString((Integer[]) selectedConfigurationInt)); // // return values; // } // // public Uri uri() { // return Uri.parse("content://com.thesis.asa.settings/contacts_settings"); // } // // public Object configurationFromCursor(Cursor groups) { // int groupColumnIndex = groups.getColumnIndex(SettingsDB.COL_GROUPS); // String filteredGroups = groups.getString(groupColumnIndex); // // return filteredGroups; // } // // public Object[] loadSettingsFromConfiguration(Object configuration) { // String filteredGroups = (String) configuration; // int[] groupIds = new int[0]; // // int size = filteredGroups.length(); // if (size > 2) { // filteredGroups = filteredGroups.substring(1, size-1); // groupIds = Utilities.processLine(filteredGroups.split(",")); // } // // Object[] ids = new Object[groupIds.length]; // for (int index = 0; index < groupIds.length; index ++) { // ids[index] = groupIds[index]; // } // // return ids; // } // // public String permissions() { // return Manifest.permission.READ_CONTACTS; // } // // protected String[] getGroupIds(Context context) { // Cursor groups = context.getContentResolver().query(ContactsContract.Groups.CONTENT_URI, // new String[] { ContactsContract.Groups._ID } // , null, null, null); // String[] ids = new String[groups.getCount()]; // if (groups != null && groups.moveToFirst()) { // // int idColumnIndex = groups.getColumnIndex(ContactsContract.Groups._ID); // int index = 0; // do{ // int id = groups.getInt(idColumnIndex); // ids[index] = ""+id; // index++; // } // while(groups.moveToNext()); // } // // if(groups != null && !groups.isClosed()){ // groups.close(); // } // // return ids; // } // // @Override // public Object[] getConfigurationByMode(SecurityMode mode, int isSystem) { // String[] configuration = null; // switch (mode) { // case PERMISSIVE: // configuration = getGroupIds(context); // break; // case SECURE: // if (isSystem == 1) // configuration= getGroupIds(context); // else // configuration = new String[0]; // break; // case PARANOID: // configuration = new String[0]; // break; // } // // return configuration; // } // }
import android.database.Cursor; import android.database.DatabaseUtils; import android.net.Uri; import android.provider.ContactsContract; import android.util.Log; import com.saurik.substrate.MS; import com.thesis.asa.contacts.ContactsSettings; import java.lang.reflect.Method; import java.util.Arrays; import android.os.Build; import android.os.CancellationSignal; import android.annotation.SuppressLint; import android.content.ContentProvider; import android.content.Context;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) params = new Class[5]; else { params = new Class[6]; params[5] = CancellationSignal.class; } params[0] = Uri.class; params[1] = String[].class; params[2] = String.class; params[3] = String[].class; params[4] = String.class; query = contentProvider.getMethod("query", params); } catch (NoSuchMethodException e) { query = null; } if (query != null) { MS.hookMethod( contentProvider, query, new MS.MethodAlteration<ContentProvider, Cursor>() { public Cursor invoked( ContentProvider contentProvider, Object... args) throws Throwable { Context context = contentProvider.getContext();
// Path: ASA/src/com/thesis/asa/contacts/ContactsSettings.java // public class ContactsSettings extends Resource { // // public ContactsSettings(Context c) { // super(c); // } // // public String tableName() { // return SettingsDB.CONTACTS_TABLE; // } // // public ContentValues createDBEntry(String pkgName, String processes, Object[] selectedConfigurations) { // ContentValues values = new ContentValues(); // // values.put(SettingsDB.COL_PKG_NAME, pkgName); // values.put(SettingsDB.COL_PROCESSES_NAMES, processes); // Integer[] selectedConfigurationInt = new Integer[selectedConfigurations.length]; // // for(int i = 0; i < selectedConfigurations.length; i++){ // selectedConfigurationInt[i] = Integer.parseInt(""+selectedConfigurations[i]); // } // // values.put(SettingsDB.COL_GROUPS, Arrays.toString((Integer[]) selectedConfigurationInt)); // // return values; // } // // public Uri uri() { // return Uri.parse("content://com.thesis.asa.settings/contacts_settings"); // } // // public Object configurationFromCursor(Cursor groups) { // int groupColumnIndex = groups.getColumnIndex(SettingsDB.COL_GROUPS); // String filteredGroups = groups.getString(groupColumnIndex); // // return filteredGroups; // } // // public Object[] loadSettingsFromConfiguration(Object configuration) { // String filteredGroups = (String) configuration; // int[] groupIds = new int[0]; // // int size = filteredGroups.length(); // if (size > 2) { // filteredGroups = filteredGroups.substring(1, size-1); // groupIds = Utilities.processLine(filteredGroups.split(",")); // } // // Object[] ids = new Object[groupIds.length]; // for (int index = 0; index < groupIds.length; index ++) { // ids[index] = groupIds[index]; // } // // return ids; // } // // public String permissions() { // return Manifest.permission.READ_CONTACTS; // } // // protected String[] getGroupIds(Context context) { // Cursor groups = context.getContentResolver().query(ContactsContract.Groups.CONTENT_URI, // new String[] { ContactsContract.Groups._ID } // , null, null, null); // String[] ids = new String[groups.getCount()]; // if (groups != null && groups.moveToFirst()) { // // int idColumnIndex = groups.getColumnIndex(ContactsContract.Groups._ID); // int index = 0; // do{ // int id = groups.getInt(idColumnIndex); // ids[index] = ""+id; // index++; // } // while(groups.moveToNext()); // } // // if(groups != null && !groups.isClosed()){ // groups.close(); // } // // return ids; // } // // @Override // public Object[] getConfigurationByMode(SecurityMode mode, int isSystem) { // String[] configuration = null; // switch (mode) { // case PERMISSIVE: // configuration = getGroupIds(context); // break; // case SECURE: // if (isSystem == 1) // configuration= getGroupIds(context); // else // configuration = new String[0]; // break; // case PARANOID: // configuration = new String[0]; // break; // } // // return configuration; // } // } // Path: ASA/src/com/thesis/asa/hook/ContactsHook.java import android.database.Cursor; import android.database.DatabaseUtils; import android.net.Uri; import android.provider.ContactsContract; import android.util.Log; import com.saurik.substrate.MS; import com.thesis.asa.contacts.ContactsSettings; import java.lang.reflect.Method; import java.util.Arrays; import android.os.Build; import android.os.CancellationSignal; import android.annotation.SuppressLint; import android.content.ContentProvider; import android.content.Context; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) params = new Class[5]; else { params = new Class[6]; params[5] = CancellationSignal.class; } params[0] = Uri.class; params[1] = String[].class; params[2] = String.class; params[3] = String[].class; params[4] = String.class; query = contentProvider.getMethod("query", params); } catch (NoSuchMethodException e) { query = null; } if (query != null) { MS.hookMethod( contentProvider, query, new MS.MethodAlteration<ContentProvider, Cursor>() { public Cursor invoked( ContentProvider contentProvider, Object... args) throws Throwable { Context context = contentProvider.getContext();
Object[] filteredGroups = Hook.queryConfigurationFromASA(context, new ContactsSettings(context));
c0d1ngb4d/ASA
ASA/src/com/thesis/asa/resourcemvc/DefaultResourceActivity.java
// Path: ASA/src/com/thesis/asa/mainui/AdvancedSettingsActivity.java // public class AdvancedSettingsActivity extends PreferenceActivity { // public static String SYSTEM = "is_system_app"; // private int pageNumber; // // private AdvancedSettingsController controller; // private AdvancedLocationSettingsController locationController; // private AdvancedWifiSettingsController wifiController; // private LocationClient locationClient; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // Intent intent = getIntent(); // pageNumber = intent.getIntExtra(SlidePageFragment.PAGE_NUMBER, -1); // // addPreferencesFromResource(R.layout.settings_layout); // controller = new AdvancedSettingsController(this); // // if (Data.permissionsForPage(pageNumber).contains( // Manifest.permission.ACCESS_WIFI_STATE)) { // wifiController = new AdvancedWifiSettingsController(this); // Preference custom = new Preference(this); // custom.setTitle("Manage wifi saved state"); // custom.setSummary("Add, modify and remove custom wifi states"); // custom.setOnPreferenceClickListener(wifiController); // PreferenceCategory category = (PreferenceCategory) findPreference("settings_key"); // category.addPreference(custom); // } // // if (Data.permissionsForPage(pageNumber).contains( // Manifest.permission.ACCESS_FINE_LOCATION)) { // locationController = new AdvancedLocationSettingsController(this); // locationClient = new LocationClient(this, locationController, locationController); // Preference custom = new Preference(this); // custom.setTitle("Save current location"); // custom.setSummary("Add current location configuration for later use"); // custom.setOnPreferenceClickListener(locationController); // PreferenceCategory category = (PreferenceCategory) findPreference("settings_key"); // category.addPreference(custom); // } // // CheckBoxPreference preference = (CheckBoxPreference) findPreference("advanced_key"); // preference.setChecked(SlidePageFragment.ADVANCED_DISPLAYED); // // preference.setOnPreferenceChangeListener(controller); // Preference system = (Preference) findPreference("system_key"); // system.setOnPreferenceClickListener(controller); // // Preference thirdParty = (Preference) findPreference("third_key"); // thirdParty.setOnPreferenceClickListener(controller); // } // // public LocationClient getLocationClient() { // return locationClient; // } // // public int getPageNumber() { // return pageNumber; // } // // @Override // protected void onStop() { // if (locationClient != null) // locationClient.disconnect(); // super.onStop(); // } // }
import com.thesis.asa.mainui.AdvancedSettingsActivity; import android.os.Bundle; import android.view.View.OnClickListener;
/******************************************************************************* * Copyright (c) 2014 CodingBad. * All rights reserved. This file is part of ASA. * * ASA is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ASA is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ASA. If not, see <http://www.gnu.org/licenses/>. * * Contributors: * Ayelén Chavez - [email protected] * Joaquín Rinaudo - [email protected] ******************************************************************************/ package com.thesis.asa.resourcemvc; public class DefaultResourceActivity extends ResourceActivity { protected void loadSettings() { loadDefaultSettings(); } @Override public String getSelectedApplication() throws Exception { throw new Exception("The activity has no reference to the package Name"); } protected void loadIntent(Bundle extras) {
// Path: ASA/src/com/thesis/asa/mainui/AdvancedSettingsActivity.java // public class AdvancedSettingsActivity extends PreferenceActivity { // public static String SYSTEM = "is_system_app"; // private int pageNumber; // // private AdvancedSettingsController controller; // private AdvancedLocationSettingsController locationController; // private AdvancedWifiSettingsController wifiController; // private LocationClient locationClient; // // @Override // public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // Intent intent = getIntent(); // pageNumber = intent.getIntExtra(SlidePageFragment.PAGE_NUMBER, -1); // // addPreferencesFromResource(R.layout.settings_layout); // controller = new AdvancedSettingsController(this); // // if (Data.permissionsForPage(pageNumber).contains( // Manifest.permission.ACCESS_WIFI_STATE)) { // wifiController = new AdvancedWifiSettingsController(this); // Preference custom = new Preference(this); // custom.setTitle("Manage wifi saved state"); // custom.setSummary("Add, modify and remove custom wifi states"); // custom.setOnPreferenceClickListener(wifiController); // PreferenceCategory category = (PreferenceCategory) findPreference("settings_key"); // category.addPreference(custom); // } // // if (Data.permissionsForPage(pageNumber).contains( // Manifest.permission.ACCESS_FINE_LOCATION)) { // locationController = new AdvancedLocationSettingsController(this); // locationClient = new LocationClient(this, locationController, locationController); // Preference custom = new Preference(this); // custom.setTitle("Save current location"); // custom.setSummary("Add current location configuration for later use"); // custom.setOnPreferenceClickListener(locationController); // PreferenceCategory category = (PreferenceCategory) findPreference("settings_key"); // category.addPreference(custom); // } // // CheckBoxPreference preference = (CheckBoxPreference) findPreference("advanced_key"); // preference.setChecked(SlidePageFragment.ADVANCED_DISPLAYED); // // preference.setOnPreferenceChangeListener(controller); // Preference system = (Preference) findPreference("system_key"); // system.setOnPreferenceClickListener(controller); // // Preference thirdParty = (Preference) findPreference("third_key"); // thirdParty.setOnPreferenceClickListener(controller); // } // // public LocationClient getLocationClient() { // return locationClient; // } // // public int getPageNumber() { // return pageNumber; // } // // @Override // protected void onStop() { // if (locationClient != null) // locationClient.disconnect(); // super.onStop(); // } // } // Path: ASA/src/com/thesis/asa/resourcemvc/DefaultResourceActivity.java import com.thesis.asa.mainui.AdvancedSettingsActivity; import android.os.Bundle; import android.view.View.OnClickListener; /******************************************************************************* * Copyright (c) 2014 CodingBad. * All rights reserved. This file is part of ASA. * * ASA is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ASA is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ASA. If not, see <http://www.gnu.org/licenses/>. * * Contributors: * Ayelén Chavez - [email protected] * Joaquín Rinaudo - [email protected] ******************************************************************************/ package com.thesis.asa.resourcemvc; public class DefaultResourceActivity extends ResourceActivity { protected void loadSettings() { loadDefaultSettings(); } @Override public String getSelectedApplication() throws Exception { throw new Exception("The activity has no reference to the package Name"); } protected void loadIntent(Bundle extras) {
isSystem = extras.getInt(AdvancedSettingsActivity.SYSTEM, -1);
c0d1ngb4d/ASA
ASA/src/com/thesis/asa/mainui/SeparatedListAdapter.java
// Path: ASA/src/com/thesis/asa/contacts/ContactsGroupItem.java // public class ContactsGroupItem { // private String label; // private String account; // private int groupId; // // public ContactsGroupItem(String l, String a, int id){ // label = l; // account = a; // groupId = id; // } // // public String getAccount() { // return account; // } // // public String getLabel() { // return label; // } // // public int getGroupId() { // return groupId; // } // }
import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.ArrayAdapter; import android.widget.BaseAdapter; import java.util.LinkedHashMap; import java.util.Map; import com.thesis.asa.R; import com.thesis.asa.contacts.ContactsGroupItem; import android.content.Context;
/******************************************************************************* * Copyright (c) 2014 CodingBad. * All rights reserved. This file is part of ASA. * * ASA is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ASA is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ASA. If not, see <http://www.gnu.org/licenses/>. * * Contributors: * Ayelén Chavez - [email protected] * Joaquín Rinaudo - [email protected] ******************************************************************************/ package com.thesis.asa.mainui; public class SeparatedListAdapter extends BaseAdapter { public final Map<String, Adapter> sections = new LinkedHashMap<String, Adapter>(); public final ArrayAdapter<String> headers; public final static int TYPE_SECTION_HEADER = 0; public SeparatedListAdapter(Context context) { headers = new ArrayAdapter<String>(context, R.layout.separated_list_layout); } public void addSection(String section, Adapter adapter) { headers.add(section); sections.put(section, adapter); } public int getLabelIndexFor(int id) { int relativePosition = 0; for (Object section : this.sections.keySet()) { Adapter ad = this.sections.get(section); for(int i = 0 ; i < ad.getCount(); i++) {
// Path: ASA/src/com/thesis/asa/contacts/ContactsGroupItem.java // public class ContactsGroupItem { // private String label; // private String account; // private int groupId; // // public ContactsGroupItem(String l, String a, int id){ // label = l; // account = a; // groupId = id; // } // // public String getAccount() { // return account; // } // // public String getLabel() { // return label; // } // // public int getGroupId() { // return groupId; // } // } // Path: ASA/src/com/thesis/asa/mainui/SeparatedListAdapter.java import android.view.View; import android.view.ViewGroup; import android.widget.Adapter; import android.widget.ArrayAdapter; import android.widget.BaseAdapter; import java.util.LinkedHashMap; import java.util.Map; import com.thesis.asa.R; import com.thesis.asa.contacts.ContactsGroupItem; import android.content.Context; /******************************************************************************* * Copyright (c) 2014 CodingBad. * All rights reserved. This file is part of ASA. * * ASA is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ASA is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ASA. If not, see <http://www.gnu.org/licenses/>. * * Contributors: * Ayelén Chavez - [email protected] * Joaquín Rinaudo - [email protected] ******************************************************************************/ package com.thesis.asa.mainui; public class SeparatedListAdapter extends BaseAdapter { public final Map<String, Adapter> sections = new LinkedHashMap<String, Adapter>(); public final ArrayAdapter<String> headers; public final static int TYPE_SECTION_HEADER = 0; public SeparatedListAdapter(Context context) { headers = new ArrayAdapter<String>(context, R.layout.separated_list_layout); } public void addSection(String section, Adapter adapter) { headers.add(section); sections.put(section, adapter); } public int getLabelIndexFor(int id) { int relativePosition = 0; for (Object section : this.sections.keySet()) { Adapter ad = this.sections.get(section); for(int i = 0 ; i < ad.getCount(); i++) {
ContactsGroupItem group = (ContactsGroupItem) ad.getItem(i);
ubleipzig/iiif-producer
xml-doc/src/test/java/de/ubleipzig/iiifproducer/doc/GetXMLFileTest.java
// Path: xml-doc/src/main/java/de/ubleipzig/iiifproducer/doc/MetsManifestBuilder.java // static MetsData getMetsFromFile(final String url) { // try { // final XBProjector projector = new XBProjector(TO_STRING_RENDERS_XML); // return projector.io().file(url).read(MetsData.class); // } catch (IOException e) { // e.printStackTrace(); // throw new RuntimeException("Cannot Read XML: " + e.getMessage()); // } // } // // Path: xml-doc/src/main/java/de/ubleipzig/iiifproducer/doc/ResourceLoader.java // public static MetsData getMetsAnchor(final String sourceFileUri) { // final File metsFile = new File(sourceFileUri); // if (metsFile.exists()) { // final String baseFileName = getBaseName(metsFile.getName()); // final String anchorFileName = baseFileName + "_anchor.xml"; // final String anchorFilePath = metsFile.getParent() + separator + anchorFileName; // final File anchorfile = new File(anchorFilePath); // if (anchorfile.exists()) { // return getMetsFromFile(anchorfile); // } // } // return null; // }
import static de.ubleipzig.iiifproducer.doc.MetsManifestBuilder.getMetsFromFile; import static de.ubleipzig.iiifproducer.doc.ResourceLoader.getMetsAnchor; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.File; import java.util.Objects; import org.junit.jupiter.api.Test;
/* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.doc; public class GetXMLFileTest { @Test void testGetAnchorFile() { final String testFileSource = GetXMLFileTest.class.getResource("/mets/BntItin_021340072.xml").getPath();
// Path: xml-doc/src/main/java/de/ubleipzig/iiifproducer/doc/MetsManifestBuilder.java // static MetsData getMetsFromFile(final String url) { // try { // final XBProjector projector = new XBProjector(TO_STRING_RENDERS_XML); // return projector.io().file(url).read(MetsData.class); // } catch (IOException e) { // e.printStackTrace(); // throw new RuntimeException("Cannot Read XML: " + e.getMessage()); // } // } // // Path: xml-doc/src/main/java/de/ubleipzig/iiifproducer/doc/ResourceLoader.java // public static MetsData getMetsAnchor(final String sourceFileUri) { // final File metsFile = new File(sourceFileUri); // if (metsFile.exists()) { // final String baseFileName = getBaseName(metsFile.getName()); // final String anchorFileName = baseFileName + "_anchor.xml"; // final String anchorFilePath = metsFile.getParent() + separator + anchorFileName; // final File anchorfile = new File(anchorFilePath); // if (anchorfile.exists()) { // return getMetsFromFile(anchorfile); // } // } // return null; // } // Path: xml-doc/src/test/java/de/ubleipzig/iiifproducer/doc/GetXMLFileTest.java import static de.ubleipzig.iiifproducer.doc.MetsManifestBuilder.getMetsFromFile; import static de.ubleipzig.iiifproducer.doc.ResourceLoader.getMetsAnchor; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.File; import java.util.Objects; import org.junit.jupiter.api.Test; /* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.doc; public class GetXMLFileTest { @Test void testGetAnchorFile() { final String testFileSource = GetXMLFileTest.class.getResource("/mets/BntItin_021340072.xml").getPath();
final MetsData mets = getMetsAnchor(testFileSource);
ubleipzig/iiif-producer
xml-doc/src/test/java/de/ubleipzig/iiifproducer/doc/GetXMLFileTest.java
// Path: xml-doc/src/main/java/de/ubleipzig/iiifproducer/doc/MetsManifestBuilder.java // static MetsData getMetsFromFile(final String url) { // try { // final XBProjector projector = new XBProjector(TO_STRING_RENDERS_XML); // return projector.io().file(url).read(MetsData.class); // } catch (IOException e) { // e.printStackTrace(); // throw new RuntimeException("Cannot Read XML: " + e.getMessage()); // } // } // // Path: xml-doc/src/main/java/de/ubleipzig/iiifproducer/doc/ResourceLoader.java // public static MetsData getMetsAnchor(final String sourceFileUri) { // final File metsFile = new File(sourceFileUri); // if (metsFile.exists()) { // final String baseFileName = getBaseName(metsFile.getName()); // final String anchorFileName = baseFileName + "_anchor.xml"; // final String anchorFilePath = metsFile.getParent() + separator + anchorFileName; // final File anchorfile = new File(anchorFilePath); // if (anchorfile.exists()) { // return getMetsFromFile(anchorfile); // } // } // return null; // }
import static de.ubleipzig.iiifproducer.doc.MetsManifestBuilder.getMetsFromFile; import static de.ubleipzig.iiifproducer.doc.ResourceLoader.getMetsAnchor; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.File; import java.util.Objects; import org.junit.jupiter.api.Test;
/* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.doc; public class GetXMLFileTest { @Test void testGetAnchorFile() { final String testFileSource = GetXMLFileTest.class.getResource("/mets/BntItin_021340072.xml").getPath(); final MetsData mets = getMetsAnchor(testFileSource); final String anchorFileLabel = Objects.requireNonNull(mets).getManifestTitle().orElse(""); assertEquals( "Itinerarivm Sacrae Scriptvrae, Das ist: Ein Reisebuch vber die gantze heilige Schrifft", anchorFileLabel); } @Test void testGetInvalidAnchorFile() { final String testFileSource = "/non-existing.xml"; final MetsData mets = getMetsAnchor(testFileSource); assertNull(mets); } @Test void testIOException() { final String testFileSource = "/non-existing.xml"; assertThrows(RuntimeException.class, () -> {
// Path: xml-doc/src/main/java/de/ubleipzig/iiifproducer/doc/MetsManifestBuilder.java // static MetsData getMetsFromFile(final String url) { // try { // final XBProjector projector = new XBProjector(TO_STRING_RENDERS_XML); // return projector.io().file(url).read(MetsData.class); // } catch (IOException e) { // e.printStackTrace(); // throw new RuntimeException("Cannot Read XML: " + e.getMessage()); // } // } // // Path: xml-doc/src/main/java/de/ubleipzig/iiifproducer/doc/ResourceLoader.java // public static MetsData getMetsAnchor(final String sourceFileUri) { // final File metsFile = new File(sourceFileUri); // if (metsFile.exists()) { // final String baseFileName = getBaseName(metsFile.getName()); // final String anchorFileName = baseFileName + "_anchor.xml"; // final String anchorFilePath = metsFile.getParent() + separator + anchorFileName; // final File anchorfile = new File(anchorFilePath); // if (anchorfile.exists()) { // return getMetsFromFile(anchorfile); // } // } // return null; // } // Path: xml-doc/src/test/java/de/ubleipzig/iiifproducer/doc/GetXMLFileTest.java import static de.ubleipzig.iiifproducer.doc.MetsManifestBuilder.getMetsFromFile; import static de.ubleipzig.iiifproducer.doc.ResourceLoader.getMetsAnchor; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.File; import java.util.Objects; import org.junit.jupiter.api.Test; /* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.doc; public class GetXMLFileTest { @Test void testGetAnchorFile() { final String testFileSource = GetXMLFileTest.class.getResource("/mets/BntItin_021340072.xml").getPath(); final MetsData mets = getMetsAnchor(testFileSource); final String anchorFileLabel = Objects.requireNonNull(mets).getManifestTitle().orElse(""); assertEquals( "Itinerarivm Sacrae Scriptvrae, Das ist: Ein Reisebuch vber die gantze heilige Schrifft", anchorFileLabel); } @Test void testGetInvalidAnchorFile() { final String testFileSource = "/non-existing.xml"; final MetsData mets = getMetsAnchor(testFileSource); assertNull(mets); } @Test void testIOException() { final String testFileSource = "/non-existing.xml"; assertThrows(RuntimeException.class, () -> {
getMetsFromFile(testFileSource);
ubleipzig/iiif-producer
producer/src/test/java/de/ubleipzig/iiifproducer/producer/SetNullableMetadataTest.java
// Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/ManifestSerializer.java // public static Optional<String> serialize(final Object manifest) { // try { // return of(MAPPER.writer(PrettyPrinter.instance).writeValueAsString(manifest)); // } catch (final JsonProcessingException ex) { // return empty(); // } // } // // Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/TemplateManifest.java // @JsonInclude(Include.NON_NULL) // @JsonPropertyOrder({"@context", "@id", "@type", "label", "license", "attribution", "logo", "related", "metadata", // "sequences", "structures"}) // public class TemplateManifest { // // @JsonProperty("@context") // private String context; // // @JsonProperty("@id") // private String id; // // @JsonProperty("@type") // private String type = SCEnum.Manifest.compactedIRI(); // // @JsonProperty("label") // private String label = "unnamed"; // // @JsonProperty("license") // private String license; // // @JsonProperty("attribution") // private String attribution; // // @JsonProperty("logo") // private String logo; // // @JsonProperty("related") // private List<String> related; // // @JsonProperty("metadata") // private List<TemplateMetadata> metadata; // // @JsonProperty("sequences") // private List<TemplateSequence> sequences; // // @JsonProperty("structures") // private List<TemplateStructure> structures; // // /** // * TemplateManifest. // */ // public TemplateManifest() { // } // // /** // * @param context String // */ // public void setContext(final String context) { // this.context = context; // } // // /** // * @param id String // */ // public void setId(final String id) { // this.id = id; // } // // /** // * @param type String // */ // public void setType(final String type) { // this.type = type; // } // // /** // * @param label String // */ // public void setLabel(final String label) { // this.label = label; // } // // /** // * @param license String // */ // public void setLicense(final String license) { // this.license = license; // } // // /** // * @param attribution String // */ // public void setAttribution(final String attribution) { // this.attribution = attribution; // } // // /** // * @param logo String // */ // public void setLogo(final String logo) { // this.logo = logo; // } // // /** // * @param related List // */ // public void setRelated(final List<String> related) { // this.related = related; // } // // /** // * @param sequences List // */ // public void setSequences(final List<TemplateSequence> sequences) { // this.sequences = sequences; // } // // /** // * @param metadata List // */ // public void setMetadata(final List<TemplateMetadata> metadata) { // this.metadata = metadata; // } // // /** // * @return List // */ // public List<TemplateStructure> getStructures() { // return this.structures; // } // // /** // * @param structures List // */ // public void setStructures(final List<TemplateStructure> structures) { // this.structures = structures; // } // }
import static de.ubleipzig.iiifproducer.template.ManifestSerializer.serialize; import static java.lang.System.out; import static java.nio.file.Paths.get; import static org.junit.jupiter.api.Assertions.assertTrue; import de.ubleipzig.iiifproducer.template.TemplateManifest; import java.util.Optional; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test;
/* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.producer; /** * SetNullableMetadataTest. * * @author christopher-johnson */ public class SetNullableMetadataTest { private static String sourceFile; @BeforeAll static void setup() { sourceFile = SetNullableMetadataTest.class.getResource("/BlhDie_004285964.xml").getPath(); } @Test void testSetManuscriptMetadata() { final Config config = new Config(); config.setXmlFile(sourceFile); config.setOutputFile("/tmp/test.json"); config.setViewId("004285964"); final MetsAccessor mets = new MetsImpl(config);
// Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/ManifestSerializer.java // public static Optional<String> serialize(final Object manifest) { // try { // return of(MAPPER.writer(PrettyPrinter.instance).writeValueAsString(manifest)); // } catch (final JsonProcessingException ex) { // return empty(); // } // } // // Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/TemplateManifest.java // @JsonInclude(Include.NON_NULL) // @JsonPropertyOrder({"@context", "@id", "@type", "label", "license", "attribution", "logo", "related", "metadata", // "sequences", "structures"}) // public class TemplateManifest { // // @JsonProperty("@context") // private String context; // // @JsonProperty("@id") // private String id; // // @JsonProperty("@type") // private String type = SCEnum.Manifest.compactedIRI(); // // @JsonProperty("label") // private String label = "unnamed"; // // @JsonProperty("license") // private String license; // // @JsonProperty("attribution") // private String attribution; // // @JsonProperty("logo") // private String logo; // // @JsonProperty("related") // private List<String> related; // // @JsonProperty("metadata") // private List<TemplateMetadata> metadata; // // @JsonProperty("sequences") // private List<TemplateSequence> sequences; // // @JsonProperty("structures") // private List<TemplateStructure> structures; // // /** // * TemplateManifest. // */ // public TemplateManifest() { // } // // /** // * @param context String // */ // public void setContext(final String context) { // this.context = context; // } // // /** // * @param id String // */ // public void setId(final String id) { // this.id = id; // } // // /** // * @param type String // */ // public void setType(final String type) { // this.type = type; // } // // /** // * @param label String // */ // public void setLabel(final String label) { // this.label = label; // } // // /** // * @param license String // */ // public void setLicense(final String license) { // this.license = license; // } // // /** // * @param attribution String // */ // public void setAttribution(final String attribution) { // this.attribution = attribution; // } // // /** // * @param logo String // */ // public void setLogo(final String logo) { // this.logo = logo; // } // // /** // * @param related List // */ // public void setRelated(final List<String> related) { // this.related = related; // } // // /** // * @param sequences List // */ // public void setSequences(final List<TemplateSequence> sequences) { // this.sequences = sequences; // } // // /** // * @param metadata List // */ // public void setMetadata(final List<TemplateMetadata> metadata) { // this.metadata = metadata; // } // // /** // * @return List // */ // public List<TemplateStructure> getStructures() { // return this.structures; // } // // /** // * @param structures List // */ // public void setStructures(final List<TemplateStructure> structures) { // this.structures = structures; // } // } // Path: producer/src/test/java/de/ubleipzig/iiifproducer/producer/SetNullableMetadataTest.java import static de.ubleipzig.iiifproducer.template.ManifestSerializer.serialize; import static java.lang.System.out; import static java.nio.file.Paths.get; import static org.junit.jupiter.api.Assertions.assertTrue; import de.ubleipzig.iiifproducer.template.TemplateManifest; import java.util.Optional; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; /* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.producer; /** * SetNullableMetadataTest. * * @author christopher-johnson */ public class SetNullableMetadataTest { private static String sourceFile; @BeforeAll static void setup() { sourceFile = SetNullableMetadataTest.class.getResource("/BlhDie_004285964.xml").getPath(); } @Test void testSetManuscriptMetadata() { final Config config = new Config(); config.setXmlFile(sourceFile); config.setOutputFile("/tmp/test.json"); config.setViewId("004285964"); final MetsAccessor mets = new MetsImpl(config);
final TemplateManifest body = new TemplateManifest();
ubleipzig/iiif-producer
producer/src/test/java/de/ubleipzig/iiifproducer/producer/SetNullableMetadataTest.java
// Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/ManifestSerializer.java // public static Optional<String> serialize(final Object manifest) { // try { // return of(MAPPER.writer(PrettyPrinter.instance).writeValueAsString(manifest)); // } catch (final JsonProcessingException ex) { // return empty(); // } // } // // Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/TemplateManifest.java // @JsonInclude(Include.NON_NULL) // @JsonPropertyOrder({"@context", "@id", "@type", "label", "license", "attribution", "logo", "related", "metadata", // "sequences", "structures"}) // public class TemplateManifest { // // @JsonProperty("@context") // private String context; // // @JsonProperty("@id") // private String id; // // @JsonProperty("@type") // private String type = SCEnum.Manifest.compactedIRI(); // // @JsonProperty("label") // private String label = "unnamed"; // // @JsonProperty("license") // private String license; // // @JsonProperty("attribution") // private String attribution; // // @JsonProperty("logo") // private String logo; // // @JsonProperty("related") // private List<String> related; // // @JsonProperty("metadata") // private List<TemplateMetadata> metadata; // // @JsonProperty("sequences") // private List<TemplateSequence> sequences; // // @JsonProperty("structures") // private List<TemplateStructure> structures; // // /** // * TemplateManifest. // */ // public TemplateManifest() { // } // // /** // * @param context String // */ // public void setContext(final String context) { // this.context = context; // } // // /** // * @param id String // */ // public void setId(final String id) { // this.id = id; // } // // /** // * @param type String // */ // public void setType(final String type) { // this.type = type; // } // // /** // * @param label String // */ // public void setLabel(final String label) { // this.label = label; // } // // /** // * @param license String // */ // public void setLicense(final String license) { // this.license = license; // } // // /** // * @param attribution String // */ // public void setAttribution(final String attribution) { // this.attribution = attribution; // } // // /** // * @param logo String // */ // public void setLogo(final String logo) { // this.logo = logo; // } // // /** // * @param related List // */ // public void setRelated(final List<String> related) { // this.related = related; // } // // /** // * @param sequences List // */ // public void setSequences(final List<TemplateSequence> sequences) { // this.sequences = sequences; // } // // /** // * @param metadata List // */ // public void setMetadata(final List<TemplateMetadata> metadata) { // this.metadata = metadata; // } // // /** // * @return List // */ // public List<TemplateStructure> getStructures() { // return this.structures; // } // // /** // * @param structures List // */ // public void setStructures(final List<TemplateStructure> structures) { // this.structures = structures; // } // }
import static de.ubleipzig.iiifproducer.template.ManifestSerializer.serialize; import static java.lang.System.out; import static java.nio.file.Paths.get; import static org.junit.jupiter.api.Assertions.assertTrue; import de.ubleipzig.iiifproducer.template.TemplateManifest; import java.util.Optional; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test;
/* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.producer; /** * SetNullableMetadataTest. * * @author christopher-johnson */ public class SetNullableMetadataTest { private static String sourceFile; @BeforeAll static void setup() { sourceFile = SetNullableMetadataTest.class.getResource("/BlhDie_004285964.xml").getPath(); } @Test void testSetManuscriptMetadata() { final Config config = new Config(); config.setXmlFile(sourceFile); config.setOutputFile("/tmp/test.json"); config.setViewId("004285964"); final MetsAccessor mets = new MetsImpl(config); final TemplateManifest body = new TemplateManifest(); mets.setHandschriftMetadata(body);
// Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/ManifestSerializer.java // public static Optional<String> serialize(final Object manifest) { // try { // return of(MAPPER.writer(PrettyPrinter.instance).writeValueAsString(manifest)); // } catch (final JsonProcessingException ex) { // return empty(); // } // } // // Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/TemplateManifest.java // @JsonInclude(Include.NON_NULL) // @JsonPropertyOrder({"@context", "@id", "@type", "label", "license", "attribution", "logo", "related", "metadata", // "sequences", "structures"}) // public class TemplateManifest { // // @JsonProperty("@context") // private String context; // // @JsonProperty("@id") // private String id; // // @JsonProperty("@type") // private String type = SCEnum.Manifest.compactedIRI(); // // @JsonProperty("label") // private String label = "unnamed"; // // @JsonProperty("license") // private String license; // // @JsonProperty("attribution") // private String attribution; // // @JsonProperty("logo") // private String logo; // // @JsonProperty("related") // private List<String> related; // // @JsonProperty("metadata") // private List<TemplateMetadata> metadata; // // @JsonProperty("sequences") // private List<TemplateSequence> sequences; // // @JsonProperty("structures") // private List<TemplateStructure> structures; // // /** // * TemplateManifest. // */ // public TemplateManifest() { // } // // /** // * @param context String // */ // public void setContext(final String context) { // this.context = context; // } // // /** // * @param id String // */ // public void setId(final String id) { // this.id = id; // } // // /** // * @param type String // */ // public void setType(final String type) { // this.type = type; // } // // /** // * @param label String // */ // public void setLabel(final String label) { // this.label = label; // } // // /** // * @param license String // */ // public void setLicense(final String license) { // this.license = license; // } // // /** // * @param attribution String // */ // public void setAttribution(final String attribution) { // this.attribution = attribution; // } // // /** // * @param logo String // */ // public void setLogo(final String logo) { // this.logo = logo; // } // // /** // * @param related List // */ // public void setRelated(final List<String> related) { // this.related = related; // } // // /** // * @param sequences List // */ // public void setSequences(final List<TemplateSequence> sequences) { // this.sequences = sequences; // } // // /** // * @param metadata List // */ // public void setMetadata(final List<TemplateMetadata> metadata) { // this.metadata = metadata; // } // // /** // * @return List // */ // public List<TemplateStructure> getStructures() { // return this.structures; // } // // /** // * @param structures List // */ // public void setStructures(final List<TemplateStructure> structures) { // this.structures = structures; // } // } // Path: producer/src/test/java/de/ubleipzig/iiifproducer/producer/SetNullableMetadataTest.java import static de.ubleipzig.iiifproducer.template.ManifestSerializer.serialize; import static java.lang.System.out; import static java.nio.file.Paths.get; import static org.junit.jupiter.api.Assertions.assertTrue; import de.ubleipzig.iiifproducer.template.TemplateManifest; import java.util.Optional; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; /* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.producer; /** * SetNullableMetadataTest. * * @author christopher-johnson */ public class SetNullableMetadataTest { private static String sourceFile; @BeforeAll static void setup() { sourceFile = SetNullableMetadataTest.class.getResource("/BlhDie_004285964.xml").getPath(); } @Test void testSetManuscriptMetadata() { final Config config = new Config(); config.setXmlFile(sourceFile); config.setOutputFile("/tmp/test.json"); config.setViewId("004285964"); final MetsAccessor mets = new MetsImpl(config); final TemplateManifest body = new TemplateManifest(); mets.setHandschriftMetadata(body);
final Optional<String> json = serialize(body);
ubleipzig/iiif-producer
xml-doc/src/test/java/de/ubleipzig/iiifproducer/doc/GetStandardMetadataTest.java
// Path: xml-doc/src/main/java/de/ubleipzig/iiifproducer/doc/ResourceLoader.java // public static MetsData getMets(final String sourceFile) { // logger.debug("Loading MetsData from File {}", sourceFile); // return getMetsFromFile(sourceFile); // } // // Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/TemplateMetadata.java // @JsonPropertyOrder({"label", "value"}) // public class TemplateMetadata { // // @JsonProperty("label") // private String label; // // @JsonProperty("value") // private String value; // // /** // * @param label String // * @param value String // */ // public TemplateMetadata(final String label, final String value) { // this.label = label; // this.value = value; // } // // /** // * @return String // */ // @JsonIgnore // public String getLabel() { // return this.label; // } // // /** // * @return String // */ // @JsonIgnore // public String getValue() { // return this.value; // } // }
import static de.ubleipzig.iiifproducer.doc.ResourceLoader.getMets; import static org.junit.jupiter.api.Assertions.assertEquals; import de.ubleipzig.iiifproducer.template.TemplateMetadata; import java.util.List; import java.util.stream.Collectors; import org.junit.jupiter.api.Test;
/* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.doc; public class GetStandardMetadataTest { @Test void getStandardMetadataWithOptionalCollection() { final String sourceFile = GetValuesFromMetsTest.class.getResource("/mets/AllgCaHaD_045008345.xml").getPath();
// Path: xml-doc/src/main/java/de/ubleipzig/iiifproducer/doc/ResourceLoader.java // public static MetsData getMets(final String sourceFile) { // logger.debug("Loading MetsData from File {}", sourceFile); // return getMetsFromFile(sourceFile); // } // // Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/TemplateMetadata.java // @JsonPropertyOrder({"label", "value"}) // public class TemplateMetadata { // // @JsonProperty("label") // private String label; // // @JsonProperty("value") // private String value; // // /** // * @param label String // * @param value String // */ // public TemplateMetadata(final String label, final String value) { // this.label = label; // this.value = value; // } // // /** // * @return String // */ // @JsonIgnore // public String getLabel() { // return this.label; // } // // /** // * @return String // */ // @JsonIgnore // public String getValue() { // return this.value; // } // } // Path: xml-doc/src/test/java/de/ubleipzig/iiifproducer/doc/GetStandardMetadataTest.java import static de.ubleipzig.iiifproducer.doc.ResourceLoader.getMets; import static org.junit.jupiter.api.Assertions.assertEquals; import de.ubleipzig.iiifproducer.template.TemplateMetadata; import java.util.List; import java.util.stream.Collectors; import org.junit.jupiter.api.Test; /* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.doc; public class GetStandardMetadataTest { @Test void getStandardMetadataWithOptionalCollection() { final String sourceFile = GetValuesFromMetsTest.class.getResource("/mets/AllgCaHaD_045008345.xml").getPath();
final MetsData mets = getMets(sourceFile);
ubleipzig/iiif-producer
xml-doc/src/test/java/de/ubleipzig/iiifproducer/doc/GetStandardMetadataTest.java
// Path: xml-doc/src/main/java/de/ubleipzig/iiifproducer/doc/ResourceLoader.java // public static MetsData getMets(final String sourceFile) { // logger.debug("Loading MetsData from File {}", sourceFile); // return getMetsFromFile(sourceFile); // } // // Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/TemplateMetadata.java // @JsonPropertyOrder({"label", "value"}) // public class TemplateMetadata { // // @JsonProperty("label") // private String label; // // @JsonProperty("value") // private String value; // // /** // * @param label String // * @param value String // */ // public TemplateMetadata(final String label, final String value) { // this.label = label; // this.value = value; // } // // /** // * @return String // */ // @JsonIgnore // public String getLabel() { // return this.label; // } // // /** // * @return String // */ // @JsonIgnore // public String getValue() { // return this.value; // } // }
import static de.ubleipzig.iiifproducer.doc.ResourceLoader.getMets; import static org.junit.jupiter.api.Assertions.assertEquals; import de.ubleipzig.iiifproducer.template.TemplateMetadata; import java.util.List; import java.util.stream.Collectors; import org.junit.jupiter.api.Test;
/* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.doc; public class GetStandardMetadataTest { @Test void getStandardMetadataWithOptionalCollection() { final String sourceFile = GetValuesFromMetsTest.class.getResource("/mets/AllgCaHaD_045008345.xml").getPath(); final MetsData mets = getMets(sourceFile); final StandardMetadata man = new StandardMetadata(mets);
// Path: xml-doc/src/main/java/de/ubleipzig/iiifproducer/doc/ResourceLoader.java // public static MetsData getMets(final String sourceFile) { // logger.debug("Loading MetsData from File {}", sourceFile); // return getMetsFromFile(sourceFile); // } // // Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/TemplateMetadata.java // @JsonPropertyOrder({"label", "value"}) // public class TemplateMetadata { // // @JsonProperty("label") // private String label; // // @JsonProperty("value") // private String value; // // /** // * @param label String // * @param value String // */ // public TemplateMetadata(final String label, final String value) { // this.label = label; // this.value = value; // } // // /** // * @return String // */ // @JsonIgnore // public String getLabel() { // return this.label; // } // // /** // * @return String // */ // @JsonIgnore // public String getValue() { // return this.value; // } // } // Path: xml-doc/src/test/java/de/ubleipzig/iiifproducer/doc/GetStandardMetadataTest.java import static de.ubleipzig.iiifproducer.doc.ResourceLoader.getMets; import static org.junit.jupiter.api.Assertions.assertEquals; import de.ubleipzig.iiifproducer.template.TemplateMetadata; import java.util.List; import java.util.stream.Collectors; import org.junit.jupiter.api.Test; /* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.doc; public class GetStandardMetadataTest { @Test void getStandardMetadataWithOptionalCollection() { final String sourceFile = GetValuesFromMetsTest.class.getResource("/mets/AllgCaHaD_045008345.xml").getPath(); final MetsData mets = getMets(sourceFile); final StandardMetadata man = new StandardMetadata(mets);
final List<TemplateMetadata> info = man.getInfo();
ubleipzig/iiif-producer
producer/src/test/java/de/ubleipzig/iiifproducer/producer/AnchorFileTest.java
// Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/TemplateManifest.java // @JsonInclude(Include.NON_NULL) // @JsonPropertyOrder({"@context", "@id", "@type", "label", "license", "attribution", "logo", "related", "metadata", // "sequences", "structures"}) // public class TemplateManifest { // // @JsonProperty("@context") // private String context; // // @JsonProperty("@id") // private String id; // // @JsonProperty("@type") // private String type = SCEnum.Manifest.compactedIRI(); // // @JsonProperty("label") // private String label = "unnamed"; // // @JsonProperty("license") // private String license; // // @JsonProperty("attribution") // private String attribution; // // @JsonProperty("logo") // private String logo; // // @JsonProperty("related") // private List<String> related; // // @JsonProperty("metadata") // private List<TemplateMetadata> metadata; // // @JsonProperty("sequences") // private List<TemplateSequence> sequences; // // @JsonProperty("structures") // private List<TemplateStructure> structures; // // /** // * TemplateManifest. // */ // public TemplateManifest() { // } // // /** // * @param context String // */ // public void setContext(final String context) { // this.context = context; // } // // /** // * @param id String // */ // public void setId(final String id) { // this.id = id; // } // // /** // * @param type String // */ // public void setType(final String type) { // this.type = type; // } // // /** // * @param label String // */ // public void setLabel(final String label) { // this.label = label; // } // // /** // * @param license String // */ // public void setLicense(final String license) { // this.license = license; // } // // /** // * @param attribution String // */ // public void setAttribution(final String attribution) { // this.attribution = attribution; // } // // /** // * @param logo String // */ // public void setLogo(final String logo) { // this.logo = logo; // } // // /** // * @param related List // */ // public void setRelated(final List<String> related) { // this.related = related; // } // // /** // * @param sequences List // */ // public void setSequences(final List<TemplateSequence> sequences) { // this.sequences = sequences; // } // // /** // * @param metadata List // */ // public void setMetadata(final List<TemplateMetadata> metadata) { // this.metadata = metadata; // } // // /** // * @return List // */ // public List<TemplateStructure> getStructures() { // return this.structures; // } // // /** // * @param structures List // */ // public void setStructures(final List<TemplateStructure> structures) { // this.structures = structures; // } // } // // Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/TemplateMetadata.java // @JsonPropertyOrder({"label", "value"}) // public class TemplateMetadata { // // @JsonProperty("label") // private String label; // // @JsonProperty("value") // private String value; // // /** // * @param label String // * @param value String // */ // public TemplateMetadata(final String label, final String value) { // this.label = label; // this.value = value; // } // // /** // * @return String // */ // @JsonIgnore // public String getLabel() { // return this.label; // } // // /** // * @return String // */ // @JsonIgnore // public String getValue() { // return this.value; // } // }
import static java.nio.file.Paths.get; import static org.junit.jupiter.api.Assertions.assertEquals; import de.ubleipzig.iiifproducer.template.TemplateManifest; import de.ubleipzig.iiifproducer.template.TemplateMetadata; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test;
/* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.producer; public class AnchorFileTest { private static Config config = new Config(); @BeforeAll static void setup() { final String path = get(".").toAbsolutePath().normalize().getParent().toString(); final String sourceFile = path + "/xml-doc/src/test/resources/mets/BntItin_021340072.xml"; config.setXmlFile(sourceFile); config.setOutputFile("/tmp/test.json"); config.setViewId("004285964"); config.setAnchorKey("Part of"); } @Test void testGetAnchorFileMetadata() { final MetsAccessor mets = new MetsImpl(config);
// Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/TemplateManifest.java // @JsonInclude(Include.NON_NULL) // @JsonPropertyOrder({"@context", "@id", "@type", "label", "license", "attribution", "logo", "related", "metadata", // "sequences", "structures"}) // public class TemplateManifest { // // @JsonProperty("@context") // private String context; // // @JsonProperty("@id") // private String id; // // @JsonProperty("@type") // private String type = SCEnum.Manifest.compactedIRI(); // // @JsonProperty("label") // private String label = "unnamed"; // // @JsonProperty("license") // private String license; // // @JsonProperty("attribution") // private String attribution; // // @JsonProperty("logo") // private String logo; // // @JsonProperty("related") // private List<String> related; // // @JsonProperty("metadata") // private List<TemplateMetadata> metadata; // // @JsonProperty("sequences") // private List<TemplateSequence> sequences; // // @JsonProperty("structures") // private List<TemplateStructure> structures; // // /** // * TemplateManifest. // */ // public TemplateManifest() { // } // // /** // * @param context String // */ // public void setContext(final String context) { // this.context = context; // } // // /** // * @param id String // */ // public void setId(final String id) { // this.id = id; // } // // /** // * @param type String // */ // public void setType(final String type) { // this.type = type; // } // // /** // * @param label String // */ // public void setLabel(final String label) { // this.label = label; // } // // /** // * @param license String // */ // public void setLicense(final String license) { // this.license = license; // } // // /** // * @param attribution String // */ // public void setAttribution(final String attribution) { // this.attribution = attribution; // } // // /** // * @param logo String // */ // public void setLogo(final String logo) { // this.logo = logo; // } // // /** // * @param related List // */ // public void setRelated(final List<String> related) { // this.related = related; // } // // /** // * @param sequences List // */ // public void setSequences(final List<TemplateSequence> sequences) { // this.sequences = sequences; // } // // /** // * @param metadata List // */ // public void setMetadata(final List<TemplateMetadata> metadata) { // this.metadata = metadata; // } // // /** // * @return List // */ // public List<TemplateStructure> getStructures() { // return this.structures; // } // // /** // * @param structures List // */ // public void setStructures(final List<TemplateStructure> structures) { // this.structures = structures; // } // } // // Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/TemplateMetadata.java // @JsonPropertyOrder({"label", "value"}) // public class TemplateMetadata { // // @JsonProperty("label") // private String label; // // @JsonProperty("value") // private String value; // // /** // * @param label String // * @param value String // */ // public TemplateMetadata(final String label, final String value) { // this.label = label; // this.value = value; // } // // /** // * @return String // */ // @JsonIgnore // public String getLabel() { // return this.label; // } // // /** // * @return String // */ // @JsonIgnore // public String getValue() { // return this.value; // } // } // Path: producer/src/test/java/de/ubleipzig/iiifproducer/producer/AnchorFileTest.java import static java.nio.file.Paths.get; import static org.junit.jupiter.api.Assertions.assertEquals; import de.ubleipzig.iiifproducer.template.TemplateManifest; import de.ubleipzig.iiifproducer.template.TemplateMetadata; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; /* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.producer; public class AnchorFileTest { private static Config config = new Config(); @BeforeAll static void setup() { final String path = get(".").toAbsolutePath().normalize().getParent().toString(); final String sourceFile = path + "/xml-doc/src/test/resources/mets/BntItin_021340072.xml"; config.setXmlFile(sourceFile); config.setOutputFile("/tmp/test.json"); config.setViewId("004285964"); config.setAnchorKey("Part of"); } @Test void testGetAnchorFileMetadata() { final MetsAccessor mets = new MetsImpl(config);
final TemplateMetadata metadata = mets.getAnchorFileMetadata();
ubleipzig/iiif-producer
producer/src/test/java/de/ubleipzig/iiifproducer/producer/AnchorFileTest.java
// Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/TemplateManifest.java // @JsonInclude(Include.NON_NULL) // @JsonPropertyOrder({"@context", "@id", "@type", "label", "license", "attribution", "logo", "related", "metadata", // "sequences", "structures"}) // public class TemplateManifest { // // @JsonProperty("@context") // private String context; // // @JsonProperty("@id") // private String id; // // @JsonProperty("@type") // private String type = SCEnum.Manifest.compactedIRI(); // // @JsonProperty("label") // private String label = "unnamed"; // // @JsonProperty("license") // private String license; // // @JsonProperty("attribution") // private String attribution; // // @JsonProperty("logo") // private String logo; // // @JsonProperty("related") // private List<String> related; // // @JsonProperty("metadata") // private List<TemplateMetadata> metadata; // // @JsonProperty("sequences") // private List<TemplateSequence> sequences; // // @JsonProperty("structures") // private List<TemplateStructure> structures; // // /** // * TemplateManifest. // */ // public TemplateManifest() { // } // // /** // * @param context String // */ // public void setContext(final String context) { // this.context = context; // } // // /** // * @param id String // */ // public void setId(final String id) { // this.id = id; // } // // /** // * @param type String // */ // public void setType(final String type) { // this.type = type; // } // // /** // * @param label String // */ // public void setLabel(final String label) { // this.label = label; // } // // /** // * @param license String // */ // public void setLicense(final String license) { // this.license = license; // } // // /** // * @param attribution String // */ // public void setAttribution(final String attribution) { // this.attribution = attribution; // } // // /** // * @param logo String // */ // public void setLogo(final String logo) { // this.logo = logo; // } // // /** // * @param related List // */ // public void setRelated(final List<String> related) { // this.related = related; // } // // /** // * @param sequences List // */ // public void setSequences(final List<TemplateSequence> sequences) { // this.sequences = sequences; // } // // /** // * @param metadata List // */ // public void setMetadata(final List<TemplateMetadata> metadata) { // this.metadata = metadata; // } // // /** // * @return List // */ // public List<TemplateStructure> getStructures() { // return this.structures; // } // // /** // * @param structures List // */ // public void setStructures(final List<TemplateStructure> structures) { // this.structures = structures; // } // } // // Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/TemplateMetadata.java // @JsonPropertyOrder({"label", "value"}) // public class TemplateMetadata { // // @JsonProperty("label") // private String label; // // @JsonProperty("value") // private String value; // // /** // * @param label String // * @param value String // */ // public TemplateMetadata(final String label, final String value) { // this.label = label; // this.value = value; // } // // /** // * @return String // */ // @JsonIgnore // public String getLabel() { // return this.label; // } // // /** // * @return String // */ // @JsonIgnore // public String getValue() { // return this.value; // } // }
import static java.nio.file.Paths.get; import static org.junit.jupiter.api.Assertions.assertEquals; import de.ubleipzig.iiifproducer.template.TemplateManifest; import de.ubleipzig.iiifproducer.template.TemplateMetadata; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test;
/* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.producer; public class AnchorFileTest { private static Config config = new Config(); @BeforeAll static void setup() { final String path = get(".").toAbsolutePath().normalize().getParent().toString(); final String sourceFile = path + "/xml-doc/src/test/resources/mets/BntItin_021340072.xml"; config.setXmlFile(sourceFile); config.setOutputFile("/tmp/test.json"); config.setViewId("004285964"); config.setAnchorKey("Part of"); } @Test void testGetAnchorFileMetadata() { final MetsAccessor mets = new MetsImpl(config); final TemplateMetadata metadata = mets.getAnchorFileMetadata(); assertEquals("Part of", metadata.getLabel()); assertEquals( "Itinerarivm Sacrae Scriptvrae, Das ist: Ein Reisebuch vber die gantze heilige Schrifft; 1", metadata.getValue()); } @Test void testSetAnchorFileMetadata() { final MetsAccessor mets = new MetsImpl(config);
// Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/TemplateManifest.java // @JsonInclude(Include.NON_NULL) // @JsonPropertyOrder({"@context", "@id", "@type", "label", "license", "attribution", "logo", "related", "metadata", // "sequences", "structures"}) // public class TemplateManifest { // // @JsonProperty("@context") // private String context; // // @JsonProperty("@id") // private String id; // // @JsonProperty("@type") // private String type = SCEnum.Manifest.compactedIRI(); // // @JsonProperty("label") // private String label = "unnamed"; // // @JsonProperty("license") // private String license; // // @JsonProperty("attribution") // private String attribution; // // @JsonProperty("logo") // private String logo; // // @JsonProperty("related") // private List<String> related; // // @JsonProperty("metadata") // private List<TemplateMetadata> metadata; // // @JsonProperty("sequences") // private List<TemplateSequence> sequences; // // @JsonProperty("structures") // private List<TemplateStructure> structures; // // /** // * TemplateManifest. // */ // public TemplateManifest() { // } // // /** // * @param context String // */ // public void setContext(final String context) { // this.context = context; // } // // /** // * @param id String // */ // public void setId(final String id) { // this.id = id; // } // // /** // * @param type String // */ // public void setType(final String type) { // this.type = type; // } // // /** // * @param label String // */ // public void setLabel(final String label) { // this.label = label; // } // // /** // * @param license String // */ // public void setLicense(final String license) { // this.license = license; // } // // /** // * @param attribution String // */ // public void setAttribution(final String attribution) { // this.attribution = attribution; // } // // /** // * @param logo String // */ // public void setLogo(final String logo) { // this.logo = logo; // } // // /** // * @param related List // */ // public void setRelated(final List<String> related) { // this.related = related; // } // // /** // * @param sequences List // */ // public void setSequences(final List<TemplateSequence> sequences) { // this.sequences = sequences; // } // // /** // * @param metadata List // */ // public void setMetadata(final List<TemplateMetadata> metadata) { // this.metadata = metadata; // } // // /** // * @return List // */ // public List<TemplateStructure> getStructures() { // return this.structures; // } // // /** // * @param structures List // */ // public void setStructures(final List<TemplateStructure> structures) { // this.structures = structures; // } // } // // Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/TemplateMetadata.java // @JsonPropertyOrder({"label", "value"}) // public class TemplateMetadata { // // @JsonProperty("label") // private String label; // // @JsonProperty("value") // private String value; // // /** // * @param label String // * @param value String // */ // public TemplateMetadata(final String label, final String value) { // this.label = label; // this.value = value; // } // // /** // * @return String // */ // @JsonIgnore // public String getLabel() { // return this.label; // } // // /** // * @return String // */ // @JsonIgnore // public String getValue() { // return this.value; // } // } // Path: producer/src/test/java/de/ubleipzig/iiifproducer/producer/AnchorFileTest.java import static java.nio.file.Paths.get; import static org.junit.jupiter.api.Assertions.assertEquals; import de.ubleipzig.iiifproducer.template.TemplateManifest; import de.ubleipzig.iiifproducer.template.TemplateMetadata; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; /* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.producer; public class AnchorFileTest { private static Config config = new Config(); @BeforeAll static void setup() { final String path = get(".").toAbsolutePath().normalize().getParent().toString(); final String sourceFile = path + "/xml-doc/src/test/resources/mets/BntItin_021340072.xml"; config.setXmlFile(sourceFile); config.setOutputFile("/tmp/test.json"); config.setViewId("004285964"); config.setAnchorKey("Part of"); } @Test void testGetAnchorFileMetadata() { final MetsAccessor mets = new MetsImpl(config); final TemplateMetadata metadata = mets.getAnchorFileMetadata(); assertEquals("Part of", metadata.getLabel()); assertEquals( "Itinerarivm Sacrae Scriptvrae, Das ist: Ein Reisebuch vber die gantze heilige Schrifft; 1", metadata.getValue()); } @Test void testSetAnchorFileMetadata() { final MetsAccessor mets = new MetsImpl(config);
final TemplateManifest manifest = new TemplateManifest();
ubleipzig/iiif-producer
xml-doc/src/main/java/de/ubleipzig/iiifproducer/doc/ResourceLoader.java
// Path: xml-doc/src/main/java/de/ubleipzig/iiifproducer/doc/MetsManifestBuilder.java // static MetsData getMetsFromFile(final String url) { // try { // final XBProjector projector = new XBProjector(TO_STRING_RENDERS_XML); // return projector.io().file(url).read(MetsData.class); // } catch (IOException e) { // e.printStackTrace(); // throw new RuntimeException("Cannot Read XML: " + e.getMessage()); // } // }
import static de.ubleipzig.iiifproducer.doc.MetsManifestBuilder.getMetsFromFile; import static java.io.File.separator; import static org.apache.commons.io.FilenameUtils.getBaseName; import static org.slf4j.LoggerFactory.getLogger; import java.io.File; import org.slf4j.Logger;
/* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.doc; /** * ResourceLoader. * * @author christopher-johnson */ public final class ResourceLoader { private static Logger logger = getLogger(ResourceLoader.class); private ResourceLoader() { } /** * @param sourceFile String * @return MetsData */ public static MetsData getMets(final String sourceFile) { logger.debug("Loading MetsData from File {}", sourceFile);
// Path: xml-doc/src/main/java/de/ubleipzig/iiifproducer/doc/MetsManifestBuilder.java // static MetsData getMetsFromFile(final String url) { // try { // final XBProjector projector = new XBProjector(TO_STRING_RENDERS_XML); // return projector.io().file(url).read(MetsData.class); // } catch (IOException e) { // e.printStackTrace(); // throw new RuntimeException("Cannot Read XML: " + e.getMessage()); // } // } // Path: xml-doc/src/main/java/de/ubleipzig/iiifproducer/doc/ResourceLoader.java import static de.ubleipzig.iiifproducer.doc.MetsManifestBuilder.getMetsFromFile; import static java.io.File.separator; import static org.apache.commons.io.FilenameUtils.getBaseName; import static org.slf4j.LoggerFactory.getLogger; import java.io.File; import org.slf4j.Logger; /* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.doc; /** * ResourceLoader. * * @author christopher-johnson */ public final class ResourceLoader { private static Logger logger = getLogger(ResourceLoader.class); private ResourceLoader() { } /** * @param sourceFile String * @return MetsData */ public static MetsData getMets(final String sourceFile) { logger.debug("Loading MetsData from File {}", sourceFile);
return getMetsFromFile(sourceFile);
ubleipzig/iiif-producer
templates/src/test/java/de/ubleipzig/iiifproducer/template/TemplateStructureTest.java
// Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/ManifestSerializer.java // public static Optional<String> serialize(final Object manifest) { // try { // return of(MAPPER.writer(PrettyPrinter.instance).writeValueAsString(manifest)); // } catch (final JsonProcessingException ex) { // return empty(); // } // }
import org.junit.jupiter.api.Test; import org.mockito.Mock; import static de.ubleipzig.iiifproducer.template.ManifestSerializer.serialize; import static java.lang.System.out; import static java.util.Arrays.asList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import de.ubleipzig.iiif.vocabulary.SCEnum; import java.util.List; import java.util.Optional; import org.junit.jupiter.api.BeforeAll;
/* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.template; /** * TemplateStructureTest. * * @author christopher-johnson */ class TemplateStructureTest { @Mock private static TemplateStructure mockStructure = new TemplateStructure(); @BeforeAll static void setup() { final List<String> ranges = asList( "https://iiif.ub.uni-leipzig.de/0000004084/range/0-0", "https://iiif.ub" + ".uni-leipzig.de/0000004084/range/0-1", "https://iiif.ub.uni-leipzig.de/0000004084/range/0-2"); final List<String> canvases = asList( "https://iiif.ub.uni-leipzig.de/0000004084/canvas/1", "https://iiif.ub" + ".uni-leipzig.de/0000004084/canvas/2"); mockStructure.setStructureLabel("TOC"); mockStructure.setStructureId("http://test.org/12345/range/0"); mockStructure.setStructureType(SCEnum.Range.compactedIRI()); mockStructure.setRanges(ranges); mockStructure.setCanvases(canvases); } @Test void testSerialization() {
// Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/ManifestSerializer.java // public static Optional<String> serialize(final Object manifest) { // try { // return of(MAPPER.writer(PrettyPrinter.instance).writeValueAsString(manifest)); // } catch (final JsonProcessingException ex) { // return empty(); // } // } // Path: templates/src/test/java/de/ubleipzig/iiifproducer/template/TemplateStructureTest.java import org.junit.jupiter.api.Test; import org.mockito.Mock; import static de.ubleipzig.iiifproducer.template.ManifestSerializer.serialize; import static java.lang.System.out; import static java.util.Arrays.asList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import de.ubleipzig.iiif.vocabulary.SCEnum; import java.util.List; import java.util.Optional; import org.junit.jupiter.api.BeforeAll; /* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.template; /** * TemplateStructureTest. * * @author christopher-johnson */ class TemplateStructureTest { @Mock private static TemplateStructure mockStructure = new TemplateStructure(); @BeforeAll static void setup() { final List<String> ranges = asList( "https://iiif.ub.uni-leipzig.de/0000004084/range/0-0", "https://iiif.ub" + ".uni-leipzig.de/0000004084/range/0-1", "https://iiif.ub.uni-leipzig.de/0000004084/range/0-2"); final List<String> canvases = asList( "https://iiif.ub.uni-leipzig.de/0000004084/canvas/1", "https://iiif.ub" + ".uni-leipzig.de/0000004084/canvas/2"); mockStructure.setStructureLabel("TOC"); mockStructure.setStructureId("http://test.org/12345/range/0"); mockStructure.setStructureType(SCEnum.Range.compactedIRI()); mockStructure.setRanges(ranges); mockStructure.setCanvases(canvases); } @Test void testSerialization() {
final Optional<String> json = serialize(mockStructure);
ubleipzig/iiif-producer
templates/src/test/java/de/ubleipzig/iiifproducer/template/TemplateTopStructureTest.java
// Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/ManifestSerializer.java // public static Optional<String> serialize(final Object manifest) { // try { // return of(MAPPER.writer(PrettyPrinter.instance).writeValueAsString(manifest)); // } catch (final JsonProcessingException ex) { // return empty(); // } // }
import org.junit.jupiter.api.Test; import org.mockito.Mock; import static de.ubleipzig.iiifproducer.template.ManifestSerializer.serialize; import static java.lang.System.out; import static java.util.Arrays.asList; import static org.junit.jupiter.api.Assertions.assertTrue; import de.ubleipzig.iiif.vocabulary.SCEnum; import java.util.ArrayList; import java.util.List; import java.util.Optional; import org.junit.jupiter.api.BeforeAll;
/* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.template; /** * TemplateTopStructureTest. * * @author christopher-johnson */ class TemplateTopStructureTest { @Mock private static TemplateTopStructure mockTopStructure = new TemplateTopStructure(); @BeforeAll static void setup() { final List<String> ranges = asList( "https://iiif.ub.uni-leipzig.de/0000004084/range/0-0", "https://iiif.ub" + ".uni-leipzig.de/0000004084/range/0-1", "https://iiif.ub.uni-leipzig.de/0000004084/range/0-2"); mockTopStructure.setStructureLabel("TOC"); mockTopStructure.setStructureId("http://test.org/12345/range/0"); mockTopStructure.setRanges(ranges); } @Test void testSerialization() {
// Path: templates/src/main/java/de/ubleipzig/iiifproducer/template/ManifestSerializer.java // public static Optional<String> serialize(final Object manifest) { // try { // return of(MAPPER.writer(PrettyPrinter.instance).writeValueAsString(manifest)); // } catch (final JsonProcessingException ex) { // return empty(); // } // } // Path: templates/src/test/java/de/ubleipzig/iiifproducer/template/TemplateTopStructureTest.java import org.junit.jupiter.api.Test; import org.mockito.Mock; import static de.ubleipzig.iiifproducer.template.ManifestSerializer.serialize; import static java.lang.System.out; import static java.util.Arrays.asList; import static org.junit.jupiter.api.Assertions.assertTrue; import de.ubleipzig.iiif.vocabulary.SCEnum; import java.util.ArrayList; import java.util.List; import java.util.Optional; import org.junit.jupiter.api.BeforeAll; /* * IIIFProducer * Copyright (C) 2017 Leipzig University Library <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package de.ubleipzig.iiifproducer.template; /** * TemplateTopStructureTest. * * @author christopher-johnson */ class TemplateTopStructureTest { @Mock private static TemplateTopStructure mockTopStructure = new TemplateTopStructure(); @BeforeAll static void setup() { final List<String> ranges = asList( "https://iiif.ub.uni-leipzig.de/0000004084/range/0-0", "https://iiif.ub" + ".uni-leipzig.de/0000004084/range/0-1", "https://iiif.ub.uni-leipzig.de/0000004084/range/0-2"); mockTopStructure.setStructureLabel("TOC"); mockTopStructure.setStructureId("http://test.org/12345/range/0"); mockTopStructure.setRanges(ranges); } @Test void testSerialization() {
final Optional<String> json = serialize(mockTopStructure);
filosganga/geogson
core/src/main/java/com/github/filosganga/geogson/model/LinearRing.java
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/LinearPositions.java // public class LinearPositions extends AbstractPositions<SinglePosition> { // // private static final long serialVersionUID = 1L; // // private final Boolean isClosed; // // private LinearPositions(List<SinglePosition> children, boolean isClosed) { // super(children); // this.isClosed = isClosed; // } // // public static LinearPositions.Builder builder() { // return new LinearPositions.Builder(); // } // // public static LinearPositions.Builder builder(LinearPositions positions) { // return builder().addSinglePositions(positions.children); // } // // /** // * Merge this LinearPositions with another one. If the given {@link Positions} is: // * - SinglePosition, it will return a new LinearPositions with the given SinglePosition appended. // * - LinearPositions, it will return a new AreaPosition composed by this and the given LinearPositions. // * - Any other, it delegates to the other the merge logic. // * // * @param other Positions instance to merge with. // * // * @return Positions results of merging. // */ // @Override // public Positions merge(Positions other) { // if (other instanceof SinglePosition) { // SinglePosition that = (SinglePosition) other; // return builder().addSinglePosition(that).build(); // } else if (other instanceof LinearPositions) { // LinearPositions that = (LinearPositions) other; // return AreaPositions.builder().addLinearPosition(this).addLinearPosition(that).build(); // } else { // return other.merge(this); // } // } // // /** // * Returns if this LinearPosition: // * - Is composed by at least 4 points // * - The first and the last are the same. // * // * @return true if it is closed, false otherwise. // */ // public boolean isClosed() { // return isClosed; // } // // public static class Builder implements PositionsBuilder { // // private LinkedList<SinglePosition> singlePositions = new LinkedList<>(); // // private SinglePosition first = null; // private SinglePosition last = null; // private int size = 0; // // public Builder addSinglePosition(SinglePosition sp) { // singlePositions.add(sp); // if(first == null) { // first = sp; // } // last = sp; // size++; // // return this; // } // // public Builder addSinglePositions(Iterable<SinglePosition> sps) { // sps.forEach(this::addSinglePosition); // return this; // } // // @Override // public PositionsBuilder addChild(Positions p) { // if(p instanceof SinglePosition) { // return addSinglePosition((SinglePosition) p); // } else if (p instanceof LinearPositions) { // return AreaPositions.builder().addChild(this.build()).addChild(p); // } else { // throw new IllegalArgumentException("The position " + p + "cannot be a child of LinearPositions"); // } // } // // @Override // public LinearPositions build() { // Boolean isClosed = size >= 4 && first.equals(last); // return new LinearPositions(singlePositions, isClosed); // } // // } // // // } // // Path: core/src/main/java/com/github/filosganga/geogson/util/Preconditions.java // public static <T> T checkArgument(T argument, Function<T, Boolean> predicate, Object errorMessage) { // if (!predicate.apply(argument)) { // throw new IllegalArgumentException(String.valueOf(errorMessage)); // } else { // return argument; // } // }
import com.github.filosganga.geogson.model.positions.LinearPositions; import java.util.Arrays; import java.util.stream.Stream; import static com.github.filosganga.geogson.util.Preconditions.checkArgument;
package com.github.filosganga.geogson.model; /** * A closed {@link LineString}. * * JeoGson reference: @see http://geojson.org/geojson-spec.html#linestring. * * eg: {@code * LinearRing lr = LinearRing.of( * Point.of(1,1), * Point.of(1,2), * Point.of(2,2), * Point.of(2,1), * Point.of(1,1) * ) * } */ public class LinearRing extends LineString { private static final long serialVersionUID = 1L;
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/LinearPositions.java // public class LinearPositions extends AbstractPositions<SinglePosition> { // // private static final long serialVersionUID = 1L; // // private final Boolean isClosed; // // private LinearPositions(List<SinglePosition> children, boolean isClosed) { // super(children); // this.isClosed = isClosed; // } // // public static LinearPositions.Builder builder() { // return new LinearPositions.Builder(); // } // // public static LinearPositions.Builder builder(LinearPositions positions) { // return builder().addSinglePositions(positions.children); // } // // /** // * Merge this LinearPositions with another one. If the given {@link Positions} is: // * - SinglePosition, it will return a new LinearPositions with the given SinglePosition appended. // * - LinearPositions, it will return a new AreaPosition composed by this and the given LinearPositions. // * - Any other, it delegates to the other the merge logic. // * // * @param other Positions instance to merge with. // * // * @return Positions results of merging. // */ // @Override // public Positions merge(Positions other) { // if (other instanceof SinglePosition) { // SinglePosition that = (SinglePosition) other; // return builder().addSinglePosition(that).build(); // } else if (other instanceof LinearPositions) { // LinearPositions that = (LinearPositions) other; // return AreaPositions.builder().addLinearPosition(this).addLinearPosition(that).build(); // } else { // return other.merge(this); // } // } // // /** // * Returns if this LinearPosition: // * - Is composed by at least 4 points // * - The first and the last are the same. // * // * @return true if it is closed, false otherwise. // */ // public boolean isClosed() { // return isClosed; // } // // public static class Builder implements PositionsBuilder { // // private LinkedList<SinglePosition> singlePositions = new LinkedList<>(); // // private SinglePosition first = null; // private SinglePosition last = null; // private int size = 0; // // public Builder addSinglePosition(SinglePosition sp) { // singlePositions.add(sp); // if(first == null) { // first = sp; // } // last = sp; // size++; // // return this; // } // // public Builder addSinglePositions(Iterable<SinglePosition> sps) { // sps.forEach(this::addSinglePosition); // return this; // } // // @Override // public PositionsBuilder addChild(Positions p) { // if(p instanceof SinglePosition) { // return addSinglePosition((SinglePosition) p); // } else if (p instanceof LinearPositions) { // return AreaPositions.builder().addChild(this.build()).addChild(p); // } else { // throw new IllegalArgumentException("The position " + p + "cannot be a child of LinearPositions"); // } // } // // @Override // public LinearPositions build() { // Boolean isClosed = size >= 4 && first.equals(last); // return new LinearPositions(singlePositions, isClosed); // } // // } // // // } // // Path: core/src/main/java/com/github/filosganga/geogson/util/Preconditions.java // public static <T> T checkArgument(T argument, Function<T, Boolean> predicate, Object errorMessage) { // if (!predicate.apply(argument)) { // throw new IllegalArgumentException(String.valueOf(errorMessage)); // } else { // return argument; // } // } // Path: core/src/main/java/com/github/filosganga/geogson/model/LinearRing.java import com.github.filosganga.geogson.model.positions.LinearPositions; import java.util.Arrays; import java.util.stream.Stream; import static com.github.filosganga.geogson.util.Preconditions.checkArgument; package com.github.filosganga.geogson.model; /** * A closed {@link LineString}. * * JeoGson reference: @see http://geojson.org/geojson-spec.html#linestring. * * eg: {@code * LinearRing lr = LinearRing.of( * Point.of(1,1), * Point.of(1,2), * Point.of(2,2), * Point.of(2,1), * Point.of(1,1) * ) * } */ public class LinearRing extends LineString { private static final long serialVersionUID = 1L;
public LinearRing(LinearPositions positions) {
filosganga/geogson
core/src/main/java/com/github/filosganga/geogson/model/LinearRing.java
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/LinearPositions.java // public class LinearPositions extends AbstractPositions<SinglePosition> { // // private static final long serialVersionUID = 1L; // // private final Boolean isClosed; // // private LinearPositions(List<SinglePosition> children, boolean isClosed) { // super(children); // this.isClosed = isClosed; // } // // public static LinearPositions.Builder builder() { // return new LinearPositions.Builder(); // } // // public static LinearPositions.Builder builder(LinearPositions positions) { // return builder().addSinglePositions(positions.children); // } // // /** // * Merge this LinearPositions with another one. If the given {@link Positions} is: // * - SinglePosition, it will return a new LinearPositions with the given SinglePosition appended. // * - LinearPositions, it will return a new AreaPosition composed by this and the given LinearPositions. // * - Any other, it delegates to the other the merge logic. // * // * @param other Positions instance to merge with. // * // * @return Positions results of merging. // */ // @Override // public Positions merge(Positions other) { // if (other instanceof SinglePosition) { // SinglePosition that = (SinglePosition) other; // return builder().addSinglePosition(that).build(); // } else if (other instanceof LinearPositions) { // LinearPositions that = (LinearPositions) other; // return AreaPositions.builder().addLinearPosition(this).addLinearPosition(that).build(); // } else { // return other.merge(this); // } // } // // /** // * Returns if this LinearPosition: // * - Is composed by at least 4 points // * - The first and the last are the same. // * // * @return true if it is closed, false otherwise. // */ // public boolean isClosed() { // return isClosed; // } // // public static class Builder implements PositionsBuilder { // // private LinkedList<SinglePosition> singlePositions = new LinkedList<>(); // // private SinglePosition first = null; // private SinglePosition last = null; // private int size = 0; // // public Builder addSinglePosition(SinglePosition sp) { // singlePositions.add(sp); // if(first == null) { // first = sp; // } // last = sp; // size++; // // return this; // } // // public Builder addSinglePositions(Iterable<SinglePosition> sps) { // sps.forEach(this::addSinglePosition); // return this; // } // // @Override // public PositionsBuilder addChild(Positions p) { // if(p instanceof SinglePosition) { // return addSinglePosition((SinglePosition) p); // } else if (p instanceof LinearPositions) { // return AreaPositions.builder().addChild(this.build()).addChild(p); // } else { // throw new IllegalArgumentException("The position " + p + "cannot be a child of LinearPositions"); // } // } // // @Override // public LinearPositions build() { // Boolean isClosed = size >= 4 && first.equals(last); // return new LinearPositions(singlePositions, isClosed); // } // // } // // // } // // Path: core/src/main/java/com/github/filosganga/geogson/util/Preconditions.java // public static <T> T checkArgument(T argument, Function<T, Boolean> predicate, Object errorMessage) { // if (!predicate.apply(argument)) { // throw new IllegalArgumentException(String.valueOf(errorMessage)); // } else { // return argument; // } // }
import com.github.filosganga.geogson.model.positions.LinearPositions; import java.util.Arrays; import java.util.stream.Stream; import static com.github.filosganga.geogson.util.Preconditions.checkArgument;
package com.github.filosganga.geogson.model; /** * A closed {@link LineString}. * * JeoGson reference: @see http://geojson.org/geojson-spec.html#linestring. * * eg: {@code * LinearRing lr = LinearRing.of( * Point.of(1,1), * Point.of(1,2), * Point.of(2,2), * Point.of(2,1), * Point.of(1,1) * ) * } */ public class LinearRing extends LineString { private static final long serialVersionUID = 1L; public LinearRing(LinearPositions positions) {
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/LinearPositions.java // public class LinearPositions extends AbstractPositions<SinglePosition> { // // private static final long serialVersionUID = 1L; // // private final Boolean isClosed; // // private LinearPositions(List<SinglePosition> children, boolean isClosed) { // super(children); // this.isClosed = isClosed; // } // // public static LinearPositions.Builder builder() { // return new LinearPositions.Builder(); // } // // public static LinearPositions.Builder builder(LinearPositions positions) { // return builder().addSinglePositions(positions.children); // } // // /** // * Merge this LinearPositions with another one. If the given {@link Positions} is: // * - SinglePosition, it will return a new LinearPositions with the given SinglePosition appended. // * - LinearPositions, it will return a new AreaPosition composed by this and the given LinearPositions. // * - Any other, it delegates to the other the merge logic. // * // * @param other Positions instance to merge with. // * // * @return Positions results of merging. // */ // @Override // public Positions merge(Positions other) { // if (other instanceof SinglePosition) { // SinglePosition that = (SinglePosition) other; // return builder().addSinglePosition(that).build(); // } else if (other instanceof LinearPositions) { // LinearPositions that = (LinearPositions) other; // return AreaPositions.builder().addLinearPosition(this).addLinearPosition(that).build(); // } else { // return other.merge(this); // } // } // // /** // * Returns if this LinearPosition: // * - Is composed by at least 4 points // * - The first and the last are the same. // * // * @return true if it is closed, false otherwise. // */ // public boolean isClosed() { // return isClosed; // } // // public static class Builder implements PositionsBuilder { // // private LinkedList<SinglePosition> singlePositions = new LinkedList<>(); // // private SinglePosition first = null; // private SinglePosition last = null; // private int size = 0; // // public Builder addSinglePosition(SinglePosition sp) { // singlePositions.add(sp); // if(first == null) { // first = sp; // } // last = sp; // size++; // // return this; // } // // public Builder addSinglePositions(Iterable<SinglePosition> sps) { // sps.forEach(this::addSinglePosition); // return this; // } // // @Override // public PositionsBuilder addChild(Positions p) { // if(p instanceof SinglePosition) { // return addSinglePosition((SinglePosition) p); // } else if (p instanceof LinearPositions) { // return AreaPositions.builder().addChild(this.build()).addChild(p); // } else { // throw new IllegalArgumentException("The position " + p + "cannot be a child of LinearPositions"); // } // } // // @Override // public LinearPositions build() { // Boolean isClosed = size >= 4 && first.equals(last); // return new LinearPositions(singlePositions, isClosed); // } // // } // // // } // // Path: core/src/main/java/com/github/filosganga/geogson/util/Preconditions.java // public static <T> T checkArgument(T argument, Function<T, Boolean> predicate, Object errorMessage) { // if (!predicate.apply(argument)) { // throw new IllegalArgumentException(String.valueOf(errorMessage)); // } else { // return argument; // } // } // Path: core/src/main/java/com/github/filosganga/geogson/model/LinearRing.java import com.github.filosganga.geogson.model.positions.LinearPositions; import java.util.Arrays; import java.util.stream.Stream; import static com.github.filosganga.geogson.util.Preconditions.checkArgument; package com.github.filosganga.geogson.model; /** * A closed {@link LineString}. * * JeoGson reference: @see http://geojson.org/geojson-spec.html#linestring. * * eg: {@code * LinearRing lr = LinearRing.of( * Point.of(1,1), * Point.of(1,2), * Point.of(2,2), * Point.of(2,1), * Point.of(1,1) * ) * } */ public class LinearRing extends LineString { private static final long serialVersionUID = 1L; public LinearRing(LinearPositions positions) {
super(checkArgument(
filosganga/geogson
core/src/main/java/com/github/filosganga/geogson/model/AbstractGeometry.java
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/Positions.java // public interface Positions extends Serializable { // // /** // * Merge this Position with another one returning a new Position resulting of this merge. // * // * @param other Positions instance. // * @return new Positions instance. // */ // Positions merge(Positions other); // // /** // * Return this position children Positions. // * @return Iterable of Positions. // */ // List<? extends Positions> children(); // // /** // * The size of this positions. The semantic changes between different implementation of Positions. // * // * @return int. // */ // int size(); // // } // // Path: core/src/main/java/com/github/filosganga/geogson/util/Preconditions.java // public static <T> T checkArgument(T argument, Function<T, Boolean> predicate, Object errorMessage) { // if (!predicate.apply(argument)) { // throw new IllegalArgumentException(String.valueOf(errorMessage)); // } else { // return argument; // } // }
import com.github.filosganga.geogson.model.positions.Positions; import java.io.Serializable; import java.util.Objects; import static com.github.filosganga.geogson.util.Preconditions.checkArgument;
package com.github.filosganga.geogson.model; /** * Abstract implementation of {@link Geometry} providing generic methods. */ public abstract class AbstractGeometry<P extends Positions> implements Geometry<P>, Serializable { private static final long serialVersionUID = 1L; private final P positions; private transient Integer cachedHashCode = null; AbstractGeometry(P positions) {
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/Positions.java // public interface Positions extends Serializable { // // /** // * Merge this Position with another one returning a new Position resulting of this merge. // * // * @param other Positions instance. // * @return new Positions instance. // */ // Positions merge(Positions other); // // /** // * Return this position children Positions. // * @return Iterable of Positions. // */ // List<? extends Positions> children(); // // /** // * The size of this positions. The semantic changes between different implementation of Positions. // * // * @return int. // */ // int size(); // // } // // Path: core/src/main/java/com/github/filosganga/geogson/util/Preconditions.java // public static <T> T checkArgument(T argument, Function<T, Boolean> predicate, Object errorMessage) { // if (!predicate.apply(argument)) { // throw new IllegalArgumentException(String.valueOf(errorMessage)); // } else { // return argument; // } // } // Path: core/src/main/java/com/github/filosganga/geogson/model/AbstractGeometry.java import com.github.filosganga.geogson.model.positions.Positions; import java.io.Serializable; import java.util.Objects; import static com.github.filosganga.geogson.util.Preconditions.checkArgument; package com.github.filosganga.geogson.model; /** * Abstract implementation of {@link Geometry} providing generic methods. */ public abstract class AbstractGeometry<P extends Positions> implements Geometry<P>, Serializable { private static final long serialVersionUID = 1L; private final P positions; private transient Integer cachedHashCode = null; AbstractGeometry(P positions) {
this.positions = checkArgument(positions, Objects::nonNull, "Postitions is mandatory");
filosganga/geogson
core/src/main/java/com/github/filosganga/geogson/model/Polygon.java
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/AreaPositions.java // public class AreaPositions extends AbstractPositions<LinearPositions> { // // private static final long serialVersionUID = 1L; // // private final Boolean allChildrenAreClosed; // // private AreaPositions(List<LinearPositions> children, Boolean allChildrenAreClosed) { // super(children); // this.allChildrenAreClosed = allChildrenAreClosed; // } // // public static AreaPositions.Builder builder() { // return new AreaPositions.Builder(); // } // // public static AreaPositions.Builder builder(AreaPositions positions) { // return builder().addLinearPositions(positions.children); // } // // public Boolean areAllChildrenClosed() { // return allChildrenAreClosed; // } // // /** // * Merge this Positions with another one. If the given {@link Positions} is: // * - SinglePosition, it will raise an IllegalArgumentException. // * - LinearPositions, it will return a new AreaPosition by appending the given LinearPositions to this. // * - AreaPositions, it will return a new MultiDimensionalPositions composed by this and the given AreaPositions, // * in order. // * - Any other, it delegates to the other the merge logic. // * // * @param other Positions instance to merge with. // * // * @return Positions results of merging. // */ // @Override // public Positions merge(Positions other) { // // if (other instanceof SinglePosition) { // // throw new IllegalArgumentException("Cannot merge single position and area children"); // } else if (other instanceof LinearPositions) { // // LinearPositions that = (LinearPositions) other; // return builder().addLinearPosition(that).build(); // } else if (other instanceof AreaPositions) { // // AreaPositions that = (AreaPositions) other; // return MultiDimensionalPositions.builder().addAreaPosition(this).addAreaPosition(that).build(); // } else { // // return other.merge(this); // } // } // // public static class Builder implements PositionsBuilder { // // private LinkedList<LinearPositions> linearPositions = new LinkedList<>(); // private boolean allChildrenAreClosed = true; // // public AreaPositions.Builder addLinearPosition(LinearPositions lp) { // linearPositions.add(lp); // allChildrenAreClosed = allChildrenAreClosed && lp.isClosed(); // return this; // } // // public AreaPositions.Builder addLinearPositions(Iterable<LinearPositions> lps) { // lps.forEach(this::addLinearPosition); // return this; // } // // @Override // public PositionsBuilder addChild(Positions p) { // if(p instanceof LinearPositions) { // return addLinearPosition((LinearPositions)p); // } else if (p instanceof SinglePosition) { // return addLinearPosition(LinearPositions.builder().addSinglePosition((SinglePosition) p).build()); // } else if (p instanceof AreaPositions) { // return MultiDimensionalPositions.builder().addAreaPosition(this.build()).addChild(p); // } else { // throw new IllegalArgumentException("The position " + p + "cannot be a child of AreaPosition"); // } // } // // public AreaPositions build() { // return new AreaPositions(linearPositions, allChildrenAreClosed); // } // // } // // } // // Path: core/src/main/java/com/github/filosganga/geogson/util/Preconditions.java // public static <T> T checkArgument(T argument, Function<T, Boolean> predicate, Object errorMessage) { // if (!predicate.apply(argument)) { // throw new IllegalArgumentException(String.valueOf(errorMessage)); // } else { // return argument; // } // }
import com.github.filosganga.geogson.model.positions.AreaPositions; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; import static com.github.filosganga.geogson.util.Preconditions.checkArgument;
/* * Copyright 2013 Filippo De Luca - [email protected] * * 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.github.filosganga.geogson.model; /** * A Geometry composed by a sequence of {@link LinearRing}s (or closed {@link LineString}s). The first one is the * external perimeter, the followers are the holes. * * GeoJson reference: @see http://geojson.org/geojson-spec.html#polygon. */ public class Polygon extends MultiLineString { private static final long serialVersionUID = 1L;
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/AreaPositions.java // public class AreaPositions extends AbstractPositions<LinearPositions> { // // private static final long serialVersionUID = 1L; // // private final Boolean allChildrenAreClosed; // // private AreaPositions(List<LinearPositions> children, Boolean allChildrenAreClosed) { // super(children); // this.allChildrenAreClosed = allChildrenAreClosed; // } // // public static AreaPositions.Builder builder() { // return new AreaPositions.Builder(); // } // // public static AreaPositions.Builder builder(AreaPositions positions) { // return builder().addLinearPositions(positions.children); // } // // public Boolean areAllChildrenClosed() { // return allChildrenAreClosed; // } // // /** // * Merge this Positions with another one. If the given {@link Positions} is: // * - SinglePosition, it will raise an IllegalArgumentException. // * - LinearPositions, it will return a new AreaPosition by appending the given LinearPositions to this. // * - AreaPositions, it will return a new MultiDimensionalPositions composed by this and the given AreaPositions, // * in order. // * - Any other, it delegates to the other the merge logic. // * // * @param other Positions instance to merge with. // * // * @return Positions results of merging. // */ // @Override // public Positions merge(Positions other) { // // if (other instanceof SinglePosition) { // // throw new IllegalArgumentException("Cannot merge single position and area children"); // } else if (other instanceof LinearPositions) { // // LinearPositions that = (LinearPositions) other; // return builder().addLinearPosition(that).build(); // } else if (other instanceof AreaPositions) { // // AreaPositions that = (AreaPositions) other; // return MultiDimensionalPositions.builder().addAreaPosition(this).addAreaPosition(that).build(); // } else { // // return other.merge(this); // } // } // // public static class Builder implements PositionsBuilder { // // private LinkedList<LinearPositions> linearPositions = new LinkedList<>(); // private boolean allChildrenAreClosed = true; // // public AreaPositions.Builder addLinearPosition(LinearPositions lp) { // linearPositions.add(lp); // allChildrenAreClosed = allChildrenAreClosed && lp.isClosed(); // return this; // } // // public AreaPositions.Builder addLinearPositions(Iterable<LinearPositions> lps) { // lps.forEach(this::addLinearPosition); // return this; // } // // @Override // public PositionsBuilder addChild(Positions p) { // if(p instanceof LinearPositions) { // return addLinearPosition((LinearPositions)p); // } else if (p instanceof SinglePosition) { // return addLinearPosition(LinearPositions.builder().addSinglePosition((SinglePosition) p).build()); // } else if (p instanceof AreaPositions) { // return MultiDimensionalPositions.builder().addAreaPosition(this.build()).addChild(p); // } else { // throw new IllegalArgumentException("The position " + p + "cannot be a child of AreaPosition"); // } // } // // public AreaPositions build() { // return new AreaPositions(linearPositions, allChildrenAreClosed); // } // // } // // } // // Path: core/src/main/java/com/github/filosganga/geogson/util/Preconditions.java // public static <T> T checkArgument(T argument, Function<T, Boolean> predicate, Object errorMessage) { // if (!predicate.apply(argument)) { // throw new IllegalArgumentException(String.valueOf(errorMessage)); // } else { // return argument; // } // } // Path: core/src/main/java/com/github/filosganga/geogson/model/Polygon.java import com.github.filosganga.geogson.model.positions.AreaPositions; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; import static com.github.filosganga.geogson.util.Preconditions.checkArgument; /* * Copyright 2013 Filippo De Luca - [email protected] * * 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.github.filosganga.geogson.model; /** * A Geometry composed by a sequence of {@link LinearRing}s (or closed {@link LineString}s). The first one is the * external perimeter, the followers are the holes. * * GeoJson reference: @see http://geojson.org/geojson-spec.html#polygon. */ public class Polygon extends MultiLineString { private static final long serialVersionUID = 1L;
public Polygon(AreaPositions positions) {
filosganga/geogson
core/src/main/java/com/github/filosganga/geogson/model/Polygon.java
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/AreaPositions.java // public class AreaPositions extends AbstractPositions<LinearPositions> { // // private static final long serialVersionUID = 1L; // // private final Boolean allChildrenAreClosed; // // private AreaPositions(List<LinearPositions> children, Boolean allChildrenAreClosed) { // super(children); // this.allChildrenAreClosed = allChildrenAreClosed; // } // // public static AreaPositions.Builder builder() { // return new AreaPositions.Builder(); // } // // public static AreaPositions.Builder builder(AreaPositions positions) { // return builder().addLinearPositions(positions.children); // } // // public Boolean areAllChildrenClosed() { // return allChildrenAreClosed; // } // // /** // * Merge this Positions with another one. If the given {@link Positions} is: // * - SinglePosition, it will raise an IllegalArgumentException. // * - LinearPositions, it will return a new AreaPosition by appending the given LinearPositions to this. // * - AreaPositions, it will return a new MultiDimensionalPositions composed by this and the given AreaPositions, // * in order. // * - Any other, it delegates to the other the merge logic. // * // * @param other Positions instance to merge with. // * // * @return Positions results of merging. // */ // @Override // public Positions merge(Positions other) { // // if (other instanceof SinglePosition) { // // throw new IllegalArgumentException("Cannot merge single position and area children"); // } else if (other instanceof LinearPositions) { // // LinearPositions that = (LinearPositions) other; // return builder().addLinearPosition(that).build(); // } else if (other instanceof AreaPositions) { // // AreaPositions that = (AreaPositions) other; // return MultiDimensionalPositions.builder().addAreaPosition(this).addAreaPosition(that).build(); // } else { // // return other.merge(this); // } // } // // public static class Builder implements PositionsBuilder { // // private LinkedList<LinearPositions> linearPositions = new LinkedList<>(); // private boolean allChildrenAreClosed = true; // // public AreaPositions.Builder addLinearPosition(LinearPositions lp) { // linearPositions.add(lp); // allChildrenAreClosed = allChildrenAreClosed && lp.isClosed(); // return this; // } // // public AreaPositions.Builder addLinearPositions(Iterable<LinearPositions> lps) { // lps.forEach(this::addLinearPosition); // return this; // } // // @Override // public PositionsBuilder addChild(Positions p) { // if(p instanceof LinearPositions) { // return addLinearPosition((LinearPositions)p); // } else if (p instanceof SinglePosition) { // return addLinearPosition(LinearPositions.builder().addSinglePosition((SinglePosition) p).build()); // } else if (p instanceof AreaPositions) { // return MultiDimensionalPositions.builder().addAreaPosition(this.build()).addChild(p); // } else { // throw new IllegalArgumentException("The position " + p + "cannot be a child of AreaPosition"); // } // } // // public AreaPositions build() { // return new AreaPositions(linearPositions, allChildrenAreClosed); // } // // } // // } // // Path: core/src/main/java/com/github/filosganga/geogson/util/Preconditions.java // public static <T> T checkArgument(T argument, Function<T, Boolean> predicate, Object errorMessage) { // if (!predicate.apply(argument)) { // throw new IllegalArgumentException(String.valueOf(errorMessage)); // } else { // return argument; // } // }
import com.github.filosganga.geogson.model.positions.AreaPositions; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; import static com.github.filosganga.geogson.util.Preconditions.checkArgument;
/* * Copyright 2013 Filippo De Luca - [email protected] * * 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.github.filosganga.geogson.model; /** * A Geometry composed by a sequence of {@link LinearRing}s (or closed {@link LineString}s). The first one is the * external perimeter, the followers are the holes. * * GeoJson reference: @see http://geojson.org/geojson-spec.html#polygon. */ public class Polygon extends MultiLineString { private static final long serialVersionUID = 1L; public Polygon(AreaPositions positions) {
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/AreaPositions.java // public class AreaPositions extends AbstractPositions<LinearPositions> { // // private static final long serialVersionUID = 1L; // // private final Boolean allChildrenAreClosed; // // private AreaPositions(List<LinearPositions> children, Boolean allChildrenAreClosed) { // super(children); // this.allChildrenAreClosed = allChildrenAreClosed; // } // // public static AreaPositions.Builder builder() { // return new AreaPositions.Builder(); // } // // public static AreaPositions.Builder builder(AreaPositions positions) { // return builder().addLinearPositions(positions.children); // } // // public Boolean areAllChildrenClosed() { // return allChildrenAreClosed; // } // // /** // * Merge this Positions with another one. If the given {@link Positions} is: // * - SinglePosition, it will raise an IllegalArgumentException. // * - LinearPositions, it will return a new AreaPosition by appending the given LinearPositions to this. // * - AreaPositions, it will return a new MultiDimensionalPositions composed by this and the given AreaPositions, // * in order. // * - Any other, it delegates to the other the merge logic. // * // * @param other Positions instance to merge with. // * // * @return Positions results of merging. // */ // @Override // public Positions merge(Positions other) { // // if (other instanceof SinglePosition) { // // throw new IllegalArgumentException("Cannot merge single position and area children"); // } else if (other instanceof LinearPositions) { // // LinearPositions that = (LinearPositions) other; // return builder().addLinearPosition(that).build(); // } else if (other instanceof AreaPositions) { // // AreaPositions that = (AreaPositions) other; // return MultiDimensionalPositions.builder().addAreaPosition(this).addAreaPosition(that).build(); // } else { // // return other.merge(this); // } // } // // public static class Builder implements PositionsBuilder { // // private LinkedList<LinearPositions> linearPositions = new LinkedList<>(); // private boolean allChildrenAreClosed = true; // // public AreaPositions.Builder addLinearPosition(LinearPositions lp) { // linearPositions.add(lp); // allChildrenAreClosed = allChildrenAreClosed && lp.isClosed(); // return this; // } // // public AreaPositions.Builder addLinearPositions(Iterable<LinearPositions> lps) { // lps.forEach(this::addLinearPosition); // return this; // } // // @Override // public PositionsBuilder addChild(Positions p) { // if(p instanceof LinearPositions) { // return addLinearPosition((LinearPositions)p); // } else if (p instanceof SinglePosition) { // return addLinearPosition(LinearPositions.builder().addSinglePosition((SinglePosition) p).build()); // } else if (p instanceof AreaPositions) { // return MultiDimensionalPositions.builder().addAreaPosition(this.build()).addChild(p); // } else { // throw new IllegalArgumentException("The position " + p + "cannot be a child of AreaPosition"); // } // } // // public AreaPositions build() { // return new AreaPositions(linearPositions, allChildrenAreClosed); // } // // } // // } // // Path: core/src/main/java/com/github/filosganga/geogson/util/Preconditions.java // public static <T> T checkArgument(T argument, Function<T, Boolean> predicate, Object errorMessage) { // if (!predicate.apply(argument)) { // throw new IllegalArgumentException(String.valueOf(errorMessage)); // } else { // return argument; // } // } // Path: core/src/main/java/com/github/filosganga/geogson/model/Polygon.java import com.github.filosganga.geogson.model.positions.AreaPositions; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; import static com.github.filosganga.geogson.util.Preconditions.checkArgument; /* * Copyright 2013 Filippo De Luca - [email protected] * * 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.github.filosganga.geogson.model; /** * A Geometry composed by a sequence of {@link LinearRing}s (or closed {@link LineString}s). The first one is the * external perimeter, the followers are the holes. * * GeoJson reference: @see http://geojson.org/geojson-spec.html#polygon. */ public class Polygon extends MultiLineString { private static final long serialVersionUID = 1L; public Polygon(AreaPositions positions) {
super(checkArgument(positions, AreaPositions::areAllChildrenClosed, "In a Polygon all the linear position must be closed"));
filosganga/geogson
core/src/main/java/com/github/filosganga/geogson/model/LineString.java
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/LinearPositions.java // public class LinearPositions extends AbstractPositions<SinglePosition> { // // private static final long serialVersionUID = 1L; // // private final Boolean isClosed; // // private LinearPositions(List<SinglePosition> children, boolean isClosed) { // super(children); // this.isClosed = isClosed; // } // // public static LinearPositions.Builder builder() { // return new LinearPositions.Builder(); // } // // public static LinearPositions.Builder builder(LinearPositions positions) { // return builder().addSinglePositions(positions.children); // } // // /** // * Merge this LinearPositions with another one. If the given {@link Positions} is: // * - SinglePosition, it will return a new LinearPositions with the given SinglePosition appended. // * - LinearPositions, it will return a new AreaPosition composed by this and the given LinearPositions. // * - Any other, it delegates to the other the merge logic. // * // * @param other Positions instance to merge with. // * // * @return Positions results of merging. // */ // @Override // public Positions merge(Positions other) { // if (other instanceof SinglePosition) { // SinglePosition that = (SinglePosition) other; // return builder().addSinglePosition(that).build(); // } else if (other instanceof LinearPositions) { // LinearPositions that = (LinearPositions) other; // return AreaPositions.builder().addLinearPosition(this).addLinearPosition(that).build(); // } else { // return other.merge(this); // } // } // // /** // * Returns if this LinearPosition: // * - Is composed by at least 4 points // * - The first and the last are the same. // * // * @return true if it is closed, false otherwise. // */ // public boolean isClosed() { // return isClosed; // } // // public static class Builder implements PositionsBuilder { // // private LinkedList<SinglePosition> singlePositions = new LinkedList<>(); // // private SinglePosition first = null; // private SinglePosition last = null; // private int size = 0; // // public Builder addSinglePosition(SinglePosition sp) { // singlePositions.add(sp); // if(first == null) { // first = sp; // } // last = sp; // size++; // // return this; // } // // public Builder addSinglePositions(Iterable<SinglePosition> sps) { // sps.forEach(this::addSinglePosition); // return this; // } // // @Override // public PositionsBuilder addChild(Positions p) { // if(p instanceof SinglePosition) { // return addSinglePosition((SinglePosition) p); // } else if (p instanceof LinearPositions) { // return AreaPositions.builder().addChild(this.build()).addChild(p); // } else { // throw new IllegalArgumentException("The position " + p + "cannot be a child of LinearPositions"); // } // } // // @Override // public LinearPositions build() { // Boolean isClosed = size >= 4 && first.equals(last); // return new LinearPositions(singlePositions, isClosed); // } // // } // // // } // // Path: core/src/main/java/com/github/filosganga/geogson/util/Preconditions.java // public static <T> T checkArgument(T argument, Function<T, Boolean> predicate, Object errorMessage) { // if (!predicate.apply(argument)) { // throw new IllegalArgumentException(String.valueOf(errorMessage)); // } else { // return argument; // } // }
import com.github.filosganga.geogson.model.positions.LinearPositions; import java.util.Arrays; import java.util.stream.Collectors; import java.util.stream.Stream; import static com.github.filosganga.geogson.util.Preconditions.checkArgument;
/* * Copyright 2013 Filippo De Luca - [email protected] * * 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.github.filosganga.geogson.model; /** * Specialization of LinearGeometry composed at least by 2 points. * <p> * JeoGson reference: @see http://geojson.org/geojson-spec.html#linestring. */ public class LineString extends LinearGeometry { private static final long serialVersionUID = 1L;
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/LinearPositions.java // public class LinearPositions extends AbstractPositions<SinglePosition> { // // private static final long serialVersionUID = 1L; // // private final Boolean isClosed; // // private LinearPositions(List<SinglePosition> children, boolean isClosed) { // super(children); // this.isClosed = isClosed; // } // // public static LinearPositions.Builder builder() { // return new LinearPositions.Builder(); // } // // public static LinearPositions.Builder builder(LinearPositions positions) { // return builder().addSinglePositions(positions.children); // } // // /** // * Merge this LinearPositions with another one. If the given {@link Positions} is: // * - SinglePosition, it will return a new LinearPositions with the given SinglePosition appended. // * - LinearPositions, it will return a new AreaPosition composed by this and the given LinearPositions. // * - Any other, it delegates to the other the merge logic. // * // * @param other Positions instance to merge with. // * // * @return Positions results of merging. // */ // @Override // public Positions merge(Positions other) { // if (other instanceof SinglePosition) { // SinglePosition that = (SinglePosition) other; // return builder().addSinglePosition(that).build(); // } else if (other instanceof LinearPositions) { // LinearPositions that = (LinearPositions) other; // return AreaPositions.builder().addLinearPosition(this).addLinearPosition(that).build(); // } else { // return other.merge(this); // } // } // // /** // * Returns if this LinearPosition: // * - Is composed by at least 4 points // * - The first and the last are the same. // * // * @return true if it is closed, false otherwise. // */ // public boolean isClosed() { // return isClosed; // } // // public static class Builder implements PositionsBuilder { // // private LinkedList<SinglePosition> singlePositions = new LinkedList<>(); // // private SinglePosition first = null; // private SinglePosition last = null; // private int size = 0; // // public Builder addSinglePosition(SinglePosition sp) { // singlePositions.add(sp); // if(first == null) { // first = sp; // } // last = sp; // size++; // // return this; // } // // public Builder addSinglePositions(Iterable<SinglePosition> sps) { // sps.forEach(this::addSinglePosition); // return this; // } // // @Override // public PositionsBuilder addChild(Positions p) { // if(p instanceof SinglePosition) { // return addSinglePosition((SinglePosition) p); // } else if (p instanceof LinearPositions) { // return AreaPositions.builder().addChild(this.build()).addChild(p); // } else { // throw new IllegalArgumentException("The position " + p + "cannot be a child of LinearPositions"); // } // } // // @Override // public LinearPositions build() { // Boolean isClosed = size >= 4 && first.equals(last); // return new LinearPositions(singlePositions, isClosed); // } // // } // // // } // // Path: core/src/main/java/com/github/filosganga/geogson/util/Preconditions.java // public static <T> T checkArgument(T argument, Function<T, Boolean> predicate, Object errorMessage) { // if (!predicate.apply(argument)) { // throw new IllegalArgumentException(String.valueOf(errorMessage)); // } else { // return argument; // } // } // Path: core/src/main/java/com/github/filosganga/geogson/model/LineString.java import com.github.filosganga.geogson.model.positions.LinearPositions; import java.util.Arrays; import java.util.stream.Collectors; import java.util.stream.Stream; import static com.github.filosganga.geogson.util.Preconditions.checkArgument; /* * Copyright 2013 Filippo De Luca - [email protected] * * 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.github.filosganga.geogson.model; /** * Specialization of LinearGeometry composed at least by 2 points. * <p> * JeoGson reference: @see http://geojson.org/geojson-spec.html#linestring. */ public class LineString extends LinearGeometry { private static final long serialVersionUID = 1L;
public LineString(LinearPositions positions) {
filosganga/geogson
core/src/main/java/com/github/filosganga/geogson/model/LineString.java
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/LinearPositions.java // public class LinearPositions extends AbstractPositions<SinglePosition> { // // private static final long serialVersionUID = 1L; // // private final Boolean isClosed; // // private LinearPositions(List<SinglePosition> children, boolean isClosed) { // super(children); // this.isClosed = isClosed; // } // // public static LinearPositions.Builder builder() { // return new LinearPositions.Builder(); // } // // public static LinearPositions.Builder builder(LinearPositions positions) { // return builder().addSinglePositions(positions.children); // } // // /** // * Merge this LinearPositions with another one. If the given {@link Positions} is: // * - SinglePosition, it will return a new LinearPositions with the given SinglePosition appended. // * - LinearPositions, it will return a new AreaPosition composed by this and the given LinearPositions. // * - Any other, it delegates to the other the merge logic. // * // * @param other Positions instance to merge with. // * // * @return Positions results of merging. // */ // @Override // public Positions merge(Positions other) { // if (other instanceof SinglePosition) { // SinglePosition that = (SinglePosition) other; // return builder().addSinglePosition(that).build(); // } else if (other instanceof LinearPositions) { // LinearPositions that = (LinearPositions) other; // return AreaPositions.builder().addLinearPosition(this).addLinearPosition(that).build(); // } else { // return other.merge(this); // } // } // // /** // * Returns if this LinearPosition: // * - Is composed by at least 4 points // * - The first and the last are the same. // * // * @return true if it is closed, false otherwise. // */ // public boolean isClosed() { // return isClosed; // } // // public static class Builder implements PositionsBuilder { // // private LinkedList<SinglePosition> singlePositions = new LinkedList<>(); // // private SinglePosition first = null; // private SinglePosition last = null; // private int size = 0; // // public Builder addSinglePosition(SinglePosition sp) { // singlePositions.add(sp); // if(first == null) { // first = sp; // } // last = sp; // size++; // // return this; // } // // public Builder addSinglePositions(Iterable<SinglePosition> sps) { // sps.forEach(this::addSinglePosition); // return this; // } // // @Override // public PositionsBuilder addChild(Positions p) { // if(p instanceof SinglePosition) { // return addSinglePosition((SinglePosition) p); // } else if (p instanceof LinearPositions) { // return AreaPositions.builder().addChild(this.build()).addChild(p); // } else { // throw new IllegalArgumentException("The position " + p + "cannot be a child of LinearPositions"); // } // } // // @Override // public LinearPositions build() { // Boolean isClosed = size >= 4 && first.equals(last); // return new LinearPositions(singlePositions, isClosed); // } // // } // // // } // // Path: core/src/main/java/com/github/filosganga/geogson/util/Preconditions.java // public static <T> T checkArgument(T argument, Function<T, Boolean> predicate, Object errorMessage) { // if (!predicate.apply(argument)) { // throw new IllegalArgumentException(String.valueOf(errorMessage)); // } else { // return argument; // } // }
import com.github.filosganga.geogson.model.positions.LinearPositions; import java.util.Arrays; import java.util.stream.Collectors; import java.util.stream.Stream; import static com.github.filosganga.geogson.util.Preconditions.checkArgument;
/* * Copyright 2013 Filippo De Luca - [email protected] * * 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.github.filosganga.geogson.model; /** * Specialization of LinearGeometry composed at least by 2 points. * <p> * JeoGson reference: @see http://geojson.org/geojson-spec.html#linestring. */ public class LineString extends LinearGeometry { private static final long serialVersionUID = 1L; public LineString(LinearPositions positions) {
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/LinearPositions.java // public class LinearPositions extends AbstractPositions<SinglePosition> { // // private static final long serialVersionUID = 1L; // // private final Boolean isClosed; // // private LinearPositions(List<SinglePosition> children, boolean isClosed) { // super(children); // this.isClosed = isClosed; // } // // public static LinearPositions.Builder builder() { // return new LinearPositions.Builder(); // } // // public static LinearPositions.Builder builder(LinearPositions positions) { // return builder().addSinglePositions(positions.children); // } // // /** // * Merge this LinearPositions with another one. If the given {@link Positions} is: // * - SinglePosition, it will return a new LinearPositions with the given SinglePosition appended. // * - LinearPositions, it will return a new AreaPosition composed by this and the given LinearPositions. // * - Any other, it delegates to the other the merge logic. // * // * @param other Positions instance to merge with. // * // * @return Positions results of merging. // */ // @Override // public Positions merge(Positions other) { // if (other instanceof SinglePosition) { // SinglePosition that = (SinglePosition) other; // return builder().addSinglePosition(that).build(); // } else if (other instanceof LinearPositions) { // LinearPositions that = (LinearPositions) other; // return AreaPositions.builder().addLinearPosition(this).addLinearPosition(that).build(); // } else { // return other.merge(this); // } // } // // /** // * Returns if this LinearPosition: // * - Is composed by at least 4 points // * - The first and the last are the same. // * // * @return true if it is closed, false otherwise. // */ // public boolean isClosed() { // return isClosed; // } // // public static class Builder implements PositionsBuilder { // // private LinkedList<SinglePosition> singlePositions = new LinkedList<>(); // // private SinglePosition first = null; // private SinglePosition last = null; // private int size = 0; // // public Builder addSinglePosition(SinglePosition sp) { // singlePositions.add(sp); // if(first == null) { // first = sp; // } // last = sp; // size++; // // return this; // } // // public Builder addSinglePositions(Iterable<SinglePosition> sps) { // sps.forEach(this::addSinglePosition); // return this; // } // // @Override // public PositionsBuilder addChild(Positions p) { // if(p instanceof SinglePosition) { // return addSinglePosition((SinglePosition) p); // } else if (p instanceof LinearPositions) { // return AreaPositions.builder().addChild(this.build()).addChild(p); // } else { // throw new IllegalArgumentException("The position " + p + "cannot be a child of LinearPositions"); // } // } // // @Override // public LinearPositions build() { // Boolean isClosed = size >= 4 && first.equals(last); // return new LinearPositions(singlePositions, isClosed); // } // // } // // // } // // Path: core/src/main/java/com/github/filosganga/geogson/util/Preconditions.java // public static <T> T checkArgument(T argument, Function<T, Boolean> predicate, Object errorMessage) { // if (!predicate.apply(argument)) { // throw new IllegalArgumentException(String.valueOf(errorMessage)); // } else { // return argument; // } // } // Path: core/src/main/java/com/github/filosganga/geogson/model/LineString.java import com.github.filosganga.geogson.model.positions.LinearPositions; import java.util.Arrays; import java.util.stream.Collectors; import java.util.stream.Stream; import static com.github.filosganga.geogson.util.Preconditions.checkArgument; /* * Copyright 2013 Filippo De Luca - [email protected] * * 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.github.filosganga.geogson.model; /** * Specialization of LinearGeometry composed at least by 2 points. * <p> * JeoGson reference: @see http://geojson.org/geojson-spec.html#linestring. */ public class LineString extends LinearGeometry { private static final long serialVersionUID = 1L; public LineString(LinearPositions positions) {
super(checkArgument(positions, toCheck -> toCheck.size() >= 2, "LineString must be composed by a minimum of 2 points."));
filosganga/geogson
core/src/main/java/com/github/filosganga/geogson/gson/FeatureCollectionAdapter.java
// Path: core/src/main/java/com/github/filosganga/geogson/model/Feature.java // public class Feature implements Serializable { // // private static final long serialVersionUID = 1L; // // private final Geometry<?> geometry; // // // Feature properties can contain generic json objects // private final Map<String, JsonElement> properties; // // private final String id; // // private transient Integer cachedHashCode = null; // // public static class Builder { // // private Geometry<?> geometry = null; // private Map<String, JsonElement> properties = new HashMap<>(240); // private Optional<String> id = Optional.empty(); // // Builder(){ // } // // public Builder withGeometry(Geometry<?> geometry) { // this.geometry = geometry; // return this; // } // // public Builder withProperties(Map<String, JsonElement> properties) { // this.properties.putAll(properties); // return this; // } // // public Builder withProperty(String name, JsonElement value) { // this.properties.put(name, value); // return this; // } // // public Builder withId(Optional<String> id) { // this.id = id; // return this; // } // // public Builder withId(String id) { // return withId(Optional.of(id)); // } // // public Feature build() { // if(geometry == null) { // throw new IllegalStateException("geometry is required to build a Feature"); // } // return new Feature(geometry, properties, id); // } // // } // // private Feature(Geometry<?> geometry, Map<String, JsonElement> properties, Optional<String> id) { // this.geometry = geometry; // this.properties = properties; // this.id = id.orElse(null); // } // // public static Builder builder() { // return new Builder(); // } // // public static Builder builder(Feature feature) { // return builder().withGeometry(feature.geometry).withProperties(feature.properties).withId(feature.id); // } // // /** // * Build a {@link Feature} with the given {@link Geometry}. // * // * @param geometry The Geometry to build Feature from // * // * @return An instance of Feature // */ // public static Feature of(Geometry<?> geometry) { // return builder().withGeometry(geometry).build(); // } // // /** // * The Geometry of this Feature. // * // * @return a Geometry instance. // */ // public Geometry<?> geometry() { // return geometry; // } // // /** // * The properties of this Feature. // * // * @return an Map containing the properties. An empty map if not properties have been set. // */ // public Map<String, JsonElement> properties() { // return Collections.unmodifiableMap(properties); // } // // /** // * The id of the Feature. // * // * @return Optional.absent if this Feature does not have any id. A valued Optional otherwise. // */ // public Optional<String> id() { // return Optional.ofNullable(id); // } // // // @Override // public int hashCode() { // if(cachedHashCode == null) { // cachedHashCode = Objects.hash(getClass(), this.id, this.geometry, this.properties); // } // // return cachedHashCode; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final Feature other = (Feature) obj; // return Objects.equals(this.id, other.id) // && Objects.equals(this.properties, other.properties) // && Objects.equals(this.geometry, other.geometry); // } // // @Override // public String toString() { // return "Feature{" + // "geometry=" + geometry + // ", properties=" + properties + // ", id=" + id + // '}'; // } // } // // Path: core/src/main/java/com/github/filosganga/geogson/model/FeatureCollection.java // public class FeatureCollection implements Serializable { // // private static final long serialVersionUID = 1L; // // private final List<Feature> features; // // public FeatureCollection(List<Feature> features) { // this.features = features; // } // // public static FeatureCollection of(Feature...features) { // return new FeatureCollection(Arrays.asList(features)); // } // // public List<Feature> features() { // return Collections.unmodifiableList(features); // } // // public int size() { // return features.size(); // } // // @Override // public int hashCode() { // return Objects.hash(getClass(), this.features); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final FeatureCollection other = (FeatureCollection) obj; // return Objects.equals(this.features, other.features); // } // // @Override // public String toString() { // return "FeatureCollection{" + // "features=" + features + // '}'; // } // }
import com.github.filosganga.geogson.model.Feature; import com.github.filosganga.geogson.model.FeatureCollection; import com.google.gson.Gson; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.LinkedList;
package com.github.filosganga.geogson.gson; /** * The Gson TypeAdapter to serialize/de-serialize {@link FeatureCollection} instances. */ public final class FeatureCollectionAdapter extends TypeAdapter<FeatureCollection> { private final Gson gson;
// Path: core/src/main/java/com/github/filosganga/geogson/model/Feature.java // public class Feature implements Serializable { // // private static final long serialVersionUID = 1L; // // private final Geometry<?> geometry; // // // Feature properties can contain generic json objects // private final Map<String, JsonElement> properties; // // private final String id; // // private transient Integer cachedHashCode = null; // // public static class Builder { // // private Geometry<?> geometry = null; // private Map<String, JsonElement> properties = new HashMap<>(240); // private Optional<String> id = Optional.empty(); // // Builder(){ // } // // public Builder withGeometry(Geometry<?> geometry) { // this.geometry = geometry; // return this; // } // // public Builder withProperties(Map<String, JsonElement> properties) { // this.properties.putAll(properties); // return this; // } // // public Builder withProperty(String name, JsonElement value) { // this.properties.put(name, value); // return this; // } // // public Builder withId(Optional<String> id) { // this.id = id; // return this; // } // // public Builder withId(String id) { // return withId(Optional.of(id)); // } // // public Feature build() { // if(geometry == null) { // throw new IllegalStateException("geometry is required to build a Feature"); // } // return new Feature(geometry, properties, id); // } // // } // // private Feature(Geometry<?> geometry, Map<String, JsonElement> properties, Optional<String> id) { // this.geometry = geometry; // this.properties = properties; // this.id = id.orElse(null); // } // // public static Builder builder() { // return new Builder(); // } // // public static Builder builder(Feature feature) { // return builder().withGeometry(feature.geometry).withProperties(feature.properties).withId(feature.id); // } // // /** // * Build a {@link Feature} with the given {@link Geometry}. // * // * @param geometry The Geometry to build Feature from // * // * @return An instance of Feature // */ // public static Feature of(Geometry<?> geometry) { // return builder().withGeometry(geometry).build(); // } // // /** // * The Geometry of this Feature. // * // * @return a Geometry instance. // */ // public Geometry<?> geometry() { // return geometry; // } // // /** // * The properties of this Feature. // * // * @return an Map containing the properties. An empty map if not properties have been set. // */ // public Map<String, JsonElement> properties() { // return Collections.unmodifiableMap(properties); // } // // /** // * The id of the Feature. // * // * @return Optional.absent if this Feature does not have any id. A valued Optional otherwise. // */ // public Optional<String> id() { // return Optional.ofNullable(id); // } // // // @Override // public int hashCode() { // if(cachedHashCode == null) { // cachedHashCode = Objects.hash(getClass(), this.id, this.geometry, this.properties); // } // // return cachedHashCode; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final Feature other = (Feature) obj; // return Objects.equals(this.id, other.id) // && Objects.equals(this.properties, other.properties) // && Objects.equals(this.geometry, other.geometry); // } // // @Override // public String toString() { // return "Feature{" + // "geometry=" + geometry + // ", properties=" + properties + // ", id=" + id + // '}'; // } // } // // Path: core/src/main/java/com/github/filosganga/geogson/model/FeatureCollection.java // public class FeatureCollection implements Serializable { // // private static final long serialVersionUID = 1L; // // private final List<Feature> features; // // public FeatureCollection(List<Feature> features) { // this.features = features; // } // // public static FeatureCollection of(Feature...features) { // return new FeatureCollection(Arrays.asList(features)); // } // // public List<Feature> features() { // return Collections.unmodifiableList(features); // } // // public int size() { // return features.size(); // } // // @Override // public int hashCode() { // return Objects.hash(getClass(), this.features); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final FeatureCollection other = (FeatureCollection) obj; // return Objects.equals(this.features, other.features); // } // // @Override // public String toString() { // return "FeatureCollection{" + // "features=" + features + // '}'; // } // } // Path: core/src/main/java/com/github/filosganga/geogson/gson/FeatureCollectionAdapter.java import com.github.filosganga.geogson.model.Feature; import com.github.filosganga.geogson.model.FeatureCollection; import com.google.gson.Gson; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.LinkedList; package com.github.filosganga.geogson.gson; /** * The Gson TypeAdapter to serialize/de-serialize {@link FeatureCollection} instances. */ public final class FeatureCollectionAdapter extends TypeAdapter<FeatureCollection> { private final Gson gson;
private final TypeAdapter<Feature> featureAdapter;
filosganga/geogson
core/src/main/java/com/github/filosganga/geogson/model/GeometryCollection.java
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/Positions.java // public interface Positions extends Serializable { // // /** // * Merge this Position with another one returning a new Position resulting of this merge. // * // * @param other Positions instance. // * @return new Positions instance. // */ // Positions merge(Positions other); // // /** // * Return this position children Positions. // * @return Iterable of Positions. // */ // List<? extends Positions> children(); // // /** // * The size of this positions. The semantic changes between different implementation of Positions. // * // * @return int. // */ // int size(); // // } // // Path: core/src/main/java/com/github/filosganga/geogson/model/positions/SinglePosition.java // public class SinglePosition extends AbstractPositions<Positions> { // // private static final long serialVersionUID = 2L; // // private static final List<Positions> EMPTY_CHILDREN = new ArrayList<>(); // // private final double lon; // private final double lat; // private final double alt; // // private transient Integer cachedHashCode = null; // // public SinglePosition(double lon, double lat, double alt) { // super(EMPTY_CHILDREN); // this.lon = lon; // this.lat = lat; // this.alt = alt; // } // // public double lon() { // return lon; // } // // public double lat() { // return lat; // } // // public double alt() { // return alt; // } // // // /** // * Merge this SinglePosition with another {@link Positions} instance. If the given {@link Positions} is: // * - a SinglePosition, it returns a {@link LinearPositions} composed by this and the given positions, in order. // * - any other {@link Positions}, it delegates to the given {@link Positions} merge. // * // * @param other Positions instance to merge with. // * // * @return Positions instance result of merge. // */ // @Override // public Positions merge(Positions other) { // // if (other instanceof SinglePosition) { // SinglePosition that = (SinglePosition) other; // return LinearPositions.builder().addSinglePosition(this).addSinglePosition(that).build(); // } else { // return other.merge(this); // } // } // // @Override // public int hashCode() { // if(cachedHashCode == null) { // cachedHashCode = Objects.hash(SinglePosition.class, lon, lat, alt); // } // return cachedHashCode; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final SinglePosition other = (SinglePosition) obj; // return Objects.equals(this.lon, other.lon) && // Objects.equals(this.lat, other.lat) && // Objects.equals(this.alt, other.alt); // } // // @Override // public String toString() { // return "SinglePosition{" + // "lon=" + lon + // ", lat=" + lat + // ", alt=" + alt + // '}'; // } // }
import com.github.filosganga.geogson.model.positions.Positions; import com.github.filosganga.geogson.model.positions.SinglePosition; import java.io.Serializable; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport;
/* * Copyright 2013 Filippo De Luca - [email protected] * * 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.github.filosganga.geogson.model; /** * Collection of {@link Geometry} holding an {@link Iterable} being a * {@link Geometry}. * <p> * GeoJson reference: @see http://geojson.org/geojson-spec.html#geometry-collection */ public class GeometryCollection implements Geometry<Positions>, Serializable { /** * internal Version for Serialization starting with 1. <b>Increment by 1 at * every change!</b> */ private static final long serialVersionUID = 1L; /** * Geometries of this {@link GeometryCollection} */ private final List<Geometry<?>> geometries; /** * Constructor creating a {@link GeometryCollection} out of * {@link Iterable} {@link Geometry Geometries}. * * @param geometries Geometries of this {@link GeometryCollection} */ private GeometryCollection(List<Geometry<?>> geometries) { this.geometries = geometries; } public static GeometryCollection of(Geometry<?>...geometries) { return new GeometryCollection(Arrays.asList(geometries)); } public static GeometryCollection of(Iterable<Geometry<?>> geometries) { if(geometries instanceof List) { return new GeometryCollection((List<Geometry<?>>)geometries); } else { return of(StreamSupport.stream(geometries.spliterator(), false).collect(Collectors.toList())); } } public static GeometryCollection of(Stream<Geometry<?>> geometries) { return new GeometryCollection(geometries.collect(Collectors.toList())); } /** * Get the {@link Iterable} {@link Geometry Geometries} of this * {@link GeometryCollection} * * @return all {@link Geometry Geometries} of this {@link Iterable} (e.g. * Collection) */ public List<Geometry<?>> getGeometries() { return Collections.unmodifiableList(this.geometries); } @Override public Type type() { return Type.GEOMETRY_COLLECTION; } @Override public Positions positions() {
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/Positions.java // public interface Positions extends Serializable { // // /** // * Merge this Position with another one returning a new Position resulting of this merge. // * // * @param other Positions instance. // * @return new Positions instance. // */ // Positions merge(Positions other); // // /** // * Return this position children Positions. // * @return Iterable of Positions. // */ // List<? extends Positions> children(); // // /** // * The size of this positions. The semantic changes between different implementation of Positions. // * // * @return int. // */ // int size(); // // } // // Path: core/src/main/java/com/github/filosganga/geogson/model/positions/SinglePosition.java // public class SinglePosition extends AbstractPositions<Positions> { // // private static final long serialVersionUID = 2L; // // private static final List<Positions> EMPTY_CHILDREN = new ArrayList<>(); // // private final double lon; // private final double lat; // private final double alt; // // private transient Integer cachedHashCode = null; // // public SinglePosition(double lon, double lat, double alt) { // super(EMPTY_CHILDREN); // this.lon = lon; // this.lat = lat; // this.alt = alt; // } // // public double lon() { // return lon; // } // // public double lat() { // return lat; // } // // public double alt() { // return alt; // } // // // /** // * Merge this SinglePosition with another {@link Positions} instance. If the given {@link Positions} is: // * - a SinglePosition, it returns a {@link LinearPositions} composed by this and the given positions, in order. // * - any other {@link Positions}, it delegates to the given {@link Positions} merge. // * // * @param other Positions instance to merge with. // * // * @return Positions instance result of merge. // */ // @Override // public Positions merge(Positions other) { // // if (other instanceof SinglePosition) { // SinglePosition that = (SinglePosition) other; // return LinearPositions.builder().addSinglePosition(this).addSinglePosition(that).build(); // } else { // return other.merge(this); // } // } // // @Override // public int hashCode() { // if(cachedHashCode == null) { // cachedHashCode = Objects.hash(SinglePosition.class, lon, lat, alt); // } // return cachedHashCode; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final SinglePosition other = (SinglePosition) obj; // return Objects.equals(this.lon, other.lon) && // Objects.equals(this.lat, other.lat) && // Objects.equals(this.alt, other.alt); // } // // @Override // public String toString() { // return "SinglePosition{" + // "lon=" + lon + // ", lat=" + lat + // ", alt=" + alt + // '}'; // } // } // Path: core/src/main/java/com/github/filosganga/geogson/model/GeometryCollection.java import com.github.filosganga.geogson.model.positions.Positions; import com.github.filosganga.geogson.model.positions.SinglePosition; import java.io.Serializable; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; /* * Copyright 2013 Filippo De Luca - [email protected] * * 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.github.filosganga.geogson.model; /** * Collection of {@link Geometry} holding an {@link Iterable} being a * {@link Geometry}. * <p> * GeoJson reference: @see http://geojson.org/geojson-spec.html#geometry-collection */ public class GeometryCollection implements Geometry<Positions>, Serializable { /** * internal Version for Serialization starting with 1. <b>Increment by 1 at * every change!</b> */ private static final long serialVersionUID = 1L; /** * Geometries of this {@link GeometryCollection} */ private final List<Geometry<?>> geometries; /** * Constructor creating a {@link GeometryCollection} out of * {@link Iterable} {@link Geometry Geometries}. * * @param geometries Geometries of this {@link GeometryCollection} */ private GeometryCollection(List<Geometry<?>> geometries) { this.geometries = geometries; } public static GeometryCollection of(Geometry<?>...geometries) { return new GeometryCollection(Arrays.asList(geometries)); } public static GeometryCollection of(Iterable<Geometry<?>> geometries) { if(geometries instanceof List) { return new GeometryCollection((List<Geometry<?>>)geometries); } else { return of(StreamSupport.stream(geometries.spliterator(), false).collect(Collectors.toList())); } } public static GeometryCollection of(Stream<Geometry<?>> geometries) { return new GeometryCollection(geometries.collect(Collectors.toList())); } /** * Get the {@link Iterable} {@link Geometry Geometries} of this * {@link GeometryCollection} * * @return all {@link Geometry Geometries} of this {@link Iterable} (e.g. * Collection) */ public List<Geometry<?>> getGeometries() { return Collections.unmodifiableList(this.geometries); } @Override public Type type() { return Type.GEOMETRY_COLLECTION; } @Override public Positions positions() {
Positions positions = new SinglePosition(Double.NaN, Double.NaN, Double.NaN);
filosganga/geogson
jts/src/main/java/com/github/filosganga/geogson/jts/AbstractJtsCodec.java
// Path: core/src/main/java/com/github/filosganga/geogson/codec/Codec.java // public interface Codec<S, T extends Geometry<?>> { // // /** // * Converts the given S instance to T. // * // * @param src a S instance to convert. // * @return a T instance. // */ // T toGeometry(S src); // // /** // * Converts the given T instance to S. // * // * @param src a T instance to convert. // * @return a S instance. // */ // S fromGeometry(T src); // } // // Path: core/src/main/java/com/github/filosganga/geogson/util/Preconditions.java // public static <T> T checkNotNull(T argument) { // return checkNotNull(argument,"Argument should be not null"); // }
import com.github.filosganga.geogson.codec.Codec; import com.github.filosganga.geogson.model.*; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.GeometryFactory; import java.util.ArrayList; import java.util.stream.StreamSupport; import static com.github.filosganga.geogson.util.Preconditions.checkNotNull;
package com.github.filosganga.geogson.jts; /** * Abstract JTS implementation of Codec. * <p> * It provides support for JTS conversions. */ public abstract class AbstractJtsCodec<S, T extends Geometry<?>> implements Codec<S, T> { /** * {@link GeometryFactory} defining a PrecisionModel and a SRID */ protected final GeometryFactory geometryFactory; /** * Get the {@link GeometryFactory} of this {@link AbstractJtsCodec} (gotten * via constructor) * * @return the {@link GeometryFactory} defining a PrecisionModel and a SRID */ public GeometryFactory getGeometryFactory() { return this.geometryFactory; } /** * Create a codec with a given {@link GeometryFactory} * * @param geometryFactory a {@link GeometryFactory} defining a PrecisionModel and a SRID */ public AbstractJtsCodec(GeometryFactory geometryFactory) {
// Path: core/src/main/java/com/github/filosganga/geogson/codec/Codec.java // public interface Codec<S, T extends Geometry<?>> { // // /** // * Converts the given S instance to T. // * // * @param src a S instance to convert. // * @return a T instance. // */ // T toGeometry(S src); // // /** // * Converts the given T instance to S. // * // * @param src a T instance to convert. // * @return a S instance. // */ // S fromGeometry(T src); // } // // Path: core/src/main/java/com/github/filosganga/geogson/util/Preconditions.java // public static <T> T checkNotNull(T argument) { // return checkNotNull(argument,"Argument should be not null"); // } // Path: jts/src/main/java/com/github/filosganga/geogson/jts/AbstractJtsCodec.java import com.github.filosganga.geogson.codec.Codec; import com.github.filosganga.geogson.model.*; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.GeometryFactory; import java.util.ArrayList; import java.util.stream.StreamSupport; import static com.github.filosganga.geogson.util.Preconditions.checkNotNull; package com.github.filosganga.geogson.jts; /** * Abstract JTS implementation of Codec. * <p> * It provides support for JTS conversions. */ public abstract class AbstractJtsCodec<S, T extends Geometry<?>> implements Codec<S, T> { /** * {@link GeometryFactory} defining a PrecisionModel and a SRID */ protected final GeometryFactory geometryFactory; /** * Get the {@link GeometryFactory} of this {@link AbstractJtsCodec} (gotten * via constructor) * * @return the {@link GeometryFactory} defining a PrecisionModel and a SRID */ public GeometryFactory getGeometryFactory() { return this.geometryFactory; } /** * Create a codec with a given {@link GeometryFactory} * * @param geometryFactory a {@link GeometryFactory} defining a PrecisionModel and a SRID */ public AbstractJtsCodec(GeometryFactory geometryFactory) {
this.geometryFactory = checkNotNull(geometryFactory, "The geometryFactory cannot be null");
filosganga/geogson
core/src/test/java/com/github/filosganga/geogson/model/PointTest.java
// Path: core/src/test/java/com/github/filosganga/geogson/model/Matchers.java // public static Matcher<Point> pointWithLonLat(final double lon, final double lat) { // return pointThatHave(positionsWithLonLat(lon, lat)); // }
import org.junit.Test; import static com.github.filosganga.geogson.model.Matchers.pointWithLonLat; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is;
/* * Copyright 2013 Filippo De Luca - [email protected] * * 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.github.filosganga.geogson.model; public class PointTest { @Test public void ofLonLatShouldReturnRightValues() {
// Path: core/src/test/java/com/github/filosganga/geogson/model/Matchers.java // public static Matcher<Point> pointWithLonLat(final double lon, final double lat) { // return pointThatHave(positionsWithLonLat(lon, lat)); // } // Path: core/src/test/java/com/github/filosganga/geogson/model/PointTest.java import org.junit.Test; import static com.github.filosganga.geogson.model.Matchers.pointWithLonLat; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; /* * Copyright 2013 Filippo De Luca - [email protected] * * 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.github.filosganga.geogson.model; public class PointTest { @Test public void ofLonLatShouldReturnRightValues() {
assertThat(Point.from(10, 20), is(pointWithLonLat(10, 20)));
filosganga/geogson
jts/src/main/java/com/github/filosganga/geogson/jts/GeometryCollectionCodec.java
// Path: core/src/main/java/com/github/filosganga/geogson/model/Geometry.java // public interface Geometry<P extends Positions> { // // /** // * Define the type of the Geometry. As defined in the GeoJson specifications. // */ // enum Type { // POINT("Point"), // MULTI_POINT("MultiPoint"), // LINE_STRING("LineString"), // LINEAR_RING("LineString"), // MULTI_LINE_STRING("MultiLineString"), // POLYGON("Polygon"), // MULTI_POLYGON("MultiPolygon"), // GEOMETRY_COLLECTION("GeometryCollection"); // // private final String value; // // Type(String value) { // this.value = value; // } // // public String getValue() { // return value; // } // // public static Type forValue(String value) { // for (Type type : values()) { // if (type.getValue().equalsIgnoreCase(value)) { // return type; // } // } // throw new IllegalArgumentException("Cannot build a geometry for type: " + value); // } // } // // /** // * Returns the Geometry type. // * // * @return Type // */ // Type type(); // // /** // * Returns the Position underlying instance. // * // * @return Position // */ // P positions(); // // /** // * Returns the size of this Geometry. Depending of the type of this Geometry, it may have different meaning. // * eg: For a LineString it is the number of points, for a MultiPolygon it is the number of polygons. // * // * @return Int // */ // int size(); // } // // Path: core/src/main/java/com/github/filosganga/geogson/model/GeometryCollection.java // public class GeometryCollection implements Geometry<Positions>, Serializable { // // /** // * internal Version for Serialization starting with 1. <b>Increment by 1 at // * every change!</b> // */ // private static final long serialVersionUID = 1L; // // /** // * Geometries of this {@link GeometryCollection} // */ // private final List<Geometry<?>> geometries; // // /** // * Constructor creating a {@link GeometryCollection} out of // * {@link Iterable} {@link Geometry Geometries}. // * // * @param geometries Geometries of this {@link GeometryCollection} // */ // private GeometryCollection(List<Geometry<?>> geometries) { // this.geometries = geometries; // } // // public static GeometryCollection of(Geometry<?>...geometries) { // return new GeometryCollection(Arrays.asList(geometries)); // } // // public static GeometryCollection of(Iterable<Geometry<?>> geometries) { // if(geometries instanceof List) { // return new GeometryCollection((List<Geometry<?>>)geometries); // } else { // return of(StreamSupport.stream(geometries.spliterator(), false).collect(Collectors.toList())); // } // } // // public static GeometryCollection of(Stream<Geometry<?>> geometries) { // return new GeometryCollection(geometries.collect(Collectors.toList())); // } // // /** // * Get the {@link Iterable} {@link Geometry Geometries} of this // * {@link GeometryCollection} // * // * @return all {@link Geometry Geometries} of this {@link Iterable} (e.g. // * Collection) // */ // public List<Geometry<?>> getGeometries() { // return Collections.unmodifiableList(this.geometries); // } // // @Override // public Type type() { // return Type.GEOMETRY_COLLECTION; // } // // @Override // public Positions positions() { // Positions positions = new SinglePosition(Double.NaN, Double.NaN, Double.NaN); // for (Geometry<?> geometry : this.geometries) { // positions.merge(geometry.positions()); // } // return positions; // } // // @Override // public int size() { // return geometries.size(); // } // // @Override // public int hashCode() { // return Objects.hash(getClass(), this.geometries); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final GeometryCollection other = (GeometryCollection) obj; // return Objects.equals(this.geometries, other.geometries); // } // // @Override // public String toString() { // return "GeometryCollection{geometries: " + Objects.toString(this.geometries) + "}"; // } // // }
import com.github.filosganga.geogson.model.Geometry; import com.github.filosganga.geogson.model.GeometryCollection; import org.locationtech.jts.geom.GeometryFactory; import java.util.stream.StreamSupport;
package com.github.filosganga.geogson.jts; /** * Codec for a {@link org.locationtech.jts.geom.GeometryCollection JTS * GeometryCollection} */ public class GeometryCollectionCodec extends AbstractJtsCodec<org.locationtech.jts.geom.GeometryCollection, GeometryCollection> { /** * Create a codec for a {@link org.locationtech.jts.geom.GeometryCollection JTS * GeometryCollection} with a given {@link GeometryFactory} * * @param geometryFactory a {@link GeometryFactory} defining a PrecisionModel and a SRID */ public GeometryCollectionCodec(GeometryFactory geometryFactory) { super(geometryFactory); } @Override public GeometryCollection toGeometry(org.locationtech.jts.geom.GeometryCollection src) { return GeometryCollection.of(StreamSupport.stream(JtsGeometryCollectionIterable.of(src).spliterator(), false) .map(this::fromJtsGeometryCollection)
// Path: core/src/main/java/com/github/filosganga/geogson/model/Geometry.java // public interface Geometry<P extends Positions> { // // /** // * Define the type of the Geometry. As defined in the GeoJson specifications. // */ // enum Type { // POINT("Point"), // MULTI_POINT("MultiPoint"), // LINE_STRING("LineString"), // LINEAR_RING("LineString"), // MULTI_LINE_STRING("MultiLineString"), // POLYGON("Polygon"), // MULTI_POLYGON("MultiPolygon"), // GEOMETRY_COLLECTION("GeometryCollection"); // // private final String value; // // Type(String value) { // this.value = value; // } // // public String getValue() { // return value; // } // // public static Type forValue(String value) { // for (Type type : values()) { // if (type.getValue().equalsIgnoreCase(value)) { // return type; // } // } // throw new IllegalArgumentException("Cannot build a geometry for type: " + value); // } // } // // /** // * Returns the Geometry type. // * // * @return Type // */ // Type type(); // // /** // * Returns the Position underlying instance. // * // * @return Position // */ // P positions(); // // /** // * Returns the size of this Geometry. Depending of the type of this Geometry, it may have different meaning. // * eg: For a LineString it is the number of points, for a MultiPolygon it is the number of polygons. // * // * @return Int // */ // int size(); // } // // Path: core/src/main/java/com/github/filosganga/geogson/model/GeometryCollection.java // public class GeometryCollection implements Geometry<Positions>, Serializable { // // /** // * internal Version for Serialization starting with 1. <b>Increment by 1 at // * every change!</b> // */ // private static final long serialVersionUID = 1L; // // /** // * Geometries of this {@link GeometryCollection} // */ // private final List<Geometry<?>> geometries; // // /** // * Constructor creating a {@link GeometryCollection} out of // * {@link Iterable} {@link Geometry Geometries}. // * // * @param geometries Geometries of this {@link GeometryCollection} // */ // private GeometryCollection(List<Geometry<?>> geometries) { // this.geometries = geometries; // } // // public static GeometryCollection of(Geometry<?>...geometries) { // return new GeometryCollection(Arrays.asList(geometries)); // } // // public static GeometryCollection of(Iterable<Geometry<?>> geometries) { // if(geometries instanceof List) { // return new GeometryCollection((List<Geometry<?>>)geometries); // } else { // return of(StreamSupport.stream(geometries.spliterator(), false).collect(Collectors.toList())); // } // } // // public static GeometryCollection of(Stream<Geometry<?>> geometries) { // return new GeometryCollection(geometries.collect(Collectors.toList())); // } // // /** // * Get the {@link Iterable} {@link Geometry Geometries} of this // * {@link GeometryCollection} // * // * @return all {@link Geometry Geometries} of this {@link Iterable} (e.g. // * Collection) // */ // public List<Geometry<?>> getGeometries() { // return Collections.unmodifiableList(this.geometries); // } // // @Override // public Type type() { // return Type.GEOMETRY_COLLECTION; // } // // @Override // public Positions positions() { // Positions positions = new SinglePosition(Double.NaN, Double.NaN, Double.NaN); // for (Geometry<?> geometry : this.geometries) { // positions.merge(geometry.positions()); // } // return positions; // } // // @Override // public int size() { // return geometries.size(); // } // // @Override // public int hashCode() { // return Objects.hash(getClass(), this.geometries); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final GeometryCollection other = (GeometryCollection) obj; // return Objects.equals(this.geometries, other.geometries); // } // // @Override // public String toString() { // return "GeometryCollection{geometries: " + Objects.toString(this.geometries) + "}"; // } // // } // Path: jts/src/main/java/com/github/filosganga/geogson/jts/GeometryCollectionCodec.java import com.github.filosganga.geogson.model.Geometry; import com.github.filosganga.geogson.model.GeometryCollection; import org.locationtech.jts.geom.GeometryFactory; import java.util.stream.StreamSupport; package com.github.filosganga.geogson.jts; /** * Codec for a {@link org.locationtech.jts.geom.GeometryCollection JTS * GeometryCollection} */ public class GeometryCollectionCodec extends AbstractJtsCodec<org.locationtech.jts.geom.GeometryCollection, GeometryCollection> { /** * Create a codec for a {@link org.locationtech.jts.geom.GeometryCollection JTS * GeometryCollection} with a given {@link GeometryFactory} * * @param geometryFactory a {@link GeometryFactory} defining a PrecisionModel and a SRID */ public GeometryCollectionCodec(GeometryFactory geometryFactory) { super(geometryFactory); } @Override public GeometryCollection toGeometry(org.locationtech.jts.geom.GeometryCollection src) { return GeometryCollection.of(StreamSupport.stream(JtsGeometryCollectionIterable.of(src).spliterator(), false) .map(this::fromJtsGeometryCollection)
.toArray(Geometry<?>[]::new)
filosganga/geogson
core/src/test/java/com/github/filosganga/geogson/PerformanceTest.java
// Path: core/src/main/java/com/github/filosganga/geogson/gson/GeometryAdapterFactory.java // public final class GeometryAdapterFactory implements TypeAdapterFactory { // // @Override // @SuppressWarnings("unchecked") // public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { // if (Geometry.class.isAssignableFrom(type.getRawType())) { // return (TypeAdapter<T>) new GeometryAdapter(gson); // } else if (Positions.class.isAssignableFrom(type.getRawType())) { // return (TypeAdapter<T>) new PositionsAdapter(); // } else if (Feature.class.isAssignableFrom(type.getRawType())) { // return (TypeAdapter<T>) new FeatureAdapter(gson); // } else if (FeatureCollection.class.isAssignableFrom(type.getRawType())) { // return (TypeAdapter<T>) new FeatureCollectionAdapter(gson); // } else { // return null; // } // } // } // // Path: core/src/main/java/com/github/filosganga/geogson/model/FeatureCollection.java // public class FeatureCollection implements Serializable { // // private static final long serialVersionUID = 1L; // // private final List<Feature> features; // // public FeatureCollection(List<Feature> features) { // this.features = features; // } // // public static FeatureCollection of(Feature...features) { // return new FeatureCollection(Arrays.asList(features)); // } // // public List<Feature> features() { // return Collections.unmodifiableList(features); // } // // public int size() { // return features.size(); // } // // @Override // public int hashCode() { // return Objects.hash(getClass(), this.features); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final FeatureCollection other = (FeatureCollection) obj; // return Objects.equals(this.features, other.features); // } // // @Override // public String toString() { // return "FeatureCollection{" + // "features=" + features + // '}'; // } // }
import com.github.filosganga.geogson.gson.GeometryAdapterFactory; import com.github.filosganga.geogson.model.FeatureCollection; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import org.openjdk.jmh.annotations.Benchmark; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader;
package com.github.filosganga.geogson; public class PerformanceTest { private static final Gson gson = new GsonBuilder().registerTypeAdapterFactory(new GeometryAdapterFactory()).create(); private static Reader openReader(String resourceName) throws IOException { return new BufferedReader(new InputStreamReader(ClassLoader.getSystemResourceAsStream(resourceName))); } @Benchmark public void featureCollectionReading() throws Exception { try (Reader reader = openReader("feature-collection.json")) {
// Path: core/src/main/java/com/github/filosganga/geogson/gson/GeometryAdapterFactory.java // public final class GeometryAdapterFactory implements TypeAdapterFactory { // // @Override // @SuppressWarnings("unchecked") // public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { // if (Geometry.class.isAssignableFrom(type.getRawType())) { // return (TypeAdapter<T>) new GeometryAdapter(gson); // } else if (Positions.class.isAssignableFrom(type.getRawType())) { // return (TypeAdapter<T>) new PositionsAdapter(); // } else if (Feature.class.isAssignableFrom(type.getRawType())) { // return (TypeAdapter<T>) new FeatureAdapter(gson); // } else if (FeatureCollection.class.isAssignableFrom(type.getRawType())) { // return (TypeAdapter<T>) new FeatureCollectionAdapter(gson); // } else { // return null; // } // } // } // // Path: core/src/main/java/com/github/filosganga/geogson/model/FeatureCollection.java // public class FeatureCollection implements Serializable { // // private static final long serialVersionUID = 1L; // // private final List<Feature> features; // // public FeatureCollection(List<Feature> features) { // this.features = features; // } // // public static FeatureCollection of(Feature...features) { // return new FeatureCollection(Arrays.asList(features)); // } // // public List<Feature> features() { // return Collections.unmodifiableList(features); // } // // public int size() { // return features.size(); // } // // @Override // public int hashCode() { // return Objects.hash(getClass(), this.features); // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final FeatureCollection other = (FeatureCollection) obj; // return Objects.equals(this.features, other.features); // } // // @Override // public String toString() { // return "FeatureCollection{" + // "features=" + features + // '}'; // } // } // Path: core/src/test/java/com/github/filosganga/geogson/PerformanceTest.java import com.github.filosganga.geogson.gson.GeometryAdapterFactory; import com.github.filosganga.geogson.model.FeatureCollection; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import org.openjdk.jmh.annotations.Benchmark; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; package com.github.filosganga.geogson; public class PerformanceTest { private static final Gson gson = new GsonBuilder().registerTypeAdapterFactory(new GeometryAdapterFactory()).create(); private static Reader openReader(String resourceName) throws IOException { return new BufferedReader(new InputStreamReader(ClassLoader.getSystemResourceAsStream(resourceName))); } @Benchmark public void featureCollectionReading() throws Exception { try (Reader reader = openReader("feature-collection.json")) {
gson.fromJson(reader, FeatureCollection.class);
filosganga/geogson
core/src/main/java/com/github/filosganga/geogson/model/MultiPoint.java
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/LinearPositions.java // public class LinearPositions extends AbstractPositions<SinglePosition> { // // private static final long serialVersionUID = 1L; // // private final Boolean isClosed; // // private LinearPositions(List<SinglePosition> children, boolean isClosed) { // super(children); // this.isClosed = isClosed; // } // // public static LinearPositions.Builder builder() { // return new LinearPositions.Builder(); // } // // public static LinearPositions.Builder builder(LinearPositions positions) { // return builder().addSinglePositions(positions.children); // } // // /** // * Merge this LinearPositions with another one. If the given {@link Positions} is: // * - SinglePosition, it will return a new LinearPositions with the given SinglePosition appended. // * - LinearPositions, it will return a new AreaPosition composed by this and the given LinearPositions. // * - Any other, it delegates to the other the merge logic. // * // * @param other Positions instance to merge with. // * // * @return Positions results of merging. // */ // @Override // public Positions merge(Positions other) { // if (other instanceof SinglePosition) { // SinglePosition that = (SinglePosition) other; // return builder().addSinglePosition(that).build(); // } else if (other instanceof LinearPositions) { // LinearPositions that = (LinearPositions) other; // return AreaPositions.builder().addLinearPosition(this).addLinearPosition(that).build(); // } else { // return other.merge(this); // } // } // // /** // * Returns if this LinearPosition: // * - Is composed by at least 4 points // * - The first and the last are the same. // * // * @return true if it is closed, false otherwise. // */ // public boolean isClosed() { // return isClosed; // } // // public static class Builder implements PositionsBuilder { // // private LinkedList<SinglePosition> singlePositions = new LinkedList<>(); // // private SinglePosition first = null; // private SinglePosition last = null; // private int size = 0; // // public Builder addSinglePosition(SinglePosition sp) { // singlePositions.add(sp); // if(first == null) { // first = sp; // } // last = sp; // size++; // // return this; // } // // public Builder addSinglePositions(Iterable<SinglePosition> sps) { // sps.forEach(this::addSinglePosition); // return this; // } // // @Override // public PositionsBuilder addChild(Positions p) { // if(p instanceof SinglePosition) { // return addSinglePosition((SinglePosition) p); // } else if (p instanceof LinearPositions) { // return AreaPositions.builder().addChild(this.build()).addChild(p); // } else { // throw new IllegalArgumentException("The position " + p + "cannot be a child of LinearPositions"); // } // } // // @Override // public LinearPositions build() { // Boolean isClosed = size >= 4 && first.equals(last); // return new LinearPositions(singlePositions, isClosed); // } // // } // // // }
import com.github.filosganga.geogson.model.positions.LinearPositions; import java.util.Arrays; import java.util.stream.Collectors; import java.util.stream.Stream;
/* * Copyright 2013 Filippo De Luca - [email protected] * * 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.github.filosganga.geogson.model; /** * Geometry composed by a sequence of {@link Point}. * <p> * GeoJson reference: @see http://geojson.org/geojson-spec.html#multipoint. * <p> * eg: {@code * MultiPoint mp = MultiPoint.of( * Point.from(1,2), * Point.from(3,4) * ) * } */ public class MultiPoint extends LinearGeometry { private static final long serialVersionUID = 1L;
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/LinearPositions.java // public class LinearPositions extends AbstractPositions<SinglePosition> { // // private static final long serialVersionUID = 1L; // // private final Boolean isClosed; // // private LinearPositions(List<SinglePosition> children, boolean isClosed) { // super(children); // this.isClosed = isClosed; // } // // public static LinearPositions.Builder builder() { // return new LinearPositions.Builder(); // } // // public static LinearPositions.Builder builder(LinearPositions positions) { // return builder().addSinglePositions(positions.children); // } // // /** // * Merge this LinearPositions with another one. If the given {@link Positions} is: // * - SinglePosition, it will return a new LinearPositions with the given SinglePosition appended. // * - LinearPositions, it will return a new AreaPosition composed by this and the given LinearPositions. // * - Any other, it delegates to the other the merge logic. // * // * @param other Positions instance to merge with. // * // * @return Positions results of merging. // */ // @Override // public Positions merge(Positions other) { // if (other instanceof SinglePosition) { // SinglePosition that = (SinglePosition) other; // return builder().addSinglePosition(that).build(); // } else if (other instanceof LinearPositions) { // LinearPositions that = (LinearPositions) other; // return AreaPositions.builder().addLinearPosition(this).addLinearPosition(that).build(); // } else { // return other.merge(this); // } // } // // /** // * Returns if this LinearPosition: // * - Is composed by at least 4 points // * - The first and the last are the same. // * // * @return true if it is closed, false otherwise. // */ // public boolean isClosed() { // return isClosed; // } // // public static class Builder implements PositionsBuilder { // // private LinkedList<SinglePosition> singlePositions = new LinkedList<>(); // // private SinglePosition first = null; // private SinglePosition last = null; // private int size = 0; // // public Builder addSinglePosition(SinglePosition sp) { // singlePositions.add(sp); // if(first == null) { // first = sp; // } // last = sp; // size++; // // return this; // } // // public Builder addSinglePositions(Iterable<SinglePosition> sps) { // sps.forEach(this::addSinglePosition); // return this; // } // // @Override // public PositionsBuilder addChild(Positions p) { // if(p instanceof SinglePosition) { // return addSinglePosition((SinglePosition) p); // } else if (p instanceof LinearPositions) { // return AreaPositions.builder().addChild(this.build()).addChild(p); // } else { // throw new IllegalArgumentException("The position " + p + "cannot be a child of LinearPositions"); // } // } // // @Override // public LinearPositions build() { // Boolean isClosed = size >= 4 && first.equals(last); // return new LinearPositions(singlePositions, isClosed); // } // // } // // // } // Path: core/src/main/java/com/github/filosganga/geogson/model/MultiPoint.java import com.github.filosganga.geogson.model.positions.LinearPositions; import java.util.Arrays; import java.util.stream.Collectors; import java.util.stream.Stream; /* * Copyright 2013 Filippo De Luca - [email protected] * * 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.github.filosganga.geogson.model; /** * Geometry composed by a sequence of {@link Point}. * <p> * GeoJson reference: @see http://geojson.org/geojson-spec.html#multipoint. * <p> * eg: {@code * MultiPoint mp = MultiPoint.of( * Point.from(1,2), * Point.from(3,4) * ) * } */ public class MultiPoint extends LinearGeometry { private static final long serialVersionUID = 1L;
public MultiPoint(LinearPositions coordinates) {
filosganga/geogson
core/src/test/java/com/github/filosganga/geogson/model/Matchers.java
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/Positions.java // public interface Positions extends Serializable { // // /** // * Merge this Position with another one returning a new Position resulting of this merge. // * // * @param other Positions instance. // * @return new Positions instance. // */ // Positions merge(Positions other); // // /** // * Return this position children Positions. // * @return Iterable of Positions. // */ // List<? extends Positions> children(); // // /** // * The size of this positions. The semantic changes between different implementation of Positions. // * // * @return int. // */ // int size(); // // } // // Path: core/src/main/java/com/github/filosganga/geogson/model/positions/SinglePosition.java // public class SinglePosition extends AbstractPositions<Positions> { // // private static final long serialVersionUID = 2L; // // private static final List<Positions> EMPTY_CHILDREN = new ArrayList<>(); // // private final double lon; // private final double lat; // private final double alt; // // private transient Integer cachedHashCode = null; // // public SinglePosition(double lon, double lat, double alt) { // super(EMPTY_CHILDREN); // this.lon = lon; // this.lat = lat; // this.alt = alt; // } // // public double lon() { // return lon; // } // // public double lat() { // return lat; // } // // public double alt() { // return alt; // } // // // /** // * Merge this SinglePosition with another {@link Positions} instance. If the given {@link Positions} is: // * - a SinglePosition, it returns a {@link LinearPositions} composed by this and the given positions, in order. // * - any other {@link Positions}, it delegates to the given {@link Positions} merge. // * // * @param other Positions instance to merge with. // * // * @return Positions instance result of merge. // */ // @Override // public Positions merge(Positions other) { // // if (other instanceof SinglePosition) { // SinglePosition that = (SinglePosition) other; // return LinearPositions.builder().addSinglePosition(this).addSinglePosition(that).build(); // } else { // return other.merge(this); // } // } // // @Override // public int hashCode() { // if(cachedHashCode == null) { // cachedHashCode = Objects.hash(SinglePosition.class, lon, lat, alt); // } // return cachedHashCode; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final SinglePosition other = (SinglePosition) obj; // return Objects.equals(this.lon, other.lon) && // Objects.equals(this.lat, other.lat) && // Objects.equals(this.alt, other.alt); // } // // @Override // public String toString() { // return "SinglePosition{" + // "lon=" + lon + // ", lat=" + lat + // ", alt=" + alt + // '}'; // } // }
import com.github.filosganga.geogson.model.positions.Positions; import com.github.filosganga.geogson.model.positions.SinglePosition; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeMatcher; import java.util.Map; import java.util.Optional;
/* * Copyright 2013 Filippo De Luca - [email protected] * * 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.github.filosganga.geogson.model; public final class Matchers { private Matchers() { }
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/Positions.java // public interface Positions extends Serializable { // // /** // * Merge this Position with another one returning a new Position resulting of this merge. // * // * @param other Positions instance. // * @return new Positions instance. // */ // Positions merge(Positions other); // // /** // * Return this position children Positions. // * @return Iterable of Positions. // */ // List<? extends Positions> children(); // // /** // * The size of this positions. The semantic changes between different implementation of Positions. // * // * @return int. // */ // int size(); // // } // // Path: core/src/main/java/com/github/filosganga/geogson/model/positions/SinglePosition.java // public class SinglePosition extends AbstractPositions<Positions> { // // private static final long serialVersionUID = 2L; // // private static final List<Positions> EMPTY_CHILDREN = new ArrayList<>(); // // private final double lon; // private final double lat; // private final double alt; // // private transient Integer cachedHashCode = null; // // public SinglePosition(double lon, double lat, double alt) { // super(EMPTY_CHILDREN); // this.lon = lon; // this.lat = lat; // this.alt = alt; // } // // public double lon() { // return lon; // } // // public double lat() { // return lat; // } // // public double alt() { // return alt; // } // // // /** // * Merge this SinglePosition with another {@link Positions} instance. If the given {@link Positions} is: // * - a SinglePosition, it returns a {@link LinearPositions} composed by this and the given positions, in order. // * - any other {@link Positions}, it delegates to the given {@link Positions} merge. // * // * @param other Positions instance to merge with. // * // * @return Positions instance result of merge. // */ // @Override // public Positions merge(Positions other) { // // if (other instanceof SinglePosition) { // SinglePosition that = (SinglePosition) other; // return LinearPositions.builder().addSinglePosition(this).addSinglePosition(that).build(); // } else { // return other.merge(this); // } // } // // @Override // public int hashCode() { // if(cachedHashCode == null) { // cachedHashCode = Objects.hash(SinglePosition.class, lon, lat, alt); // } // return cachedHashCode; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final SinglePosition other = (SinglePosition) obj; // return Objects.equals(this.lon, other.lon) && // Objects.equals(this.lat, other.lat) && // Objects.equals(this.alt, other.alt); // } // // @Override // public String toString() { // return "SinglePosition{" + // "lon=" + lon + // ", lat=" + lat + // ", alt=" + alt + // '}'; // } // } // Path: core/src/test/java/com/github/filosganga/geogson/model/Matchers.java import com.github.filosganga.geogson.model.positions.Positions; import com.github.filosganga.geogson.model.positions.SinglePosition; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeMatcher; import java.util.Map; import java.util.Optional; /* * Copyright 2013 Filippo De Luca - [email protected] * * 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.github.filosganga.geogson.model; public final class Matchers { private Matchers() { }
public static Matcher<Positions> singlePositionsWithLonLat(final double lon, final double lat) {
filosganga/geogson
core/src/test/java/com/github/filosganga/geogson/model/Matchers.java
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/Positions.java // public interface Positions extends Serializable { // // /** // * Merge this Position with another one returning a new Position resulting of this merge. // * // * @param other Positions instance. // * @return new Positions instance. // */ // Positions merge(Positions other); // // /** // * Return this position children Positions. // * @return Iterable of Positions. // */ // List<? extends Positions> children(); // // /** // * The size of this positions. The semantic changes between different implementation of Positions. // * // * @return int. // */ // int size(); // // } // // Path: core/src/main/java/com/github/filosganga/geogson/model/positions/SinglePosition.java // public class SinglePosition extends AbstractPositions<Positions> { // // private static final long serialVersionUID = 2L; // // private static final List<Positions> EMPTY_CHILDREN = new ArrayList<>(); // // private final double lon; // private final double lat; // private final double alt; // // private transient Integer cachedHashCode = null; // // public SinglePosition(double lon, double lat, double alt) { // super(EMPTY_CHILDREN); // this.lon = lon; // this.lat = lat; // this.alt = alt; // } // // public double lon() { // return lon; // } // // public double lat() { // return lat; // } // // public double alt() { // return alt; // } // // // /** // * Merge this SinglePosition with another {@link Positions} instance. If the given {@link Positions} is: // * - a SinglePosition, it returns a {@link LinearPositions} composed by this and the given positions, in order. // * - any other {@link Positions}, it delegates to the given {@link Positions} merge. // * // * @param other Positions instance to merge with. // * // * @return Positions instance result of merge. // */ // @Override // public Positions merge(Positions other) { // // if (other instanceof SinglePosition) { // SinglePosition that = (SinglePosition) other; // return LinearPositions.builder().addSinglePosition(this).addSinglePosition(that).build(); // } else { // return other.merge(this); // } // } // // @Override // public int hashCode() { // if(cachedHashCode == null) { // cachedHashCode = Objects.hash(SinglePosition.class, lon, lat, alt); // } // return cachedHashCode; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final SinglePosition other = (SinglePosition) obj; // return Objects.equals(this.lon, other.lon) && // Objects.equals(this.lat, other.lat) && // Objects.equals(this.alt, other.alt); // } // // @Override // public String toString() { // return "SinglePosition{" + // "lon=" + lon + // ", lat=" + lat + // ", alt=" + alt + // '}'; // } // }
import com.github.filosganga.geogson.model.positions.Positions; import com.github.filosganga.geogson.model.positions.SinglePosition; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeMatcher; import java.util.Map; import java.util.Optional;
/* * Copyright 2013 Filippo De Luca - [email protected] * * 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.github.filosganga.geogson.model; public final class Matchers { private Matchers() { } public static Matcher<Positions> singlePositionsWithLonLat(final double lon, final double lat) { return new TypeSafeMatcher<Positions>() { @Override protected boolean matchesSafely(Positions item) { return positionsWithLonLat(lon, lat).matches((item)); } @Override public void describeTo(Description description) { description.appendText("Single positions with position: ").appendDescriptionOf(positionsWithLonLat(lon, lat)); } }; } public static Matcher<Positions> singlePositionsWithLonLatAlt(final double lon, final double lat, final double alt) { return new TypeSafeMatcher<Positions>() { @Override protected boolean matchesSafely(Positions item) { return positionWithLonLatAlt(lon, lat, alt).matches(item); } @Override public void describeTo(Description description) { description.appendText("Single positions with position: ").appendDescriptionOf(positionWithLonLatAlt(lon, lat, alt)); } }; }
// Path: core/src/main/java/com/github/filosganga/geogson/model/positions/Positions.java // public interface Positions extends Serializable { // // /** // * Merge this Position with another one returning a new Position resulting of this merge. // * // * @param other Positions instance. // * @return new Positions instance. // */ // Positions merge(Positions other); // // /** // * Return this position children Positions. // * @return Iterable of Positions. // */ // List<? extends Positions> children(); // // /** // * The size of this positions. The semantic changes between different implementation of Positions. // * // * @return int. // */ // int size(); // // } // // Path: core/src/main/java/com/github/filosganga/geogson/model/positions/SinglePosition.java // public class SinglePosition extends AbstractPositions<Positions> { // // private static final long serialVersionUID = 2L; // // private static final List<Positions> EMPTY_CHILDREN = new ArrayList<>(); // // private final double lon; // private final double lat; // private final double alt; // // private transient Integer cachedHashCode = null; // // public SinglePosition(double lon, double lat, double alt) { // super(EMPTY_CHILDREN); // this.lon = lon; // this.lat = lat; // this.alt = alt; // } // // public double lon() { // return lon; // } // // public double lat() { // return lat; // } // // public double alt() { // return alt; // } // // // /** // * Merge this SinglePosition with another {@link Positions} instance. If the given {@link Positions} is: // * - a SinglePosition, it returns a {@link LinearPositions} composed by this and the given positions, in order. // * - any other {@link Positions}, it delegates to the given {@link Positions} merge. // * // * @param other Positions instance to merge with. // * // * @return Positions instance result of merge. // */ // @Override // public Positions merge(Positions other) { // // if (other instanceof SinglePosition) { // SinglePosition that = (SinglePosition) other; // return LinearPositions.builder().addSinglePosition(this).addSinglePosition(that).build(); // } else { // return other.merge(this); // } // } // // @Override // public int hashCode() { // if(cachedHashCode == null) { // cachedHashCode = Objects.hash(SinglePosition.class, lon, lat, alt); // } // return cachedHashCode; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null || getClass() != obj.getClass()) { // return false; // } // final SinglePosition other = (SinglePosition) obj; // return Objects.equals(this.lon, other.lon) && // Objects.equals(this.lat, other.lat) && // Objects.equals(this.alt, other.alt); // } // // @Override // public String toString() { // return "SinglePosition{" + // "lon=" + lon + // ", lat=" + lat + // ", alt=" + alt + // '}'; // } // } // Path: core/src/test/java/com/github/filosganga/geogson/model/Matchers.java import com.github.filosganga.geogson.model.positions.Positions; import com.github.filosganga.geogson.model.positions.SinglePosition; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeMatcher; import java.util.Map; import java.util.Optional; /* * Copyright 2013 Filippo De Luca - [email protected] * * 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.github.filosganga.geogson.model; public final class Matchers { private Matchers() { } public static Matcher<Positions> singlePositionsWithLonLat(final double lon, final double lat) { return new TypeSafeMatcher<Positions>() { @Override protected boolean matchesSafely(Positions item) { return positionsWithLonLat(lon, lat).matches((item)); } @Override public void describeTo(Description description) { description.appendText("Single positions with position: ").appendDescriptionOf(positionsWithLonLat(lon, lat)); } }; } public static Matcher<Positions> singlePositionsWithLonLatAlt(final double lon, final double lat, final double alt) { return new TypeSafeMatcher<Positions>() { @Override protected boolean matchesSafely(Positions item) { return positionWithLonLatAlt(lon, lat, alt).matches(item); } @Override public void describeTo(Description description) { description.appendText("Single positions with position: ").appendDescriptionOf(positionWithLonLatAlt(lon, lat, alt)); } }; }
public static Matcher<SinglePosition> positionsWithLonLat(final double lon, final double lat) {
filosganga/geogson
core/src/main/java/com/github/filosganga/geogson/model/positions/AbstractPositions.java
// Path: core/src/main/java/com/github/filosganga/geogson/util/Preconditions.java // public static <T> T checkArgument(T argument, Function<T, Boolean> predicate, Object errorMessage) { // if (!predicate.apply(argument)) { // throw new IllegalArgumentException(String.valueOf(errorMessage)); // } else { // return argument; // } // }
import java.util.Collections; import java.util.List; import java.util.Objects; import static com.github.filosganga.geogson.util.Preconditions.checkArgument;
package com.github.filosganga.geogson.model.positions; /** * Abstract implementation of {@link Positions}. Provides some basic methods. */ public abstract class AbstractPositions<T extends Positions> implements Positions { private static final long serialVersionUID = 1L; protected final List<T> children; private transient Integer cachedSize = null; private transient Integer cachedHashCode = null; AbstractPositions(List<T> children) {
// Path: core/src/main/java/com/github/filosganga/geogson/util/Preconditions.java // public static <T> T checkArgument(T argument, Function<T, Boolean> predicate, Object errorMessage) { // if (!predicate.apply(argument)) { // throw new IllegalArgumentException(String.valueOf(errorMessage)); // } else { // return argument; // } // } // Path: core/src/main/java/com/github/filosganga/geogson/model/positions/AbstractPositions.java import java.util.Collections; import java.util.List; import java.util.Objects; import static com.github.filosganga.geogson.util.Preconditions.checkArgument; package com.github.filosganga.geogson.model.positions; /** * Abstract implementation of {@link Positions}. Provides some basic methods. */ public abstract class AbstractPositions<T extends Positions> implements Positions { private static final long serialVersionUID = 1L; protected final List<T> children; private transient Integer cachedSize = null; private transient Integer cachedHashCode = null; AbstractPositions(List<T> children) {
this.children = checkArgument(children, Objects::nonNull, "The children cannot be null");
filosganga/geogson
jts/src/main/java/com/github/filosganga/geogson/jts/JtsAdapterFactory.java
// Path: core/src/main/java/com/github/filosganga/geogson/codec/CodecRegistry.java // public class CodecRegistry<T, S extends Geometry<?>> implements Codec<T, S> { // // private final Map<Type, Codec<T,S>> codecsByS = new ConcurrentHashMap<>(); // private final Map<Type, Codec<T,S>> codecsByT = new ConcurrentHashMap<>(); // // public CodecRegistry() { // this(new ArrayList<>()); // } // // public CodecRegistry(Iterable<Codec<? extends T, ? extends S>> codecs ) { // for(Codec<? extends T, ? extends S> codec : codecs) { // addCodec(codec); // } // } // // @SuppressWarnings("unchecked") // public void addCodec(Codec<? extends T, ? extends S> codec) { // // ParameterizedType type = (ParameterizedType) codec.getClass().getGenericSuperclass(); // // Type t = type.getActualTypeArguments()[0]; // Type s = type.getActualTypeArguments()[1]; // // codecsByS.put(s, (Codec<T, S>) codec); // codecsByT.put(t, (Codec<T, S>) codec); // } // // @Override // public S toGeometry(T src) { // return codecsByT.get(src.getClass()).toGeometry(src); // } // // @Override // public T fromGeometry(S src) { // return codecsByS.get(src.getClass()).fromGeometry(src); // } // } // // Path: core/src/main/java/com/github/filosganga/geogson/model/Geometry.java // public interface Geometry<P extends Positions> { // // /** // * Define the type of the Geometry. As defined in the GeoJson specifications. // */ // enum Type { // POINT("Point"), // MULTI_POINT("MultiPoint"), // LINE_STRING("LineString"), // LINEAR_RING("LineString"), // MULTI_LINE_STRING("MultiLineString"), // POLYGON("Polygon"), // MULTI_POLYGON("MultiPolygon"), // GEOMETRY_COLLECTION("GeometryCollection"); // // private final String value; // // Type(String value) { // this.value = value; // } // // public String getValue() { // return value; // } // // public static Type forValue(String value) { // for (Type type : values()) { // if (type.getValue().equalsIgnoreCase(value)) { // return type; // } // } // throw new IllegalArgumentException("Cannot build a geometry for type: " + value); // } // } // // /** // * Returns the Geometry type. // * // * @return Type // */ // Type type(); // // /** // * Returns the Position underlying instance. // * // * @return Position // */ // P positions(); // // /** // * Returns the size of this Geometry. Depending of the type of this Geometry, it may have different meaning. // * eg: For a LineString it is the number of points, for a MultiPolygon it is the number of polygons. // * // * @return Int // */ // int size(); // }
import com.github.filosganga.geogson.codec.CodecRegistry; import com.github.filosganga.geogson.model.Geometry; import com.google.gson.Gson; import com.google.gson.TypeAdapter; import com.google.gson.TypeAdapterFactory; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import org.locationtech.jts.geom.GeometryFactory; import java.io.IOException;
package com.github.filosganga.geogson.jts; /** * The JTS Gson TypeAdapterFactory. * * It can be built passing a GeometryFactory instance, otherwise it will instantiate a default one. * * How to use it: * <pre> * Gson gson = new GsonBuilder() * .registerTypeAdapterFactory(new JtsAdapterFactory(new GeometryFactory(new PrecisionModel(100), 4326))) * .registerTypeAdapterFactory(new GeometryAdapterFactory()) * .create(); * </pre> * */ public class JtsAdapterFactory implements TypeAdapterFactory { /** * {@link GeometryFactory} defining a PrecisionModel and a SRID */ private final GeometryFactory geometryFactory; /** * Create an adapter for {@link org.locationtech.jts.geom.Geometry JTS * Geometry} with a default {@link GeometryFactory} (i.e. using the * {@link GeometryFactory#GeometryFactory() empty constructor}) * */ public JtsAdapterFactory() { this.geometryFactory = new GeometryFactory(); } /** * Create an adapter for {@link org.locationtech.jts.geom.Geometry JTS * Geometry} with an optional {@link GeometryFactory} * * @param geometryFactory * an optional {@link GeometryFactory} defining a PrecisionModel * and a SRID */ public JtsAdapterFactory(GeometryFactory geometryFactory) { if (geometryFactory == null) { this.geometryFactory = new GeometryFactory(); } else { this.geometryFactory = geometryFactory; } } @Override public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
// Path: core/src/main/java/com/github/filosganga/geogson/codec/CodecRegistry.java // public class CodecRegistry<T, S extends Geometry<?>> implements Codec<T, S> { // // private final Map<Type, Codec<T,S>> codecsByS = new ConcurrentHashMap<>(); // private final Map<Type, Codec<T,S>> codecsByT = new ConcurrentHashMap<>(); // // public CodecRegistry() { // this(new ArrayList<>()); // } // // public CodecRegistry(Iterable<Codec<? extends T, ? extends S>> codecs ) { // for(Codec<? extends T, ? extends S> codec : codecs) { // addCodec(codec); // } // } // // @SuppressWarnings("unchecked") // public void addCodec(Codec<? extends T, ? extends S> codec) { // // ParameterizedType type = (ParameterizedType) codec.getClass().getGenericSuperclass(); // // Type t = type.getActualTypeArguments()[0]; // Type s = type.getActualTypeArguments()[1]; // // codecsByS.put(s, (Codec<T, S>) codec); // codecsByT.put(t, (Codec<T, S>) codec); // } // // @Override // public S toGeometry(T src) { // return codecsByT.get(src.getClass()).toGeometry(src); // } // // @Override // public T fromGeometry(S src) { // return codecsByS.get(src.getClass()).fromGeometry(src); // } // } // // Path: core/src/main/java/com/github/filosganga/geogson/model/Geometry.java // public interface Geometry<P extends Positions> { // // /** // * Define the type of the Geometry. As defined in the GeoJson specifications. // */ // enum Type { // POINT("Point"), // MULTI_POINT("MultiPoint"), // LINE_STRING("LineString"), // LINEAR_RING("LineString"), // MULTI_LINE_STRING("MultiLineString"), // POLYGON("Polygon"), // MULTI_POLYGON("MultiPolygon"), // GEOMETRY_COLLECTION("GeometryCollection"); // // private final String value; // // Type(String value) { // this.value = value; // } // // public String getValue() { // return value; // } // // public static Type forValue(String value) { // for (Type type : values()) { // if (type.getValue().equalsIgnoreCase(value)) { // return type; // } // } // throw new IllegalArgumentException("Cannot build a geometry for type: " + value); // } // } // // /** // * Returns the Geometry type. // * // * @return Type // */ // Type type(); // // /** // * Returns the Position underlying instance. // * // * @return Position // */ // P positions(); // // /** // * Returns the size of this Geometry. Depending of the type of this Geometry, it may have different meaning. // * eg: For a LineString it is the number of points, for a MultiPolygon it is the number of polygons. // * // * @return Int // */ // int size(); // } // Path: jts/src/main/java/com/github/filosganga/geogson/jts/JtsAdapterFactory.java import com.github.filosganga.geogson.codec.CodecRegistry; import com.github.filosganga.geogson.model.Geometry; import com.google.gson.Gson; import com.google.gson.TypeAdapter; import com.google.gson.TypeAdapterFactory; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import org.locationtech.jts.geom.GeometryFactory; import java.io.IOException; package com.github.filosganga.geogson.jts; /** * The JTS Gson TypeAdapterFactory. * * It can be built passing a GeometryFactory instance, otherwise it will instantiate a default one. * * How to use it: * <pre> * Gson gson = new GsonBuilder() * .registerTypeAdapterFactory(new JtsAdapterFactory(new GeometryFactory(new PrecisionModel(100), 4326))) * .registerTypeAdapterFactory(new GeometryAdapterFactory()) * .create(); * </pre> * */ public class JtsAdapterFactory implements TypeAdapterFactory { /** * {@link GeometryFactory} defining a PrecisionModel and a SRID */ private final GeometryFactory geometryFactory; /** * Create an adapter for {@link org.locationtech.jts.geom.Geometry JTS * Geometry} with a default {@link GeometryFactory} (i.e. using the * {@link GeometryFactory#GeometryFactory() empty constructor}) * */ public JtsAdapterFactory() { this.geometryFactory = new GeometryFactory(); } /** * Create an adapter for {@link org.locationtech.jts.geom.Geometry JTS * Geometry} with an optional {@link GeometryFactory} * * @param geometryFactory * an optional {@link GeometryFactory} defining a PrecisionModel * and a SRID */ public JtsAdapterFactory(GeometryFactory geometryFactory) { if (geometryFactory == null) { this.geometryFactory = new GeometryFactory(); } else { this.geometryFactory = geometryFactory; } } @Override public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
if(org.locationtech.jts.geom.Geometry.class.isAssignableFrom(type.getRawType())) {
filosganga/geogson
jts/src/main/java/com/github/filosganga/geogson/jts/JtsAdapterFactory.java
// Path: core/src/main/java/com/github/filosganga/geogson/codec/CodecRegistry.java // public class CodecRegistry<T, S extends Geometry<?>> implements Codec<T, S> { // // private final Map<Type, Codec<T,S>> codecsByS = new ConcurrentHashMap<>(); // private final Map<Type, Codec<T,S>> codecsByT = new ConcurrentHashMap<>(); // // public CodecRegistry() { // this(new ArrayList<>()); // } // // public CodecRegistry(Iterable<Codec<? extends T, ? extends S>> codecs ) { // for(Codec<? extends T, ? extends S> codec : codecs) { // addCodec(codec); // } // } // // @SuppressWarnings("unchecked") // public void addCodec(Codec<? extends T, ? extends S> codec) { // // ParameterizedType type = (ParameterizedType) codec.getClass().getGenericSuperclass(); // // Type t = type.getActualTypeArguments()[0]; // Type s = type.getActualTypeArguments()[1]; // // codecsByS.put(s, (Codec<T, S>) codec); // codecsByT.put(t, (Codec<T, S>) codec); // } // // @Override // public S toGeometry(T src) { // return codecsByT.get(src.getClass()).toGeometry(src); // } // // @Override // public T fromGeometry(S src) { // return codecsByS.get(src.getClass()).fromGeometry(src); // } // } // // Path: core/src/main/java/com/github/filosganga/geogson/model/Geometry.java // public interface Geometry<P extends Positions> { // // /** // * Define the type of the Geometry. As defined in the GeoJson specifications. // */ // enum Type { // POINT("Point"), // MULTI_POINT("MultiPoint"), // LINE_STRING("LineString"), // LINEAR_RING("LineString"), // MULTI_LINE_STRING("MultiLineString"), // POLYGON("Polygon"), // MULTI_POLYGON("MultiPolygon"), // GEOMETRY_COLLECTION("GeometryCollection"); // // private final String value; // // Type(String value) { // this.value = value; // } // // public String getValue() { // return value; // } // // public static Type forValue(String value) { // for (Type type : values()) { // if (type.getValue().equalsIgnoreCase(value)) { // return type; // } // } // throw new IllegalArgumentException("Cannot build a geometry for type: " + value); // } // } // // /** // * Returns the Geometry type. // * // * @return Type // */ // Type type(); // // /** // * Returns the Position underlying instance. // * // * @return Position // */ // P positions(); // // /** // * Returns the size of this Geometry. Depending of the type of this Geometry, it may have different meaning. // * eg: For a LineString it is the number of points, for a MultiPolygon it is the number of polygons. // * // * @return Int // */ // int size(); // }
import com.github.filosganga.geogson.codec.CodecRegistry; import com.github.filosganga.geogson.model.Geometry; import com.google.gson.Gson; import com.google.gson.TypeAdapter; import com.google.gson.TypeAdapterFactory; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import org.locationtech.jts.geom.GeometryFactory; import java.io.IOException;
package com.github.filosganga.geogson.jts; /** * The JTS Gson TypeAdapterFactory. * * It can be built passing a GeometryFactory instance, otherwise it will instantiate a default one. * * How to use it: * <pre> * Gson gson = new GsonBuilder() * .registerTypeAdapterFactory(new JtsAdapterFactory(new GeometryFactory(new PrecisionModel(100), 4326))) * .registerTypeAdapterFactory(new GeometryAdapterFactory()) * .create(); * </pre> * */ public class JtsAdapterFactory implements TypeAdapterFactory { /** * {@link GeometryFactory} defining a PrecisionModel and a SRID */ private final GeometryFactory geometryFactory; /** * Create an adapter for {@link org.locationtech.jts.geom.Geometry JTS * Geometry} with a default {@link GeometryFactory} (i.e. using the * {@link GeometryFactory#GeometryFactory() empty constructor}) * */ public JtsAdapterFactory() { this.geometryFactory = new GeometryFactory(); } /** * Create an adapter for {@link org.locationtech.jts.geom.Geometry JTS * Geometry} with an optional {@link GeometryFactory} * * @param geometryFactory * an optional {@link GeometryFactory} defining a PrecisionModel * and a SRID */ public JtsAdapterFactory(GeometryFactory geometryFactory) { if (geometryFactory == null) { this.geometryFactory = new GeometryFactory(); } else { this.geometryFactory = geometryFactory; } } @Override public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { if(org.locationtech.jts.geom.Geometry.class.isAssignableFrom(type.getRawType())) { return (TypeAdapter<T>) new JtsGeometryAdapter(gson, getGeometryFactory()); } else { return null; } } /** * Get the {@link GeometryFactory} of this {@link JtsAdapterFactory} * * @return the {@link GeometryFactory} defining a PrecisionModel and a SRID */ public GeometryFactory getGeometryFactory() { return this.geometryFactory; } } class JtsGeometryAdapter extends TypeAdapter<org.locationtech.jts.geom.Geometry> { private final Gson gson;
// Path: core/src/main/java/com/github/filosganga/geogson/codec/CodecRegistry.java // public class CodecRegistry<T, S extends Geometry<?>> implements Codec<T, S> { // // private final Map<Type, Codec<T,S>> codecsByS = new ConcurrentHashMap<>(); // private final Map<Type, Codec<T,S>> codecsByT = new ConcurrentHashMap<>(); // // public CodecRegistry() { // this(new ArrayList<>()); // } // // public CodecRegistry(Iterable<Codec<? extends T, ? extends S>> codecs ) { // for(Codec<? extends T, ? extends S> codec : codecs) { // addCodec(codec); // } // } // // @SuppressWarnings("unchecked") // public void addCodec(Codec<? extends T, ? extends S> codec) { // // ParameterizedType type = (ParameterizedType) codec.getClass().getGenericSuperclass(); // // Type t = type.getActualTypeArguments()[0]; // Type s = type.getActualTypeArguments()[1]; // // codecsByS.put(s, (Codec<T, S>) codec); // codecsByT.put(t, (Codec<T, S>) codec); // } // // @Override // public S toGeometry(T src) { // return codecsByT.get(src.getClass()).toGeometry(src); // } // // @Override // public T fromGeometry(S src) { // return codecsByS.get(src.getClass()).fromGeometry(src); // } // } // // Path: core/src/main/java/com/github/filosganga/geogson/model/Geometry.java // public interface Geometry<P extends Positions> { // // /** // * Define the type of the Geometry. As defined in the GeoJson specifications. // */ // enum Type { // POINT("Point"), // MULTI_POINT("MultiPoint"), // LINE_STRING("LineString"), // LINEAR_RING("LineString"), // MULTI_LINE_STRING("MultiLineString"), // POLYGON("Polygon"), // MULTI_POLYGON("MultiPolygon"), // GEOMETRY_COLLECTION("GeometryCollection"); // // private final String value; // // Type(String value) { // this.value = value; // } // // public String getValue() { // return value; // } // // public static Type forValue(String value) { // for (Type type : values()) { // if (type.getValue().equalsIgnoreCase(value)) { // return type; // } // } // throw new IllegalArgumentException("Cannot build a geometry for type: " + value); // } // } // // /** // * Returns the Geometry type. // * // * @return Type // */ // Type type(); // // /** // * Returns the Position underlying instance. // * // * @return Position // */ // P positions(); // // /** // * Returns the size of this Geometry. Depending of the type of this Geometry, it may have different meaning. // * eg: For a LineString it is the number of points, for a MultiPolygon it is the number of polygons. // * // * @return Int // */ // int size(); // } // Path: jts/src/main/java/com/github/filosganga/geogson/jts/JtsAdapterFactory.java import com.github.filosganga.geogson.codec.CodecRegistry; import com.github.filosganga.geogson.model.Geometry; import com.google.gson.Gson; import com.google.gson.TypeAdapter; import com.google.gson.TypeAdapterFactory; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import org.locationtech.jts.geom.GeometryFactory; import java.io.IOException; package com.github.filosganga.geogson.jts; /** * The JTS Gson TypeAdapterFactory. * * It can be built passing a GeometryFactory instance, otherwise it will instantiate a default one. * * How to use it: * <pre> * Gson gson = new GsonBuilder() * .registerTypeAdapterFactory(new JtsAdapterFactory(new GeometryFactory(new PrecisionModel(100), 4326))) * .registerTypeAdapterFactory(new GeometryAdapterFactory()) * .create(); * </pre> * */ public class JtsAdapterFactory implements TypeAdapterFactory { /** * {@link GeometryFactory} defining a PrecisionModel and a SRID */ private final GeometryFactory geometryFactory; /** * Create an adapter for {@link org.locationtech.jts.geom.Geometry JTS * Geometry} with a default {@link GeometryFactory} (i.e. using the * {@link GeometryFactory#GeometryFactory() empty constructor}) * */ public JtsAdapterFactory() { this.geometryFactory = new GeometryFactory(); } /** * Create an adapter for {@link org.locationtech.jts.geom.Geometry JTS * Geometry} with an optional {@link GeometryFactory} * * @param geometryFactory * an optional {@link GeometryFactory} defining a PrecisionModel * and a SRID */ public JtsAdapterFactory(GeometryFactory geometryFactory) { if (geometryFactory == null) { this.geometryFactory = new GeometryFactory(); } else { this.geometryFactory = geometryFactory; } } @Override public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { if(org.locationtech.jts.geom.Geometry.class.isAssignableFrom(type.getRawType())) { return (TypeAdapter<T>) new JtsGeometryAdapter(gson, getGeometryFactory()); } else { return null; } } /** * Get the {@link GeometryFactory} of this {@link JtsAdapterFactory} * * @return the {@link GeometryFactory} defining a PrecisionModel and a SRID */ public GeometryFactory getGeometryFactory() { return this.geometryFactory; } } class JtsGeometryAdapter extends TypeAdapter<org.locationtech.jts.geom.Geometry> { private final Gson gson;
private final CodecRegistry<org.locationtech.jts.geom.Geometry, Geometry<?>> codecRegistry;