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
Raxa/RaxaMachineLearning
src/com/learningmodule/association/conceptdrug/predictionmodule/DrugTableOperation.java
// Path: src/com/learningmodule/association/conceptdrug/AbstractDrugModel.java // public interface AbstractDrugModel { // // /* // * set the Drug Id for this drug // */ // public void setDrugId(String id); // // /* // * get the drug Id for this drug // */ // public String getDrugId(); // } // // Path: src/com/learningmodule/association/conceptdrug/ConceptDrugDatabaseInterface.java // public interface ConceptDrugDatabaseInterface { // // /* // * get name of file that will contain the prediction matrix generated by // * algorithm // */ // public String getMatrixFileName(); // // /* // * Method to get all the medical records containing encounterId(integer that // * represent an id for prescriptions written for a patient), // * ConceptId(integer that represent a diagnosis/diseases/observation for // * patient has been treated), DrugId(integer representing a drug that was // * written in the prescription) // */ // public LinkedList<EncounterIdConceptDrug> getData(); // // /* // * Method to get the medical records with given list of concepts Ids contaning encounterId, conceptId, DrugId, // * and feature related to medical records like age of patient, location of doctor/patient etc. // */ // // public LinkedList<EncounterIdConceptFeaturesDrugModel> getDataByConceptIds(LinkedList<String> ids); // // /* // * Method to get the list of conceptId and concept_name for given list of conceptId(integer) // */ // // public LinkedList<ConceptNameModel> getConceptIdNameByConceptIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of Drugs for given drugIds(integers) // */ // public LinkedList<AbstractDrugModel> getDrugInfoByDrugIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of all conceptId and concept_words // */ // public LinkedList<ConceptWordModel> getConceptWords(); // } // // Path: src/com/learningmodule/association/conceptdrug/PredictionResult.java // public interface PredictionResult { // public double getConfidence(); // public Object getValue(); // } // // Path: src/com/learningmodule/association/conceptdrug/model/ConceptDrugPredictionResult.java // public class ConceptDrugPredictionResult implements PredictionResult { // // contains drug info // private AbstractDrugModel drug; // // // confidence related to the drug and query // private double confidence; // // // concepts names for the concepts, drug related to // private LinkedList<String> tags; // // // conceptsId of concepts drug realted to // private HashSet<String> conceptIds; // // public ConceptDrugPredictionResult(String drug, double confidence) { // this.drug = new DrugModel(drug); // this.confidence = confidence; // this.conceptIds = new HashSet<String>(); // this.tags = new LinkedList<String>(); // } // // public AbstractDrugModel getDrug() { // return drug; // } // // @Override // public Object getValue() { // return drug; // } // // public void setDrug(AbstractDrugModel drug) { // this.drug = drug; // } // // @Override // public double getConfidence() { // return confidence; // } // // public void setConfidence(double confidence) { // this.confidence = confidence; // } // // public LinkedList<String> getTags() { // return tags; // } // // /* // * method to add a tag for drug result // */ // public void addTags(String tag) { // this.tags.add(tag); // } // // public HashSet<String> getConceptIds() { // return conceptIds; // } // // /* // * method to add concept Ids related to the drug result // */ // public void addConceptId(String conceptId) { // this.conceptIds.add(conceptId); // } // // public boolean hasConcept(String conceptId) { // return conceptIds.contains(conceptId); // } // // @Override // public String toString() { // return "PredictionResults [drug=" + drug.toString() + ", confidence=" + confidence + "]"; // } // }
import java.util.LinkedList; import org.apache.log4j.Logger; import com.learningmodule.association.conceptdrug.AbstractDrugModel; import com.learningmodule.association.conceptdrug.ConceptDrugDatabaseInterface; import com.learningmodule.association.conceptdrug.PredictionResult; import com.learningmodule.association.conceptdrug.model.ConceptDrugPredictionResult;
package com.learningmodule.association.conceptdrug.predictionmodule; /* * class to fetch the drug data from database and add drug info in results */ public class DrugTableOperation { private static Logger log = Logger.getLogger(DrugTableOperation.class); // method to get the list of Drugs details from database of given drugIDs public static LinkedList<PredictionResult> addDrugInfo( LinkedList<ConceptDrugPredictionResult> drugs,
// Path: src/com/learningmodule/association/conceptdrug/AbstractDrugModel.java // public interface AbstractDrugModel { // // /* // * set the Drug Id for this drug // */ // public void setDrugId(String id); // // /* // * get the drug Id for this drug // */ // public String getDrugId(); // } // // Path: src/com/learningmodule/association/conceptdrug/ConceptDrugDatabaseInterface.java // public interface ConceptDrugDatabaseInterface { // // /* // * get name of file that will contain the prediction matrix generated by // * algorithm // */ // public String getMatrixFileName(); // // /* // * Method to get all the medical records containing encounterId(integer that // * represent an id for prescriptions written for a patient), // * ConceptId(integer that represent a diagnosis/diseases/observation for // * patient has been treated), DrugId(integer representing a drug that was // * written in the prescription) // */ // public LinkedList<EncounterIdConceptDrug> getData(); // // /* // * Method to get the medical records with given list of concepts Ids contaning encounterId, conceptId, DrugId, // * and feature related to medical records like age of patient, location of doctor/patient etc. // */ // // public LinkedList<EncounterIdConceptFeaturesDrugModel> getDataByConceptIds(LinkedList<String> ids); // // /* // * Method to get the list of conceptId and concept_name for given list of conceptId(integer) // */ // // public LinkedList<ConceptNameModel> getConceptIdNameByConceptIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of Drugs for given drugIds(integers) // */ // public LinkedList<AbstractDrugModel> getDrugInfoByDrugIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of all conceptId and concept_words // */ // public LinkedList<ConceptWordModel> getConceptWords(); // } // // Path: src/com/learningmodule/association/conceptdrug/PredictionResult.java // public interface PredictionResult { // public double getConfidence(); // public Object getValue(); // } // // Path: src/com/learningmodule/association/conceptdrug/model/ConceptDrugPredictionResult.java // public class ConceptDrugPredictionResult implements PredictionResult { // // contains drug info // private AbstractDrugModel drug; // // // confidence related to the drug and query // private double confidence; // // // concepts names for the concepts, drug related to // private LinkedList<String> tags; // // // conceptsId of concepts drug realted to // private HashSet<String> conceptIds; // // public ConceptDrugPredictionResult(String drug, double confidence) { // this.drug = new DrugModel(drug); // this.confidence = confidence; // this.conceptIds = new HashSet<String>(); // this.tags = new LinkedList<String>(); // } // // public AbstractDrugModel getDrug() { // return drug; // } // // @Override // public Object getValue() { // return drug; // } // // public void setDrug(AbstractDrugModel drug) { // this.drug = drug; // } // // @Override // public double getConfidence() { // return confidence; // } // // public void setConfidence(double confidence) { // this.confidence = confidence; // } // // public LinkedList<String> getTags() { // return tags; // } // // /* // * method to add a tag for drug result // */ // public void addTags(String tag) { // this.tags.add(tag); // } // // public HashSet<String> getConceptIds() { // return conceptIds; // } // // /* // * method to add concept Ids related to the drug result // */ // public void addConceptId(String conceptId) { // this.conceptIds.add(conceptId); // } // // public boolean hasConcept(String conceptId) { // return conceptIds.contains(conceptId); // } // // @Override // public String toString() { // return "PredictionResults [drug=" + drug.toString() + ", confidence=" + confidence + "]"; // } // } // Path: src/com/learningmodule/association/conceptdrug/predictionmodule/DrugTableOperation.java import java.util.LinkedList; import org.apache.log4j.Logger; import com.learningmodule.association.conceptdrug.AbstractDrugModel; import com.learningmodule.association.conceptdrug.ConceptDrugDatabaseInterface; import com.learningmodule.association.conceptdrug.PredictionResult; import com.learningmodule.association.conceptdrug.model.ConceptDrugPredictionResult; package com.learningmodule.association.conceptdrug.predictionmodule; /* * class to fetch the drug data from database and add drug info in results */ public class DrugTableOperation { private static Logger log = Logger.getLogger(DrugTableOperation.class); // method to get the list of Drugs details from database of given drugIDs public static LinkedList<PredictionResult> addDrugInfo( LinkedList<ConceptDrugPredictionResult> drugs,
ConceptDrugDatabaseInterface learningInterface) {
Raxa/RaxaMachineLearning
src/com/learningmodule/association/conceptdrug/predictionmodule/DrugTableOperation.java
// Path: src/com/learningmodule/association/conceptdrug/AbstractDrugModel.java // public interface AbstractDrugModel { // // /* // * set the Drug Id for this drug // */ // public void setDrugId(String id); // // /* // * get the drug Id for this drug // */ // public String getDrugId(); // } // // Path: src/com/learningmodule/association/conceptdrug/ConceptDrugDatabaseInterface.java // public interface ConceptDrugDatabaseInterface { // // /* // * get name of file that will contain the prediction matrix generated by // * algorithm // */ // public String getMatrixFileName(); // // /* // * Method to get all the medical records containing encounterId(integer that // * represent an id for prescriptions written for a patient), // * ConceptId(integer that represent a diagnosis/diseases/observation for // * patient has been treated), DrugId(integer representing a drug that was // * written in the prescription) // */ // public LinkedList<EncounterIdConceptDrug> getData(); // // /* // * Method to get the medical records with given list of concepts Ids contaning encounterId, conceptId, DrugId, // * and feature related to medical records like age of patient, location of doctor/patient etc. // */ // // public LinkedList<EncounterIdConceptFeaturesDrugModel> getDataByConceptIds(LinkedList<String> ids); // // /* // * Method to get the list of conceptId and concept_name for given list of conceptId(integer) // */ // // public LinkedList<ConceptNameModel> getConceptIdNameByConceptIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of Drugs for given drugIds(integers) // */ // public LinkedList<AbstractDrugModel> getDrugInfoByDrugIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of all conceptId and concept_words // */ // public LinkedList<ConceptWordModel> getConceptWords(); // } // // Path: src/com/learningmodule/association/conceptdrug/PredictionResult.java // public interface PredictionResult { // public double getConfidence(); // public Object getValue(); // } // // Path: src/com/learningmodule/association/conceptdrug/model/ConceptDrugPredictionResult.java // public class ConceptDrugPredictionResult implements PredictionResult { // // contains drug info // private AbstractDrugModel drug; // // // confidence related to the drug and query // private double confidence; // // // concepts names for the concepts, drug related to // private LinkedList<String> tags; // // // conceptsId of concepts drug realted to // private HashSet<String> conceptIds; // // public ConceptDrugPredictionResult(String drug, double confidence) { // this.drug = new DrugModel(drug); // this.confidence = confidence; // this.conceptIds = new HashSet<String>(); // this.tags = new LinkedList<String>(); // } // // public AbstractDrugModel getDrug() { // return drug; // } // // @Override // public Object getValue() { // return drug; // } // // public void setDrug(AbstractDrugModel drug) { // this.drug = drug; // } // // @Override // public double getConfidence() { // return confidence; // } // // public void setConfidence(double confidence) { // this.confidence = confidence; // } // // public LinkedList<String> getTags() { // return tags; // } // // /* // * method to add a tag for drug result // */ // public void addTags(String tag) { // this.tags.add(tag); // } // // public HashSet<String> getConceptIds() { // return conceptIds; // } // // /* // * method to add concept Ids related to the drug result // */ // public void addConceptId(String conceptId) { // this.conceptIds.add(conceptId); // } // // public boolean hasConcept(String conceptId) { // return conceptIds.contains(conceptId); // } // // @Override // public String toString() { // return "PredictionResults [drug=" + drug.toString() + ", confidence=" + confidence + "]"; // } // }
import java.util.LinkedList; import org.apache.log4j.Logger; import com.learningmodule.association.conceptdrug.AbstractDrugModel; import com.learningmodule.association.conceptdrug.ConceptDrugDatabaseInterface; import com.learningmodule.association.conceptdrug.PredictionResult; import com.learningmodule.association.conceptdrug.model.ConceptDrugPredictionResult;
package com.learningmodule.association.conceptdrug.predictionmodule; /* * class to fetch the drug data from database and add drug info in results */ public class DrugTableOperation { private static Logger log = Logger.getLogger(DrugTableOperation.class); // method to get the list of Drugs details from database of given drugIDs public static LinkedList<PredictionResult> addDrugInfo( LinkedList<ConceptDrugPredictionResult> drugs, ConceptDrugDatabaseInterface learningInterface) { // get the drug data for DrugId's in results using database interface
// Path: src/com/learningmodule/association/conceptdrug/AbstractDrugModel.java // public interface AbstractDrugModel { // // /* // * set the Drug Id for this drug // */ // public void setDrugId(String id); // // /* // * get the drug Id for this drug // */ // public String getDrugId(); // } // // Path: src/com/learningmodule/association/conceptdrug/ConceptDrugDatabaseInterface.java // public interface ConceptDrugDatabaseInterface { // // /* // * get name of file that will contain the prediction matrix generated by // * algorithm // */ // public String getMatrixFileName(); // // /* // * Method to get all the medical records containing encounterId(integer that // * represent an id for prescriptions written for a patient), // * ConceptId(integer that represent a diagnosis/diseases/observation for // * patient has been treated), DrugId(integer representing a drug that was // * written in the prescription) // */ // public LinkedList<EncounterIdConceptDrug> getData(); // // /* // * Method to get the medical records with given list of concepts Ids contaning encounterId, conceptId, DrugId, // * and feature related to medical records like age of patient, location of doctor/patient etc. // */ // // public LinkedList<EncounterIdConceptFeaturesDrugModel> getDataByConceptIds(LinkedList<String> ids); // // /* // * Method to get the list of conceptId and concept_name for given list of conceptId(integer) // */ // // public LinkedList<ConceptNameModel> getConceptIdNameByConceptIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of Drugs for given drugIds(integers) // */ // public LinkedList<AbstractDrugModel> getDrugInfoByDrugIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of all conceptId and concept_words // */ // public LinkedList<ConceptWordModel> getConceptWords(); // } // // Path: src/com/learningmodule/association/conceptdrug/PredictionResult.java // public interface PredictionResult { // public double getConfidence(); // public Object getValue(); // } // // Path: src/com/learningmodule/association/conceptdrug/model/ConceptDrugPredictionResult.java // public class ConceptDrugPredictionResult implements PredictionResult { // // contains drug info // private AbstractDrugModel drug; // // // confidence related to the drug and query // private double confidence; // // // concepts names for the concepts, drug related to // private LinkedList<String> tags; // // // conceptsId of concepts drug realted to // private HashSet<String> conceptIds; // // public ConceptDrugPredictionResult(String drug, double confidence) { // this.drug = new DrugModel(drug); // this.confidence = confidence; // this.conceptIds = new HashSet<String>(); // this.tags = new LinkedList<String>(); // } // // public AbstractDrugModel getDrug() { // return drug; // } // // @Override // public Object getValue() { // return drug; // } // // public void setDrug(AbstractDrugModel drug) { // this.drug = drug; // } // // @Override // public double getConfidence() { // return confidence; // } // // public void setConfidence(double confidence) { // this.confidence = confidence; // } // // public LinkedList<String> getTags() { // return tags; // } // // /* // * method to add a tag for drug result // */ // public void addTags(String tag) { // this.tags.add(tag); // } // // public HashSet<String> getConceptIds() { // return conceptIds; // } // // /* // * method to add concept Ids related to the drug result // */ // public void addConceptId(String conceptId) { // this.conceptIds.add(conceptId); // } // // public boolean hasConcept(String conceptId) { // return conceptIds.contains(conceptId); // } // // @Override // public String toString() { // return "PredictionResults [drug=" + drug.toString() + ", confidence=" + confidence + "]"; // } // } // Path: src/com/learningmodule/association/conceptdrug/predictionmodule/DrugTableOperation.java import java.util.LinkedList; import org.apache.log4j.Logger; import com.learningmodule.association.conceptdrug.AbstractDrugModel; import com.learningmodule.association.conceptdrug.ConceptDrugDatabaseInterface; import com.learningmodule.association.conceptdrug.PredictionResult; import com.learningmodule.association.conceptdrug.model.ConceptDrugPredictionResult; package com.learningmodule.association.conceptdrug.predictionmodule; /* * class to fetch the drug data from database and add drug info in results */ public class DrugTableOperation { private static Logger log = Logger.getLogger(DrugTableOperation.class); // method to get the list of Drugs details from database of given drugIDs public static LinkedList<PredictionResult> addDrugInfo( LinkedList<ConceptDrugPredictionResult> drugs, ConceptDrugDatabaseInterface learningInterface) { // get the drug data for DrugId's in results using database interface
LinkedList<AbstractDrugModel> drugsInfo = learningInterface
Raxa/RaxaMachineLearning
src/com/learningmodule/association/conceptdrug/multifeature/LearningMethod.java
// Path: src/com/database/DatabaseConnector.java // public class DatabaseConnector { // private static Connection connection = null; // private static Logger log = Logger.getLogger(DatabaseConnector.class); // /* // * make connection as soon as the class is loaded // */ // static { // makeConnection(); // } // // /* // * method to make the connection with the database // */ // public static void makeConnection() { // // try { // PropertiesReader.load(); // // get the connection with the database // Class.forName("com.mysql.jdbc.Driver"); // connection = DriverManager.getConnection(PropertiesReader.getUrl(), // PropertiesReader.getUser(), PropertiesReader.getPassword()); // System.out.println("MySQL JDBC Driver Registered!"); // log.debug("MySQL JDBC Driver Registered!"); // } catch (SQLException e) { // System.out.println("Connection Failed! Check output console"); // e.printStackTrace(); // log.fatal(e); // return; // } catch (ClassNotFoundException e) { // e.printStackTrace(); // log.fatal(e); // } // } // // /* // * method to check if database is connected // */ // public static boolean isConnected() { // if (connection != null) { // try { // return !connection.isClosed(); // } catch (SQLException e) { // e.printStackTrace(); // } // return true; // } // return false; // } // // /* // * method the close the connection with database. // */ // public static void closeConnection() { // try { // connection.close(); // } catch (SQLException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // log.error(e); // } // } // // public static Connection getConnection() { // if(connection == null) { // makeConnection(); // } // return connection; // } // }
import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.LinkedList; import com.database.DatabaseConnector;
package com.learningmodule.association.conceptdrug.multifeature; public class LearningMethod { private static int noOfFeature = 1; public static LinkedList<EncounterIdConceptFeaturesDrugModel> getData(LinkedList<String> ids) { // get the connection with database
// Path: src/com/database/DatabaseConnector.java // public class DatabaseConnector { // private static Connection connection = null; // private static Logger log = Logger.getLogger(DatabaseConnector.class); // /* // * make connection as soon as the class is loaded // */ // static { // makeConnection(); // } // // /* // * method to make the connection with the database // */ // public static void makeConnection() { // // try { // PropertiesReader.load(); // // get the connection with the database // Class.forName("com.mysql.jdbc.Driver"); // connection = DriverManager.getConnection(PropertiesReader.getUrl(), // PropertiesReader.getUser(), PropertiesReader.getPassword()); // System.out.println("MySQL JDBC Driver Registered!"); // log.debug("MySQL JDBC Driver Registered!"); // } catch (SQLException e) { // System.out.println("Connection Failed! Check output console"); // e.printStackTrace(); // log.fatal(e); // return; // } catch (ClassNotFoundException e) { // e.printStackTrace(); // log.fatal(e); // } // } // // /* // * method to check if database is connected // */ // public static boolean isConnected() { // if (connection != null) { // try { // return !connection.isClosed(); // } catch (SQLException e) { // e.printStackTrace(); // } // return true; // } // return false; // } // // /* // * method the close the connection with database. // */ // public static void closeConnection() { // try { // connection.close(); // } catch (SQLException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // log.error(e); // } // } // // public static Connection getConnection() { // if(connection == null) { // makeConnection(); // } // return connection; // } // } // Path: src/com/learningmodule/association/conceptdrug/multifeature/LearningMethod.java import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.LinkedList; import com.database.DatabaseConnector; package com.learningmodule.association.conceptdrug.multifeature; public class LearningMethod { private static int noOfFeature = 1; public static LinkedList<EncounterIdConceptFeaturesDrugModel> getData(LinkedList<String> ids) { // get the connection with database
if (DatabaseConnector.getConnection() != null) {
Raxa/RaxaMachineLearning
src/com/machine/learning/LearningModulesPool.java
// Path: src/com/learningmodule/association/conceptdrug/PredictionResult.java // public interface PredictionResult { // public double getConfidence(); // public Object getValue(); // } // // Path: src/com/machine/learning/interfaces/LearningModuleInterface.java // public interface LearningModuleInterface { // public void learn(); // public List<PredictionResult> predict(String query, SearchAttribute[] features); // } // // Path: src/com/machine/learning/request/SearchAttribute.java // public class SearchAttribute { // private String name; // private Object value; // // public SearchAttribute(String name, Object value) { // super(); // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // @Override // public String toString() { // return "SearchAttribute [name=" + name + ", value=" + value + "]"; // } // }
import java.util.Iterator; import java.util.LinkedList; import java.util.List; import org.apache.log4j.Logger; import com.learningmodule.association.conceptdrug.PredictionResult; import com.machine.learning.interfaces.LearningModuleInterface; import com.machine.learning.request.SearchAttribute;
package com.machine.learning; /* * The class contains the list of learning modules that are added by ContextListner on start of this service */ public class LearningModulesPool { // LinkedList of Learning Modules in this pool private static LinkedList<LearningModuleInterface> modules = new LinkedList<LearningModuleInterface>(); private static Logger log = Logger.getLogger(LearningModulesPool.class); // method to add a learning module in this pool public static void addLearningModule(LearningModuleInterface module) { modules.add(module); log.debug("Module Added: " + module.getClass()); } /* * method to get the results for a query from all modules in the pool and * merge them to return all the results */
// Path: src/com/learningmodule/association/conceptdrug/PredictionResult.java // public interface PredictionResult { // public double getConfidence(); // public Object getValue(); // } // // Path: src/com/machine/learning/interfaces/LearningModuleInterface.java // public interface LearningModuleInterface { // public void learn(); // public List<PredictionResult> predict(String query, SearchAttribute[] features); // } // // Path: src/com/machine/learning/request/SearchAttribute.java // public class SearchAttribute { // private String name; // private Object value; // // public SearchAttribute(String name, Object value) { // super(); // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // @Override // public String toString() { // return "SearchAttribute [name=" + name + ", value=" + value + "]"; // } // } // Path: src/com/machine/learning/LearningModulesPool.java import java.util.Iterator; import java.util.LinkedList; import java.util.List; import org.apache.log4j.Logger; import com.learningmodule.association.conceptdrug.PredictionResult; import com.machine.learning.interfaces.LearningModuleInterface; import com.machine.learning.request.SearchAttribute; package com.machine.learning; /* * The class contains the list of learning modules that are added by ContextListner on start of this service */ public class LearningModulesPool { // LinkedList of Learning Modules in this pool private static LinkedList<LearningModuleInterface> modules = new LinkedList<LearningModuleInterface>(); private static Logger log = Logger.getLogger(LearningModulesPool.class); // method to add a learning module in this pool public static void addLearningModule(LearningModuleInterface module) { modules.add(module); log.debug("Module Added: " + module.getClass()); } /* * method to get the results for a query from all modules in the pool and * merge them to return all the results */
public static LinkedList<PredictionResult> predict(String query, SearchAttribute[] features) {
Raxa/RaxaMachineLearning
src/com/machine/learning/LearningModulesPool.java
// Path: src/com/learningmodule/association/conceptdrug/PredictionResult.java // public interface PredictionResult { // public double getConfidence(); // public Object getValue(); // } // // Path: src/com/machine/learning/interfaces/LearningModuleInterface.java // public interface LearningModuleInterface { // public void learn(); // public List<PredictionResult> predict(String query, SearchAttribute[] features); // } // // Path: src/com/machine/learning/request/SearchAttribute.java // public class SearchAttribute { // private String name; // private Object value; // // public SearchAttribute(String name, Object value) { // super(); // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // @Override // public String toString() { // return "SearchAttribute [name=" + name + ", value=" + value + "]"; // } // }
import java.util.Iterator; import java.util.LinkedList; import java.util.List; import org.apache.log4j.Logger; import com.learningmodule.association.conceptdrug.PredictionResult; import com.machine.learning.interfaces.LearningModuleInterface; import com.machine.learning.request.SearchAttribute;
package com.machine.learning; /* * The class contains the list of learning modules that are added by ContextListner on start of this service */ public class LearningModulesPool { // LinkedList of Learning Modules in this pool private static LinkedList<LearningModuleInterface> modules = new LinkedList<LearningModuleInterface>(); private static Logger log = Logger.getLogger(LearningModulesPool.class); // method to add a learning module in this pool public static void addLearningModule(LearningModuleInterface module) { modules.add(module); log.debug("Module Added: " + module.getClass()); } /* * method to get the results for a query from all modules in the pool and * merge them to return all the results */
// Path: src/com/learningmodule/association/conceptdrug/PredictionResult.java // public interface PredictionResult { // public double getConfidence(); // public Object getValue(); // } // // Path: src/com/machine/learning/interfaces/LearningModuleInterface.java // public interface LearningModuleInterface { // public void learn(); // public List<PredictionResult> predict(String query, SearchAttribute[] features); // } // // Path: src/com/machine/learning/request/SearchAttribute.java // public class SearchAttribute { // private String name; // private Object value; // // public SearchAttribute(String name, Object value) { // super(); // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // @Override // public String toString() { // return "SearchAttribute [name=" + name + ", value=" + value + "]"; // } // } // Path: src/com/machine/learning/LearningModulesPool.java import java.util.Iterator; import java.util.LinkedList; import java.util.List; import org.apache.log4j.Logger; import com.learningmodule.association.conceptdrug.PredictionResult; import com.machine.learning.interfaces.LearningModuleInterface; import com.machine.learning.request.SearchAttribute; package com.machine.learning; /* * The class contains the list of learning modules that are added by ContextListner on start of this service */ public class LearningModulesPool { // LinkedList of Learning Modules in this pool private static LinkedList<LearningModuleInterface> modules = new LinkedList<LearningModuleInterface>(); private static Logger log = Logger.getLogger(LearningModulesPool.class); // method to add a learning module in this pool public static void addLearningModule(LearningModuleInterface module) { modules.add(module); log.debug("Module Added: " + module.getClass()); } /* * method to get the results for a query from all modules in the pool and * merge them to return all the results */
public static LinkedList<PredictionResult> predict(String query, SearchAttribute[] features) {
Raxa/RaxaMachineLearning
src/com/machine/learning/interfaces/LearningModuleInterface.java
// Path: src/com/learningmodule/association/conceptdrug/PredictionResult.java // public interface PredictionResult { // public double getConfidence(); // public Object getValue(); // } // // Path: src/com/machine/learning/request/SearchAttribute.java // public class SearchAttribute { // private String name; // private Object value; // // public SearchAttribute(String name, Object value) { // super(); // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // @Override // public String toString() { // return "SearchAttribute [name=" + name + ", value=" + value + "]"; // } // }
import java.util.List; import com.learningmodule.association.conceptdrug.PredictionResult; import com.machine.learning.request.SearchAttribute;
package com.machine.learning.interfaces; public interface LearningModuleInterface { public void learn();
// Path: src/com/learningmodule/association/conceptdrug/PredictionResult.java // public interface PredictionResult { // public double getConfidence(); // public Object getValue(); // } // // Path: src/com/machine/learning/request/SearchAttribute.java // public class SearchAttribute { // private String name; // private Object value; // // public SearchAttribute(String name, Object value) { // super(); // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // @Override // public String toString() { // return "SearchAttribute [name=" + name + ", value=" + value + "]"; // } // } // Path: src/com/machine/learning/interfaces/LearningModuleInterface.java import java.util.List; import com.learningmodule.association.conceptdrug.PredictionResult; import com.machine.learning.request.SearchAttribute; package com.machine.learning.interfaces; public interface LearningModuleInterface { public void learn();
public List<PredictionResult> predict(String query, SearchAttribute[] features);
Raxa/RaxaMachineLearning
src/com/machine/learning/interfaces/LearningModuleInterface.java
// Path: src/com/learningmodule/association/conceptdrug/PredictionResult.java // public interface PredictionResult { // public double getConfidence(); // public Object getValue(); // } // // Path: src/com/machine/learning/request/SearchAttribute.java // public class SearchAttribute { // private String name; // private Object value; // // public SearchAttribute(String name, Object value) { // super(); // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // @Override // public String toString() { // return "SearchAttribute [name=" + name + ", value=" + value + "]"; // } // }
import java.util.List; import com.learningmodule.association.conceptdrug.PredictionResult; import com.machine.learning.request.SearchAttribute;
package com.machine.learning.interfaces; public interface LearningModuleInterface { public void learn();
// Path: src/com/learningmodule/association/conceptdrug/PredictionResult.java // public interface PredictionResult { // public double getConfidence(); // public Object getValue(); // } // // Path: src/com/machine/learning/request/SearchAttribute.java // public class SearchAttribute { // private String name; // private Object value; // // public SearchAttribute(String name, Object value) { // super(); // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // @Override // public String toString() { // return "SearchAttribute [name=" + name + ", value=" + value + "]"; // } // } // Path: src/com/machine/learning/interfaces/LearningModuleInterface.java import java.util.List; import com.learningmodule.association.conceptdrug.PredictionResult; import com.machine.learning.request.SearchAttribute; package com.machine.learning.interfaces; public interface LearningModuleInterface { public void learn();
public List<PredictionResult> predict(String query, SearchAttribute[] features);
Raxa/RaxaMachineLearning
src/com/learningmodule/association/conceptdrug/learning/CustomApriori.java
// Path: src/com/learningmodule/association/conceptdrug/model/EncounterIdConceptDrug.java // public class EncounterIdConceptDrug { // private int id; // private String drug, conceptId; // // public EncounterIdConceptDrug(int id, String drug, String conceptId) { // super(); // this.id = id; // this.drug = drug; // this.conceptId = conceptId; // } // // public int getEncounterId() { // return id; // } // public void setEncounterId(int id) { // this.id = id; // } // // public String getDrug() { // return drug; // } // public void setDrug(String drug) { // this.drug = drug; // } // public String getConceptId() { // return conceptId; // } // public void setConceptId(String conceptId) { // this.conceptId = conceptId; // } // } // // Path: src/com/learningmodule/association/conceptdrug/model/PredictionMatrix.java // public class PredictionMatrix implements Serializable { // /** // * // */ // private static final long serialVersionUID = 1L; // // // Prediction matrix is a hastable with key as concept_id and value as // // ConceptRow // Hashtable<String, ConceptRow> rows; // // public PredictionMatrix(int noOfConcepts) { // rows = new Hashtable<String, ConceptRow>(); // } // // /* // * method to get the list of drugs that are associated with a drugId // */ // public LinkedList<Cell> getDrugs(String conceptId) { // // if conceptId is present in the hash table then get the list of drugs // // related to it // if (rows.containsKey(conceptId)) { // return rows.get(conceptId).getDrugs(); // } // return null; // } // // /* // * method to get all the concepts which are related to some drug // */ // public LinkedList<String> getNonEmptyConcepts() { // Enumeration<String> temp = rows.keys(); // LinkedList<String> result = new LinkedList<String>(); // while (temp.hasMoreElements()) { // String key = temp.nextElement(); // if (!getDrugs(key).isEmpty()) { // result.add(key); // } // } // return result; // } // // /* // * method to add a new cell to Prediction matrix // */ // public void addCell(String concept, String drug, double conf) { // // if concept is already present in hast table put a new key value pair // // with key as this concept // if (!rows.containsKey(concept)) { // rows.put(concept, new ConceptRow(concept)); // } // // add the drug in conceptRow // rows.get(concept).addCell(drug, conf); // } // // @Override // public String toString() { // String result = ""; // int count = 0; // Enumeration<String> keys = rows.keys(); // while (keys.hasMoreElements()) { // result = result + rows.get(keys.nextElement()).toString() + "\n"; // count++; // } // return result + count; // } // // }
import java.util.HashSet; import java.util.Hashtable; import java.util.LinkedList; import com.learningmodule.association.conceptdrug.model.EncounterIdConceptDrug; import com.learningmodule.association.conceptdrug.model.PredictionMatrix;
package com.learningmodule.association.conceptdrug.learning; /* * Class for Apriori Algorithm designed specifically to find Diesease to Drug Association Rules. */ public class CustomApriori { // min support for association rules private double minSupport; private int minSupp; // minConfidence for association rules private double minConfidence; // associations rules generated by apriori algorithm private Hashtable<String, Row> rules; // constructor for this class public CustomApriori() { rules = new Hashtable<String, Row>(); } // constructor for this class given minSupport and minConfidence public CustomApriori(int minSupport, double minConfidence) { this.minSupport = minSupport; this.minConfidence = minConfidence; rules = new Hashtable<String, Row>(); } // function to increment count of a concept whenever a concepts is found // records private void incrementConceptCounts(HashSet<String> ids) { for (String id : ids) { rules.get(id).conceptCount++; } }
// Path: src/com/learningmodule/association/conceptdrug/model/EncounterIdConceptDrug.java // public class EncounterIdConceptDrug { // private int id; // private String drug, conceptId; // // public EncounterIdConceptDrug(int id, String drug, String conceptId) { // super(); // this.id = id; // this.drug = drug; // this.conceptId = conceptId; // } // // public int getEncounterId() { // return id; // } // public void setEncounterId(int id) { // this.id = id; // } // // public String getDrug() { // return drug; // } // public void setDrug(String drug) { // this.drug = drug; // } // public String getConceptId() { // return conceptId; // } // public void setConceptId(String conceptId) { // this.conceptId = conceptId; // } // } // // Path: src/com/learningmodule/association/conceptdrug/model/PredictionMatrix.java // public class PredictionMatrix implements Serializable { // /** // * // */ // private static final long serialVersionUID = 1L; // // // Prediction matrix is a hastable with key as concept_id and value as // // ConceptRow // Hashtable<String, ConceptRow> rows; // // public PredictionMatrix(int noOfConcepts) { // rows = new Hashtable<String, ConceptRow>(); // } // // /* // * method to get the list of drugs that are associated with a drugId // */ // public LinkedList<Cell> getDrugs(String conceptId) { // // if conceptId is present in the hash table then get the list of drugs // // related to it // if (rows.containsKey(conceptId)) { // return rows.get(conceptId).getDrugs(); // } // return null; // } // // /* // * method to get all the concepts which are related to some drug // */ // public LinkedList<String> getNonEmptyConcepts() { // Enumeration<String> temp = rows.keys(); // LinkedList<String> result = new LinkedList<String>(); // while (temp.hasMoreElements()) { // String key = temp.nextElement(); // if (!getDrugs(key).isEmpty()) { // result.add(key); // } // } // return result; // } // // /* // * method to add a new cell to Prediction matrix // */ // public void addCell(String concept, String drug, double conf) { // // if concept is already present in hast table put a new key value pair // // with key as this concept // if (!rows.containsKey(concept)) { // rows.put(concept, new ConceptRow(concept)); // } // // add the drug in conceptRow // rows.get(concept).addCell(drug, conf); // } // // @Override // public String toString() { // String result = ""; // int count = 0; // Enumeration<String> keys = rows.keys(); // while (keys.hasMoreElements()) { // result = result + rows.get(keys.nextElement()).toString() + "\n"; // count++; // } // return result + count; // } // // } // Path: src/com/learningmodule/association/conceptdrug/learning/CustomApriori.java import java.util.HashSet; import java.util.Hashtable; import java.util.LinkedList; import com.learningmodule.association.conceptdrug.model.EncounterIdConceptDrug; import com.learningmodule.association.conceptdrug.model.PredictionMatrix; package com.learningmodule.association.conceptdrug.learning; /* * Class for Apriori Algorithm designed specifically to find Diesease to Drug Association Rules. */ public class CustomApriori { // min support for association rules private double minSupport; private int minSupp; // minConfidence for association rules private double minConfidence; // associations rules generated by apriori algorithm private Hashtable<String, Row> rules; // constructor for this class public CustomApriori() { rules = new Hashtable<String, Row>(); } // constructor for this class given minSupport and minConfidence public CustomApriori(int minSupport, double minConfidence) { this.minSupport = minSupport; this.minConfidence = minConfidence; rules = new Hashtable<String, Row>(); } // function to increment count of a concept whenever a concepts is found // records private void incrementConceptCounts(HashSet<String> ids) { for (String id : ids) { rules.get(id).conceptCount++; } }
public PredictionMatrix buildAssociations(LinkedList<EncounterIdConceptDrug> data) {
Raxa/RaxaMachineLearning
src/com/learningmodule/association/conceptdrug/learning/CustomApriori.java
// Path: src/com/learningmodule/association/conceptdrug/model/EncounterIdConceptDrug.java // public class EncounterIdConceptDrug { // private int id; // private String drug, conceptId; // // public EncounterIdConceptDrug(int id, String drug, String conceptId) { // super(); // this.id = id; // this.drug = drug; // this.conceptId = conceptId; // } // // public int getEncounterId() { // return id; // } // public void setEncounterId(int id) { // this.id = id; // } // // public String getDrug() { // return drug; // } // public void setDrug(String drug) { // this.drug = drug; // } // public String getConceptId() { // return conceptId; // } // public void setConceptId(String conceptId) { // this.conceptId = conceptId; // } // } // // Path: src/com/learningmodule/association/conceptdrug/model/PredictionMatrix.java // public class PredictionMatrix implements Serializable { // /** // * // */ // private static final long serialVersionUID = 1L; // // // Prediction matrix is a hastable with key as concept_id and value as // // ConceptRow // Hashtable<String, ConceptRow> rows; // // public PredictionMatrix(int noOfConcepts) { // rows = new Hashtable<String, ConceptRow>(); // } // // /* // * method to get the list of drugs that are associated with a drugId // */ // public LinkedList<Cell> getDrugs(String conceptId) { // // if conceptId is present in the hash table then get the list of drugs // // related to it // if (rows.containsKey(conceptId)) { // return rows.get(conceptId).getDrugs(); // } // return null; // } // // /* // * method to get all the concepts which are related to some drug // */ // public LinkedList<String> getNonEmptyConcepts() { // Enumeration<String> temp = rows.keys(); // LinkedList<String> result = new LinkedList<String>(); // while (temp.hasMoreElements()) { // String key = temp.nextElement(); // if (!getDrugs(key).isEmpty()) { // result.add(key); // } // } // return result; // } // // /* // * method to add a new cell to Prediction matrix // */ // public void addCell(String concept, String drug, double conf) { // // if concept is already present in hast table put a new key value pair // // with key as this concept // if (!rows.containsKey(concept)) { // rows.put(concept, new ConceptRow(concept)); // } // // add the drug in conceptRow // rows.get(concept).addCell(drug, conf); // } // // @Override // public String toString() { // String result = ""; // int count = 0; // Enumeration<String> keys = rows.keys(); // while (keys.hasMoreElements()) { // result = result + rows.get(keys.nextElement()).toString() + "\n"; // count++; // } // return result + count; // } // // }
import java.util.HashSet; import java.util.Hashtable; import java.util.LinkedList; import com.learningmodule.association.conceptdrug.model.EncounterIdConceptDrug; import com.learningmodule.association.conceptdrug.model.PredictionMatrix;
package com.learningmodule.association.conceptdrug.learning; /* * Class for Apriori Algorithm designed specifically to find Diesease to Drug Association Rules. */ public class CustomApriori { // min support for association rules private double minSupport; private int minSupp; // minConfidence for association rules private double minConfidence; // associations rules generated by apriori algorithm private Hashtable<String, Row> rules; // constructor for this class public CustomApriori() { rules = new Hashtable<String, Row>(); } // constructor for this class given minSupport and minConfidence public CustomApriori(int minSupport, double minConfidence) { this.minSupport = minSupport; this.minConfidence = minConfidence; rules = new Hashtable<String, Row>(); } // function to increment count of a concept whenever a concepts is found // records private void incrementConceptCounts(HashSet<String> ids) { for (String id : ids) { rules.get(id).conceptCount++; } }
// Path: src/com/learningmodule/association/conceptdrug/model/EncounterIdConceptDrug.java // public class EncounterIdConceptDrug { // private int id; // private String drug, conceptId; // // public EncounterIdConceptDrug(int id, String drug, String conceptId) { // super(); // this.id = id; // this.drug = drug; // this.conceptId = conceptId; // } // // public int getEncounterId() { // return id; // } // public void setEncounterId(int id) { // this.id = id; // } // // public String getDrug() { // return drug; // } // public void setDrug(String drug) { // this.drug = drug; // } // public String getConceptId() { // return conceptId; // } // public void setConceptId(String conceptId) { // this.conceptId = conceptId; // } // } // // Path: src/com/learningmodule/association/conceptdrug/model/PredictionMatrix.java // public class PredictionMatrix implements Serializable { // /** // * // */ // private static final long serialVersionUID = 1L; // // // Prediction matrix is a hastable with key as concept_id and value as // // ConceptRow // Hashtable<String, ConceptRow> rows; // // public PredictionMatrix(int noOfConcepts) { // rows = new Hashtable<String, ConceptRow>(); // } // // /* // * method to get the list of drugs that are associated with a drugId // */ // public LinkedList<Cell> getDrugs(String conceptId) { // // if conceptId is present in the hash table then get the list of drugs // // related to it // if (rows.containsKey(conceptId)) { // return rows.get(conceptId).getDrugs(); // } // return null; // } // // /* // * method to get all the concepts which are related to some drug // */ // public LinkedList<String> getNonEmptyConcepts() { // Enumeration<String> temp = rows.keys(); // LinkedList<String> result = new LinkedList<String>(); // while (temp.hasMoreElements()) { // String key = temp.nextElement(); // if (!getDrugs(key).isEmpty()) { // result.add(key); // } // } // return result; // } // // /* // * method to add a new cell to Prediction matrix // */ // public void addCell(String concept, String drug, double conf) { // // if concept is already present in hast table put a new key value pair // // with key as this concept // if (!rows.containsKey(concept)) { // rows.put(concept, new ConceptRow(concept)); // } // // add the drug in conceptRow // rows.get(concept).addCell(drug, conf); // } // // @Override // public String toString() { // String result = ""; // int count = 0; // Enumeration<String> keys = rows.keys(); // while (keys.hasMoreElements()) { // result = result + rows.get(keys.nextElement()).toString() + "\n"; // count++; // } // return result + count; // } // // } // Path: src/com/learningmodule/association/conceptdrug/learning/CustomApriori.java import java.util.HashSet; import java.util.Hashtable; import java.util.LinkedList; import com.learningmodule.association.conceptdrug.model.EncounterIdConceptDrug; import com.learningmodule.association.conceptdrug.model.PredictionMatrix; package com.learningmodule.association.conceptdrug.learning; /* * Class for Apriori Algorithm designed specifically to find Diesease to Drug Association Rules. */ public class CustomApriori { // min support for association rules private double minSupport; private int minSupp; // minConfidence for association rules private double minConfidence; // associations rules generated by apriori algorithm private Hashtable<String, Row> rules; // constructor for this class public CustomApriori() { rules = new Hashtable<String, Row>(); } // constructor for this class given minSupport and minConfidence public CustomApriori(int minSupport, double minConfidence) { this.minSupport = minSupport; this.minConfidence = minConfidence; rules = new Hashtable<String, Row>(); } // function to increment count of a concept whenever a concepts is found // records private void incrementConceptCounts(HashSet<String> ids) { for (String id : ids) { rules.get(id).conceptCount++; } }
public PredictionMatrix buildAssociations(LinkedList<EncounterIdConceptDrug> data) {
Raxa/RaxaMachineLearning
src/com/learningmodule/association/conceptdrug/multifeature/ConceptDrugLearningMultiFeatureModule.java
// Path: src/com/learningmodule/association/conceptdrug/ConceptDrugDatabaseInterface.java // public interface ConceptDrugDatabaseInterface { // // /* // * get name of file that will contain the prediction matrix generated by // * algorithm // */ // public String getMatrixFileName(); // // /* // * Method to get all the medical records containing encounterId(integer that // * represent an id for prescriptions written for a patient), // * ConceptId(integer that represent a diagnosis/diseases/observation for // * patient has been treated), DrugId(integer representing a drug that was // * written in the prescription) // */ // public LinkedList<EncounterIdConceptDrug> getData(); // // /* // * Method to get the medical records with given list of concepts Ids contaning encounterId, conceptId, DrugId, // * and feature related to medical records like age of patient, location of doctor/patient etc. // */ // // public LinkedList<EncounterIdConceptFeaturesDrugModel> getDataByConceptIds(LinkedList<String> ids); // // /* // * Method to get the list of conceptId and concept_name for given list of conceptId(integer) // */ // // public LinkedList<ConceptNameModel> getConceptIdNameByConceptIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of Drugs for given drugIds(integers) // */ // public LinkedList<AbstractDrugModel> getDrugInfoByDrugIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of all conceptId and concept_words // */ // public LinkedList<ConceptWordModel> getConceptWords(); // } // // Path: src/com/learningmodule/association/conceptdrug/PredictionResult.java // public interface PredictionResult { // public double getConfidence(); // public Object getValue(); // } // // Path: src/com/machine/learning/interfaces/LearningModuleInterface.java // public interface LearningModuleInterface { // public void learn(); // public List<PredictionResult> predict(String query, SearchAttribute[] features); // } // // Path: src/com/machine/learning/request/SearchAttribute.java // public class SearchAttribute { // private String name; // private Object value; // // public SearchAttribute(String name, Object value) { // super(); // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // @Override // public String toString() { // return "SearchAttribute [name=" + name + ", value=" + value + "]"; // } // }
import java.util.List; import com.learningmodule.association.conceptdrug.ConceptDrugDatabaseInterface; import com.learningmodule.association.conceptdrug.PredictionResult; import com.machine.learning.interfaces.LearningModuleInterface; import com.machine.learning.request.SearchAttribute;
package com.learningmodule.association.conceptdrug.multifeature; public class ConceptDrugLearningMultiFeatureModule implements LearningModuleInterface { private PredictionMethod predictionMethod; // min support for association rules private int minSupport = 1; // minConfidence for association rules private double minConfidence = 0.3;
// Path: src/com/learningmodule/association/conceptdrug/ConceptDrugDatabaseInterface.java // public interface ConceptDrugDatabaseInterface { // // /* // * get name of file that will contain the prediction matrix generated by // * algorithm // */ // public String getMatrixFileName(); // // /* // * Method to get all the medical records containing encounterId(integer that // * represent an id for prescriptions written for a patient), // * ConceptId(integer that represent a diagnosis/diseases/observation for // * patient has been treated), DrugId(integer representing a drug that was // * written in the prescription) // */ // public LinkedList<EncounterIdConceptDrug> getData(); // // /* // * Method to get the medical records with given list of concepts Ids contaning encounterId, conceptId, DrugId, // * and feature related to medical records like age of patient, location of doctor/patient etc. // */ // // public LinkedList<EncounterIdConceptFeaturesDrugModel> getDataByConceptIds(LinkedList<String> ids); // // /* // * Method to get the list of conceptId and concept_name for given list of conceptId(integer) // */ // // public LinkedList<ConceptNameModel> getConceptIdNameByConceptIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of Drugs for given drugIds(integers) // */ // public LinkedList<AbstractDrugModel> getDrugInfoByDrugIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of all conceptId and concept_words // */ // public LinkedList<ConceptWordModel> getConceptWords(); // } // // Path: src/com/learningmodule/association/conceptdrug/PredictionResult.java // public interface PredictionResult { // public double getConfidence(); // public Object getValue(); // } // // Path: src/com/machine/learning/interfaces/LearningModuleInterface.java // public interface LearningModuleInterface { // public void learn(); // public List<PredictionResult> predict(String query, SearchAttribute[] features); // } // // Path: src/com/machine/learning/request/SearchAttribute.java // public class SearchAttribute { // private String name; // private Object value; // // public SearchAttribute(String name, Object value) { // super(); // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // @Override // public String toString() { // return "SearchAttribute [name=" + name + ", value=" + value + "]"; // } // } // Path: src/com/learningmodule/association/conceptdrug/multifeature/ConceptDrugLearningMultiFeatureModule.java import java.util.List; import com.learningmodule.association.conceptdrug.ConceptDrugDatabaseInterface; import com.learningmodule.association.conceptdrug.PredictionResult; import com.machine.learning.interfaces.LearningModuleInterface; import com.machine.learning.request.SearchAttribute; package com.learningmodule.association.conceptdrug.multifeature; public class ConceptDrugLearningMultiFeatureModule implements LearningModuleInterface { private PredictionMethod predictionMethod; // min support for association rules private int minSupport = 1; // minConfidence for association rules private double minConfidence = 0.3;
private ConceptDrugDatabaseInterface databaseInterface;
Raxa/RaxaMachineLearning
src/com/learningmodule/association/conceptdrug/multifeature/ConceptDrugLearningMultiFeatureModule.java
// Path: src/com/learningmodule/association/conceptdrug/ConceptDrugDatabaseInterface.java // public interface ConceptDrugDatabaseInterface { // // /* // * get name of file that will contain the prediction matrix generated by // * algorithm // */ // public String getMatrixFileName(); // // /* // * Method to get all the medical records containing encounterId(integer that // * represent an id for prescriptions written for a patient), // * ConceptId(integer that represent a diagnosis/diseases/observation for // * patient has been treated), DrugId(integer representing a drug that was // * written in the prescription) // */ // public LinkedList<EncounterIdConceptDrug> getData(); // // /* // * Method to get the medical records with given list of concepts Ids contaning encounterId, conceptId, DrugId, // * and feature related to medical records like age of patient, location of doctor/patient etc. // */ // // public LinkedList<EncounterIdConceptFeaturesDrugModel> getDataByConceptIds(LinkedList<String> ids); // // /* // * Method to get the list of conceptId and concept_name for given list of conceptId(integer) // */ // // public LinkedList<ConceptNameModel> getConceptIdNameByConceptIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of Drugs for given drugIds(integers) // */ // public LinkedList<AbstractDrugModel> getDrugInfoByDrugIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of all conceptId and concept_words // */ // public LinkedList<ConceptWordModel> getConceptWords(); // } // // Path: src/com/learningmodule/association/conceptdrug/PredictionResult.java // public interface PredictionResult { // public double getConfidence(); // public Object getValue(); // } // // Path: src/com/machine/learning/interfaces/LearningModuleInterface.java // public interface LearningModuleInterface { // public void learn(); // public List<PredictionResult> predict(String query, SearchAttribute[] features); // } // // Path: src/com/machine/learning/request/SearchAttribute.java // public class SearchAttribute { // private String name; // private Object value; // // public SearchAttribute(String name, Object value) { // super(); // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // @Override // public String toString() { // return "SearchAttribute [name=" + name + ", value=" + value + "]"; // } // }
import java.util.List; import com.learningmodule.association.conceptdrug.ConceptDrugDatabaseInterface; import com.learningmodule.association.conceptdrug.PredictionResult; import com.machine.learning.interfaces.LearningModuleInterface; import com.machine.learning.request.SearchAttribute;
package com.learningmodule.association.conceptdrug.multifeature; public class ConceptDrugLearningMultiFeatureModule implements LearningModuleInterface { private PredictionMethod predictionMethod; // min support for association rules private int minSupport = 1; // minConfidence for association rules private double minConfidence = 0.3; private ConceptDrugDatabaseInterface databaseInterface; public ConceptDrugLearningMultiFeatureModule(ConceptDrugDatabaseInterface databaseInterface) { this.databaseInterface = databaseInterface; predictionMethod = new PredictionMethod(minSupport, minConfidence, databaseInterface); } @Override public void learn() { predictionMethod = new PredictionMethod(minSupport, minConfidence, databaseInterface); } @Override
// Path: src/com/learningmodule/association/conceptdrug/ConceptDrugDatabaseInterface.java // public interface ConceptDrugDatabaseInterface { // // /* // * get name of file that will contain the prediction matrix generated by // * algorithm // */ // public String getMatrixFileName(); // // /* // * Method to get all the medical records containing encounterId(integer that // * represent an id for prescriptions written for a patient), // * ConceptId(integer that represent a diagnosis/diseases/observation for // * patient has been treated), DrugId(integer representing a drug that was // * written in the prescription) // */ // public LinkedList<EncounterIdConceptDrug> getData(); // // /* // * Method to get the medical records with given list of concepts Ids contaning encounterId, conceptId, DrugId, // * and feature related to medical records like age of patient, location of doctor/patient etc. // */ // // public LinkedList<EncounterIdConceptFeaturesDrugModel> getDataByConceptIds(LinkedList<String> ids); // // /* // * Method to get the list of conceptId and concept_name for given list of conceptId(integer) // */ // // public LinkedList<ConceptNameModel> getConceptIdNameByConceptIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of Drugs for given drugIds(integers) // */ // public LinkedList<AbstractDrugModel> getDrugInfoByDrugIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of all conceptId and concept_words // */ // public LinkedList<ConceptWordModel> getConceptWords(); // } // // Path: src/com/learningmodule/association/conceptdrug/PredictionResult.java // public interface PredictionResult { // public double getConfidence(); // public Object getValue(); // } // // Path: src/com/machine/learning/interfaces/LearningModuleInterface.java // public interface LearningModuleInterface { // public void learn(); // public List<PredictionResult> predict(String query, SearchAttribute[] features); // } // // Path: src/com/machine/learning/request/SearchAttribute.java // public class SearchAttribute { // private String name; // private Object value; // // public SearchAttribute(String name, Object value) { // super(); // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // @Override // public String toString() { // return "SearchAttribute [name=" + name + ", value=" + value + "]"; // } // } // Path: src/com/learningmodule/association/conceptdrug/multifeature/ConceptDrugLearningMultiFeatureModule.java import java.util.List; import com.learningmodule.association.conceptdrug.ConceptDrugDatabaseInterface; import com.learningmodule.association.conceptdrug.PredictionResult; import com.machine.learning.interfaces.LearningModuleInterface; import com.machine.learning.request.SearchAttribute; package com.learningmodule.association.conceptdrug.multifeature; public class ConceptDrugLearningMultiFeatureModule implements LearningModuleInterface { private PredictionMethod predictionMethod; // min support for association rules private int minSupport = 1; // minConfidence for association rules private double minConfidence = 0.3; private ConceptDrugDatabaseInterface databaseInterface; public ConceptDrugLearningMultiFeatureModule(ConceptDrugDatabaseInterface databaseInterface) { this.databaseInterface = databaseInterface; predictionMethod = new PredictionMethod(minSupport, minConfidence, databaseInterface); } @Override public void learn() { predictionMethod = new PredictionMethod(minSupport, minConfidence, databaseInterface); } @Override
public List<PredictionResult> predict(String query, SearchAttribute[] features) {
Raxa/RaxaMachineLearning
src/com/learningmodule/association/conceptdrug/multifeature/ConceptDrugLearningMultiFeatureModule.java
// Path: src/com/learningmodule/association/conceptdrug/ConceptDrugDatabaseInterface.java // public interface ConceptDrugDatabaseInterface { // // /* // * get name of file that will contain the prediction matrix generated by // * algorithm // */ // public String getMatrixFileName(); // // /* // * Method to get all the medical records containing encounterId(integer that // * represent an id for prescriptions written for a patient), // * ConceptId(integer that represent a diagnosis/diseases/observation for // * patient has been treated), DrugId(integer representing a drug that was // * written in the prescription) // */ // public LinkedList<EncounterIdConceptDrug> getData(); // // /* // * Method to get the medical records with given list of concepts Ids contaning encounterId, conceptId, DrugId, // * and feature related to medical records like age of patient, location of doctor/patient etc. // */ // // public LinkedList<EncounterIdConceptFeaturesDrugModel> getDataByConceptIds(LinkedList<String> ids); // // /* // * Method to get the list of conceptId and concept_name for given list of conceptId(integer) // */ // // public LinkedList<ConceptNameModel> getConceptIdNameByConceptIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of Drugs for given drugIds(integers) // */ // public LinkedList<AbstractDrugModel> getDrugInfoByDrugIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of all conceptId and concept_words // */ // public LinkedList<ConceptWordModel> getConceptWords(); // } // // Path: src/com/learningmodule/association/conceptdrug/PredictionResult.java // public interface PredictionResult { // public double getConfidence(); // public Object getValue(); // } // // Path: src/com/machine/learning/interfaces/LearningModuleInterface.java // public interface LearningModuleInterface { // public void learn(); // public List<PredictionResult> predict(String query, SearchAttribute[] features); // } // // Path: src/com/machine/learning/request/SearchAttribute.java // public class SearchAttribute { // private String name; // private Object value; // // public SearchAttribute(String name, Object value) { // super(); // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // @Override // public String toString() { // return "SearchAttribute [name=" + name + ", value=" + value + "]"; // } // }
import java.util.List; import com.learningmodule.association.conceptdrug.ConceptDrugDatabaseInterface; import com.learningmodule.association.conceptdrug.PredictionResult; import com.machine.learning.interfaces.LearningModuleInterface; import com.machine.learning.request.SearchAttribute;
package com.learningmodule.association.conceptdrug.multifeature; public class ConceptDrugLearningMultiFeatureModule implements LearningModuleInterface { private PredictionMethod predictionMethod; // min support for association rules private int minSupport = 1; // minConfidence for association rules private double minConfidence = 0.3; private ConceptDrugDatabaseInterface databaseInterface; public ConceptDrugLearningMultiFeatureModule(ConceptDrugDatabaseInterface databaseInterface) { this.databaseInterface = databaseInterface; predictionMethod = new PredictionMethod(minSupport, minConfidence, databaseInterface); } @Override public void learn() { predictionMethod = new PredictionMethod(minSupport, minConfidence, databaseInterface); } @Override
// Path: src/com/learningmodule/association/conceptdrug/ConceptDrugDatabaseInterface.java // public interface ConceptDrugDatabaseInterface { // // /* // * get name of file that will contain the prediction matrix generated by // * algorithm // */ // public String getMatrixFileName(); // // /* // * Method to get all the medical records containing encounterId(integer that // * represent an id for prescriptions written for a patient), // * ConceptId(integer that represent a diagnosis/diseases/observation for // * patient has been treated), DrugId(integer representing a drug that was // * written in the prescription) // */ // public LinkedList<EncounterIdConceptDrug> getData(); // // /* // * Method to get the medical records with given list of concepts Ids contaning encounterId, conceptId, DrugId, // * and feature related to medical records like age of patient, location of doctor/patient etc. // */ // // public LinkedList<EncounterIdConceptFeaturesDrugModel> getDataByConceptIds(LinkedList<String> ids); // // /* // * Method to get the list of conceptId and concept_name for given list of conceptId(integer) // */ // // public LinkedList<ConceptNameModel> getConceptIdNameByConceptIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of Drugs for given drugIds(integers) // */ // public LinkedList<AbstractDrugModel> getDrugInfoByDrugIds(LinkedList<String> conceptIds); // // /* // * Method to get the list of all conceptId and concept_words // */ // public LinkedList<ConceptWordModel> getConceptWords(); // } // // Path: src/com/learningmodule/association/conceptdrug/PredictionResult.java // public interface PredictionResult { // public double getConfidence(); // public Object getValue(); // } // // Path: src/com/machine/learning/interfaces/LearningModuleInterface.java // public interface LearningModuleInterface { // public void learn(); // public List<PredictionResult> predict(String query, SearchAttribute[] features); // } // // Path: src/com/machine/learning/request/SearchAttribute.java // public class SearchAttribute { // private String name; // private Object value; // // public SearchAttribute(String name, Object value) { // super(); // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // @Override // public String toString() { // return "SearchAttribute [name=" + name + ", value=" + value + "]"; // } // } // Path: src/com/learningmodule/association/conceptdrug/multifeature/ConceptDrugLearningMultiFeatureModule.java import java.util.List; import com.learningmodule.association.conceptdrug.ConceptDrugDatabaseInterface; import com.learningmodule.association.conceptdrug.PredictionResult; import com.machine.learning.interfaces.LearningModuleInterface; import com.machine.learning.request.SearchAttribute; package com.learningmodule.association.conceptdrug.multifeature; public class ConceptDrugLearningMultiFeatureModule implements LearningModuleInterface { private PredictionMethod predictionMethod; // min support for association rules private int minSupport = 1; // minConfidence for association rules private double minConfidence = 0.3; private ConceptDrugDatabaseInterface databaseInterface; public ConceptDrugLearningMultiFeatureModule(ConceptDrugDatabaseInterface databaseInterface) { this.databaseInterface = databaseInterface; predictionMethod = new PredictionMethod(minSupport, minConfidence, databaseInterface); } @Override public void learn() { predictionMethod = new PredictionMethod(minSupport, minConfidence, databaseInterface); } @Override
public List<PredictionResult> predict(String query, SearchAttribute[] features) {
Vhati/OpenUHS
core/src/main/java/net/vhati/openuhs/core/markup/Version88StringDecorator.java
// Path: core/src/main/java/net/vhati/openuhs/core/markup/DecoratedFragment.java // public class DecoratedFragment { // public String fragment = null; // public String[] attributes = null; // public Map[] argMaps = null; // // // public DecoratedFragment( String fragment, String[] attributes, Map[] argMaps ) { // this.fragment = fragment; // this.attributes = attributes; // this.argMaps = argMaps; // } // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/StringDecorator.java // public abstract class StringDecorator { // /** The sequence representing line breaks, as expected from the parser. */ // public static final char[] linebreak = new char[] {'^','b','r','e','a','k','^'}; // // // public abstract DecoratedFragment[] getDecoratedString( String rawContent ); // }
import java.util.Arrays; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import net.vhati.openuhs.core.markup.DecoratedFragment; import net.vhati.openuhs.core.markup.StringDecorator;
package net.vhati.openuhs.core.markup; /** * A StringDecorator ancestor. * <p> * This doesn't actually decorate anything. */ public class Version88StringDecorator extends StringDecorator { public Version88StringDecorator() { super(); } @Override
// Path: core/src/main/java/net/vhati/openuhs/core/markup/DecoratedFragment.java // public class DecoratedFragment { // public String fragment = null; // public String[] attributes = null; // public Map[] argMaps = null; // // // public DecoratedFragment( String fragment, String[] attributes, Map[] argMaps ) { // this.fragment = fragment; // this.attributes = attributes; // this.argMaps = argMaps; // } // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/StringDecorator.java // public abstract class StringDecorator { // /** The sequence representing line breaks, as expected from the parser. */ // public static final char[] linebreak = new char[] {'^','b','r','e','a','k','^'}; // // // public abstract DecoratedFragment[] getDecoratedString( String rawContent ); // } // Path: core/src/main/java/net/vhati/openuhs/core/markup/Version88StringDecorator.java import java.util.Arrays; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import net.vhati.openuhs.core.markup.DecoratedFragment; import net.vhati.openuhs.core.markup.StringDecorator; package net.vhati.openuhs.core.markup; /** * A StringDecorator ancestor. * <p> * This doesn't actually decorate anything. */ public class Version88StringDecorator extends StringDecorator { public Version88StringDecorator() { super(); } @Override
public DecoratedFragment[] getDecoratedString( String rawContent ) {
Vhati/OpenUHS
android-reader/src/main/java/net/vhati/openuhs/androidreader/downloader/UHSFetchTask.java
// Path: android-reader/src/main/java/net/vhati/openuhs/androidreader/downloader/FetchUnitException.java // public class FetchUnitException extends Exception { // // // public FetchUnitException() { // } // // public FetchUnitException( String message ) { // super(message); // } // // public FetchUnitException( Throwable cause ) { // super( cause ); // } // // public FetchUnitException( String message, Throwable cause ) { // super( message, cause ); // } // } // // Path: core/src/main/java/net/vhati/openuhs/core/downloader/CatalogItem.java // public class CatalogItem { // private String title = ""; // private String url = ""; // private String name = ""; // private Date date = null; // private String compressedSize = ""; // private String fullSize = ""; // // private boolean stateLocal = false; // private boolean stateNewer = false; // // // public CatalogItem() { // } // // // public void setTitle( String s ) { // title = (( s != null ) ? s : ""); // } // // public String getTitle() { // return title; // } // // public void setUrl( String s ) { // url = (( s != null ) ? s : ""); // } // // public String getUrl() { // return url; // } // // public void setName( String s ) { // name = (( s != null ) ? s : ""); // } // // public String getName() { // return name; // } // // public void setDate( Date d ) { // date = d; // } // // public Date getDate() { // return date; // } // // /** // * Sets the reported size of the zip file that wraps the UHS file. // */ // public void setCompressedSize( String s ) { // compressedSize = (( s != null ) ? s : ""); // } // // public String getCompressedSize() { // return compressedSize; // } // // /** // * Sets the reported size of the UHS file, once extracted from the zip file. // */ // public void setFullSize( String s ) { // fullSize = (( s != null ) ? s : ""); // } // // public String getFullSize() { // return fullSize; // } // // // /** // * Sets whether there is a local file with this catalog entry's name. // * // * @see #resetState() // */ // public void setLocal( boolean b ) { // stateLocal = b; // } // // public boolean isLocal() { // return stateLocal; // } // // /** // * Sets whether the catalog entry is newer than the local file. // * // * @see #resetState() // */ // public void setNewer( boolean b ) { // stateNewer = b; // } // // public boolean isNewer() { // return stateNewer; // } // // /** // * Resets the catalog-vs-local state flage. // * // * @see #setLocal(boolean) // * @see #setNewer(boolean) // */ // public void resetState() { // setLocal( false ); // setNewer( false ); // } // // // @Override // public String toString() { // return getTitle(); // } // }
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.util.zip.ZipInputStream; import java.util.zip.ZipEntry; import android.os.AsyncTask; import net.vhati.openuhs.androidreader.downloader.FetchUnitException; import net.vhati.openuhs.core.downloader.CatalogItem;
public void setUserAgent( String s ) { this.userAgent = s; } public String getUserAgent() { return userAgent; } // This runs in a background thread, unlike the other methods here. @Override protected UHSFetchResult doInBackground( CatalogItem... catItems ) { CatalogItem catItem = catItems[0]; UHSFetchResult fetchResult = new UHSFetchResult( catItem ); HttpURLConnection con = null; InputStream downloadStream = null; ZipInputStream unzipStream = null; OutputStream os = null; File uhsFile = null; String urlString = catItem.getUrl(); Exception ex = null; try { con = (HttpURLConnection)(new URL( urlString ).openConnection()); con.setRequestProperty( "User-Agent", userAgent ); con.connect(); if ( con.getResponseCode() != HttpURLConnection.HTTP_OK ) {
// Path: android-reader/src/main/java/net/vhati/openuhs/androidreader/downloader/FetchUnitException.java // public class FetchUnitException extends Exception { // // // public FetchUnitException() { // } // // public FetchUnitException( String message ) { // super(message); // } // // public FetchUnitException( Throwable cause ) { // super( cause ); // } // // public FetchUnitException( String message, Throwable cause ) { // super( message, cause ); // } // } // // Path: core/src/main/java/net/vhati/openuhs/core/downloader/CatalogItem.java // public class CatalogItem { // private String title = ""; // private String url = ""; // private String name = ""; // private Date date = null; // private String compressedSize = ""; // private String fullSize = ""; // // private boolean stateLocal = false; // private boolean stateNewer = false; // // // public CatalogItem() { // } // // // public void setTitle( String s ) { // title = (( s != null ) ? s : ""); // } // // public String getTitle() { // return title; // } // // public void setUrl( String s ) { // url = (( s != null ) ? s : ""); // } // // public String getUrl() { // return url; // } // // public void setName( String s ) { // name = (( s != null ) ? s : ""); // } // // public String getName() { // return name; // } // // public void setDate( Date d ) { // date = d; // } // // public Date getDate() { // return date; // } // // /** // * Sets the reported size of the zip file that wraps the UHS file. // */ // public void setCompressedSize( String s ) { // compressedSize = (( s != null ) ? s : ""); // } // // public String getCompressedSize() { // return compressedSize; // } // // /** // * Sets the reported size of the UHS file, once extracted from the zip file. // */ // public void setFullSize( String s ) { // fullSize = (( s != null ) ? s : ""); // } // // public String getFullSize() { // return fullSize; // } // // // /** // * Sets whether there is a local file with this catalog entry's name. // * // * @see #resetState() // */ // public void setLocal( boolean b ) { // stateLocal = b; // } // // public boolean isLocal() { // return stateLocal; // } // // /** // * Sets whether the catalog entry is newer than the local file. // * // * @see #resetState() // */ // public void setNewer( boolean b ) { // stateNewer = b; // } // // public boolean isNewer() { // return stateNewer; // } // // /** // * Resets the catalog-vs-local state flage. // * // * @see #setLocal(boolean) // * @see #setNewer(boolean) // */ // public void resetState() { // setLocal( false ); // setNewer( false ); // } // // // @Override // public String toString() { // return getTitle(); // } // } // Path: android-reader/src/main/java/net/vhati/openuhs/androidreader/downloader/UHSFetchTask.java import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.util.zip.ZipInputStream; import java.util.zip.ZipEntry; import android.os.AsyncTask; import net.vhati.openuhs.androidreader.downloader.FetchUnitException; import net.vhati.openuhs.core.downloader.CatalogItem; public void setUserAgent( String s ) { this.userAgent = s; } public String getUserAgent() { return userAgent; } // This runs in a background thread, unlike the other methods here. @Override protected UHSFetchResult doInBackground( CatalogItem... catItems ) { CatalogItem catItem = catItems[0]; UHSFetchResult fetchResult = new UHSFetchResult( catItem ); HttpURLConnection con = null; InputStream downloadStream = null; ZipInputStream unzipStream = null; OutputStream os = null; File uhsFile = null; String urlString = catItem.getUrl(); Exception ex = null; try { con = (HttpURLConnection)(new URL( urlString ).openConnection()); con.setRequestProperty( "User-Agent", userAgent ); con.connect(); if ( con.getResponseCode() != HttpURLConnection.HTTP_OK ) {
throw new FetchUnitException( "Server returned HTTP "+ con.getResponseCode() +" "+ con.getResponseMessage() );
Vhati/OpenUHS
desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/FieldEditorPanel.java
// Path: desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/RegexDocument.java // public class RegexDocument extends PlainDocument { // private boolean dontCheck = false; // private Pattern p = null; // // // public RegexDocument( String regex ) { // if ( regex == null || regex.length() == 0 ) dontCheck = true; // // try { // p = Pattern.compile( regex ); // } // catch ( PatternSyntaxException e ) { // dontCheck = true; // } // } // // public RegexDocument() { // dontCheck = true; // } // // // @Override // public void insertString( int offs, String str, AttributeSet a ) throws BadLocationException { // if ( str == null ) return; // // boolean proceed = true; // // if ( dontCheck == false ) { // String tmp = super.getText( 0, offs ) + str + (( super.getLength() > offs ) ? super.getText( offs,super.getLength()-offs ) : ""); // Matcher m = p.matcher( tmp ); // proceed = m.matches(); // } // // if ( proceed == true ) super.insertString( offs, str, a ); // } // // // @Override // public void remove( int offs, int len ) throws BadLocationException { // boolean proceed = true; // // if ( dontCheck == false ) { // try { // String tmp = super.getText( 0, offs ) + (( super.getLength() > (offs+len) ) ? super.getText( offs+len, super.getLength()-(offs+len) ) : ""); // Matcher m = p.matcher( tmp ); // proceed = m.matches(); // } // catch ( BadLocationException e ) { // } // } // // if ( proceed == true ) super.remove( offs, len ); // } // }
import java.awt.Component; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.util.HashMap; import java.util.Map; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.JSlider; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.SwingConstants; import javax.swing.UIManager; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import net.vhati.openuhs.desktopreader.RegexDocument;
gridC.anchor = GridBagConstraints.WEST; JTextArea valueArea = new JTextArea(); valueArea.setBackground( null ); valueArea.setEditable( false ); valueArea.setBorder( null ); valueArea.setLineWrap( true ); valueArea.setWrapStyleWord( true ); valueArea.setFocusable( false ); valueArea.setFont( UIManager.getFont( "Label.font" ) ); wrappedLabelMap.put( valueName, valueArea ); this.add( valueArea, gridC ); } else if ( contentType == ContentType.LABEL ) { gridC.anchor = GridBagConstraints.WEST; JLabel valueLbl = new JLabel(); valueLbl.setHorizontalAlignment( SwingConstants.CENTER ); labelMap.put( valueName, valueLbl ); this.add( valueLbl, gridC ); } else if ( contentType == ContentType.STRING ) { gridC.anchor = GridBagConstraints.WEST; JTextField valueField = new JTextField(); stringMap.put( valueName, valueField ); this.add( valueField, gridC ); } else if ( contentType == ContentType.INTEGER ) { gridC.anchor = GridBagConstraints.WEST; JTextField valueField = new JTextField(); valueField.setHorizontalAlignment( JTextField.RIGHT );
// Path: desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/RegexDocument.java // public class RegexDocument extends PlainDocument { // private boolean dontCheck = false; // private Pattern p = null; // // // public RegexDocument( String regex ) { // if ( regex == null || regex.length() == 0 ) dontCheck = true; // // try { // p = Pattern.compile( regex ); // } // catch ( PatternSyntaxException e ) { // dontCheck = true; // } // } // // public RegexDocument() { // dontCheck = true; // } // // // @Override // public void insertString( int offs, String str, AttributeSet a ) throws BadLocationException { // if ( str == null ) return; // // boolean proceed = true; // // if ( dontCheck == false ) { // String tmp = super.getText( 0, offs ) + str + (( super.getLength() > offs ) ? super.getText( offs,super.getLength()-offs ) : ""); // Matcher m = p.matcher( tmp ); // proceed = m.matches(); // } // // if ( proceed == true ) super.insertString( offs, str, a ); // } // // // @Override // public void remove( int offs, int len ) throws BadLocationException { // boolean proceed = true; // // if ( dontCheck == false ) { // try { // String tmp = super.getText( 0, offs ) + (( super.getLength() > (offs+len) ) ? super.getText( offs+len, super.getLength()-(offs+len) ) : ""); // Matcher m = p.matcher( tmp ); // proceed = m.matches(); // } // catch ( BadLocationException e ) { // } // } // // if ( proceed == true ) super.remove( offs, len ); // } // } // Path: desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/FieldEditorPanel.java import java.awt.Component; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.util.HashMap; import java.util.Map; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.JSlider; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.SwingConstants; import javax.swing.UIManager; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import net.vhati.openuhs.desktopreader.RegexDocument; gridC.anchor = GridBagConstraints.WEST; JTextArea valueArea = new JTextArea(); valueArea.setBackground( null ); valueArea.setEditable( false ); valueArea.setBorder( null ); valueArea.setLineWrap( true ); valueArea.setWrapStyleWord( true ); valueArea.setFocusable( false ); valueArea.setFont( UIManager.getFont( "Label.font" ) ); wrappedLabelMap.put( valueName, valueArea ); this.add( valueArea, gridC ); } else if ( contentType == ContentType.LABEL ) { gridC.anchor = GridBagConstraints.WEST; JLabel valueLbl = new JLabel(); valueLbl.setHorizontalAlignment( SwingConstants.CENTER ); labelMap.put( valueName, valueLbl ); this.add( valueLbl, gridC ); } else if ( contentType == ContentType.STRING ) { gridC.anchor = GridBagConstraints.WEST; JTextField valueField = new JTextField(); stringMap.put( valueName, valueField ); this.add( valueField, gridC ); } else if ( contentType == ContentType.INTEGER ) { gridC.anchor = GridBagConstraints.WEST; JTextField valueField = new JTextField(); valueField.setHorizontalAlignment( JTextField.RIGHT );
valueField.setDocument( new RegexDocument( "[0-9]*" ) );
Vhati/OpenUHS
core/src/main/java/net/vhati/openuhs/core/FileRegionByteReference.java
// Path: core/src/main/java/net/vhati/openuhs/core/ByteReference.java // public interface ByteReference { // public long length(); // // public InputStream getInputStream() throws IOException; // } // // Path: core/src/main/java/net/vhati/openuhs/core/RangeInputStream.java // public class RangeInputStream extends FilterInputStream { // private long remaining; // // // public RangeInputStream( InputStream in, long offset, long length ) throws IOException { // super( in ); // if ( super.skip( offset ) < offset ) { // throw new IOException( "Unable to skip leading bytes" ); // } // // remaining = length; // } // // // @Override // public boolean markSupported() { // return false; // } // // @Override // public int read() throws IOException { // return --remaining >= 0 ? super.read() : -1; // } // // @Override // public int read( byte[] b, int off, int len ) throws IOException { // if ( remaining <= 0 ) return -1; // // len = (int)Math.min( (long)len, remaining ); // // int result = super.read( b, off, len ); // if ( result > 0 ) { // remaining -= result; // } // return result; // } // }
import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.io.IOException; import net.vhati.openuhs.core.ByteReference; import net.vhati.openuhs.core.RangeInputStream;
package net.vhati.openuhs.core; public class FileRegionByteReference implements ByteReference { protected final File f; protected final long offset; protected final long length; public FileRegionByteReference( File f, long offset, long length ) { this.f = f; this.offset = offset; this.length = length; } @Override public long length() { return length; } @Override public InputStream getInputStream() throws IOException { FileInputStream fis = null; try {
// Path: core/src/main/java/net/vhati/openuhs/core/ByteReference.java // public interface ByteReference { // public long length(); // // public InputStream getInputStream() throws IOException; // } // // Path: core/src/main/java/net/vhati/openuhs/core/RangeInputStream.java // public class RangeInputStream extends FilterInputStream { // private long remaining; // // // public RangeInputStream( InputStream in, long offset, long length ) throws IOException { // super( in ); // if ( super.skip( offset ) < offset ) { // throw new IOException( "Unable to skip leading bytes" ); // } // // remaining = length; // } // // // @Override // public boolean markSupported() { // return false; // } // // @Override // public int read() throws IOException { // return --remaining >= 0 ? super.read() : -1; // } // // @Override // public int read( byte[] b, int off, int len ) throws IOException { // if ( remaining <= 0 ) return -1; // // len = (int)Math.min( (long)len, remaining ); // // int result = super.read( b, off, len ); // if ( result > 0 ) { // remaining -= result; // } // return result; // } // } // Path: core/src/main/java/net/vhati/openuhs/core/FileRegionByteReference.java import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.io.IOException; import net.vhati.openuhs.core.ByteReference; import net.vhati.openuhs.core.RangeInputStream; package net.vhati.openuhs.core; public class FileRegionByteReference implements ByteReference { protected final File f; protected final long offset; protected final long length; public FileRegionByteReference( File f, long offset, long length ) { this.f = f; this.offset = offset; this.length = length; } @Override public long length() { return length; } @Override public InputStream getInputStream() throws IOException { FileInputStream fis = null; try {
return new RangeInputStream( new BufferedInputStream( new FileInputStream( f ) ), offset, length );
Vhati/OpenUHS
core/src/main/java/net/vhati/openuhs/core/markup/Version88CreditsDecorator.java
// Path: core/src/main/java/net/vhati/openuhs/core/markup/DecoratedFragment.java // public class DecoratedFragment { // public String fragment = null; // public String[] attributes = null; // public Map[] argMaps = null; // // // public DecoratedFragment( String fragment, String[] attributes, Map[] argMaps ) { // this.fragment = fragment; // this.attributes = attributes; // this.argMaps = argMaps; // } // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/StringDecorator.java // public abstract class StringDecorator { // /** The sequence representing line breaks, as expected from the parser. */ // public static final char[] linebreak = new char[] {'^','b','r','e','a','k','^'}; // // // public abstract DecoratedFragment[] getDecoratedString( String rawContent ); // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/Version88StringDecorator.java // public class Version88StringDecorator extends StringDecorator { // // // public Version88StringDecorator() { // super(); // } // // // @Override // public DecoratedFragment[] getDecoratedString( String rawContent ) { // String fragment = rawContent; // String[] decoNames = new String[0]; // Map[] argMaps = new LinkedHashMap[0]; // DecoratedFragment[] result = new DecoratedFragment[] {new DecoratedFragment( fragment, decoNames, argMaps )}; // return result; // } // }
import java.util.Arrays; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import net.vhati.openuhs.core.markup.DecoratedFragment; import net.vhati.openuhs.core.markup.StringDecorator; import net.vhati.openuhs.core.markup.Version88StringDecorator;
package net.vhati.openuhs.core.markup; /** * A StringDecorator for "CreditData" nodes. * <p> * The official reader only honors line breaks * in credit for lines with fewer than 20 characters. * Otherwise, they're displayed as a space. No authors * ever wrote with that in mind, so it's barely worth * enforcing. */ public class Version88CreditsDecorator extends Version88StringDecorator { @Override
// Path: core/src/main/java/net/vhati/openuhs/core/markup/DecoratedFragment.java // public class DecoratedFragment { // public String fragment = null; // public String[] attributes = null; // public Map[] argMaps = null; // // // public DecoratedFragment( String fragment, String[] attributes, Map[] argMaps ) { // this.fragment = fragment; // this.attributes = attributes; // this.argMaps = argMaps; // } // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/StringDecorator.java // public abstract class StringDecorator { // /** The sequence representing line breaks, as expected from the parser. */ // public static final char[] linebreak = new char[] {'^','b','r','e','a','k','^'}; // // // public abstract DecoratedFragment[] getDecoratedString( String rawContent ); // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/Version88StringDecorator.java // public class Version88StringDecorator extends StringDecorator { // // // public Version88StringDecorator() { // super(); // } // // // @Override // public DecoratedFragment[] getDecoratedString( String rawContent ) { // String fragment = rawContent; // String[] decoNames = new String[0]; // Map[] argMaps = new LinkedHashMap[0]; // DecoratedFragment[] result = new DecoratedFragment[] {new DecoratedFragment( fragment, decoNames, argMaps )}; // return result; // } // } // Path: core/src/main/java/net/vhati/openuhs/core/markup/Version88CreditsDecorator.java import java.util.Arrays; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import net.vhati.openuhs.core.markup.DecoratedFragment; import net.vhati.openuhs.core.markup.StringDecorator; import net.vhati.openuhs.core.markup.Version88StringDecorator; package net.vhati.openuhs.core.markup; /** * A StringDecorator for "CreditData" nodes. * <p> * The official reader only honors line breaks * in credit for lines with fewer than 20 characters. * Otherwise, they're displayed as a space. No authors * ever wrote with that in mind, so it's barely worth * enforcing. */ public class Version88CreditsDecorator extends Version88StringDecorator { @Override
public DecoratedFragment[] getDecoratedString( String rawContent ) {
Vhati/OpenUHS
core/src/main/java/net/vhati/openuhs/core/markup/Version88CreditsDecorator.java
// Path: core/src/main/java/net/vhati/openuhs/core/markup/DecoratedFragment.java // public class DecoratedFragment { // public String fragment = null; // public String[] attributes = null; // public Map[] argMaps = null; // // // public DecoratedFragment( String fragment, String[] attributes, Map[] argMaps ) { // this.fragment = fragment; // this.attributes = attributes; // this.argMaps = argMaps; // } // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/StringDecorator.java // public abstract class StringDecorator { // /** The sequence representing line breaks, as expected from the parser. */ // public static final char[] linebreak = new char[] {'^','b','r','e','a','k','^'}; // // // public abstract DecoratedFragment[] getDecoratedString( String rawContent ); // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/Version88StringDecorator.java // public class Version88StringDecorator extends StringDecorator { // // // public Version88StringDecorator() { // super(); // } // // // @Override // public DecoratedFragment[] getDecoratedString( String rawContent ) { // String fragment = rawContent; // String[] decoNames = new String[0]; // Map[] argMaps = new LinkedHashMap[0]; // DecoratedFragment[] result = new DecoratedFragment[] {new DecoratedFragment( fragment, decoNames, argMaps )}; // return result; // } // }
import java.util.Arrays; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import net.vhati.openuhs.core.markup.DecoratedFragment; import net.vhati.openuhs.core.markup.StringDecorator; import net.vhati.openuhs.core.markup.Version88StringDecorator;
package net.vhati.openuhs.core.markup; /** * A StringDecorator for "CreditData" nodes. * <p> * The official reader only honors line breaks * in credit for lines with fewer than 20 characters. * Otherwise, they're displayed as a space. No authors * ever wrote with that in mind, so it's barely worth * enforcing. */ public class Version88CreditsDecorator extends Version88StringDecorator { @Override public DecoratedFragment[] getDecoratedString( String rawContent ) { char[] tmp = rawContent.toCharArray(); StringBuffer buf = new StringBuffer( tmp.length );
// Path: core/src/main/java/net/vhati/openuhs/core/markup/DecoratedFragment.java // public class DecoratedFragment { // public String fragment = null; // public String[] attributes = null; // public Map[] argMaps = null; // // // public DecoratedFragment( String fragment, String[] attributes, Map[] argMaps ) { // this.fragment = fragment; // this.attributes = attributes; // this.argMaps = argMaps; // } // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/StringDecorator.java // public abstract class StringDecorator { // /** The sequence representing line breaks, as expected from the parser. */ // public static final char[] linebreak = new char[] {'^','b','r','e','a','k','^'}; // // // public abstract DecoratedFragment[] getDecoratedString( String rawContent ); // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/Version88StringDecorator.java // public class Version88StringDecorator extends StringDecorator { // // // public Version88StringDecorator() { // super(); // } // // // @Override // public DecoratedFragment[] getDecoratedString( String rawContent ) { // String fragment = rawContent; // String[] decoNames = new String[0]; // Map[] argMaps = new LinkedHashMap[0]; // DecoratedFragment[] result = new DecoratedFragment[] {new DecoratedFragment( fragment, decoNames, argMaps )}; // return result; // } // } // Path: core/src/main/java/net/vhati/openuhs/core/markup/Version88CreditsDecorator.java import java.util.Arrays; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import net.vhati.openuhs.core.markup.DecoratedFragment; import net.vhati.openuhs.core.markup.StringDecorator; import net.vhati.openuhs.core.markup.Version88StringDecorator; package net.vhati.openuhs.core.markup; /** * A StringDecorator for "CreditData" nodes. * <p> * The official reader only honors line breaks * in credit for lines with fewer than 20 characters. * Otherwise, they're displayed as a space. No authors * ever wrote with that in mind, so it's barely worth * enforcing. */ public class Version88CreditsDecorator extends Version88StringDecorator { @Override public DecoratedFragment[] getDecoratedString( String rawContent ) { char[] tmp = rawContent.toCharArray(); StringBuffer buf = new StringBuffer( tmp.length );
char[] linebreak = StringDecorator.linebreak;
Vhati/OpenUHS
core/src/main/java/net/vhati/openuhs/core/markup/Version9xStringDecorator.java
// Path: core/src/main/java/net/vhati/openuhs/core/markup/DecoratedFragment.java // public class DecoratedFragment { // public String fragment = null; // public String[] attributes = null; // public Map[] argMaps = null; // // // public DecoratedFragment( String fragment, String[] attributes, Map[] argMaps ) { // this.fragment = fragment; // this.attributes = attributes; // this.argMaps = argMaps; // } // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/Decoration.java // public class Decoration { // public String name = null; // public char[] prefix = null; // public char[] suffix = null; // // // public Decoration( String name, char[] prefix, char[] suffix ) { // this.name = name; // this.prefix = prefix; // this.suffix = suffix; // } // // public boolean prefixMatches( char[] s, int index ) { // if ( prefix == null || prefix.length == 0 ) return false; // if ( index + prefix.length > s.length ) return false; // for ( int i=0; i < prefix.length; i++ ) { // if ( prefix[i] != s[index+i] ) return false; // } // return true; // } // // public boolean suffixMatches( char[] s, int index ) { // if ( suffix == null || suffix.length == 0 ) return false; // if ( index + suffix.length > s.length ) return false; // for ( int i=0; i < suffix.length; i++ ) { // if ( suffix[i] != s[index+i] ) return false; // } // return true; // } // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/StringDecorator.java // public abstract class StringDecorator { // /** The sequence representing line breaks, as expected from the parser. */ // public static final char[] linebreak = new char[] {'^','b','r','e','a','k','^'}; // // // public abstract DecoratedFragment[] getDecoratedString( String rawContent ); // }
import java.util.Arrays; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import net.vhati.openuhs.core.markup.DecoratedFragment; import net.vhati.openuhs.core.markup.Decoration; import net.vhati.openuhs.core.markup.StringDecorator;
package net.vhati.openuhs.core.markup; /** * A StringDecorator ancestor. * <p> * Line breaks are initially replaced with "\n" by default, * but subclasses overriding getDecoratedString() can change that. */ public class Version9xStringDecorator extends StringDecorator { public static final String MONOSPACED = "Monospaced"; public static final String HYPERLINK = "Hyperlink";
// Path: core/src/main/java/net/vhati/openuhs/core/markup/DecoratedFragment.java // public class DecoratedFragment { // public String fragment = null; // public String[] attributes = null; // public Map[] argMaps = null; // // // public DecoratedFragment( String fragment, String[] attributes, Map[] argMaps ) { // this.fragment = fragment; // this.attributes = attributes; // this.argMaps = argMaps; // } // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/Decoration.java // public class Decoration { // public String name = null; // public char[] prefix = null; // public char[] suffix = null; // // // public Decoration( String name, char[] prefix, char[] suffix ) { // this.name = name; // this.prefix = prefix; // this.suffix = suffix; // } // // public boolean prefixMatches( char[] s, int index ) { // if ( prefix == null || prefix.length == 0 ) return false; // if ( index + prefix.length > s.length ) return false; // for ( int i=0; i < prefix.length; i++ ) { // if ( prefix[i] != s[index+i] ) return false; // } // return true; // } // // public boolean suffixMatches( char[] s, int index ) { // if ( suffix == null || suffix.length == 0 ) return false; // if ( index + suffix.length > s.length ) return false; // for ( int i=0; i < suffix.length; i++ ) { // if ( suffix[i] != s[index+i] ) return false; // } // return true; // } // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/StringDecorator.java // public abstract class StringDecorator { // /** The sequence representing line breaks, as expected from the parser. */ // public static final char[] linebreak = new char[] {'^','b','r','e','a','k','^'}; // // // public abstract DecoratedFragment[] getDecoratedString( String rawContent ); // } // Path: core/src/main/java/net/vhati/openuhs/core/markup/Version9xStringDecorator.java import java.util.Arrays; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import net.vhati.openuhs.core.markup.DecoratedFragment; import net.vhati.openuhs.core.markup.Decoration; import net.vhati.openuhs.core.markup.StringDecorator; package net.vhati.openuhs.core.markup; /** * A StringDecorator ancestor. * <p> * Line breaks are initially replaced with "\n" by default, * but subclasses overriding getDecoratedString() can change that. */ public class Version9xStringDecorator extends StringDecorator { public static final String MONOSPACED = "Monospaced"; public static final String HYPERLINK = "Hyperlink";
private static final Decoration[] decorations = new Decoration[] {
Vhati/OpenUHS
core/src/main/java/net/vhati/openuhs/core/markup/Version9xStringDecorator.java
// Path: core/src/main/java/net/vhati/openuhs/core/markup/DecoratedFragment.java // public class DecoratedFragment { // public String fragment = null; // public String[] attributes = null; // public Map[] argMaps = null; // // // public DecoratedFragment( String fragment, String[] attributes, Map[] argMaps ) { // this.fragment = fragment; // this.attributes = attributes; // this.argMaps = argMaps; // } // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/Decoration.java // public class Decoration { // public String name = null; // public char[] prefix = null; // public char[] suffix = null; // // // public Decoration( String name, char[] prefix, char[] suffix ) { // this.name = name; // this.prefix = prefix; // this.suffix = suffix; // } // // public boolean prefixMatches( char[] s, int index ) { // if ( prefix == null || prefix.length == 0 ) return false; // if ( index + prefix.length > s.length ) return false; // for ( int i=0; i < prefix.length; i++ ) { // if ( prefix[i] != s[index+i] ) return false; // } // return true; // } // // public boolean suffixMatches( char[] s, int index ) { // if ( suffix == null || suffix.length == 0 ) return false; // if ( index + suffix.length > s.length ) return false; // for ( int i=0; i < suffix.length; i++ ) { // if ( suffix[i] != s[index+i] ) return false; // } // return true; // } // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/StringDecorator.java // public abstract class StringDecorator { // /** The sequence representing line breaks, as expected from the parser. */ // public static final char[] linebreak = new char[] {'^','b','r','e','a','k','^'}; // // // public abstract DecoratedFragment[] getDecoratedString( String rawContent ); // }
import java.util.Arrays; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import net.vhati.openuhs.core.markup.DecoratedFragment; import net.vhati.openuhs.core.markup.Decoration; import net.vhati.openuhs.core.markup.StringDecorator;
private static final char[] diaeresisAccent = new char[] {'Ä','Ë','Ï','Ö','Ü','ä','ë','ï','ö','ü'}; private static final char[] diaeresisNormal = new char[] {'A','E','I','O','U','a','e','i','o','u'}; private static final char[] acuteMarkup = new char[] {'\''}; private static final char[] acuteAccent = new char[] {'Á','É','Í','Ó','Ú','á','é','í','ó','ú'}; private static final char[] acuteNormal = new char[] {'A','E','I','O','U','a','e','i','o','u'}; private static final char[] graveMarkup = new char[] {'`'}; private static final char[] graveAccent = new char[] {'À','È','Ì','Ò','Ù','à','è','ì','ò','ù'}; private static final char[] graveNormal = new char[] {'A','E','I','O','U','a','e','i','o','u'}; private static final char[] circumflexMarkup = new char[] {'^'}; private static final char[] circumflexAccent = new char[] {'Â','Ê','Î','Ô','Û','â','ê','î','ô','û'}; private static final char[] circumflexNormal = new char[] {'A','E','I','O','U','a','e','i','o','u'}; private static final char[] tildeMarkup = new char[] {'~'}; private static final char[] tildeAccent = new char[] {'Ñ','ñ'}; private static final char[] tildeNormal = new char[] {'N','n'}; private static final char[][][] accents = new char[][][] { {diaeresisMarkup, diaeresisAccent, diaeresisNormal}, {acuteMarkup, acuteAccent, acuteNormal}, {graveMarkup, graveAccent, graveNormal}, {circumflexMarkup, circumflexAccent, circumflexNormal}, {tildeMarkup, tildeAccent, tildeNormal} }; public Version9xStringDecorator() { super(); } @Override
// Path: core/src/main/java/net/vhati/openuhs/core/markup/DecoratedFragment.java // public class DecoratedFragment { // public String fragment = null; // public String[] attributes = null; // public Map[] argMaps = null; // // // public DecoratedFragment( String fragment, String[] attributes, Map[] argMaps ) { // this.fragment = fragment; // this.attributes = attributes; // this.argMaps = argMaps; // } // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/Decoration.java // public class Decoration { // public String name = null; // public char[] prefix = null; // public char[] suffix = null; // // // public Decoration( String name, char[] prefix, char[] suffix ) { // this.name = name; // this.prefix = prefix; // this.suffix = suffix; // } // // public boolean prefixMatches( char[] s, int index ) { // if ( prefix == null || prefix.length == 0 ) return false; // if ( index + prefix.length > s.length ) return false; // for ( int i=0; i < prefix.length; i++ ) { // if ( prefix[i] != s[index+i] ) return false; // } // return true; // } // // public boolean suffixMatches( char[] s, int index ) { // if ( suffix == null || suffix.length == 0 ) return false; // if ( index + suffix.length > s.length ) return false; // for ( int i=0; i < suffix.length; i++ ) { // if ( suffix[i] != s[index+i] ) return false; // } // return true; // } // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/StringDecorator.java // public abstract class StringDecorator { // /** The sequence representing line breaks, as expected from the parser. */ // public static final char[] linebreak = new char[] {'^','b','r','e','a','k','^'}; // // // public abstract DecoratedFragment[] getDecoratedString( String rawContent ); // } // Path: core/src/main/java/net/vhati/openuhs/core/markup/Version9xStringDecorator.java import java.util.Arrays; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import net.vhati.openuhs.core.markup.DecoratedFragment; import net.vhati.openuhs.core.markup.Decoration; import net.vhati.openuhs.core.markup.StringDecorator; private static final char[] diaeresisAccent = new char[] {'Ä','Ë','Ï','Ö','Ü','ä','ë','ï','ö','ü'}; private static final char[] diaeresisNormal = new char[] {'A','E','I','O','U','a','e','i','o','u'}; private static final char[] acuteMarkup = new char[] {'\''}; private static final char[] acuteAccent = new char[] {'Á','É','Í','Ó','Ú','á','é','í','ó','ú'}; private static final char[] acuteNormal = new char[] {'A','E','I','O','U','a','e','i','o','u'}; private static final char[] graveMarkup = new char[] {'`'}; private static final char[] graveAccent = new char[] {'À','È','Ì','Ò','Ù','à','è','ì','ò','ù'}; private static final char[] graveNormal = new char[] {'A','E','I','O','U','a','e','i','o','u'}; private static final char[] circumflexMarkup = new char[] {'^'}; private static final char[] circumflexAccent = new char[] {'Â','Ê','Î','Ô','Û','â','ê','î','ô','û'}; private static final char[] circumflexNormal = new char[] {'A','E','I','O','U','a','e','i','o','u'}; private static final char[] tildeMarkup = new char[] {'~'}; private static final char[] tildeAccent = new char[] {'Ñ','ñ'}; private static final char[] tildeNormal = new char[] {'N','n'}; private static final char[][][] accents = new char[][][] { {diaeresisMarkup, diaeresisAccent, diaeresisNormal}, {acuteMarkup, acuteAccent, acuteNormal}, {graveMarkup, graveAccent, graveNormal}, {circumflexMarkup, circumflexAccent, circumflexNormal}, {tildeMarkup, tildeAccent, tildeNormal} }; public Version9xStringDecorator() { super(); } @Override
public DecoratedFragment[] getDecoratedString( String rawContent ) {
Vhati/OpenUHS
core/src/main/java/net/vhati/openuhs/core/UHSNode.java
// Path: core/src/main/java/net/vhati/openuhs/core/markup/DecoratedFragment.java // public class DecoratedFragment { // public String fragment = null; // public String[] attributes = null; // public Map[] argMaps = null; // // // public DecoratedFragment( String fragment, String[] attributes, Map[] argMaps ) { // this.fragment = fragment; // this.attributes = attributes; // this.argMaps = argMaps; // } // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/StringDecorator.java // public abstract class StringDecorator { // /** The sequence representing line breaks, as expected from the parser. */ // public static final char[] linebreak = new char[] {'^','b','r','e','a','k','^'}; // // // public abstract DecoratedFragment[] getDecoratedString( String rawContent ); // }
import java.io.PrintStream; import java.util.ArrayList; import java.util.List; import net.vhati.openuhs.core.markup.DecoratedFragment; import net.vhati.openuhs.core.markup.StringDecorator;
/** * Sets this node's content, may not be null. */ public void setRawStringContent( String rawStringContent ) { if ( rawStringContent == null ) throw new IllegalArgumentException( "String content may not be null" ); this.rawStringContent = rawStringContent; } public String getRawStringContent() { return rawStringContent; } public void setStringContentDecorator( StringDecorator d ) { decorator = d; } public StringDecorator getStringContentDecorator() { return decorator; } /** * Returns content with markup parsed away. * * @return an array of DecoratedFragments, or null if no decorator is set * @see #getDecoratedStringContent() */
// Path: core/src/main/java/net/vhati/openuhs/core/markup/DecoratedFragment.java // public class DecoratedFragment { // public String fragment = null; // public String[] attributes = null; // public Map[] argMaps = null; // // // public DecoratedFragment( String fragment, String[] attributes, Map[] argMaps ) { // this.fragment = fragment; // this.attributes = attributes; // this.argMaps = argMaps; // } // } // // Path: core/src/main/java/net/vhati/openuhs/core/markup/StringDecorator.java // public abstract class StringDecorator { // /** The sequence representing line breaks, as expected from the parser. */ // public static final char[] linebreak = new char[] {'^','b','r','e','a','k','^'}; // // // public abstract DecoratedFragment[] getDecoratedString( String rawContent ); // } // Path: core/src/main/java/net/vhati/openuhs/core/UHSNode.java import java.io.PrintStream; import java.util.ArrayList; import java.util.List; import net.vhati.openuhs.core.markup.DecoratedFragment; import net.vhati.openuhs.core.markup.StringDecorator; /** * Sets this node's content, may not be null. */ public void setRawStringContent( String rawStringContent ) { if ( rawStringContent == null ) throw new IllegalArgumentException( "String content may not be null" ); this.rawStringContent = rawStringContent; } public String getRawStringContent() { return rawStringContent; } public void setStringContentDecorator( StringDecorator d ) { decorator = d; } public StringDecorator getStringContentDecorator() { return decorator; } /** * Returns content with markup parsed away. * * @return an array of DecoratedFragments, or null if no decorator is set * @see #getDecoratedStringContent() */
public DecoratedFragment[] getDecoratedStringFragments() {
Vhati/OpenUHS
android-reader/src/main/java/net/vhati/openuhs/androidreader/downloader/StringFetchTask.java
// Path: android-reader/src/main/java/net/vhati/openuhs/androidreader/downloader/FetchUnitException.java // public class FetchUnitException extends Exception { // // // public FetchUnitException() { // } // // public FetchUnitException( String message ) { // super(message); // } // // public FetchUnitException( Throwable cause ) { // super( cause ); // } // // public FetchUnitException( String message, Throwable cause ) { // super( message, cause ); // } // }
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; import android.os.AsyncTask; import net.vhati.openuhs.androidreader.downloader.FetchUnitException;
return userAgent; } public void setEncoding( String s ) { this.encoding = s; } public String getEncoding() { return encoding; } // This runs in a background thread, unlike the other methods here. @Override protected StringFetchResult doInBackground( String... urlStrings ) { HttpURLConnection con = null; InputStream downloadStream = null; BufferedReader r = null; StringBuilder contentString = null; String urlString = urlStrings[0]; StringFetchResult fetchResult = new StringFetchResult( urlString ); Exception ex = null; try { con = (HttpURLConnection)(new URL( urlString ).openConnection()); con.setRequestProperty( "User-Agent", userAgent ); con.connect(); if ( con.getResponseCode() != HttpURLConnection.HTTP_OK ) {
// Path: android-reader/src/main/java/net/vhati/openuhs/androidreader/downloader/FetchUnitException.java // public class FetchUnitException extends Exception { // // // public FetchUnitException() { // } // // public FetchUnitException( String message ) { // super(message); // } // // public FetchUnitException( Throwable cause ) { // super( cause ); // } // // public FetchUnitException( String message, Throwable cause ) { // super( message, cause ); // } // } // Path: android-reader/src/main/java/net/vhati/openuhs/androidreader/downloader/StringFetchTask.java import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; import android.os.AsyncTask; import net.vhati.openuhs.androidreader.downloader.FetchUnitException; return userAgent; } public void setEncoding( String s ) { this.encoding = s; } public String getEncoding() { return encoding; } // This runs in a background thread, unlike the other methods here. @Override protected StringFetchResult doInBackground( String... urlStrings ) { HttpURLConnection con = null; InputStream downloadStream = null; BufferedReader r = null; StringBuilder contentString = null; String urlString = urlStrings[0]; StringFetchResult fetchResult = new StringFetchResult( urlString ); Exception ex = null; try { con = (HttpURLConnection)(new URL( urlString ).openConnection()); con.setRequestProperty( "User-Agent", userAgent ); con.connect(); if ( con.getResponseCode() != HttpURLConnection.HTTP_OK ) {
throw new FetchUnitException( "Server returned HTTP "+ con.getResponseCode() +" "+ con.getResponseMessage() );
Vhati/OpenUHS
desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/downloader/StringFetchTask.java
// Path: desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/downloader/FetchUnitException.java // public class FetchUnitException extends Exception { // // // public FetchUnitException() { // } // // public FetchUnitException( String message ) { // super(message); // } // // public FetchUnitException( Throwable cause ) { // super( cause ); // } // // public FetchUnitException( String message, Throwable cause ) { // super( message, cause ); // } // }
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; import javax.swing.SwingWorker; import net.vhati.openuhs.desktopreader.downloader.FetchUnitException;
/** * Signals that the task should end gracefully. * <p> * SwingWorker's cancel() will cause get() to throw a CancellationException. * Use this method instead. * <p> * This method is thread-safe. */ public void abortTask() { aborting = true; } @Override public StringFetchResult doInBackground() { HttpURLConnection con = null; InputStream downloadStream = null; BufferedReader r = null; StringBuilder contentString = null; StringFetchResult fetchResult = new StringFetchResult( urlString ); Exception ex = null; try { con = (HttpURLConnection)(new URL( urlString ).openConnection()); con.setRequestProperty( "User-Agent", userAgent ); con.connect(); if ( con.getResponseCode() != HttpURLConnection.HTTP_OK ) {
// Path: desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/downloader/FetchUnitException.java // public class FetchUnitException extends Exception { // // // public FetchUnitException() { // } // // public FetchUnitException( String message ) { // super(message); // } // // public FetchUnitException( Throwable cause ) { // super( cause ); // } // // public FetchUnitException( String message, Throwable cause ) { // super( message, cause ); // } // } // Path: desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/downloader/StringFetchTask.java import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; import javax.swing.SwingWorker; import net.vhati.openuhs.desktopreader.downloader.FetchUnitException; /** * Signals that the task should end gracefully. * <p> * SwingWorker's cancel() will cause get() to throw a CancellationException. * Use this method instead. * <p> * This method is thread-safe. */ public void abortTask() { aborting = true; } @Override public StringFetchResult doInBackground() { HttpURLConnection con = null; InputStream downloadStream = null; BufferedReader r = null; StringBuilder contentString = null; StringFetchResult fetchResult = new StringFetchResult( urlString ); Exception ex = null; try { con = (HttpURLConnection)(new URL( urlString ).openConnection()); con.setRequestProperty( "User-Agent", userAgent ); con.connect(); if ( con.getResponseCode() != HttpURLConnection.HTTP_OK ) {
throw new FetchUnitException( "Server returned HTTP "+ con.getResponseCode() +" "+ con.getResponseMessage() );
Vhati/OpenUHS
desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/downloader/UHSFetchTask.java
// Path: core/src/main/java/net/vhati/openuhs/core/downloader/CatalogItem.java // public class CatalogItem { // private String title = ""; // private String url = ""; // private String name = ""; // private Date date = null; // private String compressedSize = ""; // private String fullSize = ""; // // private boolean stateLocal = false; // private boolean stateNewer = false; // // // public CatalogItem() { // } // // // public void setTitle( String s ) { // title = (( s != null ) ? s : ""); // } // // public String getTitle() { // return title; // } // // public void setUrl( String s ) { // url = (( s != null ) ? s : ""); // } // // public String getUrl() { // return url; // } // // public void setName( String s ) { // name = (( s != null ) ? s : ""); // } // // public String getName() { // return name; // } // // public void setDate( Date d ) { // date = d; // } // // public Date getDate() { // return date; // } // // /** // * Sets the reported size of the zip file that wraps the UHS file. // */ // public void setCompressedSize( String s ) { // compressedSize = (( s != null ) ? s : ""); // } // // public String getCompressedSize() { // return compressedSize; // } // // /** // * Sets the reported size of the UHS file, once extracted from the zip file. // */ // public void setFullSize( String s ) { // fullSize = (( s != null ) ? s : ""); // } // // public String getFullSize() { // return fullSize; // } // // // /** // * Sets whether there is a local file with this catalog entry's name. // * // * @see #resetState() // */ // public void setLocal( boolean b ) { // stateLocal = b; // } // // public boolean isLocal() { // return stateLocal; // } // // /** // * Sets whether the catalog entry is newer than the local file. // * // * @see #resetState() // */ // public void setNewer( boolean b ) { // stateNewer = b; // } // // public boolean isNewer() { // return stateNewer; // } // // /** // * Resets the catalog-vs-local state flage. // * // * @see #setLocal(boolean) // * @see #setNewer(boolean) // */ // public void resetState() { // setLocal( false ); // setNewer( false ); // } // // // @Override // public String toString() { // return getTitle(); // } // } // // Path: desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/downloader/FetchUnitException.java // public class FetchUnitException extends Exception { // // // public FetchUnitException() { // } // // public FetchUnitException( String message ) { // super(message); // } // // public FetchUnitException( Throwable cause ) { // super( cause ); // } // // public FetchUnitException( String message, Throwable cause ) { // super( message, cause ); // } // }
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.zip.ZipInputStream; import java.util.zip.ZipEntry; import javax.swing.SwingWorker; import net.vhati.openuhs.core.downloader.CatalogItem; import net.vhati.openuhs.desktopreader.downloader.FetchUnitException;
package net.vhati.openuhs.desktopreader.downloader; /** * A background task that downloads a hint file, while unzipping it. * <p> * Progress can be monitored with a PropertyChangeListener. * <p> * Available properties: * <ul> * <li>state: One of the SwingWorker.StateValue constants.</li> * <li>progress: Overall progress, from 0 to 100.</li> * <li>PROP_UNIT_NAME: the name of an individual download currently in progress.</li> * <li>PROP_UNIT_PROGRESS: progress for an individual download.</li> * </ul> */ public class UHSFetchTask extends SwingWorker<List<UHSFetchTask.UHSFetchResult>, Object> { // First generic is the result, returned by doInBackground(). // Second generic is for returning intermediate results while running. (Unused) public static final String PROP_UNIT_NAME = "unitName"; public static final String PROP_UNIT_PROGRESS = "unitProgress"; private volatile boolean aborting = false; private String userAgent = System.getProperty( "http.agent" ); private File destDir;
// Path: core/src/main/java/net/vhati/openuhs/core/downloader/CatalogItem.java // public class CatalogItem { // private String title = ""; // private String url = ""; // private String name = ""; // private Date date = null; // private String compressedSize = ""; // private String fullSize = ""; // // private boolean stateLocal = false; // private boolean stateNewer = false; // // // public CatalogItem() { // } // // // public void setTitle( String s ) { // title = (( s != null ) ? s : ""); // } // // public String getTitle() { // return title; // } // // public void setUrl( String s ) { // url = (( s != null ) ? s : ""); // } // // public String getUrl() { // return url; // } // // public void setName( String s ) { // name = (( s != null ) ? s : ""); // } // // public String getName() { // return name; // } // // public void setDate( Date d ) { // date = d; // } // // public Date getDate() { // return date; // } // // /** // * Sets the reported size of the zip file that wraps the UHS file. // */ // public void setCompressedSize( String s ) { // compressedSize = (( s != null ) ? s : ""); // } // // public String getCompressedSize() { // return compressedSize; // } // // /** // * Sets the reported size of the UHS file, once extracted from the zip file. // */ // public void setFullSize( String s ) { // fullSize = (( s != null ) ? s : ""); // } // // public String getFullSize() { // return fullSize; // } // // // /** // * Sets whether there is a local file with this catalog entry's name. // * // * @see #resetState() // */ // public void setLocal( boolean b ) { // stateLocal = b; // } // // public boolean isLocal() { // return stateLocal; // } // // /** // * Sets whether the catalog entry is newer than the local file. // * // * @see #resetState() // */ // public void setNewer( boolean b ) { // stateNewer = b; // } // // public boolean isNewer() { // return stateNewer; // } // // /** // * Resets the catalog-vs-local state flage. // * // * @see #setLocal(boolean) // * @see #setNewer(boolean) // */ // public void resetState() { // setLocal( false ); // setNewer( false ); // } // // // @Override // public String toString() { // return getTitle(); // } // } // // Path: desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/downloader/FetchUnitException.java // public class FetchUnitException extends Exception { // // // public FetchUnitException() { // } // // public FetchUnitException( String message ) { // super(message); // } // // public FetchUnitException( Throwable cause ) { // super( cause ); // } // // public FetchUnitException( String message, Throwable cause ) { // super( message, cause ); // } // } // Path: desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/downloader/UHSFetchTask.java import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.zip.ZipInputStream; import java.util.zip.ZipEntry; import javax.swing.SwingWorker; import net.vhati.openuhs.core.downloader.CatalogItem; import net.vhati.openuhs.desktopreader.downloader.FetchUnitException; package net.vhati.openuhs.desktopreader.downloader; /** * A background task that downloads a hint file, while unzipping it. * <p> * Progress can be monitored with a PropertyChangeListener. * <p> * Available properties: * <ul> * <li>state: One of the SwingWorker.StateValue constants.</li> * <li>progress: Overall progress, from 0 to 100.</li> * <li>PROP_UNIT_NAME: the name of an individual download currently in progress.</li> * <li>PROP_UNIT_PROGRESS: progress for an individual download.</li> * </ul> */ public class UHSFetchTask extends SwingWorker<List<UHSFetchTask.UHSFetchResult>, Object> { // First generic is the result, returned by doInBackground(). // Second generic is for returning intermediate results while running. (Unused) public static final String PROP_UNIT_NAME = "unitName"; public static final String PROP_UNIT_PROGRESS = "unitProgress"; private volatile boolean aborting = false; private String userAgent = System.getProperty( "http.agent" ); private File destDir;
private CatalogItem[] catItems;
Vhati/OpenUHS
desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/downloader/UHSFetchTask.java
// Path: core/src/main/java/net/vhati/openuhs/core/downloader/CatalogItem.java // public class CatalogItem { // private String title = ""; // private String url = ""; // private String name = ""; // private Date date = null; // private String compressedSize = ""; // private String fullSize = ""; // // private boolean stateLocal = false; // private boolean stateNewer = false; // // // public CatalogItem() { // } // // // public void setTitle( String s ) { // title = (( s != null ) ? s : ""); // } // // public String getTitle() { // return title; // } // // public void setUrl( String s ) { // url = (( s != null ) ? s : ""); // } // // public String getUrl() { // return url; // } // // public void setName( String s ) { // name = (( s != null ) ? s : ""); // } // // public String getName() { // return name; // } // // public void setDate( Date d ) { // date = d; // } // // public Date getDate() { // return date; // } // // /** // * Sets the reported size of the zip file that wraps the UHS file. // */ // public void setCompressedSize( String s ) { // compressedSize = (( s != null ) ? s : ""); // } // // public String getCompressedSize() { // return compressedSize; // } // // /** // * Sets the reported size of the UHS file, once extracted from the zip file. // */ // public void setFullSize( String s ) { // fullSize = (( s != null ) ? s : ""); // } // // public String getFullSize() { // return fullSize; // } // // // /** // * Sets whether there is a local file with this catalog entry's name. // * // * @see #resetState() // */ // public void setLocal( boolean b ) { // stateLocal = b; // } // // public boolean isLocal() { // return stateLocal; // } // // /** // * Sets whether the catalog entry is newer than the local file. // * // * @see #resetState() // */ // public void setNewer( boolean b ) { // stateNewer = b; // } // // public boolean isNewer() { // return stateNewer; // } // // /** // * Resets the catalog-vs-local state flage. // * // * @see #setLocal(boolean) // * @see #setNewer(boolean) // */ // public void resetState() { // setLocal( false ); // setNewer( false ); // } // // // @Override // public String toString() { // return getTitle(); // } // } // // Path: desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/downloader/FetchUnitException.java // public class FetchUnitException extends Exception { // // // public FetchUnitException() { // } // // public FetchUnitException( String message ) { // super(message); // } // // public FetchUnitException( Throwable cause ) { // super( cause ); // } // // public FetchUnitException( String message, Throwable cause ) { // super( message, cause ); // } // }
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.zip.ZipInputStream; import java.util.zip.ZipEntry; import javax.swing.SwingWorker; import net.vhati.openuhs.core.downloader.CatalogItem; import net.vhati.openuhs.desktopreader.downloader.FetchUnitException;
UHSFetchResult fetchResult = new UHSFetchResult( catItem ); if ( isCancelled() || aborting ) { fetchResult.status = UHSFetchResult.STATUS_CANCELLED; fetchResults.add( fetchResult ); continue; } String unitNameOld = unitName; unitName = catItem.getName(); this.getPropertyChangeSupport().firePropertyChange( PROP_UNIT_NAME, unitNameOld, unitName ); int unitProgressOld = unitProgress; unitProgress = 0; this.getPropertyChangeSupport().firePropertyChange( PROP_UNIT_PROGRESS, unitProgressOld, unitProgress ); HttpURLConnection con = null; InputStream downloadStream = null; ZipInputStream unzipStream = null; OutputStream os = null; File uhsFile = null; String urlString = catItem.getUrl(); Exception ex = null; try { con = (HttpURLConnection)(new URL( urlString ).openConnection()); con.setRequestProperty( "User-Agent", userAgent ); con.connect(); if ( con.getResponseCode() != HttpURLConnection.HTTP_OK ) {
// Path: core/src/main/java/net/vhati/openuhs/core/downloader/CatalogItem.java // public class CatalogItem { // private String title = ""; // private String url = ""; // private String name = ""; // private Date date = null; // private String compressedSize = ""; // private String fullSize = ""; // // private boolean stateLocal = false; // private boolean stateNewer = false; // // // public CatalogItem() { // } // // // public void setTitle( String s ) { // title = (( s != null ) ? s : ""); // } // // public String getTitle() { // return title; // } // // public void setUrl( String s ) { // url = (( s != null ) ? s : ""); // } // // public String getUrl() { // return url; // } // // public void setName( String s ) { // name = (( s != null ) ? s : ""); // } // // public String getName() { // return name; // } // // public void setDate( Date d ) { // date = d; // } // // public Date getDate() { // return date; // } // // /** // * Sets the reported size of the zip file that wraps the UHS file. // */ // public void setCompressedSize( String s ) { // compressedSize = (( s != null ) ? s : ""); // } // // public String getCompressedSize() { // return compressedSize; // } // // /** // * Sets the reported size of the UHS file, once extracted from the zip file. // */ // public void setFullSize( String s ) { // fullSize = (( s != null ) ? s : ""); // } // // public String getFullSize() { // return fullSize; // } // // // /** // * Sets whether there is a local file with this catalog entry's name. // * // * @see #resetState() // */ // public void setLocal( boolean b ) { // stateLocal = b; // } // // public boolean isLocal() { // return stateLocal; // } // // /** // * Sets whether the catalog entry is newer than the local file. // * // * @see #resetState() // */ // public void setNewer( boolean b ) { // stateNewer = b; // } // // public boolean isNewer() { // return stateNewer; // } // // /** // * Resets the catalog-vs-local state flage. // * // * @see #setLocal(boolean) // * @see #setNewer(boolean) // */ // public void resetState() { // setLocal( false ); // setNewer( false ); // } // // // @Override // public String toString() { // return getTitle(); // } // } // // Path: desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/downloader/FetchUnitException.java // public class FetchUnitException extends Exception { // // // public FetchUnitException() { // } // // public FetchUnitException( String message ) { // super(message); // } // // public FetchUnitException( Throwable cause ) { // super( cause ); // } // // public FetchUnitException( String message, Throwable cause ) { // super( message, cause ); // } // } // Path: desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/downloader/UHSFetchTask.java import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.zip.ZipInputStream; import java.util.zip.ZipEntry; import javax.swing.SwingWorker; import net.vhati.openuhs.core.downloader.CatalogItem; import net.vhati.openuhs.desktopreader.downloader.FetchUnitException; UHSFetchResult fetchResult = new UHSFetchResult( catItem ); if ( isCancelled() || aborting ) { fetchResult.status = UHSFetchResult.STATUS_CANCELLED; fetchResults.add( fetchResult ); continue; } String unitNameOld = unitName; unitName = catItem.getName(); this.getPropertyChangeSupport().firePropertyChange( PROP_UNIT_NAME, unitNameOld, unitName ); int unitProgressOld = unitProgress; unitProgress = 0; this.getPropertyChangeSupport().firePropertyChange( PROP_UNIT_PROGRESS, unitProgressOld, unitProgress ); HttpURLConnection con = null; InputStream downloadStream = null; ZipInputStream unzipStream = null; OutputStream os = null; File uhsFile = null; String urlString = catItem.getUrl(); Exception ex = null; try { con = (HttpURLConnection)(new URL( urlString ).openConnection()); con.setRequestProperty( "User-Agent", userAgent ); con.connect(); if ( con.getResponseCode() != HttpURLConnection.HTTP_OK ) {
throw new FetchUnitException( String.format( "Server returned HTTP %s %s", con.getResponseCode(), con.getResponseMessage() ) );
CMPUT301F16T01/Carrier
app/src/main/java/comcmput301f16t01/github/carrier/Requests/OfferCommand.java
// Path: app/src/main/java/comcmput301f16t01/github/carrier/Users/User.java // public class User implements Parcelable{ // private String username; // private String email; // private String phoneNumber; // private String vehicleDescription; // // /** // * For use with Elastic Search, is the unique ID given to it // */ // @JestId // private String elasticID; // // //TODO we should probably say what is and isn't a valid username, email, and phone number. // // /** // * Constructor, requires username, email, and phone number. // * // * @param inputUsername The username // * @param inputEmail The e-mail // * @param inputPhoneNumber The phone number // * @param inputVehicleDescription The vehicle information // */ // public User(@NonNull String inputUsername, @NonNull String inputEmail, @NonNull String inputPhoneNumber, @NonNull String inputVehicleDescription) { // this.username = inputUsername; // this.email = inputEmail; // this.phoneNumber = inputPhoneNumber; // this.vehicleDescription = inputVehicleDescription; // } // // public User() { // this.username = "default_name"; // // TODO this method was implemented to create a default method for extending classes. Probably needs refactoring. // } // // public User(String name) { // this.username = name; // } // // protected User(Parcel in) { // username = in.readString(); // email = in.readString(); // phoneNumber = in.readString(); // vehicleDescription = in.readString(); // elasticID = in.readString(); // } // // /** // * Required by the Parcelable interface. Allows the creation and storage of parcels in bundles. // */ // public static final Creator<User> CREATOR = new Creator<User>() { // @Override // public User createFromParcel(Parcel in) { // return new User(in); // } // // @Override // public User[] newArray(int size) { // return new User[size]; // } // }; // // public void setUsername(String username) { // this.username = username; // } // // public void setEmail(String email) { // this.email = email; // } // // public void setPhone(String phone) { // this.phoneNumber = phone; // } // // public void setVehicleDescription(String vehicleDescription) { // this.vehicleDescription = vehicleDescription; // } // // public String getVehicleDescription() { // return vehicleDescription; // } // // public String getPhone() { // return phoneNumber; // } // // public String getEmail() { // return email; // } // // public String getUsername() { // return username; // } // // // public boolean hasNotifications() { // return false; // } // // public void setId(String id) { // elasticID = id; // } // // public String getId() { // return elasticID; // } // // @Override // /** // * Required by the Parcelable interface. I honestly don't know what this is for. // */ // public int describeContents() { // return 0; // } // // @Override // /** // * Required by the Parcelable interface. // * Allows the User class to be put into a bundle using putParcelable() on a bundle. // * @param dest // * @param flags // */ // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(username); // dest.writeString(email); // dest.writeString(phoneNumber); // dest.writeString(vehicleDescription); // dest.writeString(elasticID); // } // }
import comcmput301f16t01.github.carrier.Users.User;
package comcmput301f16t01.github.carrier.Requests; /** * Stores information to make an offer command in the future. This is used for offline * functionality to queue offer commands to be made. */ public class OfferCommand { private Request request;
// Path: app/src/main/java/comcmput301f16t01/github/carrier/Users/User.java // public class User implements Parcelable{ // private String username; // private String email; // private String phoneNumber; // private String vehicleDescription; // // /** // * For use with Elastic Search, is the unique ID given to it // */ // @JestId // private String elasticID; // // //TODO we should probably say what is and isn't a valid username, email, and phone number. // // /** // * Constructor, requires username, email, and phone number. // * // * @param inputUsername The username // * @param inputEmail The e-mail // * @param inputPhoneNumber The phone number // * @param inputVehicleDescription The vehicle information // */ // public User(@NonNull String inputUsername, @NonNull String inputEmail, @NonNull String inputPhoneNumber, @NonNull String inputVehicleDescription) { // this.username = inputUsername; // this.email = inputEmail; // this.phoneNumber = inputPhoneNumber; // this.vehicleDescription = inputVehicleDescription; // } // // public User() { // this.username = "default_name"; // // TODO this method was implemented to create a default method for extending classes. Probably needs refactoring. // } // // public User(String name) { // this.username = name; // } // // protected User(Parcel in) { // username = in.readString(); // email = in.readString(); // phoneNumber = in.readString(); // vehicleDescription = in.readString(); // elasticID = in.readString(); // } // // /** // * Required by the Parcelable interface. Allows the creation and storage of parcels in bundles. // */ // public static final Creator<User> CREATOR = new Creator<User>() { // @Override // public User createFromParcel(Parcel in) { // return new User(in); // } // // @Override // public User[] newArray(int size) { // return new User[size]; // } // }; // // public void setUsername(String username) { // this.username = username; // } // // public void setEmail(String email) { // this.email = email; // } // // public void setPhone(String phone) { // this.phoneNumber = phone; // } // // public void setVehicleDescription(String vehicleDescription) { // this.vehicleDescription = vehicleDescription; // } // // public String getVehicleDescription() { // return vehicleDescription; // } // // public String getPhone() { // return phoneNumber; // } // // public String getEmail() { // return email; // } // // public String getUsername() { // return username; // } // // // public boolean hasNotifications() { // return false; // } // // public void setId(String id) { // elasticID = id; // } // // public String getId() { // return elasticID; // } // // @Override // /** // * Required by the Parcelable interface. I honestly don't know what this is for. // */ // public int describeContents() { // return 0; // } // // @Override // /** // * Required by the Parcelable interface. // * Allows the User class to be put into a bundle using putParcelable() on a bundle. // * @param dest // * @param flags // */ // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(username); // dest.writeString(email); // dest.writeString(phoneNumber); // dest.writeString(vehicleDescription); // dest.writeString(elasticID); // } // } // Path: app/src/main/java/comcmput301f16t01/github/carrier/Requests/OfferCommand.java import comcmput301f16t01.github.carrier.Users.User; package comcmput301f16t01.github.carrier.Requests; /** * Stores information to make an offer command in the future. This is used for offline * functionality to queue offer commands to be made. */ public class OfferCommand { private Request request;
private User driver;
CMPUT301F16T01/Carrier
app/src/main/java/comcmput301f16t01/github/carrier/Requests/RequestAdapter.java
// Path: app/src/main/java/comcmput301f16t01/github/carrier/FareCalculator.java // public class FareCalculator { // // // Constants for calculating the fare. // static final double COST_PER_MIN = 0.15; // static final double COST_PER_KM = 0.56; // static final double BOOKING_FEE = 1.65; // static final int MIN_FARE = (int) 5.00 * 100; // // /** // * Static method takes in distance and duration and returns an estimate of a fare to post with. // * // * Formula from http://www.ridesharingdriver.com/how-much-does-uber-cost-uber-fare-estimator/ // * fare = base fare + (cost per minute * time in ride) + (cost per km * ride distance) + booking fee // * // * @param distance The distance of the ride in kilometers // * @param duration The duration of the ride in seconds // * @return Returns whatever is greater: the calculated far or the minimum fare. // */ // // see code attribution // public static int getEstimate(double distance, double duration) { // // Calculate fare and the the larger of fare vs minimum fare, we multiply by 100 to get an integer // int calculatedFare = (int) Math.round(((BOOKING_FEE + (COST_PER_MIN * duration) + // (COST_PER_KM * distance)) * 100) * 100) / 1000; // We divide by 1000 to round to two decimal places // // return Math.max(calculatedFare, MIN_FARE); // } // // /** // * Converts integer fare into a readable string (price format). // * @param intFare the fare as an integer (the dollar value * 100) // * @return A string representing the dollar amount with decimal. // */ // public static String toString(int intFare) { // double fare = ((double) intFare)/100; // String str = String.format(Locale.getDefault(), "%d",(long)fare) + "."; // String dec = String.format(Locale.getDefault(), "0%.0f",(fare%1)*100); // // format the fare as a string with 2 decimal points // str += dec.substring(dec.length()-2, dec.length()); // return str; // } // }
import android.content.Context; import android.support.annotation.NonNull; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; import java.util.ArrayList; import java.util.Currency; import java.util.Locale; import comcmput301f16t01.github.carrier.FareCalculator; import comcmput301f16t01.github.carrier.R;
if (request.getStart().getShortAddress() != null) { if(!request.getStart().getShortAddress().equals("")) { startLoc = "Start: " + request.getStart().getShortAddress(); } else { startLoc = "Start: " + request.getStart().getLatLong(); } } else { startLoc = "Start: " + request.getStart().getLatLong(); } startLocTextView.setText(startLoc); } // Set the end location in the item's view if (endLocTextView != null) { String endLoc; if (request.getEnd().getShortAddress() != null) { if(!request.getEnd().getShortAddress().equals("")) { endLoc = "End: " + request.getEnd().getShortAddress(); } else { endLoc = "End: " + request.getEnd().getLatLong(); } } else { endLoc = "End: " + request.getEnd().getLatLong(); } endLocTextView.setText(endLoc); } // Set the price in the item's view if (priceTextView != null) { Currency localCurrency = Currency.getInstance( Locale.getDefault() );
// Path: app/src/main/java/comcmput301f16t01/github/carrier/FareCalculator.java // public class FareCalculator { // // // Constants for calculating the fare. // static final double COST_PER_MIN = 0.15; // static final double COST_PER_KM = 0.56; // static final double BOOKING_FEE = 1.65; // static final int MIN_FARE = (int) 5.00 * 100; // // /** // * Static method takes in distance and duration and returns an estimate of a fare to post with. // * // * Formula from http://www.ridesharingdriver.com/how-much-does-uber-cost-uber-fare-estimator/ // * fare = base fare + (cost per minute * time in ride) + (cost per km * ride distance) + booking fee // * // * @param distance The distance of the ride in kilometers // * @param duration The duration of the ride in seconds // * @return Returns whatever is greater: the calculated far or the minimum fare. // */ // // see code attribution // public static int getEstimate(double distance, double duration) { // // Calculate fare and the the larger of fare vs minimum fare, we multiply by 100 to get an integer // int calculatedFare = (int) Math.round(((BOOKING_FEE + (COST_PER_MIN * duration) + // (COST_PER_KM * distance)) * 100) * 100) / 1000; // We divide by 1000 to round to two decimal places // // return Math.max(calculatedFare, MIN_FARE); // } // // /** // * Converts integer fare into a readable string (price format). // * @param intFare the fare as an integer (the dollar value * 100) // * @return A string representing the dollar amount with decimal. // */ // public static String toString(int intFare) { // double fare = ((double) intFare)/100; // String str = String.format(Locale.getDefault(), "%d",(long)fare) + "."; // String dec = String.format(Locale.getDefault(), "0%.0f",(fare%1)*100); // // format the fare as a string with 2 decimal points // str += dec.substring(dec.length()-2, dec.length()); // return str; // } // } // Path: app/src/main/java/comcmput301f16t01/github/carrier/Requests/RequestAdapter.java import android.content.Context; import android.support.annotation.NonNull; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; import java.util.ArrayList; import java.util.Currency; import java.util.Locale; import comcmput301f16t01.github.carrier.FareCalculator; import comcmput301f16t01.github.carrier.R; if (request.getStart().getShortAddress() != null) { if(!request.getStart().getShortAddress().equals("")) { startLoc = "Start: " + request.getStart().getShortAddress(); } else { startLoc = "Start: " + request.getStart().getLatLong(); } } else { startLoc = "Start: " + request.getStart().getLatLong(); } startLocTextView.setText(startLoc); } // Set the end location in the item's view if (endLocTextView != null) { String endLoc; if (request.getEnd().getShortAddress() != null) { if(!request.getEnd().getShortAddress().equals("")) { endLoc = "End: " + request.getEnd().getShortAddress(); } else { endLoc = "End: " + request.getEnd().getLatLong(); } } else { endLoc = "End: " + request.getEnd().getLatLong(); } endLocTextView.setText(endLoc); } // Set the price in the item's view if (priceTextView != null) { Currency localCurrency = Currency.getInstance( Locale.getDefault() );
String price = localCurrency.getSymbol() + FareCalculator.toString(request.getFare());
CMPUT301F16T01/Carrier
app/src/main/java/comcmput301f16t01/github/carrier/Requests/ViewLocationsActivity.java
// Path: app/src/main/java/comcmput301f16t01/github/carrier/CarrierLocation.java // public class CarrierLocation extends Location { // private String address; // private String shortAddress; // // public CarrierLocation() { // // get current location // super(""); // } // // public CarrierLocation(double latitude, double longitude) { // super(""); // this.setLatitude(latitude); // this.setLongitude(longitude); // } // // public String getAddress() { // return address; // } // // // see code attribution // public void setAddress(String address) { // if(!address.equals("")) { // this.address = address; // // short address is just the first line of the address string // this.shortAddress = address.split("\\r?\\n")[0]; // } // } // // public String getShortAddress() { // return shortAddress; // } // // /** // * For use when an address is null. Returns a string of a lat/long tuple. // * @return String // */ // public String getLatLong() { // return "(" + String.format("%.4f",getLatitude()) + ", " + // String.format("%.4f",getLongitude()) + ")"; // } // // @Override // public String toString() { // if(address != null) { // if(!address.equals("")) { // return getAddress(); // } else { // return getLatLong(); // } // } else { // return getLatLong(); // } // } // }
import android.app.Activity; import android.content.Intent; import android.location.Location; import android.os.AsyncTask; import android.support.v4.content.res.ResourcesCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.view.ViewTreeObserver; import android.widget.Toast; import com.google.gson.Gson; import org.osmdroid.api.IMapController; import org.osmdroid.bonuspack.routing.OSRMRoadManager; import org.osmdroid.bonuspack.routing.Road; import org.osmdroid.bonuspack.routing.RoadManager; import org.osmdroid.tileprovider.tilesource.TileSourceFactory; import org.osmdroid.util.BoundingBox; import org.osmdroid.util.GeoPoint; import org.osmdroid.views.MapView; import org.osmdroid.views.overlay.Marker; import org.osmdroid.views.overlay.Overlay; import org.osmdroid.views.overlay.OverlayItem; import org.osmdroid.views.overlay.Polyline; import org.osmdroid.views.overlay.infowindow.BasicInfoWindow; import java.util.ArrayList; import java.util.List; import comcmput301f16t01.github.carrier.CarrierLocation; import comcmput301f16t01.github.carrier.R;
package comcmput301f16t01.github.carrier.Requests; /** * <p>The ViewLocationsActivity allows the user to view on a map two start and end locations and * the route between them. Giving the user a better idea of what route they will be taking.</p> * </br> * <p>See code attribution in Wiki: <a href="https://github.com/CMPUT301F16T01/Carrier/wiki/Code-Re-Use#driverviewrequestactivity">DriverViewRequestActivity</a></p> * </br> * <p>Based on: <a href="https://github.com/MKergall/osmbonuspack/wiki/Tutorial_0">Tutorial_0</a></p> * <p>Author: MKergall</p> * <p>Retrieved on: November 10th, 2016</p> * </br> * <p>Updated with: <a href="http://stackoverflow.com/questions/38539637/osmbonuspack-roadmanager-networkonmainthreadexception">OSMBonuspack RoadManager NetworkOnMainThreadException</a></p> * <p>Author: <a href="http://stackoverflow.com/users/4670837/yubaraj-poudel">yubaraj poudel</a></p> * <p>Posted on: August 6th, 2016</p> * <p>Retrieved on: November 10th, 2016</p> * </br> * <p>Based on: <a href="http://stackoverflow.com/questions/20608590/osmdroid-zooming-to-show-the-whole-pathoverlay">OSMDroid: zooming to show the whole PathOverlay</a></p> * <p>Author: <a href="http://stackoverflow.com/users/6769091/thebugger">theBugger</a></p> * <p>Posted on: September 30th, 2016</p> * <p>Retrieved on: November 24th, 2016</p> */ public class ViewLocationsActivity extends AppCompatActivity { private final Activity activity = ViewLocationsActivity.this;
// Path: app/src/main/java/comcmput301f16t01/github/carrier/CarrierLocation.java // public class CarrierLocation extends Location { // private String address; // private String shortAddress; // // public CarrierLocation() { // // get current location // super(""); // } // // public CarrierLocation(double latitude, double longitude) { // super(""); // this.setLatitude(latitude); // this.setLongitude(longitude); // } // // public String getAddress() { // return address; // } // // // see code attribution // public void setAddress(String address) { // if(!address.equals("")) { // this.address = address; // // short address is just the first line of the address string // this.shortAddress = address.split("\\r?\\n")[0]; // } // } // // public String getShortAddress() { // return shortAddress; // } // // /** // * For use when an address is null. Returns a string of a lat/long tuple. // * @return String // */ // public String getLatLong() { // return "(" + String.format("%.4f",getLatitude()) + ", " + // String.format("%.4f",getLongitude()) + ")"; // } // // @Override // public String toString() { // if(address != null) { // if(!address.equals("")) { // return getAddress(); // } else { // return getLatLong(); // } // } else { // return getLatLong(); // } // } // } // Path: app/src/main/java/comcmput301f16t01/github/carrier/Requests/ViewLocationsActivity.java import android.app.Activity; import android.content.Intent; import android.location.Location; import android.os.AsyncTask; import android.support.v4.content.res.ResourcesCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.view.ViewTreeObserver; import android.widget.Toast; import com.google.gson.Gson; import org.osmdroid.api.IMapController; import org.osmdroid.bonuspack.routing.OSRMRoadManager; import org.osmdroid.bonuspack.routing.Road; import org.osmdroid.bonuspack.routing.RoadManager; import org.osmdroid.tileprovider.tilesource.TileSourceFactory; import org.osmdroid.util.BoundingBox; import org.osmdroid.util.GeoPoint; import org.osmdroid.views.MapView; import org.osmdroid.views.overlay.Marker; import org.osmdroid.views.overlay.Overlay; import org.osmdroid.views.overlay.OverlayItem; import org.osmdroid.views.overlay.Polyline; import org.osmdroid.views.overlay.infowindow.BasicInfoWindow; import java.util.ArrayList; import java.util.List; import comcmput301f16t01.github.carrier.CarrierLocation; import comcmput301f16t01.github.carrier.R; package comcmput301f16t01.github.carrier.Requests; /** * <p>The ViewLocationsActivity allows the user to view on a map two start and end locations and * the route between them. Giving the user a better idea of what route they will be taking.</p> * </br> * <p>See code attribution in Wiki: <a href="https://github.com/CMPUT301F16T01/Carrier/wiki/Code-Re-Use#driverviewrequestactivity">DriverViewRequestActivity</a></p> * </br> * <p>Based on: <a href="https://github.com/MKergall/osmbonuspack/wiki/Tutorial_0">Tutorial_0</a></p> * <p>Author: MKergall</p> * <p>Retrieved on: November 10th, 2016</p> * </br> * <p>Updated with: <a href="http://stackoverflow.com/questions/38539637/osmbonuspack-roadmanager-networkonmainthreadexception">OSMBonuspack RoadManager NetworkOnMainThreadException</a></p> * <p>Author: <a href="http://stackoverflow.com/users/4670837/yubaraj-poudel">yubaraj poudel</a></p> * <p>Posted on: August 6th, 2016</p> * <p>Retrieved on: November 10th, 2016</p> * </br> * <p>Based on: <a href="http://stackoverflow.com/questions/20608590/osmdroid-zooming-to-show-the-whole-pathoverlay">OSMDroid: zooming to show the whole PathOverlay</a></p> * <p>Author: <a href="http://stackoverflow.com/users/6769091/thebugger">theBugger</a></p> * <p>Posted on: September 30th, 2016</p> * <p>Retrieved on: November 24th, 2016</p> */ public class ViewLocationsActivity extends AppCompatActivity { private final Activity activity = ViewLocationsActivity.this;
private CarrierLocation start = null;
ufoscout/properlty
properlty-common/src/main/java/com/ufoscout/properlty/reader/decorator/ToLowerCaseAndDotKeyReader.java
// Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Reader.java // @FunctionalInterface // public interface Reader { // // Map<String, PropertyValue> read(); // // }
import java.util.HashMap; import java.util.Map; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.Reader;
/******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; /** * A {@link DecoratorReader} that turns each property key in lower case and replaces underscores with a dot. * This is mostly used to transform environment variables in a properties like format. * * @author Francesco Cina * */ @Deprecated public class ToLowerCaseAndDotKeyReader extends DecoratorReader {
// Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Reader.java // @FunctionalInterface // public interface Reader { // // Map<String, PropertyValue> read(); // // } // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/decorator/ToLowerCaseAndDotKeyReader.java import java.util.HashMap; import java.util.Map; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.Reader; /******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; /** * A {@link DecoratorReader} that turns each property key in lower case and replaces underscores with a dot. * This is mostly used to transform environment variables in a properties like format. * * @author Francesco Cina * */ @Deprecated public class ToLowerCaseAndDotKeyReader extends DecoratorReader {
public ToLowerCaseAndDotKeyReader(Reader reader) {
ufoscout/properlty
properlty-common/src/main/java/com/ufoscout/properlty/reader/decorator/ToLowerCaseAndDotKeyReader.java
// Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Reader.java // @FunctionalInterface // public interface Reader { // // Map<String, PropertyValue> read(); // // }
import java.util.HashMap; import java.util.Map; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.Reader;
/******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; /** * A {@link DecoratorReader} that turns each property key in lower case and replaces underscores with a dot. * This is mostly used to transform environment variables in a properties like format. * * @author Francesco Cina * */ @Deprecated public class ToLowerCaseAndDotKeyReader extends DecoratorReader { public ToLowerCaseAndDotKeyReader(Reader reader) { super(reader); } @Override
// Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Reader.java // @FunctionalInterface // public interface Reader { // // Map<String, PropertyValue> read(); // // } // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/decorator/ToLowerCaseAndDotKeyReader.java import java.util.HashMap; import java.util.Map; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.Reader; /******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; /** * A {@link DecoratorReader} that turns each property key in lower case and replaces underscores with a dot. * This is mostly used to transform environment variables in a properties like format. * * @author Francesco Cina * */ @Deprecated public class ToLowerCaseAndDotKeyReader extends DecoratorReader { public ToLowerCaseAndDotKeyReader(Reader reader) { super(reader); } @Override
protected Map<String, PropertyValue> apply(Map<String, PropertyValue> input) {
ufoscout/properlty
properlty-common/src/test/java/com/ufoscout/properlty/reader/SystemPropertiesReaderTest.java
// Path: properlty/src/test/java/com/ufoscout/properlty/ProperltyBaseTest.java // public abstract class ProperltyBaseTest { // // @Rule // public final TestName name = new TestName(); // // private Date startTime; // // @Before // public void setUpBeforeTest() { // startTime = new Date(); // System.out.println("==================================================================="); // System.out.println("BEGIN TEST " + name.getMethodName()); // System.out.println("==================================================================="); // // } // // @After // public void tearDownAfterTest() { // final String time = new BigDecimal(new Date().getTime() - startTime.getTime()).divide(new BigDecimal(1000)).toString(); // System.out.println("==================================================================="); // System.out.println("END TEST " + name.getMethodName()); // System.out.println("Execution time: " + time + " seconds"); // System.out.println("==================================================================="); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/SystemPropertiesReader.java // public class SystemPropertiesReader implements Reader { // // @Override // public Map<String, PropertyValue> read() { // final Map<String, PropertyValue> properties = new HashMap<>(); // final Properties systemProperties = System.getProperties(); // for(final Entry<Object, Object> x : systemProperties.entrySet()) { // properties.put((String)x.getKey(), PropertyValue.of((String)x.getValue())); // } // return properties; // } // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Map; import java.util.UUID; import org.junit.Test; import com.ufoscout.properlty.ProperltyBaseTest; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.SystemPropertiesReader;
/******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader; public class SystemPropertiesReaderTest extends ProperltyBaseTest{ @Test public void shouldReadSystemProperties() { final String key = UUID.randomUUID().toString(); final String value = UUID.randomUUID().toString(); System.setProperty(key, value);
// Path: properlty/src/test/java/com/ufoscout/properlty/ProperltyBaseTest.java // public abstract class ProperltyBaseTest { // // @Rule // public final TestName name = new TestName(); // // private Date startTime; // // @Before // public void setUpBeforeTest() { // startTime = new Date(); // System.out.println("==================================================================="); // System.out.println("BEGIN TEST " + name.getMethodName()); // System.out.println("==================================================================="); // // } // // @After // public void tearDownAfterTest() { // final String time = new BigDecimal(new Date().getTime() - startTime.getTime()).divide(new BigDecimal(1000)).toString(); // System.out.println("==================================================================="); // System.out.println("END TEST " + name.getMethodName()); // System.out.println("Execution time: " + time + " seconds"); // System.out.println("==================================================================="); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/SystemPropertiesReader.java // public class SystemPropertiesReader implements Reader { // // @Override // public Map<String, PropertyValue> read() { // final Map<String, PropertyValue> properties = new HashMap<>(); // final Properties systemProperties = System.getProperties(); // for(final Entry<Object, Object> x : systemProperties.entrySet()) { // properties.put((String)x.getKey(), PropertyValue.of((String)x.getValue())); // } // return properties; // } // // } // Path: properlty-common/src/test/java/com/ufoscout/properlty/reader/SystemPropertiesReaderTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Map; import java.util.UUID; import org.junit.Test; import com.ufoscout.properlty.ProperltyBaseTest; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.SystemPropertiesReader; /******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader; public class SystemPropertiesReaderTest extends ProperltyBaseTest{ @Test public void shouldReadSystemProperties() { final String key = UUID.randomUUID().toString(); final String value = UUID.randomUUID().toString(); System.setProperty(key, value);
final Map<String, PropertyValue> systemProperties = new SystemPropertiesReader().read();
ufoscout/properlty
properlty-common/src/test/java/com/ufoscout/properlty/reader/SystemPropertiesReaderTest.java
// Path: properlty/src/test/java/com/ufoscout/properlty/ProperltyBaseTest.java // public abstract class ProperltyBaseTest { // // @Rule // public final TestName name = new TestName(); // // private Date startTime; // // @Before // public void setUpBeforeTest() { // startTime = new Date(); // System.out.println("==================================================================="); // System.out.println("BEGIN TEST " + name.getMethodName()); // System.out.println("==================================================================="); // // } // // @After // public void tearDownAfterTest() { // final String time = new BigDecimal(new Date().getTime() - startTime.getTime()).divide(new BigDecimal(1000)).toString(); // System.out.println("==================================================================="); // System.out.println("END TEST " + name.getMethodName()); // System.out.println("Execution time: " + time + " seconds"); // System.out.println("==================================================================="); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/SystemPropertiesReader.java // public class SystemPropertiesReader implements Reader { // // @Override // public Map<String, PropertyValue> read() { // final Map<String, PropertyValue> properties = new HashMap<>(); // final Properties systemProperties = System.getProperties(); // for(final Entry<Object, Object> x : systemProperties.entrySet()) { // properties.put((String)x.getKey(), PropertyValue.of((String)x.getValue())); // } // return properties; // } // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Map; import java.util.UUID; import org.junit.Test; import com.ufoscout.properlty.ProperltyBaseTest; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.SystemPropertiesReader;
/******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader; public class SystemPropertiesReaderTest extends ProperltyBaseTest{ @Test public void shouldReadSystemProperties() { final String key = UUID.randomUUID().toString(); final String value = UUID.randomUUID().toString(); System.setProperty(key, value);
// Path: properlty/src/test/java/com/ufoscout/properlty/ProperltyBaseTest.java // public abstract class ProperltyBaseTest { // // @Rule // public final TestName name = new TestName(); // // private Date startTime; // // @Before // public void setUpBeforeTest() { // startTime = new Date(); // System.out.println("==================================================================="); // System.out.println("BEGIN TEST " + name.getMethodName()); // System.out.println("==================================================================="); // // } // // @After // public void tearDownAfterTest() { // final String time = new BigDecimal(new Date().getTime() - startTime.getTime()).divide(new BigDecimal(1000)).toString(); // System.out.println("==================================================================="); // System.out.println("END TEST " + name.getMethodName()); // System.out.println("Execution time: " + time + " seconds"); // System.out.println("==================================================================="); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/SystemPropertiesReader.java // public class SystemPropertiesReader implements Reader { // // @Override // public Map<String, PropertyValue> read() { // final Map<String, PropertyValue> properties = new HashMap<>(); // final Properties systemProperties = System.getProperties(); // for(final Entry<Object, Object> x : systemProperties.entrySet()) { // properties.put((String)x.getKey(), PropertyValue.of((String)x.getValue())); // } // return properties; // } // // } // Path: properlty-common/src/test/java/com/ufoscout/properlty/reader/SystemPropertiesReaderTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Map; import java.util.UUID; import org.junit.Test; import com.ufoscout.properlty.ProperltyBaseTest; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.SystemPropertiesReader; /******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader; public class SystemPropertiesReaderTest extends ProperltyBaseTest{ @Test public void shouldReadSystemProperties() { final String key = UUID.randomUUID().toString(); final String value = UUID.randomUUID().toString(); System.setProperty(key, value);
final Map<String, PropertyValue> systemProperties = new SystemPropertiesReader().read();
ufoscout/properlty
properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertiesResourceReader.java
// Path: properlty-common/src/main/java/com/ufoscout/properlty/exception/ResourceNotFoundException.java // public class ResourceNotFoundException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ResourceNotFoundException(Throwable cause) { // super(cause); // } // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/util/FileUtils.java // public final class FileUtils { // // public static final String FILE_PATH_PREFIX = "file:"; // public static final String CLASSPATH_PREFIX = "classpath:"; // private FileUtils() {} // // /** // * It returns an {@link InputStream} on the resource. // * The resourcePath can be: // * - ./path/file : path of a file in the filesystem // * - file:./path/file : same as previous case, a path of a file in the filesystem // * - classpath:/path/file : path of a resource in the classpath // * // * @param path // * @return // * @throws FileNotFoundException // */ // public static InputStream getStream(String resourcePath) throws FileNotFoundException { // if (resourcePath.startsWith(CLASSPATH_PREFIX)) { // final String resourceName = resourcePath.substring(CLASSPATH_PREFIX.length()); // final InputStream is = FileUtils.class.getClassLoader().getResourceAsStream(resourceName); // if (is == null) { // throw new FileNotFoundException("Cannot retrieve classpath resource [" + resourceName + "]"); // } // return is; // } // if (resourcePath.startsWith(FILE_PATH_PREFIX)) { // return new FileInputStream(resourcePath.substring(FILE_PATH_PREFIX.length())); // } // return new FileInputStream(resourcePath); // } // // }
import com.ufoscout.properlty.exception.ResourceNotFoundException; import com.ufoscout.properlty.util.FileUtils; import java.io.FileNotFoundException; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Properties;
/******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader; /** * Return a {@link Map} with all values from a properties file. * * @author Francesco Cina * */ public class PropertiesResourceReader implements Reader { private final String resourcePath; private boolean ignoreNotFound = false; private Charset charset = StandardCharsets.UTF_8; /** * * Build a properties reader for the resource of a specified path. * The path can be in the form: * * - ./path/file : path of a file in the filesystem * - file:./path/file : same as previous case, a path of a file in the filesystem * - classpath:/path/file : path of a resource in the classpath * * @param resourcePath the path on the filesystem of the properties file */ public static PropertiesResourceReader build(String resourcePath) { return new PropertiesResourceReader(resourcePath); } private PropertiesResourceReader(String resourcePath) { this.resourcePath = resourcePath; } @Override public Map<String, PropertyValue> read() {
// Path: properlty-common/src/main/java/com/ufoscout/properlty/exception/ResourceNotFoundException.java // public class ResourceNotFoundException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ResourceNotFoundException(Throwable cause) { // super(cause); // } // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/util/FileUtils.java // public final class FileUtils { // // public static final String FILE_PATH_PREFIX = "file:"; // public static final String CLASSPATH_PREFIX = "classpath:"; // private FileUtils() {} // // /** // * It returns an {@link InputStream} on the resource. // * The resourcePath can be: // * - ./path/file : path of a file in the filesystem // * - file:./path/file : same as previous case, a path of a file in the filesystem // * - classpath:/path/file : path of a resource in the classpath // * // * @param path // * @return // * @throws FileNotFoundException // */ // public static InputStream getStream(String resourcePath) throws FileNotFoundException { // if (resourcePath.startsWith(CLASSPATH_PREFIX)) { // final String resourceName = resourcePath.substring(CLASSPATH_PREFIX.length()); // final InputStream is = FileUtils.class.getClassLoader().getResourceAsStream(resourceName); // if (is == null) { // throw new FileNotFoundException("Cannot retrieve classpath resource [" + resourceName + "]"); // } // return is; // } // if (resourcePath.startsWith(FILE_PATH_PREFIX)) { // return new FileInputStream(resourcePath.substring(FILE_PATH_PREFIX.length())); // } // return new FileInputStream(resourcePath); // } // // } // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertiesResourceReader.java import com.ufoscout.properlty.exception.ResourceNotFoundException; import com.ufoscout.properlty.util.FileUtils; import java.io.FileNotFoundException; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Properties; /******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader; /** * Return a {@link Map} with all values from a properties file. * * @author Francesco Cina * */ public class PropertiesResourceReader implements Reader { private final String resourcePath; private boolean ignoreNotFound = false; private Charset charset = StandardCharsets.UTF_8; /** * * Build a properties reader for the resource of a specified path. * The path can be in the form: * * - ./path/file : path of a file in the filesystem * - file:./path/file : same as previous case, a path of a file in the filesystem * - classpath:/path/file : path of a resource in the classpath * * @param resourcePath the path on the filesystem of the properties file */ public static PropertiesResourceReader build(String resourcePath) { return new PropertiesResourceReader(resourcePath); } private PropertiesResourceReader(String resourcePath) { this.resourcePath = resourcePath; } @Override public Map<String, PropertyValue> read() {
try(InputStream inputStream = FileUtils.getStream(resourcePath))
ufoscout/properlty
properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertiesResourceReader.java
// Path: properlty-common/src/main/java/com/ufoscout/properlty/exception/ResourceNotFoundException.java // public class ResourceNotFoundException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ResourceNotFoundException(Throwable cause) { // super(cause); // } // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/util/FileUtils.java // public final class FileUtils { // // public static final String FILE_PATH_PREFIX = "file:"; // public static final String CLASSPATH_PREFIX = "classpath:"; // private FileUtils() {} // // /** // * It returns an {@link InputStream} on the resource. // * The resourcePath can be: // * - ./path/file : path of a file in the filesystem // * - file:./path/file : same as previous case, a path of a file in the filesystem // * - classpath:/path/file : path of a resource in the classpath // * // * @param path // * @return // * @throws FileNotFoundException // */ // public static InputStream getStream(String resourcePath) throws FileNotFoundException { // if (resourcePath.startsWith(CLASSPATH_PREFIX)) { // final String resourceName = resourcePath.substring(CLASSPATH_PREFIX.length()); // final InputStream is = FileUtils.class.getClassLoader().getResourceAsStream(resourceName); // if (is == null) { // throw new FileNotFoundException("Cannot retrieve classpath resource [" + resourceName + "]"); // } // return is; // } // if (resourcePath.startsWith(FILE_PATH_PREFIX)) { // return new FileInputStream(resourcePath.substring(FILE_PATH_PREFIX.length())); // } // return new FileInputStream(resourcePath); // } // // }
import com.ufoscout.properlty.exception.ResourceNotFoundException; import com.ufoscout.properlty.util.FileUtils; import java.io.FileNotFoundException; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Properties;
/******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader; /** * Return a {@link Map} with all values from a properties file. * * @author Francesco Cina * */ public class PropertiesResourceReader implements Reader { private final String resourcePath; private boolean ignoreNotFound = false; private Charset charset = StandardCharsets.UTF_8; /** * * Build a properties reader for the resource of a specified path. * The path can be in the form: * * - ./path/file : path of a file in the filesystem * - file:./path/file : same as previous case, a path of a file in the filesystem * - classpath:/path/file : path of a resource in the classpath * * @param resourcePath the path on the filesystem of the properties file */ public static PropertiesResourceReader build(String resourcePath) { return new PropertiesResourceReader(resourcePath); } private PropertiesResourceReader(String resourcePath) { this.resourcePath = resourcePath; } @Override public Map<String, PropertyValue> read() { try(InputStream inputStream = FileUtils.getStream(resourcePath)) { final Properties prop = new Properties(); final Map<String, PropertyValue> map = new HashMap<>(); prop.load(new InputStreamReader(inputStream, charset)); for (final Entry<Object, Object> entry : prop.entrySet()) { map.put((String) entry.getKey(), PropertyValue.of((String) entry.getValue())); } return map; } catch (final FileNotFoundException e) { if (ignoreNotFound) { return new HashMap<>(); } else {
// Path: properlty-common/src/main/java/com/ufoscout/properlty/exception/ResourceNotFoundException.java // public class ResourceNotFoundException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ResourceNotFoundException(Throwable cause) { // super(cause); // } // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/util/FileUtils.java // public final class FileUtils { // // public static final String FILE_PATH_PREFIX = "file:"; // public static final String CLASSPATH_PREFIX = "classpath:"; // private FileUtils() {} // // /** // * It returns an {@link InputStream} on the resource. // * The resourcePath can be: // * - ./path/file : path of a file in the filesystem // * - file:./path/file : same as previous case, a path of a file in the filesystem // * - classpath:/path/file : path of a resource in the classpath // * // * @param path // * @return // * @throws FileNotFoundException // */ // public static InputStream getStream(String resourcePath) throws FileNotFoundException { // if (resourcePath.startsWith(CLASSPATH_PREFIX)) { // final String resourceName = resourcePath.substring(CLASSPATH_PREFIX.length()); // final InputStream is = FileUtils.class.getClassLoader().getResourceAsStream(resourceName); // if (is == null) { // throw new FileNotFoundException("Cannot retrieve classpath resource [" + resourceName + "]"); // } // return is; // } // if (resourcePath.startsWith(FILE_PATH_PREFIX)) { // return new FileInputStream(resourcePath.substring(FILE_PATH_PREFIX.length())); // } // return new FileInputStream(resourcePath); // } // // } // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertiesResourceReader.java import com.ufoscout.properlty.exception.ResourceNotFoundException; import com.ufoscout.properlty.util.FileUtils; import java.io.FileNotFoundException; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Properties; /******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader; /** * Return a {@link Map} with all values from a properties file. * * @author Francesco Cina * */ public class PropertiesResourceReader implements Reader { private final String resourcePath; private boolean ignoreNotFound = false; private Charset charset = StandardCharsets.UTF_8; /** * * Build a properties reader for the resource of a specified path. * The path can be in the form: * * - ./path/file : path of a file in the filesystem * - file:./path/file : same as previous case, a path of a file in the filesystem * - classpath:/path/file : path of a resource in the classpath * * @param resourcePath the path on the filesystem of the properties file */ public static PropertiesResourceReader build(String resourcePath) { return new PropertiesResourceReader(resourcePath); } private PropertiesResourceReader(String resourcePath) { this.resourcePath = resourcePath; } @Override public Map<String, PropertyValue> read() { try(InputStream inputStream = FileUtils.getStream(resourcePath)) { final Properties prop = new Properties(); final Map<String, PropertyValue> map = new HashMap<>(); prop.load(new InputStreamReader(inputStream, charset)); for (final Entry<Object, Object> entry : prop.entrySet()) { map.put((String) entry.getKey(), PropertyValue.of((String) entry.getValue())); } return map; } catch (final FileNotFoundException e) { if (ignoreNotFound) { return new HashMap<>(); } else {
throw new ResourceNotFoundException(e);
ufoscout/properlty
properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/PriorityQueueDecoratorReaderTest.java
// Path: properlty/src/test/java/com/ufoscout/properlty/ProperltyBaseTest.java // public abstract class ProperltyBaseTest { // // @Rule // public final TestName name = new TestName(); // // private Date startTime; // // @Before // public void setUpBeforeTest() { // startTime = new Date(); // System.out.println("==================================================================="); // System.out.println("BEGIN TEST " + name.getMethodName()); // System.out.println("==================================================================="); // // } // // @After // public void tearDownAfterTest() { // final String time = new BigDecimal(new Date().getTime() - startTime.getTime()).divide(new BigDecimal(1000)).toString(); // System.out.println("==================================================================="); // System.out.println("END TEST " + name.getMethodName()); // System.out.println("Execution time: " + time + " seconds"); // System.out.println("==================================================================="); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/decorator/PriorityQueueDecoratorReader.java // public class PriorityQueueDecoratorReader implements Reader { // // private final Map<Integer, List<Reader>> readersMap = new TreeMap<>(Collections.reverseOrder()); // // @Override // public Map<String, PropertyValue> read() { // final Map<String, PropertyValue> result = new LinkedHashMap<>(); // readersMap.forEach((priority, readers) -> { // readers.forEach(reader -> { // final Map<String, PropertyValue> entries = reader.read(); // result.putAll(entries); // }); // }) ; // // return result; // } // // public void add(Reader reader, int priority) { // final List<Reader> readers = readersMap.computeIfAbsent(priority, p -> new ArrayList<>()); // readers.add(reader); // } // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Map; import org.junit.Test; import com.ufoscout.properlty.ProperltyBaseTest; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.decorator.PriorityQueueDecoratorReader;
/******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; public class PriorityQueueDecoratorReaderTest extends ProperltyBaseTest { @Test public void shouldReturnEmptyMapIfEmpty() {
// Path: properlty/src/test/java/com/ufoscout/properlty/ProperltyBaseTest.java // public abstract class ProperltyBaseTest { // // @Rule // public final TestName name = new TestName(); // // private Date startTime; // // @Before // public void setUpBeforeTest() { // startTime = new Date(); // System.out.println("==================================================================="); // System.out.println("BEGIN TEST " + name.getMethodName()); // System.out.println("==================================================================="); // // } // // @After // public void tearDownAfterTest() { // final String time = new BigDecimal(new Date().getTime() - startTime.getTime()).divide(new BigDecimal(1000)).toString(); // System.out.println("==================================================================="); // System.out.println("END TEST " + name.getMethodName()); // System.out.println("Execution time: " + time + " seconds"); // System.out.println("==================================================================="); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/decorator/PriorityQueueDecoratorReader.java // public class PriorityQueueDecoratorReader implements Reader { // // private final Map<Integer, List<Reader>> readersMap = new TreeMap<>(Collections.reverseOrder()); // // @Override // public Map<String, PropertyValue> read() { // final Map<String, PropertyValue> result = new LinkedHashMap<>(); // readersMap.forEach((priority, readers) -> { // readers.forEach(reader -> { // final Map<String, PropertyValue> entries = reader.read(); // result.putAll(entries); // }); // }) ; // // return result; // } // // public void add(Reader reader, int priority) { // final List<Reader> readers = readersMap.computeIfAbsent(priority, p -> new ArrayList<>()); // readers.add(reader); // } // // } // Path: properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/PriorityQueueDecoratorReaderTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Map; import org.junit.Test; import com.ufoscout.properlty.ProperltyBaseTest; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.decorator.PriorityQueueDecoratorReader; /******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; public class PriorityQueueDecoratorReaderTest extends ProperltyBaseTest { @Test public void shouldReturnEmptyMapIfEmpty() {
final PriorityQueueDecoratorReader queue = new PriorityQueueDecoratorReader();
ufoscout/properlty
properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/PriorityQueueDecoratorReaderTest.java
// Path: properlty/src/test/java/com/ufoscout/properlty/ProperltyBaseTest.java // public abstract class ProperltyBaseTest { // // @Rule // public final TestName name = new TestName(); // // private Date startTime; // // @Before // public void setUpBeforeTest() { // startTime = new Date(); // System.out.println("==================================================================="); // System.out.println("BEGIN TEST " + name.getMethodName()); // System.out.println("==================================================================="); // // } // // @After // public void tearDownAfterTest() { // final String time = new BigDecimal(new Date().getTime() - startTime.getTime()).divide(new BigDecimal(1000)).toString(); // System.out.println("==================================================================="); // System.out.println("END TEST " + name.getMethodName()); // System.out.println("Execution time: " + time + " seconds"); // System.out.println("==================================================================="); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/decorator/PriorityQueueDecoratorReader.java // public class PriorityQueueDecoratorReader implements Reader { // // private final Map<Integer, List<Reader>> readersMap = new TreeMap<>(Collections.reverseOrder()); // // @Override // public Map<String, PropertyValue> read() { // final Map<String, PropertyValue> result = new LinkedHashMap<>(); // readersMap.forEach((priority, readers) -> { // readers.forEach(reader -> { // final Map<String, PropertyValue> entries = reader.read(); // result.putAll(entries); // }); // }) ; // // return result; // } // // public void add(Reader reader, int priority) { // final List<Reader> readers = readersMap.computeIfAbsent(priority, p -> new ArrayList<>()); // readers.add(reader); // } // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Map; import org.junit.Test; import com.ufoscout.properlty.ProperltyBaseTest; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.decorator.PriorityQueueDecoratorReader;
/******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; public class PriorityQueueDecoratorReaderTest extends ProperltyBaseTest { @Test public void shouldReturnEmptyMapIfEmpty() { final PriorityQueueDecoratorReader queue = new PriorityQueueDecoratorReader();
// Path: properlty/src/test/java/com/ufoscout/properlty/ProperltyBaseTest.java // public abstract class ProperltyBaseTest { // // @Rule // public final TestName name = new TestName(); // // private Date startTime; // // @Before // public void setUpBeforeTest() { // startTime = new Date(); // System.out.println("==================================================================="); // System.out.println("BEGIN TEST " + name.getMethodName()); // System.out.println("==================================================================="); // // } // // @After // public void tearDownAfterTest() { // final String time = new BigDecimal(new Date().getTime() - startTime.getTime()).divide(new BigDecimal(1000)).toString(); // System.out.println("==================================================================="); // System.out.println("END TEST " + name.getMethodName()); // System.out.println("Execution time: " + time + " seconds"); // System.out.println("==================================================================="); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/decorator/PriorityQueueDecoratorReader.java // public class PriorityQueueDecoratorReader implements Reader { // // private final Map<Integer, List<Reader>> readersMap = new TreeMap<>(Collections.reverseOrder()); // // @Override // public Map<String, PropertyValue> read() { // final Map<String, PropertyValue> result = new LinkedHashMap<>(); // readersMap.forEach((priority, readers) -> { // readers.forEach(reader -> { // final Map<String, PropertyValue> entries = reader.read(); // result.putAll(entries); // }); // }) ; // // return result; // } // // public void add(Reader reader, int priority) { // final List<Reader> readers = readersMap.computeIfAbsent(priority, p -> new ArrayList<>()); // readers.add(reader); // } // // } // Path: properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/PriorityQueueDecoratorReaderTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Map; import org.junit.Test; import com.ufoscout.properlty.ProperltyBaseTest; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.decorator.PriorityQueueDecoratorReader; /******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; public class PriorityQueueDecoratorReaderTest extends ProperltyBaseTest { @Test public void shouldReturnEmptyMapIfEmpty() { final PriorityQueueDecoratorReader queue = new PriorityQueueDecoratorReader();
final Map<String, PropertyValue> prop = queue.read();
ufoscout/properlty
properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/PriorityQueueDecoratorReaderTest.java
// Path: properlty/src/test/java/com/ufoscout/properlty/ProperltyBaseTest.java // public abstract class ProperltyBaseTest { // // @Rule // public final TestName name = new TestName(); // // private Date startTime; // // @Before // public void setUpBeforeTest() { // startTime = new Date(); // System.out.println("==================================================================="); // System.out.println("BEGIN TEST " + name.getMethodName()); // System.out.println("==================================================================="); // // } // // @After // public void tearDownAfterTest() { // final String time = new BigDecimal(new Date().getTime() - startTime.getTime()).divide(new BigDecimal(1000)).toString(); // System.out.println("==================================================================="); // System.out.println("END TEST " + name.getMethodName()); // System.out.println("Execution time: " + time + " seconds"); // System.out.println("==================================================================="); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/decorator/PriorityQueueDecoratorReader.java // public class PriorityQueueDecoratorReader implements Reader { // // private final Map<Integer, List<Reader>> readersMap = new TreeMap<>(Collections.reverseOrder()); // // @Override // public Map<String, PropertyValue> read() { // final Map<String, PropertyValue> result = new LinkedHashMap<>(); // readersMap.forEach((priority, readers) -> { // readers.forEach(reader -> { // final Map<String, PropertyValue> entries = reader.read(); // result.putAll(entries); // }); // }) ; // // return result; // } // // public void add(Reader reader, int priority) { // final List<Reader> readers = readersMap.computeIfAbsent(priority, p -> new ArrayList<>()); // readers.add(reader); // } // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Map; import org.junit.Test; import com.ufoscout.properlty.ProperltyBaseTest; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.decorator.PriorityQueueDecoratorReader;
/******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; public class PriorityQueueDecoratorReaderTest extends ProperltyBaseTest { @Test public void shouldReturnEmptyMapIfEmpty() { final PriorityQueueDecoratorReader queue = new PriorityQueueDecoratorReader(); final Map<String, PropertyValue> prop = queue.read(); assertNotNull(prop); assertTrue(prop.isEmpty()); } @Test public void shouldMergeEntriesFromMapWithDifferentPriority() { final PriorityQueueDecoratorReader queue = new PriorityQueueDecoratorReader();
// Path: properlty/src/test/java/com/ufoscout/properlty/ProperltyBaseTest.java // public abstract class ProperltyBaseTest { // // @Rule // public final TestName name = new TestName(); // // private Date startTime; // // @Before // public void setUpBeforeTest() { // startTime = new Date(); // System.out.println("==================================================================="); // System.out.println("BEGIN TEST " + name.getMethodName()); // System.out.println("==================================================================="); // // } // // @After // public void tearDownAfterTest() { // final String time = new BigDecimal(new Date().getTime() - startTime.getTime()).divide(new BigDecimal(1000)).toString(); // System.out.println("==================================================================="); // System.out.println("END TEST " + name.getMethodName()); // System.out.println("Execution time: " + time + " seconds"); // System.out.println("==================================================================="); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/decorator/PriorityQueueDecoratorReader.java // public class PriorityQueueDecoratorReader implements Reader { // // private final Map<Integer, List<Reader>> readersMap = new TreeMap<>(Collections.reverseOrder()); // // @Override // public Map<String, PropertyValue> read() { // final Map<String, PropertyValue> result = new LinkedHashMap<>(); // readersMap.forEach((priority, readers) -> { // readers.forEach(reader -> { // final Map<String, PropertyValue> entries = reader.read(); // result.putAll(entries); // }); // }) ; // // return result; // } // // public void add(Reader reader, int priority) { // final List<Reader> readers = readersMap.computeIfAbsent(priority, p -> new ArrayList<>()); // readers.add(reader); // } // // } // Path: properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/PriorityQueueDecoratorReaderTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Map; import org.junit.Test; import com.ufoscout.properlty.ProperltyBaseTest; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.decorator.PriorityQueueDecoratorReader; /******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; public class PriorityQueueDecoratorReaderTest extends ProperltyBaseTest { @Test public void shouldReturnEmptyMapIfEmpty() { final PriorityQueueDecoratorReader queue = new PriorityQueueDecoratorReader(); final Map<String, PropertyValue> prop = queue.read(); assertNotNull(prop); assertTrue(prop.isEmpty()); } @Test public void shouldMergeEntriesFromMapWithDifferentPriority() { final PriorityQueueDecoratorReader queue = new PriorityQueueDecoratorReader();
queue.add(Properties.add("k1", "v1").add("k2", "v2"), 11);
ufoscout/properlty
properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/ReplacerDecoratorReaderTest.java
// Path: properlty/src/test/java/com/ufoscout/properlty/ProperltyBaseTest.java // public abstract class ProperltyBaseTest { // // @Rule // public final TestName name = new TestName(); // // private Date startTime; // // @Before // public void setUpBeforeTest() { // startTime = new Date(); // System.out.println("==================================================================="); // System.out.println("BEGIN TEST " + name.getMethodName()); // System.out.println("==================================================================="); // // } // // @After // public void tearDownAfterTest() { // final String time = new BigDecimal(new Date().getTime() - startTime.getTime()).divide(new BigDecimal(1000)).toString(); // System.out.println("==================================================================="); // System.out.println("END TEST " + name.getMethodName()); // System.out.println("Execution time: " + time + " seconds"); // System.out.println("==================================================================="); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/exception/UnresolvablePlaceholdersException.java // public class UnresolvablePlaceholdersException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public UnresolvablePlaceholdersException(String message) { // super(message); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/ProgrammaticPropertiesReader.java // public class ProgrammaticPropertiesReader implements Reader { // // private final Map<String, PropertyValue> properties = new HashMap<>(); // // ProgrammaticPropertiesReader() {} // // @Override // public Map<String, PropertyValue> read() { // return properties; // } // // /** // * Add a new property // * // * @param key // * @param value // * @return // */ // public ProgrammaticPropertiesReader add(String key, String value) { // properties.put(key, PropertyValue.of(value)); // return this; // } // // /** // * Add a new property // * // * @param key // * @param value // * @return // */ // public ProgrammaticPropertiesReader add(String key, PropertyValue value) { // properties.put(key, value); // return this; // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import com.ufoscout.properlty.ProperltyBaseTest; import com.ufoscout.properlty.exception.UnresolvablePlaceholdersException; import com.ufoscout.properlty.reader.ProgrammaticPropertiesReader; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import java.util.Map; import org.junit.Test;
/******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; public class ReplacerDecoratorReaderTest extends ProperltyBaseTest { @Test public void shouldResolveSimpleKeys() {
// Path: properlty/src/test/java/com/ufoscout/properlty/ProperltyBaseTest.java // public abstract class ProperltyBaseTest { // // @Rule // public final TestName name = new TestName(); // // private Date startTime; // // @Before // public void setUpBeforeTest() { // startTime = new Date(); // System.out.println("==================================================================="); // System.out.println("BEGIN TEST " + name.getMethodName()); // System.out.println("==================================================================="); // // } // // @After // public void tearDownAfterTest() { // final String time = new BigDecimal(new Date().getTime() - startTime.getTime()).divide(new BigDecimal(1000)).toString(); // System.out.println("==================================================================="); // System.out.println("END TEST " + name.getMethodName()); // System.out.println("Execution time: " + time + " seconds"); // System.out.println("==================================================================="); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/exception/UnresolvablePlaceholdersException.java // public class UnresolvablePlaceholdersException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public UnresolvablePlaceholdersException(String message) { // super(message); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/ProgrammaticPropertiesReader.java // public class ProgrammaticPropertiesReader implements Reader { // // private final Map<String, PropertyValue> properties = new HashMap<>(); // // ProgrammaticPropertiesReader() {} // // @Override // public Map<String, PropertyValue> read() { // return properties; // } // // /** // * Add a new property // * // * @param key // * @param value // * @return // */ // public ProgrammaticPropertiesReader add(String key, String value) { // properties.put(key, PropertyValue.of(value)); // return this; // } // // /** // * Add a new property // * // * @param key // * @param value // * @return // */ // public ProgrammaticPropertiesReader add(String key, PropertyValue value) { // properties.put(key, value); // return this; // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // Path: properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/ReplacerDecoratorReaderTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import com.ufoscout.properlty.ProperltyBaseTest; import com.ufoscout.properlty.exception.UnresolvablePlaceholdersException; import com.ufoscout.properlty.reader.ProgrammaticPropertiesReader; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import java.util.Map; import org.junit.Test; /******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; public class ReplacerDecoratorReaderTest extends ProperltyBaseTest { @Test public void shouldResolveSimpleKeys() {
final ProgrammaticPropertiesReader properties = Properties.add("key.one", "${key.two}");
ufoscout/properlty
properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/ReplacerDecoratorReaderTest.java
// Path: properlty/src/test/java/com/ufoscout/properlty/ProperltyBaseTest.java // public abstract class ProperltyBaseTest { // // @Rule // public final TestName name = new TestName(); // // private Date startTime; // // @Before // public void setUpBeforeTest() { // startTime = new Date(); // System.out.println("==================================================================="); // System.out.println("BEGIN TEST " + name.getMethodName()); // System.out.println("==================================================================="); // // } // // @After // public void tearDownAfterTest() { // final String time = new BigDecimal(new Date().getTime() - startTime.getTime()).divide(new BigDecimal(1000)).toString(); // System.out.println("==================================================================="); // System.out.println("END TEST " + name.getMethodName()); // System.out.println("Execution time: " + time + " seconds"); // System.out.println("==================================================================="); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/exception/UnresolvablePlaceholdersException.java // public class UnresolvablePlaceholdersException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public UnresolvablePlaceholdersException(String message) { // super(message); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/ProgrammaticPropertiesReader.java // public class ProgrammaticPropertiesReader implements Reader { // // private final Map<String, PropertyValue> properties = new HashMap<>(); // // ProgrammaticPropertiesReader() {} // // @Override // public Map<String, PropertyValue> read() { // return properties; // } // // /** // * Add a new property // * // * @param key // * @param value // * @return // */ // public ProgrammaticPropertiesReader add(String key, String value) { // properties.put(key, PropertyValue.of(value)); // return this; // } // // /** // * Add a new property // * // * @param key // * @param value // * @return // */ // public ProgrammaticPropertiesReader add(String key, PropertyValue value) { // properties.put(key, value); // return this; // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import com.ufoscout.properlty.ProperltyBaseTest; import com.ufoscout.properlty.exception.UnresolvablePlaceholdersException; import com.ufoscout.properlty.reader.ProgrammaticPropertiesReader; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import java.util.Map; import org.junit.Test;
/******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; public class ReplacerDecoratorReaderTest extends ProperltyBaseTest { @Test public void shouldResolveSimpleKeys() {
// Path: properlty/src/test/java/com/ufoscout/properlty/ProperltyBaseTest.java // public abstract class ProperltyBaseTest { // // @Rule // public final TestName name = new TestName(); // // private Date startTime; // // @Before // public void setUpBeforeTest() { // startTime = new Date(); // System.out.println("==================================================================="); // System.out.println("BEGIN TEST " + name.getMethodName()); // System.out.println("==================================================================="); // // } // // @After // public void tearDownAfterTest() { // final String time = new BigDecimal(new Date().getTime() - startTime.getTime()).divide(new BigDecimal(1000)).toString(); // System.out.println("==================================================================="); // System.out.println("END TEST " + name.getMethodName()); // System.out.println("Execution time: " + time + " seconds"); // System.out.println("==================================================================="); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/exception/UnresolvablePlaceholdersException.java // public class UnresolvablePlaceholdersException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public UnresolvablePlaceholdersException(String message) { // super(message); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/ProgrammaticPropertiesReader.java // public class ProgrammaticPropertiesReader implements Reader { // // private final Map<String, PropertyValue> properties = new HashMap<>(); // // ProgrammaticPropertiesReader() {} // // @Override // public Map<String, PropertyValue> read() { // return properties; // } // // /** // * Add a new property // * // * @param key // * @param value // * @return // */ // public ProgrammaticPropertiesReader add(String key, String value) { // properties.put(key, PropertyValue.of(value)); // return this; // } // // /** // * Add a new property // * // * @param key // * @param value // * @return // */ // public ProgrammaticPropertiesReader add(String key, PropertyValue value) { // properties.put(key, value); // return this; // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // Path: properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/ReplacerDecoratorReaderTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import com.ufoscout.properlty.ProperltyBaseTest; import com.ufoscout.properlty.exception.UnresolvablePlaceholdersException; import com.ufoscout.properlty.reader.ProgrammaticPropertiesReader; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import java.util.Map; import org.junit.Test; /******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; public class ReplacerDecoratorReaderTest extends ProperltyBaseTest { @Test public void shouldResolveSimpleKeys() {
final ProgrammaticPropertiesReader properties = Properties.add("key.one", "${key.two}");
ufoscout/properlty
properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/ReplacerDecoratorReaderTest.java
// Path: properlty/src/test/java/com/ufoscout/properlty/ProperltyBaseTest.java // public abstract class ProperltyBaseTest { // // @Rule // public final TestName name = new TestName(); // // private Date startTime; // // @Before // public void setUpBeforeTest() { // startTime = new Date(); // System.out.println("==================================================================="); // System.out.println("BEGIN TEST " + name.getMethodName()); // System.out.println("==================================================================="); // // } // // @After // public void tearDownAfterTest() { // final String time = new BigDecimal(new Date().getTime() - startTime.getTime()).divide(new BigDecimal(1000)).toString(); // System.out.println("==================================================================="); // System.out.println("END TEST " + name.getMethodName()); // System.out.println("Execution time: " + time + " seconds"); // System.out.println("==================================================================="); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/exception/UnresolvablePlaceholdersException.java // public class UnresolvablePlaceholdersException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public UnresolvablePlaceholdersException(String message) { // super(message); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/ProgrammaticPropertiesReader.java // public class ProgrammaticPropertiesReader implements Reader { // // private final Map<String, PropertyValue> properties = new HashMap<>(); // // ProgrammaticPropertiesReader() {} // // @Override // public Map<String, PropertyValue> read() { // return properties; // } // // /** // * Add a new property // * // * @param key // * @param value // * @return // */ // public ProgrammaticPropertiesReader add(String key, String value) { // properties.put(key, PropertyValue.of(value)); // return this; // } // // /** // * Add a new property // * // * @param key // * @param value // * @return // */ // public ProgrammaticPropertiesReader add(String key, PropertyValue value) { // properties.put(key, value); // return this; // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import com.ufoscout.properlty.ProperltyBaseTest; import com.ufoscout.properlty.exception.UnresolvablePlaceholdersException; import com.ufoscout.properlty.reader.ProgrammaticPropertiesReader; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import java.util.Map; import org.junit.Test;
/******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; public class ReplacerDecoratorReaderTest extends ProperltyBaseTest { @Test public void shouldResolveSimpleKeys() { final ProgrammaticPropertiesReader properties = Properties.add("key.one", "${key.two}"); properties.add("key.two", "value.two"); final boolean ignoreNotResolvable = false; final boolean caseSensitive = true;
// Path: properlty/src/test/java/com/ufoscout/properlty/ProperltyBaseTest.java // public abstract class ProperltyBaseTest { // // @Rule // public final TestName name = new TestName(); // // private Date startTime; // // @Before // public void setUpBeforeTest() { // startTime = new Date(); // System.out.println("==================================================================="); // System.out.println("BEGIN TEST " + name.getMethodName()); // System.out.println("==================================================================="); // // } // // @After // public void tearDownAfterTest() { // final String time = new BigDecimal(new Date().getTime() - startTime.getTime()).divide(new BigDecimal(1000)).toString(); // System.out.println("==================================================================="); // System.out.println("END TEST " + name.getMethodName()); // System.out.println("Execution time: " + time + " seconds"); // System.out.println("==================================================================="); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/exception/UnresolvablePlaceholdersException.java // public class UnresolvablePlaceholdersException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public UnresolvablePlaceholdersException(String message) { // super(message); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/ProgrammaticPropertiesReader.java // public class ProgrammaticPropertiesReader implements Reader { // // private final Map<String, PropertyValue> properties = new HashMap<>(); // // ProgrammaticPropertiesReader() {} // // @Override // public Map<String, PropertyValue> read() { // return properties; // } // // /** // * Add a new property // * // * @param key // * @param value // * @return // */ // public ProgrammaticPropertiesReader add(String key, String value) { // properties.put(key, PropertyValue.of(value)); // return this; // } // // /** // * Add a new property // * // * @param key // * @param value // * @return // */ // public ProgrammaticPropertiesReader add(String key, PropertyValue value) { // properties.put(key, value); // return this; // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // Path: properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/ReplacerDecoratorReaderTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import com.ufoscout.properlty.ProperltyBaseTest; import com.ufoscout.properlty.exception.UnresolvablePlaceholdersException; import com.ufoscout.properlty.reader.ProgrammaticPropertiesReader; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import java.util.Map; import org.junit.Test; /******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; public class ReplacerDecoratorReaderTest extends ProperltyBaseTest { @Test public void shouldResolveSimpleKeys() { final ProgrammaticPropertiesReader properties = Properties.add("key.one", "${key.two}"); properties.add("key.two", "value.two"); final boolean ignoreNotResolvable = false; final boolean caseSensitive = true;
final Map<String, PropertyValue> output = new ReplacerDecoratorReader(properties, "${", "}", ":", ignoreNotResolvable, caseSensitive).read();
ufoscout/properlty
properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/ReplacerDecoratorReaderTest.java
// Path: properlty/src/test/java/com/ufoscout/properlty/ProperltyBaseTest.java // public abstract class ProperltyBaseTest { // // @Rule // public final TestName name = new TestName(); // // private Date startTime; // // @Before // public void setUpBeforeTest() { // startTime = new Date(); // System.out.println("==================================================================="); // System.out.println("BEGIN TEST " + name.getMethodName()); // System.out.println("==================================================================="); // // } // // @After // public void tearDownAfterTest() { // final String time = new BigDecimal(new Date().getTime() - startTime.getTime()).divide(new BigDecimal(1000)).toString(); // System.out.println("==================================================================="); // System.out.println("END TEST " + name.getMethodName()); // System.out.println("Execution time: " + time + " seconds"); // System.out.println("==================================================================="); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/exception/UnresolvablePlaceholdersException.java // public class UnresolvablePlaceholdersException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public UnresolvablePlaceholdersException(String message) { // super(message); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/ProgrammaticPropertiesReader.java // public class ProgrammaticPropertiesReader implements Reader { // // private final Map<String, PropertyValue> properties = new HashMap<>(); // // ProgrammaticPropertiesReader() {} // // @Override // public Map<String, PropertyValue> read() { // return properties; // } // // /** // * Add a new property // * // * @param key // * @param value // * @return // */ // public ProgrammaticPropertiesReader add(String key, String value) { // properties.put(key, PropertyValue.of(value)); // return this; // } // // /** // * Add a new property // * // * @param key // * @param value // * @return // */ // public ProgrammaticPropertiesReader add(String key, PropertyValue value) { // properties.put(key, value); // return this; // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import com.ufoscout.properlty.ProperltyBaseTest; import com.ufoscout.properlty.exception.UnresolvablePlaceholdersException; import com.ufoscout.properlty.reader.ProgrammaticPropertiesReader; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import java.util.Map; import org.junit.Test;
public void shouldNotResolveUnresolvableKeys() { final ProgrammaticPropertiesReader properties = Properties.add("key.unresolvable", PropertyValue.of("${key.two}").resolvable(false)); properties.add("key.one", PropertyValue.of("${key.two}")); properties.add("key.two", PropertyValue.of("value.two")); final boolean ignoreNotResolvable = false; final boolean caseSensitive = true; final Map<String, PropertyValue> output = new ReplacerDecoratorReader(properties, "${", "}", ":", ignoreNotResolvable, caseSensitive).read(); assertNotNull(output); assertEquals(3, output.size()); assertEquals("${key.two}", output.get("key.unresolvable").getValue()); assertEquals("value.two", output.get("key.one").getValue()); assertEquals("value.two", output.get("key.two").getValue()); } @Test public void shouldFailIfNotResolvablePlaceholders() { final ProgrammaticPropertiesReader properties = Properties.add("key.1", "${key.4}"); properties.add("key.2", "${key.1}"); properties.add("key.3", "${key.2}"); properties.add("key.4", "${key.3}"); final boolean ignoreNotResolvable = false; final boolean caseSensitive = true; try { new ReplacerDecoratorReader(properties, "${", "}", ":", ignoreNotResolvable, caseSensitive).read(); fail();
// Path: properlty/src/test/java/com/ufoscout/properlty/ProperltyBaseTest.java // public abstract class ProperltyBaseTest { // // @Rule // public final TestName name = new TestName(); // // private Date startTime; // // @Before // public void setUpBeforeTest() { // startTime = new Date(); // System.out.println("==================================================================="); // System.out.println("BEGIN TEST " + name.getMethodName()); // System.out.println("==================================================================="); // // } // // @After // public void tearDownAfterTest() { // final String time = new BigDecimal(new Date().getTime() - startTime.getTime()).divide(new BigDecimal(1000)).toString(); // System.out.println("==================================================================="); // System.out.println("END TEST " + name.getMethodName()); // System.out.println("Execution time: " + time + " seconds"); // System.out.println("==================================================================="); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/exception/UnresolvablePlaceholdersException.java // public class UnresolvablePlaceholdersException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public UnresolvablePlaceholdersException(String message) { // super(message); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/ProgrammaticPropertiesReader.java // public class ProgrammaticPropertiesReader implements Reader { // // private final Map<String, PropertyValue> properties = new HashMap<>(); // // ProgrammaticPropertiesReader() {} // // @Override // public Map<String, PropertyValue> read() { // return properties; // } // // /** // * Add a new property // * // * @param key // * @param value // * @return // */ // public ProgrammaticPropertiesReader add(String key, String value) { // properties.put(key, PropertyValue.of(value)); // return this; // } // // /** // * Add a new property // * // * @param key // * @param value // * @return // */ // public ProgrammaticPropertiesReader add(String key, PropertyValue value) { // properties.put(key, value); // return this; // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // Path: properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/ReplacerDecoratorReaderTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import com.ufoscout.properlty.ProperltyBaseTest; import com.ufoscout.properlty.exception.UnresolvablePlaceholdersException; import com.ufoscout.properlty.reader.ProgrammaticPropertiesReader; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import java.util.Map; import org.junit.Test; public void shouldNotResolveUnresolvableKeys() { final ProgrammaticPropertiesReader properties = Properties.add("key.unresolvable", PropertyValue.of("${key.two}").resolvable(false)); properties.add("key.one", PropertyValue.of("${key.two}")); properties.add("key.two", PropertyValue.of("value.two")); final boolean ignoreNotResolvable = false; final boolean caseSensitive = true; final Map<String, PropertyValue> output = new ReplacerDecoratorReader(properties, "${", "}", ":", ignoreNotResolvable, caseSensitive).read(); assertNotNull(output); assertEquals(3, output.size()); assertEquals("${key.two}", output.get("key.unresolvable").getValue()); assertEquals("value.two", output.get("key.one").getValue()); assertEquals("value.two", output.get("key.two").getValue()); } @Test public void shouldFailIfNotResolvablePlaceholders() { final ProgrammaticPropertiesReader properties = Properties.add("key.1", "${key.4}"); properties.add("key.2", "${key.1}"); properties.add("key.3", "${key.2}"); properties.add("key.4", "${key.3}"); final boolean ignoreNotResolvable = false; final boolean caseSensitive = true; try { new ReplacerDecoratorReader(properties, "${", "}", ":", ignoreNotResolvable, caseSensitive).read(); fail();
} catch (final UnresolvablePlaceholdersException e) {
ufoscout/properlty
properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/ToLowerCaseAndDotKeyDecoratorReaderTest.java
// Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Reader.java // @FunctionalInterface // public interface Reader { // // Map<String, PropertyValue> read(); // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Map; import org.junit.Test; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.Reader;
/******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; public class ToLowerCaseAndDotKeyDecoratorReaderTest { @Test public void shouldLowerCaseInputMapWithoutSideEffect() {
// Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Reader.java // @FunctionalInterface // public interface Reader { // // Map<String, PropertyValue> read(); // // } // Path: properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/ToLowerCaseAndDotKeyDecoratorReaderTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Map; import org.junit.Test; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.Reader; /******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; public class ToLowerCaseAndDotKeyDecoratorReaderTest { @Test public void shouldLowerCaseInputMapWithoutSideEffect() {
final Reader input = Properties.add("UPPER_CASE_KEY_ONE", "value1")
ufoscout/properlty
properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/ToLowerCaseAndDotKeyDecoratorReaderTest.java
// Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Reader.java // @FunctionalInterface // public interface Reader { // // Map<String, PropertyValue> read(); // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Map; import org.junit.Test; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.Reader;
/******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; public class ToLowerCaseAndDotKeyDecoratorReaderTest { @Test public void shouldLowerCaseInputMapWithoutSideEffect() {
// Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Reader.java // @FunctionalInterface // public interface Reader { // // Map<String, PropertyValue> read(); // // } // Path: properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/ToLowerCaseAndDotKeyDecoratorReaderTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Map; import org.junit.Test; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.Reader; /******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; public class ToLowerCaseAndDotKeyDecoratorReaderTest { @Test public void shouldLowerCaseInputMapWithoutSideEffect() {
final Reader input = Properties.add("UPPER_CASE_KEY_ONE", "value1")
ufoscout/properlty
properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/ToLowerCaseAndDotKeyDecoratorReaderTest.java
// Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Reader.java // @FunctionalInterface // public interface Reader { // // Map<String, PropertyValue> read(); // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Map; import org.junit.Test; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.Reader;
/******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; public class ToLowerCaseAndDotKeyDecoratorReaderTest { @Test public void shouldLowerCaseInputMapWithoutSideEffect() { final Reader input = Properties.add("UPPER_CASE_KEY_ONE", "value1") .add("lower_case_key_TWO", "value2") .add("lower.case.key.three", "value3");
// Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Properties.java // public class Properties { // // public static ProgrammaticPropertiesReader add(String key, String value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // public static ProgrammaticPropertiesReader add(String key, PropertyValue value) { // return new ProgrammaticPropertiesReader().add(key, value); // } // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Reader.java // @FunctionalInterface // public interface Reader { // // Map<String, PropertyValue> read(); // // } // Path: properlty-common/src/test/java/com/ufoscout/properlty/reader/decorator/ToLowerCaseAndDotKeyDecoratorReaderTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Map; import org.junit.Test; import com.ufoscout.properlty.reader.Properties; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.Reader; /******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; public class ToLowerCaseAndDotKeyDecoratorReaderTest { @Test public void shouldLowerCaseInputMapWithoutSideEffect() { final Reader input = Properties.add("UPPER_CASE_KEY_ONE", "value1") .add("lower_case_key_TWO", "value2") .add("lower.case.key.three", "value3");
final Map<String, PropertyValue> lowerCased = new ToLowerCaseAndDotKeyReader(input).read();
ufoscout/properlty
properlty-common/src/main/java/com/ufoscout/properlty/reader/decorator/PriorityQueueDecoratorReader.java
// Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Reader.java // @FunctionalInterface // public interface Reader { // // Map<String, PropertyValue> read(); // // }
import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.Reader; import java.util.*;
/******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; /** * A {@link Reader} that wraps a prioritized list of other Readers. * Each {@link Reader} in the list has a priority that is used to resolve conflicts * when a key is defined more than once. * If two or more {@link Reader}s have the same priority, the one added by last has the highest priority * * @author Francesco Cina * */ public class PriorityQueueDecoratorReader implements Reader { private final Map<Integer, List<Reader>> readersMap = new TreeMap<>(Collections.reverseOrder()); @Override
// Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Reader.java // @FunctionalInterface // public interface Reader { // // Map<String, PropertyValue> read(); // // } // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/decorator/PriorityQueueDecoratorReader.java import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.Reader; import java.util.*; /******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; /** * A {@link Reader} that wraps a prioritized list of other Readers. * Each {@link Reader} in the list has a priority that is used to resolve conflicts * when a key is defined more than once. * If two or more {@link Reader}s have the same priority, the one added by last has the highest priority * * @author Francesco Cina * */ public class PriorityQueueDecoratorReader implements Reader { private final Map<Integer, List<Reader>> readersMap = new TreeMap<>(Collections.reverseOrder()); @Override
public Map<String, PropertyValue> read() {
ufoscout/properlty
properlty-common/src/main/java/com/ufoscout/properlty/reader/decorator/DecoratorReader.java
// Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Reader.java // @FunctionalInterface // public interface Reader { // // Map<String, PropertyValue> read(); // // }
import java.util.Map; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.Reader;
/******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; /** * A {@link Reader} decorator that applies a transformation other readers * * @author Francesco Cina * */ public abstract class DecoratorReader implements Reader { private final Reader reader; public DecoratorReader(Reader reader) { this.reader = reader; } @Override
// Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/PropertyValue.java // public class PropertyValue { // // private String value = ""; // private boolean resolvable = true; // // public static PropertyValue of(String value) { // return new PropertyValue().value(value); // } // // /** // * The property value // * // * @return the value // */ // public String getValue() { // return value; // } // /** // * Set the property value // * @param value the value to set // */ // public PropertyValue value(String value) { // this.value = value; // return this; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @return the replaceable // */ // public boolean isResolvable() { // return resolvable; // } // /** // * Whether this property contains placeholders that should be resolved. Default is true. // * // * @param resolvable // */ // public PropertyValue resolvable(boolean resolvable) { // this.resolvable = resolvable; // return this; // } // // // // } // // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/Reader.java // @FunctionalInterface // public interface Reader { // // Map<String, PropertyValue> read(); // // } // Path: properlty-common/src/main/java/com/ufoscout/properlty/reader/decorator/DecoratorReader.java import java.util.Map; import com.ufoscout.properlty.reader.PropertyValue; import com.ufoscout.properlty.reader.Reader; /******************************************************************************* * Copyright 2017 Francesco Cina' * * 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.ufoscout.properlty.reader.decorator; /** * A {@link Reader} decorator that applies a transformation other readers * * @author Francesco Cina * */ public abstract class DecoratorReader implements Reader { private final Reader reader; public DecoratorReader(Reader reader) { this.reader = reader; } @Override
public Map<String, PropertyValue> read() {
jjhesk/KickAssSlidingMenu
slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/containers/MaterialDrawerContainer.java
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/LockableScrollView.java // public class LockableScrollView extends ScrollView { // private boolean mScrollable = true; // // public LockableScrollView(Context context) { // super(context); // } // // public LockableScrollView(Context context, AttributeSet attrs) { // super(context, attrs); // } // // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // public void setScrollingEnabled(boolean enabled) { // mScrollable = enabled; // } // // public boolean isScrollable() { // return mScrollable; // } // // @Override // public boolean onTouchEvent(MotionEvent ev) { // switch (ev.getAction()) { // case MotionEvent.ACTION_DOWN: // // if we can scroll pass the event to the superclass // if (mScrollable) return super.onTouchEvent(ev); // // only continue to handle the touch event if scrolling enabled // return mScrollable; // mScrollable is always false at this point // default: // return super.onTouchEvent(ev); // } // } // // @Override // public boolean onInterceptTouchEvent(MotionEvent ev) { // // Don't do anything with intercepted touch events if // // we are not scrollable // if (!mScrollable) return false; // else return super.onInterceptTouchEvent(ev); // } // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/ImaterialBinder.java // public interface ImaterialBinder { // int getLayout(); // // View init(View view); // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/LAYOUT_DRAWER.java // public enum LAYOUT_DRAWER { // STICKY_UP(R.layout.layout_drawer_sticky_up), // STICKY_BOTTOM(R.layout.layout_drawer_sticky_bottom), // PROFILE_HEAD(R.layout.layout_drawer_headed), // USER_DEFINED_LAYOUT(-1); // private final int layout_id; // // LAYOUT_DRAWER(@LayoutRes int layout) { // this.layout_id = layout; // } // // public int getLayoutRes() { // return layout_id; // } // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/scrolli.java // public interface scrolli { // ScrollView getScrollView(); // }
import android.annotation.SuppressLint; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import mxh.kickassmenu.R; import mxh.kickassmenu.Util.LockableScrollView; import mxh.kickassmenu.menucontent.ImaterialBinder; import mxh.kickassmenu.menucontent.LAYOUT_DRAWER; import mxh.kickassmenu.menucontent.scrolli;
package mxh.kickassmenu.menucontent.containers; /** * Created by hesk on 24/6/15. */ public class MaterialDrawerContainer<T extends TextView> implements ImaterialBinder, scrolli { public LinearLayout itemMenuHolder, items, background_gradient; public ImageView background_switcher, current_back_item_background, current_head_item_photo, second_head_item_photo, third_head_item_photo, user_transition, user_switcher; public T current_head_item_title, current_head_item_sub_title;
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/LockableScrollView.java // public class LockableScrollView extends ScrollView { // private boolean mScrollable = true; // // public LockableScrollView(Context context) { // super(context); // } // // public LockableScrollView(Context context, AttributeSet attrs) { // super(context, attrs); // } // // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // public void setScrollingEnabled(boolean enabled) { // mScrollable = enabled; // } // // public boolean isScrollable() { // return mScrollable; // } // // @Override // public boolean onTouchEvent(MotionEvent ev) { // switch (ev.getAction()) { // case MotionEvent.ACTION_DOWN: // // if we can scroll pass the event to the superclass // if (mScrollable) return super.onTouchEvent(ev); // // only continue to handle the touch event if scrolling enabled // return mScrollable; // mScrollable is always false at this point // default: // return super.onTouchEvent(ev); // } // } // // @Override // public boolean onInterceptTouchEvent(MotionEvent ev) { // // Don't do anything with intercepted touch events if // // we are not scrollable // if (!mScrollable) return false; // else return super.onInterceptTouchEvent(ev); // } // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/ImaterialBinder.java // public interface ImaterialBinder { // int getLayout(); // // View init(View view); // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/LAYOUT_DRAWER.java // public enum LAYOUT_DRAWER { // STICKY_UP(R.layout.layout_drawer_sticky_up), // STICKY_BOTTOM(R.layout.layout_drawer_sticky_bottom), // PROFILE_HEAD(R.layout.layout_drawer_headed), // USER_DEFINED_LAYOUT(-1); // private final int layout_id; // // LAYOUT_DRAWER(@LayoutRes int layout) { // this.layout_id = layout; // } // // public int getLayoutRes() { // return layout_id; // } // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/scrolli.java // public interface scrolli { // ScrollView getScrollView(); // } // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/containers/MaterialDrawerContainer.java import android.annotation.SuppressLint; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import mxh.kickassmenu.R; import mxh.kickassmenu.Util.LockableScrollView; import mxh.kickassmenu.menucontent.ImaterialBinder; import mxh.kickassmenu.menucontent.LAYOUT_DRAWER; import mxh.kickassmenu.menucontent.scrolli; package mxh.kickassmenu.menucontent.containers; /** * Created by hesk on 24/6/15. */ public class MaterialDrawerContainer<T extends TextView> implements ImaterialBinder, scrolli { public LinearLayout itemMenuHolder, items, background_gradient; public ImageView background_switcher, current_back_item_background, current_head_item_photo, second_head_item_photo, third_head_item_photo, user_transition, user_switcher; public T current_head_item_title, current_head_item_sub_title;
public LAYOUT_DRAWER drawerType;
jjhesk/KickAssSlidingMenu
slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/containers/MaterialDrawerContainer.java
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/LockableScrollView.java // public class LockableScrollView extends ScrollView { // private boolean mScrollable = true; // // public LockableScrollView(Context context) { // super(context); // } // // public LockableScrollView(Context context, AttributeSet attrs) { // super(context, attrs); // } // // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // public void setScrollingEnabled(boolean enabled) { // mScrollable = enabled; // } // // public boolean isScrollable() { // return mScrollable; // } // // @Override // public boolean onTouchEvent(MotionEvent ev) { // switch (ev.getAction()) { // case MotionEvent.ACTION_DOWN: // // if we can scroll pass the event to the superclass // if (mScrollable) return super.onTouchEvent(ev); // // only continue to handle the touch event if scrolling enabled // return mScrollable; // mScrollable is always false at this point // default: // return super.onTouchEvent(ev); // } // } // // @Override // public boolean onInterceptTouchEvent(MotionEvent ev) { // // Don't do anything with intercepted touch events if // // we are not scrollable // if (!mScrollable) return false; // else return super.onInterceptTouchEvent(ev); // } // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/ImaterialBinder.java // public interface ImaterialBinder { // int getLayout(); // // View init(View view); // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/LAYOUT_DRAWER.java // public enum LAYOUT_DRAWER { // STICKY_UP(R.layout.layout_drawer_sticky_up), // STICKY_BOTTOM(R.layout.layout_drawer_sticky_bottom), // PROFILE_HEAD(R.layout.layout_drawer_headed), // USER_DEFINED_LAYOUT(-1); // private final int layout_id; // // LAYOUT_DRAWER(@LayoutRes int layout) { // this.layout_id = layout; // } // // public int getLayoutRes() { // return layout_id; // } // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/scrolli.java // public interface scrolli { // ScrollView getScrollView(); // }
import android.annotation.SuppressLint; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import mxh.kickassmenu.R; import mxh.kickassmenu.Util.LockableScrollView; import mxh.kickassmenu.menucontent.ImaterialBinder; import mxh.kickassmenu.menucontent.LAYOUT_DRAWER; import mxh.kickassmenu.menucontent.scrolli;
package mxh.kickassmenu.menucontent.containers; /** * Created by hesk on 24/6/15. */ public class MaterialDrawerContainer<T extends TextView> implements ImaterialBinder, scrolli { public LinearLayout itemMenuHolder, items, background_gradient; public ImageView background_switcher, current_back_item_background, current_head_item_photo, second_head_item_photo, third_head_item_photo, user_transition, user_switcher; public T current_head_item_title, current_head_item_sub_title; public LAYOUT_DRAWER drawerType;
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/LockableScrollView.java // public class LockableScrollView extends ScrollView { // private boolean mScrollable = true; // // public LockableScrollView(Context context) { // super(context); // } // // public LockableScrollView(Context context, AttributeSet attrs) { // super(context, attrs); // } // // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // public void setScrollingEnabled(boolean enabled) { // mScrollable = enabled; // } // // public boolean isScrollable() { // return mScrollable; // } // // @Override // public boolean onTouchEvent(MotionEvent ev) { // switch (ev.getAction()) { // case MotionEvent.ACTION_DOWN: // // if we can scroll pass the event to the superclass // if (mScrollable) return super.onTouchEvent(ev); // // only continue to handle the touch event if scrolling enabled // return mScrollable; // mScrollable is always false at this point // default: // return super.onTouchEvent(ev); // } // } // // @Override // public boolean onInterceptTouchEvent(MotionEvent ev) { // // Don't do anything with intercepted touch events if // // we are not scrollable // if (!mScrollable) return false; // else return super.onInterceptTouchEvent(ev); // } // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/ImaterialBinder.java // public interface ImaterialBinder { // int getLayout(); // // View init(View view); // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/LAYOUT_DRAWER.java // public enum LAYOUT_DRAWER { // STICKY_UP(R.layout.layout_drawer_sticky_up), // STICKY_BOTTOM(R.layout.layout_drawer_sticky_bottom), // PROFILE_HEAD(R.layout.layout_drawer_headed), // USER_DEFINED_LAYOUT(-1); // private final int layout_id; // // LAYOUT_DRAWER(@LayoutRes int layout) { // this.layout_id = layout; // } // // public int getLayoutRes() { // return layout_id; // } // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/scrolli.java // public interface scrolli { // ScrollView getScrollView(); // } // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/containers/MaterialDrawerContainer.java import android.annotation.SuppressLint; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import mxh.kickassmenu.R; import mxh.kickassmenu.Util.LockableScrollView; import mxh.kickassmenu.menucontent.ImaterialBinder; import mxh.kickassmenu.menucontent.LAYOUT_DRAWER; import mxh.kickassmenu.menucontent.scrolli; package mxh.kickassmenu.menucontent.containers; /** * Created by hesk on 24/6/15. */ public class MaterialDrawerContainer<T extends TextView> implements ImaterialBinder, scrolli { public LinearLayout itemMenuHolder, items, background_gradient; public ImageView background_switcher, current_back_item_background, current_head_item_photo, second_head_item_photo, third_head_item_photo, user_transition, user_switcher; public T current_head_item_title, current_head_item_sub_title; public LAYOUT_DRAWER drawerType;
private LockableScrollView scrollor;
jjhesk/KickAssSlidingMenu
AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/MainActivityDemo.java
// Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/expandablemenu/MenuFragment.java // public class MenuFragment extends Fragment { // // private UltimateRecyclerView ultimateRecyclerView; // private expCustomAdapter simpleRecyclerViewAdapter = null; // private LinearLayoutManager linearLayoutManager; // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // return inflater.inflate(R.layout.left_slid_menu, container, false); // } // // // private static String[] sampledatagroup1 = { // "peter", "http://google", // "billy", "http://google", // "lisa", "http://google", // "visa", "http://google" // }; // private static String[] sampledatagroup2 = { // "mother", "http://google", // "father", "http://google", // "son", "http://google", // "holy spirit", "http://google", // "god the son", "http://google" // }; // private static String[] sampledatagroup3 = { // "SONY", "http://google", // "LG", "http://google", // "SAMSUNG", "http://google", // "XIAOMI", "http://google", // "HTC", "http://google" // }; // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ultimateRecyclerView = (UltimateRecyclerView) view.findViewById(R.id.ultimate_recycler_view_menu); // ultimateRecyclerView.setHasFixedSize(false); // /** // * this is the adapter for the expanx // */ // simpleRecyclerViewAdapter = new expCustomAdapter(getActivity()); // simpleRecyclerViewAdapter.addAll(expCustomAdapter.getPreCodeMenu( // sampledatagroup1, // sampledatagroup2, // sampledatagroup3), // 0); // // linearLayoutManager = new LinearLayoutManager(getActivity()); // ultimateRecyclerView.setLayoutManager(linearLayoutManager); // ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter); // ultimateRecyclerView.setRecylerViewBackgroundColor(Color.parseColor("#ffffff")); // addExpandableFeatures(); // // } // // private void addExpandableFeatures() { // ultimateRecyclerView.getItemAnimator().setAddDuration(100); // ultimateRecyclerView.getItemAnimator().setRemoveDuration(100); // ultimateRecyclerView.getItemAnimator().setMoveDuration(200); // ultimateRecyclerView.getItemAnimator().setChangeDuration(100); // } // // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/helpr/structurebind.java // public enum structurebind { // main(R.id.main, MainActivityDemo.class), // blocktest(R.id.blocktset, testblock.class), // hb(R.id.hbstyle, demohb.class), // sys(R.id.system, MainActivityDemo.class), // profile(R.id.profiletype, MainActivityDemo.class); // private final Class<? extends AppCompatActivity> internalClazz; // private final int menu_id; // // structurebind(final @IdRes int menuid, final Class<? extends AppCompatActivity> triggerclassname) { // this.internalClazz = triggerclassname; // this.menu_id = menuid; // } // // public int getId() { // return menu_id; // } // // public Class<? extends AppCompatActivity> getClassName() { // return this.internalClazz; // } // // public static void startfromSelectionMenu(final @IdRes int menuID, final Context mcontext, @Nullable final Bundle mbundle) { // final int g = structurebind.values().length; // for (int i = 0; i < g; i++) { // structurebind bind = structurebind.values()[i]; // if (bind.getId() == menuID) { // if (mbundle != null) { // bind.newapp(mcontext, mbundle); // } else { // bind.newapp(mcontext); // } // return; // } // } // } // // public void newapp(final Context ctx) { // final Intent in = new Intent(ctx, internalClazz); // ctx.startActivity(in); // } // // // public void newapp(final Context ctx, final Bundle bun) { // final Intent in = new Intent(ctx, internalClazz); // in.putExtras(bun); // ctx.startActivity(in); // } // // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/mainpageDemo.java // public class mainpageDemo extends Fragment { // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.activity_main, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // Button bIntent = (Button) view.findViewById(R.id.openNewIntent); // bIntent.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Utils.routeSinglePage("nothing", getActivity(), CommonSingle.class); // } // }); // } // }
import android.app.Fragment; import android.view.MenuItem; import com.hkm.slidingmenulib.gestured.SlidingMenu; import com.hkm.slidingmenulib.layoutdesigns.app.SlidingAppCompactActivity; import com.hypebeast.demoslidemenu.content.expandablemenu.MenuFragment; import com.hypebeast.demoslidemenu.helpr.structurebind; import com.hypebeast.demoslidemenu.content.mainpageDemo;
package com.hypebeast.demoslidemenu; public class MainActivityDemo extends SlidingAppCompactActivity<Fragment> { @Override protected int getDefaultMainActivityLayoutId() { return SlidingAppCompactActivity.BODY_LAYOUT.actionbar.getResID(); } @Override
// Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/expandablemenu/MenuFragment.java // public class MenuFragment extends Fragment { // // private UltimateRecyclerView ultimateRecyclerView; // private expCustomAdapter simpleRecyclerViewAdapter = null; // private LinearLayoutManager linearLayoutManager; // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // return inflater.inflate(R.layout.left_slid_menu, container, false); // } // // // private static String[] sampledatagroup1 = { // "peter", "http://google", // "billy", "http://google", // "lisa", "http://google", // "visa", "http://google" // }; // private static String[] sampledatagroup2 = { // "mother", "http://google", // "father", "http://google", // "son", "http://google", // "holy spirit", "http://google", // "god the son", "http://google" // }; // private static String[] sampledatagroup3 = { // "SONY", "http://google", // "LG", "http://google", // "SAMSUNG", "http://google", // "XIAOMI", "http://google", // "HTC", "http://google" // }; // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ultimateRecyclerView = (UltimateRecyclerView) view.findViewById(R.id.ultimate_recycler_view_menu); // ultimateRecyclerView.setHasFixedSize(false); // /** // * this is the adapter for the expanx // */ // simpleRecyclerViewAdapter = new expCustomAdapter(getActivity()); // simpleRecyclerViewAdapter.addAll(expCustomAdapter.getPreCodeMenu( // sampledatagroup1, // sampledatagroup2, // sampledatagroup3), // 0); // // linearLayoutManager = new LinearLayoutManager(getActivity()); // ultimateRecyclerView.setLayoutManager(linearLayoutManager); // ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter); // ultimateRecyclerView.setRecylerViewBackgroundColor(Color.parseColor("#ffffff")); // addExpandableFeatures(); // // } // // private void addExpandableFeatures() { // ultimateRecyclerView.getItemAnimator().setAddDuration(100); // ultimateRecyclerView.getItemAnimator().setRemoveDuration(100); // ultimateRecyclerView.getItemAnimator().setMoveDuration(200); // ultimateRecyclerView.getItemAnimator().setChangeDuration(100); // } // // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/helpr/structurebind.java // public enum structurebind { // main(R.id.main, MainActivityDemo.class), // blocktest(R.id.blocktset, testblock.class), // hb(R.id.hbstyle, demohb.class), // sys(R.id.system, MainActivityDemo.class), // profile(R.id.profiletype, MainActivityDemo.class); // private final Class<? extends AppCompatActivity> internalClazz; // private final int menu_id; // // structurebind(final @IdRes int menuid, final Class<? extends AppCompatActivity> triggerclassname) { // this.internalClazz = triggerclassname; // this.menu_id = menuid; // } // // public int getId() { // return menu_id; // } // // public Class<? extends AppCompatActivity> getClassName() { // return this.internalClazz; // } // // public static void startfromSelectionMenu(final @IdRes int menuID, final Context mcontext, @Nullable final Bundle mbundle) { // final int g = structurebind.values().length; // for (int i = 0; i < g; i++) { // structurebind bind = structurebind.values()[i]; // if (bind.getId() == menuID) { // if (mbundle != null) { // bind.newapp(mcontext, mbundle); // } else { // bind.newapp(mcontext); // } // return; // } // } // } // // public void newapp(final Context ctx) { // final Intent in = new Intent(ctx, internalClazz); // ctx.startActivity(in); // } // // // public void newapp(final Context ctx, final Bundle bun) { // final Intent in = new Intent(ctx, internalClazz); // in.putExtras(bun); // ctx.startActivity(in); // } // // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/mainpageDemo.java // public class mainpageDemo extends Fragment { // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.activity_main, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // Button bIntent = (Button) view.findViewById(R.id.openNewIntent); // bIntent.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Utils.routeSinglePage("nothing", getActivity(), CommonSingle.class); // } // }); // } // } // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/MainActivityDemo.java import android.app.Fragment; import android.view.MenuItem; import com.hkm.slidingmenulib.gestured.SlidingMenu; import com.hkm.slidingmenulib.layoutdesigns.app.SlidingAppCompactActivity; import com.hypebeast.demoslidemenu.content.expandablemenu.MenuFragment; import com.hypebeast.demoslidemenu.helpr.structurebind; import com.hypebeast.demoslidemenu.content.mainpageDemo; package com.hypebeast.demoslidemenu; public class MainActivityDemo extends SlidingAppCompactActivity<Fragment> { @Override protected int getDefaultMainActivityLayoutId() { return SlidingAppCompactActivity.BODY_LAYOUT.actionbar.getResID(); } @Override
protected MenuFragment getFirstMenuFragment() {
jjhesk/KickAssSlidingMenu
AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/demohb.java
// Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/expandablemenu/MenuFragment.java // public class MenuFragment extends Fragment { // // private UltimateRecyclerView ultimateRecyclerView; // private expCustomAdapter simpleRecyclerViewAdapter = null; // private LinearLayoutManager linearLayoutManager; // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // return inflater.inflate(R.layout.left_slid_menu, container, false); // } // // // private static String[] sampledatagroup1 = { // "peter", "http://google", // "billy", "http://google", // "lisa", "http://google", // "visa", "http://google" // }; // private static String[] sampledatagroup2 = { // "mother", "http://google", // "father", "http://google", // "son", "http://google", // "holy spirit", "http://google", // "god the son", "http://google" // }; // private static String[] sampledatagroup3 = { // "SONY", "http://google", // "LG", "http://google", // "SAMSUNG", "http://google", // "XIAOMI", "http://google", // "HTC", "http://google" // }; // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ultimateRecyclerView = (UltimateRecyclerView) view.findViewById(R.id.ultimate_recycler_view_menu); // ultimateRecyclerView.setHasFixedSize(false); // /** // * this is the adapter for the expanx // */ // simpleRecyclerViewAdapter = new expCustomAdapter(getActivity()); // simpleRecyclerViewAdapter.addAll(expCustomAdapter.getPreCodeMenu( // sampledatagroup1, // sampledatagroup2, // sampledatagroup3), // 0); // // linearLayoutManager = new LinearLayoutManager(getActivity()); // ultimateRecyclerView.setLayoutManager(linearLayoutManager); // ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter); // ultimateRecyclerView.setRecylerViewBackgroundColor(Color.parseColor("#ffffff")); // addExpandableFeatures(); // // } // // private void addExpandableFeatures() { // ultimateRecyclerView.getItemAnimator().setAddDuration(100); // ultimateRecyclerView.getItemAnimator().setRemoveDuration(100); // ultimateRecyclerView.getItemAnimator().setMoveDuration(200); // ultimateRecyclerView.getItemAnimator().setChangeDuration(100); // } // // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/mainpageDemo.java // public class mainpageDemo extends Fragment { // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.activity_main, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // Button bIntent = (Button) view.findViewById(R.id.openNewIntent); // bIntent.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Utils.routeSinglePage("nothing", getActivity(), CommonSingle.class); // } // }); // } // }
import android.app.Fragment; import com.hkm.slidingmenulib.gestured.SlidingMenu; import com.hkm.slidingmenulib.layoutdesigns.app.SlidingAppCompactActivity; import com.hypebeast.demoslidemenu.content.expandablemenu.MenuFragment; import com.hypebeast.demoslidemenu.content.mainpageDemo;
package com.hypebeast.demoslidemenu; /** * Created by hesk on 10/7/15. */ public class demohb extends SlidingAppCompactActivity<Fragment> { private static String[] sampledatagroup1 = { "peter", "http://google", "billy", "http://google", "lisa", "http://google", "visa", "http://google" }; private static String[] sampledatagroup2 = { "mother", "http://google", "father", "http://google", "son", "http://google", "holy spirit", "http://google", "god the son", "http://google" }; private static String[] sampledatagroup3 = { "SONY", "http://google", "LG", "http://google", "SAMSUNG", "http://google", "XIAOMI", "http://google", "HTC", "http://google" }; @Override protected int getDefaultMainActivityLayoutId() { return SlidingAppCompactActivity.BODY_LAYOUT.actionbar.getResID(); } @Override
// Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/expandablemenu/MenuFragment.java // public class MenuFragment extends Fragment { // // private UltimateRecyclerView ultimateRecyclerView; // private expCustomAdapter simpleRecyclerViewAdapter = null; // private LinearLayoutManager linearLayoutManager; // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // return inflater.inflate(R.layout.left_slid_menu, container, false); // } // // // private static String[] sampledatagroup1 = { // "peter", "http://google", // "billy", "http://google", // "lisa", "http://google", // "visa", "http://google" // }; // private static String[] sampledatagroup2 = { // "mother", "http://google", // "father", "http://google", // "son", "http://google", // "holy spirit", "http://google", // "god the son", "http://google" // }; // private static String[] sampledatagroup3 = { // "SONY", "http://google", // "LG", "http://google", // "SAMSUNG", "http://google", // "XIAOMI", "http://google", // "HTC", "http://google" // }; // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ultimateRecyclerView = (UltimateRecyclerView) view.findViewById(R.id.ultimate_recycler_view_menu); // ultimateRecyclerView.setHasFixedSize(false); // /** // * this is the adapter for the expanx // */ // simpleRecyclerViewAdapter = new expCustomAdapter(getActivity()); // simpleRecyclerViewAdapter.addAll(expCustomAdapter.getPreCodeMenu( // sampledatagroup1, // sampledatagroup2, // sampledatagroup3), // 0); // // linearLayoutManager = new LinearLayoutManager(getActivity()); // ultimateRecyclerView.setLayoutManager(linearLayoutManager); // ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter); // ultimateRecyclerView.setRecylerViewBackgroundColor(Color.parseColor("#ffffff")); // addExpandableFeatures(); // // } // // private void addExpandableFeatures() { // ultimateRecyclerView.getItemAnimator().setAddDuration(100); // ultimateRecyclerView.getItemAnimator().setRemoveDuration(100); // ultimateRecyclerView.getItemAnimator().setMoveDuration(200); // ultimateRecyclerView.getItemAnimator().setChangeDuration(100); // } // // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/mainpageDemo.java // public class mainpageDemo extends Fragment { // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.activity_main, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // Button bIntent = (Button) view.findViewById(R.id.openNewIntent); // bIntent.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Utils.routeSinglePage("nothing", getActivity(), CommonSingle.class); // } // }); // } // } // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/demohb.java import android.app.Fragment; import com.hkm.slidingmenulib.gestured.SlidingMenu; import com.hkm.slidingmenulib.layoutdesigns.app.SlidingAppCompactActivity; import com.hypebeast.demoslidemenu.content.expandablemenu.MenuFragment; import com.hypebeast.demoslidemenu.content.mainpageDemo; package com.hypebeast.demoslidemenu; /** * Created by hesk on 10/7/15. */ public class demohb extends SlidingAppCompactActivity<Fragment> { private static String[] sampledatagroup1 = { "peter", "http://google", "billy", "http://google", "lisa", "http://google", "visa", "http://google" }; private static String[] sampledatagroup2 = { "mother", "http://google", "father", "http://google", "son", "http://google", "holy spirit", "http://google", "god the son", "http://google" }; private static String[] sampledatagroup3 = { "SONY", "http://google", "LG", "http://google", "SAMSUNG", "http://google", "XIAOMI", "http://google", "HTC", "http://google" }; @Override protected int getDefaultMainActivityLayoutId() { return SlidingAppCompactActivity.BODY_LAYOUT.actionbar.getResID(); } @Override
protected MenuFragment getFirstMenuFragment() {
jjhesk/KickAssSlidingMenu
AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/demohb.java
// Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/expandablemenu/MenuFragment.java // public class MenuFragment extends Fragment { // // private UltimateRecyclerView ultimateRecyclerView; // private expCustomAdapter simpleRecyclerViewAdapter = null; // private LinearLayoutManager linearLayoutManager; // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // return inflater.inflate(R.layout.left_slid_menu, container, false); // } // // // private static String[] sampledatagroup1 = { // "peter", "http://google", // "billy", "http://google", // "lisa", "http://google", // "visa", "http://google" // }; // private static String[] sampledatagroup2 = { // "mother", "http://google", // "father", "http://google", // "son", "http://google", // "holy spirit", "http://google", // "god the son", "http://google" // }; // private static String[] sampledatagroup3 = { // "SONY", "http://google", // "LG", "http://google", // "SAMSUNG", "http://google", // "XIAOMI", "http://google", // "HTC", "http://google" // }; // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ultimateRecyclerView = (UltimateRecyclerView) view.findViewById(R.id.ultimate_recycler_view_menu); // ultimateRecyclerView.setHasFixedSize(false); // /** // * this is the adapter for the expanx // */ // simpleRecyclerViewAdapter = new expCustomAdapter(getActivity()); // simpleRecyclerViewAdapter.addAll(expCustomAdapter.getPreCodeMenu( // sampledatagroup1, // sampledatagroup2, // sampledatagroup3), // 0); // // linearLayoutManager = new LinearLayoutManager(getActivity()); // ultimateRecyclerView.setLayoutManager(linearLayoutManager); // ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter); // ultimateRecyclerView.setRecylerViewBackgroundColor(Color.parseColor("#ffffff")); // addExpandableFeatures(); // // } // // private void addExpandableFeatures() { // ultimateRecyclerView.getItemAnimator().setAddDuration(100); // ultimateRecyclerView.getItemAnimator().setRemoveDuration(100); // ultimateRecyclerView.getItemAnimator().setMoveDuration(200); // ultimateRecyclerView.getItemAnimator().setChangeDuration(100); // } // // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/mainpageDemo.java // public class mainpageDemo extends Fragment { // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.activity_main, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // Button bIntent = (Button) view.findViewById(R.id.openNewIntent); // bIntent.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Utils.routeSinglePage("nothing", getActivity(), CommonSingle.class); // } // }); // } // }
import android.app.Fragment; import com.hkm.slidingmenulib.gestured.SlidingMenu; import com.hkm.slidingmenulib.layoutdesigns.app.SlidingAppCompactActivity; import com.hypebeast.demoslidemenu.content.expandablemenu.MenuFragment; import com.hypebeast.demoslidemenu.content.mainpageDemo;
"holy spirit", "http://google", "god the son", "http://google" }; private static String[] sampledatagroup3 = { "SONY", "http://google", "LG", "http://google", "SAMSUNG", "http://google", "XIAOMI", "http://google", "HTC", "http://google" }; @Override protected int getDefaultMainActivityLayoutId() { return SlidingAppCompactActivity.BODY_LAYOUT.actionbar.getResID(); } @Override protected MenuFragment getFirstMenuFragment() { return new MenuFragment(); } @Override protected int getRmenu() { return R.menu.menu_main; } @Override
// Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/expandablemenu/MenuFragment.java // public class MenuFragment extends Fragment { // // private UltimateRecyclerView ultimateRecyclerView; // private expCustomAdapter simpleRecyclerViewAdapter = null; // private LinearLayoutManager linearLayoutManager; // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // return inflater.inflate(R.layout.left_slid_menu, container, false); // } // // // private static String[] sampledatagroup1 = { // "peter", "http://google", // "billy", "http://google", // "lisa", "http://google", // "visa", "http://google" // }; // private static String[] sampledatagroup2 = { // "mother", "http://google", // "father", "http://google", // "son", "http://google", // "holy spirit", "http://google", // "god the son", "http://google" // }; // private static String[] sampledatagroup3 = { // "SONY", "http://google", // "LG", "http://google", // "SAMSUNG", "http://google", // "XIAOMI", "http://google", // "HTC", "http://google" // }; // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ultimateRecyclerView = (UltimateRecyclerView) view.findViewById(R.id.ultimate_recycler_view_menu); // ultimateRecyclerView.setHasFixedSize(false); // /** // * this is the adapter for the expanx // */ // simpleRecyclerViewAdapter = new expCustomAdapter(getActivity()); // simpleRecyclerViewAdapter.addAll(expCustomAdapter.getPreCodeMenu( // sampledatagroup1, // sampledatagroup2, // sampledatagroup3), // 0); // // linearLayoutManager = new LinearLayoutManager(getActivity()); // ultimateRecyclerView.setLayoutManager(linearLayoutManager); // ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter); // ultimateRecyclerView.setRecylerViewBackgroundColor(Color.parseColor("#ffffff")); // addExpandableFeatures(); // // } // // private void addExpandableFeatures() { // ultimateRecyclerView.getItemAnimator().setAddDuration(100); // ultimateRecyclerView.getItemAnimator().setRemoveDuration(100); // ultimateRecyclerView.getItemAnimator().setMoveDuration(200); // ultimateRecyclerView.getItemAnimator().setChangeDuration(100); // } // // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/mainpageDemo.java // public class mainpageDemo extends Fragment { // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.activity_main, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // Button bIntent = (Button) view.findViewById(R.id.openNewIntent); // bIntent.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Utils.routeSinglePage("nothing", getActivity(), CommonSingle.class); // } // }); // } // } // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/demohb.java import android.app.Fragment; import com.hkm.slidingmenulib.gestured.SlidingMenu; import com.hkm.slidingmenulib.layoutdesigns.app.SlidingAppCompactActivity; import com.hypebeast.demoslidemenu.content.expandablemenu.MenuFragment; import com.hypebeast.demoslidemenu.content.mainpageDemo; "holy spirit", "http://google", "god the son", "http://google" }; private static String[] sampledatagroup3 = { "SONY", "http://google", "LG", "http://google", "SAMSUNG", "http://google", "XIAOMI", "http://google", "HTC", "http://google" }; @Override protected int getDefaultMainActivityLayoutId() { return SlidingAppCompactActivity.BODY_LAYOUT.actionbar.getResID(); } @Override protected MenuFragment getFirstMenuFragment() { return new MenuFragment(); } @Override protected int getRmenu() { return R.menu.menu_main; } @Override
protected mainpageDemo getInitFragment() {
jjhesk/KickAssSlidingMenu
slideOutMenu/menux/src/main/java/mxh/kickassmenu/v4/banner/template_automatic_ll.java
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/normalfragment/banner/bind.java // public class bind { // public final static int FULL = 0, HALF = 1; // public int size; // public String link_url, tab_name; // public String image; // public Type mtype; // // // public bind(int size_con, // String tabName, // String url, // String imageUrl, // @Nullable String type) { // size = size_con; // link_url = url; // image = imageUrl; // tab_name = tabName; // if (type != null) { // if (type.equalsIgnoreCase("webpage")) { // mtype = Type.WEB; // } // } else { // mtype = Type.TAB; // } // } // }
import android.graphics.Point; import android.os.Bundle; import android.support.annotation.LayoutRes; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TableLayout; import android.widget.TableRow; import com.squareup.picasso.MemoryPolicy; import com.squareup.picasso.Picasso; import java.util.ArrayList; import java.util.Iterator; import mxh.kickassmenu.R; import mxh.kickassmenu.normalfragment.banner.bind;
package mxh.kickassmenu.v4.banner; /** * Created by zJJ on 2/19/2016. */ public abstract class template_automatic_ll extends Fragment { protected TableLayout ll; protected ProgressBar mProgress;
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/normalfragment/banner/bind.java // public class bind { // public final static int FULL = 0, HALF = 1; // public int size; // public String link_url, tab_name; // public String image; // public Type mtype; // // // public bind(int size_con, // String tabName, // String url, // String imageUrl, // @Nullable String type) { // size = size_con; // link_url = url; // image = imageUrl; // tab_name = tabName; // if (type != null) { // if (type.equalsIgnoreCase("webpage")) { // mtype = Type.WEB; // } // } else { // mtype = Type.TAB; // } // } // } // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/v4/banner/template_automatic_ll.java import android.graphics.Point; import android.os.Bundle; import android.support.annotation.LayoutRes; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TableLayout; import android.widget.TableRow; import com.squareup.picasso.MemoryPolicy; import com.squareup.picasso.Picasso; import java.util.ArrayList; import java.util.Iterator; import mxh.kickassmenu.R; import mxh.kickassmenu.normalfragment.banner.bind; package mxh.kickassmenu.v4.banner; /** * Created by zJJ on 2/19/2016. */ public abstract class template_automatic_ll extends Fragment { protected TableLayout ll; protected ProgressBar mProgress;
protected ArrayList<bind> list_configuration = new ArrayList<>();
jjhesk/KickAssSlidingMenu
slideOutMenu/menux/src/main/java/mxh/kickassmenu/fbstyle/HorzScrollWithImageMenu.java
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/ViewUtils.java // public class ViewUtils { // private ViewUtils() { // } // // public static void setViewWidths(View view, View[] views) { // int w = view.getWidth(); // int h = view.getHeight(); // for (int i = 0; i < views.length; i++) { // View v = views[i]; // v.layout((i + 1) * w, 0, (i + 2) * w, h); // printView("view[" + i + "]", v); // } // } // // public static void printView(String msg, View v) { // System.out.println(msg + "=" + v); // if (null == v) { // return; // } // System.out.print("[" + v.getLeft()); // System.out.print(", " + v.getTop()); // System.out.print(", w=" + v.getWidth()); // System.out.println(", h=" + v.getHeight() + "]"); // System.out.println("mw=" + v.getMeasuredWidth() + ", mh=" + v.getMeasuredHeight()); // System.out.println("scroll [" + v.getScrollX() + "," + v.getScrollY() + "]"); // } // // public static void initListView(Context context, ListView listView, String prefix, int numItems, int layout) { // // By using setAdpater method in listview we an add string array in list. // String[] arr = new String[numItems]; // for (int i = 0; i < arr.length; i++) { // arr[i] = prefix + (i + 1); // } // listView.setAdapter(new ArrayAdapter<String>(context, layout, arr)); // listView.setOnItemClickListener(new OnItemClickListener() { // @Override // public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Context context = view.getContext(); // String msg = "item[" + position + "]=" + parent.getItemAtPosition(position); // Toast.makeText(context, msg, Toast.LENGTH_LONG).show(); // System.out.println(msg); // } // }); // } // }
import android.widget.TextView; import mxh.kickassmenu.R; import mxh.kickassmenu.Util.ViewUtils; import android.annotation.SuppressLint; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.ListView;
/* * #%L * SlidingMenuDemo * $Id:$ * $HeadURL:$ * %% * Copyright (C) 2012 Paul Grime * %% * 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. * #L% */ package mxh.kickassmenu.fbstyle; /** * This example uses a FrameLayout to display a menu View and a HorizontalScrollView (HSV). * * The HSV has a transparent View as the first child, which means the menu will show through when the HSV is scrolled. */ public class HorzScrollWithImageMenu extends Activity { MyHorizontalScrollView scrollView; View menu; View app; ImageView btnSlide; boolean menuOut = false; Handler handler = new Handler(); int btnWidth; @SuppressLint("ResourceAsColor") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LayoutInflater inflater = LayoutInflater.from(this); setContentView(inflater.inflate(R.layout.horz_scroll_with_image_menu, null)); scrollView = (MyHorizontalScrollView) findViewById(R.id.myScrollView); menu = findViewById(R.id.menu); app = inflater.inflate(R.layout.horz_scroll_app, null); ViewGroup tabBar = (ViewGroup) app.findViewById(R.id.tabBar); ListView listView = (ListView) app.findViewById(R.id.list);
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/ViewUtils.java // public class ViewUtils { // private ViewUtils() { // } // // public static void setViewWidths(View view, View[] views) { // int w = view.getWidth(); // int h = view.getHeight(); // for (int i = 0; i < views.length; i++) { // View v = views[i]; // v.layout((i + 1) * w, 0, (i + 2) * w, h); // printView("view[" + i + "]", v); // } // } // // public static void printView(String msg, View v) { // System.out.println(msg + "=" + v); // if (null == v) { // return; // } // System.out.print("[" + v.getLeft()); // System.out.print(", " + v.getTop()); // System.out.print(", w=" + v.getWidth()); // System.out.println(", h=" + v.getHeight() + "]"); // System.out.println("mw=" + v.getMeasuredWidth() + ", mh=" + v.getMeasuredHeight()); // System.out.println("scroll [" + v.getScrollX() + "," + v.getScrollY() + "]"); // } // // public static void initListView(Context context, ListView listView, String prefix, int numItems, int layout) { // // By using setAdpater method in listview we an add string array in list. // String[] arr = new String[numItems]; // for (int i = 0; i < arr.length; i++) { // arr[i] = prefix + (i + 1); // } // listView.setAdapter(new ArrayAdapter<String>(context, layout, arr)); // listView.setOnItemClickListener(new OnItemClickListener() { // @Override // public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Context context = view.getContext(); // String msg = "item[" + position + "]=" + parent.getItemAtPosition(position); // Toast.makeText(context, msg, Toast.LENGTH_LONG).show(); // System.out.println(msg); // } // }); // } // } // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/fbstyle/HorzScrollWithImageMenu.java import android.widget.TextView; import mxh.kickassmenu.R; import mxh.kickassmenu.Util.ViewUtils; import android.annotation.SuppressLint; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.ListView; /* * #%L * SlidingMenuDemo * $Id:$ * $HeadURL:$ * %% * Copyright (C) 2012 Paul Grime * %% * 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. * #L% */ package mxh.kickassmenu.fbstyle; /** * This example uses a FrameLayout to display a menu View and a HorizontalScrollView (HSV). * * The HSV has a transparent View as the first child, which means the menu will show through when the HSV is scrolled. */ public class HorzScrollWithImageMenu extends Activity { MyHorizontalScrollView scrollView; View menu; View app; ImageView btnSlide; boolean menuOut = false; Handler handler = new Handler(); int btnWidth; @SuppressLint("ResourceAsColor") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LayoutInflater inflater = LayoutInflater.from(this); setContentView(inflater.inflate(R.layout.horz_scroll_with_image_menu, null)); scrollView = (MyHorizontalScrollView) findViewById(R.id.myScrollView); menu = findViewById(R.id.menu); app = inflater.inflate(R.layout.horz_scroll_app, null); ViewGroup tabBar = (ViewGroup) app.findViewById(R.id.tabBar); ListView listView = (ListView) app.findViewById(R.id.list);
ViewUtils.initListView(this, listView, "Item ", 30, android.R.layout.simple_list_item_1);
jjhesk/KickAssSlidingMenu
AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/helpr/structurebind.java
// Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/MainActivityDemo.java // public class MainActivityDemo extends SlidingAppCompactActivity<Fragment> { // // // @Override // protected int getDefaultMainActivityLayoutId() { // return SlidingAppCompactActivity.BODY_LAYOUT.actionbar.getResID(); // } // // @Override // protected MenuFragment getFirstMenuFragment() { // return new MenuFragment(); // } // // @Override // protected int getRmenu() { // return R.menu.menu_main; // } // // @Override // protected mainpageDemo getInitFragment() { // return new mainpageDemo(); // } // // @Override // protected void customizeSlideMenuEdge(SlidingMenu sm) { // sm.setFadeDegree(0.35f); // sm.setMode(SlidingMenu.LEFT); // sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); // sm.setBehindScrollScale(0.5f); // sm.setFadeDegree(0.34f); // sm.setBehindWidth(840); // sm.requestLayout(); // sm.invalidate(); // } // // @Override // public boolean onOptionsItemSelected(MenuItem item) { // final int t = item.getItemId(); // if (t != android.R.id.home) { // structurebind.startfromSelectionMenu(t, this, null); // return super.onOptionsItemSelected(item); // } else { // toggle(); // return true; // } // } // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/demohb.java // public class demohb extends SlidingAppCompactActivity<Fragment> { // // // private static String[] sampledatagroup1 = { // "peter", "http://google", // "billy", "http://google", // "lisa", "http://google", // "visa", "http://google" // }; // private static String[] sampledatagroup2 = { // "mother", "http://google", // "father", "http://google", // "son", "http://google", // "holy spirit", "http://google", // "god the son", "http://google" // }; // private static String[] sampledatagroup3 = { // "SONY", "http://google", // "LG", "http://google", // "SAMSUNG", "http://google", // "XIAOMI", "http://google", // "HTC", "http://google" // }; // // // // @Override // protected int getDefaultMainActivityLayoutId() { // return SlidingAppCompactActivity.BODY_LAYOUT.actionbar.getResID(); // } // // @Override // protected MenuFragment getFirstMenuFragment() { // return new MenuFragment(); // } // // // @Override // protected int getRmenu() { // return R.menu.menu_main; // } // // @Override // protected mainpageDemo getInitFragment() { // return new mainpageDemo(); // } // // @Override // protected void customizeSlideMenuEdge(SlidingMenu sm) { // sm.setFadeDegree(0.35f); // sm.setMode(SlidingMenu.LEFT); // sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); // sm.setBehindScrollScale(0.5f); // sm.setFadeDegree(0.34f); // sm.setBehindWidth(840); // sm.requestLayout(); // sm.invalidate(); // } // // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/testblock.java // public class testblock extends SlidingAppCompactActivity<Fragment> { // // // @Override // protected int getDefaultMainActivityLayoutId() { // return BODY_LAYOUT.actionbar.getResID(); // } // // @Override // protected mainpageDemo getFirstMenuFragment() { // return new mainpageDemo(); // } // // @Override // protected int getRmenu() { // return R.menu.function_test_blocking; // } // // @Override // protected mainpageDemo getInitFragment() { // return new mainpageDemo(); // } // // @Override // protected void customizeSlideMenuEdge(SlidingMenu sm) { // sm.setFadeDegree(0.35f); // sm.setMode(SlidingMenu.LEFT); // sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); // sm.setBehindScrollScale(0.5f); // sm.setFadeDegree(0.34f); // sm.setBehindWidth(840); // sm.requestLayout(); // sm.invalidate(); // } // // @Override // public boolean onOptionsItemSelected(MenuItem item) { // final int t = item.getItemId(); // if (t != android.R.id.home) { // // if (t == R.id.unblock) { // setUnblock(); // } // // if (t == R.id.block) { // setBlockEnableWithColor(R.color.block_color); // } // // structurebind.startfromSelectionMenu(t, this, null); // return super.onOptionsItemSelected(item); // } else { // toggle(); // return true; // } // } // // @Override // public void onBackPressed() { // super.onBackPressed(); // finish(); // } // // // }
import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.annotation.IdRes; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import com.hypebeast.demoslidemenu.MainActivityDemo; import com.hypebeast.demoslidemenu.R; import com.hypebeast.demoslidemenu.demohb; import com.hypebeast.demoslidemenu.testblock;
package com.hypebeast.demoslidemenu.helpr; /** * Created by hesk on 10/7/15. */ public enum structurebind { main(R.id.main, MainActivityDemo.class),
// Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/MainActivityDemo.java // public class MainActivityDemo extends SlidingAppCompactActivity<Fragment> { // // // @Override // protected int getDefaultMainActivityLayoutId() { // return SlidingAppCompactActivity.BODY_LAYOUT.actionbar.getResID(); // } // // @Override // protected MenuFragment getFirstMenuFragment() { // return new MenuFragment(); // } // // @Override // protected int getRmenu() { // return R.menu.menu_main; // } // // @Override // protected mainpageDemo getInitFragment() { // return new mainpageDemo(); // } // // @Override // protected void customizeSlideMenuEdge(SlidingMenu sm) { // sm.setFadeDegree(0.35f); // sm.setMode(SlidingMenu.LEFT); // sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); // sm.setBehindScrollScale(0.5f); // sm.setFadeDegree(0.34f); // sm.setBehindWidth(840); // sm.requestLayout(); // sm.invalidate(); // } // // @Override // public boolean onOptionsItemSelected(MenuItem item) { // final int t = item.getItemId(); // if (t != android.R.id.home) { // structurebind.startfromSelectionMenu(t, this, null); // return super.onOptionsItemSelected(item); // } else { // toggle(); // return true; // } // } // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/demohb.java // public class demohb extends SlidingAppCompactActivity<Fragment> { // // // private static String[] sampledatagroup1 = { // "peter", "http://google", // "billy", "http://google", // "lisa", "http://google", // "visa", "http://google" // }; // private static String[] sampledatagroup2 = { // "mother", "http://google", // "father", "http://google", // "son", "http://google", // "holy spirit", "http://google", // "god the son", "http://google" // }; // private static String[] sampledatagroup3 = { // "SONY", "http://google", // "LG", "http://google", // "SAMSUNG", "http://google", // "XIAOMI", "http://google", // "HTC", "http://google" // }; // // // // @Override // protected int getDefaultMainActivityLayoutId() { // return SlidingAppCompactActivity.BODY_LAYOUT.actionbar.getResID(); // } // // @Override // protected MenuFragment getFirstMenuFragment() { // return new MenuFragment(); // } // // // @Override // protected int getRmenu() { // return R.menu.menu_main; // } // // @Override // protected mainpageDemo getInitFragment() { // return new mainpageDemo(); // } // // @Override // protected void customizeSlideMenuEdge(SlidingMenu sm) { // sm.setFadeDegree(0.35f); // sm.setMode(SlidingMenu.LEFT); // sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); // sm.setBehindScrollScale(0.5f); // sm.setFadeDegree(0.34f); // sm.setBehindWidth(840); // sm.requestLayout(); // sm.invalidate(); // } // // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/testblock.java // public class testblock extends SlidingAppCompactActivity<Fragment> { // // // @Override // protected int getDefaultMainActivityLayoutId() { // return BODY_LAYOUT.actionbar.getResID(); // } // // @Override // protected mainpageDemo getFirstMenuFragment() { // return new mainpageDemo(); // } // // @Override // protected int getRmenu() { // return R.menu.function_test_blocking; // } // // @Override // protected mainpageDemo getInitFragment() { // return new mainpageDemo(); // } // // @Override // protected void customizeSlideMenuEdge(SlidingMenu sm) { // sm.setFadeDegree(0.35f); // sm.setMode(SlidingMenu.LEFT); // sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); // sm.setBehindScrollScale(0.5f); // sm.setFadeDegree(0.34f); // sm.setBehindWidth(840); // sm.requestLayout(); // sm.invalidate(); // } // // @Override // public boolean onOptionsItemSelected(MenuItem item) { // final int t = item.getItemId(); // if (t != android.R.id.home) { // // if (t == R.id.unblock) { // setUnblock(); // } // // if (t == R.id.block) { // setBlockEnableWithColor(R.color.block_color); // } // // structurebind.startfromSelectionMenu(t, this, null); // return super.onOptionsItemSelected(item); // } else { // toggle(); // return true; // } // } // // @Override // public void onBackPressed() { // super.onBackPressed(); // finish(); // } // // // } // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/helpr/structurebind.java import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.annotation.IdRes; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import com.hypebeast.demoslidemenu.MainActivityDemo; import com.hypebeast.demoslidemenu.R; import com.hypebeast.demoslidemenu.demohb; import com.hypebeast.demoslidemenu.testblock; package com.hypebeast.demoslidemenu.helpr; /** * Created by hesk on 10/7/15. */ public enum structurebind { main(R.id.main, MainActivityDemo.class),
blocktest(R.id.blocktset, testblock.class),
jjhesk/KickAssSlidingMenu
slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/containers/MaterialHeadedDrawerContainer.java
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/LockableScrollView.java // public class LockableScrollView extends ScrollView { // private boolean mScrollable = true; // // public LockableScrollView(Context context) { // super(context); // } // // public LockableScrollView(Context context, AttributeSet attrs) { // super(context, attrs); // } // // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // public void setScrollingEnabled(boolean enabled) { // mScrollable = enabled; // } // // public boolean isScrollable() { // return mScrollable; // } // // @Override // public boolean onTouchEvent(MotionEvent ev) { // switch (ev.getAction()) { // case MotionEvent.ACTION_DOWN: // // if we can scroll pass the event to the superclass // if (mScrollable) return super.onTouchEvent(ev); // // only continue to handle the touch event if scrolling enabled // return mScrollable; // mScrollable is always false at this point // default: // return super.onTouchEvent(ev); // } // } // // @Override // public boolean onInterceptTouchEvent(MotionEvent ev) { // // Don't do anything with intercepted touch events if // // we are not scrollable // if (!mScrollable) return false; // else return super.onInterceptTouchEvent(ev); // } // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/LAYOUT_DRAWER.java // public enum LAYOUT_DRAWER { // STICKY_UP(R.layout.layout_drawer_sticky_up), // STICKY_BOTTOM(R.layout.layout_drawer_sticky_bottom), // PROFILE_HEAD(R.layout.layout_drawer_headed), // USER_DEFINED_LAYOUT(-1); // private final int layout_id; // // LAYOUT_DRAWER(@LayoutRes int layout) { // this.layout_id = layout; // } // // public int getLayoutRes() { // return layout_id; // } // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/scrolli.java // public interface scrolli { // ScrollView getScrollView(); // }
import android.annotation.SuppressLint; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import mxh.kickassmenu.R; import mxh.kickassmenu.Util.LockableScrollView; import mxh.kickassmenu.menucontent.LAYOUT_DRAWER; import mxh.kickassmenu.menucontent.scrolli;
package mxh.kickassmenu.menucontent.containers; /** * Created by hesk on 24/6/15. */ public class MaterialHeadedDrawerContainer extends MaterialDrawerContainer implements scrolli { public LinearLayout background_gradient; public ImageView background_switcher, current_back_item_background, current_head_item_photo, second_head_item_photo, third_head_item_photo, user_transition, user_switcher; public TextView current_head_item_title, current_head_item_sub_title;
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/LockableScrollView.java // public class LockableScrollView extends ScrollView { // private boolean mScrollable = true; // // public LockableScrollView(Context context) { // super(context); // } // // public LockableScrollView(Context context, AttributeSet attrs) { // super(context, attrs); // } // // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // public void setScrollingEnabled(boolean enabled) { // mScrollable = enabled; // } // // public boolean isScrollable() { // return mScrollable; // } // // @Override // public boolean onTouchEvent(MotionEvent ev) { // switch (ev.getAction()) { // case MotionEvent.ACTION_DOWN: // // if we can scroll pass the event to the superclass // if (mScrollable) return super.onTouchEvent(ev); // // only continue to handle the touch event if scrolling enabled // return mScrollable; // mScrollable is always false at this point // default: // return super.onTouchEvent(ev); // } // } // // @Override // public boolean onInterceptTouchEvent(MotionEvent ev) { // // Don't do anything with intercepted touch events if // // we are not scrollable // if (!mScrollable) return false; // else return super.onInterceptTouchEvent(ev); // } // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/LAYOUT_DRAWER.java // public enum LAYOUT_DRAWER { // STICKY_UP(R.layout.layout_drawer_sticky_up), // STICKY_BOTTOM(R.layout.layout_drawer_sticky_bottom), // PROFILE_HEAD(R.layout.layout_drawer_headed), // USER_DEFINED_LAYOUT(-1); // private final int layout_id; // // LAYOUT_DRAWER(@LayoutRes int layout) { // this.layout_id = layout; // } // // public int getLayoutRes() { // return layout_id; // } // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/scrolli.java // public interface scrolli { // ScrollView getScrollView(); // } // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/containers/MaterialHeadedDrawerContainer.java import android.annotation.SuppressLint; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import mxh.kickassmenu.R; import mxh.kickassmenu.Util.LockableScrollView; import mxh.kickassmenu.menucontent.LAYOUT_DRAWER; import mxh.kickassmenu.menucontent.scrolli; package mxh.kickassmenu.menucontent.containers; /** * Created by hesk on 24/6/15. */ public class MaterialHeadedDrawerContainer extends MaterialDrawerContainer implements scrolli { public LinearLayout background_gradient; public ImageView background_switcher, current_back_item_background, current_head_item_photo, second_head_item_photo, third_head_item_photo, user_transition, user_switcher; public TextView current_head_item_title, current_head_item_sub_title;
private LockableScrollView scrollor;
jjhesk/KickAssSlidingMenu
slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/containers/MaterialHeadedDrawerContainer.java
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/LockableScrollView.java // public class LockableScrollView extends ScrollView { // private boolean mScrollable = true; // // public LockableScrollView(Context context) { // super(context); // } // // public LockableScrollView(Context context, AttributeSet attrs) { // super(context, attrs); // } // // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // public void setScrollingEnabled(boolean enabled) { // mScrollable = enabled; // } // // public boolean isScrollable() { // return mScrollable; // } // // @Override // public boolean onTouchEvent(MotionEvent ev) { // switch (ev.getAction()) { // case MotionEvent.ACTION_DOWN: // // if we can scroll pass the event to the superclass // if (mScrollable) return super.onTouchEvent(ev); // // only continue to handle the touch event if scrolling enabled // return mScrollable; // mScrollable is always false at this point // default: // return super.onTouchEvent(ev); // } // } // // @Override // public boolean onInterceptTouchEvent(MotionEvent ev) { // // Don't do anything with intercepted touch events if // // we are not scrollable // if (!mScrollable) return false; // else return super.onInterceptTouchEvent(ev); // } // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/LAYOUT_DRAWER.java // public enum LAYOUT_DRAWER { // STICKY_UP(R.layout.layout_drawer_sticky_up), // STICKY_BOTTOM(R.layout.layout_drawer_sticky_bottom), // PROFILE_HEAD(R.layout.layout_drawer_headed), // USER_DEFINED_LAYOUT(-1); // private final int layout_id; // // LAYOUT_DRAWER(@LayoutRes int layout) { // this.layout_id = layout; // } // // public int getLayoutRes() { // return layout_id; // } // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/scrolli.java // public interface scrolli { // ScrollView getScrollView(); // }
import android.annotation.SuppressLint; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import mxh.kickassmenu.R; import mxh.kickassmenu.Util.LockableScrollView; import mxh.kickassmenu.menucontent.LAYOUT_DRAWER; import mxh.kickassmenu.menucontent.scrolli;
package mxh.kickassmenu.menucontent.containers; /** * Created by hesk on 24/6/15. */ public class MaterialHeadedDrawerContainer extends MaterialDrawerContainer implements scrolli { public LinearLayout background_gradient; public ImageView background_switcher, current_back_item_background, current_head_item_photo, second_head_item_photo, third_head_item_photo, user_transition, user_switcher; public TextView current_head_item_title, current_head_item_sub_title; private LockableScrollView scrollor;
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/LockableScrollView.java // public class LockableScrollView extends ScrollView { // private boolean mScrollable = true; // // public LockableScrollView(Context context) { // super(context); // } // // public LockableScrollView(Context context, AttributeSet attrs) { // super(context, attrs); // } // // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // public void setScrollingEnabled(boolean enabled) { // mScrollable = enabled; // } // // public boolean isScrollable() { // return mScrollable; // } // // @Override // public boolean onTouchEvent(MotionEvent ev) { // switch (ev.getAction()) { // case MotionEvent.ACTION_DOWN: // // if we can scroll pass the event to the superclass // if (mScrollable) return super.onTouchEvent(ev); // // only continue to handle the touch event if scrolling enabled // return mScrollable; // mScrollable is always false at this point // default: // return super.onTouchEvent(ev); // } // } // // @Override // public boolean onInterceptTouchEvent(MotionEvent ev) { // // Don't do anything with intercepted touch events if // // we are not scrollable // if (!mScrollable) return false; // else return super.onInterceptTouchEvent(ev); // } // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/LAYOUT_DRAWER.java // public enum LAYOUT_DRAWER { // STICKY_UP(R.layout.layout_drawer_sticky_up), // STICKY_BOTTOM(R.layout.layout_drawer_sticky_bottom), // PROFILE_HEAD(R.layout.layout_drawer_headed), // USER_DEFINED_LAYOUT(-1); // private final int layout_id; // // LAYOUT_DRAWER(@LayoutRes int layout) { // this.layout_id = layout; // } // // public int getLayoutRes() { // return layout_id; // } // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/scrolli.java // public interface scrolli { // ScrollView getScrollView(); // } // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/containers/MaterialHeadedDrawerContainer.java import android.annotation.SuppressLint; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import mxh.kickassmenu.R; import mxh.kickassmenu.Util.LockableScrollView; import mxh.kickassmenu.menucontent.LAYOUT_DRAWER; import mxh.kickassmenu.menucontent.scrolli; package mxh.kickassmenu.menucontent.containers; /** * Created by hesk on 24/6/15. */ public class MaterialHeadedDrawerContainer extends MaterialDrawerContainer implements scrolli { public LinearLayout background_gradient; public ImageView background_switcher, current_back_item_background, current_head_item_photo, second_head_item_photo, third_head_item_photo, user_transition, user_switcher; public TextView current_head_item_title, current_head_item_sub_title; private LockableScrollView scrollor;
public MaterialHeadedDrawerContainer(LAYOUT_DRAWER layout_type) {
jjhesk/KickAssSlidingMenu
slideOutMenu/menux/src/main/java/mxh/kickassmenu/fbstyle/SlideAnimationThenCallLayout.java
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/ViewUtils.java // public class ViewUtils { // private ViewUtils() { // } // // public static void setViewWidths(View view, View[] views) { // int w = view.getWidth(); // int h = view.getHeight(); // for (int i = 0; i < views.length; i++) { // View v = views[i]; // v.layout((i + 1) * w, 0, (i + 2) * w, h); // printView("view[" + i + "]", v); // } // } // // public static void printView(String msg, View v) { // System.out.println(msg + "=" + v); // if (null == v) { // return; // } // System.out.print("[" + v.getLeft()); // System.out.print(", " + v.getTop()); // System.out.print(", w=" + v.getWidth()); // System.out.println(", h=" + v.getHeight() + "]"); // System.out.println("mw=" + v.getMeasuredWidth() + ", mh=" + v.getMeasuredHeight()); // System.out.println("scroll [" + v.getScrollX() + "," + v.getScrollY() + "]"); // } // // public static void initListView(Context context, ListView listView, String prefix, int numItems, int layout) { // // By using setAdpater method in listview we an add string array in list. // String[] arr = new String[numItems]; // for (int i = 0; i < arr.length; i++) { // arr[i] = prefix + (i + 1); // } // listView.setAdapter(new ArrayAdapter<String>(context, layout, arr)); // listView.setOnItemClickListener(new OnItemClickListener() { // @Override // public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Context context = view.getContext(); // String msg = "item[" + position + "]=" + parent.getItemAtPosition(position); // Toast.makeText(context, msg, Toast.LENGTH_LONG).show(); // System.out.println(msg); // } // }); // } // }
import java.util.Date; import mxh.kickassmenu.R; import mxh.kickassmenu.Util.ViewUtils; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.TranslateAnimation; import android.widget.ListView;
anim = new TranslateAnimation(0, -left, 0, 0); animParams.init(0, 0, w, h); } anim.setDuration(500); anim.setAnimationListener(me); //Tell the animation to stay as it ended (we are going to set the app.layout first than remove this property) anim.setFillAfter(true); // Only use fillEnabled and fillAfter if we don't call layout ourselves. // We need to do the layout ourselves and not use fillEnabled and fillAfter because when the anim is finished // although the View appears to have moved, it is actually just a drawing effect and the View hasn't moved. // Therefore clicking on the screen where the button appears does not work, but clicking where the View *was* does // work. // anim.setFillEnabled(true); // anim.setFillAfter(true); app.startAnimation(anim); } } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.slide_animation_then_call_layout); menu = findViewById(R.id.menu); app = findViewById(R.id.app);
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/ViewUtils.java // public class ViewUtils { // private ViewUtils() { // } // // public static void setViewWidths(View view, View[] views) { // int w = view.getWidth(); // int h = view.getHeight(); // for (int i = 0; i < views.length; i++) { // View v = views[i]; // v.layout((i + 1) * w, 0, (i + 2) * w, h); // printView("view[" + i + "]", v); // } // } // // public static void printView(String msg, View v) { // System.out.println(msg + "=" + v); // if (null == v) { // return; // } // System.out.print("[" + v.getLeft()); // System.out.print(", " + v.getTop()); // System.out.print(", w=" + v.getWidth()); // System.out.println(", h=" + v.getHeight() + "]"); // System.out.println("mw=" + v.getMeasuredWidth() + ", mh=" + v.getMeasuredHeight()); // System.out.println("scroll [" + v.getScrollX() + "," + v.getScrollY() + "]"); // } // // public static void initListView(Context context, ListView listView, String prefix, int numItems, int layout) { // // By using setAdpater method in listview we an add string array in list. // String[] arr = new String[numItems]; // for (int i = 0; i < arr.length; i++) { // arr[i] = prefix + (i + 1); // } // listView.setAdapter(new ArrayAdapter<String>(context, layout, arr)); // listView.setOnItemClickListener(new OnItemClickListener() { // @Override // public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Context context = view.getContext(); // String msg = "item[" + position + "]=" + parent.getItemAtPosition(position); // Toast.makeText(context, msg, Toast.LENGTH_LONG).show(); // System.out.println(msg); // } // }); // } // } // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/fbstyle/SlideAnimationThenCallLayout.java import java.util.Date; import mxh.kickassmenu.R; import mxh.kickassmenu.Util.ViewUtils; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.TranslateAnimation; import android.widget.ListView; anim = new TranslateAnimation(0, -left, 0, 0); animParams.init(0, 0, w, h); } anim.setDuration(500); anim.setAnimationListener(me); //Tell the animation to stay as it ended (we are going to set the app.layout first than remove this property) anim.setFillAfter(true); // Only use fillEnabled and fillAfter if we don't call layout ourselves. // We need to do the layout ourselves and not use fillEnabled and fillAfter because when the anim is finished // although the View appears to have moved, it is actually just a drawing effect and the View hasn't moved. // Therefore clicking on the screen where the button appears does not work, but clicking where the View *was* does // work. // anim.setFillEnabled(true); // anim.setFillAfter(true); app.startAnimation(anim); } } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.slide_animation_then_call_layout); menu = findViewById(R.id.menu); app = findViewById(R.id.app);
ViewUtils.printView("menu", menu);
jjhesk/KickAssSlidingMenu
AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/testblock.java
// Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/helpr/structurebind.java // public enum structurebind { // main(R.id.main, MainActivityDemo.class), // blocktest(R.id.blocktset, testblock.class), // hb(R.id.hbstyle, demohb.class), // sys(R.id.system, MainActivityDemo.class), // profile(R.id.profiletype, MainActivityDemo.class); // private final Class<? extends AppCompatActivity> internalClazz; // private final int menu_id; // // structurebind(final @IdRes int menuid, final Class<? extends AppCompatActivity> triggerclassname) { // this.internalClazz = triggerclassname; // this.menu_id = menuid; // } // // public int getId() { // return menu_id; // } // // public Class<? extends AppCompatActivity> getClassName() { // return this.internalClazz; // } // // public static void startfromSelectionMenu(final @IdRes int menuID, final Context mcontext, @Nullable final Bundle mbundle) { // final int g = structurebind.values().length; // for (int i = 0; i < g; i++) { // structurebind bind = structurebind.values()[i]; // if (bind.getId() == menuID) { // if (mbundle != null) { // bind.newapp(mcontext, mbundle); // } else { // bind.newapp(mcontext); // } // return; // } // } // } // // public void newapp(final Context ctx) { // final Intent in = new Intent(ctx, internalClazz); // ctx.startActivity(in); // } // // // public void newapp(final Context ctx, final Bundle bun) { // final Intent in = new Intent(ctx, internalClazz); // in.putExtras(bun); // ctx.startActivity(in); // } // // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/mainpageDemo.java // public class mainpageDemo extends Fragment { // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.activity_main, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // Button bIntent = (Button) view.findViewById(R.id.openNewIntent); // bIntent.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Utils.routeSinglePage("nothing", getActivity(), CommonSingle.class); // } // }); // } // }
import android.app.Fragment; import android.view.MenuItem; import com.hkm.slidingmenulib.gestured.SlidingMenu; import com.hkm.slidingmenulib.layoutdesigns.app.SlidingAppCompactActivity; import com.hypebeast.demoslidemenu.helpr.structurebind; import com.hypebeast.demoslidemenu.content.mainpageDemo;
package com.hypebeast.demoslidemenu; public class testblock extends SlidingAppCompactActivity<Fragment> { @Override protected int getDefaultMainActivityLayoutId() { return BODY_LAYOUT.actionbar.getResID(); } @Override
// Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/helpr/structurebind.java // public enum structurebind { // main(R.id.main, MainActivityDemo.class), // blocktest(R.id.blocktset, testblock.class), // hb(R.id.hbstyle, demohb.class), // sys(R.id.system, MainActivityDemo.class), // profile(R.id.profiletype, MainActivityDemo.class); // private final Class<? extends AppCompatActivity> internalClazz; // private final int menu_id; // // structurebind(final @IdRes int menuid, final Class<? extends AppCompatActivity> triggerclassname) { // this.internalClazz = triggerclassname; // this.menu_id = menuid; // } // // public int getId() { // return menu_id; // } // // public Class<? extends AppCompatActivity> getClassName() { // return this.internalClazz; // } // // public static void startfromSelectionMenu(final @IdRes int menuID, final Context mcontext, @Nullable final Bundle mbundle) { // final int g = structurebind.values().length; // for (int i = 0; i < g; i++) { // structurebind bind = structurebind.values()[i]; // if (bind.getId() == menuID) { // if (mbundle != null) { // bind.newapp(mcontext, mbundle); // } else { // bind.newapp(mcontext); // } // return; // } // } // } // // public void newapp(final Context ctx) { // final Intent in = new Intent(ctx, internalClazz); // ctx.startActivity(in); // } // // // public void newapp(final Context ctx, final Bundle bun) { // final Intent in = new Intent(ctx, internalClazz); // in.putExtras(bun); // ctx.startActivity(in); // } // // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/mainpageDemo.java // public class mainpageDemo extends Fragment { // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.activity_main, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // Button bIntent = (Button) view.findViewById(R.id.openNewIntent); // bIntent.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Utils.routeSinglePage("nothing", getActivity(), CommonSingle.class); // } // }); // } // } // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/testblock.java import android.app.Fragment; import android.view.MenuItem; import com.hkm.slidingmenulib.gestured.SlidingMenu; import com.hkm.slidingmenulib.layoutdesigns.app.SlidingAppCompactActivity; import com.hypebeast.demoslidemenu.helpr.structurebind; import com.hypebeast.demoslidemenu.content.mainpageDemo; package com.hypebeast.demoslidemenu; public class testblock extends SlidingAppCompactActivity<Fragment> { @Override protected int getDefaultMainActivityLayoutId() { return BODY_LAYOUT.actionbar.getResID(); } @Override
protected mainpageDemo getFirstMenuFragment() {
jjhesk/KickAssSlidingMenu
AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/testblock.java
// Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/helpr/structurebind.java // public enum structurebind { // main(R.id.main, MainActivityDemo.class), // blocktest(R.id.blocktset, testblock.class), // hb(R.id.hbstyle, demohb.class), // sys(R.id.system, MainActivityDemo.class), // profile(R.id.profiletype, MainActivityDemo.class); // private final Class<? extends AppCompatActivity> internalClazz; // private final int menu_id; // // structurebind(final @IdRes int menuid, final Class<? extends AppCompatActivity> triggerclassname) { // this.internalClazz = triggerclassname; // this.menu_id = menuid; // } // // public int getId() { // return menu_id; // } // // public Class<? extends AppCompatActivity> getClassName() { // return this.internalClazz; // } // // public static void startfromSelectionMenu(final @IdRes int menuID, final Context mcontext, @Nullable final Bundle mbundle) { // final int g = structurebind.values().length; // for (int i = 0; i < g; i++) { // structurebind bind = structurebind.values()[i]; // if (bind.getId() == menuID) { // if (mbundle != null) { // bind.newapp(mcontext, mbundle); // } else { // bind.newapp(mcontext); // } // return; // } // } // } // // public void newapp(final Context ctx) { // final Intent in = new Intent(ctx, internalClazz); // ctx.startActivity(in); // } // // // public void newapp(final Context ctx, final Bundle bun) { // final Intent in = new Intent(ctx, internalClazz); // in.putExtras(bun); // ctx.startActivity(in); // } // // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/mainpageDemo.java // public class mainpageDemo extends Fragment { // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.activity_main, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // Button bIntent = (Button) view.findViewById(R.id.openNewIntent); // bIntent.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Utils.routeSinglePage("nothing", getActivity(), CommonSingle.class); // } // }); // } // }
import android.app.Fragment; import android.view.MenuItem; import com.hkm.slidingmenulib.gestured.SlidingMenu; import com.hkm.slidingmenulib.layoutdesigns.app.SlidingAppCompactActivity; import com.hypebeast.demoslidemenu.helpr.structurebind; import com.hypebeast.demoslidemenu.content.mainpageDemo;
@Override protected mainpageDemo getInitFragment() { return new mainpageDemo(); } @Override protected void customizeSlideMenuEdge(SlidingMenu sm) { sm.setFadeDegree(0.35f); sm.setMode(SlidingMenu.LEFT); sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); sm.setBehindScrollScale(0.5f); sm.setFadeDegree(0.34f); sm.setBehindWidth(840); sm.requestLayout(); sm.invalidate(); } @Override public boolean onOptionsItemSelected(MenuItem item) { final int t = item.getItemId(); if (t != android.R.id.home) { if (t == R.id.unblock) { setUnblock(); } if (t == R.id.block) { setBlockEnableWithColor(R.color.block_color); }
// Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/helpr/structurebind.java // public enum structurebind { // main(R.id.main, MainActivityDemo.class), // blocktest(R.id.blocktset, testblock.class), // hb(R.id.hbstyle, demohb.class), // sys(R.id.system, MainActivityDemo.class), // profile(R.id.profiletype, MainActivityDemo.class); // private final Class<? extends AppCompatActivity> internalClazz; // private final int menu_id; // // structurebind(final @IdRes int menuid, final Class<? extends AppCompatActivity> triggerclassname) { // this.internalClazz = triggerclassname; // this.menu_id = menuid; // } // // public int getId() { // return menu_id; // } // // public Class<? extends AppCompatActivity> getClassName() { // return this.internalClazz; // } // // public static void startfromSelectionMenu(final @IdRes int menuID, final Context mcontext, @Nullable final Bundle mbundle) { // final int g = structurebind.values().length; // for (int i = 0; i < g; i++) { // structurebind bind = structurebind.values()[i]; // if (bind.getId() == menuID) { // if (mbundle != null) { // bind.newapp(mcontext, mbundle); // } else { // bind.newapp(mcontext); // } // return; // } // } // } // // public void newapp(final Context ctx) { // final Intent in = new Intent(ctx, internalClazz); // ctx.startActivity(in); // } // // // public void newapp(final Context ctx, final Bundle bun) { // final Intent in = new Intent(ctx, internalClazz); // in.putExtras(bun); // ctx.startActivity(in); // } // // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/mainpageDemo.java // public class mainpageDemo extends Fragment { // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.activity_main, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // Button bIntent = (Button) view.findViewById(R.id.openNewIntent); // bIntent.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Utils.routeSinglePage("nothing", getActivity(), CommonSingle.class); // } // }); // } // } // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/testblock.java import android.app.Fragment; import android.view.MenuItem; import com.hkm.slidingmenulib.gestured.SlidingMenu; import com.hkm.slidingmenulib.layoutdesigns.app.SlidingAppCompactActivity; import com.hypebeast.demoslidemenu.helpr.structurebind; import com.hypebeast.demoslidemenu.content.mainpageDemo; @Override protected mainpageDemo getInitFragment() { return new mainpageDemo(); } @Override protected void customizeSlideMenuEdge(SlidingMenu sm) { sm.setFadeDegree(0.35f); sm.setMode(SlidingMenu.LEFT); sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); sm.setBehindScrollScale(0.5f); sm.setFadeDegree(0.34f); sm.setBehindWidth(840); sm.requestLayout(); sm.invalidate(); } @Override public boolean onOptionsItemSelected(MenuItem item) { final int t = item.getItemId(); if (t != android.R.id.home) { if (t == R.id.unblock) { setUnblock(); } if (t == R.id.block) { setBlockEnableWithColor(R.color.block_color); }
structurebind.startfromSelectionMenu(t, this, null);
jjhesk/KickAssSlidingMenu
AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/demosys.java
// Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/expandablemenu/MenuFragment.java // public class MenuFragment extends Fragment { // // private UltimateRecyclerView ultimateRecyclerView; // private expCustomAdapter simpleRecyclerViewAdapter = null; // private LinearLayoutManager linearLayoutManager; // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // return inflater.inflate(R.layout.left_slid_menu, container, false); // } // // // private static String[] sampledatagroup1 = { // "peter", "http://google", // "billy", "http://google", // "lisa", "http://google", // "visa", "http://google" // }; // private static String[] sampledatagroup2 = { // "mother", "http://google", // "father", "http://google", // "son", "http://google", // "holy spirit", "http://google", // "god the son", "http://google" // }; // private static String[] sampledatagroup3 = { // "SONY", "http://google", // "LG", "http://google", // "SAMSUNG", "http://google", // "XIAOMI", "http://google", // "HTC", "http://google" // }; // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ultimateRecyclerView = (UltimateRecyclerView) view.findViewById(R.id.ultimate_recycler_view_menu); // ultimateRecyclerView.setHasFixedSize(false); // /** // * this is the adapter for the expanx // */ // simpleRecyclerViewAdapter = new expCustomAdapter(getActivity()); // simpleRecyclerViewAdapter.addAll(expCustomAdapter.getPreCodeMenu( // sampledatagroup1, // sampledatagroup2, // sampledatagroup3), // 0); // // linearLayoutManager = new LinearLayoutManager(getActivity()); // ultimateRecyclerView.setLayoutManager(linearLayoutManager); // ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter); // ultimateRecyclerView.setRecylerViewBackgroundColor(Color.parseColor("#ffffff")); // addExpandableFeatures(); // // } // // private void addExpandableFeatures() { // ultimateRecyclerView.getItemAnimator().setAddDuration(100); // ultimateRecyclerView.getItemAnimator().setRemoveDuration(100); // ultimateRecyclerView.getItemAnimator().setMoveDuration(200); // ultimateRecyclerView.getItemAnimator().setChangeDuration(100); // } // // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/mainpageDemo.java // public class mainpageDemo extends Fragment { // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.activity_main, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // Button bIntent = (Button) view.findViewById(R.id.openNewIntent); // bIntent.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Utils.routeSinglePage("nothing", getActivity(), CommonSingle.class); // } // }); // } // }
import android.app.Fragment; import com.hkm.slidingmenulib.gestured.SlidingMenu; import com.hkm.slidingmenulib.layoutdesigns.app.SlidingAppCompactActivity; import com.hypebeast.demoslidemenu.content.expandablemenu.MenuFragment; import com.hypebeast.demoslidemenu.content.mainpageDemo;
package com.hypebeast.demoslidemenu; /** * Created by hesk on 10/7/15. */ public class demosys extends SlidingAppCompactActivity<Fragment> { @Override protected int getDefaultMainActivityLayoutId() { return SlidingAppCompactActivity.BODY_LAYOUT.actionbar.getResID(); } @Override
// Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/expandablemenu/MenuFragment.java // public class MenuFragment extends Fragment { // // private UltimateRecyclerView ultimateRecyclerView; // private expCustomAdapter simpleRecyclerViewAdapter = null; // private LinearLayoutManager linearLayoutManager; // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // return inflater.inflate(R.layout.left_slid_menu, container, false); // } // // // private static String[] sampledatagroup1 = { // "peter", "http://google", // "billy", "http://google", // "lisa", "http://google", // "visa", "http://google" // }; // private static String[] sampledatagroup2 = { // "mother", "http://google", // "father", "http://google", // "son", "http://google", // "holy spirit", "http://google", // "god the son", "http://google" // }; // private static String[] sampledatagroup3 = { // "SONY", "http://google", // "LG", "http://google", // "SAMSUNG", "http://google", // "XIAOMI", "http://google", // "HTC", "http://google" // }; // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ultimateRecyclerView = (UltimateRecyclerView) view.findViewById(R.id.ultimate_recycler_view_menu); // ultimateRecyclerView.setHasFixedSize(false); // /** // * this is the adapter for the expanx // */ // simpleRecyclerViewAdapter = new expCustomAdapter(getActivity()); // simpleRecyclerViewAdapter.addAll(expCustomAdapter.getPreCodeMenu( // sampledatagroup1, // sampledatagroup2, // sampledatagroup3), // 0); // // linearLayoutManager = new LinearLayoutManager(getActivity()); // ultimateRecyclerView.setLayoutManager(linearLayoutManager); // ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter); // ultimateRecyclerView.setRecylerViewBackgroundColor(Color.parseColor("#ffffff")); // addExpandableFeatures(); // // } // // private void addExpandableFeatures() { // ultimateRecyclerView.getItemAnimator().setAddDuration(100); // ultimateRecyclerView.getItemAnimator().setRemoveDuration(100); // ultimateRecyclerView.getItemAnimator().setMoveDuration(200); // ultimateRecyclerView.getItemAnimator().setChangeDuration(100); // } // // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/mainpageDemo.java // public class mainpageDemo extends Fragment { // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.activity_main, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // Button bIntent = (Button) view.findViewById(R.id.openNewIntent); // bIntent.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Utils.routeSinglePage("nothing", getActivity(), CommonSingle.class); // } // }); // } // } // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/demosys.java import android.app.Fragment; import com.hkm.slidingmenulib.gestured.SlidingMenu; import com.hkm.slidingmenulib.layoutdesigns.app.SlidingAppCompactActivity; import com.hypebeast.demoslidemenu.content.expandablemenu.MenuFragment; import com.hypebeast.demoslidemenu.content.mainpageDemo; package com.hypebeast.demoslidemenu; /** * Created by hesk on 10/7/15. */ public class demosys extends SlidingAppCompactActivity<Fragment> { @Override protected int getDefaultMainActivityLayoutId() { return SlidingAppCompactActivity.BODY_LAYOUT.actionbar.getResID(); } @Override
protected MenuFragment getFirstMenuFragment() {
jjhesk/KickAssSlidingMenu
AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/demosys.java
// Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/expandablemenu/MenuFragment.java // public class MenuFragment extends Fragment { // // private UltimateRecyclerView ultimateRecyclerView; // private expCustomAdapter simpleRecyclerViewAdapter = null; // private LinearLayoutManager linearLayoutManager; // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // return inflater.inflate(R.layout.left_slid_menu, container, false); // } // // // private static String[] sampledatagroup1 = { // "peter", "http://google", // "billy", "http://google", // "lisa", "http://google", // "visa", "http://google" // }; // private static String[] sampledatagroup2 = { // "mother", "http://google", // "father", "http://google", // "son", "http://google", // "holy spirit", "http://google", // "god the son", "http://google" // }; // private static String[] sampledatagroup3 = { // "SONY", "http://google", // "LG", "http://google", // "SAMSUNG", "http://google", // "XIAOMI", "http://google", // "HTC", "http://google" // }; // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ultimateRecyclerView = (UltimateRecyclerView) view.findViewById(R.id.ultimate_recycler_view_menu); // ultimateRecyclerView.setHasFixedSize(false); // /** // * this is the adapter for the expanx // */ // simpleRecyclerViewAdapter = new expCustomAdapter(getActivity()); // simpleRecyclerViewAdapter.addAll(expCustomAdapter.getPreCodeMenu( // sampledatagroup1, // sampledatagroup2, // sampledatagroup3), // 0); // // linearLayoutManager = new LinearLayoutManager(getActivity()); // ultimateRecyclerView.setLayoutManager(linearLayoutManager); // ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter); // ultimateRecyclerView.setRecylerViewBackgroundColor(Color.parseColor("#ffffff")); // addExpandableFeatures(); // // } // // private void addExpandableFeatures() { // ultimateRecyclerView.getItemAnimator().setAddDuration(100); // ultimateRecyclerView.getItemAnimator().setRemoveDuration(100); // ultimateRecyclerView.getItemAnimator().setMoveDuration(200); // ultimateRecyclerView.getItemAnimator().setChangeDuration(100); // } // // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/mainpageDemo.java // public class mainpageDemo extends Fragment { // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.activity_main, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // Button bIntent = (Button) view.findViewById(R.id.openNewIntent); // bIntent.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Utils.routeSinglePage("nothing", getActivity(), CommonSingle.class); // } // }); // } // }
import android.app.Fragment; import com.hkm.slidingmenulib.gestured.SlidingMenu; import com.hkm.slidingmenulib.layoutdesigns.app.SlidingAppCompactActivity; import com.hypebeast.demoslidemenu.content.expandablemenu.MenuFragment; import com.hypebeast.demoslidemenu.content.mainpageDemo;
package com.hypebeast.demoslidemenu; /** * Created by hesk on 10/7/15. */ public class demosys extends SlidingAppCompactActivity<Fragment> { @Override protected int getDefaultMainActivityLayoutId() { return SlidingAppCompactActivity.BODY_LAYOUT.actionbar.getResID(); } @Override protected MenuFragment getFirstMenuFragment() { return new MenuFragment(); } @Override protected int getRmenu() { return R.menu.menu_main; } @Override
// Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/expandablemenu/MenuFragment.java // public class MenuFragment extends Fragment { // // private UltimateRecyclerView ultimateRecyclerView; // private expCustomAdapter simpleRecyclerViewAdapter = null; // private LinearLayoutManager linearLayoutManager; // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // return inflater.inflate(R.layout.left_slid_menu, container, false); // } // // // private static String[] sampledatagroup1 = { // "peter", "http://google", // "billy", "http://google", // "lisa", "http://google", // "visa", "http://google" // }; // private static String[] sampledatagroup2 = { // "mother", "http://google", // "father", "http://google", // "son", "http://google", // "holy spirit", "http://google", // "god the son", "http://google" // }; // private static String[] sampledatagroup3 = { // "SONY", "http://google", // "LG", "http://google", // "SAMSUNG", "http://google", // "XIAOMI", "http://google", // "HTC", "http://google" // }; // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // ultimateRecyclerView = (UltimateRecyclerView) view.findViewById(R.id.ultimate_recycler_view_menu); // ultimateRecyclerView.setHasFixedSize(false); // /** // * this is the adapter for the expanx // */ // simpleRecyclerViewAdapter = new expCustomAdapter(getActivity()); // simpleRecyclerViewAdapter.addAll(expCustomAdapter.getPreCodeMenu( // sampledatagroup1, // sampledatagroup2, // sampledatagroup3), // 0); // // linearLayoutManager = new LinearLayoutManager(getActivity()); // ultimateRecyclerView.setLayoutManager(linearLayoutManager); // ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter); // ultimateRecyclerView.setRecylerViewBackgroundColor(Color.parseColor("#ffffff")); // addExpandableFeatures(); // // } // // private void addExpandableFeatures() { // ultimateRecyclerView.getItemAnimator().setAddDuration(100); // ultimateRecyclerView.getItemAnimator().setRemoveDuration(100); // ultimateRecyclerView.getItemAnimator().setMoveDuration(200); // ultimateRecyclerView.getItemAnimator().setChangeDuration(100); // } // // } // // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/mainpageDemo.java // public class mainpageDemo extends Fragment { // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // return inflater.inflate(R.layout.activity_main, container, false); // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // Button bIntent = (Button) view.findViewById(R.id.openNewIntent); // bIntent.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Utils.routeSinglePage("nothing", getActivity(), CommonSingle.class); // } // }); // } // } // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/demosys.java import android.app.Fragment; import com.hkm.slidingmenulib.gestured.SlidingMenu; import com.hkm.slidingmenulib.layoutdesigns.app.SlidingAppCompactActivity; import com.hypebeast.demoslidemenu.content.expandablemenu.MenuFragment; import com.hypebeast.demoslidemenu.content.mainpageDemo; package com.hypebeast.demoslidemenu; /** * Created by hesk on 10/7/15. */ public class demosys extends SlidingAppCompactActivity<Fragment> { @Override protected int getDefaultMainActivityLayoutId() { return SlidingAppCompactActivity.BODY_LAYOUT.actionbar.getResID(); } @Override protected MenuFragment getFirstMenuFragment() { return new MenuFragment(); } @Override protected int getRmenu() { return R.menu.menu_main; } @Override
protected mainpageDemo getInitFragment() {
jjhesk/KickAssSlidingMenu
AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/mainpageDemo.java
// Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/CommonSingle.java // public class CommonSingle extends singleDetailPost<DemoFrag2>{ // @Override // protected void loadPageWithFullURL(String url) { // // } // // @Override // protected void loadPageWithPID(long pid) { // // } // // /** // * setting the first initial fragment at the beginning // * // * @return generic type fragment // * @throws Exception the exception for the wrongs // */ // @Override // protected DemoFrag2 getInitFragment() throws Exception { // return new DemoFrag2(); // } // // @Override // protected void onMenuItemSelected(@IdRes int Id) { // // } // }
import android.app.Fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import com.hkm.slidingmenulib.Util.Utils; import com.hypebeast.demoslidemenu.CommonSingle; import com.hypebeast.demoslidemenu.R;
package com.hypebeast.demoslidemenu.content; /** * Created by hesk on 23/6/15. */ public class mainpageDemo extends Fragment { @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { return inflater.inflate(R.layout.activity_main, container, false); } @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Button bIntent = (Button) view.findViewById(R.id.openNewIntent); bIntent.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
// Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/CommonSingle.java // public class CommonSingle extends singleDetailPost<DemoFrag2>{ // @Override // protected void loadPageWithFullURL(String url) { // // } // // @Override // protected void loadPageWithPID(long pid) { // // } // // /** // * setting the first initial fragment at the beginning // * // * @return generic type fragment // * @throws Exception the exception for the wrongs // */ // @Override // protected DemoFrag2 getInitFragment() throws Exception { // return new DemoFrag2(); // } // // @Override // protected void onMenuItemSelected(@IdRes int Id) { // // } // } // Path: AdvancedSlidingMenu/demoslidemenu/src/main/java/com/hypebeast/demoslidemenu/content/mainpageDemo.java import android.app.Fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import com.hkm.slidingmenulib.Util.Utils; import com.hypebeast.demoslidemenu.CommonSingle; import com.hypebeast.demoslidemenu.R; package com.hypebeast.demoslidemenu.content; /** * Created by hesk on 23/6/15. */ public class mainpageDemo extends Fragment { @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { return inflater.inflate(R.layout.activity_main, container, false); } @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Button bIntent = (Button) view.findViewById(R.id.openNewIntent); bIntent.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
Utils.routeSinglePage("nothing", getActivity(), CommonSingle.class);
jjhesk/KickAssSlidingMenu
slideOutMenu/menux/src/main/java/mxh/kickassmenu/fbstyle/TestSlideActivity.java
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/ViewUtils.java // public class ViewUtils { // private ViewUtils() { // } // // public static void setViewWidths(View view, View[] views) { // int w = view.getWidth(); // int h = view.getHeight(); // for (int i = 0; i < views.length; i++) { // View v = views[i]; // v.layout((i + 1) * w, 0, (i + 2) * w, h); // printView("view[" + i + "]", v); // } // } // // public static void printView(String msg, View v) { // System.out.println(msg + "=" + v); // if (null == v) { // return; // } // System.out.print("[" + v.getLeft()); // System.out.print(", " + v.getTop()); // System.out.print(", w=" + v.getWidth()); // System.out.println(", h=" + v.getHeight() + "]"); // System.out.println("mw=" + v.getMeasuredWidth() + ", mh=" + v.getMeasuredHeight()); // System.out.println("scroll [" + v.getScrollX() + "," + v.getScrollY() + "]"); // } // // public static void initListView(Context context, ListView listView, String prefix, int numItems, int layout) { // // By using setAdpater method in listview we an add string array in list. // String[] arr = new String[numItems]; // for (int i = 0; i < arr.length; i++) { // arr[i] = prefix + (i + 1); // } // listView.setAdapter(new ArrayAdapter<String>(context, layout, arr)); // listView.setOnItemClickListener(new OnItemClickListener() { // @Override // public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Context context = view.getContext(); // String msg = "item[" + position + "]=" + parent.getItemAtPosition(position); // Toast.makeText(context, msg, Toast.LENGTH_LONG).show(); // System.out.println(msg); // } // }); // } // }
import mxh.kickassmenu.R; import mxh.kickassmenu.Util.ViewUtils; import android.app.Activity; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.LinearLayout;
/* * #%L * SlidingMenuDemo * $Id:$ * $HeadURL:$ * %% * Copyright (C) 2012 Paul Grime * %% * 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. * #L% */ package mxh.kickassmenu.fbstyle; /** * This demo does not work. */ public class TestSlideActivity extends Activity { ViewGroup parentLayout; LinearLayout layout1; LinearLayout layout2; boolean layout1Shown = true; class ClickListener implements OnClickListener { @Override public void onClick(View v) {
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/ViewUtils.java // public class ViewUtils { // private ViewUtils() { // } // // public static void setViewWidths(View view, View[] views) { // int w = view.getWidth(); // int h = view.getHeight(); // for (int i = 0; i < views.length; i++) { // View v = views[i]; // v.layout((i + 1) * w, 0, (i + 2) * w, h); // printView("view[" + i + "]", v); // } // } // // public static void printView(String msg, View v) { // System.out.println(msg + "=" + v); // if (null == v) { // return; // } // System.out.print("[" + v.getLeft()); // System.out.print(", " + v.getTop()); // System.out.print(", w=" + v.getWidth()); // System.out.println(", h=" + v.getHeight() + "]"); // System.out.println("mw=" + v.getMeasuredWidth() + ", mh=" + v.getMeasuredHeight()); // System.out.println("scroll [" + v.getScrollX() + "," + v.getScrollY() + "]"); // } // // public static void initListView(Context context, ListView listView, String prefix, int numItems, int layout) { // // By using setAdpater method in listview we an add string array in list. // String[] arr = new String[numItems]; // for (int i = 0; i < arr.length; i++) { // arr[i] = prefix + (i + 1); // } // listView.setAdapter(new ArrayAdapter<String>(context, layout, arr)); // listView.setOnItemClickListener(new OnItemClickListener() { // @Override // public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Context context = view.getContext(); // String msg = "item[" + position + "]=" + parent.getItemAtPosition(position); // Toast.makeText(context, msg, Toast.LENGTH_LONG).show(); // System.out.println(msg); // } // }); // } // } // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/fbstyle/TestSlideActivity.java import mxh.kickassmenu.R; import mxh.kickassmenu.Util.ViewUtils; import android.app.Activity; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.LinearLayout; /* * #%L * SlidingMenuDemo * $Id:$ * $HeadURL:$ * %% * Copyright (C) 2012 Paul Grime * %% * 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. * #L% */ package mxh.kickassmenu.fbstyle; /** * This demo does not work. */ public class TestSlideActivity extends Activity { ViewGroup parentLayout; LinearLayout layout1; LinearLayout layout2; boolean layout1Shown = true; class ClickListener implements OnClickListener { @Override public void onClick(View v) {
ViewUtils.printView("parentLayout", parentLayout);
jjhesk/KickAssSlidingMenu
slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/sectionPlate/touchItems/MaterialListSection.java
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/LockableScrollView.java // public class LockableScrollView extends ScrollView { // private boolean mScrollable = true; // // public LockableScrollView(Context context) { // super(context); // } // // public LockableScrollView(Context context, AttributeSet attrs) { // super(context, attrs); // } // // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // public void setScrollingEnabled(boolean enabled) { // mScrollable = enabled; // } // // public boolean isScrollable() { // return mScrollable; // } // // @Override // public boolean onTouchEvent(MotionEvent ev) { // switch (ev.getAction()) { // case MotionEvent.ACTION_DOWN: // // if we can scroll pass the event to the superclass // if (mScrollable) return super.onTouchEvent(ev); // // only continue to handle the touch event if scrolling enabled // return mScrollable; // mScrollable is always false at this point // default: // return super.onTouchEvent(ev); // } // } // // @Override // public boolean onInterceptTouchEvent(MotionEvent ev) { // // Don't do anything with intercepted touch events if // // we are not scrollable // if (!mScrollable) return false; // else return super.onInterceptTouchEvent(ev); // } // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/ImaterialBinder.java // public interface ImaterialBinder { // int getLayout(); // // View init(View view); // }
import android.animation.Animator; import android.animation.ValueAnimator; import android.annotation.SuppressLint; import android.content.res.Resources; import android.support.v4.view.ViewCompat; import android.support.v7.widget.LinearLayoutManager; import android.view.View; import android.view.ViewGroup; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.Animation; import android.view.animation.RotateAnimation; import android.widget.ImageView; import android.widget.TextView; import com.marshalchen.ultimaterecyclerview.UltimateRecyclerView; import com.marshalchen.ultimaterecyclerview.layoutmanagers.CustomLinearLayoutManager; import com.marshalchen.ultimaterecyclerview.quickAdapter.easyRegularAdapter; import java.util.List; import mxh.kickassmenu.R; import mxh.kickassmenu.Util.LockableScrollView; import mxh.kickassmenu.menucontent.ImaterialBinder;
package mxh.kickassmenu.menucontent.sectionPlate.touchItems; /** * Created by hesk on 25/6/15. * from the HB STORE project 2015 */ public class MaterialListSection<TD, CustomTextView extends TextView, RenderBinder extends MaterialListSection.RenderViewBindAdapter> implements ImaterialBinder { public CustomTextView text, notificationtext; public ImageView indicator, icon; public UltimateRecyclerView listview; public static String TAG = "txtNavigation"; private RenderBinder renderer; private boolean mstatusShown, animate_indicator; private View mContainer; private int mContainerOriginalHeight, itemcounts, bottomNavigationHeight;
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/LockableScrollView.java // public class LockableScrollView extends ScrollView { // private boolean mScrollable = true; // // public LockableScrollView(Context context) { // super(context); // } // // public LockableScrollView(Context context, AttributeSet attrs) { // super(context, attrs); // } // // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public LockableScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // public void setScrollingEnabled(boolean enabled) { // mScrollable = enabled; // } // // public boolean isScrollable() { // return mScrollable; // } // // @Override // public boolean onTouchEvent(MotionEvent ev) { // switch (ev.getAction()) { // case MotionEvent.ACTION_DOWN: // // if we can scroll pass the event to the superclass // if (mScrollable) return super.onTouchEvent(ev); // // only continue to handle the touch event if scrolling enabled // return mScrollable; // mScrollable is always false at this point // default: // return super.onTouchEvent(ev); // } // } // // @Override // public boolean onInterceptTouchEvent(MotionEvent ev) { // // Don't do anything with intercepted touch events if // // we are not scrollable // if (!mScrollable) return false; // else return super.onInterceptTouchEvent(ev); // } // } // // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/ImaterialBinder.java // public interface ImaterialBinder { // int getLayout(); // // View init(View view); // } // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/menucontent/sectionPlate/touchItems/MaterialListSection.java import android.animation.Animator; import android.animation.ValueAnimator; import android.annotation.SuppressLint; import android.content.res.Resources; import android.support.v4.view.ViewCompat; import android.support.v7.widget.LinearLayoutManager; import android.view.View; import android.view.ViewGroup; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.Animation; import android.view.animation.RotateAnimation; import android.widget.ImageView; import android.widget.TextView; import com.marshalchen.ultimaterecyclerview.UltimateRecyclerView; import com.marshalchen.ultimaterecyclerview.layoutmanagers.CustomLinearLayoutManager; import com.marshalchen.ultimaterecyclerview.quickAdapter.easyRegularAdapter; import java.util.List; import mxh.kickassmenu.R; import mxh.kickassmenu.Util.LockableScrollView; import mxh.kickassmenu.menucontent.ImaterialBinder; package mxh.kickassmenu.menucontent.sectionPlate.touchItems; /** * Created by hesk on 25/6/15. * from the HB STORE project 2015 */ public class MaterialListSection<TD, CustomTextView extends TextView, RenderBinder extends MaterialListSection.RenderViewBindAdapter> implements ImaterialBinder { public CustomTextView text, notificationtext; public ImageView indicator, icon; public UltimateRecyclerView listview; public static String TAG = "txtNavigation"; private RenderBinder renderer; private boolean mstatusShown, animate_indicator; private View mContainer; private int mContainerOriginalHeight, itemcounts, bottomNavigationHeight;
private LockableScrollView scrollcontainer;
jjhesk/KickAssSlidingMenu
slideOutMenu/menux/src/main/java/mxh/kickassmenu/fbstyle/HorzScrollWithListMenu.java
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/ViewUtils.java // public class ViewUtils { // private ViewUtils() { // } // // public static void setViewWidths(View view, View[] views) { // int w = view.getWidth(); // int h = view.getHeight(); // for (int i = 0; i < views.length; i++) { // View v = views[i]; // v.layout((i + 1) * w, 0, (i + 2) * w, h); // printView("view[" + i + "]", v); // } // } // // public static void printView(String msg, View v) { // System.out.println(msg + "=" + v); // if (null == v) { // return; // } // System.out.print("[" + v.getLeft()); // System.out.print(", " + v.getTop()); // System.out.print(", w=" + v.getWidth()); // System.out.println(", h=" + v.getHeight() + "]"); // System.out.println("mw=" + v.getMeasuredWidth() + ", mh=" + v.getMeasuredHeight()); // System.out.println("scroll [" + v.getScrollX() + "," + v.getScrollY() + "]"); // } // // public static void initListView(Context context, ListView listView, String prefix, int numItems, int layout) { // // By using setAdpater method in listview we an add string array in list. // String[] arr = new String[numItems]; // for (int i = 0; i < arr.length; i++) { // arr[i] = prefix + (i + 1); // } // listView.setAdapter(new ArrayAdapter<String>(context, layout, arr)); // listView.setOnItemClickListener(new OnItemClickListener() { // @Override // public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Context context = view.getContext(); // String msg = "item[" + position + "]=" + parent.getItemAtPosition(position); // Toast.makeText(context, msg, Toast.LENGTH_LONG).show(); // System.out.println(msg); // } // }); // } // }
import android.widget.ImageView; import android.widget.ListView; import android.widget.Toast; import java.util.Date; import mxh.kickassmenu.R; import mxh.kickassmenu.Util.ViewUtils; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.os.Handler; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.HorizontalScrollView;
/* * #%L * SlidingMenuDemo * $Id:$ * $HeadURL:$ * %% * Copyright (C) 2012 Paul Grime * %% * 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. * #L% */ package mxh.kickassmenu.fbstyle; /** * This demo uses a custom HorizontalScrollView that ignores touch events, and therefore does NOT allow manual scrolling. * * The only scrolling allowed is scrolling in code triggered by the menu button. * * When the button is pressed, both the menu and the app will scroll. So the menu isn't revealed from beneath the app, it * adjoins the app and moves with the app. */ public class HorzScrollWithListMenu extends Activity { MyHorizontalScrollView scrollView; View menu; View app; ImageView btnSlide; boolean menuOut = false; Handler handler = new Handler(); int btnWidth; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LayoutInflater inflater = LayoutInflater.from(this); scrollView = (MyHorizontalScrollView) inflater.inflate(R.layout.horz_scroll_with_list_menu, null); setContentView(scrollView); menu = inflater.inflate(R.layout.horz_scroll_menu, null); app = inflater.inflate(R.layout.horz_scroll_app, null); ViewGroup tabBar = (ViewGroup) app.findViewById(R.id.tabBar); ListView listView = (ListView) app.findViewById(R.id.list);
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/ViewUtils.java // public class ViewUtils { // private ViewUtils() { // } // // public static void setViewWidths(View view, View[] views) { // int w = view.getWidth(); // int h = view.getHeight(); // for (int i = 0; i < views.length; i++) { // View v = views[i]; // v.layout((i + 1) * w, 0, (i + 2) * w, h); // printView("view[" + i + "]", v); // } // } // // public static void printView(String msg, View v) { // System.out.println(msg + "=" + v); // if (null == v) { // return; // } // System.out.print("[" + v.getLeft()); // System.out.print(", " + v.getTop()); // System.out.print(", w=" + v.getWidth()); // System.out.println(", h=" + v.getHeight() + "]"); // System.out.println("mw=" + v.getMeasuredWidth() + ", mh=" + v.getMeasuredHeight()); // System.out.println("scroll [" + v.getScrollX() + "," + v.getScrollY() + "]"); // } // // public static void initListView(Context context, ListView listView, String prefix, int numItems, int layout) { // // By using setAdpater method in listview we an add string array in list. // String[] arr = new String[numItems]; // for (int i = 0; i < arr.length; i++) { // arr[i] = prefix + (i + 1); // } // listView.setAdapter(new ArrayAdapter<String>(context, layout, arr)); // listView.setOnItemClickListener(new OnItemClickListener() { // @Override // public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Context context = view.getContext(); // String msg = "item[" + position + "]=" + parent.getItemAtPosition(position); // Toast.makeText(context, msg, Toast.LENGTH_LONG).show(); // System.out.println(msg); // } // }); // } // } // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/fbstyle/HorzScrollWithListMenu.java import android.widget.ImageView; import android.widget.ListView; import android.widget.Toast; import java.util.Date; import mxh.kickassmenu.R; import mxh.kickassmenu.Util.ViewUtils; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.os.Handler; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.HorizontalScrollView; /* * #%L * SlidingMenuDemo * $Id:$ * $HeadURL:$ * %% * Copyright (C) 2012 Paul Grime * %% * 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. * #L% */ package mxh.kickassmenu.fbstyle; /** * This demo uses a custom HorizontalScrollView that ignores touch events, and therefore does NOT allow manual scrolling. * * The only scrolling allowed is scrolling in code triggered by the menu button. * * When the button is pressed, both the menu and the app will scroll. So the menu isn't revealed from beneath the app, it * adjoins the app and moves with the app. */ public class HorzScrollWithListMenu extends Activity { MyHorizontalScrollView scrollView; View menu; View app; ImageView btnSlide; boolean menuOut = false; Handler handler = new Handler(); int btnWidth; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LayoutInflater inflater = LayoutInflater.from(this); scrollView = (MyHorizontalScrollView) inflater.inflate(R.layout.horz_scroll_with_list_menu, null); setContentView(scrollView); menu = inflater.inflate(R.layout.horz_scroll_menu, null); app = inflater.inflate(R.layout.horz_scroll_app, null); ViewGroup tabBar = (ViewGroup) app.findViewById(R.id.tabBar); ListView listView = (ListView) app.findViewById(R.id.list);
ViewUtils.initListView(this, listView, "Item ", 30, android.R.layout.simple_list_item_1);
jjhesk/KickAssSlidingMenu
slideOutMenu/menux/src/main/java/mxh/kickassmenu/fbstyle/AnimationStackedFrames.java
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/ViewUtils.java // public class ViewUtils { // private ViewUtils() { // } // // public static void setViewWidths(View view, View[] views) { // int w = view.getWidth(); // int h = view.getHeight(); // for (int i = 0; i < views.length; i++) { // View v = views[i]; // v.layout((i + 1) * w, 0, (i + 2) * w, h); // printView("view[" + i + "]", v); // } // } // // public static void printView(String msg, View v) { // System.out.println(msg + "=" + v); // if (null == v) { // return; // } // System.out.print("[" + v.getLeft()); // System.out.print(", " + v.getTop()); // System.out.print(", w=" + v.getWidth()); // System.out.println(", h=" + v.getHeight() + "]"); // System.out.println("mw=" + v.getMeasuredWidth() + ", mh=" + v.getMeasuredHeight()); // System.out.println("scroll [" + v.getScrollX() + "," + v.getScrollY() + "]"); // } // // public static void initListView(Context context, ListView listView, String prefix, int numItems, int layout) { // // By using setAdpater method in listview we an add string array in list. // String[] arr = new String[numItems]; // for (int i = 0; i < arr.length; i++) { // arr[i] = prefix + (i + 1); // } // listView.setAdapter(new ArrayAdapter<String>(context, layout, arr)); // listView.setOnItemClickListener(new OnItemClickListener() { // @Override // public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Context context = view.getContext(); // String msg = "item[" + position + "]=" + parent.getItemAtPosition(position); // Toast.makeText(context, msg, Toast.LENGTH_LONG).show(); // System.out.println(msg); // } // }); // } // }
import android.widget.ListView; import mxh.kickassmenu.R; import mxh.kickassmenu.Util.ViewUtils; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationUtils; import android.widget.FrameLayout;
/* * #%L * SlidingMenuDemo * $Id:$ * $HeadURL:$ * %% * Copyright (C) 2012 Paul Grime * %% * 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. * #L% */ package mxh.kickassmenu.fbstyle; /** * Animates the menu view over the app view in a FrameLayout. * * As this uses animations, after the menu has moved over the app, touch events are still passed to the app, as the menu View * actually hasn't moved. The animation just renders the menu in a different location to its real position. */ public class AnimationStackedFrames extends Activity implements AnimationListener { FrameLayout mFrameLayout; View menu; View app; boolean menuOut = false; class ClickListener implements OnClickListener { @Override public void onClick(View v) { AnimationStackedFrames me = AnimationStackedFrames.this; Context context = me; Animation anim; if (!menuOut) { menu.setVisibility(View.VISIBLE);
// Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/Util/ViewUtils.java // public class ViewUtils { // private ViewUtils() { // } // // public static void setViewWidths(View view, View[] views) { // int w = view.getWidth(); // int h = view.getHeight(); // for (int i = 0; i < views.length; i++) { // View v = views[i]; // v.layout((i + 1) * w, 0, (i + 2) * w, h); // printView("view[" + i + "]", v); // } // } // // public static void printView(String msg, View v) { // System.out.println(msg + "=" + v); // if (null == v) { // return; // } // System.out.print("[" + v.getLeft()); // System.out.print(", " + v.getTop()); // System.out.print(", w=" + v.getWidth()); // System.out.println(", h=" + v.getHeight() + "]"); // System.out.println("mw=" + v.getMeasuredWidth() + ", mh=" + v.getMeasuredHeight()); // System.out.println("scroll [" + v.getScrollX() + "," + v.getScrollY() + "]"); // } // // public static void initListView(Context context, ListView listView, String prefix, int numItems, int layout) { // // By using setAdpater method in listview we an add string array in list. // String[] arr = new String[numItems]; // for (int i = 0; i < arr.length; i++) { // arr[i] = prefix + (i + 1); // } // listView.setAdapter(new ArrayAdapter<String>(context, layout, arr)); // listView.setOnItemClickListener(new OnItemClickListener() { // @Override // public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Context context = view.getContext(); // String msg = "item[" + position + "]=" + parent.getItemAtPosition(position); // Toast.makeText(context, msg, Toast.LENGTH_LONG).show(); // System.out.println(msg); // } // }); // } // } // Path: slideOutMenu/menux/src/main/java/mxh/kickassmenu/fbstyle/AnimationStackedFrames.java import android.widget.ListView; import mxh.kickassmenu.R; import mxh.kickassmenu.Util.ViewUtils; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationUtils; import android.widget.FrameLayout; /* * #%L * SlidingMenuDemo * $Id:$ * $HeadURL:$ * %% * Copyright (C) 2012 Paul Grime * %% * 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. * #L% */ package mxh.kickassmenu.fbstyle; /** * Animates the menu view over the app view in a FrameLayout. * * As this uses animations, after the menu has moved over the app, touch events are still passed to the app, as the menu View * actually hasn't moved. The animation just renders the menu in a different location to its real position. */ public class AnimationStackedFrames extends Activity implements AnimationListener { FrameLayout mFrameLayout; View menu; View app; boolean menuOut = false; class ClickListener implements OnClickListener { @Override public void onClick(View v) { AnimationStackedFrames me = AnimationStackedFrames.this; Context context = me; Animation anim; if (!menuOut) { menu.setVisibility(View.VISIBLE);
ViewUtils.printView("menu", menu);
52Jolynn/MyTv
src/main/java/com/laudandjolynn/mytv/datasource/Sqlite.java
// Path: src/main/java/com/laudandjolynn/mytv/utils/Constant.java // public class Constant { // // 应用名称 // public final static String APP_NAME = "mytv"; // // CPU核数 // public static final int CPU_PROCESSOR_NUM = Runtime.getRuntime() // .availableProcessors(); // // 数据文件目录 // public final static String MY_TV_DATA_PATH = Config.getDataFilePath() // + "data" + File.separator; // // 数据文件 // public final static String MY_TV_DATA_FILE_PATH = MY_TV_DATA_PATH // + "mytv.dat"; // // 电视节目表文件路径 // public final static String CRAWL_FILE_PATH = Constant.MY_TV_DATA_PATH // + "crawlfiles" + File.separator; // // public final static String XML_TAG_DB = "db"; // public final static String XML_TAG_DATA = "data"; // public final static String XML_TAG_STATION = "station"; // public final static String XML_TAG_PROGRAM = "program"; // // public final static String TV_STATION_INIT_DATA_FILE_NAME = "tv_station.properties"; // public final static String TV_STATION_ALIAS_INIT_DATA_FILE_NAME = "tv_station_alias.properties"; // // public final static String DOT = "."; // public final static String COMMA = ","; // public final static String UNDERLINE = "_"; // public final static String COLON = ":"; // // static { // File file = new File(MY_TV_DATA_PATH); // if (!file.exists()) { // file.mkdirs(); // } // // file = new File(CRAWL_FILE_PATH); // if (!file.exists()) { // file.mkdirs(); // } // } // // }
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Properties; import com.laudandjolynn.mytv.utils.Constant;
/******************************************************************************* * Copyright 2015 htd0324@gmail.com * * 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.laudandjolynn.mytv.datasource; /** * @author: Laud * @email: htd0324@gmail.com * @date: 2015年4月14日 上午9:39:20 * @copyright: www.laudandjolynn.com */ public class Sqlite implements TvDataSource { @Override public Connection getConnection(Properties prop) throws SQLException { String dbFileName = prop .getProperty(DataSourceManager.RES_KEY_DB_FILE_NAME); return DriverManager.getConnection("jdbc:sqlite:"
// Path: src/main/java/com/laudandjolynn/mytv/utils/Constant.java // public class Constant { // // 应用名称 // public final static String APP_NAME = "mytv"; // // CPU核数 // public static final int CPU_PROCESSOR_NUM = Runtime.getRuntime() // .availableProcessors(); // // 数据文件目录 // public final static String MY_TV_DATA_PATH = Config.getDataFilePath() // + "data" + File.separator; // // 数据文件 // public final static String MY_TV_DATA_FILE_PATH = MY_TV_DATA_PATH // + "mytv.dat"; // // 电视节目表文件路径 // public final static String CRAWL_FILE_PATH = Constant.MY_TV_DATA_PATH // + "crawlfiles" + File.separator; // // public final static String XML_TAG_DB = "db"; // public final static String XML_TAG_DATA = "data"; // public final static String XML_TAG_STATION = "station"; // public final static String XML_TAG_PROGRAM = "program"; // // public final static String TV_STATION_INIT_DATA_FILE_NAME = "tv_station.properties"; // public final static String TV_STATION_ALIAS_INIT_DATA_FILE_NAME = "tv_station_alias.properties"; // // public final static String DOT = "."; // public final static String COMMA = ","; // public final static String UNDERLINE = "_"; // public final static String COLON = ":"; // // static { // File file = new File(MY_TV_DATA_PATH); // if (!file.exists()) { // file.mkdirs(); // } // // file = new File(CRAWL_FILE_PATH); // if (!file.exists()) { // file.mkdirs(); // } // } // // } // Path: src/main/java/com/laudandjolynn/mytv/datasource/Sqlite.java import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Properties; import com.laudandjolynn.mytv.utils.Constant; /******************************************************************************* * Copyright 2015 htd0324@gmail.com * * 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.laudandjolynn.mytv.datasource; /** * @author: Laud * @email: htd0324@gmail.com * @date: 2015年4月14日 上午9:39:20 * @copyright: www.laudandjolynn.com */ public class Sqlite implements TvDataSource { @Override public Connection getConnection(Properties prop) throws SQLException { String dbFileName = prop .getProperty(DataSourceManager.RES_KEY_DB_FILE_NAME); return DriverManager.getConnection("jdbc:sqlite:"
+ Constant.MY_TV_DATA_PATH + dbFileName);
52Jolynn/MyTv
src/main/java/com/laudandjolynn/mytv/crawler/MyTvCrawlerFactory.java
// Path: src/main/java/com/laudandjolynn/mytv/crawler/epg/EpgCrawlerFactory.java // public class EpgCrawlerFactory implements CrawlerFactory { // @Override // public Crawler createCrawler() { // return new EpgCrawler(); // } // } // // Path: src/main/java/com/laudandjolynn/mytv/crawler/tvmao/TvMaoCrawlerFactory.java // public class TvMaoCrawlerFactory implements CrawlerFactory { // @Override // public Crawler createCrawler() { // return new TvMaoCrawler(); // } // }
import com.laudandjolynn.mytv.crawler.epg.EpgCrawlerFactory; import com.laudandjolynn.mytv.crawler.tvmao.TvMaoCrawlerFactory;
/******************************************************************************* * Copyright 2015 htd0324@gmail.com * * 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.laudandjolynn.mytv.crawler; /** * @author: Laud * @email: htd0324@gmail.com * @date: 2015年4月16日 下午2:57:53 * @copyright: www.laudandjolynn.com */ public class MyTvCrawlerFactory implements CrawlerFactory { @Override public Crawler createCrawler() { CrawlerGroup cralwerGroup = new CrawlerGroup();
// Path: src/main/java/com/laudandjolynn/mytv/crawler/epg/EpgCrawlerFactory.java // public class EpgCrawlerFactory implements CrawlerFactory { // @Override // public Crawler createCrawler() { // return new EpgCrawler(); // } // } // // Path: src/main/java/com/laudandjolynn/mytv/crawler/tvmao/TvMaoCrawlerFactory.java // public class TvMaoCrawlerFactory implements CrawlerFactory { // @Override // public Crawler createCrawler() { // return new TvMaoCrawler(); // } // } // Path: src/main/java/com/laudandjolynn/mytv/crawler/MyTvCrawlerFactory.java import com.laudandjolynn.mytv.crawler.epg.EpgCrawlerFactory; import com.laudandjolynn.mytv.crawler.tvmao.TvMaoCrawlerFactory; /******************************************************************************* * Copyright 2015 htd0324@gmail.com * * 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.laudandjolynn.mytv.crawler; /** * @author: Laud * @email: htd0324@gmail.com * @date: 2015年4月16日 下午2:57:53 * @copyright: www.laudandjolynn.com */ public class MyTvCrawlerFactory implements CrawlerFactory { @Override public Crawler createCrawler() { CrawlerGroup cralwerGroup = new CrawlerGroup();
cralwerGroup.addCrawler(new EpgCrawlerFactory().createCrawler());
52Jolynn/MyTv
src/main/java/com/laudandjolynn/mytv/crawler/MyTvCrawlerFactory.java
// Path: src/main/java/com/laudandjolynn/mytv/crawler/epg/EpgCrawlerFactory.java // public class EpgCrawlerFactory implements CrawlerFactory { // @Override // public Crawler createCrawler() { // return new EpgCrawler(); // } // } // // Path: src/main/java/com/laudandjolynn/mytv/crawler/tvmao/TvMaoCrawlerFactory.java // public class TvMaoCrawlerFactory implements CrawlerFactory { // @Override // public Crawler createCrawler() { // return new TvMaoCrawler(); // } // }
import com.laudandjolynn.mytv.crawler.epg.EpgCrawlerFactory; import com.laudandjolynn.mytv.crawler.tvmao.TvMaoCrawlerFactory;
/******************************************************************************* * Copyright 2015 htd0324@gmail.com * * 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.laudandjolynn.mytv.crawler; /** * @author: Laud * @email: htd0324@gmail.com * @date: 2015年4月16日 下午2:57:53 * @copyright: www.laudandjolynn.com */ public class MyTvCrawlerFactory implements CrawlerFactory { @Override public Crawler createCrawler() { CrawlerGroup cralwerGroup = new CrawlerGroup(); cralwerGroup.addCrawler(new EpgCrawlerFactory().createCrawler());
// Path: src/main/java/com/laudandjolynn/mytv/crawler/epg/EpgCrawlerFactory.java // public class EpgCrawlerFactory implements CrawlerFactory { // @Override // public Crawler createCrawler() { // return new EpgCrawler(); // } // } // // Path: src/main/java/com/laudandjolynn/mytv/crawler/tvmao/TvMaoCrawlerFactory.java // public class TvMaoCrawlerFactory implements CrawlerFactory { // @Override // public Crawler createCrawler() { // return new TvMaoCrawler(); // } // } // Path: src/main/java/com/laudandjolynn/mytv/crawler/MyTvCrawlerFactory.java import com.laudandjolynn.mytv.crawler.epg.EpgCrawlerFactory; import com.laudandjolynn.mytv.crawler.tvmao.TvMaoCrawlerFactory; /******************************************************************************* * Copyright 2015 htd0324@gmail.com * * 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.laudandjolynn.mytv.crawler; /** * @author: Laud * @email: htd0324@gmail.com * @date: 2015年4月16日 下午2:57:53 * @copyright: www.laudandjolynn.com */ public class MyTvCrawlerFactory implements CrawlerFactory { @Override public Crawler createCrawler() { CrawlerGroup cralwerGroup = new CrawlerGroup(); cralwerGroup.addCrawler(new EpgCrawlerFactory().createCrawler());
cralwerGroup.addCrawler(new TvMaoCrawlerFactory().createCrawler());
52Jolynn/MyTv
src/main/java/com/laudandjolynn/mytv/crawler/epg/EpgCrawlerFactory.java
// Path: src/main/java/com/laudandjolynn/mytv/crawler/Crawler.java // public interface Crawler { // /** // * 抓取所有电视台 // * // * @return // */ // public List<TvStation> crawlAllTvStation(); // // /** // * 根据电视台名称、日期抓取电视节目表 // * // * @param date // * @param station // * @return // */ // public List<ProgramTable> crawlProgramTable(String date, TvStation station); // // /** // * 判断指定电视台是否可抓取 // * // * @param station // * @return // */ // public boolean exists(TvStation station); // // /** // * 获取抓取器名称 // * // * @return // */ // public String getCrawlerName(); // // /** // * 获取抓取地址 // * // * @return // */ // public String getUrl(); // // /** // * 注册抓取事件监听器 // * // * @param listener // */ // public void registerCrawlEventListener(CrawlEventListener listener); // // /** // * 删除抓取事件监听器 // * // * @param listener // */ // public void removeCrawlEventListener(CrawlEventListener listener); // } // // Path: src/main/java/com/laudandjolynn/mytv/crawler/CrawlerFactory.java // public interface CrawlerFactory { // /** // * 创建抓取器 // * // * @return // */ // public Crawler createCrawler(); // }
import com.laudandjolynn.mytv.crawler.Crawler; import com.laudandjolynn.mytv.crawler.CrawlerFactory;
/******************************************************************************* * Copyright 2015 htd0324@gmail.com * * 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.laudandjolynn.mytv.crawler.epg; /** * @author: Laud * @email: htd0324@gmail.com * @date: 2015年4月16日 下午12:27:25 * @copyright: www.laudandjolynn.com */ public class EpgCrawlerFactory implements CrawlerFactory { @Override
// Path: src/main/java/com/laudandjolynn/mytv/crawler/Crawler.java // public interface Crawler { // /** // * 抓取所有电视台 // * // * @return // */ // public List<TvStation> crawlAllTvStation(); // // /** // * 根据电视台名称、日期抓取电视节目表 // * // * @param date // * @param station // * @return // */ // public List<ProgramTable> crawlProgramTable(String date, TvStation station); // // /** // * 判断指定电视台是否可抓取 // * // * @param station // * @return // */ // public boolean exists(TvStation station); // // /** // * 获取抓取器名称 // * // * @return // */ // public String getCrawlerName(); // // /** // * 获取抓取地址 // * // * @return // */ // public String getUrl(); // // /** // * 注册抓取事件监听器 // * // * @param listener // */ // public void registerCrawlEventListener(CrawlEventListener listener); // // /** // * 删除抓取事件监听器 // * // * @param listener // */ // public void removeCrawlEventListener(CrawlEventListener listener); // } // // Path: src/main/java/com/laudandjolynn/mytv/crawler/CrawlerFactory.java // public interface CrawlerFactory { // /** // * 创建抓取器 // * // * @return // */ // public Crawler createCrawler(); // } // Path: src/main/java/com/laudandjolynn/mytv/crawler/epg/EpgCrawlerFactory.java import com.laudandjolynn.mytv.crawler.Crawler; import com.laudandjolynn.mytv.crawler.CrawlerFactory; /******************************************************************************* * Copyright 2015 htd0324@gmail.com * * 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.laudandjolynn.mytv.crawler.epg; /** * @author: Laud * @email: htd0324@gmail.com * @date: 2015年4月16日 下午12:27:25 * @copyright: www.laudandjolynn.com */ public class EpgCrawlerFactory implements CrawlerFactory { @Override
public Crawler createCrawler() {
52Jolynn/MyTv
src/main/java/com/laudandjolynn/mytv/utils/MyTvUtils.java
// Path: src/main/java/com/laudandjolynn/mytv/exception/MyTvException.java // public class MyTvException extends RuntimeException { // private static final long serialVersionUID = -2699920699817552410L; // // public MyTvException() { // super(); // } // // public MyTvException(String message, Throwable cause) { // super(message, cause); // } // // public MyTvException(String message) { // super(message); // } // // public MyTvException(Throwable cause) { // super(cause); // } // // }
import java.io.File; import java.io.IOException; import java.net.URL; import java.net.URLDecoder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.laudandjolynn.mytv.exception.MyTvException;
/******************************************************************************* * Copyright 2015 htd0324@gmail.com * * 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.laudandjolynn.mytv.utils; /** * @author: Laud * @email: htd0324@gmail.com * @date: 2015年3月30日 上午9:34:41 * @copyright: www.laudandjolynn.com */ public class MyTvUtils { private final static Logger logger = LoggerFactory .getLogger(MyTvUtils.class); /** * 读入html文件 * * @param path * @return */ public static String readAsHtml(String path) throws IOException { return new String(FileUtils.readWithNIO(path, "UTF-8"), "UTF-8"); } /** * 输出抓取数据到文件 * * @param dirName * 目录名称,如日期,yyyy-MM-dd * @param data * 数据 * @param fileName * 文件名 */ public static void outputCrawlData(String dirName, String data, String fileName) { String crawlFileDir = Constant.CRAWL_FILE_PATH + dirName + File.separator; File file = new File(crawlFileDir); if (!file.exists()) { file.mkdirs(); } String crawlFilePath = crawlFileDir + fileName; // 若文件已存在,则删除 file = new File(crawlFilePath); if (file.exists()) { file.delete(); } try { logger.info("write data to file: " + crawlFilePath); FileUtils.writeWithNIO(data, FileUtils.DEFAULT_CHARSET_NAME, crawlFilePath); } catch (IOException e) {
// Path: src/main/java/com/laudandjolynn/mytv/exception/MyTvException.java // public class MyTvException extends RuntimeException { // private static final long serialVersionUID = -2699920699817552410L; // // public MyTvException() { // super(); // } // // public MyTvException(String message, Throwable cause) { // super(message, cause); // } // // public MyTvException(String message) { // super(message); // } // // public MyTvException(Throwable cause) { // super(cause); // } // // } // Path: src/main/java/com/laudandjolynn/mytv/utils/MyTvUtils.java import java.io.File; import java.io.IOException; import java.net.URL; import java.net.URLDecoder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.laudandjolynn.mytv.exception.MyTvException; /******************************************************************************* * Copyright 2015 htd0324@gmail.com * * 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.laudandjolynn.mytv.utils; /** * @author: Laud * @email: htd0324@gmail.com * @date: 2015年3月30日 上午9:34:41 * @copyright: www.laudandjolynn.com */ public class MyTvUtils { private final static Logger logger = LoggerFactory .getLogger(MyTvUtils.class); /** * 读入html文件 * * @param path * @return */ public static String readAsHtml(String path) throws IOException { return new String(FileUtils.readWithNIO(path, "UTF-8"), "UTF-8"); } /** * 输出抓取数据到文件 * * @param dirName * 目录名称,如日期,yyyy-MM-dd * @param data * 数据 * @param fileName * 文件名 */ public static void outputCrawlData(String dirName, String data, String fileName) { String crawlFileDir = Constant.CRAWL_FILE_PATH + dirName + File.separator; File file = new File(crawlFileDir); if (!file.exists()) { file.mkdirs(); } String crawlFilePath = crawlFileDir + fileName; // 若文件已存在,则删除 file = new File(crawlFilePath); if (file.exists()) { file.delete(); } try { logger.info("write data to file: " + crawlFilePath); FileUtils.writeWithNIO(data, FileUtils.DEFAULT_CHARSET_NAME, crawlFilePath); } catch (IOException e) {
throw new MyTvException(
52Jolynn/MyTv
src/main/java/com/laudandjolynn/mytv/crawler/tvmao/TvMaoCrawlerFactory.java
// Path: src/main/java/com/laudandjolynn/mytv/crawler/Crawler.java // public interface Crawler { // /** // * 抓取所有电视台 // * // * @return // */ // public List<TvStation> crawlAllTvStation(); // // /** // * 根据电视台名称、日期抓取电视节目表 // * // * @param date // * @param station // * @return // */ // public List<ProgramTable> crawlProgramTable(String date, TvStation station); // // /** // * 判断指定电视台是否可抓取 // * // * @param station // * @return // */ // public boolean exists(TvStation station); // // /** // * 获取抓取器名称 // * // * @return // */ // public String getCrawlerName(); // // /** // * 获取抓取地址 // * // * @return // */ // public String getUrl(); // // /** // * 注册抓取事件监听器 // * // * @param listener // */ // public void registerCrawlEventListener(CrawlEventListener listener); // // /** // * 删除抓取事件监听器 // * // * @param listener // */ // public void removeCrawlEventListener(CrawlEventListener listener); // } // // Path: src/main/java/com/laudandjolynn/mytv/crawler/CrawlerFactory.java // public interface CrawlerFactory { // /** // * 创建抓取器 // * // * @return // */ // public Crawler createCrawler(); // }
import com.laudandjolynn.mytv.crawler.Crawler; import com.laudandjolynn.mytv.crawler.CrawlerFactory;
/******************************************************************************* * Copyright 2015 htd0324@gmail.com * * 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.laudandjolynn.mytv.crawler.tvmao; /** * @author: Laud * @email: htd0324@gmail.com * @date: 2015年4月16日 下午12:29:59 * @copyright: www.laudandjolynn.com */ public class TvMaoCrawlerFactory implements CrawlerFactory { @Override
// Path: src/main/java/com/laudandjolynn/mytv/crawler/Crawler.java // public interface Crawler { // /** // * 抓取所有电视台 // * // * @return // */ // public List<TvStation> crawlAllTvStation(); // // /** // * 根据电视台名称、日期抓取电视节目表 // * // * @param date // * @param station // * @return // */ // public List<ProgramTable> crawlProgramTable(String date, TvStation station); // // /** // * 判断指定电视台是否可抓取 // * // * @param station // * @return // */ // public boolean exists(TvStation station); // // /** // * 获取抓取器名称 // * // * @return // */ // public String getCrawlerName(); // // /** // * 获取抓取地址 // * // * @return // */ // public String getUrl(); // // /** // * 注册抓取事件监听器 // * // * @param listener // */ // public void registerCrawlEventListener(CrawlEventListener listener); // // /** // * 删除抓取事件监听器 // * // * @param listener // */ // public void removeCrawlEventListener(CrawlEventListener listener); // } // // Path: src/main/java/com/laudandjolynn/mytv/crawler/CrawlerFactory.java // public interface CrawlerFactory { // /** // * 创建抓取器 // * // * @return // */ // public Crawler createCrawler(); // } // Path: src/main/java/com/laudandjolynn/mytv/crawler/tvmao/TvMaoCrawlerFactory.java import com.laudandjolynn.mytv.crawler.Crawler; import com.laudandjolynn.mytv.crawler.CrawlerFactory; /******************************************************************************* * Copyright 2015 htd0324@gmail.com * * 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.laudandjolynn.mytv.crawler.tvmao; /** * @author: Laud * @email: htd0324@gmail.com * @date: 2015年4月16日 下午12:29:59 * @copyright: www.laudandjolynn.com */ public class TvMaoCrawlerFactory implements CrawlerFactory { @Override
public Crawler createCrawler() {
WetABQ/Nukkit-AntiCheat
src/main/java/top/dreamcity/AntiCheat/Config/MasterConfig.java
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheat.java // public class AntiCheat extends PluginBase implements AntiCheatAPI { // // private static AntiCheat instance; // private static MasterConfig masterConfig; // private PlayerCheatRecord playerCheatRecord; // public static HashMap<String, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType> reportPlayer = new HashMap<>(); // public static HashMap<String, Report> reportThread = new HashMap<>(); // public static HashSet<String> DemoPlayer = new HashSet<>(); // // public static AntiCheat getInstance() { // return instance; // } // // // @Override // public void onLoad() { // instance = this; // this.saveResource("Steve.png"); // this.getLogger().notice("AntiCheat - Load"); // } // // @Override // public void onEnable() { // // initConfig(); // // initAntiThread(); // // Server.getInstance().getCommandMap().register("", new ReportCommand()); // // this.getServer().getPluginManager().registerEvents(new EventListener(), this); // // this.getLogger().notice("AntiCheat - Enable"); // } // // @Override // public void onDisable() { // this.getLogger().notice("AntiCheat - Disable"); // } // // private void initAntiThread() { // //this.getServer().getScheduler().scheduleRepeatingTask(new AntiSpeedThread(this),1); // new AntiSpeedThread(); // new CheckChatThread(); // new AntiFlyThread(); // new AntiWaterWalkThread(); // } // // private void initConfig() { // Config c = new Config(this.getDataFolder() + "/config.yml", Config.YAML); // masterConfig = new MasterConfig(c.getRootSection()); // if (masterConfig.isEmpty()) { // this.getLogger().warning("The Config is empty!"); // } // playerCheatRecord = new PlayerCheatRecord(new Config(this.getDataFolder() + "/record.yml", Config.YAML).getRootSection()); // } // // @Override // public void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType) { // playerCheatRecord.addRecord(player, cheatType); // } // // @Override // public MasterConfig getMasterConfig() { // return masterConfig; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // }
import cn.nukkit.utils.Config; import cn.nukkit.utils.ConfigSection; import top.dreamcity.AntiCheat.AntiCheat; import top.dreamcity.AntiCheat.AntiCheatAPI; import java.util.ArrayList;
maxMoveSpeed = (float) config.getDouble("maxMoveSpeed"); pingNoCheckValue = config.getInt("pingNoCheckValue"); inAirTimeCheck = config.getInt("inAirTimeCheck"); chatSec = config.getInt("chatSec"); checkKillAuraCPS = config.getInt("checkKillAuraCPS"); SensitiveWords = (ArrayList) config.get("SensitiveWords"); SkinPath = config.getString("RobotSkinPath"); } else { spawnDefaultConfig(); } } public void spawnDefaultConfig() { AntiCheat.getInstance().getLogger().notice("Start spawning default config."); antiSpeed = true; checkBB = true; antiFly = true; checkChat = true; checkChatWord = true; antiKillAura = true; antiAutoAim = true; antiSpeedPingCheck = true; maxMoveSpeed = 10F; pingNoCheckValue = 25; inAirTimeCheck = 5; chatSec = 2; checkKillAuraCPS = 3; SensitiveWords = new ArrayList<>(); SensitiveWords.add("fuck"); SensitiveWords.add("shit");
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheat.java // public class AntiCheat extends PluginBase implements AntiCheatAPI { // // private static AntiCheat instance; // private static MasterConfig masterConfig; // private PlayerCheatRecord playerCheatRecord; // public static HashMap<String, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType> reportPlayer = new HashMap<>(); // public static HashMap<String, Report> reportThread = new HashMap<>(); // public static HashSet<String> DemoPlayer = new HashSet<>(); // // public static AntiCheat getInstance() { // return instance; // } // // // @Override // public void onLoad() { // instance = this; // this.saveResource("Steve.png"); // this.getLogger().notice("AntiCheat - Load"); // } // // @Override // public void onEnable() { // // initConfig(); // // initAntiThread(); // // Server.getInstance().getCommandMap().register("", new ReportCommand()); // // this.getServer().getPluginManager().registerEvents(new EventListener(), this); // // this.getLogger().notice("AntiCheat - Enable"); // } // // @Override // public void onDisable() { // this.getLogger().notice("AntiCheat - Disable"); // } // // private void initAntiThread() { // //this.getServer().getScheduler().scheduleRepeatingTask(new AntiSpeedThread(this),1); // new AntiSpeedThread(); // new CheckChatThread(); // new AntiFlyThread(); // new AntiWaterWalkThread(); // } // // private void initConfig() { // Config c = new Config(this.getDataFolder() + "/config.yml", Config.YAML); // masterConfig = new MasterConfig(c.getRootSection()); // if (masterConfig.isEmpty()) { // this.getLogger().warning("The Config is empty!"); // } // playerCheatRecord = new PlayerCheatRecord(new Config(this.getDataFolder() + "/record.yml", Config.YAML).getRootSection()); // } // // @Override // public void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType) { // playerCheatRecord.addRecord(player, cheatType); // } // // @Override // public MasterConfig getMasterConfig() { // return masterConfig; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // Path: src/main/java/top/dreamcity/AntiCheat/Config/MasterConfig.java import cn.nukkit.utils.Config; import cn.nukkit.utils.ConfigSection; import top.dreamcity.AntiCheat.AntiCheat; import top.dreamcity.AntiCheat.AntiCheatAPI; import java.util.ArrayList; maxMoveSpeed = (float) config.getDouble("maxMoveSpeed"); pingNoCheckValue = config.getInt("pingNoCheckValue"); inAirTimeCheck = config.getInt("inAirTimeCheck"); chatSec = config.getInt("chatSec"); checkKillAuraCPS = config.getInt("checkKillAuraCPS"); SensitiveWords = (ArrayList) config.get("SensitiveWords"); SkinPath = config.getString("RobotSkinPath"); } else { spawnDefaultConfig(); } } public void spawnDefaultConfig() { AntiCheat.getInstance().getLogger().notice("Start spawning default config."); antiSpeed = true; checkBB = true; antiFly = true; checkChat = true; checkChatWord = true; antiKillAura = true; antiAutoAim = true; antiSpeedPingCheck = true; maxMoveSpeed = 10F; pingNoCheckValue = 25; inAirTimeCheck = 5; chatSec = 2; checkKillAuraCPS = 3; SensitiveWords = new ArrayList<>(); SensitiveWords.add("fuck"); SensitiveWords.add("shit");
SkinPath = AntiCheatAPI.getInstance().getDataFolder() + "/Steve.png";
WetABQ/Nukkit-AntiCheat
src/main/java/top/dreamcity/AntiCheat/Cheat/chat/CheckWords.java
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/PlayerCheating.java // public class PlayerCheating extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public PlayerCheating(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // }
import cn.nukkit.Player; import cn.nukkit.Server; import top.dreamcity.AntiCheat.AntiCheatAPI; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import top.dreamcity.AntiCheat.Event.PlayerCheating; import java.util.ArrayList;
package top.dreamcity.AntiCheat.Cheat.chat; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class CheckWords extends Chat { public CheckWords(Player player, String message) { super(player, message); } @Override public CheatType getCheatType() { return CheatType.SENSITIVE_WORDS; } @Override public boolean isCheat() {
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/PlayerCheating.java // public class PlayerCheating extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public PlayerCheating(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/chat/CheckWords.java import cn.nukkit.Player; import cn.nukkit.Server; import top.dreamcity.AntiCheat.AntiCheatAPI; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import top.dreamcity.AntiCheat.Event.PlayerCheating; import java.util.ArrayList; package top.dreamcity.AntiCheat.Cheat.chat; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class CheckWords extends Chat { public CheckWords(Player player, String message) { super(player, message); } @Override public CheatType getCheatType() { return CheatType.SENSITIVE_WORDS; } @Override public boolean isCheat() {
CheckCheatEvent event = new CheckCheatEvent(player, getCheatType());
WetABQ/Nukkit-AntiCheat
src/main/java/top/dreamcity/AntiCheat/Cheat/chat/CheckWords.java
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/PlayerCheating.java // public class PlayerCheating extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public PlayerCheating(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // }
import cn.nukkit.Player; import cn.nukkit.Server; import top.dreamcity.AntiCheat.AntiCheatAPI; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import top.dreamcity.AntiCheat.Event.PlayerCheating; import java.util.ArrayList;
package top.dreamcity.AntiCheat.Cheat.chat; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class CheckWords extends Chat { public CheckWords(Player player, String message) { super(player, message); } @Override public CheatType getCheatType() { return CheatType.SENSITIVE_WORDS; } @Override public boolean isCheat() { CheckCheatEvent event = new CheckCheatEvent(player, getCheatType()); Server.getInstance().getPluginManager().callEvent(event); if (event.isCancelled()) return false;
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/PlayerCheating.java // public class PlayerCheating extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public PlayerCheating(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/chat/CheckWords.java import cn.nukkit.Player; import cn.nukkit.Server; import top.dreamcity.AntiCheat.AntiCheatAPI; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import top.dreamcity.AntiCheat.Event.PlayerCheating; import java.util.ArrayList; package top.dreamcity.AntiCheat.Cheat.chat; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class CheckWords extends Chat { public CheckWords(Player player, String message) { super(player, message); } @Override public CheatType getCheatType() { return CheatType.SENSITIVE_WORDS; } @Override public boolean isCheat() { CheckCheatEvent event = new CheckCheatEvent(player, getCheatType()); Server.getInstance().getPluginManager().callEvent(event); if (event.isCancelled()) return false;
ArrayList<String> list = AntiCheatAPI.getInstance().getMasterConfig().getSensitiveWords();
WetABQ/Nukkit-AntiCheat
src/main/java/top/dreamcity/AntiCheat/Cheat/chat/CheckWords.java
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/PlayerCheating.java // public class PlayerCheating extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public PlayerCheating(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // }
import cn.nukkit.Player; import cn.nukkit.Server; import top.dreamcity.AntiCheat.AntiCheatAPI; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import top.dreamcity.AntiCheat.Event.PlayerCheating; import java.util.ArrayList;
package top.dreamcity.AntiCheat.Cheat.chat; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class CheckWords extends Chat { public CheckWords(Player player, String message) { super(player, message); } @Override public CheatType getCheatType() { return CheatType.SENSITIVE_WORDS; } @Override public boolean isCheat() { CheckCheatEvent event = new CheckCheatEvent(player, getCheatType()); Server.getInstance().getPluginManager().callEvent(event); if (event.isCancelled()) return false; ArrayList<String> list = AntiCheatAPI.getInstance().getMasterConfig().getSensitiveWords(); for (String sw : list) { if (message.contains(sw)) {
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/PlayerCheating.java // public class PlayerCheating extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public PlayerCheating(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/chat/CheckWords.java import cn.nukkit.Player; import cn.nukkit.Server; import top.dreamcity.AntiCheat.AntiCheatAPI; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import top.dreamcity.AntiCheat.Event.PlayerCheating; import java.util.ArrayList; package top.dreamcity.AntiCheat.Cheat.chat; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class CheckWords extends Chat { public CheckWords(Player player, String message) { super(player, message); } @Override public CheatType getCheatType() { return CheatType.SENSITIVE_WORDS; } @Override public boolean isCheat() { CheckCheatEvent event = new CheckCheatEvent(player, getCheatType()); Server.getInstance().getPluginManager().callEvent(event); if (event.isCancelled()) return false; ArrayList<String> list = AntiCheatAPI.getInstance().getMasterConfig().getSensitiveWords(); for (String sw : list) { if (message.contains(sw)) {
PlayerCheating event2 = new PlayerCheating(player, getCheatType());
WetABQ/Nukkit-AntiCheat
src/main/java/top/dreamcity/AntiCheat/Cheat/move/AntiFlyThread.java
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // }
import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.scheduler.AsyncTask; import top.dreamcity.AntiCheat.AntiCheatAPI; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.UUID;
package top.dreamcity.AntiCheat.Cheat.move; /** * Copyright © 2016 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/11/17. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class AntiFlyThread extends AsyncTask { private HashSet<String> playerThread = new HashSet<>(); //private HashMap<String,Integer> Flycount = new HashMap<>(); public AntiFlyThread() {
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/move/AntiFlyThread.java import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.scheduler.AsyncTask; import top.dreamcity.AntiCheat.AntiCheatAPI; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.UUID; package top.dreamcity.AntiCheat.Cheat.move; /** * Copyright © 2016 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/11/17. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class AntiFlyThread extends AsyncTask { private HashSet<String> playerThread = new HashSet<>(); //private HashMap<String,Integer> Flycount = new HashMap<>(); public AntiFlyThread() {
Server.getInstance().getScheduler().scheduleAsyncTask(AntiCheatAPI.getInstance(), this);
WetABQ/Nukkit-AntiCheat
src/main/java/top/dreamcity/AntiCheat/Cheat/chat/CheckChat.java
// Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/PlayerCheating.java // public class PlayerCheating extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public PlayerCheating(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // }
import cn.nukkit.Player; import cn.nukkit.Server; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import top.dreamcity.AntiCheat.Event.PlayerCheating;
package top.dreamcity.AntiCheat.Cheat.chat; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class CheckChat extends Chat { public CheckChat(Player player, String message) { super(player, message); } @Override public CheatType getCheatType() { return CheatType.FAST_CHAT; } @Override public boolean isCheat() {
// Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/PlayerCheating.java // public class PlayerCheating extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public PlayerCheating(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/chat/CheckChat.java import cn.nukkit.Player; import cn.nukkit.Server; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import top.dreamcity.AntiCheat.Event.PlayerCheating; package top.dreamcity.AntiCheat.Cheat.chat; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class CheckChat extends Chat { public CheckChat(Player player, String message) { super(player, message); } @Override public CheatType getCheatType() { return CheatType.FAST_CHAT; } @Override public boolean isCheat() {
CheckCheatEvent event = new CheckCheatEvent(player, getCheatType());
WetABQ/Nukkit-AntiCheat
src/main/java/top/dreamcity/AntiCheat/Cheat/chat/CheckChat.java
// Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/PlayerCheating.java // public class PlayerCheating extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public PlayerCheating(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // }
import cn.nukkit.Player; import cn.nukkit.Server; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import top.dreamcity.AntiCheat.Event.PlayerCheating;
package top.dreamcity.AntiCheat.Cheat.chat; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class CheckChat extends Chat { public CheckChat(Player player, String message) { super(player, message); } @Override public CheatType getCheatType() { return CheatType.FAST_CHAT; } @Override public boolean isCheat() { CheckCheatEvent event = new CheckCheatEvent(player, getCheatType()); Server.getInstance().getPluginManager().callEvent(event); if (event.isCancelled()) return false; if (CheckChatThread.hasPlayer(player.getName())) {
// Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/PlayerCheating.java // public class PlayerCheating extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public PlayerCheating(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/chat/CheckChat.java import cn.nukkit.Player; import cn.nukkit.Server; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import top.dreamcity.AntiCheat.Event.PlayerCheating; package top.dreamcity.AntiCheat.Cheat.chat; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class CheckChat extends Chat { public CheckChat(Player player, String message) { super(player, message); } @Override public CheatType getCheatType() { return CheatType.FAST_CHAT; } @Override public boolean isCheat() { CheckCheatEvent event = new CheckCheatEvent(player, getCheatType()); Server.getInstance().getPluginManager().callEvent(event); if (event.isCancelled()) return false; if (CheckChatThread.hasPlayer(player.getName())) {
PlayerCheating event2 = new PlayerCheating(player, getCheatType());
WetABQ/Nukkit-AntiCheat
src/main/java/top/dreamcity/AntiCheat/Cheat/combat/AntiAutoAim.java
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // }
import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.level.Location; import cn.nukkit.level.Position; import top.dreamcity.AntiCheat.AntiCheatAPI; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException;
package top.dreamcity.AntiCheat.Cheat.combat; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class AntiAutoAim extends Combat { public AntiAutoAim(Player player) { super(player); addDummy(); } private NPC npc; @Override public CheatType getCheatType() { return CheatType.AUTO_AIM; } @Override public boolean isCheat() {
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/combat/AntiAutoAim.java import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.level.Location; import cn.nukkit.level.Position; import top.dreamcity.AntiCheat.AntiCheatAPI; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; package top.dreamcity.AntiCheat.Cheat.combat; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class AntiAutoAim extends Combat { public AntiAutoAim(Player player) { super(player); addDummy(); } private NPC npc; @Override public CheatType getCheatType() { return CheatType.AUTO_AIM; } @Override public boolean isCheat() {
CheckCheatEvent event = new CheckCheatEvent(player, getCheatType());
WetABQ/Nukkit-AntiCheat
src/main/java/top/dreamcity/AntiCheat/Cheat/combat/AntiAutoAim.java
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // }
import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.level.Location; import cn.nukkit.level.Position; import top.dreamcity.AntiCheat.AntiCheatAPI; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException;
package top.dreamcity.AntiCheat.Cheat.combat; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class AntiAutoAim extends Combat { public AntiAutoAim(Player player) { super(player); addDummy(); } private NPC npc; @Override public CheatType getCheatType() { return CheatType.AUTO_AIM; } @Override public boolean isCheat() { CheckCheatEvent event = new CheckCheatEvent(player, getCheatType()); Server.getInstance().getPluginManager().callEvent(event); if (event.isCancelled()) return false; addDummy(); return false; } private void addDummy() { /*ddPlayerPacket pk = new AddPlayerPacket(); eid = pk.entityRuntimeId = pk.entityUniqueId = Entity.entityCount++; pk.item = Item.get(Item.BOW); pk.speedX = pk.speedY = pk.speedZ = 0; pk.pitch = pk.yaw = 90; pk.metadata = new EntityMetadata().put(new FloatEntityData(39, 0.1F)); pk.x = (float) player.getX(); pk.y = (float) player.getY() + 1.5F; pk.z = (float) player.getZ(); AddPlayerPacket pk1 = ((AddPlayerPacket) (pk.clone())); AddPlayerPacket pk2 = ((AddPlayerPacket) (pk.clone())); AddPlayerPacket pk3 = ((AddPlayerPacket) (pk.clone())); AddPlayerPacket pk4 = ((AddPlayerPacket) (pk.clone())); pk1.x++; pk2.x--; pk3.z++; pk4.z--; player.dataPacket(pk1); player.dataPacket(pk2); player.dataPacket(pk3); player.dataPacket(pk4);*/
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/combat/AntiAutoAim.java import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.level.Location; import cn.nukkit.level.Position; import top.dreamcity.AntiCheat.AntiCheatAPI; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; package top.dreamcity.AntiCheat.Cheat.combat; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class AntiAutoAim extends Combat { public AntiAutoAim(Player player) { super(player); addDummy(); } private NPC npc; @Override public CheatType getCheatType() { return CheatType.AUTO_AIM; } @Override public boolean isCheat() { CheckCheatEvent event = new CheckCheatEvent(player, getCheatType()); Server.getInstance().getPluginManager().callEvent(event); if (event.isCancelled()) return false; addDummy(); return false; } private void addDummy() { /*ddPlayerPacket pk = new AddPlayerPacket(); eid = pk.entityRuntimeId = pk.entityUniqueId = Entity.entityCount++; pk.item = Item.get(Item.BOW); pk.speedX = pk.speedY = pk.speedZ = 0; pk.pitch = pk.yaw = 90; pk.metadata = new EntityMetadata().put(new FloatEntityData(39, 0.1F)); pk.x = (float) player.getX(); pk.y = (float) player.getY() + 1.5F; pk.z = (float) player.getZ(); AddPlayerPacket pk1 = ((AddPlayerPacket) (pk.clone())); AddPlayerPacket pk2 = ((AddPlayerPacket) (pk.clone())); AddPlayerPacket pk3 = ((AddPlayerPacket) (pk.clone())); AddPlayerPacket pk4 = ((AddPlayerPacket) (pk.clone())); pk1.x++; pk2.x--; pk3.z++; pk4.z--; player.dataPacket(pk1); player.dataPacket(pk2); player.dataPacket(pk3); player.dataPacket(pk4);*/
byte[] skin = image(AntiCheatAPI.getInstance().getMasterConfig().getSkinPath());
WetABQ/Nukkit-AntiCheat
src/main/java/top/dreamcity/AntiCheat/Cheat/move/ReportSpeedThread.java
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/Report.java // public class Report extends AsyncTask { // protected Player player; // // public Report(Player player) { // this.player = player; // } // // public void onRun() { // // } // } // // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/Study/Study.java // public class Study { // public final static String API_ADDRESS_SPEED = "http://14.29.54.37:88/AntiCheat/SpeedCheat.php"; // // public static void SpeedStudy(double maxSpeed, double avgSpeed, boolean isCheat) { // sendGet(API_ADDRESS_SPEED, "maxspeed=" + maxSpeed + "&averageSpeed=" + avgSpeed + "&isCheating=" + isCheat); // } // // public static boolean SpeedPredict(double maxSpeed, double avgSpeed) { // try { // Gson gson = new Gson(); // Map<?, ?> json = gson.fromJson(sendGet(API_ADDRESS_SPEED, "maxspeed=" + maxSpeed + "&averageSpeed=" + avgSpeed), Map.class); // return json.get("isCheating").toString().equals("true"); // } catch (Exception e) { // Server.getInstance().getLogger().error("AntiCheat-MLSystem >> Error to predict speed cheat."); // return false; // } // } // // private static String sendGet(String url, String param) { // String result = ""; // BufferedReader in = null; // try { // String urlNameString = url + "?" + param; // URL realUrl = new URL(urlNameString); // URLConnection connection = realUrl.openConnection(); // connection.setRequestProperty("accept", "*/*"); // connection.setRequestProperty("connection", "Keep-Alive"); // connection.setRequestProperty("user-agent", // "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); // connection.connect(); // in = new BufferedReader(new InputStreamReader( // connection.getInputStream())); // String line; // while ((line = in.readLine()) != null) { // result += line; // } // } catch (Exception e) { // System.out.println("Send get error" + e); // e.printStackTrace(); // } finally { // try { // if (in != null) { // in.close(); // } // } catch (Exception e2) { // e2.printStackTrace(); // } // } // return result; // } // // }
import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.math.Vector3; import cn.nukkit.utils.TextFormat; import top.dreamcity.AntiCheat.AntiCheatAPI; import top.dreamcity.AntiCheat.Cheat.Report; import top.dreamcity.AntiCheat.Cheat.Study.Study; import java.util.ArrayList; import java.util.Collections;
package top.dreamcity.AntiCheat.Cheat.move; /** * Copyright © 2016 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/11/17. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class ReportSpeedThread extends Report implements Runnable { public ReportSpeedThread(Player player) { super(player);
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/Report.java // public class Report extends AsyncTask { // protected Player player; // // public Report(Player player) { // this.player = player; // } // // public void onRun() { // // } // } // // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/Study/Study.java // public class Study { // public final static String API_ADDRESS_SPEED = "http://14.29.54.37:88/AntiCheat/SpeedCheat.php"; // // public static void SpeedStudy(double maxSpeed, double avgSpeed, boolean isCheat) { // sendGet(API_ADDRESS_SPEED, "maxspeed=" + maxSpeed + "&averageSpeed=" + avgSpeed + "&isCheating=" + isCheat); // } // // public static boolean SpeedPredict(double maxSpeed, double avgSpeed) { // try { // Gson gson = new Gson(); // Map<?, ?> json = gson.fromJson(sendGet(API_ADDRESS_SPEED, "maxspeed=" + maxSpeed + "&averageSpeed=" + avgSpeed), Map.class); // return json.get("isCheating").toString().equals("true"); // } catch (Exception e) { // Server.getInstance().getLogger().error("AntiCheat-MLSystem >> Error to predict speed cheat."); // return false; // } // } // // private static String sendGet(String url, String param) { // String result = ""; // BufferedReader in = null; // try { // String urlNameString = url + "?" + param; // URL realUrl = new URL(urlNameString); // URLConnection connection = realUrl.openConnection(); // connection.setRequestProperty("accept", "*/*"); // connection.setRequestProperty("connection", "Keep-Alive"); // connection.setRequestProperty("user-agent", // "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); // connection.connect(); // in = new BufferedReader(new InputStreamReader( // connection.getInputStream())); // String line; // while ((line = in.readLine()) != null) { // result += line; // } // } catch (Exception e) { // System.out.println("Send get error" + e); // e.printStackTrace(); // } finally { // try { // if (in != null) { // in.close(); // } // } catch (Exception e2) { // e2.printStackTrace(); // } // } // return result; // } // // } // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/move/ReportSpeedThread.java import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.math.Vector3; import cn.nukkit.utils.TextFormat; import top.dreamcity.AntiCheat.AntiCheatAPI; import top.dreamcity.AntiCheat.Cheat.Report; import top.dreamcity.AntiCheat.Cheat.Study.Study; import java.util.ArrayList; import java.util.Collections; package top.dreamcity.AntiCheat.Cheat.move; /** * Copyright © 2016 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/11/17. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class ReportSpeedThread extends Report implements Runnable { public ReportSpeedThread(Player player) { super(player);
Server.getInstance().getScheduler().scheduleAsyncTask(AntiCheatAPI.getInstance(), this);
WetABQ/Nukkit-AntiCheat
src/main/java/top/dreamcity/AntiCheat/Cheat/move/ReportSpeedThread.java
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/Report.java // public class Report extends AsyncTask { // protected Player player; // // public Report(Player player) { // this.player = player; // } // // public void onRun() { // // } // } // // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/Study/Study.java // public class Study { // public final static String API_ADDRESS_SPEED = "http://14.29.54.37:88/AntiCheat/SpeedCheat.php"; // // public static void SpeedStudy(double maxSpeed, double avgSpeed, boolean isCheat) { // sendGet(API_ADDRESS_SPEED, "maxspeed=" + maxSpeed + "&averageSpeed=" + avgSpeed + "&isCheating=" + isCheat); // } // // public static boolean SpeedPredict(double maxSpeed, double avgSpeed) { // try { // Gson gson = new Gson(); // Map<?, ?> json = gson.fromJson(sendGet(API_ADDRESS_SPEED, "maxspeed=" + maxSpeed + "&averageSpeed=" + avgSpeed), Map.class); // return json.get("isCheating").toString().equals("true"); // } catch (Exception e) { // Server.getInstance().getLogger().error("AntiCheat-MLSystem >> Error to predict speed cheat."); // return false; // } // } // // private static String sendGet(String url, String param) { // String result = ""; // BufferedReader in = null; // try { // String urlNameString = url + "?" + param; // URL realUrl = new URL(urlNameString); // URLConnection connection = realUrl.openConnection(); // connection.setRequestProperty("accept", "*/*"); // connection.setRequestProperty("connection", "Keep-Alive"); // connection.setRequestProperty("user-agent", // "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); // connection.connect(); // in = new BufferedReader(new InputStreamReader( // connection.getInputStream())); // String line; // while ((line = in.readLine()) != null) { // result += line; // } // } catch (Exception e) { // System.out.println("Send get error" + e); // e.printStackTrace(); // } finally { // try { // if (in != null) { // in.close(); // } // } catch (Exception e2) { // e2.printStackTrace(); // } // } // return result; // } // // }
import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.math.Vector3; import cn.nukkit.utils.TextFormat; import top.dreamcity.AntiCheat.AntiCheatAPI; import top.dreamcity.AntiCheat.Cheat.Report; import top.dreamcity.AntiCheat.Cheat.Study.Study; import java.util.ArrayList; import java.util.Collections;
if (move >= m || move2 >= m) { if (move >= m && move2 >= m) { flag = true; } if (!flag) { if (Math.abs(move2 - move) >= m - Math.min(move, move2)) { flag = true; } } } } if (flag) { player.kick(TextFormat.AQUA + "Cheat Type: " + TextFormat.RED + "Speed"); } } Thread.sleep(1000); } ArrayList<Double> speedList = new ArrayList<>(); for (int i = 0; i < 10 && player.isOnline(); i++) { speedList.add((double) AntiSpeedThread.getMove(player.getName())); Thread.sleep(1000); } if (player.isOnline()) { double maxSpeed = Collections.max(speedList); double allSpeed = 0; for (double speed : speedList) { allSpeed = allSpeed + speed; } double avgSpeed = allSpeed / (double) speedList.size();
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/Report.java // public class Report extends AsyncTask { // protected Player player; // // public Report(Player player) { // this.player = player; // } // // public void onRun() { // // } // } // // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/Study/Study.java // public class Study { // public final static String API_ADDRESS_SPEED = "http://14.29.54.37:88/AntiCheat/SpeedCheat.php"; // // public static void SpeedStudy(double maxSpeed, double avgSpeed, boolean isCheat) { // sendGet(API_ADDRESS_SPEED, "maxspeed=" + maxSpeed + "&averageSpeed=" + avgSpeed + "&isCheating=" + isCheat); // } // // public static boolean SpeedPredict(double maxSpeed, double avgSpeed) { // try { // Gson gson = new Gson(); // Map<?, ?> json = gson.fromJson(sendGet(API_ADDRESS_SPEED, "maxspeed=" + maxSpeed + "&averageSpeed=" + avgSpeed), Map.class); // return json.get("isCheating").toString().equals("true"); // } catch (Exception e) { // Server.getInstance().getLogger().error("AntiCheat-MLSystem >> Error to predict speed cheat."); // return false; // } // } // // private static String sendGet(String url, String param) { // String result = ""; // BufferedReader in = null; // try { // String urlNameString = url + "?" + param; // URL realUrl = new URL(urlNameString); // URLConnection connection = realUrl.openConnection(); // connection.setRequestProperty("accept", "*/*"); // connection.setRequestProperty("connection", "Keep-Alive"); // connection.setRequestProperty("user-agent", // "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); // connection.connect(); // in = new BufferedReader(new InputStreamReader( // connection.getInputStream())); // String line; // while ((line = in.readLine()) != null) { // result += line; // } // } catch (Exception e) { // System.out.println("Send get error" + e); // e.printStackTrace(); // } finally { // try { // if (in != null) { // in.close(); // } // } catch (Exception e2) { // e2.printStackTrace(); // } // } // return result; // } // // } // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/move/ReportSpeedThread.java import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.math.Vector3; import cn.nukkit.utils.TextFormat; import top.dreamcity.AntiCheat.AntiCheatAPI; import top.dreamcity.AntiCheat.Cheat.Report; import top.dreamcity.AntiCheat.Cheat.Study.Study; import java.util.ArrayList; import java.util.Collections; if (move >= m || move2 >= m) { if (move >= m && move2 >= m) { flag = true; } if (!flag) { if (Math.abs(move2 - move) >= m - Math.min(move, move2)) { flag = true; } } } } if (flag) { player.kick(TextFormat.AQUA + "Cheat Type: " + TextFormat.RED + "Speed"); } } Thread.sleep(1000); } ArrayList<Double> speedList = new ArrayList<>(); for (int i = 0; i < 10 && player.isOnline(); i++) { speedList.add((double) AntiSpeedThread.getMove(player.getName())); Thread.sleep(1000); } if (player.isOnline()) { double maxSpeed = Collections.max(speedList); double allSpeed = 0; for (double speed : speedList) { allSpeed = allSpeed + speed; } double avgSpeed = allSpeed / (double) speedList.size();
boolean isCheating = Study.SpeedPredict(maxSpeed, avgSpeed);
WetABQ/Nukkit-AntiCheat
src/main/java/top/dreamcity/AntiCheat/Cheat/move/CheckBB.java
// Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/PlayerCheating.java // public class PlayerCheating extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public PlayerCheating(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // }
import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.block.Block; import cn.nukkit.math.AxisAlignedBB; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import top.dreamcity.AntiCheat.Event.PlayerCheating;
package top.dreamcity.AntiCheat.Cheat.move; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class CheckBB extends Move { public CheckBB(Player player) { super(player); } @Override public CheatType getCheatType() { return CheatType.BOUNDING_BOX; } @Override public boolean isCheat() {
// Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/PlayerCheating.java // public class PlayerCheating extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public PlayerCheating(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/move/CheckBB.java import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.block.Block; import cn.nukkit.math.AxisAlignedBB; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import top.dreamcity.AntiCheat.Event.PlayerCheating; package top.dreamcity.AntiCheat.Cheat.move; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class CheckBB extends Move { public CheckBB(Player player) { super(player); } @Override public CheatType getCheatType() { return CheatType.BOUNDING_BOX; } @Override public boolean isCheat() {
CheckCheatEvent event = new CheckCheatEvent(player, getCheatType());
WetABQ/Nukkit-AntiCheat
src/main/java/top/dreamcity/AntiCheat/Cheat/move/CheckBB.java
// Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/PlayerCheating.java // public class PlayerCheating extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public PlayerCheating(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // }
import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.block.Block; import cn.nukkit.math.AxisAlignedBB; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import top.dreamcity.AntiCheat.Event.PlayerCheating;
package top.dreamcity.AntiCheat.Cheat.move; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class CheckBB extends Move { public CheckBB(Player player) { super(player); } @Override public CheatType getCheatType() { return CheatType.BOUNDING_BOX; } @Override public boolean isCheat() { CheckCheatEvent event = new CheckCheatEvent(player, getCheatType()); Server.getInstance().getPluginManager().callEvent(event); if (player.getGamemode() != 0) event.setCancelled(); if (event.isCancelled()) return false; double radius = (double) player.getWidth() / 2.0D; AxisAlignedBB bb = player.getBoundingBox().clone().setBounds( player.x - radius + 0.3D, player.y + 1.1D, player.z - radius + 0.3D, player.x + radius - 0.3D, player.y + (double) (player.getHeight() * player.scale) - 0.1D, player.z + radius - 0.3D ); for (Block block : player.getBlocksAround()) { if (block.collidesWithBB(bb) && !block.canPassThrough() && block.getId() != Block.LADDER) {
// Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/PlayerCheating.java // public class PlayerCheating extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public PlayerCheating(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/move/CheckBB.java import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.block.Block; import cn.nukkit.math.AxisAlignedBB; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import top.dreamcity.AntiCheat.Event.PlayerCheating; package top.dreamcity.AntiCheat.Cheat.move; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class CheckBB extends Move { public CheckBB(Player player) { super(player); } @Override public CheatType getCheatType() { return CheatType.BOUNDING_BOX; } @Override public boolean isCheat() { CheckCheatEvent event = new CheckCheatEvent(player, getCheatType()); Server.getInstance().getPluginManager().callEvent(event); if (player.getGamemode() != 0) event.setCancelled(); if (event.isCancelled()) return false; double radius = (double) player.getWidth() / 2.0D; AxisAlignedBB bb = player.getBoundingBox().clone().setBounds( player.x - radius + 0.3D, player.y + 1.1D, player.z - radius + 0.3D, player.x + radius - 0.3D, player.y + (double) (player.getHeight() * player.scale) - 0.1D, player.z + radius - 0.3D ); for (Block block : player.getBlocksAround()) { if (block.collidesWithBB(bb) && !block.canPassThrough() && block.getId() != Block.LADDER) {
PlayerCheating event2 = new PlayerCheating(player, getCheatType());
WetABQ/Nukkit-AntiCheat
src/main/java/top/dreamcity/AntiCheat/Cheat/move/AntiWaterWalkPlayerThread.java
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // }
import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.block.Block; import cn.nukkit.math.Vector3; import cn.nukkit.scheduler.AsyncTask; import top.dreamcity.AntiCheat.AntiCheatAPI;
package top.dreamcity.AntiCheat.Cheat.move; /** * Copyright © 2016 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/12/9. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class AntiWaterWalkPlayerThread extends AsyncTask { private Player player; private boolean onGround; public AntiWaterWalkPlayerThread(Player player, boolean onGround) { this.player = player; this.onGround = onGround;
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/move/AntiWaterWalkPlayerThread.java import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.block.Block; import cn.nukkit.math.Vector3; import cn.nukkit.scheduler.AsyncTask; import top.dreamcity.AntiCheat.AntiCheatAPI; package top.dreamcity.AntiCheat.Cheat.move; /** * Copyright © 2016 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/12/9. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class AntiWaterWalkPlayerThread extends AsyncTask { private Player player; private boolean onGround; public AntiWaterWalkPlayerThread(Player player, boolean onGround) { this.player = player; this.onGround = onGround;
Server.getInstance().getScheduler().scheduleAsyncTask(AntiCheatAPI.getInstance(), this);
WetABQ/Nukkit-AntiCheat
src/main/java/top/dreamcity/AntiCheat/Cheat/move/AntiWaterWalkThread.java
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // }
import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.scheduler.AsyncTask; import top.dreamcity.AntiCheat.AntiCheatAPI; import java.util.HashMap; import java.util.Map; import java.util.UUID;
package top.dreamcity.AntiCheat.Cheat.move; /** * Copyright © 2016 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/12/6. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class AntiWaterWalkThread extends AsyncTask { public AntiWaterWalkThread() {
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/move/AntiWaterWalkThread.java import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.scheduler.AsyncTask; import top.dreamcity.AntiCheat.AntiCheatAPI; import java.util.HashMap; import java.util.Map; import java.util.UUID; package top.dreamcity.AntiCheat.Cheat.move; /** * Copyright © 2016 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/12/6. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class AntiWaterWalkThread extends AsyncTask { public AntiWaterWalkThread() {
Server.getInstance().getScheduler().scheduleAsyncTask(AntiCheatAPI.getInstance(), this);
WetABQ/Nukkit-AntiCheat
src/main/java/top/dreamcity/AntiCheat/Cheat/chat/CheckChatThread.java
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // }
import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.scheduler.AsyncTask; import top.dreamcity.AntiCheat.AntiCheatAPI; import java.util.HashMap;
package top.dreamcity.AntiCheat.Cheat.chat; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class CheckChatThread extends AsyncTask { private static HashMap<String, Integer> playerChat = new HashMap<>(); public CheckChatThread() {
// Path: src/main/java/top/dreamcity/AntiCheat/AntiCheatAPI.java // public interface AntiCheatAPI { // // static AntiCheat getInstance() { // return AntiCheat.getInstance(); // } // // MasterConfig getMasterConfig(); // // void addRecord(Player player, top.dreamcity.AntiCheat.Cheat.AntiCheat.CheatType cheatType); // // } // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/chat/CheckChatThread.java import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.scheduler.AsyncTask; import top.dreamcity.AntiCheat.AntiCheatAPI; import java.util.HashMap; package top.dreamcity.AntiCheat.Cheat.chat; /** * Copyright © 2017 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/10/8. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class CheckChatThread extends AsyncTask { private static HashMap<String, Integer> playerChat = new HashMap<>(); public CheckChatThread() {
Server.getInstance().getScheduler().scheduleAsyncTask(AntiCheatAPI.getInstance(), this);
WetABQ/Nukkit-AntiCheat
src/main/java/top/dreamcity/AntiCheat/Cheat/combat/Reach.java
// Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/PlayerCheating.java // public class PlayerCheating extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public PlayerCheating(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // }
import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.block.Block; import cn.nukkit.entity.Entity; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import top.dreamcity.AntiCheat.Event.PlayerCheating;
package top.dreamcity.AntiCheat.Cheat.combat; /** * Copyright © 2016 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/12/4. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class Reach extends Combat { public Block block = null; public Entity entity = null; public Reach(Player player, Block block) { super(player); this.block = block; } public Reach(Player player, Entity entity) { super(player); this.entity = entity; } @Override public CheatType getCheatType() { return CheatType.REACH; } @Override public boolean isCheat() {
// Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/PlayerCheating.java // public class PlayerCheating extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public PlayerCheating(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/combat/Reach.java import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.block.Block; import cn.nukkit.entity.Entity; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import top.dreamcity.AntiCheat.Event.PlayerCheating; package top.dreamcity.AntiCheat.Cheat.combat; /** * Copyright © 2016 WetABQ&DreamCityAdminGroup All right reserved. * Welcome to DreamCity Server Address:dreamcity.top:19132 * Created by WetABQ(Administrator) on 2017/12/4. * ||| || |||| || |||||||| ||||||| * ||| ||| ||| || || | ||| || ||| ||| * ||| ||| || |||||| |||||||| || || || |||| ||| || * || ||||| || ||| || |||| ||| ||||| |||||||| | || * || || || || || || | |||||||| || || ||| || || * |||| |||| || || || || ||| ||| |||| ||| |||||||| * || ||| ||||||| ||||| ||| |||| |||||||| ||||| | * |||| */ public class Reach extends Combat { public Block block = null; public Entity entity = null; public Reach(Player player, Block block) { super(player); this.block = block; } public Reach(Player player, Entity entity) { super(player); this.entity = entity; } @Override public CheatType getCheatType() { return CheatType.REACH; } @Override public boolean isCheat() {
CheckCheatEvent event = new CheckCheatEvent(player, getCheatType());
WetABQ/Nukkit-AntiCheat
src/main/java/top/dreamcity/AntiCheat/Cheat/combat/Reach.java
// Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/PlayerCheating.java // public class PlayerCheating extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public PlayerCheating(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // }
import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.block.Block; import cn.nukkit.entity.Entity; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import top.dreamcity.AntiCheat.Event.PlayerCheating;
public Reach(Player player, Entity entity) { super(player); this.entity = entity; } @Override public CheatType getCheatType() { return CheatType.REACH; } @Override public boolean isCheat() { CheckCheatEvent event = new CheckCheatEvent(player, getCheatType()); Server.getInstance().getPluginManager().callEvent(event); if (player.getGamemode() != 0) event.setCancelled(); if (event.isCancelled()) return false; boolean flag = false; if (entity != null) { if (entity.distance(player) >= 4) { flag = true; } } else if (block != null) { if (block.distance(player) >= 6) { flag = true; } } if (flag) {
// Path: src/main/java/top/dreamcity/AntiCheat/Event/CheckCheatEvent.java // public class CheckCheatEvent extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public CheckCheatEvent(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // // Path: src/main/java/top/dreamcity/AntiCheat/Event/PlayerCheating.java // public class PlayerCheating extends PlayerEvent implements Cancellable { // // public AntiCheat.CheatType cheatType; // // private static final HandlerList handlers = new HandlerList(); // // public static HandlerList getHandlers() { // return handlers; // } // // public PlayerCheating(Player player, AntiCheat.CheatType cheatType) { // this.player = player; // this.cheatType = cheatType; // } // // public AntiCheat.CheatType getCheatType() { // return cheatType; // } // // } // Path: src/main/java/top/dreamcity/AntiCheat/Cheat/combat/Reach.java import cn.nukkit.Player; import cn.nukkit.Server; import cn.nukkit.block.Block; import cn.nukkit.entity.Entity; import top.dreamcity.AntiCheat.Event.CheckCheatEvent; import top.dreamcity.AntiCheat.Event.PlayerCheating; public Reach(Player player, Entity entity) { super(player); this.entity = entity; } @Override public CheatType getCheatType() { return CheatType.REACH; } @Override public boolean isCheat() { CheckCheatEvent event = new CheckCheatEvent(player, getCheatType()); Server.getInstance().getPluginManager().callEvent(event); if (player.getGamemode() != 0) event.setCancelled(); if (event.isCancelled()) return false; boolean flag = false; if (entity != null) { if (entity.distance(player) >= 4) { flag = true; } } else if (block != null) { if (block.distance(player) >= 6) { flag = true; } } if (flag) {
PlayerCheating event2 = new PlayerCheating(player, getCheatType());
jesse-gallagher/frostillic.us-Blog
frostillicus-blog/frostillicus-blog-j2ee/src/main/java/security/jaxrs/DarwinoJAXRSSecurityContext.java
// Path: frostillicus-blog/frostillicus-blog-j2ee/src/main/java/security/DarwinoPrincipal.java // public class DarwinoPrincipal implements Principal { // private final User user; // // public DarwinoPrincipal(final User user) { // this.user = user; // } // // @Override // public String getName() { // return user.getDn(); // } // // }
import java.security.Principal; import javax.ws.rs.core.SecurityContext; import javax.ws.rs.core.UriInfo; import com.darwino.platform.DarwinoContext; import security.DarwinoPrincipal;
/* * Copyright © 2012-2020 Jesse Gallagher * * 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 security.jaxrs; /** * * @author Jesse Gallagher * @since 2.5.0 */ public class DarwinoJAXRSSecurityContext implements SecurityContext { private final UriInfo uriInfo; public DarwinoJAXRSSecurityContext(final UriInfo uriInfo) { this.uriInfo = uriInfo; } @Override public Principal getUserPrincipal() {
// Path: frostillicus-blog/frostillicus-blog-j2ee/src/main/java/security/DarwinoPrincipal.java // public class DarwinoPrincipal implements Principal { // private final User user; // // public DarwinoPrincipal(final User user) { // this.user = user; // } // // @Override // public String getName() { // return user.getDn(); // } // // } // Path: frostillicus-blog/frostillicus-blog-j2ee/src/main/java/security/jaxrs/DarwinoJAXRSSecurityContext.java import java.security.Principal; import javax.ws.rs.core.SecurityContext; import javax.ws.rs.core.UriInfo; import com.darwino.platform.DarwinoContext; import security.DarwinoPrincipal; /* * Copyright © 2012-2020 Jesse Gallagher * * 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 security.jaxrs; /** * * @author Jesse Gallagher * @since 2.5.0 */ public class DarwinoJAXRSSecurityContext implements SecurityContext { private final UriInfo uriInfo; public DarwinoJAXRSSecurityContext(final UriInfo uriInfo) { this.uriInfo = uriInfo; } @Override public Principal getUserPrincipal() {
return new DarwinoPrincipal(DarwinoContext.get().getUser());
jesse-gallagher/frostillic.us-Blog
frostillicus-blog/frostillicus-blog-shared/src/main/java/model/Link.java
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/util/BooleanYNConverter.java // public class BooleanYNConverter implements AttributeConverter<Boolean, String> { // // @Override // public String convertToDatabaseColumn(final Boolean attribute) { // return attribute ? "Y" : "N"; //$NON-NLS-1$ //$NON-NLS-2$ // } // // @Override // public Boolean convertToEntityAttribute(final String dbData) { // return "Y".equals(dbData); //$NON-NLS-1$ // } // // }
import javax.validation.constraints.NotEmpty; import jakarta.nosql.mapping.Column; import jakarta.nosql.mapping.Convert; import jakarta.nosql.mapping.Entity; import jakarta.nosql.mapping.Id; import lombok.Data; import lombok.NoArgsConstructor; import model.util.BooleanYNConverter;
/* * Copyright © 2012-2020 Jesse Gallagher * * 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 model; @Entity @Data @NoArgsConstructor public class Link { @Id @Column private String id; @Column private String category; @Column("link_url") @NotEmpty private String url; @Column("link_name") @NotEmpty private String name;
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/util/BooleanYNConverter.java // public class BooleanYNConverter implements AttributeConverter<Boolean, String> { // // @Override // public String convertToDatabaseColumn(final Boolean attribute) { // return attribute ? "Y" : "N"; //$NON-NLS-1$ //$NON-NLS-2$ // } // // @Override // public Boolean convertToEntityAttribute(final String dbData) { // return "Y".equals(dbData); //$NON-NLS-1$ // } // // } // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/Link.java import javax.validation.constraints.NotEmpty; import jakarta.nosql.mapping.Column; import jakarta.nosql.mapping.Convert; import jakarta.nosql.mapping.Entity; import jakarta.nosql.mapping.Id; import lombok.Data; import lombok.NoArgsConstructor; import model.util.BooleanYNConverter; /* * Copyright © 2012-2020 Jesse Gallagher * * 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 model; @Entity @Data @NoArgsConstructor public class Link { @Id @Column private String id; @Column private String category; @Column("link_url") @NotEmpty private String url; @Column("link_name") @NotEmpty private String name;
@Column("link_visible") @Convert(BooleanYNConverter.class) private boolean visible;
jesse-gallagher/frostillic.us-Blog
frostillicus-blog/frostillicus-blog-j2ee/src/main/java/security/AccessTokenIdentityStore.java
// Path: frostillicus-blog/frostillicus-blog-j2ee/src/main/java/security/AccessTokenAuthHandler.java // @AllArgsConstructor // public static class AccessTokenAuthenticator extends HttpClient.Authenticator implements Credential { // private static final long serialVersionUID = 1L; // // private final @Getter String token; // // @SneakyThrows // public String getDn() { // var session = DarwinoApplication.get().getLocalJsonDBServer().createSystemSession(null); // try { // var database = session.getDatabase(AppDatabaseDef.DATABASE_NAME); // var store = database.getStore(AppDatabaseDef.STORE_TOKENS); // var query = JsonObject.of("token", token); //$NON-NLS-1$ // var tokenDoc = store.openCursor() // .query(query) // .findOneDocument(); // return tokenDoc == null ? null : tokenDoc.getString("userName"); //$NON-NLS-1$ // } finally { // session.close(); // } // } // // @Override // public boolean isValid() { // return StringUtil.isNotEmpty(getDn()); // } // // @Override // public Map<String, String> getAuthenticationHeaders() { // if(isValid()) { // return Collections.singletonMap(HttpBase.HEADER_AUTHORIZATION, "Bearer " + token); //$NON-NLS-1$ // } // return null; // } // }
import javax.enterprise.context.ApplicationScoped; import javax.security.enterprise.credential.Credential; import javax.security.enterprise.credential.UsernamePasswordCredential; import javax.security.enterprise.identitystore.CredentialValidationResult; import javax.security.enterprise.identitystore.IdentityStore; import javax.security.enterprise.identitystore.IdentityStoreHandler; import com.darwino.commons.Platform; import com.darwino.commons.security.acl.UserException; import com.darwino.commons.security.acl.UserService; import security.AccessTokenAuthHandler.AccessTokenAuthenticator;
/* * Copyright © 2012-2020 Jesse Gallagher * * 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 security; /** * Implements the Jakarta EE security API for {@link AccessTokenAuthHandler} use. * * @author Jesse Gallagher * @since 2.3.0 */ @ApplicationScoped public class AccessTokenIdentityStore implements IdentityStore, IdentityStoreHandler { public static final String STORE_ID = AccessTokenIdentityStore.class.getName();
// Path: frostillicus-blog/frostillicus-blog-j2ee/src/main/java/security/AccessTokenAuthHandler.java // @AllArgsConstructor // public static class AccessTokenAuthenticator extends HttpClient.Authenticator implements Credential { // private static final long serialVersionUID = 1L; // // private final @Getter String token; // // @SneakyThrows // public String getDn() { // var session = DarwinoApplication.get().getLocalJsonDBServer().createSystemSession(null); // try { // var database = session.getDatabase(AppDatabaseDef.DATABASE_NAME); // var store = database.getStore(AppDatabaseDef.STORE_TOKENS); // var query = JsonObject.of("token", token); //$NON-NLS-1$ // var tokenDoc = store.openCursor() // .query(query) // .findOneDocument(); // return tokenDoc == null ? null : tokenDoc.getString("userName"); //$NON-NLS-1$ // } finally { // session.close(); // } // } // // @Override // public boolean isValid() { // return StringUtil.isNotEmpty(getDn()); // } // // @Override // public Map<String, String> getAuthenticationHeaders() { // if(isValid()) { // return Collections.singletonMap(HttpBase.HEADER_AUTHORIZATION, "Bearer " + token); //$NON-NLS-1$ // } // return null; // } // } // Path: frostillicus-blog/frostillicus-blog-j2ee/src/main/java/security/AccessTokenIdentityStore.java import javax.enterprise.context.ApplicationScoped; import javax.security.enterprise.credential.Credential; import javax.security.enterprise.credential.UsernamePasswordCredential; import javax.security.enterprise.identitystore.CredentialValidationResult; import javax.security.enterprise.identitystore.IdentityStore; import javax.security.enterprise.identitystore.IdentityStoreHandler; import com.darwino.commons.Platform; import com.darwino.commons.security.acl.UserException; import com.darwino.commons.security.acl.UserService; import security.AccessTokenAuthHandler.AccessTokenAuthenticator; /* * Copyright © 2012-2020 Jesse Gallagher * * 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 security; /** * Implements the Jakarta EE security API for {@link AccessTokenAuthHandler} use. * * @author Jesse Gallagher * @since 2.3.0 */ @ApplicationScoped public class AccessTokenIdentityStore implements IdentityStore, IdentityStoreHandler { public static final String STORE_ID = AccessTokenIdentityStore.class.getName();
public CredentialValidationResult validate(final AccessTokenAuthenticator credential) {
jesse-gallagher/frostillic.us-Blog
frostillicus-blog/frostillicus-blog-j2ee/src/main/java/security/AccessTokenAuthHandler.java
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/darwino/AppDatabaseDef.java // public class AppDatabaseDef extends DatabaseFactoryImpl { // // public static final int DATABASE_VERSION = 17; // public static final String DATABASE_NAME = "frostillicus_blog"; //$NON-NLS-1$ // public static final String STORE_POSTS = "posts"; //$NON-NLS-1$ // public static final String STORE_COMMENTS = "comments"; //$NON-NLS-1$ // public static final String STORE_CONFIG = "config"; //$NON-NLS-1$ // public static final String STORE_MEDIA = "media"; //$NON-NLS-1$ // /** @since 2.3.0 */ // public static final String STORE_MICROPOSTS = "microposts"; //$NON-NLS-1$ // /** @since 2.3.0 */ // public static final String STORE_TOKENS = "tokens"; //$NON-NLS-1$ // /** @since 2.3.0 */ // public static final String STORE_WEBMENTIONS = "webmentions"; //$NON-NLS-1$ // // // The list of instances is defined through a property for the DB // public static String[] getInstances() { // String inst = Platform.getProperty("frostillicus_blog.instances"); //$NON-NLS-1$ // if(StringUtil.isNotEmpty(inst)) { // return StringUtil.splitString(inst, ',', true); // } // return null; // } // // @Override // public int getDatabaseVersion(final String databaseName) throws JsonException { // if(!StringUtil.equalsIgnoreCase(databaseName, DATABASE_NAME)) { // return -1; // } // return DATABASE_VERSION; // } // // @Override // public _Database loadDatabase(final String databaseName) throws JsonException { // if(!StringUtil.equalsIgnoreCase(databaseName, DATABASE_NAME)) { // return null; // } // _Database db = new _Database(DATABASE_NAME, "frostillic.us Blog", DATABASE_VERSION); //$NON-NLS-1$ // db.setDocumentSecurity(Base.DOCSEC_NOTESLIKE | Base.DOCSEC_INCLUDE | Base.DOCSEC_DYNAMIC); // // _DatabaseACL acl = new _DatabaseACL(); // acl.addRole(UserInfoBean.ROLE_ADMIN, _DatabaseACL.ROLE_MANAGE); // acl.addAnonymous(_DatabaseACL.ROLE_AUTHOR); // acl.addUser("anonymous", _DatabaseACL.ROLE_READER); //$NON-NLS-1$ // db.setACL(acl); // // db.setReplicationEnabled(true); // db.setDocumentLockEnabled(false); // // db.setInstanceEnabled(false); // // { // _Store posts = db.addStore(STORE_POSTS); // posts.setFtSearchEnabled(true); // posts.setTaggingEnabled(true); // _FtSearch ft = posts.setFTSearch(new _FtSearch()); // ft.setFields("$"); //$NON-NLS-1$ // } // { // _Store comments = db.addStore(STORE_COMMENTS); // comments.setFtSearchEnabled(true); // _FtSearch ft = comments.setFTSearch(new _FtSearch()); // ft.setFields("$"); //$NON-NLS-1$ // } // db.addStore(STORE_CONFIG); // db.addStore(STORE_MEDIA); // db.addStore(STORE_MICROPOSTS); // db.addStore(STORE_TOKENS); // db.addStore(STORE_WEBMENTIONS); // // return db; // } // }
import com.darwino.platform.DarwinoApplication; import darwino.AppDatabaseDef; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.SneakyThrows; import java.io.IOException; import java.util.Collections; import java.util.Map; import javax.security.enterprise.credential.Credential; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.darwino.commons.httpclnt.HttpBase; import com.darwino.commons.httpclnt.HttpClient; import com.darwino.commons.httpclnt.HttpClient.Authenticator; import com.darwino.commons.json.JsonObject; import com.darwino.commons.util.StringUtil; import com.darwino.j2ee.servlet.authentication.handler.AbstractAuthHandler;
/* * Copyright © 2012-2020 Jesse Gallagher * * 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 security; /** * Authentication handler for the app's ad-hoc not-really-OAuth "Bearer" tokens. * * @author Jesse Gallagher * @since 2.3.0 */ public class AccessTokenAuthHandler extends AbstractAuthHandler { @AllArgsConstructor public static class AccessTokenAuthenticator extends HttpClient.Authenticator implements Credential { private static final long serialVersionUID = 1L; private final @Getter String token; @SneakyThrows public String getDn() { var session = DarwinoApplication.get().getLocalJsonDBServer().createSystemSession(null); try {
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/darwino/AppDatabaseDef.java // public class AppDatabaseDef extends DatabaseFactoryImpl { // // public static final int DATABASE_VERSION = 17; // public static final String DATABASE_NAME = "frostillicus_blog"; //$NON-NLS-1$ // public static final String STORE_POSTS = "posts"; //$NON-NLS-1$ // public static final String STORE_COMMENTS = "comments"; //$NON-NLS-1$ // public static final String STORE_CONFIG = "config"; //$NON-NLS-1$ // public static final String STORE_MEDIA = "media"; //$NON-NLS-1$ // /** @since 2.3.0 */ // public static final String STORE_MICROPOSTS = "microposts"; //$NON-NLS-1$ // /** @since 2.3.0 */ // public static final String STORE_TOKENS = "tokens"; //$NON-NLS-1$ // /** @since 2.3.0 */ // public static final String STORE_WEBMENTIONS = "webmentions"; //$NON-NLS-1$ // // // The list of instances is defined through a property for the DB // public static String[] getInstances() { // String inst = Platform.getProperty("frostillicus_blog.instances"); //$NON-NLS-1$ // if(StringUtil.isNotEmpty(inst)) { // return StringUtil.splitString(inst, ',', true); // } // return null; // } // // @Override // public int getDatabaseVersion(final String databaseName) throws JsonException { // if(!StringUtil.equalsIgnoreCase(databaseName, DATABASE_NAME)) { // return -1; // } // return DATABASE_VERSION; // } // // @Override // public _Database loadDatabase(final String databaseName) throws JsonException { // if(!StringUtil.equalsIgnoreCase(databaseName, DATABASE_NAME)) { // return null; // } // _Database db = new _Database(DATABASE_NAME, "frostillic.us Blog", DATABASE_VERSION); //$NON-NLS-1$ // db.setDocumentSecurity(Base.DOCSEC_NOTESLIKE | Base.DOCSEC_INCLUDE | Base.DOCSEC_DYNAMIC); // // _DatabaseACL acl = new _DatabaseACL(); // acl.addRole(UserInfoBean.ROLE_ADMIN, _DatabaseACL.ROLE_MANAGE); // acl.addAnonymous(_DatabaseACL.ROLE_AUTHOR); // acl.addUser("anonymous", _DatabaseACL.ROLE_READER); //$NON-NLS-1$ // db.setACL(acl); // // db.setReplicationEnabled(true); // db.setDocumentLockEnabled(false); // // db.setInstanceEnabled(false); // // { // _Store posts = db.addStore(STORE_POSTS); // posts.setFtSearchEnabled(true); // posts.setTaggingEnabled(true); // _FtSearch ft = posts.setFTSearch(new _FtSearch()); // ft.setFields("$"); //$NON-NLS-1$ // } // { // _Store comments = db.addStore(STORE_COMMENTS); // comments.setFtSearchEnabled(true); // _FtSearch ft = comments.setFTSearch(new _FtSearch()); // ft.setFields("$"); //$NON-NLS-1$ // } // db.addStore(STORE_CONFIG); // db.addStore(STORE_MEDIA); // db.addStore(STORE_MICROPOSTS); // db.addStore(STORE_TOKENS); // db.addStore(STORE_WEBMENTIONS); // // return db; // } // } // Path: frostillicus-blog/frostillicus-blog-j2ee/src/main/java/security/AccessTokenAuthHandler.java import com.darwino.platform.DarwinoApplication; import darwino.AppDatabaseDef; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.SneakyThrows; import java.io.IOException; import java.util.Collections; import java.util.Map; import javax.security.enterprise.credential.Credential; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.darwino.commons.httpclnt.HttpBase; import com.darwino.commons.httpclnt.HttpClient; import com.darwino.commons.httpclnt.HttpClient.Authenticator; import com.darwino.commons.json.JsonObject; import com.darwino.commons.util.StringUtil; import com.darwino.j2ee.servlet.authentication.handler.AbstractAuthHandler; /* * Copyright © 2012-2020 Jesse Gallagher * * 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 security; /** * Authentication handler for the app's ad-hoc not-really-OAuth "Bearer" tokens. * * @author Jesse Gallagher * @since 2.3.0 */ public class AccessTokenAuthHandler extends AbstractAuthHandler { @AllArgsConstructor public static class AccessTokenAuthenticator extends HttpClient.Authenticator implements Credential { private static final long serialVersionUID = 1L; private final @Getter String token; @SneakyThrows public String getDn() { var session = DarwinoApplication.get().getLocalJsonDBServer().createSystemSession(null); try {
var database = session.getDatabase(AppDatabaseDef.DATABASE_NAME);
jesse-gallagher/frostillic.us-Blog
frostillicus-blog/frostillicus-blog-j2ee/src/main/java/controller/AdminController.java
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/bean/UserInfoBean.java // @RequestScoped // @Named("userInfo") // public class UserInfoBean { // public static final String ROLE_ADMIN = "admin"; //$NON-NLS-1$ // // @Inject @Named("darwinoContext") // DarwinoContext context; // // @SneakyThrows // public String getImageUrl(final String userName) { // String md5 = StringUtil.md5Hex(StringUtil.toString(userName).toLowerCase()); // return StringUtil.format(DarwinoHttpConstants.SOCIAL_USERS_PATH + "/users/{0}/content/photo", URLEncoder.encode(md5, "UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$ // } // // public boolean isAdmin() { // return context.getUser().hasRole(ROLE_ADMIN); // } // // public boolean isAnonymous() { // return context.getUser().isAnonymous(); // } // // public String getCn() { // return context.getUser().getCn(); // } // // public String getDn() { // return context.getUser().getDn(); // } // // public String getEmailAddress() throws UserException { // Object mail = context.getUser().getAttribute(User.ATTR_EMAIL); // return StringUtil.toString(mail); // } // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessToken.java // @Entity @Data @NoArgsConstructor // public class AccessToken { // @Id @Column private String id; // @Column private String userName; // @Column private String name; // @Column private String token; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessTokenRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_TOKENS) // public interface AccessTokenRepository extends DarwinoRepository<AccessToken, String> { // Stream<AccessToken> findAll(); // // Optional<AccessToken> findByToken(String token); // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/Link.java // @Entity @Data @NoArgsConstructor // public class Link { // @Id @Column private String id; // @Column private String category; // @Column("link_url") @NotEmpty private String url; // @Column("link_name") @NotEmpty private String name; // @Column("link_visible") @Convert(BooleanYNConverter.class) private boolean visible; // @Column private String rel; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/LinkRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_CONFIG) // public interface LinkRepository extends DarwinoRepository<Link, String> { // Stream<Link> findAll(); // // @Query("select * from Link order by category name") // List<Link> findAllByCategoryAndName(); // }
import bean.UserInfoBean; import com.darwino.commons.json.JsonException; import com.darwino.jsonstore.Session; import model.AccessToken; import model.AccessTokenRepository; import model.Link; import model.LinkRepository; import javax.annotation.security.RolesAllowed; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.mvc.Controller; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.util.UUID;
/* * Copyright © 2012-2020 Jesse Gallagher * * 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 controller; @Controller @Path("admin")
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/bean/UserInfoBean.java // @RequestScoped // @Named("userInfo") // public class UserInfoBean { // public static final String ROLE_ADMIN = "admin"; //$NON-NLS-1$ // // @Inject @Named("darwinoContext") // DarwinoContext context; // // @SneakyThrows // public String getImageUrl(final String userName) { // String md5 = StringUtil.md5Hex(StringUtil.toString(userName).toLowerCase()); // return StringUtil.format(DarwinoHttpConstants.SOCIAL_USERS_PATH + "/users/{0}/content/photo", URLEncoder.encode(md5, "UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$ // } // // public boolean isAdmin() { // return context.getUser().hasRole(ROLE_ADMIN); // } // // public boolean isAnonymous() { // return context.getUser().isAnonymous(); // } // // public String getCn() { // return context.getUser().getCn(); // } // // public String getDn() { // return context.getUser().getDn(); // } // // public String getEmailAddress() throws UserException { // Object mail = context.getUser().getAttribute(User.ATTR_EMAIL); // return StringUtil.toString(mail); // } // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessToken.java // @Entity @Data @NoArgsConstructor // public class AccessToken { // @Id @Column private String id; // @Column private String userName; // @Column private String name; // @Column private String token; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessTokenRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_TOKENS) // public interface AccessTokenRepository extends DarwinoRepository<AccessToken, String> { // Stream<AccessToken> findAll(); // // Optional<AccessToken> findByToken(String token); // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/Link.java // @Entity @Data @NoArgsConstructor // public class Link { // @Id @Column private String id; // @Column private String category; // @Column("link_url") @NotEmpty private String url; // @Column("link_name") @NotEmpty private String name; // @Column("link_visible") @Convert(BooleanYNConverter.class) private boolean visible; // @Column private String rel; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/LinkRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_CONFIG) // public interface LinkRepository extends DarwinoRepository<Link, String> { // Stream<Link> findAll(); // // @Query("select * from Link order by category name") // List<Link> findAllByCategoryAndName(); // } // Path: frostillicus-blog/frostillicus-blog-j2ee/src/main/java/controller/AdminController.java import bean.UserInfoBean; import com.darwino.commons.json.JsonException; import com.darwino.jsonstore.Session; import model.AccessToken; import model.AccessTokenRepository; import model.Link; import model.LinkRepository; import javax.annotation.security.RolesAllowed; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.mvc.Controller; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.util.UUID; /* * Copyright © 2012-2020 Jesse Gallagher * * 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 controller; @Controller @Path("admin")
@RolesAllowed(UserInfoBean.ROLE_ADMIN)
jesse-gallagher/frostillic.us-Blog
frostillicus-blog/frostillicus-blog-j2ee/src/main/java/controller/AdminController.java
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/bean/UserInfoBean.java // @RequestScoped // @Named("userInfo") // public class UserInfoBean { // public static final String ROLE_ADMIN = "admin"; //$NON-NLS-1$ // // @Inject @Named("darwinoContext") // DarwinoContext context; // // @SneakyThrows // public String getImageUrl(final String userName) { // String md5 = StringUtil.md5Hex(StringUtil.toString(userName).toLowerCase()); // return StringUtil.format(DarwinoHttpConstants.SOCIAL_USERS_PATH + "/users/{0}/content/photo", URLEncoder.encode(md5, "UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$ // } // // public boolean isAdmin() { // return context.getUser().hasRole(ROLE_ADMIN); // } // // public boolean isAnonymous() { // return context.getUser().isAnonymous(); // } // // public String getCn() { // return context.getUser().getCn(); // } // // public String getDn() { // return context.getUser().getDn(); // } // // public String getEmailAddress() throws UserException { // Object mail = context.getUser().getAttribute(User.ATTR_EMAIL); // return StringUtil.toString(mail); // } // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessToken.java // @Entity @Data @NoArgsConstructor // public class AccessToken { // @Id @Column private String id; // @Column private String userName; // @Column private String name; // @Column private String token; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessTokenRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_TOKENS) // public interface AccessTokenRepository extends DarwinoRepository<AccessToken, String> { // Stream<AccessToken> findAll(); // // Optional<AccessToken> findByToken(String token); // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/Link.java // @Entity @Data @NoArgsConstructor // public class Link { // @Id @Column private String id; // @Column private String category; // @Column("link_url") @NotEmpty private String url; // @Column("link_name") @NotEmpty private String name; // @Column("link_visible") @Convert(BooleanYNConverter.class) private boolean visible; // @Column private String rel; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/LinkRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_CONFIG) // public interface LinkRepository extends DarwinoRepository<Link, String> { // Stream<Link> findAll(); // // @Query("select * from Link order by category name") // List<Link> findAllByCategoryAndName(); // }
import bean.UserInfoBean; import com.darwino.commons.json.JsonException; import com.darwino.jsonstore.Session; import model.AccessToken; import model.AccessTokenRepository; import model.Link; import model.LinkRepository; import javax.annotation.security.RolesAllowed; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.mvc.Controller; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.util.UUID;
/* * Copyright © 2012-2020 Jesse Gallagher * * 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 controller; @Controller @Path("admin") @RolesAllowed(UserInfoBean.ROLE_ADMIN) @RequestScoped public class AdminController { @Inject
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/bean/UserInfoBean.java // @RequestScoped // @Named("userInfo") // public class UserInfoBean { // public static final String ROLE_ADMIN = "admin"; //$NON-NLS-1$ // // @Inject @Named("darwinoContext") // DarwinoContext context; // // @SneakyThrows // public String getImageUrl(final String userName) { // String md5 = StringUtil.md5Hex(StringUtil.toString(userName).toLowerCase()); // return StringUtil.format(DarwinoHttpConstants.SOCIAL_USERS_PATH + "/users/{0}/content/photo", URLEncoder.encode(md5, "UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$ // } // // public boolean isAdmin() { // return context.getUser().hasRole(ROLE_ADMIN); // } // // public boolean isAnonymous() { // return context.getUser().isAnonymous(); // } // // public String getCn() { // return context.getUser().getCn(); // } // // public String getDn() { // return context.getUser().getDn(); // } // // public String getEmailAddress() throws UserException { // Object mail = context.getUser().getAttribute(User.ATTR_EMAIL); // return StringUtil.toString(mail); // } // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessToken.java // @Entity @Data @NoArgsConstructor // public class AccessToken { // @Id @Column private String id; // @Column private String userName; // @Column private String name; // @Column private String token; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessTokenRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_TOKENS) // public interface AccessTokenRepository extends DarwinoRepository<AccessToken, String> { // Stream<AccessToken> findAll(); // // Optional<AccessToken> findByToken(String token); // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/Link.java // @Entity @Data @NoArgsConstructor // public class Link { // @Id @Column private String id; // @Column private String category; // @Column("link_url") @NotEmpty private String url; // @Column("link_name") @NotEmpty private String name; // @Column("link_visible") @Convert(BooleanYNConverter.class) private boolean visible; // @Column private String rel; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/LinkRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_CONFIG) // public interface LinkRepository extends DarwinoRepository<Link, String> { // Stream<Link> findAll(); // // @Query("select * from Link order by category name") // List<Link> findAllByCategoryAndName(); // } // Path: frostillicus-blog/frostillicus-blog-j2ee/src/main/java/controller/AdminController.java import bean.UserInfoBean; import com.darwino.commons.json.JsonException; import com.darwino.jsonstore.Session; import model.AccessToken; import model.AccessTokenRepository; import model.Link; import model.LinkRepository; import javax.annotation.security.RolesAllowed; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.mvc.Controller; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.util.UUID; /* * Copyright © 2012-2020 Jesse Gallagher * * 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 controller; @Controller @Path("admin") @RolesAllowed(UserInfoBean.ROLE_ADMIN) @RequestScoped public class AdminController { @Inject
LinkRepository links;
jesse-gallagher/frostillic.us-Blog
frostillicus-blog/frostillicus-blog-j2ee/src/main/java/controller/AdminController.java
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/bean/UserInfoBean.java // @RequestScoped // @Named("userInfo") // public class UserInfoBean { // public static final String ROLE_ADMIN = "admin"; //$NON-NLS-1$ // // @Inject @Named("darwinoContext") // DarwinoContext context; // // @SneakyThrows // public String getImageUrl(final String userName) { // String md5 = StringUtil.md5Hex(StringUtil.toString(userName).toLowerCase()); // return StringUtil.format(DarwinoHttpConstants.SOCIAL_USERS_PATH + "/users/{0}/content/photo", URLEncoder.encode(md5, "UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$ // } // // public boolean isAdmin() { // return context.getUser().hasRole(ROLE_ADMIN); // } // // public boolean isAnonymous() { // return context.getUser().isAnonymous(); // } // // public String getCn() { // return context.getUser().getCn(); // } // // public String getDn() { // return context.getUser().getDn(); // } // // public String getEmailAddress() throws UserException { // Object mail = context.getUser().getAttribute(User.ATTR_EMAIL); // return StringUtil.toString(mail); // } // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessToken.java // @Entity @Data @NoArgsConstructor // public class AccessToken { // @Id @Column private String id; // @Column private String userName; // @Column private String name; // @Column private String token; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessTokenRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_TOKENS) // public interface AccessTokenRepository extends DarwinoRepository<AccessToken, String> { // Stream<AccessToken> findAll(); // // Optional<AccessToken> findByToken(String token); // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/Link.java // @Entity @Data @NoArgsConstructor // public class Link { // @Id @Column private String id; // @Column private String category; // @Column("link_url") @NotEmpty private String url; // @Column("link_name") @NotEmpty private String name; // @Column("link_visible") @Convert(BooleanYNConverter.class) private boolean visible; // @Column private String rel; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/LinkRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_CONFIG) // public interface LinkRepository extends DarwinoRepository<Link, String> { // Stream<Link> findAll(); // // @Query("select * from Link order by category name") // List<Link> findAllByCategoryAndName(); // }
import bean.UserInfoBean; import com.darwino.commons.json.JsonException; import com.darwino.jsonstore.Session; import model.AccessToken; import model.AccessTokenRepository; import model.Link; import model.LinkRepository; import javax.annotation.security.RolesAllowed; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.mvc.Controller; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.util.UUID;
/* * Copyright © 2012-2020 Jesse Gallagher * * 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 controller; @Controller @Path("admin") @RolesAllowed(UserInfoBean.ROLE_ADMIN) @RequestScoped public class AdminController { @Inject LinkRepository links; @Inject
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/bean/UserInfoBean.java // @RequestScoped // @Named("userInfo") // public class UserInfoBean { // public static final String ROLE_ADMIN = "admin"; //$NON-NLS-1$ // // @Inject @Named("darwinoContext") // DarwinoContext context; // // @SneakyThrows // public String getImageUrl(final String userName) { // String md5 = StringUtil.md5Hex(StringUtil.toString(userName).toLowerCase()); // return StringUtil.format(DarwinoHttpConstants.SOCIAL_USERS_PATH + "/users/{0}/content/photo", URLEncoder.encode(md5, "UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$ // } // // public boolean isAdmin() { // return context.getUser().hasRole(ROLE_ADMIN); // } // // public boolean isAnonymous() { // return context.getUser().isAnonymous(); // } // // public String getCn() { // return context.getUser().getCn(); // } // // public String getDn() { // return context.getUser().getDn(); // } // // public String getEmailAddress() throws UserException { // Object mail = context.getUser().getAttribute(User.ATTR_EMAIL); // return StringUtil.toString(mail); // } // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessToken.java // @Entity @Data @NoArgsConstructor // public class AccessToken { // @Id @Column private String id; // @Column private String userName; // @Column private String name; // @Column private String token; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessTokenRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_TOKENS) // public interface AccessTokenRepository extends DarwinoRepository<AccessToken, String> { // Stream<AccessToken> findAll(); // // Optional<AccessToken> findByToken(String token); // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/Link.java // @Entity @Data @NoArgsConstructor // public class Link { // @Id @Column private String id; // @Column private String category; // @Column("link_url") @NotEmpty private String url; // @Column("link_name") @NotEmpty private String name; // @Column("link_visible") @Convert(BooleanYNConverter.class) private boolean visible; // @Column private String rel; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/LinkRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_CONFIG) // public interface LinkRepository extends DarwinoRepository<Link, String> { // Stream<Link> findAll(); // // @Query("select * from Link order by category name") // List<Link> findAllByCategoryAndName(); // } // Path: frostillicus-blog/frostillicus-blog-j2ee/src/main/java/controller/AdminController.java import bean.UserInfoBean; import com.darwino.commons.json.JsonException; import com.darwino.jsonstore.Session; import model.AccessToken; import model.AccessTokenRepository; import model.Link; import model.LinkRepository; import javax.annotation.security.RolesAllowed; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.mvc.Controller; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.util.UUID; /* * Copyright © 2012-2020 Jesse Gallagher * * 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 controller; @Controller @Path("admin") @RolesAllowed(UserInfoBean.ROLE_ADMIN) @RequestScoped public class AdminController { @Inject LinkRepository links; @Inject
AccessTokenRepository tokens;
jesse-gallagher/frostillic.us-Blog
frostillicus-blog/frostillicus-blog-j2ee/src/main/java/controller/AdminController.java
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/bean/UserInfoBean.java // @RequestScoped // @Named("userInfo") // public class UserInfoBean { // public static final String ROLE_ADMIN = "admin"; //$NON-NLS-1$ // // @Inject @Named("darwinoContext") // DarwinoContext context; // // @SneakyThrows // public String getImageUrl(final String userName) { // String md5 = StringUtil.md5Hex(StringUtil.toString(userName).toLowerCase()); // return StringUtil.format(DarwinoHttpConstants.SOCIAL_USERS_PATH + "/users/{0}/content/photo", URLEncoder.encode(md5, "UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$ // } // // public boolean isAdmin() { // return context.getUser().hasRole(ROLE_ADMIN); // } // // public boolean isAnonymous() { // return context.getUser().isAnonymous(); // } // // public String getCn() { // return context.getUser().getCn(); // } // // public String getDn() { // return context.getUser().getDn(); // } // // public String getEmailAddress() throws UserException { // Object mail = context.getUser().getAttribute(User.ATTR_EMAIL); // return StringUtil.toString(mail); // } // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessToken.java // @Entity @Data @NoArgsConstructor // public class AccessToken { // @Id @Column private String id; // @Column private String userName; // @Column private String name; // @Column private String token; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessTokenRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_TOKENS) // public interface AccessTokenRepository extends DarwinoRepository<AccessToken, String> { // Stream<AccessToken> findAll(); // // Optional<AccessToken> findByToken(String token); // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/Link.java // @Entity @Data @NoArgsConstructor // public class Link { // @Id @Column private String id; // @Column private String category; // @Column("link_url") @NotEmpty private String url; // @Column("link_name") @NotEmpty private String name; // @Column("link_visible") @Convert(BooleanYNConverter.class) private boolean visible; // @Column private String rel; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/LinkRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_CONFIG) // public interface LinkRepository extends DarwinoRepository<Link, String> { // Stream<Link> findAll(); // // @Query("select * from Link order by category name") // List<Link> findAllByCategoryAndName(); // }
import bean.UserInfoBean; import com.darwino.commons.json.JsonException; import com.darwino.jsonstore.Session; import model.AccessToken; import model.AccessTokenRepository; import model.Link; import model.LinkRepository; import javax.annotation.security.RolesAllowed; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.mvc.Controller; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.util.UUID;
@POST @Path("links/{linkId}") public String update( @PathParam("linkId") final String linkId, @FormParam("visible") final String visible, @FormParam("category") final String category, @FormParam("name") final String name, @FormParam("url") final String url, @FormParam("rel") final String rel ) { var link = links.findById(linkId).orElseThrow(() -> new NotFoundException("Unable to find link matching ID " + linkId)); //$NON-NLS-1$ link.setVisible("Y".equals(visible)); //$NON-NLS-1$ link.setCategory(category); link.setName(name); link.setUrl(url); link.setRel(rel); links.save(link); return "redirect:admin"; //$NON-NLS-1$ } @DELETE @Path("links/{linkId}") public String deleteLink(@PathParam("linkId") final String linkId) { links.deleteById(linkId); return "redirect:admin"; //$NON-NLS-1$ } @POST @Path("links/new") public String createLink() {
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/bean/UserInfoBean.java // @RequestScoped // @Named("userInfo") // public class UserInfoBean { // public static final String ROLE_ADMIN = "admin"; //$NON-NLS-1$ // // @Inject @Named("darwinoContext") // DarwinoContext context; // // @SneakyThrows // public String getImageUrl(final String userName) { // String md5 = StringUtil.md5Hex(StringUtil.toString(userName).toLowerCase()); // return StringUtil.format(DarwinoHttpConstants.SOCIAL_USERS_PATH + "/users/{0}/content/photo", URLEncoder.encode(md5, "UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$ // } // // public boolean isAdmin() { // return context.getUser().hasRole(ROLE_ADMIN); // } // // public boolean isAnonymous() { // return context.getUser().isAnonymous(); // } // // public String getCn() { // return context.getUser().getCn(); // } // // public String getDn() { // return context.getUser().getDn(); // } // // public String getEmailAddress() throws UserException { // Object mail = context.getUser().getAttribute(User.ATTR_EMAIL); // return StringUtil.toString(mail); // } // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessToken.java // @Entity @Data @NoArgsConstructor // public class AccessToken { // @Id @Column private String id; // @Column private String userName; // @Column private String name; // @Column private String token; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessTokenRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_TOKENS) // public interface AccessTokenRepository extends DarwinoRepository<AccessToken, String> { // Stream<AccessToken> findAll(); // // Optional<AccessToken> findByToken(String token); // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/Link.java // @Entity @Data @NoArgsConstructor // public class Link { // @Id @Column private String id; // @Column private String category; // @Column("link_url") @NotEmpty private String url; // @Column("link_name") @NotEmpty private String name; // @Column("link_visible") @Convert(BooleanYNConverter.class) private boolean visible; // @Column private String rel; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/LinkRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_CONFIG) // public interface LinkRepository extends DarwinoRepository<Link, String> { // Stream<Link> findAll(); // // @Query("select * from Link order by category name") // List<Link> findAllByCategoryAndName(); // } // Path: frostillicus-blog/frostillicus-blog-j2ee/src/main/java/controller/AdminController.java import bean.UserInfoBean; import com.darwino.commons.json.JsonException; import com.darwino.jsonstore.Session; import model.AccessToken; import model.AccessTokenRepository; import model.Link; import model.LinkRepository; import javax.annotation.security.RolesAllowed; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.mvc.Controller; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.util.UUID; @POST @Path("links/{linkId}") public String update( @PathParam("linkId") final String linkId, @FormParam("visible") final String visible, @FormParam("category") final String category, @FormParam("name") final String name, @FormParam("url") final String url, @FormParam("rel") final String rel ) { var link = links.findById(linkId).orElseThrow(() -> new NotFoundException("Unable to find link matching ID " + linkId)); //$NON-NLS-1$ link.setVisible("Y".equals(visible)); //$NON-NLS-1$ link.setCategory(category); link.setName(name); link.setUrl(url); link.setRel(rel); links.save(link); return "redirect:admin"; //$NON-NLS-1$ } @DELETE @Path("links/{linkId}") public String deleteLink(@PathParam("linkId") final String linkId) { links.deleteById(linkId); return "redirect:admin"; //$NON-NLS-1$ } @POST @Path("links/new") public String createLink() {
var link = new Link();
jesse-gallagher/frostillic.us-Blog
frostillicus-blog/frostillicus-blog-j2ee/src/main/java/controller/AdminController.java
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/bean/UserInfoBean.java // @RequestScoped // @Named("userInfo") // public class UserInfoBean { // public static final String ROLE_ADMIN = "admin"; //$NON-NLS-1$ // // @Inject @Named("darwinoContext") // DarwinoContext context; // // @SneakyThrows // public String getImageUrl(final String userName) { // String md5 = StringUtil.md5Hex(StringUtil.toString(userName).toLowerCase()); // return StringUtil.format(DarwinoHttpConstants.SOCIAL_USERS_PATH + "/users/{0}/content/photo", URLEncoder.encode(md5, "UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$ // } // // public boolean isAdmin() { // return context.getUser().hasRole(ROLE_ADMIN); // } // // public boolean isAnonymous() { // return context.getUser().isAnonymous(); // } // // public String getCn() { // return context.getUser().getCn(); // } // // public String getDn() { // return context.getUser().getDn(); // } // // public String getEmailAddress() throws UserException { // Object mail = context.getUser().getAttribute(User.ATTR_EMAIL); // return StringUtil.toString(mail); // } // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessToken.java // @Entity @Data @NoArgsConstructor // public class AccessToken { // @Id @Column private String id; // @Column private String userName; // @Column private String name; // @Column private String token; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessTokenRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_TOKENS) // public interface AccessTokenRepository extends DarwinoRepository<AccessToken, String> { // Stream<AccessToken> findAll(); // // Optional<AccessToken> findByToken(String token); // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/Link.java // @Entity @Data @NoArgsConstructor // public class Link { // @Id @Column private String id; // @Column private String category; // @Column("link_url") @NotEmpty private String url; // @Column("link_name") @NotEmpty private String name; // @Column("link_visible") @Convert(BooleanYNConverter.class) private boolean visible; // @Column private String rel; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/LinkRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_CONFIG) // public interface LinkRepository extends DarwinoRepository<Link, String> { // Stream<Link> findAll(); // // @Query("select * from Link order by category name") // List<Link> findAllByCategoryAndName(); // }
import bean.UserInfoBean; import com.darwino.commons.json.JsonException; import com.darwino.jsonstore.Session; import model.AccessToken; import model.AccessTokenRepository; import model.Link; import model.LinkRepository; import javax.annotation.security.RolesAllowed; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.mvc.Controller; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.util.UUID;
// ******************************************************************************* // * Access Tokens // ******************************************************************************* @POST @Path("tokens/{tokenId}") public String updateToken( @PathParam("tokenId") final String tokenId, @FormParam("userName") final String userName, @FormParam("name") final String name, @FormParam("token") final String token ) { var accessToken = tokens.findById(tokenId).orElseThrow(() -> new NotFoundException("Unable to find token matching ID " + tokenId)); //$NON-NLS-1$ accessToken.setUserName(userName); accessToken.setName(name); accessToken.setToken(token); tokens.save(accessToken); return "redirect:admin"; //$NON-NLS-1$ } @DELETE @Path("tokens/{tokenId}") public String deleteToken(@PathParam("tokenId") final String tokenId) { tokens.deleteById(tokenId); return "redirect:admin"; //$NON-NLS-1$ } @POST @Path("tokens/new") public String createToken() throws JsonException {
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/bean/UserInfoBean.java // @RequestScoped // @Named("userInfo") // public class UserInfoBean { // public static final String ROLE_ADMIN = "admin"; //$NON-NLS-1$ // // @Inject @Named("darwinoContext") // DarwinoContext context; // // @SneakyThrows // public String getImageUrl(final String userName) { // String md5 = StringUtil.md5Hex(StringUtil.toString(userName).toLowerCase()); // return StringUtil.format(DarwinoHttpConstants.SOCIAL_USERS_PATH + "/users/{0}/content/photo", URLEncoder.encode(md5, "UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$ // } // // public boolean isAdmin() { // return context.getUser().hasRole(ROLE_ADMIN); // } // // public boolean isAnonymous() { // return context.getUser().isAnonymous(); // } // // public String getCn() { // return context.getUser().getCn(); // } // // public String getDn() { // return context.getUser().getDn(); // } // // public String getEmailAddress() throws UserException { // Object mail = context.getUser().getAttribute(User.ATTR_EMAIL); // return StringUtil.toString(mail); // } // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessToken.java // @Entity @Data @NoArgsConstructor // public class AccessToken { // @Id @Column private String id; // @Column private String userName; // @Column private String name; // @Column private String token; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessTokenRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_TOKENS) // public interface AccessTokenRepository extends DarwinoRepository<AccessToken, String> { // Stream<AccessToken> findAll(); // // Optional<AccessToken> findByToken(String token); // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/Link.java // @Entity @Data @NoArgsConstructor // public class Link { // @Id @Column private String id; // @Column private String category; // @Column("link_url") @NotEmpty private String url; // @Column("link_name") @NotEmpty private String name; // @Column("link_visible") @Convert(BooleanYNConverter.class) private boolean visible; // @Column private String rel; // @Column private boolean isConflict; // } // // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/LinkRepository.java // @RepositoryProvider(AppDatabaseDef.STORE_CONFIG) // public interface LinkRepository extends DarwinoRepository<Link, String> { // Stream<Link> findAll(); // // @Query("select * from Link order by category name") // List<Link> findAllByCategoryAndName(); // } // Path: frostillicus-blog/frostillicus-blog-j2ee/src/main/java/controller/AdminController.java import bean.UserInfoBean; import com.darwino.commons.json.JsonException; import com.darwino.jsonstore.Session; import model.AccessToken; import model.AccessTokenRepository; import model.Link; import model.LinkRepository; import javax.annotation.security.RolesAllowed; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.mvc.Controller; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.util.UUID; // ******************************************************************************* // * Access Tokens // ******************************************************************************* @POST @Path("tokens/{tokenId}") public String updateToken( @PathParam("tokenId") final String tokenId, @FormParam("userName") final String userName, @FormParam("name") final String name, @FormParam("token") final String token ) { var accessToken = tokens.findById(tokenId).orElseThrow(() -> new NotFoundException("Unable to find token matching ID " + tokenId)); //$NON-NLS-1$ accessToken.setUserName(userName); accessToken.setName(name); accessToken.setToken(token); tokens.save(accessToken); return "redirect:admin"; //$NON-NLS-1$ } @DELETE @Path("tokens/{tokenId}") public String deleteToken(@PathParam("tokenId") final String tokenId) { tokens.deleteById(tokenId); return "redirect:admin"; //$NON-NLS-1$ } @POST @Path("tokens/new") public String createToken() throws JsonException {
var token = new AccessToken();
jesse-gallagher/frostillic.us-Blog
frostillicus-blog/frostillicus-blog-shared/src/main/java/bean/LoggerBean.java
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/darwino/AppDatabaseDef.java // public class AppDatabaseDef extends DatabaseFactoryImpl { // // public static final int DATABASE_VERSION = 17; // public static final String DATABASE_NAME = "frostillicus_blog"; //$NON-NLS-1$ // public static final String STORE_POSTS = "posts"; //$NON-NLS-1$ // public static final String STORE_COMMENTS = "comments"; //$NON-NLS-1$ // public static final String STORE_CONFIG = "config"; //$NON-NLS-1$ // public static final String STORE_MEDIA = "media"; //$NON-NLS-1$ // /** @since 2.3.0 */ // public static final String STORE_MICROPOSTS = "microposts"; //$NON-NLS-1$ // /** @since 2.3.0 */ // public static final String STORE_TOKENS = "tokens"; //$NON-NLS-1$ // /** @since 2.3.0 */ // public static final String STORE_WEBMENTIONS = "webmentions"; //$NON-NLS-1$ // // // The list of instances is defined through a property for the DB // public static String[] getInstances() { // String inst = Platform.getProperty("frostillicus_blog.instances"); //$NON-NLS-1$ // if(StringUtil.isNotEmpty(inst)) { // return StringUtil.splitString(inst, ',', true); // } // return null; // } // // @Override // public int getDatabaseVersion(final String databaseName) throws JsonException { // if(!StringUtil.equalsIgnoreCase(databaseName, DATABASE_NAME)) { // return -1; // } // return DATABASE_VERSION; // } // // @Override // public _Database loadDatabase(final String databaseName) throws JsonException { // if(!StringUtil.equalsIgnoreCase(databaseName, DATABASE_NAME)) { // return null; // } // _Database db = new _Database(DATABASE_NAME, "frostillic.us Blog", DATABASE_VERSION); //$NON-NLS-1$ // db.setDocumentSecurity(Base.DOCSEC_NOTESLIKE | Base.DOCSEC_INCLUDE | Base.DOCSEC_DYNAMIC); // // _DatabaseACL acl = new _DatabaseACL(); // acl.addRole(UserInfoBean.ROLE_ADMIN, _DatabaseACL.ROLE_MANAGE); // acl.addAnonymous(_DatabaseACL.ROLE_AUTHOR); // acl.addUser("anonymous", _DatabaseACL.ROLE_READER); //$NON-NLS-1$ // db.setACL(acl); // // db.setReplicationEnabled(true); // db.setDocumentLockEnabled(false); // // db.setInstanceEnabled(false); // // { // _Store posts = db.addStore(STORE_POSTS); // posts.setFtSearchEnabled(true); // posts.setTaggingEnabled(true); // _FtSearch ft = posts.setFTSearch(new _FtSearch()); // ft.setFields("$"); //$NON-NLS-1$ // } // { // _Store comments = db.addStore(STORE_COMMENTS); // comments.setFtSearchEnabled(true); // _FtSearch ft = comments.setFTSearch(new _FtSearch()); // ft.setFields("$"); //$NON-NLS-1$ // } // db.addStore(STORE_CONFIG); // db.addStore(STORE_MEDIA); // db.addStore(STORE_MICROPOSTS); // db.addStore(STORE_TOKENS); // db.addStore(STORE_WEBMENTIONS); // // return db; // } // }
import java.util.logging.Logger; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.inject.Produces; import darwino.AppDatabaseDef;
/* * Copyright © 2012-2020 Jesse Gallagher * * 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 bean; /** * Provides an app logger for CDI injection. * * @author Jesse Gallagher * @since 2.3.0 */ @ApplicationScoped public class LoggerBean { @Produces public Logger getLogger() {
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/darwino/AppDatabaseDef.java // public class AppDatabaseDef extends DatabaseFactoryImpl { // // public static final int DATABASE_VERSION = 17; // public static final String DATABASE_NAME = "frostillicus_blog"; //$NON-NLS-1$ // public static final String STORE_POSTS = "posts"; //$NON-NLS-1$ // public static final String STORE_COMMENTS = "comments"; //$NON-NLS-1$ // public static final String STORE_CONFIG = "config"; //$NON-NLS-1$ // public static final String STORE_MEDIA = "media"; //$NON-NLS-1$ // /** @since 2.3.0 */ // public static final String STORE_MICROPOSTS = "microposts"; //$NON-NLS-1$ // /** @since 2.3.0 */ // public static final String STORE_TOKENS = "tokens"; //$NON-NLS-1$ // /** @since 2.3.0 */ // public static final String STORE_WEBMENTIONS = "webmentions"; //$NON-NLS-1$ // // // The list of instances is defined through a property for the DB // public static String[] getInstances() { // String inst = Platform.getProperty("frostillicus_blog.instances"); //$NON-NLS-1$ // if(StringUtil.isNotEmpty(inst)) { // return StringUtil.splitString(inst, ',', true); // } // return null; // } // // @Override // public int getDatabaseVersion(final String databaseName) throws JsonException { // if(!StringUtil.equalsIgnoreCase(databaseName, DATABASE_NAME)) { // return -1; // } // return DATABASE_VERSION; // } // // @Override // public _Database loadDatabase(final String databaseName) throws JsonException { // if(!StringUtil.equalsIgnoreCase(databaseName, DATABASE_NAME)) { // return null; // } // _Database db = new _Database(DATABASE_NAME, "frostillic.us Blog", DATABASE_VERSION); //$NON-NLS-1$ // db.setDocumentSecurity(Base.DOCSEC_NOTESLIKE | Base.DOCSEC_INCLUDE | Base.DOCSEC_DYNAMIC); // // _DatabaseACL acl = new _DatabaseACL(); // acl.addRole(UserInfoBean.ROLE_ADMIN, _DatabaseACL.ROLE_MANAGE); // acl.addAnonymous(_DatabaseACL.ROLE_AUTHOR); // acl.addUser("anonymous", _DatabaseACL.ROLE_READER); //$NON-NLS-1$ // db.setACL(acl); // // db.setReplicationEnabled(true); // db.setDocumentLockEnabled(false); // // db.setInstanceEnabled(false); // // { // _Store posts = db.addStore(STORE_POSTS); // posts.setFtSearchEnabled(true); // posts.setTaggingEnabled(true); // _FtSearch ft = posts.setFTSearch(new _FtSearch()); // ft.setFields("$"); //$NON-NLS-1$ // } // { // _Store comments = db.addStore(STORE_COMMENTS); // comments.setFtSearchEnabled(true); // _FtSearch ft = comments.setFTSearch(new _FtSearch()); // ft.setFields("$"); //$NON-NLS-1$ // } // db.addStore(STORE_CONFIG); // db.addStore(STORE_MEDIA); // db.addStore(STORE_MICROPOSTS); // db.addStore(STORE_TOKENS); // db.addStore(STORE_WEBMENTIONS); // // return db; // } // } // Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/bean/LoggerBean.java import java.util.logging.Logger; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.inject.Produces; import darwino.AppDatabaseDef; /* * Copyright © 2012-2020 Jesse Gallagher * * 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 bean; /** * Provides an app logger for CDI injection. * * @author Jesse Gallagher * @since 2.3.0 */ @ApplicationScoped public class LoggerBean { @Produces public Logger getLogger() {
return Logger.getLogger(AppDatabaseDef.DATABASE_NAME);