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
gruter/utogen
src/main/java/com/gruter/generator/randomisers/LogWriter.java
// Path: src/main/java/generator/misc/DataFileDefinition.java // public class DataFileDefinition // { // private String name; // private String description; // private Vector<DataFileItem> outDataItems; //a place holder for DataFileItem // private String dataItemXml; // private String delimiter; // private long totalRecords; // private int tps; // private String log4j; // private String log4jName; // // public void setDataItemXml(String xml) throws Exception { // String fullXml = "<datafile-definitions><File-output-definition delimiter=\",\" name=\"Test_" + System.currentTimeMillis() + "\" " + // "totalRecords=\"0\" tps=\"0\">" + xml; // fullXml += "</File-output-definition></datafile-definitions>"; // // Vector<DataFileDefinition> vData; // RandomDefinitionsBuilder builder = new RandomDefinitionsBuilder(); // // builder.setInputStreame(new ByteArrayInputStream(fullXml.getBytes())); // builder.setSAXHandler(new DataFileOutputSAXHandler() ); // vData = builder.getElements(); // if(vData.size() == 0) { // throw new IOException("XML Parsing error:" + xml); // } // outDataItems = vData.get(0).getOutDataItems(); // this.dataItemXml = xml; // } // // public String getDataItemXml() { // return dataItemXml; // } // // public String getName() { // return name; // } // public void setName(String name) { // this.name = name; // } // public String getDescription() { // return description; // } // public void setDescription(String description) { // this.description = description; // } // public Vector<DataFileItem> getOutDataItems() { // return outDataItems; // } // public void setOutDataItems(Vector<DataFileItem> outDataItems) { // this.outDataItems = outDataItems; // StringBuilder sb = new StringBuilder(); // for(DataFileItem eachItem: outDataItems) { // sb.append(dataItemToXml(eachItem)).append("\n"); // } // // dataItemXml = sb.toString(); // } // // private String dataItemToXml(DataFileItem dataItem) { // String result = "<data-item "; // result += "fieldName=\"" + dataItem.getFieldName() + "\" "; // result += "randomiser-instance=\"" + dataItem.getRandomiserInstanceName() + "\" "; // result += "width=\"" + dataItem.getWidth() + "\" "; // result += "encloseChar=\"" + dataItem.getEncloseChar() + "\" "; // if(dataItem.getDummy() != null && dataItem.getDummy().length() > 0) { // result += "dummy=\"" + dataItem.getDummy() + "\" "; // } // if(dataItem.getExpression() != null && dataItem.getExpression().length() > 0) { // result += "expression=\"" + dataItem.getExpression() + "\" "; // } // result += "alignment=\"" + dataItem.getAlignment() + "\" />"; // return result; // } // // public String getDelimiter() { // return delimiter; // } // public void setDelimiter(String delimiter) { // this.delimiter = delimiter; // } // public long getTotalRecords() { // return totalRecords; // } // public void setTotalRecords(long totalRecords) { // this.totalRecords = totalRecords; // } // public int getTps() { // return tps; // } // public void setTps(int tps) { // this.tps = tps; // } // public String getLog4j() { // return log4j; // } // public void setLog4j(String log4j) { // this.log4j = log4j; // } // public String getLog4jName() { // return log4jName; // } // public void setLog4jName(String log4jName) { // this.log4jName = log4jName; // } // public String toString() { // return name; // } // // public static void main(String[] args) throws Exception { // String data = "<data-item fieldName=\"f1\" alignment=\"1\" encloseChar=\"\" randomiser-instance=\"SimpleSequencer\" width=\"-1\"/>" + // "<data-item fieldName=\"f2\" alignment=\"1\" encloseChar=\"\" randomiser-instance=\"EnglishFirstnames\" width=\"-1\"/>"; // // data = "<datafile-definitions><File-output-definition delimiter=\",\" name=\"Test_" + System.currentTimeMillis() + "\" totalRecords=\"0\" tps=\"0\">" + data; // data += "</File-output-definition></datafile-definitions>"; // // Vector<DataFileDefinition> vData; // RandomDefinitionsBuilder builder = new RandomDefinitionsBuilder(); // // builder.setInputStreame(new ByteArrayInputStream(data.getBytes())); // builder.setSAXHandler(new DataFileOutputSAXHandler() ); // vData = builder.getElements(); // System.out.println(">>>>" + vData.get(0).getOutDataItems().size()); // } // }
import generator.misc.DataFileDefinition; import java.io.BufferedWriter; import java.io.IOException; import java.util.Properties; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator;
package com.gruter.generator.randomisers; public class LogWriter { // static final Logger logger = Logger.getLogger(LogWriter.class); private BufferedWriter fileWriter; private Logger log4jWriter;
// Path: src/main/java/generator/misc/DataFileDefinition.java // public class DataFileDefinition // { // private String name; // private String description; // private Vector<DataFileItem> outDataItems; //a place holder for DataFileItem // private String dataItemXml; // private String delimiter; // private long totalRecords; // private int tps; // private String log4j; // private String log4jName; // // public void setDataItemXml(String xml) throws Exception { // String fullXml = "<datafile-definitions><File-output-definition delimiter=\",\" name=\"Test_" + System.currentTimeMillis() + "\" " + // "totalRecords=\"0\" tps=\"0\">" + xml; // fullXml += "</File-output-definition></datafile-definitions>"; // // Vector<DataFileDefinition> vData; // RandomDefinitionsBuilder builder = new RandomDefinitionsBuilder(); // // builder.setInputStreame(new ByteArrayInputStream(fullXml.getBytes())); // builder.setSAXHandler(new DataFileOutputSAXHandler() ); // vData = builder.getElements(); // if(vData.size() == 0) { // throw new IOException("XML Parsing error:" + xml); // } // outDataItems = vData.get(0).getOutDataItems(); // this.dataItemXml = xml; // } // // public String getDataItemXml() { // return dataItemXml; // } // // public String getName() { // return name; // } // public void setName(String name) { // this.name = name; // } // public String getDescription() { // return description; // } // public void setDescription(String description) { // this.description = description; // } // public Vector<DataFileItem> getOutDataItems() { // return outDataItems; // } // public void setOutDataItems(Vector<DataFileItem> outDataItems) { // this.outDataItems = outDataItems; // StringBuilder sb = new StringBuilder(); // for(DataFileItem eachItem: outDataItems) { // sb.append(dataItemToXml(eachItem)).append("\n"); // } // // dataItemXml = sb.toString(); // } // // private String dataItemToXml(DataFileItem dataItem) { // String result = "<data-item "; // result += "fieldName=\"" + dataItem.getFieldName() + "\" "; // result += "randomiser-instance=\"" + dataItem.getRandomiserInstanceName() + "\" "; // result += "width=\"" + dataItem.getWidth() + "\" "; // result += "encloseChar=\"" + dataItem.getEncloseChar() + "\" "; // if(dataItem.getDummy() != null && dataItem.getDummy().length() > 0) { // result += "dummy=\"" + dataItem.getDummy() + "\" "; // } // if(dataItem.getExpression() != null && dataItem.getExpression().length() > 0) { // result += "expression=\"" + dataItem.getExpression() + "\" "; // } // result += "alignment=\"" + dataItem.getAlignment() + "\" />"; // return result; // } // // public String getDelimiter() { // return delimiter; // } // public void setDelimiter(String delimiter) { // this.delimiter = delimiter; // } // public long getTotalRecords() { // return totalRecords; // } // public void setTotalRecords(long totalRecords) { // this.totalRecords = totalRecords; // } // public int getTps() { // return tps; // } // public void setTps(int tps) { // this.tps = tps; // } // public String getLog4j() { // return log4j; // } // public void setLog4j(String log4j) { // this.log4j = log4j; // } // public String getLog4jName() { // return log4jName; // } // public void setLog4jName(String log4jName) { // this.log4jName = log4jName; // } // public String toString() { // return name; // } // // public static void main(String[] args) throws Exception { // String data = "<data-item fieldName=\"f1\" alignment=\"1\" encloseChar=\"\" randomiser-instance=\"SimpleSequencer\" width=\"-1\"/>" + // "<data-item fieldName=\"f2\" alignment=\"1\" encloseChar=\"\" randomiser-instance=\"EnglishFirstnames\" width=\"-1\"/>"; // // data = "<datafile-definitions><File-output-definition delimiter=\",\" name=\"Test_" + System.currentTimeMillis() + "\" totalRecords=\"0\" tps=\"0\">" + data; // data += "</File-output-definition></datafile-definitions>"; // // Vector<DataFileDefinition> vData; // RandomDefinitionsBuilder builder = new RandomDefinitionsBuilder(); // // builder.setInputStreame(new ByteArrayInputStream(data.getBytes())); // builder.setSAXHandler(new DataFileOutputSAXHandler() ); // vData = builder.getElements(); // System.out.println(">>>>" + vData.get(0).getOutDataItems().size()); // } // } // Path: src/main/java/com/gruter/generator/randomisers/LogWriter.java import generator.misc.DataFileDefinition; import java.io.BufferedWriter; import java.io.IOException; import java.util.Properties; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; package com.gruter.generator.randomisers; public class LogWriter { // static final Logger logger = Logger.getLogger(LogWriter.class); private BufferedWriter fileWriter; private Logger log4jWriter;
public LogWriter(DataFileDefinition df) throws Exception {
gruter/utogen
src/main/java/generator/panels/PanelNumLongRandomiser.java
// Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // // Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // }
import java.net.URL; import java.util.HashMap; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import org.apache.log4j.Logger; import generator.extenders.RandomiserPanel; import generator.extenders.RandomiserInstance;
{lValues[1] = new Long(sTo);} catch(Exception e) {error=2;} try {lValues[2] = new Long(sPercent);} catch(Exception e) {error=3;} if(lValues[0].longValue()>lValues[1].longValue()) { JOptionPane.showMessageDialog(this,"From value should be lower than to value.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(error>0) { JOptionPane.showMessageDialog(this,"Values for the fields From, To, Percentage should be numeric.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(lValues[2].intValue()<=0) { JOptionPane.showMessageDialog(this,"Percentage field should be a positive integer.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } newModel.addRow(lValues); }//GEN-LAST:event_btnAddActionPerformed
// Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // // Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // Path: src/main/java/generator/panels/PanelNumLongRandomiser.java import java.net.URL; import java.util.HashMap; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import org.apache.log4j.Logger; import generator.extenders.RandomiserPanel; import generator.extenders.RandomiserInstance; {lValues[1] = new Long(sTo);} catch(Exception e) {error=2;} try {lValues[2] = new Long(sPercent);} catch(Exception e) {error=3;} if(lValues[0].longValue()>lValues[1].longValue()) { JOptionPane.showMessageDialog(this,"From value should be lower than to value.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(error>0) { JOptionPane.showMessageDialog(this,"Values for the fields From, To, Percentage should be numeric.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(lValues[2].intValue()<=0) { JOptionPane.showMessageDialog(this,"Percentage field should be a positive integer.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } newModel.addRow(lValues); }//GEN-LAST:event_btnAddActionPerformed
public void initialise(RandomiserInstance ri)
gruter/utogen
src/main/java/generator/panels/PanelNumDoubleRandomiser.java
// Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // // Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // }
import java.net.URL; import java.util.HashMap; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JOptionPane.*; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import org.apache.log4j.Logger; import generator.extenders.RandomiserPanel; import generator.extenders.RandomiserInstance;
{dblValues[1] = new Double(sTo);} catch(Exception e) {error=2;} try {dblValues[2] = new Double(sPercent);} catch(Exception e) {error=3;} if(error>0) { JOptionPane.showMessageDialog(this,"Values for the fields From, To, Percentage should be numeric.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(dblValues[0].doubleValue()>dblValues[1].doubleValue()) { JOptionPane.showMessageDialog(this,"From value should be lower than to value.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(dblValues[2].doubleValue()<=0) { JOptionPane.showMessageDialog(this,"Percentage field should be a positive integer.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } newModel.addRow(dblValues); }//GEN-LAST:event_btnAddActionPerformed
// Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // // Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // Path: src/main/java/generator/panels/PanelNumDoubleRandomiser.java import java.net.URL; import java.util.HashMap; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JOptionPane.*; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import org.apache.log4j.Logger; import generator.extenders.RandomiserPanel; import generator.extenders.RandomiserInstance; {dblValues[1] = new Double(sTo);} catch(Exception e) {error=2;} try {dblValues[2] = new Double(sPercent);} catch(Exception e) {error=3;} if(error>0) { JOptionPane.showMessageDialog(this,"Values for the fields From, To, Percentage should be numeric.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(dblValues[0].doubleValue()>dblValues[1].doubleValue()) { JOptionPane.showMessageDialog(this,"From value should be lower than to value.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(dblValues[2].doubleValue()<=0) { JOptionPane.showMessageDialog(this,"Percentage field should be a positive integer.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } newModel.addRow(dblValues); }//GEN-LAST:event_btnAddActionPerformed
public void initialise(RandomiserInstance ri)
gruter/utogen
src/main/java/generator/panels/PanelNumIntegerRandomiser.java
// Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // // Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // }
import java.net.URL; import java.util.HashMap; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import org.apache.log4j.Logger; import generator.extenders.RandomiserPanel; import generator.extenders.RandomiserInstance;
try {iValues[1] = new Integer(sTo);} catch(Exception e) {error=2;} try {iValues[2] = new Integer(sPercent);} catch(Exception e) {error=3;} if(iValues[0].intValue()>iValues[1].intValue()) { JOptionPane.showMessageDialog(this,"From value should be lower than to value.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(error>0) { JOptionPane.showMessageDialog(this,"Values for the fields From, To, Percentage should be numeric.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(iValues[2].intValue()<=0) { JOptionPane.showMessageDialog(this,"Percentage field should be a positive integer.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } newModel.addRow(iValues); }//GEN-LAST:event_btnAddActionPerformed
// Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // // Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // Path: src/main/java/generator/panels/PanelNumIntegerRandomiser.java import java.net.URL; import java.util.HashMap; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import org.apache.log4j.Logger; import generator.extenders.RandomiserPanel; import generator.extenders.RandomiserInstance; try {iValues[1] = new Integer(sTo);} catch(Exception e) {error=2;} try {iValues[2] = new Integer(sPercent);} catch(Exception e) {error=3;} if(iValues[0].intValue()>iValues[1].intValue()) { JOptionPane.showMessageDialog(this,"From value should be lower than to value.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(error>0) { JOptionPane.showMessageDialog(this,"Values for the fields From, To, Percentage should be numeric.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(iValues[2].intValue()<=0) { JOptionPane.showMessageDialog(this,"Percentage field should be a positive integer.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } newModel.addRow(iValues); }//GEN-LAST:event_btnAddActionPerformed
public void initialise(RandomiserInstance ri)
gruter/utogen
src/main/java/com/gruter/generator/randomisers/PanelIPRandomiser.java
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // // Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // }
import java.util.LinkedHashMap; import javax.swing.JOptionPane; import generator.extenders.RandomiserInstance; import generator.extenders.RandomiserPanel; import org.apache.log4j.Logger;
); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(10, 10, 10) .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addContainerGap(101, Short.MAX_VALUE)) ); }// </editor-fold> public boolean isFormValid() { if (txtName.getText().trim().length() == 0) { JOptionPane.showMessageDialog(this, "Please provide a value for the name", "Required field", JOptionPane.ERROR_MESSAGE); return false; } return true; }
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // // Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // Path: src/main/java/com/gruter/generator/randomisers/PanelIPRandomiser.java import java.util.LinkedHashMap; import javax.swing.JOptionPane; import generator.extenders.RandomiserInstance; import generator.extenders.RandomiserPanel; import org.apache.log4j.Logger; ); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(10, 10, 10) .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addContainerGap(101, Short.MAX_VALUE)) ); }// </editor-fold> public boolean isFormValid() { if (txtName.getText().trim().length() == 0) { JOptionPane.showMessageDialog(this, "Please provide a value for the name", "Required field", JOptionPane.ERROR_MESSAGE); return false; } return true; }
public RandomiserInstance getRandomiserInstance() {
gruter/utogen
src/main/java/com/gruter/generator/randomisers/IPRandomiser.java
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // }
import java.util.Random; import generator.extenders.IRandomiserFunctionality; import generator.extenders.RandomiserInstance;
package com.gruter.generator.randomisers; public class IPRandomiser implements IRandomiserFunctionality { private Random rand1; private Random rand2; private Random rand3; private Random rand4; @Override public void destroy() { } @Override public Object generate() { return rand1.nextInt(256) + "." + rand2.nextInt(256) + "." + rand3.nextInt(256) + "." + rand4.nextInt(256); } @Override
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // Path: src/main/java/com/gruter/generator/randomisers/IPRandomiser.java import java.util.Random; import generator.extenders.IRandomiserFunctionality; import generator.extenders.RandomiserInstance; package com.gruter.generator.randomisers; public class IPRandomiser implements IRandomiserFunctionality { private Random rand1; private Random rand2; private Random rand3; private Random rand4; @Override public void destroy() { } @Override public Object generate() { return rand1.nextInt(256) + "." + rand2.nextInt(256) + "." + rand3.nextInt(256) + "." + rand4.nextInt(256); } @Override
public void setRandomiserInstance(RandomiserInstance ri) {
gruter/utogen
src/main/java/generator/panels/PanelSQLDateRandomiser.java
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // // Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // }
import generator.extenders.RandomiserInstance; import generator.extenders.RandomiserPanel; import java.net.URL; import java.sql.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JCheckBox; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import org.apache.log4j.Logger;
sDateFrom = objValues[0].toString(); sDateTo = objValues[1].toString(); sPercent = objValues[2].toString(); dateFrom = Date.valueOf(sDateFrom); dateTo = Date.valueOf(sDateTo); if( dateFrom.getTime() > dateTo.getTime()) { JOptionPane.showMessageDialog(this,"From date has a higher value than To date.","Invalid field",JOptionPane.ERROR_MESSAGE); return false; } temp = Integer.valueOf(sPercent); percent+=temp; } catch(Exception e) { logger.warn("Error retrieving data from table",e); JOptionPane.showMessageDialog(this,"Values in the table should be dates (from,to) or numerical (percent.).","Invalid field",JOptionPane.ERROR_MESSAGE); return false; } } if(percent!=100) { JOptionPane.showMessageDialog(this,"Percentages in the table should add up to 100.","Invalid field",JOptionPane.ERROR_MESSAGE); return false; } return true; }
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // // Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // Path: src/main/java/generator/panels/PanelSQLDateRandomiser.java import generator.extenders.RandomiserInstance; import generator.extenders.RandomiserPanel; import java.net.URL; import java.sql.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JCheckBox; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import org.apache.log4j.Logger; sDateFrom = objValues[0].toString(); sDateTo = objValues[1].toString(); sPercent = objValues[2].toString(); dateFrom = Date.valueOf(sDateFrom); dateTo = Date.valueOf(sDateTo); if( dateFrom.getTime() > dateTo.getTime()) { JOptionPane.showMessageDialog(this,"From date has a higher value than To date.","Invalid field",JOptionPane.ERROR_MESSAGE); return false; } temp = Integer.valueOf(sPercent); percent+=temp; } catch(Exception e) { logger.warn("Error retrieving data from table",e); JOptionPane.showMessageDialog(this,"Values in the table should be dates (from,to) or numerical (percent.).","Invalid field",JOptionPane.ERROR_MESSAGE); return false; } } if(percent!=100) { JOptionPane.showMessageDialog(this,"Percentages in the table should add up to 100.","Invalid field",JOptionPane.ERROR_MESSAGE); return false; } return true; }
public RandomiserInstance getRandomiserInstance()
gruter/utogen
src/main/java/com/gruter/generator/randomisers/DBColumnRandomiser.java
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // }
import generator.extenders.IRandomiserFunctionality; import generator.extenders.RandomiserInstance; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Random; import org.apache.log4j.Logger;
package com.gruter.generator.randomisers; public class DBColumnRandomiser implements IRandomiserFunctionality { Logger logger = Logger.getLogger(DBColumnRandomiser.class); private String driver; private String connUrl; private String userId; private String password; private String query; private int maxItems; List<String> items = new ArrayList<String>(); int itemSize; Random random; @Override public void destroy() { } @Override public Object generate() { return items.get(random.nextInt(itemSize)); } @SuppressWarnings("unchecked") @Override
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // Path: src/main/java/com/gruter/generator/randomisers/DBColumnRandomiser.java import generator.extenders.IRandomiserFunctionality; import generator.extenders.RandomiserInstance; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Random; import org.apache.log4j.Logger; package com.gruter.generator.randomisers; public class DBColumnRandomiser implements IRandomiserFunctionality { Logger logger = Logger.getLogger(DBColumnRandomiser.class); private String driver; private String connUrl; private String userId; private String password; private String query; private int maxItems; List<String> items = new ArrayList<String>(); int itemSize; Random random; @Override public void destroy() { } @Override public Object generate() { return items.get(random.nextInt(itemSize)); } @SuppressWarnings("unchecked") @Override
public void setRandomiserInstance(RandomiserInstance ri) {
gruter/utogen
src/main/java/generator/panels/PanelSQLTimestampRandomiser.java
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // // Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // }
import generator.extenders.RandomiserInstance; import generator.extenders.RandomiserPanel; import java.sql.Timestamp; import java.net.URL; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JCheckBox; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import org.apache.log4j.Logger;
if( dateFrom.getTime() > dateTo.getTime()) { JOptionPane.showMessageDialog(this,"From date has a higher value than To date.","Invalid field",JOptionPane.ERROR_MESSAGE); return false; } temp = Integer.valueOf(sPercent); percent+=temp; } catch(Exception e) { logger.warn("Error retrieving data from table",e); JOptionPane.showMessageDialog(this,"Values in the table should be dates (from,to) or numerical (percent.).","Invalid field",JOptionPane.ERROR_MESSAGE); return false; } } if(percent!=100) { JOptionPane.showMessageDialog(this,"Percentages in the table should add up to 100.","Invalid data",JOptionPane.ERROR_MESSAGE); return false; } for(int i=0; i<7; i++) { } return true; }
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // // Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // Path: src/main/java/generator/panels/PanelSQLTimestampRandomiser.java import generator.extenders.RandomiserInstance; import generator.extenders.RandomiserPanel; import java.sql.Timestamp; import java.net.URL; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JCheckBox; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import org.apache.log4j.Logger; if( dateFrom.getTime() > dateTo.getTime()) { JOptionPane.showMessageDialog(this,"From date has a higher value than To date.","Invalid field",JOptionPane.ERROR_MESSAGE); return false; } temp = Integer.valueOf(sPercent); percent+=temp; } catch(Exception e) { logger.warn("Error retrieving data from table",e); JOptionPane.showMessageDialog(this,"Values in the table should be dates (from,to) or numerical (percent.).","Invalid field",JOptionPane.ERROR_MESSAGE); return false; } } if(percent!=100) { JOptionPane.showMessageDialog(this,"Percentages in the table should add up to 100.","Invalid data",JOptionPane.ERROR_MESSAGE); return false; } for(int i=0; i<7; i++) { } return true; }
public RandomiserInstance getRandomiserInstance()
gruter/utogen
src/main/java/generator/misc/ApplicationContext.java
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // }
import generator.db.SQLJavaMapping; import generator.extenders.RandomiserInstance; import java.util.Vector;
/* * ApplicationContext.java * * Created on 09 June 2007, 02:37 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package generator.misc; /** * * @author Michael */ public class ApplicationContext { private static ApplicationContext context = null;
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // Path: src/main/java/generator/misc/ApplicationContext.java import generator.db.SQLJavaMapping; import generator.extenders.RandomiserInstance; import java.util.Vector; /* * ApplicationContext.java * * Created on 09 June 2007, 02:37 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package generator.misc; /** * * @author Michael */ public class ApplicationContext { private static ApplicationContext context = null;
private static Vector<RandomiserInstance> vRI;
gruter/utogen
src/main/java/generator/panels/PanelSQLTimeRandomiser.java
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // // Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // }
import generator.extenders.RandomiserInstance; import generator.extenders.RandomiserPanel; import java.net.URL; import java.sql.Time; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import org.apache.log4j.Logger;
if( dateFrom.getTime() > dateTo.getTime()) { JOptionPane.showMessageDialog(this,"From date has a higher value than To date.","Invalid data",JOptionPane.ERROR_MESSAGE); return false; } temp = Integer.valueOf(sPercent); percent+=temp; } catch(Exception e) { logger.warn("Error retrieving data from table",e); JOptionPane.showMessageDialog(this,"Values in the table should be dates (from,to) or numerical (percent.).","Invalid field",JOptionPane.ERROR_MESSAGE); return false; } } if(percent!=100) { JOptionPane.showMessageDialog(this,"Percentages in the table should add up to 100.","Invalid data",JOptionPane.ERROR_MESSAGE); return false; } for(int i=0; i<7; i++) { } return true; }
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // // Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // Path: src/main/java/generator/panels/PanelSQLTimeRandomiser.java import generator.extenders.RandomiserInstance; import generator.extenders.RandomiserPanel; import java.net.URL; import java.sql.Time; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import org.apache.log4j.Logger; if( dateFrom.getTime() > dateTo.getTime()) { JOptionPane.showMessageDialog(this,"From date has a higher value than To date.","Invalid data",JOptionPane.ERROR_MESSAGE); return false; } temp = Integer.valueOf(sPercent); percent+=temp; } catch(Exception e) { logger.warn("Error retrieving data from table",e); JOptionPane.showMessageDialog(this,"Values in the table should be dates (from,to) or numerical (percent.).","Invalid field",JOptionPane.ERROR_MESSAGE); return false; } } if(percent!=100) { JOptionPane.showMessageDialog(this,"Percentages in the table should add up to 100.","Invalid data",JOptionPane.ERROR_MESSAGE); return false; } for(int i=0; i<7; i++) { } return true; }
public RandomiserInstance getRandomiserInstance()
gruter/utogen
src/main/java/generator/panels/PanelListItemsSequencer.java
// Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // // Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // }
import java.io.File; import java.net.URL; import java.util.HashMap; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import org.apache.log4j.Logger; import generator.extenders.RandomiserPanel; import generator.extenders.IGeneratorPanel; import generator.extenders.RandomiserInstance;
package generator.panels; public class PanelListItemsSequencer extends RandomiserPanel { Logger logger = Logger.getLogger(PanelListItemsSequencer.class); /** Creates new form PanelDoubleGenerator */ /** Creates new form PanelListItemGenerator */ public PanelListItemsSequencer() { initComponents(); radFile.setSelected(true); newModel.addColumn("Item"); tblItems.setModel(newModel); enableList(false); loadButtonImages(); } private void loadButtonImages() { URL urlAdd = this.getClass().getClassLoader().getResource("resources/images/list-add-small.png"); URL urlRemSelect = this.getClass().getClassLoader().getResource("resources/images/list-remove-small.png"); URL urlBrowse = this.getClass().getClassLoader().getResource("resources/images/document-open-small.png"); btnAddItem.setIcon(new ImageIcon(urlAdd)); btnRemove.setIcon(new ImageIcon(urlRemSelect)); btnBrowse.setIcon(new ImageIcon(urlBrowse)); } public boolean isFormValid() { String name; String fname, temp; int percent, ival; Integer intValue; name = txtName.getText().trim(); //run checks if(name.length()==0) { JOptionPane.showMessageDialog(this,"Please provide a value for the name.","Required field",JOptionPane.ERROR_MESSAGE); return false; } if(radFile.isSelected()) { fname = txtFilename.getText().trim(); if(fname.length()==0) { JOptionPane.showMessageDialog(this,"Please provide a value for the filename.","Required field",JOptionPane.ERROR_MESSAGE); return false; } } if(radList.isSelected()) { int listCount = newModel.getRowCount(); if(listCount<1) { JOptionPane.showMessageDialog(this,"Please provide at least two items.","Required fields",JOptionPane.ERROR_MESSAGE); return false; } } return true; }
// Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // // Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // Path: src/main/java/generator/panels/PanelListItemsSequencer.java import java.io.File; import java.net.URL; import java.util.HashMap; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import org.apache.log4j.Logger; import generator.extenders.RandomiserPanel; import generator.extenders.IGeneratorPanel; import generator.extenders.RandomiserInstance; package generator.panels; public class PanelListItemsSequencer extends RandomiserPanel { Logger logger = Logger.getLogger(PanelListItemsSequencer.class); /** Creates new form PanelDoubleGenerator */ /** Creates new form PanelListItemGenerator */ public PanelListItemsSequencer() { initComponents(); radFile.setSelected(true); newModel.addColumn("Item"); tblItems.setModel(newModel); enableList(false); loadButtonImages(); } private void loadButtonImages() { URL urlAdd = this.getClass().getClassLoader().getResource("resources/images/list-add-small.png"); URL urlRemSelect = this.getClass().getClassLoader().getResource("resources/images/list-remove-small.png"); URL urlBrowse = this.getClass().getClassLoader().getResource("resources/images/document-open-small.png"); btnAddItem.setIcon(new ImageIcon(urlAdd)); btnRemove.setIcon(new ImageIcon(urlRemSelect)); btnBrowse.setIcon(new ImageIcon(urlBrowse)); } public boolean isFormValid() { String name; String fname, temp; int percent, ival; Integer intValue; name = txtName.getText().trim(); //run checks if(name.length()==0) { JOptionPane.showMessageDialog(this,"Please provide a value for the name.","Required field",JOptionPane.ERROR_MESSAGE); return false; } if(radFile.isSelected()) { fname = txtFilename.getText().trim(); if(fname.length()==0) { JOptionPane.showMessageDialog(this,"Please provide a value for the filename.","Required field",JOptionPane.ERROR_MESSAGE); return false; } } if(radList.isSelected()) { int listCount = newModel.getRowCount(); if(listCount<1) { JOptionPane.showMessageDialog(this,"Please provide at least two items.","Required fields",JOptionPane.ERROR_MESSAGE); return false; } } return true; }
public RandomiserInstance getRandomiserInstance()
gruter/utogen
src/main/java/generator/panels/PanelEmailRandomiser.java
// Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // // Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // }
import javax.swing.JOptionPane; import generator.extenders.RandomiserPanel; import generator.extenders.RandomiserInstance; import java.util.LinkedHashMap;
} } if(lnameSeed!=null) { try { seed = Integer.parseInt(lnameSeed); } catch(Exception e) { JOptionPane.showMessageDialog(this,"Please provide a numerical value for the seed.","Invalid field",JOptionPane.ERROR_MESSAGE); return false; } } //run checks if(name.length()==0) { JOptionPane.showMessageDialog(this,"Please provide a value for the name.","Required field",JOptionPane.ERROR_MESSAGE); return false; } if( nullField<0 || nullField>100 ) { JOptionPane.showMessageDialog(this,"Please provide a value in the range [0..100] for the Null field.","Invalid field",JOptionPane.ERROR_MESSAGE); return false; } return true; }
// Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // // Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // Path: src/main/java/generator/panels/PanelEmailRandomiser.java import javax.swing.JOptionPane; import generator.extenders.RandomiserPanel; import generator.extenders.RandomiserInstance; import java.util.LinkedHashMap; } } if(lnameSeed!=null) { try { seed = Integer.parseInt(lnameSeed); } catch(Exception e) { JOptionPane.showMessageDialog(this,"Please provide a numerical value for the seed.","Invalid field",JOptionPane.ERROR_MESSAGE); return false; } } //run checks if(name.length()==0) { JOptionPane.showMessageDialog(this,"Please provide a value for the name.","Required field",JOptionPane.ERROR_MESSAGE); return false; } if( nullField<0 || nullField>100 ) { JOptionPane.showMessageDialog(this,"Please provide a value in the range [0..100] for the Null field.","Invalid field",JOptionPane.ERROR_MESSAGE); return false; } return true; }
public RandomiserInstance getRandomiserInstance()
gruter/utogen
src/main/java/generator/panels/PanelNumShortRandomiser.java
// Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // // Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // }
import java.net.URL; import java.util.HashMap; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import org.apache.log4j.Logger; import generator.extenders.RandomiserPanel; import generator.extenders.RandomiserInstance;
try {srtValues[1] = new Short(sTo);} catch(Exception e) {error=2;} try {srtValues[2] = new Short(sPercent);} catch(Exception e) {error=3;} if(srtValues[0].shortValue()>srtValues[1].shortValue()) { JOptionPane.showMessageDialog(this,"From value should be lower than to value.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(error>0) { JOptionPane.showMessageDialog(this,"Values for the fields From, To, Percentage should be numeric.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(srtValues[2].shortValue()<=0) { JOptionPane.showMessageDialog(this,"Percentage field should be a positive integer.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } newModel.addRow(srtValues); }//GEN-LAST:event_btnAddActionPerformed
// Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // // Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // Path: src/main/java/generator/panels/PanelNumShortRandomiser.java import java.net.URL; import java.util.HashMap; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import org.apache.log4j.Logger; import generator.extenders.RandomiserPanel; import generator.extenders.RandomiserInstance; try {srtValues[1] = new Short(sTo);} catch(Exception e) {error=2;} try {srtValues[2] = new Short(sPercent);} catch(Exception e) {error=3;} if(srtValues[0].shortValue()>srtValues[1].shortValue()) { JOptionPane.showMessageDialog(this,"From value should be lower than to value.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(error>0) { JOptionPane.showMessageDialog(this,"Values for the fields From, To, Percentage should be numeric.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(srtValues[2].shortValue()<=0) { JOptionPane.showMessageDialog(this,"Percentage field should be a positive integer.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } newModel.addRow(srtValues); }//GEN-LAST:event_btnAddActionPerformed
public void initialise(RandomiserInstance ri)
gruter/utogen
src/main/java/com/gruter/generator/randomisers/ExpressionRandomiser.java
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // }
import generator.extenders.IRandomiserFunctionality; import generator.extenders.RandomiserInstance; import java.util.Random;
package com.gruter.generator.randomisers; public class ExpressionRandomiser implements IRandomiserFunctionality { @Override public void destroy() { } @Override public Object generate() { return ""; } @Override
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // Path: src/main/java/com/gruter/generator/randomisers/ExpressionRandomiser.java import generator.extenders.IRandomiserFunctionality; import generator.extenders.RandomiserInstance; import java.util.Random; package com.gruter.generator.randomisers; public class ExpressionRandomiser implements IRandomiserFunctionality { @Override public void destroy() { } @Override public Object generate() { return ""; } @Override
public void setRandomiserInstance(RandomiserInstance ri) {
gruter/utogen
src/main/java/generator/misc/RandomInstanceSaver.java
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // }
import java.util.LinkedHashMap; import java.util.Set; import java.util.Vector; import generator.extenders.RandomiserInstance; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; import org.apache.log4j.Logger;
/* * dgMaster: A versatile, open source data generator. *(c) 2007 M. Michalakopoulos, mmichalak@gmail.com */ package generator.misc; /** * * Saves a random-instances vector in Repository.xml * When a collection of new classes needs to be saved in an XML file, * a similar class will have to be provided and the saveData method * will have to be called. It is hard to convert these classes into some kind * of design pattern, because each class will actually provide its own XML structure. */ public class RandomInstanceSaver { private Logger logger = Logger.getLogger(RandomInstanceSaver.class); private XMLSaver xmlSaver; private Document dom=null; private Element root; /** * Saves the data to the XML file. This is the method that the caller will * actually call to save the RandomiserInstance data. * * <p> Preconditions: Vector contains valid RandomiserInstance objects * <p> Post-effects: Contents of vector are saved in Repository.xml * CAUTION: Any actual data existing in file will be overwritten!!! * * @param vData a Vector of RandomiserInstance objects to be saved in file Repository.xml */
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // Path: src/main/java/generator/misc/RandomInstanceSaver.java import java.util.LinkedHashMap; import java.util.Set; import java.util.Vector; import generator.extenders.RandomiserInstance; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; import org.apache.log4j.Logger; /* * dgMaster: A versatile, open source data generator. *(c) 2007 M. Michalakopoulos, mmichalak@gmail.com */ package generator.misc; /** * * Saves a random-instances vector in Repository.xml * When a collection of new classes needs to be saved in an XML file, * a similar class will have to be provided and the saveData method * will have to be called. It is hard to convert these classes into some kind * of design pattern, because each class will actually provide its own XML structure. */ public class RandomInstanceSaver { private Logger logger = Logger.getLogger(RandomInstanceSaver.class); private XMLSaver xmlSaver; private Document dom=null; private Element root; /** * Saves the data to the XML file. This is the method that the caller will * actually call to save the RandomiserInstance data. * * <p> Preconditions: Vector contains valid RandomiserInstance objects * <p> Post-effects: Contents of vector are saved in Repository.xml * CAUTION: Any actual data existing in file will be overwritten!!! * * @param vData a Vector of RandomiserInstance objects to be saved in file Repository.xml */
public void saveData(Vector<RandomiserInstance> vData)
gruter/utogen
src/main/java/com/gruter/generator/randomisers/PanelDBColumnRandomiser.java
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // // Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // }
import generator.extenders.RandomiserInstance; import generator.extenders.RandomiserPanel; import java.util.LinkedHashMap; import javax.swing.JOptionPane; import org.apache.log4j.Logger;
return false; } if (txtConnUrl.getText().trim().length() == 0) { JOptionPane.showMessageDialog(this, "Please provide a value for the conn url", "Required field", JOptionPane.ERROR_MESSAGE); return false; } if (txtUserId.getText().trim().length() == 0) { JOptionPane.showMessageDialog(this, "Please provide a value for the conn user id", "Required field", JOptionPane.ERROR_MESSAGE); return false; } if (txtPassword.getText().trim().length() == 0) { JOptionPane.showMessageDialog(this, "Please provide a value for the password", "Required field", JOptionPane.ERROR_MESSAGE); return false; } if (txtQuery.getText().trim().length() == 0) { JOptionPane.showMessageDialog(this, "Please provide a value for the query", "Required field", JOptionPane.ERROR_MESSAGE); return false; } return true; }
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // // Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // Path: src/main/java/com/gruter/generator/randomisers/PanelDBColumnRandomiser.java import generator.extenders.RandomiserInstance; import generator.extenders.RandomiserPanel; import java.util.LinkedHashMap; import javax.swing.JOptionPane; import org.apache.log4j.Logger; return false; } if (txtConnUrl.getText().trim().length() == 0) { JOptionPane.showMessageDialog(this, "Please provide a value for the conn url", "Required field", JOptionPane.ERROR_MESSAGE); return false; } if (txtUserId.getText().trim().length() == 0) { JOptionPane.showMessageDialog(this, "Please provide a value for the conn user id", "Required field", JOptionPane.ERROR_MESSAGE); return false; } if (txtPassword.getText().trim().length() == 0) { JOptionPane.showMessageDialog(this, "Please provide a value for the password", "Required field", JOptionPane.ERROR_MESSAGE); return false; } if (txtQuery.getText().trim().length() == 0) { JOptionPane.showMessageDialog(this, "Please provide a value for the query", "Required field", JOptionPane.ERROR_MESSAGE); return false; } return true; }
public RandomiserInstance getRandomiserInstance() {
gruter/utogen
src/main/java/generator/misc/RandomInstanceSAXHandler.java
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // }
import java.util.LinkedHashMap; import java.util.Vector; import org.apache.log4j.Logger; import generator.extenders.RandomiserInstance; import org.xml.sax.Attributes; import org.xml.sax.SAXException;
/* * dgMaster: A versatile, open source data generator. *(c) 2007 M. Michalakopoulos, mmichalak@gmail.com */ package generator.misc; /** * * Handles the input of an XML file which represents the definitions * for a user defined random instnace (RandomiserInstance). * Data are loaded in the initial loading of the application. */ public class RandomInstanceSAXHandler extends SAXDataHandler { private Logger logger = Logger.getLogger(RandomInstanceSAXHandler.class);
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // Path: src/main/java/generator/misc/RandomInstanceSAXHandler.java import java.util.LinkedHashMap; import java.util.Vector; import org.apache.log4j.Logger; import generator.extenders.RandomiserInstance; import org.xml.sax.Attributes; import org.xml.sax.SAXException; /* * dgMaster: A versatile, open source data generator. *(c) 2007 M. Michalakopoulos, mmichalak@gmail.com */ package generator.misc; /** * * Handles the input of an XML file which represents the definitions * for a user defined random instnace (RandomiserInstance). * Data are loaded in the initial loading of the application. */ public class RandomInstanceSAXHandler extends SAXDataHandler { private Logger logger = Logger.getLogger(RandomInstanceSAXHandler.class);
private Vector<RandomiserInstance> vRandomInstances;
gruter/utogen
src/main/java/com/gruter/generator/randomisers/PanelExpressionRandomiser.java
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // // Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // }
import java.util.LinkedHashMap; import javax.swing.JOptionPane; import generator.extenders.RandomiserInstance; import generator.extenders.RandomiserPanel; import org.apache.log4j.Logger;
); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(10, 10, 10) .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addContainerGap(101, Short.MAX_VALUE)) ); }// </editor-fold> public boolean isFormValid() { if (txtName.getText().trim().length() == 0) { JOptionPane.showMessageDialog(this, "Please provide a value for the name", "Required field", JOptionPane.ERROR_MESSAGE); return false; } return true; }
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // // Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // Path: src/main/java/com/gruter/generator/randomisers/PanelExpressionRandomiser.java import java.util.LinkedHashMap; import javax.swing.JOptionPane; import generator.extenders.RandomiserInstance; import generator.extenders.RandomiserPanel; import org.apache.log4j.Logger; ); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(10, 10, 10) .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addContainerGap(101, Short.MAX_VALUE)) ); }// </editor-fold> public boolean isFormValid() { if (txtName.getText().trim().length() == 0) { JOptionPane.showMessageDialog(this, "Please provide a value for the name", "Required field", JOptionPane.ERROR_MESSAGE); return false; } return true; }
public RandomiserInstance getRandomiserInstance() {
gruter/utogen
src/main/java/generator/panels/PanelNumFloatRandomiser.java
// Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // // Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // }
import java.net.URL; import java.util.HashMap; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JOptionPane.*; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import org.apache.log4j.Logger; import generator.extenders.RandomiserPanel; import generator.extenders.RandomiserInstance;
{fltlValues[1] = new Float(sTo);} catch(Exception e) {error=2;} try {fltlValues[2] = new Float(sPercent);} catch(Exception e) {error=3;} if(error>0) { JOptionPane.showMessageDialog(this,"Values for the fields From, To, Percentage should be numeric.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(fltlValues[0].floatValue()>fltlValues[1].floatValue()) { JOptionPane.showMessageDialog(this,"From value should be lower than to value.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(fltlValues[2].floatValue()<=0) { JOptionPane.showMessageDialog(this,"Percentage field should be a positive integer.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } newModel.addRow(fltlValues); }//GEN-LAST:event_btnAddActionPerformed
// Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // // Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // Path: src/main/java/generator/panels/PanelNumFloatRandomiser.java import java.net.URL; import java.util.HashMap; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JOptionPane.*; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import org.apache.log4j.Logger; import generator.extenders.RandomiserPanel; import generator.extenders.RandomiserInstance; {fltlValues[1] = new Float(sTo);} catch(Exception e) {error=2;} try {fltlValues[2] = new Float(sPercent);} catch(Exception e) {error=3;} if(error>0) { JOptionPane.showMessageDialog(this,"Values for the fields From, To, Percentage should be numeric.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(fltlValues[0].floatValue()>fltlValues[1].floatValue()) { JOptionPane.showMessageDialog(this,"From value should be lower than to value.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } if(fltlValues[2].floatValue()<=0) { JOptionPane.showMessageDialog(this,"Percentage field should be a positive integer.","Invalid field",JOptionPane.ERROR_MESSAGE); return; } newModel.addRow(fltlValues); }//GEN-LAST:event_btnAddActionPerformed
public void initialise(RandomiserInstance ri)
gruter/utogen
src/main/java/generator/panels/PanelDateRandomiser.java
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // // Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // }
import generator.extenders.RandomiserInstance; import generator.extenders.RandomiserPanel; import java.net.URL; import java.sql.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JCheckBox; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import org.apache.log4j.Logger;
objValues[0] = (Object) newModel.getValueAt(i, 0); objValues[1] = (Object) newModel.getValueAt(i, 1); objValues[2] = (Object) newModel.getValueAt(i, 2); sDateFrom = objValues[0].toString(); sDateTo = objValues[1].toString(); sPercent = objValues[2].toString(); dateFrom = Date.valueOf(sDateFrom); dateTo = Date.valueOf(sDateTo); if (dateFrom.getTime() > dateTo.getTime()) { JOptionPane.showMessageDialog(this, "From date has a higher value than To date.", "Invalid field", JOptionPane.ERROR_MESSAGE); return false; } temp = Integer.valueOf(sPercent); percent += temp; } catch (Exception e) { logger.warn("Error retrieving data from table", e); JOptionPane .showMessageDialog(this, "Values in the table should be dates (from,to) or numerical (percent.).", "Invalid data", JOptionPane.ERROR_MESSAGE); return false; } } if (percent != 100) { JOptionPane.showMessageDialog(this, "Percentages in the table should add up to 100.", "Invalid data", JOptionPane.ERROR_MESSAGE); return false; } return true; }
// Path: src/main/java/generator/extenders/RandomiserInstance.java // public class RandomiserInstance // { // //the name of the randomiser type to load // private String randomiserType; // // //name and description are standard fields for all the user-defined cases. // private String name; // private String description; // // //any object can be stored in the properties hashmap, however, it will be // //its String representation that will be saved in the XML file. // private LinkedHashMap properties; // // // public RandomiserInstance() // { // } // // // public RandomiserInstance( String randomiserType, // String name, // String description, // LinkedHashMap properties) // { // this.randomiserType = randomiserType; // this.name = name; // this.description = description; // this.properties = properties; // } // // // public String getRandomiserType() // { // return randomiserType; // } // // public void setRandomiserType(String randomiserType) // { // this.randomiserType = randomiserType; // } // // public String getName() // { // return name; // } // // public void setName(String name) // { // this.name = name; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public LinkedHashMap getProperties() // { // return properties; // } // // public void setProperties(LinkedHashMap properties) // { // this.properties = properties; // } // // public String toString() // { // return name; // } // } // // Path: src/main/java/generator/extenders/RandomiserPanel.java // public abstract class RandomiserPanel extends JPanel implements IGeneratorPanel // { // // // } // Path: src/main/java/generator/panels/PanelDateRandomiser.java import generator.extenders.RandomiserInstance; import generator.extenders.RandomiserPanel; import java.net.URL; import java.sql.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.LinkedHashMap; import javax.swing.ImageIcon; import javax.swing.JCheckBox; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import org.apache.log4j.Logger; objValues[0] = (Object) newModel.getValueAt(i, 0); objValues[1] = (Object) newModel.getValueAt(i, 1); objValues[2] = (Object) newModel.getValueAt(i, 2); sDateFrom = objValues[0].toString(); sDateTo = objValues[1].toString(); sPercent = objValues[2].toString(); dateFrom = Date.valueOf(sDateFrom); dateTo = Date.valueOf(sDateTo); if (dateFrom.getTime() > dateTo.getTime()) { JOptionPane.showMessageDialog(this, "From date has a higher value than To date.", "Invalid field", JOptionPane.ERROR_MESSAGE); return false; } temp = Integer.valueOf(sPercent); percent += temp; } catch (Exception e) { logger.warn("Error retrieving data from table", e); JOptionPane .showMessageDialog(this, "Values in the table should be dates (from,to) or numerical (percent.).", "Invalid data", JOptionPane.ERROR_MESSAGE); return false; } } if (percent != 100) { JOptionPane.showMessageDialog(this, "Percentages in the table should add up to 100.", "Invalid data", JOptionPane.ERROR_MESSAGE); return false; } return true; }
public RandomiserInstance getRandomiserInstance() {
aliyun-beta/aliyun-jclouds
aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/SLBLoadBalancerServiceAdapter.java
// Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/SLBApi.java // public interface SLBApi extends Closeable { // // static final String DEFAULT_REGION = "cn-hangzhou"; // // IAcsClient getAcsClient(String region); // // Set<String> getAvailableRegions(); // // String encodeToId(String region, String id); // // String decodeToRegion(String id); // // String decodeToId(String id); // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java // public class LoadBalancerToLoadBalancerMetadata implements Function<LoadBalancer, LoadBalancerMetadata> { // // @Resource // @Named(LoadBalancerConstants.LOADBALANCER_LOGGER) // protected Logger logger = Logger.NULL; // // protected final IAcsClient client; // protected final Map<String, LoadBalancerType> loadBalancerTypes; // // public LoadBalancerToLoadBalancerMetadata( // IAcsClient client, // Map<String, LoadBalancerType> loadBalancerTypes) { // this.client = client; // this.loadBalancerTypes = loadBalancerTypes; // } // // @Override // public LoadBalancerMetadata apply(LoadBalancer input) { // DescribeLoadBalancerAttributeRequest req = new DescribeLoadBalancerAttributeRequest(); // req.setLoadBalancerId(input.getLoadBalancerId()); // DescribeLoadBalancerAttributeResponse resp = null; // try { // resp = client.getAcsResponse(req); // } catch (Exception e) { // logger.warn(e.getMessage()); // } // LocationBuilder location = new LocationBuilder() // .scope(LocationScope.REGION) // .id(resp.getRegionId()) // .description(resp.getRegionId()); // return new LoadBalancerMetadataImpl( // loadBalancerTypes.get(resp.getAddressType()), // input.getLoadBalancerId(), // input.getLoadBalancerName(), // input.getLoadBalancerId(), // location.build(), // null, // ImmutableMap.<String, String>builder().build(), // ImmutableSet.<String> builder().add(resp.getAddress()).build()); // } // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/functions/RegionToLocation.java // public class RegionToLocation implements Function<String, Location> { // // @Override // public Location apply(String input) { // LocationBuilder builder = new LocationBuilder(); // builder.scope(LocationScope.REGION); // builder.id(input); // builder.description(input); // return builder.build(); // } // }
import static com.google.common.collect.Iterables.transform; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; import org.jclouds.aliyun.slb.SLBApi; import org.jclouds.aliyun.slb.loadbalancer.functions.LoadBalancerToLoadBalancerMetadata; import org.jclouds.aliyun.slb.loadbalancer.functions.RegionToLocation; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; import org.jclouds.domain.LocationScope; import org.jclouds.loadbalancer.LoadBalancerServiceAdapter; import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; import org.jclouds.loadbalancer.domain.LoadBalancerType; import org.jclouds.loadbalancer.domain.internal.LoadBalancerMetadataImpl; import org.jclouds.loadbalancer.reference.LoadBalancerConstants; import org.jclouds.logging.Logger; import com.aliyuncs.IAcsClient; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerRequest; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerResponse; import com.aliyuncs.slb.model.v20140515.DeleteLoadBalancerRequest; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancerAttributeRequest; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancerAttributeResponse; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancersRequest; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancersResponse.LoadBalancer; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet.Builder;
package org.jclouds.aliyun.slb.loadbalancer; public class SLBLoadBalancerServiceAdapter implements LoadBalancerServiceAdapter<LoadBalancerMetadata, Location> { @Resource @Named(LoadBalancerConstants.LOADBALANCER_LOGGER) protected Logger logger = Logger.NULL;
// Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/SLBApi.java // public interface SLBApi extends Closeable { // // static final String DEFAULT_REGION = "cn-hangzhou"; // // IAcsClient getAcsClient(String region); // // Set<String> getAvailableRegions(); // // String encodeToId(String region, String id); // // String decodeToRegion(String id); // // String decodeToId(String id); // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java // public class LoadBalancerToLoadBalancerMetadata implements Function<LoadBalancer, LoadBalancerMetadata> { // // @Resource // @Named(LoadBalancerConstants.LOADBALANCER_LOGGER) // protected Logger logger = Logger.NULL; // // protected final IAcsClient client; // protected final Map<String, LoadBalancerType> loadBalancerTypes; // // public LoadBalancerToLoadBalancerMetadata( // IAcsClient client, // Map<String, LoadBalancerType> loadBalancerTypes) { // this.client = client; // this.loadBalancerTypes = loadBalancerTypes; // } // // @Override // public LoadBalancerMetadata apply(LoadBalancer input) { // DescribeLoadBalancerAttributeRequest req = new DescribeLoadBalancerAttributeRequest(); // req.setLoadBalancerId(input.getLoadBalancerId()); // DescribeLoadBalancerAttributeResponse resp = null; // try { // resp = client.getAcsResponse(req); // } catch (Exception e) { // logger.warn(e.getMessage()); // } // LocationBuilder location = new LocationBuilder() // .scope(LocationScope.REGION) // .id(resp.getRegionId()) // .description(resp.getRegionId()); // return new LoadBalancerMetadataImpl( // loadBalancerTypes.get(resp.getAddressType()), // input.getLoadBalancerId(), // input.getLoadBalancerName(), // input.getLoadBalancerId(), // location.build(), // null, // ImmutableMap.<String, String>builder().build(), // ImmutableSet.<String> builder().add(resp.getAddress()).build()); // } // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/functions/RegionToLocation.java // public class RegionToLocation implements Function<String, Location> { // // @Override // public Location apply(String input) { // LocationBuilder builder = new LocationBuilder(); // builder.scope(LocationScope.REGION); // builder.id(input); // builder.description(input); // return builder.build(); // } // } // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/SLBLoadBalancerServiceAdapter.java import static com.google.common.collect.Iterables.transform; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; import org.jclouds.aliyun.slb.SLBApi; import org.jclouds.aliyun.slb.loadbalancer.functions.LoadBalancerToLoadBalancerMetadata; import org.jclouds.aliyun.slb.loadbalancer.functions.RegionToLocation; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; import org.jclouds.domain.LocationScope; import org.jclouds.loadbalancer.LoadBalancerServiceAdapter; import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; import org.jclouds.loadbalancer.domain.LoadBalancerType; import org.jclouds.loadbalancer.domain.internal.LoadBalancerMetadataImpl; import org.jclouds.loadbalancer.reference.LoadBalancerConstants; import org.jclouds.logging.Logger; import com.aliyuncs.IAcsClient; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerRequest; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerResponse; import com.aliyuncs.slb.model.v20140515.DeleteLoadBalancerRequest; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancerAttributeRequest; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancerAttributeResponse; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancersRequest; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancersResponse.LoadBalancer; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet.Builder; package org.jclouds.aliyun.slb.loadbalancer; public class SLBLoadBalancerServiceAdapter implements LoadBalancerServiceAdapter<LoadBalancerMetadata, Location> { @Resource @Named(LoadBalancerConstants.LOADBALANCER_LOGGER) protected Logger logger = Logger.NULL;
protected final SLBApi api;
aliyun-beta/aliyun-jclouds
aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/SLBLoadBalancerServiceAdapter.java
// Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/SLBApi.java // public interface SLBApi extends Closeable { // // static final String DEFAULT_REGION = "cn-hangzhou"; // // IAcsClient getAcsClient(String region); // // Set<String> getAvailableRegions(); // // String encodeToId(String region, String id); // // String decodeToRegion(String id); // // String decodeToId(String id); // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java // public class LoadBalancerToLoadBalancerMetadata implements Function<LoadBalancer, LoadBalancerMetadata> { // // @Resource // @Named(LoadBalancerConstants.LOADBALANCER_LOGGER) // protected Logger logger = Logger.NULL; // // protected final IAcsClient client; // protected final Map<String, LoadBalancerType> loadBalancerTypes; // // public LoadBalancerToLoadBalancerMetadata( // IAcsClient client, // Map<String, LoadBalancerType> loadBalancerTypes) { // this.client = client; // this.loadBalancerTypes = loadBalancerTypes; // } // // @Override // public LoadBalancerMetadata apply(LoadBalancer input) { // DescribeLoadBalancerAttributeRequest req = new DescribeLoadBalancerAttributeRequest(); // req.setLoadBalancerId(input.getLoadBalancerId()); // DescribeLoadBalancerAttributeResponse resp = null; // try { // resp = client.getAcsResponse(req); // } catch (Exception e) { // logger.warn(e.getMessage()); // } // LocationBuilder location = new LocationBuilder() // .scope(LocationScope.REGION) // .id(resp.getRegionId()) // .description(resp.getRegionId()); // return new LoadBalancerMetadataImpl( // loadBalancerTypes.get(resp.getAddressType()), // input.getLoadBalancerId(), // input.getLoadBalancerName(), // input.getLoadBalancerId(), // location.build(), // null, // ImmutableMap.<String, String>builder().build(), // ImmutableSet.<String> builder().add(resp.getAddress()).build()); // } // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/functions/RegionToLocation.java // public class RegionToLocation implements Function<String, Location> { // // @Override // public Location apply(String input) { // LocationBuilder builder = new LocationBuilder(); // builder.scope(LocationScope.REGION); // builder.id(input); // builder.description(input); // return builder.build(); // } // }
import static com.google.common.collect.Iterables.transform; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; import org.jclouds.aliyun.slb.SLBApi; import org.jclouds.aliyun.slb.loadbalancer.functions.LoadBalancerToLoadBalancerMetadata; import org.jclouds.aliyun.slb.loadbalancer.functions.RegionToLocation; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; import org.jclouds.domain.LocationScope; import org.jclouds.loadbalancer.LoadBalancerServiceAdapter; import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; import org.jclouds.loadbalancer.domain.LoadBalancerType; import org.jclouds.loadbalancer.domain.internal.LoadBalancerMetadataImpl; import org.jclouds.loadbalancer.reference.LoadBalancerConstants; import org.jclouds.logging.Logger; import com.aliyuncs.IAcsClient; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerRequest; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerResponse; import com.aliyuncs.slb.model.v20140515.DeleteLoadBalancerRequest; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancerAttributeRequest; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancerAttributeResponse; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancersRequest; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancersResponse.LoadBalancer; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet.Builder;
int loadBalancerPort, int instancePort, Iterable<? extends NodeMetadata> nodes) { IAcsClient client = api.getAcsClient(location.getId()); CreateLoadBalancerRequest req = new CreateLoadBalancerRequest(); req.setAddressType("intranet"); req.setLoadBalancerName(loadBalancerName); CreateLoadBalancerResponse resp = null; LoadBalancerMetadata lbm = null; try { resp = client.getAcsResponse(req); } catch (Exception e) { logger.warn(e.getMessage()); return null; } lbm = new LoadBalancerMetadataImpl( loadBalancerTypes.get(req.getAddressType()), resp.getLoadBalancerId(), resp.getLoadBalancerName(), resp.getLoadBalancerId(), location, null, ImmutableMap.<String, String>builder().build(), ImmutableSet.<String> builder().add(resp.getAddress()).build()); return lbm; } @Override public Iterable<Location> listAssignableLocations() { Builder<Location> builder = ImmutableSet.builder();
// Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/SLBApi.java // public interface SLBApi extends Closeable { // // static final String DEFAULT_REGION = "cn-hangzhou"; // // IAcsClient getAcsClient(String region); // // Set<String> getAvailableRegions(); // // String encodeToId(String region, String id); // // String decodeToRegion(String id); // // String decodeToId(String id); // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java // public class LoadBalancerToLoadBalancerMetadata implements Function<LoadBalancer, LoadBalancerMetadata> { // // @Resource // @Named(LoadBalancerConstants.LOADBALANCER_LOGGER) // protected Logger logger = Logger.NULL; // // protected final IAcsClient client; // protected final Map<String, LoadBalancerType> loadBalancerTypes; // // public LoadBalancerToLoadBalancerMetadata( // IAcsClient client, // Map<String, LoadBalancerType> loadBalancerTypes) { // this.client = client; // this.loadBalancerTypes = loadBalancerTypes; // } // // @Override // public LoadBalancerMetadata apply(LoadBalancer input) { // DescribeLoadBalancerAttributeRequest req = new DescribeLoadBalancerAttributeRequest(); // req.setLoadBalancerId(input.getLoadBalancerId()); // DescribeLoadBalancerAttributeResponse resp = null; // try { // resp = client.getAcsResponse(req); // } catch (Exception e) { // logger.warn(e.getMessage()); // } // LocationBuilder location = new LocationBuilder() // .scope(LocationScope.REGION) // .id(resp.getRegionId()) // .description(resp.getRegionId()); // return new LoadBalancerMetadataImpl( // loadBalancerTypes.get(resp.getAddressType()), // input.getLoadBalancerId(), // input.getLoadBalancerName(), // input.getLoadBalancerId(), // location.build(), // null, // ImmutableMap.<String, String>builder().build(), // ImmutableSet.<String> builder().add(resp.getAddress()).build()); // } // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/functions/RegionToLocation.java // public class RegionToLocation implements Function<String, Location> { // // @Override // public Location apply(String input) { // LocationBuilder builder = new LocationBuilder(); // builder.scope(LocationScope.REGION); // builder.id(input); // builder.description(input); // return builder.build(); // } // } // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/SLBLoadBalancerServiceAdapter.java import static com.google.common.collect.Iterables.transform; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; import org.jclouds.aliyun.slb.SLBApi; import org.jclouds.aliyun.slb.loadbalancer.functions.LoadBalancerToLoadBalancerMetadata; import org.jclouds.aliyun.slb.loadbalancer.functions.RegionToLocation; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; import org.jclouds.domain.LocationScope; import org.jclouds.loadbalancer.LoadBalancerServiceAdapter; import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; import org.jclouds.loadbalancer.domain.LoadBalancerType; import org.jclouds.loadbalancer.domain.internal.LoadBalancerMetadataImpl; import org.jclouds.loadbalancer.reference.LoadBalancerConstants; import org.jclouds.logging.Logger; import com.aliyuncs.IAcsClient; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerRequest; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerResponse; import com.aliyuncs.slb.model.v20140515.DeleteLoadBalancerRequest; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancerAttributeRequest; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancerAttributeResponse; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancersRequest; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancersResponse.LoadBalancer; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet.Builder; int loadBalancerPort, int instancePort, Iterable<? extends NodeMetadata> nodes) { IAcsClient client = api.getAcsClient(location.getId()); CreateLoadBalancerRequest req = new CreateLoadBalancerRequest(); req.setAddressType("intranet"); req.setLoadBalancerName(loadBalancerName); CreateLoadBalancerResponse resp = null; LoadBalancerMetadata lbm = null; try { resp = client.getAcsResponse(req); } catch (Exception e) { logger.warn(e.getMessage()); return null; } lbm = new LoadBalancerMetadataImpl( loadBalancerTypes.get(req.getAddressType()), resp.getLoadBalancerId(), resp.getLoadBalancerName(), resp.getLoadBalancerId(), location, null, ImmutableMap.<String, String>builder().build(), ImmutableSet.<String> builder().add(resp.getAddress()).build()); return lbm; } @Override public Iterable<Location> listAssignableLocations() { Builder<Location> builder = ImmutableSet.builder();
builder.addAll(transform(api.getAvailableRegions(), new RegionToLocation()));
aliyun-beta/aliyun-jclouds
aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/SLBLoadBalancerServiceAdapter.java
// Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/SLBApi.java // public interface SLBApi extends Closeable { // // static final String DEFAULT_REGION = "cn-hangzhou"; // // IAcsClient getAcsClient(String region); // // Set<String> getAvailableRegions(); // // String encodeToId(String region, String id); // // String decodeToRegion(String id); // // String decodeToId(String id); // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java // public class LoadBalancerToLoadBalancerMetadata implements Function<LoadBalancer, LoadBalancerMetadata> { // // @Resource // @Named(LoadBalancerConstants.LOADBALANCER_LOGGER) // protected Logger logger = Logger.NULL; // // protected final IAcsClient client; // protected final Map<String, LoadBalancerType> loadBalancerTypes; // // public LoadBalancerToLoadBalancerMetadata( // IAcsClient client, // Map<String, LoadBalancerType> loadBalancerTypes) { // this.client = client; // this.loadBalancerTypes = loadBalancerTypes; // } // // @Override // public LoadBalancerMetadata apply(LoadBalancer input) { // DescribeLoadBalancerAttributeRequest req = new DescribeLoadBalancerAttributeRequest(); // req.setLoadBalancerId(input.getLoadBalancerId()); // DescribeLoadBalancerAttributeResponse resp = null; // try { // resp = client.getAcsResponse(req); // } catch (Exception e) { // logger.warn(e.getMessage()); // } // LocationBuilder location = new LocationBuilder() // .scope(LocationScope.REGION) // .id(resp.getRegionId()) // .description(resp.getRegionId()); // return new LoadBalancerMetadataImpl( // loadBalancerTypes.get(resp.getAddressType()), // input.getLoadBalancerId(), // input.getLoadBalancerName(), // input.getLoadBalancerId(), // location.build(), // null, // ImmutableMap.<String, String>builder().build(), // ImmutableSet.<String> builder().add(resp.getAddress()).build()); // } // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/functions/RegionToLocation.java // public class RegionToLocation implements Function<String, Location> { // // @Override // public Location apply(String input) { // LocationBuilder builder = new LocationBuilder(); // builder.scope(LocationScope.REGION); // builder.id(input); // builder.description(input); // return builder.build(); // } // }
import static com.google.common.collect.Iterables.transform; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; import org.jclouds.aliyun.slb.SLBApi; import org.jclouds.aliyun.slb.loadbalancer.functions.LoadBalancerToLoadBalancerMetadata; import org.jclouds.aliyun.slb.loadbalancer.functions.RegionToLocation; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; import org.jclouds.domain.LocationScope; import org.jclouds.loadbalancer.LoadBalancerServiceAdapter; import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; import org.jclouds.loadbalancer.domain.LoadBalancerType; import org.jclouds.loadbalancer.domain.internal.LoadBalancerMetadataImpl; import org.jclouds.loadbalancer.reference.LoadBalancerConstants; import org.jclouds.logging.Logger; import com.aliyuncs.IAcsClient; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerRequest; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerResponse; import com.aliyuncs.slb.model.v20140515.DeleteLoadBalancerRequest; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancerAttributeRequest; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancerAttributeResponse; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancersRequest; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancersResponse.LoadBalancer; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet.Builder;
location.build(), null, ImmutableMap.<String, String>builder().build(), ImmutableSet.<String> builder().add(resp.getAddress()).build()); } catch (Exception e) { logger.warn(e.getMessage()); } return lbm; } @Override public void destroyLoadBalancer(String id) { IAcsClient client = api.getAcsClient(SLBApi.DEFAULT_REGION); DeleteLoadBalancerRequest req = new DeleteLoadBalancerRequest(); req.setLoadBalancerId(id); try { client.getAcsResponse(req); } catch (Exception e) { logger.warn(e.getMessage()); } } @Override public Iterable<LoadBalancerMetadata> listLoadBalancers() { Builder<LoadBalancerMetadata> builder = ImmutableSet.builder(); for (String region : api.getAvailableRegions()) { IAcsClient client = api.getAcsClient(region); DescribeLoadBalancersRequest req = new DescribeLoadBalancersRequest(); try { List<LoadBalancer> list = client.getAcsResponse(req).getLoadBalancers();
// Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/SLBApi.java // public interface SLBApi extends Closeable { // // static final String DEFAULT_REGION = "cn-hangzhou"; // // IAcsClient getAcsClient(String region); // // Set<String> getAvailableRegions(); // // String encodeToId(String region, String id); // // String decodeToRegion(String id); // // String decodeToId(String id); // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java // public class LoadBalancerToLoadBalancerMetadata implements Function<LoadBalancer, LoadBalancerMetadata> { // // @Resource // @Named(LoadBalancerConstants.LOADBALANCER_LOGGER) // protected Logger logger = Logger.NULL; // // protected final IAcsClient client; // protected final Map<String, LoadBalancerType> loadBalancerTypes; // // public LoadBalancerToLoadBalancerMetadata( // IAcsClient client, // Map<String, LoadBalancerType> loadBalancerTypes) { // this.client = client; // this.loadBalancerTypes = loadBalancerTypes; // } // // @Override // public LoadBalancerMetadata apply(LoadBalancer input) { // DescribeLoadBalancerAttributeRequest req = new DescribeLoadBalancerAttributeRequest(); // req.setLoadBalancerId(input.getLoadBalancerId()); // DescribeLoadBalancerAttributeResponse resp = null; // try { // resp = client.getAcsResponse(req); // } catch (Exception e) { // logger.warn(e.getMessage()); // } // LocationBuilder location = new LocationBuilder() // .scope(LocationScope.REGION) // .id(resp.getRegionId()) // .description(resp.getRegionId()); // return new LoadBalancerMetadataImpl( // loadBalancerTypes.get(resp.getAddressType()), // input.getLoadBalancerId(), // input.getLoadBalancerName(), // input.getLoadBalancerId(), // location.build(), // null, // ImmutableMap.<String, String>builder().build(), // ImmutableSet.<String> builder().add(resp.getAddress()).build()); // } // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/functions/RegionToLocation.java // public class RegionToLocation implements Function<String, Location> { // // @Override // public Location apply(String input) { // LocationBuilder builder = new LocationBuilder(); // builder.scope(LocationScope.REGION); // builder.id(input); // builder.description(input); // return builder.build(); // } // } // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/SLBLoadBalancerServiceAdapter.java import static com.google.common.collect.Iterables.transform; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; import org.jclouds.aliyun.slb.SLBApi; import org.jclouds.aliyun.slb.loadbalancer.functions.LoadBalancerToLoadBalancerMetadata; import org.jclouds.aliyun.slb.loadbalancer.functions.RegionToLocation; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; import org.jclouds.domain.LocationScope; import org.jclouds.loadbalancer.LoadBalancerServiceAdapter; import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; import org.jclouds.loadbalancer.domain.LoadBalancerType; import org.jclouds.loadbalancer.domain.internal.LoadBalancerMetadataImpl; import org.jclouds.loadbalancer.reference.LoadBalancerConstants; import org.jclouds.logging.Logger; import com.aliyuncs.IAcsClient; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerRequest; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerResponse; import com.aliyuncs.slb.model.v20140515.DeleteLoadBalancerRequest; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancerAttributeRequest; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancerAttributeResponse; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancersRequest; import com.aliyuncs.slb.model.v20140515.DescribeLoadBalancersResponse.LoadBalancer; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet.Builder; location.build(), null, ImmutableMap.<String, String>builder().build(), ImmutableSet.<String> builder().add(resp.getAddress()).build()); } catch (Exception e) { logger.warn(e.getMessage()); } return lbm; } @Override public void destroyLoadBalancer(String id) { IAcsClient client = api.getAcsClient(SLBApi.DEFAULT_REGION); DeleteLoadBalancerRequest req = new DeleteLoadBalancerRequest(); req.setLoadBalancerId(id); try { client.getAcsResponse(req); } catch (Exception e) { logger.warn(e.getMessage()); } } @Override public Iterable<LoadBalancerMetadata> listLoadBalancers() { Builder<LoadBalancerMetadata> builder = ImmutableSet.builder(); for (String region : api.getAvailableRegions()) { IAcsClient client = api.getAcsClient(region); DescribeLoadBalancersRequest req = new DescribeLoadBalancersRequest(); try { List<LoadBalancer> list = client.getAcsResponse(req).getLoadBalancers();
builder.addAll(transform(list, new LoadBalancerToLoadBalancerMetadata(client, loadBalancerTypes)));
aliyun-beta/aliyun-jclouds
aliyun-ecs/src/main/java/org/jclouds/aliyun/ecs/ECSApiMetadata.java
// Path: aliyun-ecs/src/main/java/org/jclouds/aliyun/ecs/compute/ECSComputeServiceContext.java // @ImplementedBy(ECSComputeServiceContextImpl.class) // public interface ECSComputeServiceContext extends ComputeServiceContext { // // @Override // ECSComputeService getComputeService(); // } // // Path: aliyun-ecs/src/main/java/org/jclouds/aliyun/ecs/compute/config/ECSComputeServiceContextModule.java // public class ECSComputeServiceContextModule extends JCloudsNativeComputeServiceAdapterContextModule { // // public ECSComputeServiceContextModule() { // super(ECSComputeServiceAdapter.class); // } // // @Override // protected void configure() { // super.configure(); // bind(ECSApi.class).to(ECSApiImpl.class); // bind(ComputeService.class).to(ECSComputeService.class); // install(new LocationsFromComputeServiceAdapterModule<NodeMetadata, Hardware, Image, Location>() {}); // } // // @Provides // @Named("ECS") // protected final TemplateOptions guiceProvideTemplateOptions(TemplateOptions options) { // return options.blockUntilRunning(false); // } // // @Provides // @Named("ECS") // protected final TemplateBuilder guiceProvideTemplateBuilder(TemplateBuilder template) { // return template.imageId("cn-shanghai:aliyun1501_64_20G_aliaegis_20150325.vhd") // .hardwareId("ecs.t1.small") // .locationId("cn-hangzhou"); // } // // @Provides // @Singleton // protected final Map<Instance.Status, NodeMetadata.Status> getInstanceStatus() { // return ImmutableMap.<Instance.Status, NodeMetadata.Status> builder() // .put(Instance.Status.RUNNING, NodeMetadata.Status.RUNNING) // .put(Instance.Status.STOPPED, NodeMetadata.Status.SUSPENDED) // .put(Instance.Status.DELETED, NodeMetadata.Status.TERMINATED) // .put(Instance.Status.STARTING, NodeMetadata.Status.PENDING) // .put(Instance.Status.RESETTING, NodeMetadata.Status.PENDING) // .put(Instance.Status.TRANSFERRING, NodeMetadata.Status.PENDING) // .put(Instance.Status.STOPPING, NodeMetadata.Status.PENDING) // .build(); // } // }
import java.net.URI; import org.jclouds.aliyun.ecs.compute.ECSComputeServiceContext; import org.jclouds.aliyun.ecs.compute.config.ECSComputeServiceContextModule; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import com.google.common.collect.ImmutableSet; import com.google.inject.Module;
package org.jclouds.aliyun.ecs; public class ECSApiMetadata extends BaseApiMetadata { @Override public Builder toBuilder() { return new Builder(); } public ECSApiMetadata() { this(new Builder()); } protected ECSApiMetadata(Builder builder) { super(builder); } public static class Builder extends BaseApiMetadata.Builder<Builder> { protected Builder() { id("aliyun-ecs-api") .name("aliyun ecs api") .identityName("identity") .documentation(URI.create("https://help.aliyun.com/document_detail/ecs/open-api/summary.html")) .defaultEndpoint("http://ecs.aliyuncs.com")
// Path: aliyun-ecs/src/main/java/org/jclouds/aliyun/ecs/compute/ECSComputeServiceContext.java // @ImplementedBy(ECSComputeServiceContextImpl.class) // public interface ECSComputeServiceContext extends ComputeServiceContext { // // @Override // ECSComputeService getComputeService(); // } // // Path: aliyun-ecs/src/main/java/org/jclouds/aliyun/ecs/compute/config/ECSComputeServiceContextModule.java // public class ECSComputeServiceContextModule extends JCloudsNativeComputeServiceAdapterContextModule { // // public ECSComputeServiceContextModule() { // super(ECSComputeServiceAdapter.class); // } // // @Override // protected void configure() { // super.configure(); // bind(ECSApi.class).to(ECSApiImpl.class); // bind(ComputeService.class).to(ECSComputeService.class); // install(new LocationsFromComputeServiceAdapterModule<NodeMetadata, Hardware, Image, Location>() {}); // } // // @Provides // @Named("ECS") // protected final TemplateOptions guiceProvideTemplateOptions(TemplateOptions options) { // return options.blockUntilRunning(false); // } // // @Provides // @Named("ECS") // protected final TemplateBuilder guiceProvideTemplateBuilder(TemplateBuilder template) { // return template.imageId("cn-shanghai:aliyun1501_64_20G_aliaegis_20150325.vhd") // .hardwareId("ecs.t1.small") // .locationId("cn-hangzhou"); // } // // @Provides // @Singleton // protected final Map<Instance.Status, NodeMetadata.Status> getInstanceStatus() { // return ImmutableMap.<Instance.Status, NodeMetadata.Status> builder() // .put(Instance.Status.RUNNING, NodeMetadata.Status.RUNNING) // .put(Instance.Status.STOPPED, NodeMetadata.Status.SUSPENDED) // .put(Instance.Status.DELETED, NodeMetadata.Status.TERMINATED) // .put(Instance.Status.STARTING, NodeMetadata.Status.PENDING) // .put(Instance.Status.RESETTING, NodeMetadata.Status.PENDING) // .put(Instance.Status.TRANSFERRING, NodeMetadata.Status.PENDING) // .put(Instance.Status.STOPPING, NodeMetadata.Status.PENDING) // .build(); // } // } // Path: aliyun-ecs/src/main/java/org/jclouds/aliyun/ecs/ECSApiMetadata.java import java.net.URI; import org.jclouds.aliyun.ecs.compute.ECSComputeServiceContext; import org.jclouds.aliyun.ecs.compute.config.ECSComputeServiceContextModule; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; package org.jclouds.aliyun.ecs; public class ECSApiMetadata extends BaseApiMetadata { @Override public Builder toBuilder() { return new Builder(); } public ECSApiMetadata() { this(new Builder()); } protected ECSApiMetadata(Builder builder) { super(builder); } public static class Builder extends BaseApiMetadata.Builder<Builder> { protected Builder() { id("aliyun-ecs-api") .name("aliyun ecs api") .identityName("identity") .documentation(URI.create("https://help.aliyun.com/document_detail/ecs/open-api/summary.html")) .defaultEndpoint("http://ecs.aliyuncs.com")
.view(ECSComputeServiceContext.class)
aliyun-beta/aliyun-jclouds
aliyun-ecs/src/main/java/org/jclouds/aliyun/ecs/ECSApiMetadata.java
// Path: aliyun-ecs/src/main/java/org/jclouds/aliyun/ecs/compute/ECSComputeServiceContext.java // @ImplementedBy(ECSComputeServiceContextImpl.class) // public interface ECSComputeServiceContext extends ComputeServiceContext { // // @Override // ECSComputeService getComputeService(); // } // // Path: aliyun-ecs/src/main/java/org/jclouds/aliyun/ecs/compute/config/ECSComputeServiceContextModule.java // public class ECSComputeServiceContextModule extends JCloudsNativeComputeServiceAdapterContextModule { // // public ECSComputeServiceContextModule() { // super(ECSComputeServiceAdapter.class); // } // // @Override // protected void configure() { // super.configure(); // bind(ECSApi.class).to(ECSApiImpl.class); // bind(ComputeService.class).to(ECSComputeService.class); // install(new LocationsFromComputeServiceAdapterModule<NodeMetadata, Hardware, Image, Location>() {}); // } // // @Provides // @Named("ECS") // protected final TemplateOptions guiceProvideTemplateOptions(TemplateOptions options) { // return options.blockUntilRunning(false); // } // // @Provides // @Named("ECS") // protected final TemplateBuilder guiceProvideTemplateBuilder(TemplateBuilder template) { // return template.imageId("cn-shanghai:aliyun1501_64_20G_aliaegis_20150325.vhd") // .hardwareId("ecs.t1.small") // .locationId("cn-hangzhou"); // } // // @Provides // @Singleton // protected final Map<Instance.Status, NodeMetadata.Status> getInstanceStatus() { // return ImmutableMap.<Instance.Status, NodeMetadata.Status> builder() // .put(Instance.Status.RUNNING, NodeMetadata.Status.RUNNING) // .put(Instance.Status.STOPPED, NodeMetadata.Status.SUSPENDED) // .put(Instance.Status.DELETED, NodeMetadata.Status.TERMINATED) // .put(Instance.Status.STARTING, NodeMetadata.Status.PENDING) // .put(Instance.Status.RESETTING, NodeMetadata.Status.PENDING) // .put(Instance.Status.TRANSFERRING, NodeMetadata.Status.PENDING) // .put(Instance.Status.STOPPING, NodeMetadata.Status.PENDING) // .build(); // } // }
import java.net.URI; import org.jclouds.aliyun.ecs.compute.ECSComputeServiceContext; import org.jclouds.aliyun.ecs.compute.config.ECSComputeServiceContextModule; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import com.google.common.collect.ImmutableSet; import com.google.inject.Module;
package org.jclouds.aliyun.ecs; public class ECSApiMetadata extends BaseApiMetadata { @Override public Builder toBuilder() { return new Builder(); } public ECSApiMetadata() { this(new Builder()); } protected ECSApiMetadata(Builder builder) { super(builder); } public static class Builder extends BaseApiMetadata.Builder<Builder> { protected Builder() { id("aliyun-ecs-api") .name("aliyun ecs api") .identityName("identity") .documentation(URI.create("https://help.aliyun.com/document_detail/ecs/open-api/summary.html")) .defaultEndpoint("http://ecs.aliyuncs.com") .view(ECSComputeServiceContext.class) .defaultModules(ImmutableSet.<Class<? extends Module>>builder()
// Path: aliyun-ecs/src/main/java/org/jclouds/aliyun/ecs/compute/ECSComputeServiceContext.java // @ImplementedBy(ECSComputeServiceContextImpl.class) // public interface ECSComputeServiceContext extends ComputeServiceContext { // // @Override // ECSComputeService getComputeService(); // } // // Path: aliyun-ecs/src/main/java/org/jclouds/aliyun/ecs/compute/config/ECSComputeServiceContextModule.java // public class ECSComputeServiceContextModule extends JCloudsNativeComputeServiceAdapterContextModule { // // public ECSComputeServiceContextModule() { // super(ECSComputeServiceAdapter.class); // } // // @Override // protected void configure() { // super.configure(); // bind(ECSApi.class).to(ECSApiImpl.class); // bind(ComputeService.class).to(ECSComputeService.class); // install(new LocationsFromComputeServiceAdapterModule<NodeMetadata, Hardware, Image, Location>() {}); // } // // @Provides // @Named("ECS") // protected final TemplateOptions guiceProvideTemplateOptions(TemplateOptions options) { // return options.blockUntilRunning(false); // } // // @Provides // @Named("ECS") // protected final TemplateBuilder guiceProvideTemplateBuilder(TemplateBuilder template) { // return template.imageId("cn-shanghai:aliyun1501_64_20G_aliaegis_20150325.vhd") // .hardwareId("ecs.t1.small") // .locationId("cn-hangzhou"); // } // // @Provides // @Singleton // protected final Map<Instance.Status, NodeMetadata.Status> getInstanceStatus() { // return ImmutableMap.<Instance.Status, NodeMetadata.Status> builder() // .put(Instance.Status.RUNNING, NodeMetadata.Status.RUNNING) // .put(Instance.Status.STOPPED, NodeMetadata.Status.SUSPENDED) // .put(Instance.Status.DELETED, NodeMetadata.Status.TERMINATED) // .put(Instance.Status.STARTING, NodeMetadata.Status.PENDING) // .put(Instance.Status.RESETTING, NodeMetadata.Status.PENDING) // .put(Instance.Status.TRANSFERRING, NodeMetadata.Status.PENDING) // .put(Instance.Status.STOPPING, NodeMetadata.Status.PENDING) // .build(); // } // } // Path: aliyun-ecs/src/main/java/org/jclouds/aliyun/ecs/ECSApiMetadata.java import java.net.URI; import org.jclouds.aliyun.ecs.compute.ECSComputeServiceContext; import org.jclouds.aliyun.ecs.compute.config.ECSComputeServiceContextModule; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; package org.jclouds.aliyun.ecs; public class ECSApiMetadata extends BaseApiMetadata { @Override public Builder toBuilder() { return new Builder(); } public ECSApiMetadata() { this(new Builder()); } protected ECSApiMetadata(Builder builder) { super(builder); } public static class Builder extends BaseApiMetadata.Builder<Builder> { protected Builder() { id("aliyun-ecs-api") .name("aliyun ecs api") .identityName("identity") .documentation(URI.create("https://help.aliyun.com/document_detail/ecs/open-api/summary.html")) .defaultEndpoint("http://ecs.aliyuncs.com") .view(ECSComputeServiceContext.class) .defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(ECSComputeServiceContextModule.class)
aliyun-beta/aliyun-jclouds
aliyun-ecs/src/main/java/org/jclouds/aliyun/ecs/compute/internal/ECSComputeServiceContextImpl.java
// Path: aliyun-ecs/src/main/java/org/jclouds/aliyun/ecs/compute/ECSComputeService.java // @Singleton // public class ECSComputeService extends BaseComputeService { // // private final JCloudsNativeComputeServiceAdapter client; // // @Inject // protected ECSComputeService( // ComputeServiceContext context, // ECSComputeServiceAdapter client, // Map<String, Credentials> credentialStore, // @Memoized Supplier<Set<? extends Image>> images, // Supplier<Set<? extends Hardware>> hardwareProfiles, // @Memoized Supplier<Set<? extends Location>> locations, // ListNodesStrategy listNodesStrategy, // GetImageStrategy getImageStrategy, // GetNodeMetadataStrategy getNodeMetadataStrategy, // CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, // RebootNodeStrategy rebootNodeStrategy, // DestroyNodeStrategy destroyNodeStrategy, // ResumeNodeStrategy resumeNodeStrategy, // SuspendNodeStrategy suspendNodeStrategy, // @Named("ECS") Provider<TemplateBuilder> templateBuilderProvider, // @Named("ECS") Provider<TemplateOptions> templateOptionsProvider, // @Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning, // @Named(TIMEOUT_NODE_TERMINATED) Predicate<AtomicReference<NodeMetadata>> nodeTerminated, // @Named(TIMEOUT_NODE_SUSPENDED) Predicate<AtomicReference<NodeMetadata>> nodeSuspended, // Factory initScriptRunnerFactory, // InitAdminAccess initAdminAccess, // org.jclouds.compute.callables.RunScriptOnNode.Factory runScriptOnNodeFactory, // PersistNodeCredentials persistNodeCredentials, // Timeouts timeouts, // @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, // Optional<ImageExtension> imageExtension, // Optional<SecurityGroupExtension> securityGroupExtension) { // super(context, credentialStore, images, hardwareProfiles, locations, listNodesStrategy, getImageStrategy, // getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy, resumeNodeStrategy, // suspendNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning, nodeTerminated, nodeSuspended, // initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory, persistNodeCredentials, timeouts, userExecutor, // imageExtension, securityGroupExtension); // this.client = client; // } // // @Override // public Set<? extends NodeMetadata> listNodesByIds(Iterable<String> ids) { // return ImmutableSet.<NodeMetadata> builder() // .addAll(client.listNodesByIds(ids)) // .build(); // } // // @Override // public Set<? extends NodeMetadata> createNodesInGroup(String group, int count, Template template) throws RunNodesException { // return super.createNodesInGroup(group, count, template); // } // // @Override // public Set<? extends NodeMetadata> createNodesInGroup(String group, int count, TemplateOptions templateOptions) throws RunNodesException { // return this.createNodesInGroup(group, count, templateBuilder().options(templateOptions).build()); // } // // @Override // public Set<? extends NodeMetadata> createNodesInGroup(String group, int count) throws RunNodesException { // return super.createNodesInGroup(group, count); // } // } // // Path: aliyun-ecs/src/main/java/org/jclouds/aliyun/ecs/compute/ECSComputeServiceContext.java // @ImplementedBy(ECSComputeServiceContextImpl.class) // public interface ECSComputeServiceContext extends ComputeServiceContext { // // @Override // ECSComputeService getComputeService(); // }
import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.Context; import org.jclouds.aliyun.ecs.compute.ECSComputeService; import org.jclouds.aliyun.ecs.compute.ECSComputeServiceContext; import org.jclouds.compute.ComputeService; import org.jclouds.compute.Utils; import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.location.Provider; import com.google.common.reflect.TypeToken;
package org.jclouds.aliyun.ecs.compute.internal; @Singleton public class ECSComputeServiceContextImpl extends ComputeServiceContextImpl implements ECSComputeServiceContext { @Inject public ECSComputeServiceContextImpl( @Provider Context backend, @Provider TypeToken<? extends Context> backendType, ComputeService computeService, Utils utils) { super(backend, backendType, computeService, utils); } @Override
// Path: aliyun-ecs/src/main/java/org/jclouds/aliyun/ecs/compute/ECSComputeService.java // @Singleton // public class ECSComputeService extends BaseComputeService { // // private final JCloudsNativeComputeServiceAdapter client; // // @Inject // protected ECSComputeService( // ComputeServiceContext context, // ECSComputeServiceAdapter client, // Map<String, Credentials> credentialStore, // @Memoized Supplier<Set<? extends Image>> images, // Supplier<Set<? extends Hardware>> hardwareProfiles, // @Memoized Supplier<Set<? extends Location>> locations, // ListNodesStrategy listNodesStrategy, // GetImageStrategy getImageStrategy, // GetNodeMetadataStrategy getNodeMetadataStrategy, // CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, // RebootNodeStrategy rebootNodeStrategy, // DestroyNodeStrategy destroyNodeStrategy, // ResumeNodeStrategy resumeNodeStrategy, // SuspendNodeStrategy suspendNodeStrategy, // @Named("ECS") Provider<TemplateBuilder> templateBuilderProvider, // @Named("ECS") Provider<TemplateOptions> templateOptionsProvider, // @Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning, // @Named(TIMEOUT_NODE_TERMINATED) Predicate<AtomicReference<NodeMetadata>> nodeTerminated, // @Named(TIMEOUT_NODE_SUSPENDED) Predicate<AtomicReference<NodeMetadata>> nodeSuspended, // Factory initScriptRunnerFactory, // InitAdminAccess initAdminAccess, // org.jclouds.compute.callables.RunScriptOnNode.Factory runScriptOnNodeFactory, // PersistNodeCredentials persistNodeCredentials, // Timeouts timeouts, // @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, // Optional<ImageExtension> imageExtension, // Optional<SecurityGroupExtension> securityGroupExtension) { // super(context, credentialStore, images, hardwareProfiles, locations, listNodesStrategy, getImageStrategy, // getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy, resumeNodeStrategy, // suspendNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning, nodeTerminated, nodeSuspended, // initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory, persistNodeCredentials, timeouts, userExecutor, // imageExtension, securityGroupExtension); // this.client = client; // } // // @Override // public Set<? extends NodeMetadata> listNodesByIds(Iterable<String> ids) { // return ImmutableSet.<NodeMetadata> builder() // .addAll(client.listNodesByIds(ids)) // .build(); // } // // @Override // public Set<? extends NodeMetadata> createNodesInGroup(String group, int count, Template template) throws RunNodesException { // return super.createNodesInGroup(group, count, template); // } // // @Override // public Set<? extends NodeMetadata> createNodesInGroup(String group, int count, TemplateOptions templateOptions) throws RunNodesException { // return this.createNodesInGroup(group, count, templateBuilder().options(templateOptions).build()); // } // // @Override // public Set<? extends NodeMetadata> createNodesInGroup(String group, int count) throws RunNodesException { // return super.createNodesInGroup(group, count); // } // } // // Path: aliyun-ecs/src/main/java/org/jclouds/aliyun/ecs/compute/ECSComputeServiceContext.java // @ImplementedBy(ECSComputeServiceContextImpl.class) // public interface ECSComputeServiceContext extends ComputeServiceContext { // // @Override // ECSComputeService getComputeService(); // } // Path: aliyun-ecs/src/main/java/org/jclouds/aliyun/ecs/compute/internal/ECSComputeServiceContextImpl.java import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.Context; import org.jclouds.aliyun.ecs.compute.ECSComputeService; import org.jclouds.aliyun.ecs.compute.ECSComputeServiceContext; import org.jclouds.compute.ComputeService; import org.jclouds.compute.Utils; import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.location.Provider; import com.google.common.reflect.TypeToken; package org.jclouds.aliyun.ecs.compute.internal; @Singleton public class ECSComputeServiceContextImpl extends ComputeServiceContextImpl implements ECSComputeServiceContext { @Inject public ECSComputeServiceContextImpl( @Provider Context backend, @Provider TypeToken<? extends Context> backendType, ComputeService computeService, Utils utils) { super(backend, backendType, computeService, utils); } @Override
public ECSComputeService getComputeService() {
aliyun-beta/aliyun-jclouds
aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/strategy/SLBLoadBalanceNodesStrategy.java
// Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/SLBApi.java // public interface SLBApi extends Closeable { // // static final String DEFAULT_REGION = "cn-hangzhou"; // // IAcsClient getAcsClient(String region); // // Set<String> getAvailableRegions(); // // String encodeToId(String region, String id); // // String decodeToRegion(String id); // // String decodeToId(String id); // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/domain/SLBLoadBalancerProtocol.java // public enum SLBLoadBalancerProtocol { // HTTP, HTTPS, TCP, UDP // }
import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; import org.jclouds.aliyun.slb.SLBApi; import org.jclouds.aliyun.slb.loadbalancer.domain.SLBLoadBalancerProtocol; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.domain.Location; import org.jclouds.loadbalancer.LoadBalancerServiceAdapter; import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; import org.jclouds.loadbalancer.reference.LoadBalancerConstants; import org.jclouds.loadbalancer.strategy.LoadBalanceNodesStrategy; import org.jclouds.logging.Logger; import com.aliyuncs.IAcsClient; import com.aliyuncs.slb.model.v20140515.AddBackendServersRequest; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerHTTPListenerRequest; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerHTTPSListenerRequest; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerTCPListenerRequest; import com.aliyuncs.slb.model.v20140515.StartLoadBalancerListenerRequest; import com.google.common.collect.ImmutableSet; import com.google.gson.Gson; import com.google.gson.GsonBuilder;
package org.jclouds.aliyun.slb.loadbalancer.strategy; public class SLBLoadBalanceNodesStrategy implements LoadBalanceNodesStrategy { @Resource @Named(LoadBalancerConstants.LOADBALANCER_LOGGER) protected Logger logger = Logger.NULL;
// Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/SLBApi.java // public interface SLBApi extends Closeable { // // static final String DEFAULT_REGION = "cn-hangzhou"; // // IAcsClient getAcsClient(String region); // // Set<String> getAvailableRegions(); // // String encodeToId(String region, String id); // // String decodeToRegion(String id); // // String decodeToId(String id); // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/domain/SLBLoadBalancerProtocol.java // public enum SLBLoadBalancerProtocol { // HTTP, HTTPS, TCP, UDP // } // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/strategy/SLBLoadBalanceNodesStrategy.java import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; import org.jclouds.aliyun.slb.SLBApi; import org.jclouds.aliyun.slb.loadbalancer.domain.SLBLoadBalancerProtocol; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.domain.Location; import org.jclouds.loadbalancer.LoadBalancerServiceAdapter; import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; import org.jclouds.loadbalancer.reference.LoadBalancerConstants; import org.jclouds.loadbalancer.strategy.LoadBalanceNodesStrategy; import org.jclouds.logging.Logger; import com.aliyuncs.IAcsClient; import com.aliyuncs.slb.model.v20140515.AddBackendServersRequest; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerHTTPListenerRequest; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerHTTPSListenerRequest; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerTCPListenerRequest; import com.aliyuncs.slb.model.v20140515.StartLoadBalancerListenerRequest; import com.google.common.collect.ImmutableSet; import com.google.gson.Gson; import com.google.gson.GsonBuilder; package org.jclouds.aliyun.slb.loadbalancer.strategy; public class SLBLoadBalanceNodesStrategy implements LoadBalanceNodesStrategy { @Resource @Named(LoadBalancerConstants.LOADBALANCER_LOGGER) protected Logger logger = Logger.NULL;
protected final SLBApi api;
aliyun-beta/aliyun-jclouds
aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/strategy/SLBLoadBalanceNodesStrategy.java
// Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/SLBApi.java // public interface SLBApi extends Closeable { // // static final String DEFAULT_REGION = "cn-hangzhou"; // // IAcsClient getAcsClient(String region); // // Set<String> getAvailableRegions(); // // String encodeToId(String region, String id); // // String decodeToRegion(String id); // // String decodeToId(String id); // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/domain/SLBLoadBalancerProtocol.java // public enum SLBLoadBalancerProtocol { // HTTP, HTTPS, TCP, UDP // }
import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; import org.jclouds.aliyun.slb.SLBApi; import org.jclouds.aliyun.slb.loadbalancer.domain.SLBLoadBalancerProtocol; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.domain.Location; import org.jclouds.loadbalancer.LoadBalancerServiceAdapter; import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; import org.jclouds.loadbalancer.reference.LoadBalancerConstants; import org.jclouds.loadbalancer.strategy.LoadBalanceNodesStrategy; import org.jclouds.logging.Logger; import com.aliyuncs.IAcsClient; import com.aliyuncs.slb.model.v20140515.AddBackendServersRequest; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerHTTPListenerRequest; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerHTTPSListenerRequest; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerTCPListenerRequest; import com.aliyuncs.slb.model.v20140515.StartLoadBalancerListenerRequest; import com.google.common.collect.ImmutableSet; import com.google.gson.Gson; import com.google.gson.GsonBuilder;
package org.jclouds.aliyun.slb.loadbalancer.strategy; public class SLBLoadBalanceNodesStrategy implements LoadBalanceNodesStrategy { @Resource @Named(LoadBalancerConstants.LOADBALANCER_LOGGER) protected Logger logger = Logger.NULL; protected final SLBApi api; protected final LoadBalancerServiceAdapter<LoadBalancerMetadata, Location> adapter; @Inject public SLBLoadBalanceNodesStrategy ( LoadBalancerServiceAdapter<LoadBalancerMetadata, Location> adapter, SLBApi api) { this.adapter = adapter; this.api = api; } @Override public LoadBalancerMetadata createLoadBalancerInLocation( Location location, String name, String protocol, int loadBalancerPort, int instancePort, Iterable<? extends NodeMetadata> nodes) { IAcsClient client = api.getAcsClient(location.getId()); LoadBalancerMetadata lbm = adapter .createLoadBalancerInLocation(location, name, protocol, loadBalancerPort, instancePort, nodes); String loadBalancerId = lbm.getId();
// Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/SLBApi.java // public interface SLBApi extends Closeable { // // static final String DEFAULT_REGION = "cn-hangzhou"; // // IAcsClient getAcsClient(String region); // // Set<String> getAvailableRegions(); // // String encodeToId(String region, String id); // // String decodeToRegion(String id); // // String decodeToId(String id); // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/domain/SLBLoadBalancerProtocol.java // public enum SLBLoadBalancerProtocol { // HTTP, HTTPS, TCP, UDP // } // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/strategy/SLBLoadBalanceNodesStrategy.java import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; import org.jclouds.aliyun.slb.SLBApi; import org.jclouds.aliyun.slb.loadbalancer.domain.SLBLoadBalancerProtocol; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.domain.Location; import org.jclouds.loadbalancer.LoadBalancerServiceAdapter; import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; import org.jclouds.loadbalancer.reference.LoadBalancerConstants; import org.jclouds.loadbalancer.strategy.LoadBalanceNodesStrategy; import org.jclouds.logging.Logger; import com.aliyuncs.IAcsClient; import com.aliyuncs.slb.model.v20140515.AddBackendServersRequest; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerHTTPListenerRequest; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerHTTPSListenerRequest; import com.aliyuncs.slb.model.v20140515.CreateLoadBalancerTCPListenerRequest; import com.aliyuncs.slb.model.v20140515.StartLoadBalancerListenerRequest; import com.google.common.collect.ImmutableSet; import com.google.gson.Gson; import com.google.gson.GsonBuilder; package org.jclouds.aliyun.slb.loadbalancer.strategy; public class SLBLoadBalanceNodesStrategy implements LoadBalanceNodesStrategy { @Resource @Named(LoadBalancerConstants.LOADBALANCER_LOGGER) protected Logger logger = Logger.NULL; protected final SLBApi api; protected final LoadBalancerServiceAdapter<LoadBalancerMetadata, Location> adapter; @Inject public SLBLoadBalanceNodesStrategy ( LoadBalancerServiceAdapter<LoadBalancerMetadata, Location> adapter, SLBApi api) { this.adapter = adapter; this.api = api; } @Override public LoadBalancerMetadata createLoadBalancerInLocation( Location location, String name, String protocol, int loadBalancerPort, int instancePort, Iterable<? extends NodeMetadata> nodes) { IAcsClient client = api.getAcsClient(location.getId()); LoadBalancerMetadata lbm = adapter .createLoadBalancerInLocation(location, name, protocol, loadBalancerPort, instancePort, nodes); String loadBalancerId = lbm.getId();
if (SLBLoadBalancerProtocol.HTTP.name().equalsIgnoreCase(protocol)) {
aliyun-beta/aliyun-jclouds
aliyun-slb/src/main/java/org/jclouds/aliyun/slb/SLBApiMetadata.java
// Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/SLBLoadBalancerServiceContext.java // @ImplementedBy(SLBLoadBalancerServiceContextImpl.class) // public interface SLBLoadBalancerServiceContext extends LoadBalancerServiceContext { // // @Override // SLBLoadBalancerService getLoadBalancerService(); // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/config/SLBLoadBalancerServiceContextModule.java // public class SLBLoadBalancerServiceContextModule extends BaseLoadBalancerServiceContextModule { // // @Override // protected void configure() { // super.configure(); // bind(new TypeLiteral<LoadBalancerServiceAdapter<LoadBalancerMetadata, Location>>(){}).to(SLBLoadBalancerServiceAdapter.class); // bind(SLBApi.class).to(SLBApiImpl.class); // bind(LoadBalancerService.class).to(SLBLoadBalancerService.class); // install(new SLBBindLoadBalancerStrategiesByClass()); // } // // @Provides // @Singleton // protected final Map<String, LoadBalancerType> loadBalancerTypeProvides() { // return ImmutableMap.<String, LoadBalancerType> builder() // .put("internet", LoadBalancerType.GSLB) // .put("intranet", LoadBalancerType.LB) // .build(); // } // }
import java.net.URI; import java.util.Properties; import org.jclouds.aliyun.slb.loadbalancer.SLBLoadBalancerServiceContext; import org.jclouds.aliyun.slb.loadbalancer.config.SLBLoadBalancerServiceContextModule; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.internal.BaseHttpApiMetadata; import com.google.common.collect.ImmutableSet; import com.google.inject.Module;
package org.jclouds.aliyun.slb; public class SLBApiMetadata extends BaseApiMetadata { @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); } public SLBApiMetadata() { this(new Builder()); } protected SLBApiMetadata(Builder builder) { super(builder); } public static Properties defaultProperties() { Properties properties = BaseHttpApiMetadata.defaultProperties(); return properties; } public static class Builder extends BaseApiMetadata.Builder<Builder> { protected Builder() { id("aliyun-slb-api") .name("aliyun slb api") .identityName("identity") .documentation(URI.create("https://help.aliyun.com/document_detail/slb/api-reference/brief-introduction.html")) .defaultEndpoint("http://slb.aliyuncs.com") .defaultProperties(SLBApiMetadata.defaultProperties())
// Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/SLBLoadBalancerServiceContext.java // @ImplementedBy(SLBLoadBalancerServiceContextImpl.class) // public interface SLBLoadBalancerServiceContext extends LoadBalancerServiceContext { // // @Override // SLBLoadBalancerService getLoadBalancerService(); // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/config/SLBLoadBalancerServiceContextModule.java // public class SLBLoadBalancerServiceContextModule extends BaseLoadBalancerServiceContextModule { // // @Override // protected void configure() { // super.configure(); // bind(new TypeLiteral<LoadBalancerServiceAdapter<LoadBalancerMetadata, Location>>(){}).to(SLBLoadBalancerServiceAdapter.class); // bind(SLBApi.class).to(SLBApiImpl.class); // bind(LoadBalancerService.class).to(SLBLoadBalancerService.class); // install(new SLBBindLoadBalancerStrategiesByClass()); // } // // @Provides // @Singleton // protected final Map<String, LoadBalancerType> loadBalancerTypeProvides() { // return ImmutableMap.<String, LoadBalancerType> builder() // .put("internet", LoadBalancerType.GSLB) // .put("intranet", LoadBalancerType.LB) // .build(); // } // } // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/SLBApiMetadata.java import java.net.URI; import java.util.Properties; import org.jclouds.aliyun.slb.loadbalancer.SLBLoadBalancerServiceContext; import org.jclouds.aliyun.slb.loadbalancer.config.SLBLoadBalancerServiceContextModule; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.internal.BaseHttpApiMetadata; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; package org.jclouds.aliyun.slb; public class SLBApiMetadata extends BaseApiMetadata { @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); } public SLBApiMetadata() { this(new Builder()); } protected SLBApiMetadata(Builder builder) { super(builder); } public static Properties defaultProperties() { Properties properties = BaseHttpApiMetadata.defaultProperties(); return properties; } public static class Builder extends BaseApiMetadata.Builder<Builder> { protected Builder() { id("aliyun-slb-api") .name("aliyun slb api") .identityName("identity") .documentation(URI.create("https://help.aliyun.com/document_detail/slb/api-reference/brief-introduction.html")) .defaultEndpoint("http://slb.aliyuncs.com") .defaultProperties(SLBApiMetadata.defaultProperties())
.view(SLBLoadBalancerServiceContext.class)
aliyun-beta/aliyun-jclouds
aliyun-slb/src/main/java/org/jclouds/aliyun/slb/SLBApiMetadata.java
// Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/SLBLoadBalancerServiceContext.java // @ImplementedBy(SLBLoadBalancerServiceContextImpl.class) // public interface SLBLoadBalancerServiceContext extends LoadBalancerServiceContext { // // @Override // SLBLoadBalancerService getLoadBalancerService(); // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/config/SLBLoadBalancerServiceContextModule.java // public class SLBLoadBalancerServiceContextModule extends BaseLoadBalancerServiceContextModule { // // @Override // protected void configure() { // super.configure(); // bind(new TypeLiteral<LoadBalancerServiceAdapter<LoadBalancerMetadata, Location>>(){}).to(SLBLoadBalancerServiceAdapter.class); // bind(SLBApi.class).to(SLBApiImpl.class); // bind(LoadBalancerService.class).to(SLBLoadBalancerService.class); // install(new SLBBindLoadBalancerStrategiesByClass()); // } // // @Provides // @Singleton // protected final Map<String, LoadBalancerType> loadBalancerTypeProvides() { // return ImmutableMap.<String, LoadBalancerType> builder() // .put("internet", LoadBalancerType.GSLB) // .put("intranet", LoadBalancerType.LB) // .build(); // } // }
import java.net.URI; import java.util.Properties; import org.jclouds.aliyun.slb.loadbalancer.SLBLoadBalancerServiceContext; import org.jclouds.aliyun.slb.loadbalancer.config.SLBLoadBalancerServiceContextModule; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.internal.BaseHttpApiMetadata; import com.google.common.collect.ImmutableSet; import com.google.inject.Module;
package org.jclouds.aliyun.slb; public class SLBApiMetadata extends BaseApiMetadata { @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); } public SLBApiMetadata() { this(new Builder()); } protected SLBApiMetadata(Builder builder) { super(builder); } public static Properties defaultProperties() { Properties properties = BaseHttpApiMetadata.defaultProperties(); return properties; } public static class Builder extends BaseApiMetadata.Builder<Builder> { protected Builder() { id("aliyun-slb-api") .name("aliyun slb api") .identityName("identity") .documentation(URI.create("https://help.aliyun.com/document_detail/slb/api-reference/brief-introduction.html")) .defaultEndpoint("http://slb.aliyuncs.com") .defaultProperties(SLBApiMetadata.defaultProperties()) .view(SLBLoadBalancerServiceContext.class) .defaultModules(ImmutableSet.<Class<? extends Module>>builder()
// Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/SLBLoadBalancerServiceContext.java // @ImplementedBy(SLBLoadBalancerServiceContextImpl.class) // public interface SLBLoadBalancerServiceContext extends LoadBalancerServiceContext { // // @Override // SLBLoadBalancerService getLoadBalancerService(); // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/config/SLBLoadBalancerServiceContextModule.java // public class SLBLoadBalancerServiceContextModule extends BaseLoadBalancerServiceContextModule { // // @Override // protected void configure() { // super.configure(); // bind(new TypeLiteral<LoadBalancerServiceAdapter<LoadBalancerMetadata, Location>>(){}).to(SLBLoadBalancerServiceAdapter.class); // bind(SLBApi.class).to(SLBApiImpl.class); // bind(LoadBalancerService.class).to(SLBLoadBalancerService.class); // install(new SLBBindLoadBalancerStrategiesByClass()); // } // // @Provides // @Singleton // protected final Map<String, LoadBalancerType> loadBalancerTypeProvides() { // return ImmutableMap.<String, LoadBalancerType> builder() // .put("internet", LoadBalancerType.GSLB) // .put("intranet", LoadBalancerType.LB) // .build(); // } // } // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/SLBApiMetadata.java import java.net.URI; import java.util.Properties; import org.jclouds.aliyun.slb.loadbalancer.SLBLoadBalancerServiceContext; import org.jclouds.aliyun.slb.loadbalancer.config.SLBLoadBalancerServiceContextModule; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.internal.BaseHttpApiMetadata; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; package org.jclouds.aliyun.slb; public class SLBApiMetadata extends BaseApiMetadata { @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); } public SLBApiMetadata() { this(new Builder()); } protected SLBApiMetadata(Builder builder) { super(builder); } public static Properties defaultProperties() { Properties properties = BaseHttpApiMetadata.defaultProperties(); return properties; } public static class Builder extends BaseApiMetadata.Builder<Builder> { protected Builder() { id("aliyun-slb-api") .name("aliyun slb api") .identityName("identity") .documentation(URI.create("https://help.aliyun.com/document_detail/slb/api-reference/brief-introduction.html")) .defaultEndpoint("http://slb.aliyuncs.com") .defaultProperties(SLBApiMetadata.defaultProperties()) .view(SLBLoadBalancerServiceContext.class) .defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(SLBLoadBalancerServiceContextModule.class)
aliyun-beta/aliyun-jclouds
aliyun-oss/src/main/java/org/jclouds/aliyun/oss/OSSApiMetadata.java
// Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/blobstore/OSSBlobStoreContext.java // @ImplementedBy(OSSBlobStoreContextImpl.class) // public interface OSSBlobStoreContext extends BlobStoreContext { // // @Override // OSSBlobStore getBlobStore(); // } // // Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/blobstore/config/OSSBlobStoreContextModule.java // public class OSSBlobStoreContextModule extends AbstractModule { // // @Override // protected void configure() { // bind(OSSApi.class).to(OSSApiImpl.class); // bind(BlobStore.class).to(OSSBlobStore.class); // bind(BlobRequestSigner.class).to(OSSBlobRequestSigner.class); // bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL); // bind(BlobBuilder.class).to(OSSBlobBuilder.class); // bind(BlobUtils.class).to(OSSBlobUtils.class); // bind(LocationsSupplier.class).to(OSSLocationsSupplier.class); // bind(RegionIdsSupplier.class).to(OSSRegionIdsSupplier.class); // } // // @Provides // @Singleton // protected final Supplier<Map<BlobAccess, CannedAccessControlList>> accessFromBlobToOSS() { // Map<BlobAccess, CannedAccessControlList> regions = ImmutableMap // .<BlobAccess, CannedAccessControlList>builder() // .put(BlobAccess.PRIVATE, CannedAccessControlList.Private) // .put(BlobAccess.PUBLIC_READ, CannedAccessControlList.PublicRead) // .build(); // return Suppliers.ofInstance(regions); // } // // @Provides // @Singleton // protected final Supplier<Map<ContainerAccess, CannedAccessControlList>> accessFromContainerToOSS() { // Map<ContainerAccess, CannedAccessControlList> regions = ImmutableMap // .<ContainerAccess, CannedAccessControlList>builder() // .put(ContainerAccess.PRIVATE, CannedAccessControlList.Private) // .put(ContainerAccess.PUBLIC_READ, CannedAccessControlList.PublicRead) // .build(); // return Suppliers.ofInstance(regions); // } // }
import java.net.URI; import java.util.Properties; import org.jclouds.aliyun.oss.blobstore.OSSBlobStoreContext; import org.jclouds.aliyun.oss.blobstore.config.OSSBlobStoreContextModule; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.internal.BaseHttpApiMetadata; import com.google.common.collect.ImmutableSet; import com.google.inject.Module;
package org.jclouds.aliyun.oss; public class OSSApiMetadata extends BaseApiMetadata { @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); } public OSSApiMetadata() { this(new Builder()); } protected OSSApiMetadata(Builder builder) { super(builder); } public static Properties defaultProperties() { Properties properties = BaseHttpApiMetadata.defaultProperties(); return properties; } public static class Builder extends BaseApiMetadata.Builder<Builder> { protected Builder() { id("aliyun-oss-api") .name("aliyun oss api") .identityName("identity") .documentation(URI.create("https://help.aliyun.com/document_detail/oss/api-reference/abstract.html")) .defaultEndpoint("http://oss.aliyuncs.com") .defaultProperties(OSSApiMetadata.defaultProperties())
// Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/blobstore/OSSBlobStoreContext.java // @ImplementedBy(OSSBlobStoreContextImpl.class) // public interface OSSBlobStoreContext extends BlobStoreContext { // // @Override // OSSBlobStore getBlobStore(); // } // // Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/blobstore/config/OSSBlobStoreContextModule.java // public class OSSBlobStoreContextModule extends AbstractModule { // // @Override // protected void configure() { // bind(OSSApi.class).to(OSSApiImpl.class); // bind(BlobStore.class).to(OSSBlobStore.class); // bind(BlobRequestSigner.class).to(OSSBlobRequestSigner.class); // bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL); // bind(BlobBuilder.class).to(OSSBlobBuilder.class); // bind(BlobUtils.class).to(OSSBlobUtils.class); // bind(LocationsSupplier.class).to(OSSLocationsSupplier.class); // bind(RegionIdsSupplier.class).to(OSSRegionIdsSupplier.class); // } // // @Provides // @Singleton // protected final Supplier<Map<BlobAccess, CannedAccessControlList>> accessFromBlobToOSS() { // Map<BlobAccess, CannedAccessControlList> regions = ImmutableMap // .<BlobAccess, CannedAccessControlList>builder() // .put(BlobAccess.PRIVATE, CannedAccessControlList.Private) // .put(BlobAccess.PUBLIC_READ, CannedAccessControlList.PublicRead) // .build(); // return Suppliers.ofInstance(regions); // } // // @Provides // @Singleton // protected final Supplier<Map<ContainerAccess, CannedAccessControlList>> accessFromContainerToOSS() { // Map<ContainerAccess, CannedAccessControlList> regions = ImmutableMap // .<ContainerAccess, CannedAccessControlList>builder() // .put(ContainerAccess.PRIVATE, CannedAccessControlList.Private) // .put(ContainerAccess.PUBLIC_READ, CannedAccessControlList.PublicRead) // .build(); // return Suppliers.ofInstance(regions); // } // } // Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/OSSApiMetadata.java import java.net.URI; import java.util.Properties; import org.jclouds.aliyun.oss.blobstore.OSSBlobStoreContext; import org.jclouds.aliyun.oss.blobstore.config.OSSBlobStoreContextModule; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.internal.BaseHttpApiMetadata; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; package org.jclouds.aliyun.oss; public class OSSApiMetadata extends BaseApiMetadata { @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); } public OSSApiMetadata() { this(new Builder()); } protected OSSApiMetadata(Builder builder) { super(builder); } public static Properties defaultProperties() { Properties properties = BaseHttpApiMetadata.defaultProperties(); return properties; } public static class Builder extends BaseApiMetadata.Builder<Builder> { protected Builder() { id("aliyun-oss-api") .name("aliyun oss api") .identityName("identity") .documentation(URI.create("https://help.aliyun.com/document_detail/oss/api-reference/abstract.html")) .defaultEndpoint("http://oss.aliyuncs.com") .defaultProperties(OSSApiMetadata.defaultProperties())
.view(OSSBlobStoreContext.class)
aliyun-beta/aliyun-jclouds
aliyun-oss/src/main/java/org/jclouds/aliyun/oss/OSSApiMetadata.java
// Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/blobstore/OSSBlobStoreContext.java // @ImplementedBy(OSSBlobStoreContextImpl.class) // public interface OSSBlobStoreContext extends BlobStoreContext { // // @Override // OSSBlobStore getBlobStore(); // } // // Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/blobstore/config/OSSBlobStoreContextModule.java // public class OSSBlobStoreContextModule extends AbstractModule { // // @Override // protected void configure() { // bind(OSSApi.class).to(OSSApiImpl.class); // bind(BlobStore.class).to(OSSBlobStore.class); // bind(BlobRequestSigner.class).to(OSSBlobRequestSigner.class); // bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL); // bind(BlobBuilder.class).to(OSSBlobBuilder.class); // bind(BlobUtils.class).to(OSSBlobUtils.class); // bind(LocationsSupplier.class).to(OSSLocationsSupplier.class); // bind(RegionIdsSupplier.class).to(OSSRegionIdsSupplier.class); // } // // @Provides // @Singleton // protected final Supplier<Map<BlobAccess, CannedAccessControlList>> accessFromBlobToOSS() { // Map<BlobAccess, CannedAccessControlList> regions = ImmutableMap // .<BlobAccess, CannedAccessControlList>builder() // .put(BlobAccess.PRIVATE, CannedAccessControlList.Private) // .put(BlobAccess.PUBLIC_READ, CannedAccessControlList.PublicRead) // .build(); // return Suppliers.ofInstance(regions); // } // // @Provides // @Singleton // protected final Supplier<Map<ContainerAccess, CannedAccessControlList>> accessFromContainerToOSS() { // Map<ContainerAccess, CannedAccessControlList> regions = ImmutableMap // .<ContainerAccess, CannedAccessControlList>builder() // .put(ContainerAccess.PRIVATE, CannedAccessControlList.Private) // .put(ContainerAccess.PUBLIC_READ, CannedAccessControlList.PublicRead) // .build(); // return Suppliers.ofInstance(regions); // } // }
import java.net.URI; import java.util.Properties; import org.jclouds.aliyun.oss.blobstore.OSSBlobStoreContext; import org.jclouds.aliyun.oss.blobstore.config.OSSBlobStoreContextModule; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.internal.BaseHttpApiMetadata; import com.google.common.collect.ImmutableSet; import com.google.inject.Module;
package org.jclouds.aliyun.oss; public class OSSApiMetadata extends BaseApiMetadata { @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); } public OSSApiMetadata() { this(new Builder()); } protected OSSApiMetadata(Builder builder) { super(builder); } public static Properties defaultProperties() { Properties properties = BaseHttpApiMetadata.defaultProperties(); return properties; } public static class Builder extends BaseApiMetadata.Builder<Builder> { protected Builder() { id("aliyun-oss-api") .name("aliyun oss api") .identityName("identity") .documentation(URI.create("https://help.aliyun.com/document_detail/oss/api-reference/abstract.html")) .defaultEndpoint("http://oss.aliyuncs.com") .defaultProperties(OSSApiMetadata.defaultProperties()) .view(OSSBlobStoreContext.class) .defaultModules(ImmutableSet.<Class<? extends Module>>builder()
// Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/blobstore/OSSBlobStoreContext.java // @ImplementedBy(OSSBlobStoreContextImpl.class) // public interface OSSBlobStoreContext extends BlobStoreContext { // // @Override // OSSBlobStore getBlobStore(); // } // // Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/blobstore/config/OSSBlobStoreContextModule.java // public class OSSBlobStoreContextModule extends AbstractModule { // // @Override // protected void configure() { // bind(OSSApi.class).to(OSSApiImpl.class); // bind(BlobStore.class).to(OSSBlobStore.class); // bind(BlobRequestSigner.class).to(OSSBlobRequestSigner.class); // bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL); // bind(BlobBuilder.class).to(OSSBlobBuilder.class); // bind(BlobUtils.class).to(OSSBlobUtils.class); // bind(LocationsSupplier.class).to(OSSLocationsSupplier.class); // bind(RegionIdsSupplier.class).to(OSSRegionIdsSupplier.class); // } // // @Provides // @Singleton // protected final Supplier<Map<BlobAccess, CannedAccessControlList>> accessFromBlobToOSS() { // Map<BlobAccess, CannedAccessControlList> regions = ImmutableMap // .<BlobAccess, CannedAccessControlList>builder() // .put(BlobAccess.PRIVATE, CannedAccessControlList.Private) // .put(BlobAccess.PUBLIC_READ, CannedAccessControlList.PublicRead) // .build(); // return Suppliers.ofInstance(regions); // } // // @Provides // @Singleton // protected final Supplier<Map<ContainerAccess, CannedAccessControlList>> accessFromContainerToOSS() { // Map<ContainerAccess, CannedAccessControlList> regions = ImmutableMap // .<ContainerAccess, CannedAccessControlList>builder() // .put(ContainerAccess.PRIVATE, CannedAccessControlList.Private) // .put(ContainerAccess.PUBLIC_READ, CannedAccessControlList.PublicRead) // .build(); // return Suppliers.ofInstance(regions); // } // } // Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/OSSApiMetadata.java import java.net.URI; import java.util.Properties; import org.jclouds.aliyun.oss.blobstore.OSSBlobStoreContext; import org.jclouds.aliyun.oss.blobstore.config.OSSBlobStoreContextModule; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.internal.BaseHttpApiMetadata; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; package org.jclouds.aliyun.oss; public class OSSApiMetadata extends BaseApiMetadata { @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); } public OSSApiMetadata() { this(new Builder()); } protected OSSApiMetadata(Builder builder) { super(builder); } public static Properties defaultProperties() { Properties properties = BaseHttpApiMetadata.defaultProperties(); return properties; } public static class Builder extends BaseApiMetadata.Builder<Builder> { protected Builder() { id("aliyun-oss-api") .name("aliyun oss api") .identityName("identity") .documentation(URI.create("https://help.aliyun.com/document_detail/oss/api-reference/abstract.html")) .defaultEndpoint("http://oss.aliyuncs.com") .defaultProperties(OSSApiMetadata.defaultProperties()) .view(OSSBlobStoreContext.class) .defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(OSSBlobStoreContextModule.class)
aliyun-beta/aliyun-jclouds
aliyun-oss/src/main/java/org/jclouds/aliyun/oss/blobstore/OSSBlobStore.java
// Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/OSSApi.java // public interface OSSApi extends Closeable { // // static final String DEFAULT_REGION = "oss-cn-hangzhou"; // // OSS getOSSClient(String region); // // Set<String> getAvailableRegions(); // } // // Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/blobstore/functions/RegionToLocation.java // public class RegionToLocation implements Function<String, Location> { // // @Override // public Location apply(String input) { // LocationBuilder builder = new LocationBuilder(); // builder.scope(LocationScope.REGION); // builder.id(input); // builder.description(input); // return builder.build(); // } // }
import static com.google.common.collect.Iterables.transform; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Set; import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.aliyun.oss.OSSApi; import org.jclouds.aliyun.oss.blobstore.functions.RegionToLocation; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobAccess; import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.ContainerAccess; import org.jclouds.blobstore.domain.PageSet; import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.domain.StorageType; import org.jclouds.blobstore.domain.internal.BlobMetadataImpl; import org.jclouds.blobstore.domain.internal.PageSetImpl; import org.jclouds.blobstore.domain.internal.StorageMetadataImpl; import org.jclouds.blobstore.internal.BaseBlobStore; import org.jclouds.blobstore.options.CreateContainerOptions; import org.jclouds.blobstore.options.GetOptions; import org.jclouds.blobstore.options.ListContainerOptions; import org.jclouds.blobstore.options.PutOptions; import org.jclouds.blobstore.reference.BlobStoreConstants; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; import org.jclouds.domain.LocationScope; import org.jclouds.io.ContentMetadata; import org.jclouds.io.ContentMetadataBuilder; import org.jclouds.location.suppliers.LocationsSupplier; import org.jclouds.logging.Logger; import com.aliyun.oss.OSS; import com.aliyun.oss.model.AccessControlList; import com.aliyun.oss.model.Bucket; import com.aliyun.oss.model.CannedAccessControlList; import com.aliyun.oss.model.CreateBucketRequest; import com.aliyun.oss.model.DeleteObjectsRequest; import com.aliyun.oss.model.GetObjectRequest; import com.aliyun.oss.model.Grant; import com.aliyun.oss.model.GroupGrantee; import com.aliyun.oss.model.ListObjectsRequest; import com.aliyun.oss.model.OSSObject; import com.aliyun.oss.model.OSSObjectSummary; import com.aliyun.oss.model.ObjectAcl; import com.aliyun.oss.model.ObjectListing; import com.aliyun.oss.model.ObjectPermission; import com.aliyun.oss.model.PutObjectResult; import com.google.common.base.Function; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet;
package org.jclouds.aliyun.oss.blobstore; @Singleton public class OSSBlobStore extends BaseBlobStore { @Resource @Named(BlobStoreConstants.BLOBSTORE_LOGGER) private Logger logger = Logger.NULL;
// Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/OSSApi.java // public interface OSSApi extends Closeable { // // static final String DEFAULT_REGION = "oss-cn-hangzhou"; // // OSS getOSSClient(String region); // // Set<String> getAvailableRegions(); // } // // Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/blobstore/functions/RegionToLocation.java // public class RegionToLocation implements Function<String, Location> { // // @Override // public Location apply(String input) { // LocationBuilder builder = new LocationBuilder(); // builder.scope(LocationScope.REGION); // builder.id(input); // builder.description(input); // return builder.build(); // } // } // Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/blobstore/OSSBlobStore.java import static com.google.common.collect.Iterables.transform; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Set; import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.aliyun.oss.OSSApi; import org.jclouds.aliyun.oss.blobstore.functions.RegionToLocation; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobAccess; import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.ContainerAccess; import org.jclouds.blobstore.domain.PageSet; import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.domain.StorageType; import org.jclouds.blobstore.domain.internal.BlobMetadataImpl; import org.jclouds.blobstore.domain.internal.PageSetImpl; import org.jclouds.blobstore.domain.internal.StorageMetadataImpl; import org.jclouds.blobstore.internal.BaseBlobStore; import org.jclouds.blobstore.options.CreateContainerOptions; import org.jclouds.blobstore.options.GetOptions; import org.jclouds.blobstore.options.ListContainerOptions; import org.jclouds.blobstore.options.PutOptions; import org.jclouds.blobstore.reference.BlobStoreConstants; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; import org.jclouds.domain.LocationScope; import org.jclouds.io.ContentMetadata; import org.jclouds.io.ContentMetadataBuilder; import org.jclouds.location.suppliers.LocationsSupplier; import org.jclouds.logging.Logger; import com.aliyun.oss.OSS; import com.aliyun.oss.model.AccessControlList; import com.aliyun.oss.model.Bucket; import com.aliyun.oss.model.CannedAccessControlList; import com.aliyun.oss.model.CreateBucketRequest; import com.aliyun.oss.model.DeleteObjectsRequest; import com.aliyun.oss.model.GetObjectRequest; import com.aliyun.oss.model.Grant; import com.aliyun.oss.model.GroupGrantee; import com.aliyun.oss.model.ListObjectsRequest; import com.aliyun.oss.model.OSSObject; import com.aliyun.oss.model.OSSObjectSummary; import com.aliyun.oss.model.ObjectAcl; import com.aliyun.oss.model.ObjectListing; import com.aliyun.oss.model.ObjectPermission; import com.aliyun.oss.model.PutObjectResult; import com.google.common.base.Function; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; package org.jclouds.aliyun.oss.blobstore; @Singleton public class OSSBlobStore extends BaseBlobStore { @Resource @Named(BlobStoreConstants.BLOBSTORE_LOGGER) private Logger logger = Logger.NULL;
protected final OSSApi api;
aliyun-beta/aliyun-jclouds
aliyun-oss/src/main/java/org/jclouds/aliyun/oss/blobstore/OSSBlobStore.java
// Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/OSSApi.java // public interface OSSApi extends Closeable { // // static final String DEFAULT_REGION = "oss-cn-hangzhou"; // // OSS getOSSClient(String region); // // Set<String> getAvailableRegions(); // } // // Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/blobstore/functions/RegionToLocation.java // public class RegionToLocation implements Function<String, Location> { // // @Override // public Location apply(String input) { // LocationBuilder builder = new LocationBuilder(); // builder.scope(LocationScope.REGION); // builder.id(input); // builder.description(input); // return builder.build(); // } // }
import static com.google.common.collect.Iterables.transform; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Set; import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.aliyun.oss.OSSApi; import org.jclouds.aliyun.oss.blobstore.functions.RegionToLocation; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobAccess; import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.ContainerAccess; import org.jclouds.blobstore.domain.PageSet; import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.domain.StorageType; import org.jclouds.blobstore.domain.internal.BlobMetadataImpl; import org.jclouds.blobstore.domain.internal.PageSetImpl; import org.jclouds.blobstore.domain.internal.StorageMetadataImpl; import org.jclouds.blobstore.internal.BaseBlobStore; import org.jclouds.blobstore.options.CreateContainerOptions; import org.jclouds.blobstore.options.GetOptions; import org.jclouds.blobstore.options.ListContainerOptions; import org.jclouds.blobstore.options.PutOptions; import org.jclouds.blobstore.reference.BlobStoreConstants; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; import org.jclouds.domain.LocationScope; import org.jclouds.io.ContentMetadata; import org.jclouds.io.ContentMetadataBuilder; import org.jclouds.location.suppliers.LocationsSupplier; import org.jclouds.logging.Logger; import com.aliyun.oss.OSS; import com.aliyun.oss.model.AccessControlList; import com.aliyun.oss.model.Bucket; import com.aliyun.oss.model.CannedAccessControlList; import com.aliyun.oss.model.CreateBucketRequest; import com.aliyun.oss.model.DeleteObjectsRequest; import com.aliyun.oss.model.GetObjectRequest; import com.aliyun.oss.model.Grant; import com.aliyun.oss.model.GroupGrantee; import com.aliyun.oss.model.ListObjectsRequest; import com.aliyun.oss.model.OSSObject; import com.aliyun.oss.model.OSSObjectSummary; import com.aliyun.oss.model.ObjectAcl; import com.aliyun.oss.model.ObjectListing; import com.aliyun.oss.model.ObjectPermission; import com.aliyun.oss.model.PutObjectResult; import com.google.common.base.Function; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet;
package org.jclouds.aliyun.oss.blobstore; @Singleton public class OSSBlobStore extends BaseBlobStore { @Resource @Named(BlobStoreConstants.BLOBSTORE_LOGGER) private Logger logger = Logger.NULL; protected final OSSApi api; protected final Map<ContainerAccess, CannedAccessControlList> bucketAccesses; protected final Map<BlobAccess, CannedAccessControlList> blobAccesses; @Inject protected OSSBlobStore( OSSApi api, BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation, LocationsSupplier locations, Supplier<Map<ContainerAccess, CannedAccessControlList>> bucketAccesses, Supplier<Map<BlobAccess, CannedAccessControlList>> blobAccesses) { super(context, blobUtils, defaultLocation, locations); this.api = api; this.bucketAccesses = bucketAccesses.get(); this.blobAccesses = blobAccesses.get(); } @Override public Set<? extends Location> listAssignableLocations() { return ImmutableSet.<Location> builder()
// Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/OSSApi.java // public interface OSSApi extends Closeable { // // static final String DEFAULT_REGION = "oss-cn-hangzhou"; // // OSS getOSSClient(String region); // // Set<String> getAvailableRegions(); // } // // Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/blobstore/functions/RegionToLocation.java // public class RegionToLocation implements Function<String, Location> { // // @Override // public Location apply(String input) { // LocationBuilder builder = new LocationBuilder(); // builder.scope(LocationScope.REGION); // builder.id(input); // builder.description(input); // return builder.build(); // } // } // Path: aliyun-oss/src/main/java/org/jclouds/aliyun/oss/blobstore/OSSBlobStore.java import static com.google.common.collect.Iterables.transform; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Set; import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.aliyun.oss.OSSApi; import org.jclouds.aliyun.oss.blobstore.functions.RegionToLocation; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobAccess; import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.ContainerAccess; import org.jclouds.blobstore.domain.PageSet; import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.domain.StorageType; import org.jclouds.blobstore.domain.internal.BlobMetadataImpl; import org.jclouds.blobstore.domain.internal.PageSetImpl; import org.jclouds.blobstore.domain.internal.StorageMetadataImpl; import org.jclouds.blobstore.internal.BaseBlobStore; import org.jclouds.blobstore.options.CreateContainerOptions; import org.jclouds.blobstore.options.GetOptions; import org.jclouds.blobstore.options.ListContainerOptions; import org.jclouds.blobstore.options.PutOptions; import org.jclouds.blobstore.reference.BlobStoreConstants; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; import org.jclouds.domain.LocationScope; import org.jclouds.io.ContentMetadata; import org.jclouds.io.ContentMetadataBuilder; import org.jclouds.location.suppliers.LocationsSupplier; import org.jclouds.logging.Logger; import com.aliyun.oss.OSS; import com.aliyun.oss.model.AccessControlList; import com.aliyun.oss.model.Bucket; import com.aliyun.oss.model.CannedAccessControlList; import com.aliyun.oss.model.CreateBucketRequest; import com.aliyun.oss.model.DeleteObjectsRequest; import com.aliyun.oss.model.GetObjectRequest; import com.aliyun.oss.model.Grant; import com.aliyun.oss.model.GroupGrantee; import com.aliyun.oss.model.ListObjectsRequest; import com.aliyun.oss.model.OSSObject; import com.aliyun.oss.model.OSSObjectSummary; import com.aliyun.oss.model.ObjectAcl; import com.aliyun.oss.model.ObjectListing; import com.aliyun.oss.model.ObjectPermission; import com.aliyun.oss.model.PutObjectResult; import com.google.common.base.Function; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; package org.jclouds.aliyun.oss.blobstore; @Singleton public class OSSBlobStore extends BaseBlobStore { @Resource @Named(BlobStoreConstants.BLOBSTORE_LOGGER) private Logger logger = Logger.NULL; protected final OSSApi api; protected final Map<ContainerAccess, CannedAccessControlList> bucketAccesses; protected final Map<BlobAccess, CannedAccessControlList> blobAccesses; @Inject protected OSSBlobStore( OSSApi api, BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation, LocationsSupplier locations, Supplier<Map<ContainerAccess, CannedAccessControlList>> bucketAccesses, Supplier<Map<BlobAccess, CannedAccessControlList>> blobAccesses) { super(context, blobUtils, defaultLocation, locations); this.api = api; this.bucketAccesses = bucketAccesses.get(); this.blobAccesses = blobAccesses.get(); } @Override public Set<? extends Location> listAssignableLocations() { return ImmutableSet.<Location> builder()
.addAll(transform(api.getAvailableRegions(), new RegionToLocation()))
aliyun-beta/aliyun-jclouds
aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/internal/SLBLoadBalancerServiceContextImpl.java
// Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/SLBLoadBalancerService.java // @Singleton // public class SLBLoadBalancerService extends BaseLoadBalancerService { // // protected final LoadBalancerServiceAdapter<LoadBalancerMetadata, Location> adapter; // // @Inject // protected SLBLoadBalancerService( // LoadBalancerServiceAdapter<LoadBalancerMetadata, Location> adapter, // LoadBalancerServiceContext context, // Supplier<Location> defaultLocationSupplier, // @Memoized Supplier<Set<? extends Location>> locations, // LoadBalanceNodesStrategy loadBalancerStrategy, // GetLoadBalancerMetadataStrategy getLoadBalancerMetadataStrategy, // DestroyLoadBalancerStrategy destroyLoadBalancerStrategy, // ListLoadBalancersStrategy listLoadBalancersStrategy) { // super(defaultLocationSupplier, context, loadBalancerStrategy, // getLoadBalancerMetadataStrategy, destroyLoadBalancerStrategy, // listLoadBalancersStrategy, locations); // this.adapter = adapter; // } // // @Override // public Set<? extends Location> listAssignableLocations() { // return ImmutableSet.<Location> builder() // .addAll(adapter.listAssignableLocations()) // .build(); // } // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/SLBLoadBalancerServiceContext.java // @ImplementedBy(SLBLoadBalancerServiceContextImpl.class) // public interface SLBLoadBalancerServiceContext extends LoadBalancerServiceContext { // // @Override // SLBLoadBalancerService getLoadBalancerService(); // }
import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.Context; import org.jclouds.aliyun.slb.loadbalancer.SLBLoadBalancerService; import org.jclouds.aliyun.slb.loadbalancer.SLBLoadBalancerServiceContext; import org.jclouds.loadbalancer.LoadBalancerService; import org.jclouds.loadbalancer.internal.LoadBalancerServiceContextImpl; import org.jclouds.location.Provider; import org.jclouds.rest.Utils; import com.google.common.reflect.TypeToken;
package org.jclouds.aliyun.slb.loadbalancer.internal; @Singleton public class SLBLoadBalancerServiceContextImpl extends LoadBalancerServiceContextImpl implements SLBLoadBalancerServiceContext { @Inject public SLBLoadBalancerServiceContextImpl( @Provider Context backend, @Provider TypeToken<? extends Context> backendType, LoadBalancerService loadBalancerService, Utils utils) { super(backend, backendType, loadBalancerService, utils); } @Override
// Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/SLBLoadBalancerService.java // @Singleton // public class SLBLoadBalancerService extends BaseLoadBalancerService { // // protected final LoadBalancerServiceAdapter<LoadBalancerMetadata, Location> adapter; // // @Inject // protected SLBLoadBalancerService( // LoadBalancerServiceAdapter<LoadBalancerMetadata, Location> adapter, // LoadBalancerServiceContext context, // Supplier<Location> defaultLocationSupplier, // @Memoized Supplier<Set<? extends Location>> locations, // LoadBalanceNodesStrategy loadBalancerStrategy, // GetLoadBalancerMetadataStrategy getLoadBalancerMetadataStrategy, // DestroyLoadBalancerStrategy destroyLoadBalancerStrategy, // ListLoadBalancersStrategy listLoadBalancersStrategy) { // super(defaultLocationSupplier, context, loadBalancerStrategy, // getLoadBalancerMetadataStrategy, destroyLoadBalancerStrategy, // listLoadBalancersStrategy, locations); // this.adapter = adapter; // } // // @Override // public Set<? extends Location> listAssignableLocations() { // return ImmutableSet.<Location> builder() // .addAll(adapter.listAssignableLocations()) // .build(); // } // } // // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/SLBLoadBalancerServiceContext.java // @ImplementedBy(SLBLoadBalancerServiceContextImpl.class) // public interface SLBLoadBalancerServiceContext extends LoadBalancerServiceContext { // // @Override // SLBLoadBalancerService getLoadBalancerService(); // } // Path: aliyun-slb/src/main/java/org/jclouds/aliyun/slb/loadbalancer/internal/SLBLoadBalancerServiceContextImpl.java import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.Context; import org.jclouds.aliyun.slb.loadbalancer.SLBLoadBalancerService; import org.jclouds.aliyun.slb.loadbalancer.SLBLoadBalancerServiceContext; import org.jclouds.loadbalancer.LoadBalancerService; import org.jclouds.loadbalancer.internal.LoadBalancerServiceContextImpl; import org.jclouds.location.Provider; import org.jclouds.rest.Utils; import com.google.common.reflect.TypeToken; package org.jclouds.aliyun.slb.loadbalancer.internal; @Singleton public class SLBLoadBalancerServiceContextImpl extends LoadBalancerServiceContextImpl implements SLBLoadBalancerServiceContext { @Inject public SLBLoadBalancerServiceContextImpl( @Provider Context backend, @Provider TypeToken<? extends Context> backendType, LoadBalancerService loadBalancerService, Utils utils) { super(backend, backendType, loadBalancerService, utils); } @Override
public SLBLoadBalancerService getLoadBalancerService() {
LWJGLX/debug
src/org/lwjglx/debug/org/lwjgl/opengl/ARBDirectStateAccess.java
// Path: src/org/lwjglx/debug/Properties.java // public class Properties { // // public static class BooleanProperty { // public boolean enabled; // public boolean byDefault = true; // // public void enable() { // this.enabled = true; // this.byDefault = false; // } // // public void disableIfByDefault() { // if (this.byDefault) { // this.enabled = false; // this.byDefault = false; // } // } // } // // public static final BooleanProperty VALIDATE = getBooleanProperty("org.lwjglx.VALIDATE", true); // public static final BooleanProperty STRICT = getBooleanProperty("org.lwjglx.STRICT", false); // public static final BooleanProperty DEBUG = getBooleanProperty("org.lwjglx.DEBUG", false); // public static final BooleanProperty TRACE = getBooleanProperty("org.lwjglx.TRACE", false); // public static final BooleanProperty NO_THROW_ON_ERROR = getBooleanProperty("org.lwjglx.NO_THROW", false); // public static String OUTPUT = System.getProperty("org.lwjglx.OUTPUT", null); // public static long SLEEP = getLongProperty("org.lwjglx.SLEEP", 0L); // // private static BooleanProperty getBooleanProperty(String prop, boolean def) { // String value = System.getProperty(prop); // BooleanProperty p = new BooleanProperty(); // if (value != null) { // p.byDefault = false; // p.enabled = value.equals("") || Boolean.valueOf(value); // } else { // p.byDefault = true; // p.enabled = def; // } // return p; // } // // private static long getLongProperty(String prop, long def) { // String value = System.getProperty(prop); // try { // if (value != null) // return Long.valueOf(value); // return def; // } catch (NumberFormatException e) { // throw new AssertionError("System property [" + prop + "] is not an integer: " + value); // } // } // // } // // Path: src/org/lwjglx/debug/org/lwjgl/opengl/Context.java // public static class VAO { // public boolean[] enabledVertexArrays; // public boolean[] initializedVertexArrays; // public boolean vertexArrayEnabled; // public boolean vertexArrayInitialized; // public boolean normalArrayEnabled; // public boolean normalArrayInitialized; // public boolean colorArrayEnabled; // public boolean colorArrayInitialized; // public boolean texCoordArrayEnabled; // public boolean texCoordArrayInitialized; // // public VAO(int GL_MAX_VERTEX_ATTRIBS) { // this.enabledVertexArrays = new boolean[GL_MAX_VERTEX_ATTRIBS]; // this.initializedVertexArrays = new boolean[GL_MAX_VERTEX_ATTRIBS]; // } // }
import java.nio.IntBuffer; import org.lwjglx.debug.Properties; import org.lwjglx.debug.org.lwjgl.opengl.Context.VAO;
/* * (C) Copyright 2017 Kai Burjack Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package org.lwjglx.debug.org.lwjgl.opengl; public class ARBDirectStateAccess { public static void glCreateVertexArrays(IntBuffer arrays) { org.lwjgl.opengl.ARBDirectStateAccess.glCreateVertexArrays(arrays);
// Path: src/org/lwjglx/debug/Properties.java // public class Properties { // // public static class BooleanProperty { // public boolean enabled; // public boolean byDefault = true; // // public void enable() { // this.enabled = true; // this.byDefault = false; // } // // public void disableIfByDefault() { // if (this.byDefault) { // this.enabled = false; // this.byDefault = false; // } // } // } // // public static final BooleanProperty VALIDATE = getBooleanProperty("org.lwjglx.VALIDATE", true); // public static final BooleanProperty STRICT = getBooleanProperty("org.lwjglx.STRICT", false); // public static final BooleanProperty DEBUG = getBooleanProperty("org.lwjglx.DEBUG", false); // public static final BooleanProperty TRACE = getBooleanProperty("org.lwjglx.TRACE", false); // public static final BooleanProperty NO_THROW_ON_ERROR = getBooleanProperty("org.lwjglx.NO_THROW", false); // public static String OUTPUT = System.getProperty("org.lwjglx.OUTPUT", null); // public static long SLEEP = getLongProperty("org.lwjglx.SLEEP", 0L); // // private static BooleanProperty getBooleanProperty(String prop, boolean def) { // String value = System.getProperty(prop); // BooleanProperty p = new BooleanProperty(); // if (value != null) { // p.byDefault = false; // p.enabled = value.equals("") || Boolean.valueOf(value); // } else { // p.byDefault = true; // p.enabled = def; // } // return p; // } // // private static long getLongProperty(String prop, long def) { // String value = System.getProperty(prop); // try { // if (value != null) // return Long.valueOf(value); // return def; // } catch (NumberFormatException e) { // throw new AssertionError("System property [" + prop + "] is not an integer: " + value); // } // } // // } // // Path: src/org/lwjglx/debug/org/lwjgl/opengl/Context.java // public static class VAO { // public boolean[] enabledVertexArrays; // public boolean[] initializedVertexArrays; // public boolean vertexArrayEnabled; // public boolean vertexArrayInitialized; // public boolean normalArrayEnabled; // public boolean normalArrayInitialized; // public boolean colorArrayEnabled; // public boolean colorArrayInitialized; // public boolean texCoordArrayEnabled; // public boolean texCoordArrayInitialized; // // public VAO(int GL_MAX_VERTEX_ATTRIBS) { // this.enabledVertexArrays = new boolean[GL_MAX_VERTEX_ATTRIBS]; // this.initializedVertexArrays = new boolean[GL_MAX_VERTEX_ATTRIBS]; // } // } // Path: src/org/lwjglx/debug/org/lwjgl/opengl/ARBDirectStateAccess.java import java.nio.IntBuffer; import org.lwjglx.debug.Properties; import org.lwjglx.debug.org.lwjgl.opengl.Context.VAO; /* * (C) Copyright 2017 Kai Burjack Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package org.lwjglx.debug.org.lwjgl.opengl; public class ARBDirectStateAccess { public static void glCreateVertexArrays(IntBuffer arrays) { org.lwjgl.opengl.ARBDirectStateAccess.glCreateVertexArrays(arrays);
if (Properties.VALIDATE.enabled) {
LWJGLX/debug
src/org/lwjglx/debug/org/lwjgl/opengl/ARBDirectStateAccess.java
// Path: src/org/lwjglx/debug/Properties.java // public class Properties { // // public static class BooleanProperty { // public boolean enabled; // public boolean byDefault = true; // // public void enable() { // this.enabled = true; // this.byDefault = false; // } // // public void disableIfByDefault() { // if (this.byDefault) { // this.enabled = false; // this.byDefault = false; // } // } // } // // public static final BooleanProperty VALIDATE = getBooleanProperty("org.lwjglx.VALIDATE", true); // public static final BooleanProperty STRICT = getBooleanProperty("org.lwjglx.STRICT", false); // public static final BooleanProperty DEBUG = getBooleanProperty("org.lwjglx.DEBUG", false); // public static final BooleanProperty TRACE = getBooleanProperty("org.lwjglx.TRACE", false); // public static final BooleanProperty NO_THROW_ON_ERROR = getBooleanProperty("org.lwjglx.NO_THROW", false); // public static String OUTPUT = System.getProperty("org.lwjglx.OUTPUT", null); // public static long SLEEP = getLongProperty("org.lwjglx.SLEEP", 0L); // // private static BooleanProperty getBooleanProperty(String prop, boolean def) { // String value = System.getProperty(prop); // BooleanProperty p = new BooleanProperty(); // if (value != null) { // p.byDefault = false; // p.enabled = value.equals("") || Boolean.valueOf(value); // } else { // p.byDefault = true; // p.enabled = def; // } // return p; // } // // private static long getLongProperty(String prop, long def) { // String value = System.getProperty(prop); // try { // if (value != null) // return Long.valueOf(value); // return def; // } catch (NumberFormatException e) { // throw new AssertionError("System property [" + prop + "] is not an integer: " + value); // } // } // // } // // Path: src/org/lwjglx/debug/org/lwjgl/opengl/Context.java // public static class VAO { // public boolean[] enabledVertexArrays; // public boolean[] initializedVertexArrays; // public boolean vertexArrayEnabled; // public boolean vertexArrayInitialized; // public boolean normalArrayEnabled; // public boolean normalArrayInitialized; // public boolean colorArrayEnabled; // public boolean colorArrayInitialized; // public boolean texCoordArrayEnabled; // public boolean texCoordArrayInitialized; // // public VAO(int GL_MAX_VERTEX_ATTRIBS) { // this.enabledVertexArrays = new boolean[GL_MAX_VERTEX_ATTRIBS]; // this.initializedVertexArrays = new boolean[GL_MAX_VERTEX_ATTRIBS]; // } // }
import java.nio.IntBuffer; import org.lwjglx.debug.Properties; import org.lwjglx.debug.org.lwjgl.opengl.Context.VAO;
/* * (C) Copyright 2017 Kai Burjack Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package org.lwjglx.debug.org.lwjgl.opengl; public class ARBDirectStateAccess { public static void glCreateVertexArrays(IntBuffer arrays) { org.lwjgl.opengl.ARBDirectStateAccess.glCreateVertexArrays(arrays); if (Properties.VALIDATE.enabled) { Context context = Context.currentContext(); int position = arrays.position(); for (int i = 0; i < arrays.remaining(); i++) {
// Path: src/org/lwjglx/debug/Properties.java // public class Properties { // // public static class BooleanProperty { // public boolean enabled; // public boolean byDefault = true; // // public void enable() { // this.enabled = true; // this.byDefault = false; // } // // public void disableIfByDefault() { // if (this.byDefault) { // this.enabled = false; // this.byDefault = false; // } // } // } // // public static final BooleanProperty VALIDATE = getBooleanProperty("org.lwjglx.VALIDATE", true); // public static final BooleanProperty STRICT = getBooleanProperty("org.lwjglx.STRICT", false); // public static final BooleanProperty DEBUG = getBooleanProperty("org.lwjglx.DEBUG", false); // public static final BooleanProperty TRACE = getBooleanProperty("org.lwjglx.TRACE", false); // public static final BooleanProperty NO_THROW_ON_ERROR = getBooleanProperty("org.lwjglx.NO_THROW", false); // public static String OUTPUT = System.getProperty("org.lwjglx.OUTPUT", null); // public static long SLEEP = getLongProperty("org.lwjglx.SLEEP", 0L); // // private static BooleanProperty getBooleanProperty(String prop, boolean def) { // String value = System.getProperty(prop); // BooleanProperty p = new BooleanProperty(); // if (value != null) { // p.byDefault = false; // p.enabled = value.equals("") || Boolean.valueOf(value); // } else { // p.byDefault = true; // p.enabled = def; // } // return p; // } // // private static long getLongProperty(String prop, long def) { // String value = System.getProperty(prop); // try { // if (value != null) // return Long.valueOf(value); // return def; // } catch (NumberFormatException e) { // throw new AssertionError("System property [" + prop + "] is not an integer: " + value); // } // } // // } // // Path: src/org/lwjglx/debug/org/lwjgl/opengl/Context.java // public static class VAO { // public boolean[] enabledVertexArrays; // public boolean[] initializedVertexArrays; // public boolean vertexArrayEnabled; // public boolean vertexArrayInitialized; // public boolean normalArrayEnabled; // public boolean normalArrayInitialized; // public boolean colorArrayEnabled; // public boolean colorArrayInitialized; // public boolean texCoordArrayEnabled; // public boolean texCoordArrayInitialized; // // public VAO(int GL_MAX_VERTEX_ATTRIBS) { // this.enabledVertexArrays = new boolean[GL_MAX_VERTEX_ATTRIBS]; // this.initializedVertexArrays = new boolean[GL_MAX_VERTEX_ATTRIBS]; // } // } // Path: src/org/lwjglx/debug/org/lwjgl/opengl/ARBDirectStateAccess.java import java.nio.IntBuffer; import org.lwjglx.debug.Properties; import org.lwjglx.debug.org.lwjgl.opengl.Context.VAO; /* * (C) Copyright 2017 Kai Burjack Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package org.lwjglx.debug.org.lwjgl.opengl; public class ARBDirectStateAccess { public static void glCreateVertexArrays(IntBuffer arrays) { org.lwjgl.opengl.ARBDirectStateAccess.glCreateVertexArrays(arrays); if (Properties.VALIDATE.enabled) { Context context = Context.currentContext(); int position = arrays.position(); for (int i = 0; i < arrays.remaining(); i++) {
VAO vao = new VAO(context.GL_MAX_VERTEX_ATTRIBS);
LWJGLX/debug
src/org/lwjglx/debug/org/lwjgl/opengl/EXTSeparateShaderObjects.java
// Path: src/org/lwjglx/debug/Log.java // public static void trace(String message) { // log("trace", message); // } // // Path: src/org/lwjglx/debug/Properties.java // public class Properties { // // public static class BooleanProperty { // public boolean enabled; // public boolean byDefault = true; // // public void enable() { // this.enabled = true; // this.byDefault = false; // } // // public void disableIfByDefault() { // if (this.byDefault) { // this.enabled = false; // this.byDefault = false; // } // } // } // // public static final BooleanProperty VALIDATE = getBooleanProperty("org.lwjglx.VALIDATE", true); // public static final BooleanProperty STRICT = getBooleanProperty("org.lwjglx.STRICT", false); // public static final BooleanProperty DEBUG = getBooleanProperty("org.lwjglx.DEBUG", false); // public static final BooleanProperty TRACE = getBooleanProperty("org.lwjglx.TRACE", false); // public static final BooleanProperty NO_THROW_ON_ERROR = getBooleanProperty("org.lwjglx.NO_THROW", false); // public static String OUTPUT = System.getProperty("org.lwjglx.OUTPUT", null); // public static long SLEEP = getLongProperty("org.lwjglx.SLEEP", 0L); // // private static BooleanProperty getBooleanProperty(String prop, boolean def) { // String value = System.getProperty(prop); // BooleanProperty p = new BooleanProperty(); // if (value != null) { // p.byDefault = false; // p.enabled = value.equals("") || Boolean.valueOf(value); // } else { // p.byDefault = true; // p.enabled = def; // } // return p; // } // // private static long getLongProperty(String prop, long def) { // String value = System.getProperty(prop); // try { // if (value != null) // return Long.valueOf(value); // return def; // } catch (NumberFormatException e) { // throw new AssertionError("System property [" + prop + "] is not an integer: " + value); // } // } // // }
import static org.lwjglx.debug.Log.trace; import static org.lwjglx.debug.Properties.*; import java.nio.ByteBuffer;
/* * (C) Copyright 2017 Kai Burjack Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package org.lwjglx.debug.org.lwjgl.opengl; public class EXTSeparateShaderObjects { public static int glCreateShaderProgramEXT(int type, ByteBuffer string) { int shader = org.lwjgl.opengl.EXTSeparateShaderObjects.glCreateShaderProgramEXT(type, string); if (TRACE.enabled) { /* Log the shader source */ StringBuilder sb = new StringBuilder(); if (string != null) { String source = org.lwjgl.system.MemoryUtil.memASCII(string); sb.append(source); }
// Path: src/org/lwjglx/debug/Log.java // public static void trace(String message) { // log("trace", message); // } // // Path: src/org/lwjglx/debug/Properties.java // public class Properties { // // public static class BooleanProperty { // public boolean enabled; // public boolean byDefault = true; // // public void enable() { // this.enabled = true; // this.byDefault = false; // } // // public void disableIfByDefault() { // if (this.byDefault) { // this.enabled = false; // this.byDefault = false; // } // } // } // // public static final BooleanProperty VALIDATE = getBooleanProperty("org.lwjglx.VALIDATE", true); // public static final BooleanProperty STRICT = getBooleanProperty("org.lwjglx.STRICT", false); // public static final BooleanProperty DEBUG = getBooleanProperty("org.lwjglx.DEBUG", false); // public static final BooleanProperty TRACE = getBooleanProperty("org.lwjglx.TRACE", false); // public static final BooleanProperty NO_THROW_ON_ERROR = getBooleanProperty("org.lwjglx.NO_THROW", false); // public static String OUTPUT = System.getProperty("org.lwjglx.OUTPUT", null); // public static long SLEEP = getLongProperty("org.lwjglx.SLEEP", 0L); // // private static BooleanProperty getBooleanProperty(String prop, boolean def) { // String value = System.getProperty(prop); // BooleanProperty p = new BooleanProperty(); // if (value != null) { // p.byDefault = false; // p.enabled = value.equals("") || Boolean.valueOf(value); // } else { // p.byDefault = true; // p.enabled = def; // } // return p; // } // // private static long getLongProperty(String prop, long def) { // String value = System.getProperty(prop); // try { // if (value != null) // return Long.valueOf(value); // return def; // } catch (NumberFormatException e) { // throw new AssertionError("System property [" + prop + "] is not an integer: " + value); // } // } // // } // Path: src/org/lwjglx/debug/org/lwjgl/opengl/EXTSeparateShaderObjects.java import static org.lwjglx.debug.Log.trace; import static org.lwjglx.debug.Properties.*; import java.nio.ByteBuffer; /* * (C) Copyright 2017 Kai Burjack Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package org.lwjglx.debug.org.lwjgl.opengl; public class EXTSeparateShaderObjects { public static int glCreateShaderProgramEXT(int type, ByteBuffer string) { int shader = org.lwjgl.opengl.EXTSeparateShaderObjects.glCreateShaderProgramEXT(type, string); if (TRACE.enabled) { /* Log the shader source */ StringBuilder sb = new StringBuilder(); if (string != null) { String source = org.lwjgl.system.MemoryUtil.memASCII(string); sb.append(source); }
trace("Shader source for shader [" + shader + "]:\n" + sb.toString());
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/bulkonly/UsbFacade.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/EndianessUtil.java // public class EndianessUtil // { // private EndianessUtil() // { // // } // // public static int swapEndianess(int i) // { // return((i&0xff)<<24)+((i&0xff00)<<8)+((i&0xff0000)>>8)+((i>>24)&0xff); // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // // Path: src/main/java/commandwrappers/CommandWrapper.java // public abstract class CommandWrapper // { // public static final int CBW_SIGNATURE = 0x43425355; // public static final int CBS_SIGNATURE = 0x53425355; // public static final int CBW_SIZE = 31; // public static final int CBS_SIZE = 13; // // public CommandWrapper() // { // // } // // public abstract byte[] getCWBuffer(); // // // protected class CommandBlock // { // // 128 bit command instruction // private int data1; // Most Significant // private int data2; // private int data3; // private int data4; // Less Significant // // public CommandBlock(int data1, int data2, int data3, int data4) // { // this.data1 = data1; // this.data2 = data2; // this.data3 = data3; // this.data4 = data4; // } // // public byte[] getBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(4); // buffer.putInt(data1); // buffer.putInt(data2); // buffer.putInt(data3); // buffer.putInt(data4); // return buffer.array(); // } // // } // // }
import android.hardware.usb.UsbConstants; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbDeviceConnection; import android.hardware.usb.UsbEndpoint; import android.hardware.usb.UsbInterface; import android.os.Handler; import android.os.Looper; import android.os.Message; import com.felhr.usbmassstorageforandroid.utilities.EndianessUtil; import java.nio.ByteBuffer; import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean; import commandwrappers.CommandBlockWrapper; import commandwrappers.CommandWrapper;
Looper.loop(); } } private class DataInThread extends Thread { private byte[] buffer; private AtomicBoolean keep; private AtomicBoolean waiting; public DataInThread() { this.buffer = new byte[USB_ENDPOINT_LENGTH]; this.keep = new AtomicBoolean(true); this.waiting = new AtomicBoolean(true); } @Override public void run() { waitTillBufferSet(); while(keep.get()) { int response = mConnection.bulkTransfer(inEndpoint, buffer, USB_IN_BUFFER_LENGTH, 0); if(response > 0) { byte[] receivedData = new byte[response]; System.arraycopy(buffer, 0, receivedData, 0, response); int cswSignature = 0;
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/EndianessUtil.java // public class EndianessUtil // { // private EndianessUtil() // { // // } // // public static int swapEndianess(int i) // { // return((i&0xff)<<24)+((i&0xff00)<<8)+((i&0xff0000)>>8)+((i>>24)&0xff); // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // // Path: src/main/java/commandwrappers/CommandWrapper.java // public abstract class CommandWrapper // { // public static final int CBW_SIGNATURE = 0x43425355; // public static final int CBS_SIGNATURE = 0x53425355; // public static final int CBW_SIZE = 31; // public static final int CBS_SIZE = 13; // // public CommandWrapper() // { // // } // // public abstract byte[] getCWBuffer(); // // // protected class CommandBlock // { // // 128 bit command instruction // private int data1; // Most Significant // private int data2; // private int data3; // private int data4; // Less Significant // // public CommandBlock(int data1, int data2, int data3, int data4) // { // this.data1 = data1; // this.data2 = data2; // this.data3 = data3; // this.data4 = data4; // } // // public byte[] getBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(4); // buffer.putInt(data1); // buffer.putInt(data2); // buffer.putInt(data3); // buffer.putInt(data4); // return buffer.array(); // } // // } // // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/bulkonly/UsbFacade.java import android.hardware.usb.UsbConstants; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbDeviceConnection; import android.hardware.usb.UsbEndpoint; import android.hardware.usb.UsbInterface; import android.os.Handler; import android.os.Looper; import android.os.Message; import com.felhr.usbmassstorageforandroid.utilities.EndianessUtil; import java.nio.ByteBuffer; import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean; import commandwrappers.CommandBlockWrapper; import commandwrappers.CommandWrapper; Looper.loop(); } } private class DataInThread extends Thread { private byte[] buffer; private AtomicBoolean keep; private AtomicBoolean waiting; public DataInThread() { this.buffer = new byte[USB_ENDPOINT_LENGTH]; this.keep = new AtomicBoolean(true); this.waiting = new AtomicBoolean(true); } @Override public void run() { waitTillBufferSet(); while(keep.get()) { int response = mConnection.bulkTransfer(inEndpoint, buffer, USB_IN_BUFFER_LENGTH, 0); if(response > 0) { byte[] receivedData = new byte[response]; System.arraycopy(buffer, 0, receivedData, 0, response); int cswSignature = 0;
if(response == CommandWrapper.CBS_SIZE)
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/bulkonly/UsbFacade.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/EndianessUtil.java // public class EndianessUtil // { // private EndianessUtil() // { // // } // // public static int swapEndianess(int i) // { // return((i&0xff)<<24)+((i&0xff00)<<8)+((i&0xff0000)>>8)+((i>>24)&0xff); // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // // Path: src/main/java/commandwrappers/CommandWrapper.java // public abstract class CommandWrapper // { // public static final int CBW_SIGNATURE = 0x43425355; // public static final int CBS_SIGNATURE = 0x53425355; // public static final int CBW_SIZE = 31; // public static final int CBS_SIZE = 13; // // public CommandWrapper() // { // // } // // public abstract byte[] getCWBuffer(); // // // protected class CommandBlock // { // // 128 bit command instruction // private int data1; // Most Significant // private int data2; // private int data3; // private int data4; // Less Significant // // public CommandBlock(int data1, int data2, int data3, int data4) // { // this.data1 = data1; // this.data2 = data2; // this.data3 = data3; // this.data4 = data4; // } // // public byte[] getBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(4); // buffer.putInt(data1); // buffer.putInt(data2); // buffer.putInt(data3); // buffer.putInt(data4); // return buffer.array(); // } // // } // // }
import android.hardware.usb.UsbConstants; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbDeviceConnection; import android.hardware.usb.UsbEndpoint; import android.hardware.usb.UsbInterface; import android.os.Handler; import android.os.Looper; import android.os.Message; import com.felhr.usbmassstorageforandroid.utilities.EndianessUtil; import java.nio.ByteBuffer; import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean; import commandwrappers.CommandBlockWrapper; import commandwrappers.CommandWrapper;
} } private class DataInThread extends Thread { private byte[] buffer; private AtomicBoolean keep; private AtomicBoolean waiting; public DataInThread() { this.buffer = new byte[USB_ENDPOINT_LENGTH]; this.keep = new AtomicBoolean(true); this.waiting = new AtomicBoolean(true); } @Override public void run() { waitTillBufferSet(); while(keep.get()) { int response = mConnection.bulkTransfer(inEndpoint, buffer, USB_IN_BUFFER_LENGTH, 0); if(response > 0) { byte[] receivedData = new byte[response]; System.arraycopy(buffer, 0, receivedData, 0, response); int cswSignature = 0; if(response == CommandWrapper.CBS_SIZE)
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/EndianessUtil.java // public class EndianessUtil // { // private EndianessUtil() // { // // } // // public static int swapEndianess(int i) // { // return((i&0xff)<<24)+((i&0xff00)<<8)+((i&0xff0000)>>8)+((i>>24)&0xff); // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // // Path: src/main/java/commandwrappers/CommandWrapper.java // public abstract class CommandWrapper // { // public static final int CBW_SIGNATURE = 0x43425355; // public static final int CBS_SIGNATURE = 0x53425355; // public static final int CBW_SIZE = 31; // public static final int CBS_SIZE = 13; // // public CommandWrapper() // { // // } // // public abstract byte[] getCWBuffer(); // // // protected class CommandBlock // { // // 128 bit command instruction // private int data1; // Most Significant // private int data2; // private int data3; // private int data4; // Less Significant // // public CommandBlock(int data1, int data2, int data3, int data4) // { // this.data1 = data1; // this.data2 = data2; // this.data3 = data3; // this.data4 = data4; // } // // public byte[] getBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(4); // buffer.putInt(data1); // buffer.putInt(data2); // buffer.putInt(data3); // buffer.putInt(data4); // return buffer.array(); // } // // } // // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/bulkonly/UsbFacade.java import android.hardware.usb.UsbConstants; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbDeviceConnection; import android.hardware.usb.UsbEndpoint; import android.hardware.usb.UsbInterface; import android.os.Handler; import android.os.Looper; import android.os.Message; import com.felhr.usbmassstorageforandroid.utilities.EndianessUtil; import java.nio.ByteBuffer; import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean; import commandwrappers.CommandBlockWrapper; import commandwrappers.CommandWrapper; } } private class DataInThread extends Thread { private byte[] buffer; private AtomicBoolean keep; private AtomicBoolean waiting; public DataInThread() { this.buffer = new byte[USB_ENDPOINT_LENGTH]; this.keep = new AtomicBoolean(true); this.waiting = new AtomicBoolean(true); } @Override public void run() { waitTillBufferSet(); while(keep.get()) { int response = mConnection.bulkTransfer(inEndpoint, buffer, USB_IN_BUFFER_LENGTH, 0); if(response > 0) { byte[] receivedData = new byte[response]; System.arraycopy(buffer, 0, receivedData, 0, response); int cswSignature = 0; if(response == CommandWrapper.CBS_SIZE)
cswSignature = EndianessUtil.swapEndianess(
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/bulkonly/UsbFacade.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/EndianessUtil.java // public class EndianessUtil // { // private EndianessUtil() // { // // } // // public static int swapEndianess(int i) // { // return((i&0xff)<<24)+((i&0xff00)<<8)+((i&0xff0000)>>8)+((i>>24)&0xff); // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // // Path: src/main/java/commandwrappers/CommandWrapper.java // public abstract class CommandWrapper // { // public static final int CBW_SIGNATURE = 0x43425355; // public static final int CBS_SIGNATURE = 0x53425355; // public static final int CBW_SIZE = 31; // public static final int CBS_SIZE = 13; // // public CommandWrapper() // { // // } // // public abstract byte[] getCWBuffer(); // // // protected class CommandBlock // { // // 128 bit command instruction // private int data1; // Most Significant // private int data2; // private int data3; // private int data4; // Less Significant // // public CommandBlock(int data1, int data2, int data3, int data4) // { // this.data1 = data1; // this.data2 = data2; // this.data3 = data3; // this.data4 = data4; // } // // public byte[] getBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(4); // buffer.putInt(data1); // buffer.putInt(data2); // buffer.putInt(data3); // buffer.putInt(data4); // return buffer.array(); // } // // } // // }
import android.hardware.usb.UsbConstants; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbDeviceConnection; import android.hardware.usb.UsbEndpoint; import android.hardware.usb.UsbInterface; import android.os.Handler; import android.os.Looper; import android.os.Message; import com.felhr.usbmassstorageforandroid.utilities.EndianessUtil; import java.nio.ByteBuffer; import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean; import commandwrappers.CommandBlockWrapper; import commandwrappers.CommandWrapper;
private class DataInThread extends Thread { private byte[] buffer; private AtomicBoolean keep; private AtomicBoolean waiting; public DataInThread() { this.buffer = new byte[USB_ENDPOINT_LENGTH]; this.keep = new AtomicBoolean(true); this.waiting = new AtomicBoolean(true); } @Override public void run() { waitTillBufferSet(); while(keep.get()) { int response = mConnection.bulkTransfer(inEndpoint, buffer, USB_IN_BUFFER_LENGTH, 0); if(response > 0) { byte[] receivedData = new byte[response]; System.arraycopy(buffer, 0, receivedData, 0, response); int cswSignature = 0; if(response == CommandWrapper.CBS_SIZE) cswSignature = EndianessUtil.swapEndianess( ByteBuffer.wrap(Arrays.copyOfRange(receivedData, 0, 4)).getInt());
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/EndianessUtil.java // public class EndianessUtil // { // private EndianessUtil() // { // // } // // public static int swapEndianess(int i) // { // return((i&0xff)<<24)+((i&0xff00)<<8)+((i&0xff0000)>>8)+((i>>24)&0xff); // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // // Path: src/main/java/commandwrappers/CommandWrapper.java // public abstract class CommandWrapper // { // public static final int CBW_SIGNATURE = 0x43425355; // public static final int CBS_SIGNATURE = 0x53425355; // public static final int CBW_SIZE = 31; // public static final int CBS_SIZE = 13; // // public CommandWrapper() // { // // } // // public abstract byte[] getCWBuffer(); // // // protected class CommandBlock // { // // 128 bit command instruction // private int data1; // Most Significant // private int data2; // private int data3; // private int data4; // Less Significant // // public CommandBlock(int data1, int data2, int data3, int data4) // { // this.data1 = data1; // this.data2 = data2; // this.data3 = data3; // this.data4 = data4; // } // // public byte[] getBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(4); // buffer.putInt(data1); // buffer.putInt(data2); // buffer.putInt(data3); // buffer.putInt(data4); // return buffer.array(); // } // // } // // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/bulkonly/UsbFacade.java import android.hardware.usb.UsbConstants; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbDeviceConnection; import android.hardware.usb.UsbEndpoint; import android.hardware.usb.UsbInterface; import android.os.Handler; import android.os.Looper; import android.os.Message; import com.felhr.usbmassstorageforandroid.utilities.EndianessUtil; import java.nio.ByteBuffer; import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean; import commandwrappers.CommandBlockWrapper; import commandwrappers.CommandWrapper; private class DataInThread extends Thread { private byte[] buffer; private AtomicBoolean keep; private AtomicBoolean waiting; public DataInThread() { this.buffer = new byte[USB_ENDPOINT_LENGTH]; this.keep = new AtomicBoolean(true); this.waiting = new AtomicBoolean(true); } @Override public void run() { waitTillBufferSet(); while(keep.get()) { int response = mConnection.bulkTransfer(inEndpoint, buffer, USB_IN_BUFFER_LENGTH, 0); if(response > 0) { byte[] receivedData = new byte[response]; System.arraycopy(buffer, 0, receivedData, 0, response); int cswSignature = 0; if(response == CommandWrapper.CBS_SIZE) cswSignature = EndianessUtil.swapEndianess( ByteBuffer.wrap(Arrays.copyOfRange(receivedData, 0, 4)).getInt());
if(receivedData.length == CommandWrapper.CBS_SIZE && cswSignature == CommandBlockWrapper.CBS_SIGNATURE) // It is a CSW
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/filesystems/fat32/LFNHandler.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/UnsignedUtil.java // public class UnsignedUtil { // private final static short MAX_UNSIGNED_BYTE_VALUE = 256; // private final static int MAX_UNSIGNED_SHORT_VALUE = 65536; // private final static long MAX_UNSIGNED_INT_VALUE = 4294967296L; // // private UnsignedUtil() { // // } // // public static short byteToUshort(byte value) // { // if (value < 0) // { // short complement2Value = (short) (~value + 1); // return (short) (MAX_UNSIGNED_BYTE_VALUE - complement2Value); // } else // { // return (short) value; // } // } // // public static byte ushortToByte(short value) // { // if (value <= MAX_UNSIGNED_SHORT_VALUE) // { // if (value >= MAX_UNSIGNED_BYTE_VALUE / 2) // { // return (byte) ((~(MAX_UNSIGNED_BYTE_VALUE - value)) + 1); // } else // { // return (byte) value; // } // } else // { // throw new IllegalArgumentException("Value out of range for a byte"); // } // } // // // public static int shortToUint(short value) // { // if (value < 0) // { // return MAX_UNSIGNED_SHORT_VALUE - (~value + 1); // } else // { // return value; // } // } // // // public static short uintToShort(int value) // { // if (value <= MAX_UNSIGNED_SHORT_VALUE) // { // if (value >= MAX_UNSIGNED_SHORT_VALUE / 2) // { // return (short) (~(MAX_UNSIGNED_SHORT_VALUE - value) + 1); // } else // { // return (short) value; // } // } else // { // throw new IllegalArgumentException("Value out of range for a short"); // } // } // // public static long intToUlong(int value) // { // if (value < 0) // { // long complement2Value = (~((long) value) + 1); // return MAX_UNSIGNED_INT_VALUE - complement2Value; // } else // { // return value; // } // } // // public static int ulongToInt(long value) // { // if (value <= MAX_UNSIGNED_INT_VALUE) // { // if (value >= MAX_UNSIGNED_INT_VALUE / 2) // { // return (int) (~(MAX_UNSIGNED_INT_VALUE - value) + 1); // } else // { // return (int) value; // } // } else // { // throw new IllegalArgumentException("Value out of range for a int"); // } // } // // public static byte ulongToByte(long value) throws IllegalArgumentException // { // if (value <= MAX_UNSIGNED_BYTE_VALUE) // { // if (value >= MAX_UNSIGNED_BYTE_VALUE / 2) // { // long originalComplementValue = (~(MAX_UNSIGNED_BYTE_VALUE - value)) + 1; // return (byte) originalComplementValue; // } else // { // return (byte) value; // } // } else // { // throw new IllegalArgumentException("Value out of range for a byte"); // } // } // // public static long byteToUlong(byte value) // { // if (value < 0) // { // long complement2Value = ~value + 1; // return MAX_UNSIGNED_BYTE_VALUE - complement2Value; // } else // { // return (long) value; // } // } // // public static int byteToUint(byte value) // { // if (value < 0) // { // int complement2Value = ~value + 1; // return MAX_UNSIGNED_BYTE_VALUE - complement2Value; // } else // { // return (int) value; // } // } // // public static long convertBytes2Long(byte... bytes) // { // long value = 0; // int length = bytes.length; // int firstIndex = 8 * (length - 1); // int n = 0; // for (byte b : bytes) // { // value += (byteToUlong(b) << (firstIndex - n)); // n += 8; // } // return value; // } // // public static byte[] convertULong2Bytes(long value) // { // byte[] byteValues = new byte[4]; // int signedValue = ulongToInt(value); // byteValues[0] = (byte) ((signedValue & 0xff000000) >> 24); // byteValues[1] = (byte) ((signedValue & 0x00ff0000) >> 16); // byteValues[2] = (byte) ((signedValue & 0x0000ff00) >> 8); // byteValues[3] = (byte) (signedValue & 0x000000ff); // return byteValues; // } // // }
import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.UnsignedUtil; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List;
package com.felhr.usbmassstorageforandroid.filesystems.fat32; /** * Created by Felipe Herranz(felhr85@gmail.com) on 16/7/15. */ public class LFNHandler { private LFNHandler() { } public static String parseLFNEntry(byte[] lfnData) { boolean endChar = false; List<Byte> unicodeList = new ArrayList<Byte>(); if((lfnData[1] != 0x00 || lfnData[2] != 0x00)) {
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/UnsignedUtil.java // public class UnsignedUtil { // private final static short MAX_UNSIGNED_BYTE_VALUE = 256; // private final static int MAX_UNSIGNED_SHORT_VALUE = 65536; // private final static long MAX_UNSIGNED_INT_VALUE = 4294967296L; // // private UnsignedUtil() { // // } // // public static short byteToUshort(byte value) // { // if (value < 0) // { // short complement2Value = (short) (~value + 1); // return (short) (MAX_UNSIGNED_BYTE_VALUE - complement2Value); // } else // { // return (short) value; // } // } // // public static byte ushortToByte(short value) // { // if (value <= MAX_UNSIGNED_SHORT_VALUE) // { // if (value >= MAX_UNSIGNED_BYTE_VALUE / 2) // { // return (byte) ((~(MAX_UNSIGNED_BYTE_VALUE - value)) + 1); // } else // { // return (byte) value; // } // } else // { // throw new IllegalArgumentException("Value out of range for a byte"); // } // } // // // public static int shortToUint(short value) // { // if (value < 0) // { // return MAX_UNSIGNED_SHORT_VALUE - (~value + 1); // } else // { // return value; // } // } // // // public static short uintToShort(int value) // { // if (value <= MAX_UNSIGNED_SHORT_VALUE) // { // if (value >= MAX_UNSIGNED_SHORT_VALUE / 2) // { // return (short) (~(MAX_UNSIGNED_SHORT_VALUE - value) + 1); // } else // { // return (short) value; // } // } else // { // throw new IllegalArgumentException("Value out of range for a short"); // } // } // // public static long intToUlong(int value) // { // if (value < 0) // { // long complement2Value = (~((long) value) + 1); // return MAX_UNSIGNED_INT_VALUE - complement2Value; // } else // { // return value; // } // } // // public static int ulongToInt(long value) // { // if (value <= MAX_UNSIGNED_INT_VALUE) // { // if (value >= MAX_UNSIGNED_INT_VALUE / 2) // { // return (int) (~(MAX_UNSIGNED_INT_VALUE - value) + 1); // } else // { // return (int) value; // } // } else // { // throw new IllegalArgumentException("Value out of range for a int"); // } // } // // public static byte ulongToByte(long value) throws IllegalArgumentException // { // if (value <= MAX_UNSIGNED_BYTE_VALUE) // { // if (value >= MAX_UNSIGNED_BYTE_VALUE / 2) // { // long originalComplementValue = (~(MAX_UNSIGNED_BYTE_VALUE - value)) + 1; // return (byte) originalComplementValue; // } else // { // return (byte) value; // } // } else // { // throw new IllegalArgumentException("Value out of range for a byte"); // } // } // // public static long byteToUlong(byte value) // { // if (value < 0) // { // long complement2Value = ~value + 1; // return MAX_UNSIGNED_BYTE_VALUE - complement2Value; // } else // { // return (long) value; // } // } // // public static int byteToUint(byte value) // { // if (value < 0) // { // int complement2Value = ~value + 1; // return MAX_UNSIGNED_BYTE_VALUE - complement2Value; // } else // { // return (int) value; // } // } // // public static long convertBytes2Long(byte... bytes) // { // long value = 0; // int length = bytes.length; // int firstIndex = 8 * (length - 1); // int n = 0; // for (byte b : bytes) // { // value += (byteToUlong(b) << (firstIndex - n)); // n += 8; // } // return value; // } // // public static byte[] convertULong2Bytes(long value) // { // byte[] byteValues = new byte[4]; // int signedValue = ulongToInt(value); // byteValues[0] = (byte) ((signedValue & 0xff000000) >> 24); // byteValues[1] = (byte) ((signedValue & 0x00ff0000) >> 16); // byteValues[2] = (byte) ((signedValue & 0x0000ff00) >> 8); // byteValues[3] = (byte) (signedValue & 0x000000ff); // return byteValues; // } // // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/filesystems/fat32/LFNHandler.java import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.UnsignedUtil; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; package com.felhr.usbmassstorageforandroid.filesystems.fat32; /** * Created by Felipe Herranz(felhr85@gmail.com) on 16/7/15. */ public class LFNHandler { private LFNHandler() { } public static String parseLFNEntry(byte[] lfnData) { boolean endChar = false; List<Byte> unicodeList = new ArrayList<Byte>(); if((lfnData[1] != 0x00 || lfnData[2] != 0x00)) {
int codePoint = (UnsignedUtil.byteToUint(lfnData[2]) << 8) + UnsignedUtil.byteToUint(lfnData[1]);
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIPreventAllowRemoval.java
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // }
import java.nio.ByteBuffer; import commandwrappers.CommandBlockWrapper;
firstByte &= ~(1 << 6); firstByte |= (1 << 5); break; case 6: firstByte |= (1 << 7); firstByte |= (1 << 6); firstByte &= ~(1 << 5); break; case 7: firstByte |= (1 << 7); firstByte |= (1 << 6); firstByte |= (1 << 5); break; } buffer.put(firstByte); buffer.put((byte) 0x00); buffer.put((byte) 0x00); byte fourthByte = 0x00; if(prevent) fourthByte |= 1; buffer.put(fourthByte); buffer.put(control); return buffer.array(); } @Override
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIPreventAllowRemoval.java import java.nio.ByteBuffer; import commandwrappers.CommandBlockWrapper; firstByte &= ~(1 << 6); firstByte |= (1 << 5); break; case 6: firstByte |= (1 << 7); firstByte |= (1 << 6); firstByte &= ~(1 << 5); break; case 7: firstByte |= (1 << 7); firstByte |= (1 << 6); firstByte |= (1 << 5); break; } buffer.put(firstByte); buffer.put((byte) 0x00); buffer.put((byte) 0x00); byte fourthByte = 0x00; if(prevent) fourthByte |= 1; buffer.put(fourthByte); buffer.put(control); return buffer.array(); } @Override
public CommandBlockWrapper getCbw()
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSITestUnitReady.java
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // }
import java.nio.ByteBuffer; import commandwrappers.CommandBlockWrapper;
package com.felhr.usbmassstorageforandroid.scsi; /** * Created by Felipe Herranz(felhr85@gmail.com) on 16/12/14. */ public class SCSITestUnitReady extends SCSICommand { public byte TESTUNIT_OPERATION_CODE = 0x00; private static final int TESTUNIT_COMMAND_LENGTH = 6; public byte control; public SCSITestUnitReady() { this.dataTransportPhase = false; this.direction = 0; this.control = 0x00; } @Override public byte[] getSCSICommandBuffer() { ByteBuffer buffer = ByteBuffer.allocate(6); buffer.put(TESTUNIT_OPERATION_CODE); buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put(control); return buffer.array(); } @Override
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSITestUnitReady.java import java.nio.ByteBuffer; import commandwrappers.CommandBlockWrapper; package com.felhr.usbmassstorageforandroid.scsi; /** * Created by Felipe Herranz(felhr85@gmail.com) on 16/12/14. */ public class SCSITestUnitReady extends SCSICommand { public byte TESTUNIT_OPERATION_CODE = 0x00; private static final int TESTUNIT_COMMAND_LENGTH = 6; public byte control; public SCSITestUnitReady() { this.dataTransportPhase = false; this.direction = 0; this.control = 0x00; } @Override public byte[] getSCSICommandBuffer() { ByteBuffer buffer = ByteBuffer.allocate(6); buffer.put(TESTUNIT_OPERATION_CODE); buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put(control); return buffer.array(); } @Override
public CommandBlockWrapper getCbw()
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/commandwrappers/CommandBlockWrapper.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/EndianessUtil.java // public class EndianessUtil // { // private EndianessUtil() // { // // } // // public static int swapEndianess(int i) // { // return((i&0xff)<<24)+((i&0xff00)<<8)+((i&0xff0000)>>8)+((i>>24)&0xff); // } // }
import com.felhr.usbmassstorageforandroid.utilities.EndianessUtil; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.Random;
byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) { this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; this.dCBWTag = generateTag(); this.dCBWDataLength = dCBWDataLength; this.bmCBWFlags = bmCBWFlags; this.bCBWLUN = bCBWLUN; this.bCBWCBLength = bCBWCBLength; } public void setCommandBlock(byte[] commandBlock) { this.commandBlock = commandBlock; } public int getdCBWDataLength() { return dCBWDataLength; } public int generateTag() { Random random = new Random(); return random.nextInt(); } @Override public byte[] getCWBuffer() { ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE);
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/EndianessUtil.java // public class EndianessUtil // { // private EndianessUtil() // { // // } // // public static int swapEndianess(int i) // { // return((i&0xff)<<24)+((i&0xff00)<<8)+((i&0xff0000)>>8)+((i>>24)&0xff); // } // } // Path: src/main/java/commandwrappers/CommandBlockWrapper.java import com.felhr.usbmassstorageforandroid.utilities.EndianessUtil; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.Random; byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) { this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; this.dCBWTag = generateTag(); this.dCBWDataLength = dCBWDataLength; this.bmCBWFlags = bmCBWFlags; this.bCBWLUN = bCBWLUN; this.bCBWCBLength = bCBWCBLength; } public void setCommandBlock(byte[] commandBlock) { this.commandBlock = commandBlock; } public int getdCBWDataLength() { return dCBWDataLength; } public int generateTag() { Random random = new Random(); return random.nextInt(); } @Override public byte[] getCWBuffer() { ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE);
buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature));
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIRead10Response.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // }
import android.os.Bundle; import com.felhr.usbmassstorageforandroid.utilities.HexUtil;
package com.felhr.usbmassstorageforandroid.scsi; /** * Created by Felipe Herranz(felhr85@gmail.com) on 16/12/14. */ public class SCSIRead10Response extends SCSIResponse { private byte[] readBuffer; private int pointer; private SCSIRead10Response(int lengthResponse) { this.readBuffer = new byte[lengthResponse]; this.pointer = 0; } public static SCSIRead10Response getResponse(byte[] data, int lengthResponse) { SCSIRead10Response response = new SCSIRead10Response(lengthResponse); response.addToBuffer(data); return response; } @Override public Bundle getReadableResponse() { Bundle bundle = new Bundle();
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIRead10Response.java import android.os.Bundle; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; package com.felhr.usbmassstorageforandroid.scsi; /** * Created by Felipe Herranz(felhr85@gmail.com) on 16/12/14. */ public class SCSIRead10Response extends SCSIResponse { private byte[] readBuffer; private int pointer; private SCSIRead10Response(int lengthResponse) { this.readBuffer = new byte[lengthResponse]; this.pointer = 0; } public static SCSIRead10Response getResponse(byte[] data, int lengthResponse) { SCSIRead10Response response = new SCSIRead10Response(lengthResponse); response.addToBuffer(data); return response; } @Override public Bundle getReadableResponse() { Bundle bundle = new Bundle();
bundle.putString("readBuffer", HexUtil.hexToString(readBuffer));
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIRequestSenseResponse.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // }
import android.os.Bundle; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.util.Arrays;
package com.felhr.usbmassstorageforandroid.scsi; /** * Created by Felipe Herranz(felhr85@gmail.com) on 15/12/14. */ public class SCSIRequestSenseResponse extends SCSIResponse { private boolean valid; private int responseCode; private boolean fileMark; private boolean eom; private boolean ili; private int senseKey; private int information; private int additionalSenseLength; private int commandSpecificInformation; private int additionalSenseCode; private int additionalSenseCodeCodeQualifier; private int fieldReplaceableUnitCode; private boolean sksv; private int senseKeySpecific; private byte[] additionalSenseBytes; private SCSIRequestSenseResponse() { } public static SCSIRequestSenseResponse getResponse(byte[] data) {
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIRequestSenseResponse.java import android.os.Bundle; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.util.Arrays; package com.felhr.usbmassstorageforandroid.scsi; /** * Created by Felipe Herranz(felhr85@gmail.com) on 15/12/14. */ public class SCSIRequestSenseResponse extends SCSIResponse { private boolean valid; private int responseCode; private boolean fileMark; private boolean eom; private boolean ili; private int senseKey; private int information; private int additionalSenseLength; private int commandSpecificInformation; private int additionalSenseCode; private int additionalSenseCodeCodeQualifier; private int fieldReplaceableUnitCode; private boolean sksv; private int senseKeySpecific; private byte[] additionalSenseBytes; private SCSIRequestSenseResponse() { } public static SCSIRequestSenseResponse getResponse(byte[] data) {
Log.i("Buffer state", "Data to host: " + HexUtil.hexToString(data));
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIReadCapacity10.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // }
import commandwrappers.CommandBlockWrapper; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.nio.ByteBuffer;
private boolean pmi; private byte control; public SCSIReadCapacity10(int logicalBlockAddress, boolean pmi) { this.dataTransportPhase = true; this.direction = 1; this.logicalBlockAddress = logicalBlockAddress; this.pmi = pmi; this.control = 0x00; } @Override public byte[] getSCSICommandBuffer() { ByteBuffer buffer = ByteBuffer.allocate(10); buffer.put(READCAPACITY10_OPERATION_CODE); buffer.put((byte) 0x00); buffer.putInt(logicalBlockAddress); buffer.put((byte) 0x00); buffer.put((byte) 0x00); byte pmiByte = 0x00; if(pmi) pmiByte |= 1; buffer.put(pmiByte); buffer.put(control); return buffer.array(); } @Override
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIReadCapacity10.java import commandwrappers.CommandBlockWrapper; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.nio.ByteBuffer; private boolean pmi; private byte control; public SCSIReadCapacity10(int logicalBlockAddress, boolean pmi) { this.dataTransportPhase = true; this.direction = 1; this.logicalBlockAddress = logicalBlockAddress; this.pmi = pmi; this.control = 0x00; } @Override public byte[] getSCSICommandBuffer() { ByteBuffer buffer = ByteBuffer.allocate(10); buffer.put(READCAPACITY10_OPERATION_CODE); buffer.put((byte) 0x00); buffer.putInt(logicalBlockAddress); buffer.put((byte) 0x00); buffer.put((byte) 0x00); byte pmiByte = 0x00; if(pmi) pmiByte |= 1; buffer.put(pmiByte); buffer.put(control); return buffer.array(); } @Override
public CommandBlockWrapper getCbw()
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIReadCapacity10.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // }
import commandwrappers.CommandBlockWrapper; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.nio.ByteBuffer;
public SCSIReadCapacity10(int logicalBlockAddress, boolean pmi) { this.dataTransportPhase = true; this.direction = 1; this.logicalBlockAddress = logicalBlockAddress; this.pmi = pmi; this.control = 0x00; } @Override public byte[] getSCSICommandBuffer() { ByteBuffer buffer = ByteBuffer.allocate(10); buffer.put(READCAPACITY10_OPERATION_CODE); buffer.put((byte) 0x00); buffer.putInt(logicalBlockAddress); buffer.put((byte) 0x00); buffer.put((byte) 0x00); byte pmiByte = 0x00; if(pmi) pmiByte |= 1; buffer.put(pmiByte); buffer.put(control); return buffer.array(); } @Override public CommandBlockWrapper getCbw() { byte[] rawCommand = getCbwcb(getSCSICommandBuffer());
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIReadCapacity10.java import commandwrappers.CommandBlockWrapper; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.nio.ByteBuffer; public SCSIReadCapacity10(int logicalBlockAddress, boolean pmi) { this.dataTransportPhase = true; this.direction = 1; this.logicalBlockAddress = logicalBlockAddress; this.pmi = pmi; this.control = 0x00; } @Override public byte[] getSCSICommandBuffer() { ByteBuffer buffer = ByteBuffer.allocate(10); buffer.put(READCAPACITY10_OPERATION_CODE); buffer.put((byte) 0x00); buffer.putInt(logicalBlockAddress); buffer.put((byte) 0x00); buffer.put((byte) 0x00); byte pmiByte = 0x00; if(pmi) pmiByte |= 1; buffer.put(pmiByte); buffer.put(control); return buffer.array(); } @Override public CommandBlockWrapper getCbw() { byte[] rawCommand = getCbwcb(getSCSICommandBuffer());
Log.i("Buffer state", "SCSI: " + HexUtil.hexToString(rawCommand));
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSICommand.java
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // }
import java.util.Arrays; import commandwrappers.CommandBlockWrapper;
package com.felhr.usbmassstorageforandroid.scsi; /** * Created by Felipe Herranz(felhr85@gmail.com) on 12/12/14. */ public abstract class SCSICommand { protected byte[] dataBuffer; protected boolean dataTransportPhase; protected int direction; // 0:NONE 1:IN(to host) 2:OUT(from host) public SCSICommand() { } /* Serialize a SCSI command object into a stream of bytes */ public abstract byte[] getSCSICommandBuffer(); /* Get a Command Block wrapper from a SCSI command */
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSICommand.java import java.util.Arrays; import commandwrappers.CommandBlockWrapper; package com.felhr.usbmassstorageforandroid.scsi; /** * Created by Felipe Herranz(felhr85@gmail.com) on 12/12/14. */ public abstract class SCSICommand { protected byte[] dataBuffer; protected boolean dataTransportPhase; protected int direction; // 0:NONE 1:IN(to host) 2:OUT(from host) public SCSICommand() { } /* Serialize a SCSI command object into a stream of bytes */ public abstract byte[] getSCSICommandBuffer(); /* Get a Command Block wrapper from a SCSI command */
public abstract CommandBlockWrapper getCbw();
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIModeSelect10.java
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // }
import java.nio.ByteBuffer; import commandwrappers.CommandBlockWrapper;
this.dataTransportPhase = false; this.direction = 0; this.pageFormat = pageFormat; this.savePages = savePages; this.parameterListLength = parameterListLength; this.control = 0x00; } @Override public byte[] getSCSICommandBuffer() { ByteBuffer buffer = ByteBuffer.allocate(6); buffer.put(MODESELECT10_OPERATION_CODE); byte firstByte = 0x00; if(pageFormat) firstByte |= (1 << 4); if(savePages) firstByte |= 1; buffer.put(firstByte); buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put(convertToByte(parameterListLength, 2)); buffer.put(control); return buffer.array(); } @Override
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIModeSelect10.java import java.nio.ByteBuffer; import commandwrappers.CommandBlockWrapper; this.dataTransportPhase = false; this.direction = 0; this.pageFormat = pageFormat; this.savePages = savePages; this.parameterListLength = parameterListLength; this.control = 0x00; } @Override public byte[] getSCSICommandBuffer() { ByteBuffer buffer = ByteBuffer.allocate(6); buffer.put(MODESELECT10_OPERATION_CODE); byte firstByte = 0x00; if(pageFormat) firstByte |= (1 << 4); if(savePages) firstByte |= 1; buffer.put(firstByte); buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put(convertToByte(parameterListLength, 2)); buffer.put(control); return buffer.array(); } @Override
public CommandBlockWrapper getCbw()
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIReadCapacity10Response.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // }
import android.os.Bundle; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil;
package com.felhr.usbmassstorageforandroid.scsi; /** * Created by Felipe Herranz(felhr85@gmail.com) on 16/12/14. */ public class SCSIReadCapacity10Response extends SCSIResponse { private int returnedLogicalBlockAddress; private int blockLength; private SCSIReadCapacity10Response() { } public static SCSIReadCapacity10Response getResponse(byte[] data) {
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIReadCapacity10Response.java import android.os.Bundle; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; package com.felhr.usbmassstorageforandroid.scsi; /** * Created by Felipe Herranz(felhr85@gmail.com) on 16/12/14. */ public class SCSIReadCapacity10Response extends SCSIResponse { private int returnedLogicalBlockAddress; private int blockLength; private SCSIReadCapacity10Response() { } public static SCSIReadCapacity10Response getResponse(byte[] data) {
Log.i("Buffer state", "Data to host: " + HexUtil.hexToString(data));
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/bulkonly/BulkOnlyStatusInterface.java
// Path: src/main/java/commandwrappers/CommandStatusWrapper.java // public class CommandStatusWrapper extends CommandWrapper // { // private int dCSWSignature; // private int dCSWTag; // private int dCSWDataResidue; // private byte bCSWStatus; // // public CommandStatusWrapper(int dCSWSignature, int dCSWTag, int dCSWDataResidue, // byte bCSWStatus) // { // this.dCSWSignature = dCSWSignature; // this.dCSWTag = dCSWTag; // this.dCSWDataResidue = dCSWDataResidue; // this.bCSWStatus = bCSWStatus; // } // // public static CommandStatusWrapper getCWStatus(byte[] buffer) // { // int signature = convertToInt(Arrays.copyOfRange(buffer, 0, 4)); // int tag = convertToInt(Arrays.copyOfRange(buffer, 4, 8)); // int residue = convertToInt(Arrays.copyOfRange(buffer, 8, 12)); // byte status = buffer[12]; // return new CommandStatusWrapper(signature, tag, residue, status); // } // // private static int convertToInt(byte[] buffer) // { // int result; // result = buffer[0] & 0xff; // result = result + ((buffer[1] & 0xff) << 8); // result = result + ((buffer[2] & 0xff) << 16); // return result + ((buffer[3] & 0xff) << 24); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBS_SIZE); // buffer.putInt(dCSWSignature); // buffer.putInt(dCSWTag); // buffer.putInt(dCSWDataResidue); // buffer.put(bCSWStatus); // return buffer.array(); // } // // public int getdCSWSignature() // { // return dCSWSignature; // } // // public void setdCSWSignature(int dCSWSignature) // { // this.dCSWSignature = dCSWSignature; // } // // public int getdCSWTag() // { // return dCSWTag; // } // // public void setdCSWTag(int dCSWTag) // { // this.dCSWTag = dCSWTag; // } // // public int getdCSWDataResidue() // { // return dCSWDataResidue; // } // // public void setdCSWDataResidue(int dCSWDataResidue) // { // this.dCSWDataResidue = dCSWDataResidue; // } // // public byte getbCSWStatus() // { // return bCSWStatus; // } // // public void setbCSWStatus(byte bCSWStatus) // { // this.bCSWStatus = bCSWStatus; // } // }
import commandwrappers.CommandStatusWrapper;
package com.felhr.usbmassstorageforandroid.bulkonly; /** * Created by Felipe Herranz(felhr85@gmail.com) on 11/12/14. */ public interface BulkOnlyStatusInterface { public void onOperationStarted(boolean status);
// Path: src/main/java/commandwrappers/CommandStatusWrapper.java // public class CommandStatusWrapper extends CommandWrapper // { // private int dCSWSignature; // private int dCSWTag; // private int dCSWDataResidue; // private byte bCSWStatus; // // public CommandStatusWrapper(int dCSWSignature, int dCSWTag, int dCSWDataResidue, // byte bCSWStatus) // { // this.dCSWSignature = dCSWSignature; // this.dCSWTag = dCSWTag; // this.dCSWDataResidue = dCSWDataResidue; // this.bCSWStatus = bCSWStatus; // } // // public static CommandStatusWrapper getCWStatus(byte[] buffer) // { // int signature = convertToInt(Arrays.copyOfRange(buffer, 0, 4)); // int tag = convertToInt(Arrays.copyOfRange(buffer, 4, 8)); // int residue = convertToInt(Arrays.copyOfRange(buffer, 8, 12)); // byte status = buffer[12]; // return new CommandStatusWrapper(signature, tag, residue, status); // } // // private static int convertToInt(byte[] buffer) // { // int result; // result = buffer[0] & 0xff; // result = result + ((buffer[1] & 0xff) << 8); // result = result + ((buffer[2] & 0xff) << 16); // return result + ((buffer[3] & 0xff) << 24); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBS_SIZE); // buffer.putInt(dCSWSignature); // buffer.putInt(dCSWTag); // buffer.putInt(dCSWDataResidue); // buffer.put(bCSWStatus); // return buffer.array(); // } // // public int getdCSWSignature() // { // return dCSWSignature; // } // // public void setdCSWSignature(int dCSWSignature) // { // this.dCSWSignature = dCSWSignature; // } // // public int getdCSWTag() // { // return dCSWTag; // } // // public void setdCSWTag(int dCSWTag) // { // this.dCSWTag = dCSWTag; // } // // public int getdCSWDataResidue() // { // return dCSWDataResidue; // } // // public void setdCSWDataResidue(int dCSWDataResidue) // { // this.dCSWDataResidue = dCSWDataResidue; // } // // public byte getbCSWStatus() // { // return bCSWStatus; // } // // public void setbCSWStatus(byte bCSWStatus) // { // this.bCSWStatus = bCSWStatus; // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/bulkonly/BulkOnlyStatusInterface.java import commandwrappers.CommandStatusWrapper; package com.felhr.usbmassstorageforandroid.bulkonly; /** * Created by Felipe Herranz(felhr85@gmail.com) on 11/12/14. */ public interface BulkOnlyStatusInterface { public void onOperationStarted(boolean status);
public void onOperationCompleted(CommandStatusWrapper csw);
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIWrite10.java
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // }
import java.nio.ByteBuffer; import commandwrappers.CommandBlockWrapper;
break; case 6: firstByte |= (1 << 7); firstByte |= (1 << 6); firstByte &= ~(1 << 5); break; case 7: firstByte |= (1 << 7); firstByte |= (1 << 6); firstByte |= (1 << 5); break; } if(dpo) firstByte |= (1 << 4); if(fua) firstByte |= (1 << 3); if(fuaNv) firstByte |= (1 << 1); buffer.put(firstByte); buffer.putInt(logicalBlockAddress); buffer.put(convertToByte(groupNumber, 1)); buffer.put(convertToByte(transferLength, 2)); buffer.put(control); return buffer.array(); } @Override
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIWrite10.java import java.nio.ByteBuffer; import commandwrappers.CommandBlockWrapper; break; case 6: firstByte |= (1 << 7); firstByte |= (1 << 6); firstByte &= ~(1 << 5); break; case 7: firstByte |= (1 << 7); firstByte |= (1 << 6); firstByte |= (1 << 5); break; } if(dpo) firstByte |= (1 << 4); if(fua) firstByte |= (1 << 3); if(fuaNv) firstByte |= (1 << 1); buffer.put(firstByte); buffer.putInt(logicalBlockAddress); buffer.put(convertToByte(groupNumber, 1)); buffer.put(convertToByte(transferLength, 2)); buffer.put(control); return buffer.array(); } @Override
public CommandBlockWrapper getCbw()
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIFormatUnit.java
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // }
import java.nio.ByteBuffer; import commandwrappers.CommandBlockWrapper;
case 4: firstByte |= (1 << 2); firstByte &= ~(1 << 1); firstByte &= ~(1); break; case 5: firstByte |= (1 << 2); firstByte &= ~(1 << 1); firstByte |= 1; break; case 6: firstByte |= (1 << 2); firstByte |= (1 << 1); firstByte &= ~(1); break; case 7: firstByte |= (1 << 2); firstByte |= (1 << 1); firstByte |= 1; break; } buffer.put(firstByte); buffer.put(vendorSpecific); buffer.put((byte) 0x00); buffer.put(control); return buffer.array(); } @Override
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIFormatUnit.java import java.nio.ByteBuffer; import commandwrappers.CommandBlockWrapper; case 4: firstByte |= (1 << 2); firstByte &= ~(1 << 1); firstByte &= ~(1); break; case 5: firstByte |= (1 << 2); firstByte &= ~(1 << 1); firstByte |= 1; break; case 6: firstByte |= (1 << 2); firstByte |= (1 << 1); firstByte &= ~(1); break; case 7: firstByte |= (1 << 2); firstByte |= (1 << 1); firstByte |= 1; break; } buffer.put(firstByte); buffer.put(vendorSpecific); buffer.put((byte) 0x00); buffer.put(control); return buffer.array(); } @Override
public CommandBlockWrapper getCbw()
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIModeSense10Response.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // }
import android.os.Bundle; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil;
package com.felhr.usbmassstorageforandroid.scsi; /** * Created by Felipe Herranz(felhr85@gmail.com) on 22/12/14. */ public class SCSIModeSense10Response extends SCSIResponse { private int modeDataLength; private int mediumType; private int deviceSpecificParameter; private boolean longLba; private int blockDescriptorLength; private SCSIModeSense10Response() { } public static SCSIModeSense10Response getResponse(byte[] data) {
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIModeSense10Response.java import android.os.Bundle; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; package com.felhr.usbmassstorageforandroid.scsi; /** * Created by Felipe Herranz(felhr85@gmail.com) on 22/12/14. */ public class SCSIModeSense10Response extends SCSIResponse { private int modeDataLength; private int mediumType; private int deviceSpecificParameter; private boolean longLba; private int blockDescriptorLength; private SCSIModeSense10Response() { } public static SCSIModeSense10Response getResponse(byte[] data) {
Log.i("Buffer state", "Data to host: " + HexUtil.hexToString(data));
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIInquiry.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // }
import commandwrappers.CommandBlockWrapper; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.nio.ByteBuffer;
private byte control; public SCSIInquiry(boolean evpd, int pageCode, int allocationLength) { this.dataTransportPhase = true; this.direction = 1; this.operationCode = INQUIRY_OPERATION_CODE; this.evpd = evpd; this.pageCode = pageCode; this.allocationLength = allocationLength; this.control = 0x00; } @Override public byte[] getSCSICommandBuffer() { ByteBuffer buffer = ByteBuffer.allocate(6); buffer.put(operationCode); if(evpd) buffer.put((byte) 0x01); else buffer.put((byte) 0x00); buffer.put(convertToByte(pageCode, 1)); buffer.put(convertToByte(allocationLength, 2)); buffer.put(control); return buffer.array(); } @Override
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIInquiry.java import commandwrappers.CommandBlockWrapper; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.nio.ByteBuffer; private byte control; public SCSIInquiry(boolean evpd, int pageCode, int allocationLength) { this.dataTransportPhase = true; this.direction = 1; this.operationCode = INQUIRY_OPERATION_CODE; this.evpd = evpd; this.pageCode = pageCode; this.allocationLength = allocationLength; this.control = 0x00; } @Override public byte[] getSCSICommandBuffer() { ByteBuffer buffer = ByteBuffer.allocate(6); buffer.put(operationCode); if(evpd) buffer.put((byte) 0x01); else buffer.put((byte) 0x00); buffer.put(convertToByte(pageCode, 1)); buffer.put(convertToByte(allocationLength, 2)); buffer.put(control); return buffer.array(); } @Override
public CommandBlockWrapper getCbw()
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIInquiry.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // }
import commandwrappers.CommandBlockWrapper; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.nio.ByteBuffer;
{ this.dataTransportPhase = true; this.direction = 1; this.operationCode = INQUIRY_OPERATION_CODE; this.evpd = evpd; this.pageCode = pageCode; this.allocationLength = allocationLength; this.control = 0x00; } @Override public byte[] getSCSICommandBuffer() { ByteBuffer buffer = ByteBuffer.allocate(6); buffer.put(operationCode); if(evpd) buffer.put((byte) 0x01); else buffer.put((byte) 0x00); buffer.put(convertToByte(pageCode, 1)); buffer.put(convertToByte(allocationLength, 2)); buffer.put(control); return buffer.array(); } @Override public CommandBlockWrapper getCbw() { byte[] rawCommand = getCbwcb(getSCSICommandBuffer()); // getCbwcb forces this command to be a 16 byte length array Log.i("Buffer state", "SCSI Length: " + String.valueOf(rawCommand.length));
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIInquiry.java import commandwrappers.CommandBlockWrapper; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.nio.ByteBuffer; { this.dataTransportPhase = true; this.direction = 1; this.operationCode = INQUIRY_OPERATION_CODE; this.evpd = evpd; this.pageCode = pageCode; this.allocationLength = allocationLength; this.control = 0x00; } @Override public byte[] getSCSICommandBuffer() { ByteBuffer buffer = ByteBuffer.allocate(6); buffer.put(operationCode); if(evpd) buffer.put((byte) 0x01); else buffer.put((byte) 0x00); buffer.put(convertToByte(pageCode, 1)); buffer.put(convertToByte(allocationLength, 2)); buffer.put(control); return buffer.array(); } @Override public CommandBlockWrapper getCbw() { byte[] rawCommand = getCbwcb(getSCSICommandBuffer()); // getCbwcb forces this command to be a 16 byte length array Log.i("Buffer state", "SCSI Length: " + String.valueOf(rawCommand.length));
Log.i("Buffer state", "SCSI: " + HexUtil.hexToString(rawCommand));
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIRequestSense.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // }
import commandwrappers.CommandBlockWrapper; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.nio.ByteBuffer;
private int allocationLength; private byte control; public SCSIRequestSense(boolean desc, int allocationLength) { this.dataTransportPhase = true; this.direction = 1; this.operationCode = REQUESTSENSE_OPERATION_CODE; this.desc = desc; this.allocationLength = allocationLength; this.control = 0x00; } @Override public byte[] getSCSICommandBuffer() { ByteBuffer buffer = ByteBuffer.allocate(6); buffer.put(operationCode); if(desc) buffer.put((byte) 0x01); else buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put(convertToByte(allocationLength, 1)); buffer.put(control); return buffer.array(); } @Override
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIRequestSense.java import commandwrappers.CommandBlockWrapper; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.nio.ByteBuffer; private int allocationLength; private byte control; public SCSIRequestSense(boolean desc, int allocationLength) { this.dataTransportPhase = true; this.direction = 1; this.operationCode = REQUESTSENSE_OPERATION_CODE; this.desc = desc; this.allocationLength = allocationLength; this.control = 0x00; } @Override public byte[] getSCSICommandBuffer() { ByteBuffer buffer = ByteBuffer.allocate(6); buffer.put(operationCode); if(desc) buffer.put((byte) 0x01); else buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put(convertToByte(allocationLength, 1)); buffer.put(control); return buffer.array(); } @Override
public CommandBlockWrapper getCbw()
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIRequestSense.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // }
import commandwrappers.CommandBlockWrapper; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.nio.ByteBuffer;
public SCSIRequestSense(boolean desc, int allocationLength) { this.dataTransportPhase = true; this.direction = 1; this.operationCode = REQUESTSENSE_OPERATION_CODE; this.desc = desc; this.allocationLength = allocationLength; this.control = 0x00; } @Override public byte[] getSCSICommandBuffer() { ByteBuffer buffer = ByteBuffer.allocate(6); buffer.put(operationCode); if(desc) buffer.put((byte) 0x01); else buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put(convertToByte(allocationLength, 1)); buffer.put(control); return buffer.array(); } @Override public CommandBlockWrapper getCbw() { byte[] rawCommand = getCbwcb(getSCSICommandBuffer());
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIRequestSense.java import commandwrappers.CommandBlockWrapper; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.nio.ByteBuffer; public SCSIRequestSense(boolean desc, int allocationLength) { this.dataTransportPhase = true; this.direction = 1; this.operationCode = REQUESTSENSE_OPERATION_CODE; this.desc = desc; this.allocationLength = allocationLength; this.control = 0x00; } @Override public byte[] getSCSICommandBuffer() { ByteBuffer buffer = ByteBuffer.allocate(6); buffer.put(operationCode); if(desc) buffer.put((byte) 0x01); else buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put(convertToByte(allocationLength, 1)); buffer.put(control); return buffer.array(); } @Override public CommandBlockWrapper getCbw() { byte[] rawCommand = getCbwcb(getSCSICommandBuffer());
Log.i("Buffer state", "SCSI: " + HexUtil.hexToString(rawCommand));
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/filesystems/fat32/FileEntry.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/UnsignedUtil.java // public class UnsignedUtil { // private final static short MAX_UNSIGNED_BYTE_VALUE = 256; // private final static int MAX_UNSIGNED_SHORT_VALUE = 65536; // private final static long MAX_UNSIGNED_INT_VALUE = 4294967296L; // // private UnsignedUtil() { // // } // // public static short byteToUshort(byte value) // { // if (value < 0) // { // short complement2Value = (short) (~value + 1); // return (short) (MAX_UNSIGNED_BYTE_VALUE - complement2Value); // } else // { // return (short) value; // } // } // // public static byte ushortToByte(short value) // { // if (value <= MAX_UNSIGNED_SHORT_VALUE) // { // if (value >= MAX_UNSIGNED_BYTE_VALUE / 2) // { // return (byte) ((~(MAX_UNSIGNED_BYTE_VALUE - value)) + 1); // } else // { // return (byte) value; // } // } else // { // throw new IllegalArgumentException("Value out of range for a byte"); // } // } // // // public static int shortToUint(short value) // { // if (value < 0) // { // return MAX_UNSIGNED_SHORT_VALUE - (~value + 1); // } else // { // return value; // } // } // // // public static short uintToShort(int value) // { // if (value <= MAX_UNSIGNED_SHORT_VALUE) // { // if (value >= MAX_UNSIGNED_SHORT_VALUE / 2) // { // return (short) (~(MAX_UNSIGNED_SHORT_VALUE - value) + 1); // } else // { // return (short) value; // } // } else // { // throw new IllegalArgumentException("Value out of range for a short"); // } // } // // public static long intToUlong(int value) // { // if (value < 0) // { // long complement2Value = (~((long) value) + 1); // return MAX_UNSIGNED_INT_VALUE - complement2Value; // } else // { // return value; // } // } // // public static int ulongToInt(long value) // { // if (value <= MAX_UNSIGNED_INT_VALUE) // { // if (value >= MAX_UNSIGNED_INT_VALUE / 2) // { // return (int) (~(MAX_UNSIGNED_INT_VALUE - value) + 1); // } else // { // return (int) value; // } // } else // { // throw new IllegalArgumentException("Value out of range for a int"); // } // } // // public static byte ulongToByte(long value) throws IllegalArgumentException // { // if (value <= MAX_UNSIGNED_BYTE_VALUE) // { // if (value >= MAX_UNSIGNED_BYTE_VALUE / 2) // { // long originalComplementValue = (~(MAX_UNSIGNED_BYTE_VALUE - value)) + 1; // return (byte) originalComplementValue; // } else // { // return (byte) value; // } // } else // { // throw new IllegalArgumentException("Value out of range for a byte"); // } // } // // public static long byteToUlong(byte value) // { // if (value < 0) // { // long complement2Value = ~value + 1; // return MAX_UNSIGNED_BYTE_VALUE - complement2Value; // } else // { // return (long) value; // } // } // // public static int byteToUint(byte value) // { // if (value < 0) // { // int complement2Value = ~value + 1; // return MAX_UNSIGNED_BYTE_VALUE - complement2Value; // } else // { // return (int) value; // } // } // // public static long convertBytes2Long(byte... bytes) // { // long value = 0; // int length = bytes.length; // int firstIndex = 8 * (length - 1); // int n = 0; // for (byte b : bytes) // { // value += (byteToUlong(b) << (firstIndex - n)); // n += 8; // } // return value; // } // // public static byte[] convertULong2Bytes(long value) // { // byte[] byteValues = new byte[4]; // int signedValue = ulongToInt(value); // byteValues[0] = (byte) ((signedValue & 0xff000000) >> 24); // byteValues[1] = (byte) ((signedValue & 0x00ff0000) >> 16); // byteValues[2] = (byte) ((signedValue & 0x0000ff00) >> 8); // byteValues[3] = (byte) (signedValue & 0x000000ff); // return byteValues; // } // // }
import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.UnsignedUtil; import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.List; import java.util.TimeZone;
{ entry.shortName = new String(buffer, 0, length); }else { entry.shortName = new String(buffer); } Arrays.fill(buffer, (byte) 0x20); System.arraycopy(data, 8, buffer, 0, 3); length = findNullChar(buffer, 3); if(length > -1) { if(length == 0) entry.fileExtension = ""; else entry.fileExtension = new String(buffer, 0, length); }else // No null char { entry.fileExtension = new String(Arrays.copyOf(buffer, 3)); } //entry.fileExtension = new String(Arrays.copyOf(buffer, 3)); System.arraycopy(data, 11, buffer, 0, 1); entry.attr = new Attributes(buffer[0]); System.arraycopy(data, 13, buffer, 0, 1); entry.fileCreationTime = buffer[0]; System.arraycopy(data, 14, buffer, 0, 2);
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/UnsignedUtil.java // public class UnsignedUtil { // private final static short MAX_UNSIGNED_BYTE_VALUE = 256; // private final static int MAX_UNSIGNED_SHORT_VALUE = 65536; // private final static long MAX_UNSIGNED_INT_VALUE = 4294967296L; // // private UnsignedUtil() { // // } // // public static short byteToUshort(byte value) // { // if (value < 0) // { // short complement2Value = (short) (~value + 1); // return (short) (MAX_UNSIGNED_BYTE_VALUE - complement2Value); // } else // { // return (short) value; // } // } // // public static byte ushortToByte(short value) // { // if (value <= MAX_UNSIGNED_SHORT_VALUE) // { // if (value >= MAX_UNSIGNED_BYTE_VALUE / 2) // { // return (byte) ((~(MAX_UNSIGNED_BYTE_VALUE - value)) + 1); // } else // { // return (byte) value; // } // } else // { // throw new IllegalArgumentException("Value out of range for a byte"); // } // } // // // public static int shortToUint(short value) // { // if (value < 0) // { // return MAX_UNSIGNED_SHORT_VALUE - (~value + 1); // } else // { // return value; // } // } // // // public static short uintToShort(int value) // { // if (value <= MAX_UNSIGNED_SHORT_VALUE) // { // if (value >= MAX_UNSIGNED_SHORT_VALUE / 2) // { // return (short) (~(MAX_UNSIGNED_SHORT_VALUE - value) + 1); // } else // { // return (short) value; // } // } else // { // throw new IllegalArgumentException("Value out of range for a short"); // } // } // // public static long intToUlong(int value) // { // if (value < 0) // { // long complement2Value = (~((long) value) + 1); // return MAX_UNSIGNED_INT_VALUE - complement2Value; // } else // { // return value; // } // } // // public static int ulongToInt(long value) // { // if (value <= MAX_UNSIGNED_INT_VALUE) // { // if (value >= MAX_UNSIGNED_INT_VALUE / 2) // { // return (int) (~(MAX_UNSIGNED_INT_VALUE - value) + 1); // } else // { // return (int) value; // } // } else // { // throw new IllegalArgumentException("Value out of range for a int"); // } // } // // public static byte ulongToByte(long value) throws IllegalArgumentException // { // if (value <= MAX_UNSIGNED_BYTE_VALUE) // { // if (value >= MAX_UNSIGNED_BYTE_VALUE / 2) // { // long originalComplementValue = (~(MAX_UNSIGNED_BYTE_VALUE - value)) + 1; // return (byte) originalComplementValue; // } else // { // return (byte) value; // } // } else // { // throw new IllegalArgumentException("Value out of range for a byte"); // } // } // // public static long byteToUlong(byte value) // { // if (value < 0) // { // long complement2Value = ~value + 1; // return MAX_UNSIGNED_BYTE_VALUE - complement2Value; // } else // { // return (long) value; // } // } // // public static int byteToUint(byte value) // { // if (value < 0) // { // int complement2Value = ~value + 1; // return MAX_UNSIGNED_BYTE_VALUE - complement2Value; // } else // { // return (int) value; // } // } // // public static long convertBytes2Long(byte... bytes) // { // long value = 0; // int length = bytes.length; // int firstIndex = 8 * (length - 1); // int n = 0; // for (byte b : bytes) // { // value += (byteToUlong(b) << (firstIndex - n)); // n += 8; // } // return value; // } // // public static byte[] convertULong2Bytes(long value) // { // byte[] byteValues = new byte[4]; // int signedValue = ulongToInt(value); // byteValues[0] = (byte) ((signedValue & 0xff000000) >> 24); // byteValues[1] = (byte) ((signedValue & 0x00ff0000) >> 16); // byteValues[2] = (byte) ((signedValue & 0x0000ff00) >> 8); // byteValues[3] = (byte) (signedValue & 0x000000ff); // return byteValues; // } // // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/filesystems/fat32/FileEntry.java import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.UnsignedUtil; import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.List; import java.util.TimeZone; { entry.shortName = new String(buffer, 0, length); }else { entry.shortName = new String(buffer); } Arrays.fill(buffer, (byte) 0x20); System.arraycopy(data, 8, buffer, 0, 3); length = findNullChar(buffer, 3); if(length > -1) { if(length == 0) entry.fileExtension = ""; else entry.fileExtension = new String(buffer, 0, length); }else // No null char { entry.fileExtension = new String(Arrays.copyOf(buffer, 3)); } //entry.fileExtension = new String(Arrays.copyOf(buffer, 3)); System.arraycopy(data, 11, buffer, 0, 1); entry.attr = new Attributes(buffer[0]); System.arraycopy(data, 13, buffer, 0, 1); entry.fileCreationTime = buffer[0]; System.arraycopy(data, 14, buffer, 0, 2);
int value0 = UnsignedUtil.byteToUint(buffer[0]);
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIReportLuns.java
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // }
import java.nio.ByteBuffer; import commandwrappers.CommandBlockWrapper;
package com.felhr.usbmassstorageforandroid.scsi; /** * Created by Felipe Herranz(felhr85@gmail.com) on 23/12/14. */ public class SCSIReportLuns extends SCSICommand { public static final byte REPORTLUNS_OPERATION_CODE = (byte) 0xa0; private int selectReport; // 1 byte private int allocationLength; // 2 bytes private byte control; public SCSIReportLuns(int selectReport, int allocationLength) { this.dataTransportPhase = true; this.direction = 1; this.selectReport = selectReport; this.allocationLength = allocationLength; this.control = 0x00; } @Override public byte[] getSCSICommandBuffer() { ByteBuffer buffer = ByteBuffer.allocate(9); buffer.put(REPORTLUNS_OPERATION_CODE); buffer.put((byte) 0x00); buffer.put(convertToByte(selectReport, 1)); buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put(convertToByte(allocationLength, 2)); buffer.put((byte) 0x00); buffer.put(control); return buffer.array(); } @Override
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIReportLuns.java import java.nio.ByteBuffer; import commandwrappers.CommandBlockWrapper; package com.felhr.usbmassstorageforandroid.scsi; /** * Created by Felipe Herranz(felhr85@gmail.com) on 23/12/14. */ public class SCSIReportLuns extends SCSICommand { public static final byte REPORTLUNS_OPERATION_CODE = (byte) 0xa0; private int selectReport; // 1 byte private int allocationLength; // 2 bytes private byte control; public SCSIReportLuns(int selectReport, int allocationLength) { this.dataTransportPhase = true; this.direction = 1; this.selectReport = selectReport; this.allocationLength = allocationLength; this.control = 0x00; } @Override public byte[] getSCSICommandBuffer() { ByteBuffer buffer = ByteBuffer.allocate(9); buffer.put(REPORTLUNS_OPERATION_CODE); buffer.put((byte) 0x00); buffer.put(convertToByte(selectReport, 1)); buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put(convertToByte(allocationLength, 2)); buffer.put((byte) 0x00); buffer.put(control); return buffer.array(); } @Override
public CommandBlockWrapper getCbw()
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIModeSense10.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // }
import commandwrappers.CommandBlockWrapper; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.nio.ByteBuffer;
{ case 0: secondByte &= ~(1 << 7); secondByte &= ~(1 << 6); break; case 1: secondByte &= ~(1 << 7); secondByte |= (1 << 6); break; case 2: secondByte |= (1 << 7); secondByte &= ~(1 << 6); break; case 3: secondByte |= (1 << 7); secondByte |= (1 << 6); break; } buffer.put(secondByte); buffer.put(convertToByte(subPageCode, 1)); buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put(convertToByte(allocationLength, 2)); buffer.put(control); return buffer.array(); } @Override
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIModeSense10.java import commandwrappers.CommandBlockWrapper; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.nio.ByteBuffer; { case 0: secondByte &= ~(1 << 7); secondByte &= ~(1 << 6); break; case 1: secondByte &= ~(1 << 7); secondByte |= (1 << 6); break; case 2: secondByte |= (1 << 7); secondByte &= ~(1 << 6); break; case 3: secondByte |= (1 << 7); secondByte |= (1 << 6); break; } buffer.put(secondByte); buffer.put(convertToByte(subPageCode, 1)); buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put(convertToByte(allocationLength, 2)); buffer.put(control); return buffer.array(); } @Override
public CommandBlockWrapper getCbw()
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIModeSense10.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // }
import commandwrappers.CommandBlockWrapper; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.nio.ByteBuffer;
secondByte &= ~(1 << 6); break; case 1: secondByte &= ~(1 << 7); secondByte |= (1 << 6); break; case 2: secondByte |= (1 << 7); secondByte &= ~(1 << 6); break; case 3: secondByte |= (1 << 7); secondByte |= (1 << 6); break; } buffer.put(secondByte); buffer.put(convertToByte(subPageCode, 1)); buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put(convertToByte(allocationLength, 2)); buffer.put(control); return buffer.array(); } @Override public CommandBlockWrapper getCbw() { byte[] rawCommand = getCbwcb(getSCSICommandBuffer());
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // // Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIModeSense10.java import commandwrappers.CommandBlockWrapper; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.nio.ByteBuffer; secondByte &= ~(1 << 6); break; case 1: secondByte &= ~(1 << 7); secondByte |= (1 << 6); break; case 2: secondByte |= (1 << 7); secondByte &= ~(1 << 6); break; case 3: secondByte |= (1 << 7); secondByte |= (1 << 6); break; } buffer.put(secondByte); buffer.put(convertToByte(subPageCode, 1)); buffer.put((byte) 0x00); buffer.put((byte) 0x00); buffer.put(convertToByte(allocationLength, 2)); buffer.put(control); return buffer.array(); } @Override public CommandBlockWrapper getCbw() { byte[] rawCommand = getCbwcb(getSCSICommandBuffer());
Log.i("Buffer state", "SCSI: " + HexUtil.hexToString(rawCommand));
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIRead10.java
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // }
import java.nio.ByteBuffer; import commandwrappers.CommandBlockWrapper;
break; case 6: firstByte |= (1 << 7); firstByte |= (1 << 6); firstByte &= ~(1 << 5); break; case 7: firstByte |= (1 << 7); firstByte |= (1 << 6); firstByte |= (1 << 5); break; } if(dpo) firstByte |= (1 << 4); if(fua) firstByte |= (1 << 3); if(fuaNv) firstByte |= (1 << 1); buffer.put(firstByte); buffer.putInt(logicalBlockAddress); buffer.put(convertToByte(groupNumber, 1)); buffer.put(convertToByte(transferLength, 2)); buffer.put(control); return buffer.array(); } @Override
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIRead10.java import java.nio.ByteBuffer; import commandwrappers.CommandBlockWrapper; break; case 6: firstByte |= (1 << 7); firstByte |= (1 << 6); firstByte &= ~(1 << 5); break; case 7: firstByte |= (1 << 7); firstByte |= (1 << 6); firstByte |= (1 << 5); break; } if(dpo) firstByte |= (1 << 4); if(fua) firstByte |= (1 << 3); if(fuaNv) firstByte |= (1 << 1); buffer.put(firstByte); buffer.putInt(logicalBlockAddress); buffer.put(convertToByte(groupNumber, 1)); buffer.put(convertToByte(transferLength, 2)); buffer.put(control); return buffer.array(); } @Override
public CommandBlockWrapper getCbw()
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/bulkonly/BulkOnlyCommunicator.java
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // // Path: src/main/java/commandwrappers/CommandStatusWrapper.java // public class CommandStatusWrapper extends CommandWrapper // { // private int dCSWSignature; // private int dCSWTag; // private int dCSWDataResidue; // private byte bCSWStatus; // // public CommandStatusWrapper(int dCSWSignature, int dCSWTag, int dCSWDataResidue, // byte bCSWStatus) // { // this.dCSWSignature = dCSWSignature; // this.dCSWTag = dCSWTag; // this.dCSWDataResidue = dCSWDataResidue; // this.bCSWStatus = bCSWStatus; // } // // public static CommandStatusWrapper getCWStatus(byte[] buffer) // { // int signature = convertToInt(Arrays.copyOfRange(buffer, 0, 4)); // int tag = convertToInt(Arrays.copyOfRange(buffer, 4, 8)); // int residue = convertToInt(Arrays.copyOfRange(buffer, 8, 12)); // byte status = buffer[12]; // return new CommandStatusWrapper(signature, tag, residue, status); // } // // private static int convertToInt(byte[] buffer) // { // int result; // result = buffer[0] & 0xff; // result = result + ((buffer[1] & 0xff) << 8); // result = result + ((buffer[2] & 0xff) << 16); // return result + ((buffer[3] & 0xff) << 24); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBS_SIZE); // buffer.putInt(dCSWSignature); // buffer.putInt(dCSWTag); // buffer.putInt(dCSWDataResidue); // buffer.put(bCSWStatus); // return buffer.array(); // } // // public int getdCSWSignature() // { // return dCSWSignature; // } // // public void setdCSWSignature(int dCSWSignature) // { // this.dCSWSignature = dCSWSignature; // } // // public int getdCSWTag() // { // return dCSWTag; // } // // public void setdCSWTag(int dCSWTag) // { // this.dCSWTag = dCSWTag; // } // // public int getdCSWDataResidue() // { // return dCSWDataResidue; // } // // public void setdCSWDataResidue(int dCSWDataResidue) // { // this.dCSWDataResidue = dCSWDataResidue; // } // // public byte getbCSWStatus() // { // return bCSWStatus; // } // // public void setbCSWStatus(byte bCSWStatus) // { // this.bCSWStatus = bCSWStatus; // } // }
import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbDeviceConnection; import android.util.Log; import java.util.concurrent.atomic.AtomicBoolean; import commandwrappers.CommandBlockWrapper; import commandwrappers.CommandStatusWrapper;
package com.felhr.usbmassstorageforandroid.bulkonly; /** * Created by Felipe Herranz(felhr85@gmail.com) on 9/12/14. */ public class BulkOnlyCommunicator { private BulkOnlyStatusInterface statusCallback; private UsbFacade usbFacade; private AtomicBoolean flagDataIN; private AtomicBoolean flagDataOUT; public BulkOnlyCommunicator(UsbDevice mDevice, UsbDeviceConnection mConnection) { this.usbFacade = new UsbFacade(mDevice, mConnection); this.flagDataIN = new AtomicBoolean(false); this.flagDataOUT = new AtomicBoolean(false); } public boolean startBulkOnly(BulkOnlyStatusInterface statusCallback) { this.statusCallback = statusCallback; usbFacade.setCallback(mCallback); return usbFacade.openDevice(); }
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // // Path: src/main/java/commandwrappers/CommandStatusWrapper.java // public class CommandStatusWrapper extends CommandWrapper // { // private int dCSWSignature; // private int dCSWTag; // private int dCSWDataResidue; // private byte bCSWStatus; // // public CommandStatusWrapper(int dCSWSignature, int dCSWTag, int dCSWDataResidue, // byte bCSWStatus) // { // this.dCSWSignature = dCSWSignature; // this.dCSWTag = dCSWTag; // this.dCSWDataResidue = dCSWDataResidue; // this.bCSWStatus = bCSWStatus; // } // // public static CommandStatusWrapper getCWStatus(byte[] buffer) // { // int signature = convertToInt(Arrays.copyOfRange(buffer, 0, 4)); // int tag = convertToInt(Arrays.copyOfRange(buffer, 4, 8)); // int residue = convertToInt(Arrays.copyOfRange(buffer, 8, 12)); // byte status = buffer[12]; // return new CommandStatusWrapper(signature, tag, residue, status); // } // // private static int convertToInt(byte[] buffer) // { // int result; // result = buffer[0] & 0xff; // result = result + ((buffer[1] & 0xff) << 8); // result = result + ((buffer[2] & 0xff) << 16); // return result + ((buffer[3] & 0xff) << 24); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBS_SIZE); // buffer.putInt(dCSWSignature); // buffer.putInt(dCSWTag); // buffer.putInt(dCSWDataResidue); // buffer.put(bCSWStatus); // return buffer.array(); // } // // public int getdCSWSignature() // { // return dCSWSignature; // } // // public void setdCSWSignature(int dCSWSignature) // { // this.dCSWSignature = dCSWSignature; // } // // public int getdCSWTag() // { // return dCSWTag; // } // // public void setdCSWTag(int dCSWTag) // { // this.dCSWTag = dCSWTag; // } // // public int getdCSWDataResidue() // { // return dCSWDataResidue; // } // // public void setdCSWDataResidue(int dCSWDataResidue) // { // this.dCSWDataResidue = dCSWDataResidue; // } // // public byte getbCSWStatus() // { // return bCSWStatus; // } // // public void setbCSWStatus(byte bCSWStatus) // { // this.bCSWStatus = bCSWStatus; // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/bulkonly/BulkOnlyCommunicator.java import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbDeviceConnection; import android.util.Log; import java.util.concurrent.atomic.AtomicBoolean; import commandwrappers.CommandBlockWrapper; import commandwrappers.CommandStatusWrapper; package com.felhr.usbmassstorageforandroid.bulkonly; /** * Created by Felipe Herranz(felhr85@gmail.com) on 9/12/14. */ public class BulkOnlyCommunicator { private BulkOnlyStatusInterface statusCallback; private UsbFacade usbFacade; private AtomicBoolean flagDataIN; private AtomicBoolean flagDataOUT; public BulkOnlyCommunicator(UsbDevice mDevice, UsbDeviceConnection mConnection) { this.usbFacade = new UsbFacade(mDevice, mConnection); this.flagDataIN = new AtomicBoolean(false); this.flagDataOUT = new AtomicBoolean(false); } public boolean startBulkOnly(BulkOnlyStatusInterface statusCallback) { this.statusCallback = statusCallback; usbFacade.setCallback(mCallback); return usbFacade.openDevice(); }
public void sendCbw(CommandBlockWrapper cbw, byte[] data)
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/bulkonly/BulkOnlyCommunicator.java
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // // Path: src/main/java/commandwrappers/CommandStatusWrapper.java // public class CommandStatusWrapper extends CommandWrapper // { // private int dCSWSignature; // private int dCSWTag; // private int dCSWDataResidue; // private byte bCSWStatus; // // public CommandStatusWrapper(int dCSWSignature, int dCSWTag, int dCSWDataResidue, // byte bCSWStatus) // { // this.dCSWSignature = dCSWSignature; // this.dCSWTag = dCSWTag; // this.dCSWDataResidue = dCSWDataResidue; // this.bCSWStatus = bCSWStatus; // } // // public static CommandStatusWrapper getCWStatus(byte[] buffer) // { // int signature = convertToInt(Arrays.copyOfRange(buffer, 0, 4)); // int tag = convertToInt(Arrays.copyOfRange(buffer, 4, 8)); // int residue = convertToInt(Arrays.copyOfRange(buffer, 8, 12)); // byte status = buffer[12]; // return new CommandStatusWrapper(signature, tag, residue, status); // } // // private static int convertToInt(byte[] buffer) // { // int result; // result = buffer[0] & 0xff; // result = result + ((buffer[1] & 0xff) << 8); // result = result + ((buffer[2] & 0xff) << 16); // return result + ((buffer[3] & 0xff) << 24); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBS_SIZE); // buffer.putInt(dCSWSignature); // buffer.putInt(dCSWTag); // buffer.putInt(dCSWDataResidue); // buffer.put(bCSWStatus); // return buffer.array(); // } // // public int getdCSWSignature() // { // return dCSWSignature; // } // // public void setdCSWSignature(int dCSWSignature) // { // this.dCSWSignature = dCSWSignature; // } // // public int getdCSWTag() // { // return dCSWTag; // } // // public void setdCSWTag(int dCSWTag) // { // this.dCSWTag = dCSWTag; // } // // public int getdCSWDataResidue() // { // return dCSWDataResidue; // } // // public void setdCSWDataResidue(int dCSWDataResidue) // { // this.dCSWDataResidue = dCSWDataResidue; // } // // public byte getbCSWStatus() // { // return bCSWStatus; // } // // public void setbCSWStatus(byte bCSWStatus) // { // this.bCSWStatus = bCSWStatus; // } // }
import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbDeviceConnection; import android.util.Log; import java.util.concurrent.atomic.AtomicBoolean; import commandwrappers.CommandBlockWrapper; import commandwrappers.CommandStatusWrapper;
} public void injectUsbFacade(UsbFacade usbFacade) { this.usbFacade = usbFacade; } private UsbFacadeInterface mCallback = new UsbFacadeInterface() { @Override public void cbwResponse(int response) { if(response > 0 && flagDataOUT.get()) // CBW correctly sent. Send data. { statusCallback.onOperationStarted(true); }else if(response > 0 && flagDataIN.get()) // CBW correctly sent. Receive data. { statusCallback.onOperationStarted(true); }else if(response > 0) // CBW correctly sent. No data expected. { statusCallback.onOperationStarted(true); }else if(response <= 0) // CBW not correctly sent. { statusCallback.onOperationStarted(false); } } @Override public void cswData(byte[] data) {
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java // public class CommandBlockWrapper extends CommandWrapper // { // private int dCBWSignature; // private int dCBWTag; // private int dCBWDataLength; // private byte bmCBWFlags; // private byte bCBWLUN; // private byte bCBWCBLength; // private byte[] commandBlock; // // // public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = dCBWSignature; // this.dCBWTag = dCBWTag; // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public CommandBlockWrapper( int dCBWDataLength, // byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength) // { // this.dCBWSignature = CommandWrapper.CBW_SIGNATURE; // this.dCBWTag = generateTag(); // this.dCBWDataLength = dCBWDataLength; // this.bmCBWFlags = bmCBWFlags; // this.bCBWLUN = bCBWLUN; // this.bCBWCBLength = bCBWCBLength; // } // // public void setCommandBlock(byte[] commandBlock) // { // this.commandBlock = commandBlock; // } // // public int getdCBWDataLength() // { // return dCBWDataLength; // } // // public int generateTag() // { // Random random = new Random(); // return random.nextInt(); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE); // buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature)); // buffer.putInt(dCBWTag); // buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength)); // buffer.put(bmCBWFlags); // buffer.put(bCBWLUN); // buffer.put(bCBWCBLength); // buffer.put(commandBlock); // return buffer.array(); // } // } // // Path: src/main/java/commandwrappers/CommandStatusWrapper.java // public class CommandStatusWrapper extends CommandWrapper // { // private int dCSWSignature; // private int dCSWTag; // private int dCSWDataResidue; // private byte bCSWStatus; // // public CommandStatusWrapper(int dCSWSignature, int dCSWTag, int dCSWDataResidue, // byte bCSWStatus) // { // this.dCSWSignature = dCSWSignature; // this.dCSWTag = dCSWTag; // this.dCSWDataResidue = dCSWDataResidue; // this.bCSWStatus = bCSWStatus; // } // // public static CommandStatusWrapper getCWStatus(byte[] buffer) // { // int signature = convertToInt(Arrays.copyOfRange(buffer, 0, 4)); // int tag = convertToInt(Arrays.copyOfRange(buffer, 4, 8)); // int residue = convertToInt(Arrays.copyOfRange(buffer, 8, 12)); // byte status = buffer[12]; // return new CommandStatusWrapper(signature, tag, residue, status); // } // // private static int convertToInt(byte[] buffer) // { // int result; // result = buffer[0] & 0xff; // result = result + ((buffer[1] & 0xff) << 8); // result = result + ((buffer[2] & 0xff) << 16); // return result + ((buffer[3] & 0xff) << 24); // } // // @Override // public byte[] getCWBuffer() // { // ByteBuffer buffer = ByteBuffer.allocate(CBS_SIZE); // buffer.putInt(dCSWSignature); // buffer.putInt(dCSWTag); // buffer.putInt(dCSWDataResidue); // buffer.put(bCSWStatus); // return buffer.array(); // } // // public int getdCSWSignature() // { // return dCSWSignature; // } // // public void setdCSWSignature(int dCSWSignature) // { // this.dCSWSignature = dCSWSignature; // } // // public int getdCSWTag() // { // return dCSWTag; // } // // public void setdCSWTag(int dCSWTag) // { // this.dCSWTag = dCSWTag; // } // // public int getdCSWDataResidue() // { // return dCSWDataResidue; // } // // public void setdCSWDataResidue(int dCSWDataResidue) // { // this.dCSWDataResidue = dCSWDataResidue; // } // // public byte getbCSWStatus() // { // return bCSWStatus; // } // // public void setbCSWStatus(byte bCSWStatus) // { // this.bCSWStatus = bCSWStatus; // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/bulkonly/BulkOnlyCommunicator.java import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbDeviceConnection; import android.util.Log; import java.util.concurrent.atomic.AtomicBoolean; import commandwrappers.CommandBlockWrapper; import commandwrappers.CommandStatusWrapper; } public void injectUsbFacade(UsbFacade usbFacade) { this.usbFacade = usbFacade; } private UsbFacadeInterface mCallback = new UsbFacadeInterface() { @Override public void cbwResponse(int response) { if(response > 0 && flagDataOUT.get()) // CBW correctly sent. Send data. { statusCallback.onOperationStarted(true); }else if(response > 0 && flagDataIN.get()) // CBW correctly sent. Receive data. { statusCallback.onOperationStarted(true); }else if(response > 0) // CBW correctly sent. No data expected. { statusCallback.onOperationStarted(true); }else if(response <= 0) // CBW not correctly sent. { statusCallback.onOperationStarted(false); } } @Override public void cswData(byte[] data) {
CommandStatusWrapper csw = CommandStatusWrapper.getCWStatus(data);
felHR85/Pincho-Usb-Mass-Storage-for-Android
src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIInquiryResponse.java
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // }
import android.os.Bundle; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.util.Arrays;
private boolean hisup; private int dataFormatResponse; private int aditionalLength; private boolean sccs; private boolean acc; private int tpgs; private boolean thirdPartyCommands; private boolean protect; private boolean bque; private boolean encserv; private boolean vs; private boolean multip; private boolean mchngr; private boolean addr16; // Not used with USB interface private boolean wbus16; // Not used with USB interface private boolean sync; // Not used with USB interface private boolean linked; private boolean cmdque; private boolean vendorSpecific; private byte[] t10VendorIdentification; //8..15 private byte[] productIdentification; //16..31 private byte[] productRevisionLevel; //32..35 private SCSIInquiryResponse() { } public static SCSIInquiryResponse getResponse(byte[] data) {
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java // public class HexUtil // { // private static final String HEXES = "0123456789ABCDEF"; // private static final String HEX_INDICATOR = "0x"; // private static final String SPACE = " "; // // private HexUtil() // { // // } // // public static String hexToString(byte[] data) // { // if(data != null) // { // StringBuilder hex = new StringBuilder(2*data.length); // for(int i=0;i<=data.length-1;i++) // { // byte dataAtIndex = data[i]; // hex.append(HEX_INDICATOR); // hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) // .append(HEXES.charAt((dataAtIndex & 0x0F))); // hex.append(SPACE); // } // return hex.toString(); // }else // { // return null; // } // } // } // Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIInquiryResponse.java import android.os.Bundle; import android.util.Log; import com.felhr.usbmassstorageforandroid.utilities.HexUtil; import java.util.Arrays; private boolean hisup; private int dataFormatResponse; private int aditionalLength; private boolean sccs; private boolean acc; private int tpgs; private boolean thirdPartyCommands; private boolean protect; private boolean bque; private boolean encserv; private boolean vs; private boolean multip; private boolean mchngr; private boolean addr16; // Not used with USB interface private boolean wbus16; // Not used with USB interface private boolean sync; // Not used with USB interface private boolean linked; private boolean cmdque; private boolean vendorSpecific; private byte[] t10VendorIdentification; //8..15 private byte[] productIdentification; //16..31 private byte[] productRevisionLevel; //32..35 private SCSIInquiryResponse() { } public static SCSIInquiryResponse getResponse(byte[] data) {
Log.i("Buffer state", "Data to host: " + HexUtil.hexToString(data));
quiram/build-hotspots
src/test/java/com/github/quiram/buildhotspots/datetofrequencytransformertest/TwoElementsInDateToFrequencyTransformerTest.java
// Path: src/main/java/com/github/quiram/buildhotspots/DateToFrequencyTransformer.java // public class DateToFrequencyTransformer { // private LocalDateTime oldest; // private LocalDateTime mostRecent; // // // public LocalDateTime getOldestDate() { // return oldest; // } // // public void add(LocalDateTime dateTime) { // if (this.oldest == null || dateTime.isBefore(this.oldest)) { // this.oldest = dateTime; // } // // if (this.mostRecent == null || dateTime.isAfter(this.mostRecent)) { // mostRecent = dateTime; // } // } // // public LocalDateTime getMostRecentDate() { // return mostRecent; // } // // public long getFrequencyFor(LocalDateTime dateTime) { // if (oldest == null) { // throw new IllegalStateException("Transformer is empty."); // } // // if (oldest == mostRecent) { // throw new IllegalStateException("Transformer only has one element."); // } // // if (dateTime.isBefore(oldest) || dateTime.isAfter(mostRecent)) { // throw new IllegalArgumentException("Date to calculate frequency from must be within range of dates previously inserted in the transformer."); // } // // long totalRange = oldest.until(mostRecent, SECONDS); // long datePosition = oldest.until(dateTime, SECONDS); // // return datePosition * 100 / totalRange; // } // }
import com.github.quiram.buildhotspots.DateToFrequencyTransformer; import org.junit.Before; import org.junit.Test; import java.time.LocalDateTime; import static java.time.LocalDateTime.now; import static org.hamcrest.core.StringContains.containsString; import static org.junit.Assert.assertEquals;
package com.github.quiram.buildhotspots.datetofrequencytransformertest; public class TwoElementsInDateToFrequencyTransformerTest extends DateToFrequencyTransformerTest { private LocalDateTime older; private LocalDateTime later; @Before @Override public void setUp() { super.setUp(); older = now(); later = older.plusDays(1); transformer.add(older); transformer.add(later); } @Test public void oldestDateWhenFirstIsOlderReturnsFirst() { assertEquals(older, transformer.getOldestDate()); } @Test public void mostRecentDateWhenSecondIsOlderReturnsFirst() {
// Path: src/main/java/com/github/quiram/buildhotspots/DateToFrequencyTransformer.java // public class DateToFrequencyTransformer { // private LocalDateTime oldest; // private LocalDateTime mostRecent; // // // public LocalDateTime getOldestDate() { // return oldest; // } // // public void add(LocalDateTime dateTime) { // if (this.oldest == null || dateTime.isBefore(this.oldest)) { // this.oldest = dateTime; // } // // if (this.mostRecent == null || dateTime.isAfter(this.mostRecent)) { // mostRecent = dateTime; // } // } // // public LocalDateTime getMostRecentDate() { // return mostRecent; // } // // public long getFrequencyFor(LocalDateTime dateTime) { // if (oldest == null) { // throw new IllegalStateException("Transformer is empty."); // } // // if (oldest == mostRecent) { // throw new IllegalStateException("Transformer only has one element."); // } // // if (dateTime.isBefore(oldest) || dateTime.isAfter(mostRecent)) { // throw new IllegalArgumentException("Date to calculate frequency from must be within range of dates previously inserted in the transformer."); // } // // long totalRange = oldest.until(mostRecent, SECONDS); // long datePosition = oldest.until(dateTime, SECONDS); // // return datePosition * 100 / totalRange; // } // } // Path: src/test/java/com/github/quiram/buildhotspots/datetofrequencytransformertest/TwoElementsInDateToFrequencyTransformerTest.java import com.github.quiram.buildhotspots.DateToFrequencyTransformer; import org.junit.Before; import org.junit.Test; import java.time.LocalDateTime; import static java.time.LocalDateTime.now; import static org.hamcrest.core.StringContains.containsString; import static org.junit.Assert.assertEquals; package com.github.quiram.buildhotspots.datetofrequencytransformertest; public class TwoElementsInDateToFrequencyTransformerTest extends DateToFrequencyTransformerTest { private LocalDateTime older; private LocalDateTime later; @Before @Override public void setUp() { super.setUp(); older = now(); later = older.plusDays(1); transformer.add(older); transformer.add(later); } @Test public void oldestDateWhenFirstIsOlderReturnsFirst() { assertEquals(older, transformer.getOldestDate()); } @Test public void mostRecentDateWhenSecondIsOlderReturnsFirst() {
DateToFrequencyTransformer transformer = new DateToFrequencyTransformer();
quiram/build-hotspots
src/main/java/com/github/quiram/buildhotspots/DrawingBuilder.java
// Path: src/main/java/com/github/quiram/buildhotspots/clients/CiClient.java // public interface CiClient { // Optional<LocalDateTime> getDateOfOldestBuildFor(String jobName); // // List<String> getAllBuildConfigurations(); // // List<String> getDependenciesFor(String jobName); // // List<String> getDependentsFor(String jobName); // } // // Path: src/main/java/com/github/quiram/buildhotspots/drawingdata/DependencyType.java // @XmlAccessorType(XmlAccessType.FIELD) // @XmlType(name = "DependencyType", propOrder = { "buildConfigurationName" }) // public class DependencyType { // // @XmlElement(name = "BuildConfigurationName", required = true) // protected String buildConfigurationName; // // /** // * Gets the value of the buildConfigurationName property. // * // * @return // * possible object is // * {@link String } // * // */ // public String getBuildConfigurationName() { // return buildConfigurationName; // } // // /** // * Sets the value of the buildConfigurationName property. // * // * @param value // * allowed object is // * {@link String } // * // */ // public void setBuildConfigurationName(String value) { // this.buildConfigurationName = value; // } // // }
import com.github.quiram.buildhotspots.clients.CiClient; import com.github.quiram.buildhotspots.drawingdata.BuildConfigurationType; import com.github.quiram.buildhotspots.drawingdata.BuildConfigurationType.BuildStats; import com.github.quiram.buildhotspots.drawingdata.BuildConfigurationType.Dependencies; import com.github.quiram.buildhotspots.drawingdata.DependencyType; import com.github.quiram.buildhotspots.drawingdata.Root; import com.github.quiram.buildhotspots.drawingdata.Root.BuildConfigurations; import java.time.LocalDateTime; import java.util.*; import java.util.function.BiFunction; import static java.lang.String.format; import static java.util.stream.Collectors.toSet;
throw new BuildNotFoundException(buildName, e); } dateOfOldestBuild.ifPresent(transformer::add); final BuildConfigurationType buildConfiguration = new BuildConfigurationType(); buildConfiguration.setName(buildName); setDependencies(buildName, buildConfiguration); buildConfigurationsList.add(buildConfiguration); }); // Second pass: calculate relative frequency for all available builds buildConfigurationsList.forEach(this::setBuildStats); return root; } private void setBuildStats(BuildConfigurationType buildConfiguration) { BuildStats buildStats = new BuildStats(); final String buildName = buildConfiguration.getName(); final Optional<LocalDateTime> dateOfOldestBuild = ciClient.getDateOfOldestBuildFor(buildName); buildStats.setPercentage(dateOfOldestBuild.map(transformer::getFrequencyFor).orElse(50L).byteValue()); buildConfiguration.setBuildStats(buildStats); } private void setDependencies(String buildName, BuildConfigurationType buildConfiguration) { final Dependencies dependencies = new Dependencies();
// Path: src/main/java/com/github/quiram/buildhotspots/clients/CiClient.java // public interface CiClient { // Optional<LocalDateTime> getDateOfOldestBuildFor(String jobName); // // List<String> getAllBuildConfigurations(); // // List<String> getDependenciesFor(String jobName); // // List<String> getDependentsFor(String jobName); // } // // Path: src/main/java/com/github/quiram/buildhotspots/drawingdata/DependencyType.java // @XmlAccessorType(XmlAccessType.FIELD) // @XmlType(name = "DependencyType", propOrder = { "buildConfigurationName" }) // public class DependencyType { // // @XmlElement(name = "BuildConfigurationName", required = true) // protected String buildConfigurationName; // // /** // * Gets the value of the buildConfigurationName property. // * // * @return // * possible object is // * {@link String } // * // */ // public String getBuildConfigurationName() { // return buildConfigurationName; // } // // /** // * Sets the value of the buildConfigurationName property. // * // * @param value // * allowed object is // * {@link String } // * // */ // public void setBuildConfigurationName(String value) { // this.buildConfigurationName = value; // } // // } // Path: src/main/java/com/github/quiram/buildhotspots/DrawingBuilder.java import com.github.quiram.buildhotspots.clients.CiClient; import com.github.quiram.buildhotspots.drawingdata.BuildConfigurationType; import com.github.quiram.buildhotspots.drawingdata.BuildConfigurationType.BuildStats; import com.github.quiram.buildhotspots.drawingdata.BuildConfigurationType.Dependencies; import com.github.quiram.buildhotspots.drawingdata.DependencyType; import com.github.quiram.buildhotspots.drawingdata.Root; import com.github.quiram.buildhotspots.drawingdata.Root.BuildConfigurations; import java.time.LocalDateTime; import java.util.*; import java.util.function.BiFunction; import static java.lang.String.format; import static java.util.stream.Collectors.toSet; throw new BuildNotFoundException(buildName, e); } dateOfOldestBuild.ifPresent(transformer::add); final BuildConfigurationType buildConfiguration = new BuildConfigurationType(); buildConfiguration.setName(buildName); setDependencies(buildName, buildConfiguration); buildConfigurationsList.add(buildConfiguration); }); // Second pass: calculate relative frequency for all available builds buildConfigurationsList.forEach(this::setBuildStats); return root; } private void setBuildStats(BuildConfigurationType buildConfiguration) { BuildStats buildStats = new BuildStats(); final String buildName = buildConfiguration.getName(); final Optional<LocalDateTime> dateOfOldestBuild = ciClient.getDateOfOldestBuildFor(buildName); buildStats.setPercentage(dateOfOldestBuild.map(transformer::getFrequencyFor).orElse(50L).byteValue()); buildConfiguration.setBuildStats(buildStats); } private void setDependencies(String buildName, BuildConfigurationType buildConfiguration) { final Dependencies dependencies = new Dependencies();
final List<DependencyType> dependencyList = dependencies.getDependency();
quiram/build-hotspots
src/test/java/com/github/quiram/buildhotspots/datetofrequencytransformertest/DateToFrequencyTransformerTest.java
// Path: src/main/java/com/github/quiram/buildhotspots/DateToFrequencyTransformer.java // public class DateToFrequencyTransformer { // private LocalDateTime oldest; // private LocalDateTime mostRecent; // // // public LocalDateTime getOldestDate() { // return oldest; // } // // public void add(LocalDateTime dateTime) { // if (this.oldest == null || dateTime.isBefore(this.oldest)) { // this.oldest = dateTime; // } // // if (this.mostRecent == null || dateTime.isAfter(this.mostRecent)) { // mostRecent = dateTime; // } // } // // public LocalDateTime getMostRecentDate() { // return mostRecent; // } // // public long getFrequencyFor(LocalDateTime dateTime) { // if (oldest == null) { // throw new IllegalStateException("Transformer is empty."); // } // // if (oldest == mostRecent) { // throw new IllegalStateException("Transformer only has one element."); // } // // if (dateTime.isBefore(oldest) || dateTime.isAfter(mostRecent)) { // throw new IllegalArgumentException("Date to calculate frequency from must be within range of dates previously inserted in the transformer."); // } // // long totalRange = oldest.until(mostRecent, SECONDS); // long datePosition = oldest.until(dateTime, SECONDS); // // return datePosition * 100 / totalRange; // } // }
import com.github.quiram.buildhotspots.DateToFrequencyTransformer; import org.junit.Before; import org.junit.Rule; import org.junit.rules.ExpectedException;
package com.github.quiram.buildhotspots.datetofrequencytransformertest; abstract public class DateToFrequencyTransformerTest { @Rule public ExpectedException onBadState = ExpectedException.none();
// Path: src/main/java/com/github/quiram/buildhotspots/DateToFrequencyTransformer.java // public class DateToFrequencyTransformer { // private LocalDateTime oldest; // private LocalDateTime mostRecent; // // // public LocalDateTime getOldestDate() { // return oldest; // } // // public void add(LocalDateTime dateTime) { // if (this.oldest == null || dateTime.isBefore(this.oldest)) { // this.oldest = dateTime; // } // // if (this.mostRecent == null || dateTime.isAfter(this.mostRecent)) { // mostRecent = dateTime; // } // } // // public LocalDateTime getMostRecentDate() { // return mostRecent; // } // // public long getFrequencyFor(LocalDateTime dateTime) { // if (oldest == null) { // throw new IllegalStateException("Transformer is empty."); // } // // if (oldest == mostRecent) { // throw new IllegalStateException("Transformer only has one element."); // } // // if (dateTime.isBefore(oldest) || dateTime.isAfter(mostRecent)) { // throw new IllegalArgumentException("Date to calculate frequency from must be within range of dates previously inserted in the transformer."); // } // // long totalRange = oldest.until(mostRecent, SECONDS); // long datePosition = oldest.until(dateTime, SECONDS); // // return datePosition * 100 / totalRange; // } // } // Path: src/test/java/com/github/quiram/buildhotspots/datetofrequencytransformertest/DateToFrequencyTransformerTest.java import com.github.quiram.buildhotspots.DateToFrequencyTransformer; import org.junit.Before; import org.junit.Rule; import org.junit.rules.ExpectedException; package com.github.quiram.buildhotspots.datetofrequencytransformertest; abstract public class DateToFrequencyTransformerTest { @Rule public ExpectedException onBadState = ExpectedException.none();
protected DateToFrequencyTransformer transformer;
quiram/build-hotspots
src/test/java/com/github/quiram/buildhotspots/DrawingBuilderTest.java
// Path: src/main/java/com/github/quiram/buildhotspots/clients/CiClient.java // public interface CiClient { // Optional<LocalDateTime> getDateOfOldestBuildFor(String jobName); // // List<String> getAllBuildConfigurations(); // // List<String> getDependenciesFor(String jobName); // // List<String> getDependentsFor(String jobName); // } // // Path: src/main/java/com/github/quiram/buildhotspots/drawingdata/DependencyType.java // @XmlAccessorType(XmlAccessType.FIELD) // @XmlType(name = "DependencyType", propOrder = { "buildConfigurationName" }) // public class DependencyType { // // @XmlElement(name = "BuildConfigurationName", required = true) // protected String buildConfigurationName; // // /** // * Gets the value of the buildConfigurationName property. // * // * @return // * possible object is // * {@link String } // * // */ // public String getBuildConfigurationName() { // return buildConfigurationName; // } // // /** // * Sets the value of the buildConfigurationName property. // * // * @param value // * allowed object is // * {@link String } // * // */ // public void setBuildConfigurationName(String value) { // this.buildConfigurationName = value; // } // // }
import com.github.quiram.buildhotspots.clients.CiClient; import com.github.quiram.buildhotspots.drawingdata.BuildConfigurationType; import com.github.quiram.buildhotspots.drawingdata.BuildConfigurationType.BuildStats; import com.github.quiram.buildhotspots.drawingdata.DependencyType; import com.github.quiram.buildhotspots.drawingdata.Root; import com.github.quiram.buildhotspots.drawingdata.Root.BuildConfigurations; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.InOrder; import java.time.LocalDateTime; import java.util.List; import java.util.Optional; import java.util.Random; import static java.time.LocalDateTime.now; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.core.StringContains.containsString; import static org.junit.Assert.*; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.*;
final String unrelatedDependent = "unrelated-dependent"; when(ciClient.getDependentsFor(dependencyBuildName)).thenReturn(asList(buildName, unrelatedDependent)); when(ciClient.getDependenciesFor(buildName)).thenReturn(singletonList(dependencyBuildName)); Root documentRoot = drawingBuilder.buildFor(singletonList(buildName)); assertRootHasTwoDependentBuilds(documentRoot, dependencyBuildName, buildName); } private void assertEmptyDocument(Root documentRoot) { assertNotNull(documentRoot); final BuildConfigurations buildConfigurations = documentRoot.getBuildConfigurations(); assertNotNull(buildConfigurations); final List<BuildConfigurationType> buildConfiguration = buildConfigurations.getBuildConfiguration(); assertTrue(buildConfiguration.isEmpty()); } private void assertRootHasOneBuild(Root documentRoot, String buildName) { final List<BuildConfigurationType> buildConfigurationList = documentRoot.getBuildConfigurations().getBuildConfiguration(); assertEquals(1, buildConfigurationList.size()); final BuildConfigurationType buildConfigurationType = buildConfigurationList.get(0); assertEquals(buildName, buildConfigurationType.getName()); assertNull(buildConfigurationType.getDependencies()); } private void assertRootHasTwoDependentBuilds(Root documentRoot, String mainBuildName, String dependentBuildName) { final List<BuildConfigurationType> buildConfigurationList = documentRoot.getBuildConfigurations().getBuildConfiguration(); assertEquals(2, buildConfigurationList.size()); final BuildConfigurationType buildConfiguration = buildConfigurationList.stream().filter(b -> b.getName().equals(dependentBuildName)).findFirst().get();
// Path: src/main/java/com/github/quiram/buildhotspots/clients/CiClient.java // public interface CiClient { // Optional<LocalDateTime> getDateOfOldestBuildFor(String jobName); // // List<String> getAllBuildConfigurations(); // // List<String> getDependenciesFor(String jobName); // // List<String> getDependentsFor(String jobName); // } // // Path: src/main/java/com/github/quiram/buildhotspots/drawingdata/DependencyType.java // @XmlAccessorType(XmlAccessType.FIELD) // @XmlType(name = "DependencyType", propOrder = { "buildConfigurationName" }) // public class DependencyType { // // @XmlElement(name = "BuildConfigurationName", required = true) // protected String buildConfigurationName; // // /** // * Gets the value of the buildConfigurationName property. // * // * @return // * possible object is // * {@link String } // * // */ // public String getBuildConfigurationName() { // return buildConfigurationName; // } // // /** // * Sets the value of the buildConfigurationName property. // * // * @param value // * allowed object is // * {@link String } // * // */ // public void setBuildConfigurationName(String value) { // this.buildConfigurationName = value; // } // // } // Path: src/test/java/com/github/quiram/buildhotspots/DrawingBuilderTest.java import com.github.quiram.buildhotspots.clients.CiClient; import com.github.quiram.buildhotspots.drawingdata.BuildConfigurationType; import com.github.quiram.buildhotspots.drawingdata.BuildConfigurationType.BuildStats; import com.github.quiram.buildhotspots.drawingdata.DependencyType; import com.github.quiram.buildhotspots.drawingdata.Root; import com.github.quiram.buildhotspots.drawingdata.Root.BuildConfigurations; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.InOrder; import java.time.LocalDateTime; import java.util.List; import java.util.Optional; import java.util.Random; import static java.time.LocalDateTime.now; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.core.StringContains.containsString; import static org.junit.Assert.*; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.*; final String unrelatedDependent = "unrelated-dependent"; when(ciClient.getDependentsFor(dependencyBuildName)).thenReturn(asList(buildName, unrelatedDependent)); when(ciClient.getDependenciesFor(buildName)).thenReturn(singletonList(dependencyBuildName)); Root documentRoot = drawingBuilder.buildFor(singletonList(buildName)); assertRootHasTwoDependentBuilds(documentRoot, dependencyBuildName, buildName); } private void assertEmptyDocument(Root documentRoot) { assertNotNull(documentRoot); final BuildConfigurations buildConfigurations = documentRoot.getBuildConfigurations(); assertNotNull(buildConfigurations); final List<BuildConfigurationType> buildConfiguration = buildConfigurations.getBuildConfiguration(); assertTrue(buildConfiguration.isEmpty()); } private void assertRootHasOneBuild(Root documentRoot, String buildName) { final List<BuildConfigurationType> buildConfigurationList = documentRoot.getBuildConfigurations().getBuildConfiguration(); assertEquals(1, buildConfigurationList.size()); final BuildConfigurationType buildConfigurationType = buildConfigurationList.get(0); assertEquals(buildName, buildConfigurationType.getName()); assertNull(buildConfigurationType.getDependencies()); } private void assertRootHasTwoDependentBuilds(Root documentRoot, String mainBuildName, String dependentBuildName) { final List<BuildConfigurationType> buildConfigurationList = documentRoot.getBuildConfigurations().getBuildConfiguration(); assertEquals(2, buildConfigurationList.size()); final BuildConfigurationType buildConfiguration = buildConfigurationList.stream().filter(b -> b.getName().equals(dependentBuildName)).findFirst().get();
final List<DependencyType> dependencyList = buildConfiguration.getDependencies().getDependency();
quiram/build-hotspots
src/test/java/com/github/quiram/buildhotspots/clients/JenkinsClientTest.java
// Path: src/main/java/com/github/quiram/buildhotspots/clients/jenkins/beans/JenkinsClient.java // public class JenkinsClient implements CiClient { // // private WebTarget target; // private JenkinsPathBuilder pathBuilder = new JenkinsPathBuilder(); // // public JenkinsClient(String jenkinsBaseUrl) { // target = ClientBuilder.newClient().target(jenkinsBaseUrl); // } // // /** // * Provide the serial number for the oldest available build, if any. // * // * @param buildName Name of the build // * @return Number of the oldest available build, if there is any. // */ // public Optional<Integer> getOldestBuildNumber(String buildName) { // FirstBuildResponseBean buildNumberBean = requestData(FirstBuildResponseBean.class, "firstBuild[number]", "job", buildName); // // try { // return buildNumberBean.getNumber(); // } catch (Exception e) { // System.err.println(format("Failed to obtain oldest build number for '%s'.", buildName)); // throw e; // } // } // // @Override // public Optional<LocalDateTime> getDateOfOldestBuildFor(String jobName) { // final Optional<Integer> oldestBuildNumber = getOldestBuildNumber(jobName); // // if (!oldestBuildNumber.isPresent()) { // return Optional.empty(); // } // // TimestampBean timeStampBean = requestData(TimestampBean.class, "timestamp[*]", "job", jobName, oldestBuildNumber.get()); // // Instant instant = Instant.ofEpochMilli(timeStampBean.getTimestamp()); // // return Optional.of(LocalDateTime.ofInstant(instant, ZoneId.of("Z"))); // } // // private <T> T requestData(Class<T> returnType, String filter, Object... pathElements) { // String requestUrl = pathBuilder.build(pathElements); // // try { // WebTarget path = target.path(requestUrl); // // if (!filter.equals("")) { // path = path.queryParam("tree", filter); // } // // return path.request().get(returnType); // } catch (Exception e) { // System.err.println(format("Failed to request '%s' with tree filter '%s'", requestUrl, filter)); // throw e; // } // } // // @Override // public List<String> getAllBuildConfigurations() { // final GetBuildsResponse response = requestData(GetBuildsResponse.class, ""); // // return response.getJobs().stream().map(Job::getName).collect(toList()); // } // // @Override // public List<String> getDependenciesFor(String jobName) { // return getDataForJob(jobName, GetBuildResponse::getUpstreamProjects); // } // // @Override // public List<String> getDependentsFor(String jobName) { // return getDataForJob(jobName, GetBuildResponse::getDownstreamProjects); // } // // private List<String> getDataForJob(String jobName, Function<GetBuildResponse, List<Project>> operation) { // final GetBuildResponse response = requestData(GetBuildResponse.class, "", "job", jobName); // final List<Project> referredProjects = operation.apply(response); // return referredProjects.stream().map(Project::getName).collect(toList()); // } // }
import com.github.quiram.buildhotspots.clients.jenkins.beans.JenkinsClient; import com.github.tomakehurst.wiremock.junit.WireMockRule; import org.junit.Before; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.List; import static com.github.tomakehurst.wiremock.client.WireMock.*; import static java.lang.String.format; import static java.time.LocalDateTime.parse; import static org.fest.assertions.Assertions.assertThat; import static org.junit.Assert.*;
package com.github.quiram.buildhotspots.clients; public class JenkinsClientTest { public static final String DATASETS_SERVICE = "datasets-service"; public static final int PORT = 8080; public static final String JENKINS_BASE_URL = format("http://localhost:%s/", PORT);
// Path: src/main/java/com/github/quiram/buildhotspots/clients/jenkins/beans/JenkinsClient.java // public class JenkinsClient implements CiClient { // // private WebTarget target; // private JenkinsPathBuilder pathBuilder = new JenkinsPathBuilder(); // // public JenkinsClient(String jenkinsBaseUrl) { // target = ClientBuilder.newClient().target(jenkinsBaseUrl); // } // // /** // * Provide the serial number for the oldest available build, if any. // * // * @param buildName Name of the build // * @return Number of the oldest available build, if there is any. // */ // public Optional<Integer> getOldestBuildNumber(String buildName) { // FirstBuildResponseBean buildNumberBean = requestData(FirstBuildResponseBean.class, "firstBuild[number]", "job", buildName); // // try { // return buildNumberBean.getNumber(); // } catch (Exception e) { // System.err.println(format("Failed to obtain oldest build number for '%s'.", buildName)); // throw e; // } // } // // @Override // public Optional<LocalDateTime> getDateOfOldestBuildFor(String jobName) { // final Optional<Integer> oldestBuildNumber = getOldestBuildNumber(jobName); // // if (!oldestBuildNumber.isPresent()) { // return Optional.empty(); // } // // TimestampBean timeStampBean = requestData(TimestampBean.class, "timestamp[*]", "job", jobName, oldestBuildNumber.get()); // // Instant instant = Instant.ofEpochMilli(timeStampBean.getTimestamp()); // // return Optional.of(LocalDateTime.ofInstant(instant, ZoneId.of("Z"))); // } // // private <T> T requestData(Class<T> returnType, String filter, Object... pathElements) { // String requestUrl = pathBuilder.build(pathElements); // // try { // WebTarget path = target.path(requestUrl); // // if (!filter.equals("")) { // path = path.queryParam("tree", filter); // } // // return path.request().get(returnType); // } catch (Exception e) { // System.err.println(format("Failed to request '%s' with tree filter '%s'", requestUrl, filter)); // throw e; // } // } // // @Override // public List<String> getAllBuildConfigurations() { // final GetBuildsResponse response = requestData(GetBuildsResponse.class, ""); // // return response.getJobs().stream().map(Job::getName).collect(toList()); // } // // @Override // public List<String> getDependenciesFor(String jobName) { // return getDataForJob(jobName, GetBuildResponse::getUpstreamProjects); // } // // @Override // public List<String> getDependentsFor(String jobName) { // return getDataForJob(jobName, GetBuildResponse::getDownstreamProjects); // } // // private List<String> getDataForJob(String jobName, Function<GetBuildResponse, List<Project>> operation) { // final GetBuildResponse response = requestData(GetBuildResponse.class, "", "job", jobName); // final List<Project> referredProjects = operation.apply(response); // return referredProjects.stream().map(Project::getName).collect(toList()); // } // } // Path: src/test/java/com/github/quiram/buildhotspots/clients/JenkinsClientTest.java import com.github.quiram.buildhotspots.clients.jenkins.beans.JenkinsClient; import com.github.tomakehurst.wiremock.junit.WireMockRule; import org.junit.Before; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.List; import static com.github.tomakehurst.wiremock.client.WireMock.*; import static java.lang.String.format; import static java.time.LocalDateTime.parse; import static org.fest.assertions.Assertions.assertThat; import static org.junit.Assert.*; package com.github.quiram.buildhotspots.clients; public class JenkinsClientTest { public static final String DATASETS_SERVICE = "datasets-service"; public static final int PORT = 8080; public static final String JENKINS_BASE_URL = format("http://localhost:%s/", PORT);
private JenkinsClient jenkinsClient;
undera/jmeter-plugins-manager
src/main/java/org/jmeterplugins/repository/PluginManager.java
// Path: src/main/java/org/jmeterplugins/repository/exception/DownloadException.java // public class DownloadException extends RuntimeException { // public DownloadException() { // } // // public DownloadException(String message) { // super(message); // } // // public DownloadException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/main/java/org/jmeterplugins/repository/http/StatsReporter.java // public class StatsReporter extends Thread { // private static final Logger log = LoggerFactory.getLogger(StatsReporter.class); // // private final JARSource jarSource; // private final String[] usageStats; // // public StatsReporter(JARSource jarSource, String[] usageStats) throws CloneNotSupportedException { // this.jarSource = (JARSource) jarSource.clone(); // this.usageStats = usageStats; // setDaemon(true); // } // // @Override // public void run() { // try { // jarSource.reportStats(usageStats); // log.debug("Finished send repo stats"); // } catch (IOException e) { // log.warn("Failed to send repo stats", e); // } // } // // protected JARSource getJarSource() { // return jarSource; // } // }
import net.sf.json.JSON; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import net.sf.json.JSONSerializer; import org.apache.jmeter.assertions.Assertion; import org.apache.jmeter.config.ConfigElement; import org.apache.jmeter.control.Controller; import org.apache.jmeter.engine.JMeterEngine; import org.apache.jmeter.gui.JMeterGUIComponent; import org.apache.jmeter.processor.PostProcessor; import org.apache.jmeter.processor.PreProcessor; import org.apache.jmeter.samplers.SampleListener; import org.apache.jmeter.samplers.Sampler; import org.apache.jmeter.testbeans.TestBean; import org.apache.jmeter.timers.Timer; import org.apache.jmeter.util.JMeterUtils; import org.apache.jorphan.reflect.ClassFinder; import org.jmeterplugins.repository.exception.DownloadException; import org.jmeterplugins.repository.http.StatsReporter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.nio.file.AccessDeniedException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet;
throw new RuntimeException("Result is not array"); } for (Object elm : (JSONArray) json) { if (elm instanceof JSONObject) { Plugin plugin = Plugin.fromJSON((JSONObject) elm); if (plugin.getName().isEmpty()) { log.debug("Skip empty name: " + plugin); continue; } if (!plugin.isVirtual()) { plugin.detectInstalled(getInstalledPlugins()); } allPlugins.put(plugin, plugin.isInstalled()); } else { log.warn("Invalid array element: " + elm); } } // after all usual plugins detected, detect virtual sets for (Plugin plugin : allPlugins.keySet()) { if (plugin.isVirtual()) { plugin.detectInstalled(getInstalledPlugins()); allPlugins.put(plugin, plugin.isInstalled()); } } if (isSendRepoStats && JMeterUtils.getPropDefault("jpgc.repo.sendstats", "true").equals("true")) { try {
// Path: src/main/java/org/jmeterplugins/repository/exception/DownloadException.java // public class DownloadException extends RuntimeException { // public DownloadException() { // } // // public DownloadException(String message) { // super(message); // } // // public DownloadException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/main/java/org/jmeterplugins/repository/http/StatsReporter.java // public class StatsReporter extends Thread { // private static final Logger log = LoggerFactory.getLogger(StatsReporter.class); // // private final JARSource jarSource; // private final String[] usageStats; // // public StatsReporter(JARSource jarSource, String[] usageStats) throws CloneNotSupportedException { // this.jarSource = (JARSource) jarSource.clone(); // this.usageStats = usageStats; // setDaemon(true); // } // // @Override // public void run() { // try { // jarSource.reportStats(usageStats); // log.debug("Finished send repo stats"); // } catch (IOException e) { // log.warn("Failed to send repo stats", e); // } // } // // protected JARSource getJarSource() { // return jarSource; // } // } // Path: src/main/java/org/jmeterplugins/repository/PluginManager.java import net.sf.json.JSON; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import net.sf.json.JSONSerializer; import org.apache.jmeter.assertions.Assertion; import org.apache.jmeter.config.ConfigElement; import org.apache.jmeter.control.Controller; import org.apache.jmeter.engine.JMeterEngine; import org.apache.jmeter.gui.JMeterGUIComponent; import org.apache.jmeter.processor.PostProcessor; import org.apache.jmeter.processor.PreProcessor; import org.apache.jmeter.samplers.SampleListener; import org.apache.jmeter.samplers.Sampler; import org.apache.jmeter.testbeans.TestBean; import org.apache.jmeter.timers.Timer; import org.apache.jmeter.util.JMeterUtils; import org.apache.jorphan.reflect.ClassFinder; import org.jmeterplugins.repository.exception.DownloadException; import org.jmeterplugins.repository.http.StatsReporter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.nio.file.AccessDeniedException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; throw new RuntimeException("Result is not array"); } for (Object elm : (JSONArray) json) { if (elm instanceof JSONObject) { Plugin plugin = Plugin.fromJSON((JSONObject) elm); if (plugin.getName().isEmpty()) { log.debug("Skip empty name: " + plugin); continue; } if (!plugin.isVirtual()) { plugin.detectInstalled(getInstalledPlugins()); } allPlugins.put(plugin, plugin.isInstalled()); } else { log.warn("Invalid array element: " + elm); } } // after all usual plugins detected, detect virtual sets for (Plugin plugin : allPlugins.keySet()) { if (plugin.isVirtual()) { plugin.detectInstalled(getInstalledPlugins()); allPlugins.put(plugin, plugin.isInstalled()); } } if (isSendRepoStats && JMeterUtils.getPropDefault("jpgc.repo.sendstats", "true").equals("true")) { try {
StatsReporter reporter = new StatsReporter(jarSource, getUsageStats());
undera/jmeter-plugins-manager
src/main/java/org/jmeterplugins/repository/PluginManager.java
// Path: src/main/java/org/jmeterplugins/repository/exception/DownloadException.java // public class DownloadException extends RuntimeException { // public DownloadException() { // } // // public DownloadException(String message) { // super(message); // } // // public DownloadException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/main/java/org/jmeterplugins/repository/http/StatsReporter.java // public class StatsReporter extends Thread { // private static final Logger log = LoggerFactory.getLogger(StatsReporter.class); // // private final JARSource jarSource; // private final String[] usageStats; // // public StatsReporter(JARSource jarSource, String[] usageStats) throws CloneNotSupportedException { // this.jarSource = (JARSource) jarSource.clone(); // this.usageStats = usageStats; // setDaemon(true); // } // // @Override // public void run() { // try { // jarSource.reportStats(usageStats); // log.debug("Finished send repo stats"); // } catch (IOException e) { // log.warn("Failed to send repo stats", e); // } // } // // protected JARSource getJarSource() { // return jarSource; // } // }
import net.sf.json.JSON; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import net.sf.json.JSONSerializer; import org.apache.jmeter.assertions.Assertion; import org.apache.jmeter.config.ConfigElement; import org.apache.jmeter.control.Controller; import org.apache.jmeter.engine.JMeterEngine; import org.apache.jmeter.gui.JMeterGUIComponent; import org.apache.jmeter.processor.PostProcessor; import org.apache.jmeter.processor.PreProcessor; import org.apache.jmeter.samplers.SampleListener; import org.apache.jmeter.samplers.Sampler; import org.apache.jmeter.testbeans.TestBean; import org.apache.jmeter.timers.Timer; import org.apache.jmeter.util.JMeterUtils; import org.apache.jorphan.reflect.ClassFinder; import org.jmeterplugins.repository.exception.DownloadException; import org.jmeterplugins.repository.http.StatsReporter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.nio.file.AccessDeniedException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet;
File restartFile; if (doRestart) { restartFile = maker.getRestartFile(additionalJMeterOptions); } else { restartFile = null; } final ProcessBuilder builder = maker.getProcessBuilder(moveFile, installFile, restartFile); log.info("JAR Modifications log will be saved into: " + builder.redirectOutput().file().getPath()); builder.start(); } public void applyChanges(GenericCallback<String> statusChanged, boolean doRestart, LinkedList<String> additionalJMeterOptions) { try { checkRW(); } catch (Throwable e) { throw new RuntimeException("Cannot apply changes: " + e.getMessage(), e); } DependencyResolver resolver = new DependencyResolver(allPlugins); Set<Plugin> additions = resolver.getAdditions(); Set<Library.InstallationInfo> libInstalls = new HashSet<>(); for (Map.Entry<String, String> entry : resolver.getLibAdditions().entrySet()) { try { JARSource.DownloadResult dwn = jarSource.getJAR(entry.getKey(), entry.getValue(), statusChanged); libInstalls.add(new Library.InstallationInfo(entry.getKey(), dwn.getTmpFile(), dwn.getFilename())); } catch (Throwable e) { String msg = "Failed to download " + entry.getKey(); log.error(msg, e); statusChanged.notify(msg);
// Path: src/main/java/org/jmeterplugins/repository/exception/DownloadException.java // public class DownloadException extends RuntimeException { // public DownloadException() { // } // // public DownloadException(String message) { // super(message); // } // // public DownloadException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/main/java/org/jmeterplugins/repository/http/StatsReporter.java // public class StatsReporter extends Thread { // private static final Logger log = LoggerFactory.getLogger(StatsReporter.class); // // private final JARSource jarSource; // private final String[] usageStats; // // public StatsReporter(JARSource jarSource, String[] usageStats) throws CloneNotSupportedException { // this.jarSource = (JARSource) jarSource.clone(); // this.usageStats = usageStats; // setDaemon(true); // } // // @Override // public void run() { // try { // jarSource.reportStats(usageStats); // log.debug("Finished send repo stats"); // } catch (IOException e) { // log.warn("Failed to send repo stats", e); // } // } // // protected JARSource getJarSource() { // return jarSource; // } // } // Path: src/main/java/org/jmeterplugins/repository/PluginManager.java import net.sf.json.JSON; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import net.sf.json.JSONSerializer; import org.apache.jmeter.assertions.Assertion; import org.apache.jmeter.config.ConfigElement; import org.apache.jmeter.control.Controller; import org.apache.jmeter.engine.JMeterEngine; import org.apache.jmeter.gui.JMeterGUIComponent; import org.apache.jmeter.processor.PostProcessor; import org.apache.jmeter.processor.PreProcessor; import org.apache.jmeter.samplers.SampleListener; import org.apache.jmeter.samplers.Sampler; import org.apache.jmeter.testbeans.TestBean; import org.apache.jmeter.timers.Timer; import org.apache.jmeter.util.JMeterUtils; import org.apache.jorphan.reflect.ClassFinder; import org.jmeterplugins.repository.exception.DownloadException; import org.jmeterplugins.repository.http.StatsReporter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.nio.file.AccessDeniedException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; File restartFile; if (doRestart) { restartFile = maker.getRestartFile(additionalJMeterOptions); } else { restartFile = null; } final ProcessBuilder builder = maker.getProcessBuilder(moveFile, installFile, restartFile); log.info("JAR Modifications log will be saved into: " + builder.redirectOutput().file().getPath()); builder.start(); } public void applyChanges(GenericCallback<String> statusChanged, boolean doRestart, LinkedList<String> additionalJMeterOptions) { try { checkRW(); } catch (Throwable e) { throw new RuntimeException("Cannot apply changes: " + e.getMessage(), e); } DependencyResolver resolver = new DependencyResolver(allPlugins); Set<Plugin> additions = resolver.getAdditions(); Set<Library.InstallationInfo> libInstalls = new HashSet<>(); for (Map.Entry<String, String> entry : resolver.getLibAdditions().entrySet()) { try { JARSource.DownloadResult dwn = jarSource.getJAR(entry.getKey(), entry.getValue(), statusChanged); libInstalls.add(new Library.InstallationInfo(entry.getKey(), dwn.getTmpFile(), dwn.getFilename())); } catch (Throwable e) { String msg = "Failed to download " + entry.getKey(); log.error(msg, e); statusChanged.notify(msg);
throw new DownloadException("Failed to download library " + entry.getKey(), e);
undera/jmeter-plugins-manager
src/main/java/org/jmeterplugins/repository/PluginManagerDialog.java
// Path: src/main/java/org/jmeterplugins/repository/exception/DownloadException.java // public class DownloadException extends RuntimeException { // public DownloadException() { // } // // public DownloadException(String message) { // super(message); // } // // public DownloadException(String message, Throwable cause) { // super(message, cause); // } // }
import org.apache.jmeter.gui.GuiPackage; import org.apache.jmeter.gui.action.ActionNames; import org.apache.jmeter.gui.action.ActionRouter; import org.apache.jmeter.gui.util.EscapeDialog; import org.apache.jorphan.gui.ComponentUtil; import org.jmeterplugins.repository.exception.DownloadException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.swing.*; import javax.swing.border.Border; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.util.LinkedList;
statusLabel.setForeground(Color.BLACK); enableComponents(false); new Thread() { @Override public void run() { // FIXME: what to do when user presses "cancel" on save test plan dialog? GenericCallback<String> statusChanged = new GenericCallback<String>() { @Override public void notify(final String s) { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { statusLabel.setText(s); repaint(); } }); } }; try { LinkedList<String> options = null; String testPlan = GuiPackage.getInstance().getTestPlanFile(); if (testPlan != null) { options = new LinkedList<>(); options.add("-t"); options.add(testPlan); } manager.applyChanges(statusChanged, true, options); ActionRouter.getInstance().actionPerformed(new ActionEvent(this, 0, ActionNames.EXIT));
// Path: src/main/java/org/jmeterplugins/repository/exception/DownloadException.java // public class DownloadException extends RuntimeException { // public DownloadException() { // } // // public DownloadException(String message) { // super(message); // } // // public DownloadException(String message, Throwable cause) { // super(message, cause); // } // } // Path: src/main/java/org/jmeterplugins/repository/PluginManagerDialog.java import org.apache.jmeter.gui.GuiPackage; import org.apache.jmeter.gui.action.ActionNames; import org.apache.jmeter.gui.action.ActionRouter; import org.apache.jmeter.gui.util.EscapeDialog; import org.apache.jorphan.gui.ComponentUtil; import org.jmeterplugins.repository.exception.DownloadException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.swing.*; import javax.swing.border.Border; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.util.LinkedList; statusLabel.setForeground(Color.BLACK); enableComponents(false); new Thread() { @Override public void run() { // FIXME: what to do when user presses "cancel" on save test plan dialog? GenericCallback<String> statusChanged = new GenericCallback<String>() { @Override public void notify(final String s) { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { statusLabel.setText(s); repaint(); } }); } }; try { LinkedList<String> options = null; String testPlan = GuiPackage.getInstance().getTestPlanFile(); if (testPlan != null) { options = new LinkedList<>(); options.add("-t"); options.add(testPlan); } manager.applyChanges(statusChanged, true, options); ActionRouter.getInstance().actionPerformed(new ActionEvent(this, 0, ActionNames.EXIT));
} catch (DownloadException ex) {
undera/jmeter-plugins-manager
src/test/java/org/jmeterplugins/repository/PluginManagerTest.java
// Path: src/main/java/org/jmeterplugins/repository/exception/DownloadException.java // public class DownloadException extends RuntimeException { // public DownloadException() { // } // // public DownloadException(String message) { // super(message); // } // // public DownloadException(String message, Throwable cause) { // super(message, cause); // } // }
import kg.apc.emulators.TestJMeterUtils; import net.sf.json.JSONObject; import net.sf.json.JsonConfig; import org.apache.jmeter.engine.JMeterEngine; import org.apache.jmeter.util.JMeterUtils; import org.jmeterplugins.repository.exception.DownloadException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.io.File; import java.io.IOException; import java.lang.reflect.Field; import java.net.URL; import static org.junit.Assert.*;
String addr = JMeterUtils.getPropDefault("jpgc.repo.address", "https://jmeter-plugins.org/repo/"); try { JMeterUtils.setProperty("jpgc.repo.address", "http://httpstat.us/500"); Plugin p = Plugin.fromJSON(JSONObject.fromObject(str, new JsonConfig())); PluginManager manager = new PluginManager(); manager.allPlugins.put(p, true); // need to install p.setCandidateVersion("9999"); try { manager.applyChanges(new GenericCallback<String>() { @Override public void notify(String progress) { } }, true, null); fail(); } catch (IllegalArgumentException ex) { assertTrue(ex.getMessage().contains("Version 9999 not found for plugin")); } manager.allPlugins.put(p, true); // need to install p.setCandidateVersion("0.2"); try { manager.applyChanges(new GenericCallback<String>() { @Override public void notify(String progress) { } }, true, null); fail();
// Path: src/main/java/org/jmeterplugins/repository/exception/DownloadException.java // public class DownloadException extends RuntimeException { // public DownloadException() { // } // // public DownloadException(String message) { // super(message); // } // // public DownloadException(String message, Throwable cause) { // super(message, cause); // } // } // Path: src/test/java/org/jmeterplugins/repository/PluginManagerTest.java import kg.apc.emulators.TestJMeterUtils; import net.sf.json.JSONObject; import net.sf.json.JsonConfig; import org.apache.jmeter.engine.JMeterEngine; import org.apache.jmeter.util.JMeterUtils; import org.jmeterplugins.repository.exception.DownloadException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.io.File; import java.io.IOException; import java.lang.reflect.Field; import java.net.URL; import static org.junit.Assert.*; String addr = JMeterUtils.getPropDefault("jpgc.repo.address", "https://jmeter-plugins.org/repo/"); try { JMeterUtils.setProperty("jpgc.repo.address", "http://httpstat.us/500"); Plugin p = Plugin.fromJSON(JSONObject.fromObject(str, new JsonConfig())); PluginManager manager = new PluginManager(); manager.allPlugins.put(p, true); // need to install p.setCandidateVersion("9999"); try { manager.applyChanges(new GenericCallback<String>() { @Override public void notify(String progress) { } }, true, null); fail(); } catch (IllegalArgumentException ex) { assertTrue(ex.getMessage().contains("Version 9999 not found for plugin")); } manager.allPlugins.put(p, true); // need to install p.setCandidateVersion("0.2"); try { manager.applyChanges(new GenericCallback<String>() { @Override public void notify(String progress) { } }, true, null); fail();
} catch (DownloadException ex) {
undera/jmeter-plugins-manager
src/main/java/org/jmeterplugins/repository/http/StatsReporter.java
// Path: src/main/java/org/jmeterplugins/repository/JARSource.java // abstract public class JARSource implements Cloneable { // public abstract JSON getRepo() throws IOException; // // public abstract void reportStats(String[] usageStats) throws IOException; // // public abstract void setTimeout(int timeout); // // public abstract DownloadResult getJAR(String id, String location, GenericCallback<String> statusChanged) throws IOException; // // public class DownloadResult { // private final String tmpFile; // private final String filename; // // public DownloadResult(String tmpFile, String filename) { // this.tmpFile = tmpFile; // this.filename = filename; // } // // public String getTmpFile() { // return tmpFile; // } // // public String getFilename() { // return filename; // } // } // // @Override // public Object clone() throws CloneNotSupportedException { // return super.clone(); // } // }
import org.jmeterplugins.repository.JARSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException;
package org.jmeterplugins.repository.http; public class StatsReporter extends Thread { private static final Logger log = LoggerFactory.getLogger(StatsReporter.class);
// Path: src/main/java/org/jmeterplugins/repository/JARSource.java // abstract public class JARSource implements Cloneable { // public abstract JSON getRepo() throws IOException; // // public abstract void reportStats(String[] usageStats) throws IOException; // // public abstract void setTimeout(int timeout); // // public abstract DownloadResult getJAR(String id, String location, GenericCallback<String> statusChanged) throws IOException; // // public class DownloadResult { // private final String tmpFile; // private final String filename; // // public DownloadResult(String tmpFile, String filename) { // this.tmpFile = tmpFile; // this.filename = filename; // } // // public String getTmpFile() { // return tmpFile; // } // // public String getFilename() { // return filename; // } // } // // @Override // public Object clone() throws CloneNotSupportedException { // return super.clone(); // } // } // Path: src/main/java/org/jmeterplugins/repository/http/StatsReporter.java import org.jmeterplugins.repository.JARSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; package org.jmeterplugins.repository.http; public class StatsReporter extends Thread { private static final Logger log = LoggerFactory.getLogger(StatsReporter.class);
private final JARSource jarSource;
undera/jmeter-plugins-manager
src/main/java/org/jmeterplugins/repository/PluginManagerMenuItem.java
// Path: src/main/java/org/jmeterplugins/repository/logging/LoggingHooker.java // public class LoggingHooker { // private static final org.slf4j.Logger log = LoggerFactory.getLogger(LoggingHooker.class); // private final PluginManager mgr; // // public LoggingHooker(PluginManager mgr) { // this.mgr = mgr; // } // // public void hook() { // try { // if (!isJMeter32orLater()) { // Logger logger = LoggerFactory.getLogger("jmeter.save.SaveService"); // // FIXME: what to do? logger.setLogTargets(new LogTarget[]{new LoggerPanelWrapping(mgr)}); // } else { // Class<?> cls = Class.forName("org.jmeterplugins.repository.logging.LoggerAppender"); // Constructor<?> constructor = cls.getConstructor(String.class, PluginManager.class); // constructor.newInstance("pmgr-logging-appender", mgr); // } // } catch (Throwable ex) { // log.error("Cannot hook into logging", ex); // } // } // // public static boolean isJMeter32orLater() { // try { // Class<?> cls = LoggingHooker.class.getClassLoader().loadClass("org.apache.jmeter.gui.logging.GuiLogEventBus"); // if (cls != null) { // return true; // } // } catch (ClassNotFoundException ex) { // log.debug("Class 'org.apache.jmeter.gui.logging.GuiLogEventBus' not found", ex); // } catch (Throwable ex) { // log.warn("Fail to detect JMeter version", ex); // } // return false; // } // } // // Path: src/main/java/org/jmeterplugins/repository/util/ComponentFinder.java // public class ComponentFinder<T extends Component> { // private static final Logger log = LoggerFactory.getLogger(ComponentFinder.class); // // private final Class<T> search; // // public ComponentFinder(Class<T> cls) { // search = cls; // } // // public T findComponentIn(Container container) { // log.debug("Searching in " + container); // for (Component a : container.getComponents()) { // if (search.isAssignableFrom(a.getClass())) { // log.debug("Found " + a); // return (T) a; // } // // if (a instanceof Container) { // T res = findComponentIn((Container) a); // if (res != null) { // return res; // } // } // } // // return null; // } // }
import org.apache.jmeter.gui.GuiPackage; import org.apache.jmeter.gui.MainFrame; import org.apache.jmeter.gui.util.JMeterToolBar; import org.jmeterplugins.repository.logging.LoggingHooker; import org.jmeterplugins.repository.util.ComponentFinder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Arrays;
package org.jmeterplugins.repository; public class PluginManagerMenuItem extends JMenuItem implements ActionListener { private static final long serialVersionUID = -8708638472918746046L; private static final Logger log = LoggerFactory.getLogger(PluginManagerMenuItem.class); private static PluginManagerDialog dialog; private final PluginManager mgr; public PluginManagerMenuItem() { super("Plugins Manager"); addActionListener(this); mgr = new PluginManager(); // don't delay startup for longer that 1 second
// Path: src/main/java/org/jmeterplugins/repository/logging/LoggingHooker.java // public class LoggingHooker { // private static final org.slf4j.Logger log = LoggerFactory.getLogger(LoggingHooker.class); // private final PluginManager mgr; // // public LoggingHooker(PluginManager mgr) { // this.mgr = mgr; // } // // public void hook() { // try { // if (!isJMeter32orLater()) { // Logger logger = LoggerFactory.getLogger("jmeter.save.SaveService"); // // FIXME: what to do? logger.setLogTargets(new LogTarget[]{new LoggerPanelWrapping(mgr)}); // } else { // Class<?> cls = Class.forName("org.jmeterplugins.repository.logging.LoggerAppender"); // Constructor<?> constructor = cls.getConstructor(String.class, PluginManager.class); // constructor.newInstance("pmgr-logging-appender", mgr); // } // } catch (Throwable ex) { // log.error("Cannot hook into logging", ex); // } // } // // public static boolean isJMeter32orLater() { // try { // Class<?> cls = LoggingHooker.class.getClassLoader().loadClass("org.apache.jmeter.gui.logging.GuiLogEventBus"); // if (cls != null) { // return true; // } // } catch (ClassNotFoundException ex) { // log.debug("Class 'org.apache.jmeter.gui.logging.GuiLogEventBus' not found", ex); // } catch (Throwable ex) { // log.warn("Fail to detect JMeter version", ex); // } // return false; // } // } // // Path: src/main/java/org/jmeterplugins/repository/util/ComponentFinder.java // public class ComponentFinder<T extends Component> { // private static final Logger log = LoggerFactory.getLogger(ComponentFinder.class); // // private final Class<T> search; // // public ComponentFinder(Class<T> cls) { // search = cls; // } // // public T findComponentIn(Container container) { // log.debug("Searching in " + container); // for (Component a : container.getComponents()) { // if (search.isAssignableFrom(a.getClass())) { // log.debug("Found " + a); // return (T) a; // } // // if (a instanceof Container) { // T res = findComponentIn((Container) a); // if (res != null) { // return res; // } // } // } // // return null; // } // } // Path: src/main/java/org/jmeterplugins/repository/PluginManagerMenuItem.java import org.apache.jmeter.gui.GuiPackage; import org.apache.jmeter.gui.MainFrame; import org.apache.jmeter.gui.util.JMeterToolBar; import org.jmeterplugins.repository.logging.LoggingHooker; import org.jmeterplugins.repository.util.ComponentFinder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Arrays; package org.jmeterplugins.repository; public class PluginManagerMenuItem extends JMenuItem implements ActionListener { private static final long serialVersionUID = -8708638472918746046L; private static final Logger log = LoggerFactory.getLogger(PluginManagerMenuItem.class); private static PluginManagerDialog dialog; private final PluginManager mgr; public PluginManagerMenuItem() { super("Plugins Manager"); addActionListener(this); mgr = new PluginManager(); // don't delay startup for longer that 1 second
LoggingHooker hooker = new LoggingHooker(mgr);
undera/jmeter-plugins-manager
src/main/java/org/jmeterplugins/repository/PluginManagerMenuItem.java
// Path: src/main/java/org/jmeterplugins/repository/logging/LoggingHooker.java // public class LoggingHooker { // private static final org.slf4j.Logger log = LoggerFactory.getLogger(LoggingHooker.class); // private final PluginManager mgr; // // public LoggingHooker(PluginManager mgr) { // this.mgr = mgr; // } // // public void hook() { // try { // if (!isJMeter32orLater()) { // Logger logger = LoggerFactory.getLogger("jmeter.save.SaveService"); // // FIXME: what to do? logger.setLogTargets(new LogTarget[]{new LoggerPanelWrapping(mgr)}); // } else { // Class<?> cls = Class.forName("org.jmeterplugins.repository.logging.LoggerAppender"); // Constructor<?> constructor = cls.getConstructor(String.class, PluginManager.class); // constructor.newInstance("pmgr-logging-appender", mgr); // } // } catch (Throwable ex) { // log.error("Cannot hook into logging", ex); // } // } // // public static boolean isJMeter32orLater() { // try { // Class<?> cls = LoggingHooker.class.getClassLoader().loadClass("org.apache.jmeter.gui.logging.GuiLogEventBus"); // if (cls != null) { // return true; // } // } catch (ClassNotFoundException ex) { // log.debug("Class 'org.apache.jmeter.gui.logging.GuiLogEventBus' not found", ex); // } catch (Throwable ex) { // log.warn("Fail to detect JMeter version", ex); // } // return false; // } // } // // Path: src/main/java/org/jmeterplugins/repository/util/ComponentFinder.java // public class ComponentFinder<T extends Component> { // private static final Logger log = LoggerFactory.getLogger(ComponentFinder.class); // // private final Class<T> search; // // public ComponentFinder(Class<T> cls) { // search = cls; // } // // public T findComponentIn(Container container) { // log.debug("Searching in " + container); // for (Component a : container.getComponents()) { // if (search.isAssignableFrom(a.getClass())) { // log.debug("Found " + a); // return (T) a; // } // // if (a instanceof Container) { // T res = findComponentIn((Container) a); // if (res != null) { // return res; // } // } // } // // return null; // } // }
import org.apache.jmeter.gui.GuiPackage; import org.apache.jmeter.gui.MainFrame; import org.apache.jmeter.gui.util.JMeterToolBar; import org.jmeterplugins.repository.logging.LoggingHooker; import org.jmeterplugins.repository.util.ComponentFinder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Arrays;
new Thread("repo-downloader-thread") { @Override public void run() { try { mgr.load(); } catch (Throwable e) { log.warn("Failed to load plugin updates info", e); } if (mgr.hasAnyUpdates()) { setText("Plugins Manager (has upgrades)"); log.info("Plugins Manager has upgrades: " + Arrays.toString(mgr.getUpgradablePlugins().toArray())); } boolean hasAnyUpdates = mgr.hasAnyUpdates(); setIcon(PluginIcon.getPluginsIcon(hasAnyUpdates)); toolbarButton.setIcon(PluginIcon.getIcon22Px(hasAnyUpdates)); toolbarButton.setToolTipText(hasAnyUpdates ? "Plugins Manager (has upgrades)" : "Plugins Manager" ); } }.start(); } private void addToolbarIcon(final Component toolbarButton) { GuiPackage instance = GuiPackage.getInstance(); if (instance != null) { final MainFrame mf = instance.getMainFrame();
// Path: src/main/java/org/jmeterplugins/repository/logging/LoggingHooker.java // public class LoggingHooker { // private static final org.slf4j.Logger log = LoggerFactory.getLogger(LoggingHooker.class); // private final PluginManager mgr; // // public LoggingHooker(PluginManager mgr) { // this.mgr = mgr; // } // // public void hook() { // try { // if (!isJMeter32orLater()) { // Logger logger = LoggerFactory.getLogger("jmeter.save.SaveService"); // // FIXME: what to do? logger.setLogTargets(new LogTarget[]{new LoggerPanelWrapping(mgr)}); // } else { // Class<?> cls = Class.forName("org.jmeterplugins.repository.logging.LoggerAppender"); // Constructor<?> constructor = cls.getConstructor(String.class, PluginManager.class); // constructor.newInstance("pmgr-logging-appender", mgr); // } // } catch (Throwable ex) { // log.error("Cannot hook into logging", ex); // } // } // // public static boolean isJMeter32orLater() { // try { // Class<?> cls = LoggingHooker.class.getClassLoader().loadClass("org.apache.jmeter.gui.logging.GuiLogEventBus"); // if (cls != null) { // return true; // } // } catch (ClassNotFoundException ex) { // log.debug("Class 'org.apache.jmeter.gui.logging.GuiLogEventBus' not found", ex); // } catch (Throwable ex) { // log.warn("Fail to detect JMeter version", ex); // } // return false; // } // } // // Path: src/main/java/org/jmeterplugins/repository/util/ComponentFinder.java // public class ComponentFinder<T extends Component> { // private static final Logger log = LoggerFactory.getLogger(ComponentFinder.class); // // private final Class<T> search; // // public ComponentFinder(Class<T> cls) { // search = cls; // } // // public T findComponentIn(Container container) { // log.debug("Searching in " + container); // for (Component a : container.getComponents()) { // if (search.isAssignableFrom(a.getClass())) { // log.debug("Found " + a); // return (T) a; // } // // if (a instanceof Container) { // T res = findComponentIn((Container) a); // if (res != null) { // return res; // } // } // } // // return null; // } // } // Path: src/main/java/org/jmeterplugins/repository/PluginManagerMenuItem.java import org.apache.jmeter.gui.GuiPackage; import org.apache.jmeter.gui.MainFrame; import org.apache.jmeter.gui.util.JMeterToolBar; import org.jmeterplugins.repository.logging.LoggingHooker; import org.jmeterplugins.repository.util.ComponentFinder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Arrays; new Thread("repo-downloader-thread") { @Override public void run() { try { mgr.load(); } catch (Throwable e) { log.warn("Failed to load plugin updates info", e); } if (mgr.hasAnyUpdates()) { setText("Plugins Manager (has upgrades)"); log.info("Plugins Manager has upgrades: " + Arrays.toString(mgr.getUpgradablePlugins().toArray())); } boolean hasAnyUpdates = mgr.hasAnyUpdates(); setIcon(PluginIcon.getPluginsIcon(hasAnyUpdates)); toolbarButton.setIcon(PluginIcon.getIcon22Px(hasAnyUpdates)); toolbarButton.setToolTipText(hasAnyUpdates ? "Plugins Manager (has upgrades)" : "Plugins Manager" ); } }.start(); } private void addToolbarIcon(final Component toolbarButton) { GuiPackage instance = GuiPackage.getInstance(); if (instance != null) { final MainFrame mf = instance.getMainFrame();
final ComponentFinder<JMeterToolBar> finder = new ComponentFinder<>(JMeterToolBar.class);
undera/jmeter-plugins-manager
src/main/java/org/apache/jorphan/logging/Slf4jLogkitLogger.java
// Path: src/main/java/org/apache/log/Priority.java // @Deprecated // public final class Priority // implements Serializable // { // private static final long serialVersionUID = 1L; // // /** // * Developer orientated messages, usually used during development of product. // */ // public static final Priority DEBUG = new Priority( "DEBUG", 5 ); // // /** // * Useful information messages such as state changes, client connection, user login etc. // */ // public static final Priority INFO = new Priority( "INFO", 10 ); // // /** // * A problem or conflict has occurred but it may be recoverable, then // * again it could be the start of the system failing. // */ // public static final Priority WARN = new Priority( "WARN", 15 ); // // /** // * A problem has occurred but it is not fatal. The system will still function. // */ // public static final Priority ERROR = new Priority( "ERROR", 20 ); // // /** // * Something caused whole system to fail. This indicates that an administrator // * should restart the system and try to fix the problem that caused the failure. // */ // public static final Priority FATAL_ERROR = new Priority( "FATAL_ERROR", 25 ); // // /** // * Do not log anything. // */ // public static final Priority NONE = new Priority( "NONE", Integer.MAX_VALUE ); // // private final String m_name; // private final int m_priority; // // /** // * Retrieve a Priority object for the name parameter. // * // * @param priority the priority name // * @return the Priority for name // */ // public static Priority getPriorityForName( final String priority ) // { // if( Priority.DEBUG.getName().equals( priority ) ) // { // return Priority.DEBUG; // } // else if( Priority.INFO.getName().equals( priority ) ) // { // return Priority.INFO; // } // else if( Priority.WARN.getName().equals( priority ) ) // { // return Priority.WARN; // } // else if( Priority.ERROR.getName().equals( priority ) ) // { // return Priority.ERROR; // } // else if( Priority.FATAL_ERROR.getName().equals( priority ) ) // { // return Priority.FATAL_ERROR; // } // else if( Priority.NONE.getName().equals( priority ) ) // { // return Priority.NONE; // } // else // { // return Priority.DEBUG; // } // } // // /** // * Private Constructor to block instantiation outside class. // * // * @param name the string name of priority // * @param priority the numerical code of priority // */ // private Priority( final String name, final int priority ) // { // if( null == name ) // { // throw new NullPointerException( "name" ); // } // // m_name = name; // m_priority = priority; // } // // /** // * Overridden string to display Priority in human readable form. // * // * @return the string describing priority // */ // @Override // public String toString() // { // return "Priority[" + getName() + "/" + getValue() + "]"; // } // // /** // * Get numerical value associated with priority. // * // * @return the numerical value // */ // public int getValue() // { // return m_priority; // } // // /** // * Get name of priority. // * // * @return the priorities name // */ // public String getName() // { // return m_name; // } // // /** // * Test whether this priority is greater than other priority. // * // * @param other the other Priority // * @return TRUE if the priority is greater else FALSE // */ // public boolean isGreater( final Priority other ) // { // return m_priority > other.getValue(); // } // // /** // * Test whether this priority is lower than other priority. // * // * @param other the other Priority // * @return TRUE if the priority is lower else FALSE // */ // public boolean isLower( final Priority other ) // { // return m_priority < other.getValue(); // } // // /** // * Test whether this priority is lower or equal to other priority. // * // * @param other the other Priority // * @return TRUE if the priority is lower or equal else FALSE // */ // public boolean isLowerOrEqual( final Priority other ) // { // return m_priority <= other.getValue(); // } // // /** // * Helper method that replaces deserialized object with correct singleton. // * // * @return the singleton version of object // */ // private Object readResolve() // { // return getPriorityForName( m_name ); // } // }
import org.apache.log.Priority; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
public boolean isErrorEnabled() { return slf4jLogger.isErrorEnabled(); } @Override public void error(String message, Throwable throwable) { slf4jLogger.error(message, throwable); } @Override public void error(String message) { slf4jLogger.error(message); } @Override public boolean isFatalErrorEnabled() { return slf4jLogger.isErrorEnabled(); } @Override public void fatalError(String message, Throwable throwable) { slf4jLogger.error(message, throwable); } @Override public void fatalError(String message) { slf4jLogger.error(message); } @Override
// Path: src/main/java/org/apache/log/Priority.java // @Deprecated // public final class Priority // implements Serializable // { // private static final long serialVersionUID = 1L; // // /** // * Developer orientated messages, usually used during development of product. // */ // public static final Priority DEBUG = new Priority( "DEBUG", 5 ); // // /** // * Useful information messages such as state changes, client connection, user login etc. // */ // public static final Priority INFO = new Priority( "INFO", 10 ); // // /** // * A problem or conflict has occurred but it may be recoverable, then // * again it could be the start of the system failing. // */ // public static final Priority WARN = new Priority( "WARN", 15 ); // // /** // * A problem has occurred but it is not fatal. The system will still function. // */ // public static final Priority ERROR = new Priority( "ERROR", 20 ); // // /** // * Something caused whole system to fail. This indicates that an administrator // * should restart the system and try to fix the problem that caused the failure. // */ // public static final Priority FATAL_ERROR = new Priority( "FATAL_ERROR", 25 ); // // /** // * Do not log anything. // */ // public static final Priority NONE = new Priority( "NONE", Integer.MAX_VALUE ); // // private final String m_name; // private final int m_priority; // // /** // * Retrieve a Priority object for the name parameter. // * // * @param priority the priority name // * @return the Priority for name // */ // public static Priority getPriorityForName( final String priority ) // { // if( Priority.DEBUG.getName().equals( priority ) ) // { // return Priority.DEBUG; // } // else if( Priority.INFO.getName().equals( priority ) ) // { // return Priority.INFO; // } // else if( Priority.WARN.getName().equals( priority ) ) // { // return Priority.WARN; // } // else if( Priority.ERROR.getName().equals( priority ) ) // { // return Priority.ERROR; // } // else if( Priority.FATAL_ERROR.getName().equals( priority ) ) // { // return Priority.FATAL_ERROR; // } // else if( Priority.NONE.getName().equals( priority ) ) // { // return Priority.NONE; // } // else // { // return Priority.DEBUG; // } // } // // /** // * Private Constructor to block instantiation outside class. // * // * @param name the string name of priority // * @param priority the numerical code of priority // */ // private Priority( final String name, final int priority ) // { // if( null == name ) // { // throw new NullPointerException( "name" ); // } // // m_name = name; // m_priority = priority; // } // // /** // * Overridden string to display Priority in human readable form. // * // * @return the string describing priority // */ // @Override // public String toString() // { // return "Priority[" + getName() + "/" + getValue() + "]"; // } // // /** // * Get numerical value associated with priority. // * // * @return the numerical value // */ // public int getValue() // { // return m_priority; // } // // /** // * Get name of priority. // * // * @return the priorities name // */ // public String getName() // { // return m_name; // } // // /** // * Test whether this priority is greater than other priority. // * // * @param other the other Priority // * @return TRUE if the priority is greater else FALSE // */ // public boolean isGreater( final Priority other ) // { // return m_priority > other.getValue(); // } // // /** // * Test whether this priority is lower than other priority. // * // * @param other the other Priority // * @return TRUE if the priority is lower else FALSE // */ // public boolean isLower( final Priority other ) // { // return m_priority < other.getValue(); // } // // /** // * Test whether this priority is lower or equal to other priority. // * // * @param other the other Priority // * @return TRUE if the priority is lower or equal else FALSE // */ // public boolean isLowerOrEqual( final Priority other ) // { // return m_priority <= other.getValue(); // } // // /** // * Helper method that replaces deserialized object with correct singleton. // * // * @return the singleton version of object // */ // private Object readResolve() // { // return getPriorityForName( m_name ); // } // } // Path: src/main/java/org/apache/jorphan/logging/Slf4jLogkitLogger.java import org.apache.log.Priority; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public boolean isErrorEnabled() { return slf4jLogger.isErrorEnabled(); } @Override public void error(String message, Throwable throwable) { slf4jLogger.error(message, throwable); } @Override public void error(String message) { slf4jLogger.error(message); } @Override public boolean isFatalErrorEnabled() { return slf4jLogger.isErrorEnabled(); } @Override public void fatalError(String message, Throwable throwable) { slf4jLogger.error(message, throwable); } @Override public void fatalError(String message) { slf4jLogger.error(message); } @Override
public boolean isPriorityEnabled(Priority priority) {
undera/jmeter-plugins-manager
src/main/java/org/jmeterplugins/repository/PluginsList.java
// Path: src/main/java/org/jmeterplugins/repository/util/PlaceholderTextField.java // public class PlaceholderTextField extends JTextField { // // private String placeholder; // // @Override // protected void paintComponent(final Graphics pG) { // super.paintComponent(pG); // // if (placeholder.length() == 0 || getText().length() > 0) { // return; // } // // final Graphics2D g = (Graphics2D) pG; // g.setRenderingHint( // RenderingHints.KEY_ANTIALIASING, // RenderingHints.VALUE_ANTIALIAS_ON); // g.setColor(getDisabledTextColor()); // g.drawString(placeholder, getInsets().left, pG.getFontMetrics() // .getMaxAscent() + getInsets().top); // } // // public void setPlaceholder(final String s) { // placeholder = s; // } // // public String getPlaceholder() { // return placeholder; // } // }
import org.apache.commons.lang3.StringUtils; import org.jmeterplugins.repository.util.PlaceholderTextField; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.imageio.ImageIO; import javax.swing.*; import javax.swing.event.ChangeListener; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Dictionary; import java.util.Hashtable; import java.util.List; import java.util.Map; import java.util.Set;
package org.jmeterplugins.repository; public class PluginsList extends JPanel implements ListSelectionListener, HyperlinkListener { private static final long serialVersionUID = 295116233618658217L; private static final Logger log = LoggerFactory.getLogger(PluginsList.class); private final JTextPane description = new JTextPane();
// Path: src/main/java/org/jmeterplugins/repository/util/PlaceholderTextField.java // public class PlaceholderTextField extends JTextField { // // private String placeholder; // // @Override // protected void paintComponent(final Graphics pG) { // super.paintComponent(pG); // // if (placeholder.length() == 0 || getText().length() > 0) { // return; // } // // final Graphics2D g = (Graphics2D) pG; // g.setRenderingHint( // RenderingHints.KEY_ANTIALIASING, // RenderingHints.VALUE_ANTIALIAS_ON); // g.setColor(getDisabledTextColor()); // g.drawString(placeholder, getInsets().left, pG.getFontMetrics() // .getMaxAscent() + getInsets().top); // } // // public void setPlaceholder(final String s) { // placeholder = s; // } // // public String getPlaceholder() { // return placeholder; // } // } // Path: src/main/java/org/jmeterplugins/repository/PluginsList.java import org.apache.commons.lang3.StringUtils; import org.jmeterplugins.repository.util.PlaceholderTextField; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.imageio.ImageIO; import javax.swing.*; import javax.swing.event.ChangeListener; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Dictionary; import java.util.Hashtable; import java.util.List; import java.util.Map; import java.util.Set; package org.jmeterplugins.repository; public class PluginsList extends JPanel implements ListSelectionListener, HyperlinkListener { private static final long serialVersionUID = 295116233618658217L; private static final Logger log = LoggerFactory.getLogger(PluginsList.class); private final JTextPane description = new JTextPane();
protected final PlaceholderTextField searchField = new PlaceholderTextField();
undera/jmeter-plugins-manager
src/main/java/org/jmeterplugins/repository/PluginManagerCMD.java
// Path: src/main/java/org/jmeterplugins/repository/plugins/PluginSuggester.java // public class PluginSuggester { // private static final Logger log = LoggerFactory.getLogger(PluginSuggester.class); // // protected TestPlanAnalyzer analyzer; // protected String testPlan; // private final PluginManager pmgr; // // public PluginSuggester(PluginManager pmgr) { // this.pmgr = pmgr; // analyzer = new TestPlanAnalyzer(); // } // // public void checkAndSuggest(String msg) { // Set<Plugin> pluginsToInstall = findPluginsToInstall(msg); // if (pluginsToInstall.size() > 0) { // // pmgr.togglePlugins(pluginsToInstall, true); // // Frame parent = (GuiPackage.getInstance() != null) ? GuiPackage.getInstance().getMainFrame() : null; // SuggestDialog dialog = new SuggestDialog(parent, pmgr, pluginsToInstall, testPlan); // dialog.setVisible(true); // dialog.setAlwaysOnTop(true); // } // } // // protected Set<Plugin> findPluginsToInstall(String msg) { // if (msg != null && msg.contains("Loading file")) { // testPlan = msg.substring(msg.indexOf(": ") + 2); // if (!"null".equals(testPlan)) { // return analyzeTestPlan(testPlan); // } // } // return Collections.emptySet(); // } // // public Set<Plugin> analyzeTestPlan(String path) { // Set<String> nonExistentClasses = analyzer.analyze(path); // if (nonExistentClasses.size() > 0) { // return findPluginsFromClasses(nonExistentClasses); // } // return Collections.emptySet(); // } // // // protected Set<Plugin> findPluginsFromClasses(Set<String> nonExistentClasses) { // try { // pmgr.load(); // } catch (Throwable throwable) { // log.warn("Cannot load plugins repo: ", throwable); // return Collections.emptySet(); // } // final Set<Plugin> availablePlugins = pmgr.getAvailablePlugins(); // final Set<Plugin> pluginsToInstall = new HashSet<>(); // for (Plugin plugin : availablePlugins) { // if (plugin.containsComponentClasses(nonExistentClasses)) { // pluginsToInstall.add(plugin); // } // } // // if (pluginsToInstall.isEmpty()) { // log.warn("Plugins Manager were unable to find plugins to satisfy Test Plan requirements. " + // "To help improve, please report following list to https://jmeter-plugins.org/support/: " + // Arrays.toString(nonExistentClasses.toArray())); // } // // return pluginsToInstall; // } // // public TestPlanAnalyzer getAnalyzer() { // return analyzer; // } // // public void setAnalyzer(TestPlanAnalyzer analyzer) { // this.analyzer = analyzer; // } // // } // // Path: src/main/java/org/jmeterplugins/repository/logging/LoggingHooker.java // public static boolean isJMeter32orLater() { // try { // Class<?> cls = LoggingHooker.class.getClassLoader().loadClass("org.apache.jmeter.gui.logging.GuiLogEventBus"); // if (cls != null) { // return true; // } // } catch (ClassNotFoundException ex) { // log.debug("Class 'org.apache.jmeter.gui.logging.GuiLogEventBus' not found", ex); // } catch (Throwable ex) { // log.warn("Fail to detect JMeter version", ex); // } // return false; // }
import kg.apc.cmdtools.AbstractCMDTool; import org.apache.jmeter.util.JMeterUtils; import org.jmeterplugins.repository.plugins.PluginSuggester; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.PrintStream; import java.io.UnsupportedEncodingException; import java.lang.reflect.Constructor; import java.net.URLDecoder; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.ListIterator; import java.util.Map; import java.util.Set; import static org.jmeterplugins.repository.logging.LoggingHooker.isJMeter32orLater;
package org.jmeterplugins.repository; public class PluginManagerCMD extends AbstractCMDTool implements GenericCallback<String> { private static final Logger log = LoggerFactory.getLogger(PluginManagerCMD.class); public PluginManagerCMD() { setJMeterHome();
// Path: src/main/java/org/jmeterplugins/repository/plugins/PluginSuggester.java // public class PluginSuggester { // private static final Logger log = LoggerFactory.getLogger(PluginSuggester.class); // // protected TestPlanAnalyzer analyzer; // protected String testPlan; // private final PluginManager pmgr; // // public PluginSuggester(PluginManager pmgr) { // this.pmgr = pmgr; // analyzer = new TestPlanAnalyzer(); // } // // public void checkAndSuggest(String msg) { // Set<Plugin> pluginsToInstall = findPluginsToInstall(msg); // if (pluginsToInstall.size() > 0) { // // pmgr.togglePlugins(pluginsToInstall, true); // // Frame parent = (GuiPackage.getInstance() != null) ? GuiPackage.getInstance().getMainFrame() : null; // SuggestDialog dialog = new SuggestDialog(parent, pmgr, pluginsToInstall, testPlan); // dialog.setVisible(true); // dialog.setAlwaysOnTop(true); // } // } // // protected Set<Plugin> findPluginsToInstall(String msg) { // if (msg != null && msg.contains("Loading file")) { // testPlan = msg.substring(msg.indexOf(": ") + 2); // if (!"null".equals(testPlan)) { // return analyzeTestPlan(testPlan); // } // } // return Collections.emptySet(); // } // // public Set<Plugin> analyzeTestPlan(String path) { // Set<String> nonExistentClasses = analyzer.analyze(path); // if (nonExistentClasses.size() > 0) { // return findPluginsFromClasses(nonExistentClasses); // } // return Collections.emptySet(); // } // // // protected Set<Plugin> findPluginsFromClasses(Set<String> nonExistentClasses) { // try { // pmgr.load(); // } catch (Throwable throwable) { // log.warn("Cannot load plugins repo: ", throwable); // return Collections.emptySet(); // } // final Set<Plugin> availablePlugins = pmgr.getAvailablePlugins(); // final Set<Plugin> pluginsToInstall = new HashSet<>(); // for (Plugin plugin : availablePlugins) { // if (plugin.containsComponentClasses(nonExistentClasses)) { // pluginsToInstall.add(plugin); // } // } // // if (pluginsToInstall.isEmpty()) { // log.warn("Plugins Manager were unable to find plugins to satisfy Test Plan requirements. " + // "To help improve, please report following list to https://jmeter-plugins.org/support/: " + // Arrays.toString(nonExistentClasses.toArray())); // } // // return pluginsToInstall; // } // // public TestPlanAnalyzer getAnalyzer() { // return analyzer; // } // // public void setAnalyzer(TestPlanAnalyzer analyzer) { // this.analyzer = analyzer; // } // // } // // Path: src/main/java/org/jmeterplugins/repository/logging/LoggingHooker.java // public static boolean isJMeter32orLater() { // try { // Class<?> cls = LoggingHooker.class.getClassLoader().loadClass("org.apache.jmeter.gui.logging.GuiLogEventBus"); // if (cls != null) { // return true; // } // } catch (ClassNotFoundException ex) { // log.debug("Class 'org.apache.jmeter.gui.logging.GuiLogEventBus' not found", ex); // } catch (Throwable ex) { // log.warn("Fail to detect JMeter version", ex); // } // return false; // } // Path: src/main/java/org/jmeterplugins/repository/PluginManagerCMD.java import kg.apc.cmdtools.AbstractCMDTool; import org.apache.jmeter.util.JMeterUtils; import org.jmeterplugins.repository.plugins.PluginSuggester; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.PrintStream; import java.io.UnsupportedEncodingException; import java.lang.reflect.Constructor; import java.net.URLDecoder; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.ListIterator; import java.util.Map; import java.util.Set; import static org.jmeterplugins.repository.logging.LoggingHooker.isJMeter32orLater; package org.jmeterplugins.repository; public class PluginManagerCMD extends AbstractCMDTool implements GenericCallback<String> { private static final Logger log = LoggerFactory.getLogger(PluginManagerCMD.class); public PluginManagerCMD() { setJMeterHome();
if (isJMeter32orLater()) {
undera/jmeter-plugins-manager
src/main/java/org/jmeterplugins/repository/PluginManagerCMD.java
// Path: src/main/java/org/jmeterplugins/repository/plugins/PluginSuggester.java // public class PluginSuggester { // private static final Logger log = LoggerFactory.getLogger(PluginSuggester.class); // // protected TestPlanAnalyzer analyzer; // protected String testPlan; // private final PluginManager pmgr; // // public PluginSuggester(PluginManager pmgr) { // this.pmgr = pmgr; // analyzer = new TestPlanAnalyzer(); // } // // public void checkAndSuggest(String msg) { // Set<Plugin> pluginsToInstall = findPluginsToInstall(msg); // if (pluginsToInstall.size() > 0) { // // pmgr.togglePlugins(pluginsToInstall, true); // // Frame parent = (GuiPackage.getInstance() != null) ? GuiPackage.getInstance().getMainFrame() : null; // SuggestDialog dialog = new SuggestDialog(parent, pmgr, pluginsToInstall, testPlan); // dialog.setVisible(true); // dialog.setAlwaysOnTop(true); // } // } // // protected Set<Plugin> findPluginsToInstall(String msg) { // if (msg != null && msg.contains("Loading file")) { // testPlan = msg.substring(msg.indexOf(": ") + 2); // if (!"null".equals(testPlan)) { // return analyzeTestPlan(testPlan); // } // } // return Collections.emptySet(); // } // // public Set<Plugin> analyzeTestPlan(String path) { // Set<String> nonExistentClasses = analyzer.analyze(path); // if (nonExistentClasses.size() > 0) { // return findPluginsFromClasses(nonExistentClasses); // } // return Collections.emptySet(); // } // // // protected Set<Plugin> findPluginsFromClasses(Set<String> nonExistentClasses) { // try { // pmgr.load(); // } catch (Throwable throwable) { // log.warn("Cannot load plugins repo: ", throwable); // return Collections.emptySet(); // } // final Set<Plugin> availablePlugins = pmgr.getAvailablePlugins(); // final Set<Plugin> pluginsToInstall = new HashSet<>(); // for (Plugin plugin : availablePlugins) { // if (plugin.containsComponentClasses(nonExistentClasses)) { // pluginsToInstall.add(plugin); // } // } // // if (pluginsToInstall.isEmpty()) { // log.warn("Plugins Manager were unable to find plugins to satisfy Test Plan requirements. " + // "To help improve, please report following list to https://jmeter-plugins.org/support/: " + // Arrays.toString(nonExistentClasses.toArray())); // } // // return pluginsToInstall; // } // // public TestPlanAnalyzer getAnalyzer() { // return analyzer; // } // // public void setAnalyzer(TestPlanAnalyzer analyzer) { // this.analyzer = analyzer; // } // // } // // Path: src/main/java/org/jmeterplugins/repository/logging/LoggingHooker.java // public static boolean isJMeter32orLater() { // try { // Class<?> cls = LoggingHooker.class.getClassLoader().loadClass("org.apache.jmeter.gui.logging.GuiLogEventBus"); // if (cls != null) { // return true; // } // } catch (ClassNotFoundException ex) { // log.debug("Class 'org.apache.jmeter.gui.logging.GuiLogEventBus' not found", ex); // } catch (Throwable ex) { // log.warn("Fail to detect JMeter version", ex); // } // return false; // }
import kg.apc.cmdtools.AbstractCMDTool; import org.apache.jmeter.util.JMeterUtils; import org.jmeterplugins.repository.plugins.PluginSuggester; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.PrintStream; import java.io.UnsupportedEncodingException; import java.lang.reflect.Constructor; import java.net.URLDecoder; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.ListIterator; import java.util.Map; import java.util.Set; import static org.jmeterplugins.repository.logging.LoggingHooker.isJMeter32orLater;
System.out.println(PluginManager.getUpgradablePluginsAsString()); break; default: showHelp(System.out); throw new UnsupportedOperationException("Wrong command: " + command); } } catch (IllegalArgumentException e) { throw e; } catch (Throwable e) { throw new RuntimeException("Failed to perform cmdline operation: " + e.getMessage(), e); } return 0; } private PluginManager getPluginsManager(boolean isSendRepoStats) throws Throwable { PluginManager mgr = new PluginManager(); mgr.setSendRepoStats(isSendRepoStats); mgr.setTimeout(30000); // TODO: add property? mgr.load(); return mgr; } protected void installPluginsForJmx(ListIterator jmxFilesIterator) throws Throwable { if (!jmxFilesIterator.hasNext()) { throw new IllegalArgumentException("No jmx files specified"); } String files = jmxFilesIterator.next().toString(); PluginManager mgr = getPluginsManager(false);
// Path: src/main/java/org/jmeterplugins/repository/plugins/PluginSuggester.java // public class PluginSuggester { // private static final Logger log = LoggerFactory.getLogger(PluginSuggester.class); // // protected TestPlanAnalyzer analyzer; // protected String testPlan; // private final PluginManager pmgr; // // public PluginSuggester(PluginManager pmgr) { // this.pmgr = pmgr; // analyzer = new TestPlanAnalyzer(); // } // // public void checkAndSuggest(String msg) { // Set<Plugin> pluginsToInstall = findPluginsToInstall(msg); // if (pluginsToInstall.size() > 0) { // // pmgr.togglePlugins(pluginsToInstall, true); // // Frame parent = (GuiPackage.getInstance() != null) ? GuiPackage.getInstance().getMainFrame() : null; // SuggestDialog dialog = new SuggestDialog(parent, pmgr, pluginsToInstall, testPlan); // dialog.setVisible(true); // dialog.setAlwaysOnTop(true); // } // } // // protected Set<Plugin> findPluginsToInstall(String msg) { // if (msg != null && msg.contains("Loading file")) { // testPlan = msg.substring(msg.indexOf(": ") + 2); // if (!"null".equals(testPlan)) { // return analyzeTestPlan(testPlan); // } // } // return Collections.emptySet(); // } // // public Set<Plugin> analyzeTestPlan(String path) { // Set<String> nonExistentClasses = analyzer.analyze(path); // if (nonExistentClasses.size() > 0) { // return findPluginsFromClasses(nonExistentClasses); // } // return Collections.emptySet(); // } // // // protected Set<Plugin> findPluginsFromClasses(Set<String> nonExistentClasses) { // try { // pmgr.load(); // } catch (Throwable throwable) { // log.warn("Cannot load plugins repo: ", throwable); // return Collections.emptySet(); // } // final Set<Plugin> availablePlugins = pmgr.getAvailablePlugins(); // final Set<Plugin> pluginsToInstall = new HashSet<>(); // for (Plugin plugin : availablePlugins) { // if (plugin.containsComponentClasses(nonExistentClasses)) { // pluginsToInstall.add(plugin); // } // } // // if (pluginsToInstall.isEmpty()) { // log.warn("Plugins Manager were unable to find plugins to satisfy Test Plan requirements. " + // "To help improve, please report following list to https://jmeter-plugins.org/support/: " + // Arrays.toString(nonExistentClasses.toArray())); // } // // return pluginsToInstall; // } // // public TestPlanAnalyzer getAnalyzer() { // return analyzer; // } // // public void setAnalyzer(TestPlanAnalyzer analyzer) { // this.analyzer = analyzer; // } // // } // // Path: src/main/java/org/jmeterplugins/repository/logging/LoggingHooker.java // public static boolean isJMeter32orLater() { // try { // Class<?> cls = LoggingHooker.class.getClassLoader().loadClass("org.apache.jmeter.gui.logging.GuiLogEventBus"); // if (cls != null) { // return true; // } // } catch (ClassNotFoundException ex) { // log.debug("Class 'org.apache.jmeter.gui.logging.GuiLogEventBus' not found", ex); // } catch (Throwable ex) { // log.warn("Fail to detect JMeter version", ex); // } // return false; // } // Path: src/main/java/org/jmeterplugins/repository/PluginManagerCMD.java import kg.apc.cmdtools.AbstractCMDTool; import org.apache.jmeter.util.JMeterUtils; import org.jmeterplugins.repository.plugins.PluginSuggester; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.PrintStream; import java.io.UnsupportedEncodingException; import java.lang.reflect.Constructor; import java.net.URLDecoder; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.ListIterator; import java.util.Map; import java.util.Set; import static org.jmeterplugins.repository.logging.LoggingHooker.isJMeter32orLater; System.out.println(PluginManager.getUpgradablePluginsAsString()); break; default: showHelp(System.out); throw new UnsupportedOperationException("Wrong command: " + command); } } catch (IllegalArgumentException e) { throw e; } catch (Throwable e) { throw new RuntimeException("Failed to perform cmdline operation: " + e.getMessage(), e); } return 0; } private PluginManager getPluginsManager(boolean isSendRepoStats) throws Throwable { PluginManager mgr = new PluginManager(); mgr.setSendRepoStats(isSendRepoStats); mgr.setTimeout(30000); // TODO: add property? mgr.load(); return mgr; } protected void installPluginsForJmx(ListIterator jmxFilesIterator) throws Throwable { if (!jmxFilesIterator.hasNext()) { throw new IllegalArgumentException("No jmx files specified"); } String files = jmxFilesIterator.next().toString(); PluginManager mgr = getPluginsManager(false);
PluginSuggester suggester = new PluginSuggester(mgr);
liberborn/extapp
src/net/prime/extapp/ExtFileCombiner.java
// Path: src/net/prime/extapp/ExtappConfig.java // class DependTypeEnum { // public Boolean folder; // public DependType dependType; // // DependTypeEnum(Boolean folder, DependType dependType) { // this.folder = folder; // this.dependType = dependType; // } // // public Boolean isFolder(){ // return folder; // } // // public Boolean isArrayProperty() { // return dependType.getValue().equals("Array") ? true : false; // } // // public Boolean isStringProperty() { // return dependType.getValue().equals("String") ? true : false; // } // }
import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.TreeMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import net.prime.extapp.ExtappConfig.DependTypeEnum;
} if (this.main.warnings > 0) { printMsg("-- warnings : " + this.main.warnings); } printMsg("-- total : " + rangedSourceFiles.size() + " files"); printMsg("-- time : " + elapsedTimeSec + " seconds\n\n\n"); } /** * Get dependency type folder * * example: controllers > controller, models > model * * @param String dependType * @return String */ public String getDependencyTypeFolder(String dependType) { return dependType.substring(0, dependType.length() - 1); } /** * Check for folder type enum * * folder types have paths like : '{dependencyType}/{extClass}.js' * non-folder types have paths like : '{extParentClass}/{extSubClasses}/{extSubClass}.js' * * @param String type * @return Boolean */ public Boolean isFolderDependencyType(String type) {
// Path: src/net/prime/extapp/ExtappConfig.java // class DependTypeEnum { // public Boolean folder; // public DependType dependType; // // DependTypeEnum(Boolean folder, DependType dependType) { // this.folder = folder; // this.dependType = dependType; // } // // public Boolean isFolder(){ // return folder; // } // // public Boolean isArrayProperty() { // return dependType.getValue().equals("Array") ? true : false; // } // // public Boolean isStringProperty() { // return dependType.getValue().equals("String") ? true : false; // } // } // Path: src/net/prime/extapp/ExtFileCombiner.java import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.TreeMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import net.prime.extapp.ExtappConfig.DependTypeEnum; } if (this.main.warnings > 0) { printMsg("-- warnings : " + this.main.warnings); } printMsg("-- total : " + rangedSourceFiles.size() + " files"); printMsg("-- time : " + elapsedTimeSec + " seconds\n\n\n"); } /** * Get dependency type folder * * example: controllers > controller, models > model * * @param String dependType * @return String */ public String getDependencyTypeFolder(String dependType) { return dependType.substring(0, dependType.length() - 1); } /** * Check for folder type enum * * folder types have paths like : '{dependencyType}/{extClass}.js' * non-folder types have paths like : '{extParentClass}/{extSubClasses}/{extSubClass}.js' * * @param String type * @return Boolean */ public Boolean isFolderDependencyType(String type) {
DependTypeEnum dependType = this.config.getDependTypeEnums().get(type);
JoeSteven/BiBi
app/src/main/java/com/joe/bibi/service/UpdateService.java
// Path: app/src/main/java/com/joe/bibi/domain/Comment.java // public class Comment extends BmobObject implements Serializable{ // private String BelongTo;//属于哪个话题 // private String Content;//评论内容 // private String UserName;//评论人的用户名 // private String Avatar;//评论人头像 // private String Nick;//评论人的昵称 // private Integer Like;//评论的赞同数 // private Integer UnLike;//评论的差评数 // private Integer Point;//评论所支持的观点 三种 正方,反方 中立 // private String Title; // // public String getTitle() { // return Title; // } // // public void setTitle(String title) { // Title = title; // } // // public static final int POSITIVE_COMMENT=0; // public static final int NEGATIVE_COMMENT=2; // public static final int NEUTRAL_COMMENT=1; // // public String getBelongTo() { // return BelongTo; // } // // public void setBelongTo(String belongTo) { // BelongTo = belongTo; // } // // public String getContent() { // return Content; // } // // public void setContent(String content) { // Content = content; // } // // public String getUserName() { // return UserName; // } // // public void setUserName(String userName) { // UserName = userName; // } // // public String getAvatar() { // return Avatar; // } // // public void setAvatar(String avatar) { // Avatar = avatar; // } // // public String getNick() { // return Nick; // } // // public void setNick(String nick) { // Nick = nick; // } // // public Integer getLike() { // return Like; // } // // public void setLike(Integer like) { // Like = like; // } // // public Integer getUnLike() { // return UnLike; // } // // public void setUnLike(Integer unLike) { // UnLike = unLike; // } // // public Integer getPoint() { // return Point; // } // // public void setPoint(Integer point) { // Point = point; // } // } // // Path: app/src/main/java/com/joe/bibi/domain/Debate.java // public class Debate extends BmobObject implements Serializable{ // private String publisher; // private String title; // private String desc; // private Integer positive; // private Integer negative; // private Integer total; // private String image; // private String avatar; // private String positiveop; // private String negativeop; // private Integer comment; // // public Integer getComment() { // return comment; // } // // public void setComment(Integer comment) { // this.comment = comment; // } // // public String getAvatar() { // return avatar; // } // // public void setAvatar(String avatar) { // this.avatar = avatar; // } // // public String getPositiveop() { // return positiveop; // } // // public void setPositiveop(String positiveop) { // this.positiveop = positiveop; // } // // public String getNegativeop() { // return negativeop; // } // // public void setNegativeop(String negativeop) { // this.negativeop = negativeop; // } // // public String getPublisher() { // return publisher; // } // // public void setPublisher(String publisher) { // this.publisher = publisher; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDesc() { // return desc; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public Integer getPositive() { // return positive; // } // // public void setPositive(Integer positive) { // this.positive = positive; // } // // public Integer getNegative() { // return negative; // } // // public void setNegative(Integer negative) { // this.negative = negative; // } // // public Integer getTotal() { // return total; // } // // public void setTotal(Integer total) { // this.total = total; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // }
import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.support.annotation.Nullable; import android.util.Log; import com.joe.bibi.domain.Comment; import com.joe.bibi.domain.Debate; import java.util.List; import cn.bmob.v3.BmobQuery; import cn.bmob.v3.listener.FindListener; import cn.bmob.v3.listener.UpdateListener;
package com.joe.bibi.service; /** * Created by Joe on 2016/3/2. */ public class UpdateService extends Service { private int num=0;//记录当前更新状态 @Override public int onStartCommand(Intent intent, int flags, int startId) { Log.e("BB","开启服务"+num+"-UpdateService"); String nick=intent.getStringExtra("Nick"); String publisher=intent.getStringExtra("publisher"); final String mAvatarUrl=intent.getStringExtra("AvatarUrl");
// Path: app/src/main/java/com/joe/bibi/domain/Comment.java // public class Comment extends BmobObject implements Serializable{ // private String BelongTo;//属于哪个话题 // private String Content;//评论内容 // private String UserName;//评论人的用户名 // private String Avatar;//评论人头像 // private String Nick;//评论人的昵称 // private Integer Like;//评论的赞同数 // private Integer UnLike;//评论的差评数 // private Integer Point;//评论所支持的观点 三种 正方,反方 中立 // private String Title; // // public String getTitle() { // return Title; // } // // public void setTitle(String title) { // Title = title; // } // // public static final int POSITIVE_COMMENT=0; // public static final int NEGATIVE_COMMENT=2; // public static final int NEUTRAL_COMMENT=1; // // public String getBelongTo() { // return BelongTo; // } // // public void setBelongTo(String belongTo) { // BelongTo = belongTo; // } // // public String getContent() { // return Content; // } // // public void setContent(String content) { // Content = content; // } // // public String getUserName() { // return UserName; // } // // public void setUserName(String userName) { // UserName = userName; // } // // public String getAvatar() { // return Avatar; // } // // public void setAvatar(String avatar) { // Avatar = avatar; // } // // public String getNick() { // return Nick; // } // // public void setNick(String nick) { // Nick = nick; // } // // public Integer getLike() { // return Like; // } // // public void setLike(Integer like) { // Like = like; // } // // public Integer getUnLike() { // return UnLike; // } // // public void setUnLike(Integer unLike) { // UnLike = unLike; // } // // public Integer getPoint() { // return Point; // } // // public void setPoint(Integer point) { // Point = point; // } // } // // Path: app/src/main/java/com/joe/bibi/domain/Debate.java // public class Debate extends BmobObject implements Serializable{ // private String publisher; // private String title; // private String desc; // private Integer positive; // private Integer negative; // private Integer total; // private String image; // private String avatar; // private String positiveop; // private String negativeop; // private Integer comment; // // public Integer getComment() { // return comment; // } // // public void setComment(Integer comment) { // this.comment = comment; // } // // public String getAvatar() { // return avatar; // } // // public void setAvatar(String avatar) { // this.avatar = avatar; // } // // public String getPositiveop() { // return positiveop; // } // // public void setPositiveop(String positiveop) { // this.positiveop = positiveop; // } // // public String getNegativeop() { // return negativeop; // } // // public void setNegativeop(String negativeop) { // this.negativeop = negativeop; // } // // public String getPublisher() { // return publisher; // } // // public void setPublisher(String publisher) { // this.publisher = publisher; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDesc() { // return desc; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public Integer getPositive() { // return positive; // } // // public void setPositive(Integer positive) { // this.positive = positive; // } // // public Integer getNegative() { // return negative; // } // // public void setNegative(Integer negative) { // this.negative = negative; // } // // public Integer getTotal() { // return total; // } // // public void setTotal(Integer total) { // this.total = total; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // } // Path: app/src/main/java/com/joe/bibi/service/UpdateService.java import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.support.annotation.Nullable; import android.util.Log; import com.joe.bibi.domain.Comment; import com.joe.bibi.domain.Debate; import java.util.List; import cn.bmob.v3.BmobQuery; import cn.bmob.v3.listener.FindListener; import cn.bmob.v3.listener.UpdateListener; package com.joe.bibi.service; /** * Created by Joe on 2016/3/2. */ public class UpdateService extends Service { private int num=0;//记录当前更新状态 @Override public int onStartCommand(Intent intent, int flags, int startId) { Log.e("BB","开启服务"+num+"-UpdateService"); String nick=intent.getStringExtra("Nick"); String publisher=intent.getStringExtra("publisher"); final String mAvatarUrl=intent.getStringExtra("AvatarUrl");
BmobQuery<Comment> commentBmobQuery=new BmobQuery<Comment>();
JoeSteven/BiBi
app/src/main/java/com/joe/bibi/service/UpdateService.java
// Path: app/src/main/java/com/joe/bibi/domain/Comment.java // public class Comment extends BmobObject implements Serializable{ // private String BelongTo;//属于哪个话题 // private String Content;//评论内容 // private String UserName;//评论人的用户名 // private String Avatar;//评论人头像 // private String Nick;//评论人的昵称 // private Integer Like;//评论的赞同数 // private Integer UnLike;//评论的差评数 // private Integer Point;//评论所支持的观点 三种 正方,反方 中立 // private String Title; // // public String getTitle() { // return Title; // } // // public void setTitle(String title) { // Title = title; // } // // public static final int POSITIVE_COMMENT=0; // public static final int NEGATIVE_COMMENT=2; // public static final int NEUTRAL_COMMENT=1; // // public String getBelongTo() { // return BelongTo; // } // // public void setBelongTo(String belongTo) { // BelongTo = belongTo; // } // // public String getContent() { // return Content; // } // // public void setContent(String content) { // Content = content; // } // // public String getUserName() { // return UserName; // } // // public void setUserName(String userName) { // UserName = userName; // } // // public String getAvatar() { // return Avatar; // } // // public void setAvatar(String avatar) { // Avatar = avatar; // } // // public String getNick() { // return Nick; // } // // public void setNick(String nick) { // Nick = nick; // } // // public Integer getLike() { // return Like; // } // // public void setLike(Integer like) { // Like = like; // } // // public Integer getUnLike() { // return UnLike; // } // // public void setUnLike(Integer unLike) { // UnLike = unLike; // } // // public Integer getPoint() { // return Point; // } // // public void setPoint(Integer point) { // Point = point; // } // } // // Path: app/src/main/java/com/joe/bibi/domain/Debate.java // public class Debate extends BmobObject implements Serializable{ // private String publisher; // private String title; // private String desc; // private Integer positive; // private Integer negative; // private Integer total; // private String image; // private String avatar; // private String positiveop; // private String negativeop; // private Integer comment; // // public Integer getComment() { // return comment; // } // // public void setComment(Integer comment) { // this.comment = comment; // } // // public String getAvatar() { // return avatar; // } // // public void setAvatar(String avatar) { // this.avatar = avatar; // } // // public String getPositiveop() { // return positiveop; // } // // public void setPositiveop(String positiveop) { // this.positiveop = positiveop; // } // // public String getNegativeop() { // return negativeop; // } // // public void setNegativeop(String negativeop) { // this.negativeop = negativeop; // } // // public String getPublisher() { // return publisher; // } // // public void setPublisher(String publisher) { // this.publisher = publisher; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDesc() { // return desc; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public Integer getPositive() { // return positive; // } // // public void setPositive(Integer positive) { // this.positive = positive; // } // // public Integer getNegative() { // return negative; // } // // public void setNegative(Integer negative) { // this.negative = negative; // } // // public Integer getTotal() { // return total; // } // // public void setTotal(Integer total) { // this.total = total; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // }
import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.support.annotation.Nullable; import android.util.Log; import com.joe.bibi.domain.Comment; import com.joe.bibi.domain.Debate; import java.util.List; import cn.bmob.v3.BmobQuery; import cn.bmob.v3.listener.FindListener; import cn.bmob.v3.listener.UpdateListener;
commentBmobQuery.addWhereEqualTo("Nick",nick); commentBmobQuery.findObjects(this, new FindListener<Comment>() { @Override public void onSuccess(List<Comment> list) { Log.e("BB","更新评论成功"+list.size()+"-UpdateService"); if(list.size()>0){ for (Comment c : list) { c.setAvatar(mAvatarUrl); c.update(UpdateService.this, c.getObjectId(), new UpdateListener() { @Override public void onSuccess() { } @Override public void onFailure(int i, String s) { } }); } } updateDone(); } @Override public void onError(int i, String s) { Log.e("BB","更新评论失败-UpdateService"); updateDone(); } });
// Path: app/src/main/java/com/joe/bibi/domain/Comment.java // public class Comment extends BmobObject implements Serializable{ // private String BelongTo;//属于哪个话题 // private String Content;//评论内容 // private String UserName;//评论人的用户名 // private String Avatar;//评论人头像 // private String Nick;//评论人的昵称 // private Integer Like;//评论的赞同数 // private Integer UnLike;//评论的差评数 // private Integer Point;//评论所支持的观点 三种 正方,反方 中立 // private String Title; // // public String getTitle() { // return Title; // } // // public void setTitle(String title) { // Title = title; // } // // public static final int POSITIVE_COMMENT=0; // public static final int NEGATIVE_COMMENT=2; // public static final int NEUTRAL_COMMENT=1; // // public String getBelongTo() { // return BelongTo; // } // // public void setBelongTo(String belongTo) { // BelongTo = belongTo; // } // // public String getContent() { // return Content; // } // // public void setContent(String content) { // Content = content; // } // // public String getUserName() { // return UserName; // } // // public void setUserName(String userName) { // UserName = userName; // } // // public String getAvatar() { // return Avatar; // } // // public void setAvatar(String avatar) { // Avatar = avatar; // } // // public String getNick() { // return Nick; // } // // public void setNick(String nick) { // Nick = nick; // } // // public Integer getLike() { // return Like; // } // // public void setLike(Integer like) { // Like = like; // } // // public Integer getUnLike() { // return UnLike; // } // // public void setUnLike(Integer unLike) { // UnLike = unLike; // } // // public Integer getPoint() { // return Point; // } // // public void setPoint(Integer point) { // Point = point; // } // } // // Path: app/src/main/java/com/joe/bibi/domain/Debate.java // public class Debate extends BmobObject implements Serializable{ // private String publisher; // private String title; // private String desc; // private Integer positive; // private Integer negative; // private Integer total; // private String image; // private String avatar; // private String positiveop; // private String negativeop; // private Integer comment; // // public Integer getComment() { // return comment; // } // // public void setComment(Integer comment) { // this.comment = comment; // } // // public String getAvatar() { // return avatar; // } // // public void setAvatar(String avatar) { // this.avatar = avatar; // } // // public String getPositiveop() { // return positiveop; // } // // public void setPositiveop(String positiveop) { // this.positiveop = positiveop; // } // // public String getNegativeop() { // return negativeop; // } // // public void setNegativeop(String negativeop) { // this.negativeop = negativeop; // } // // public String getPublisher() { // return publisher; // } // // public void setPublisher(String publisher) { // this.publisher = publisher; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDesc() { // return desc; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public Integer getPositive() { // return positive; // } // // public void setPositive(Integer positive) { // this.positive = positive; // } // // public Integer getNegative() { // return negative; // } // // public void setNegative(Integer negative) { // this.negative = negative; // } // // public Integer getTotal() { // return total; // } // // public void setTotal(Integer total) { // this.total = total; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // } // Path: app/src/main/java/com/joe/bibi/service/UpdateService.java import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.support.annotation.Nullable; import android.util.Log; import com.joe.bibi.domain.Comment; import com.joe.bibi.domain.Debate; import java.util.List; import cn.bmob.v3.BmobQuery; import cn.bmob.v3.listener.FindListener; import cn.bmob.v3.listener.UpdateListener; commentBmobQuery.addWhereEqualTo("Nick",nick); commentBmobQuery.findObjects(this, new FindListener<Comment>() { @Override public void onSuccess(List<Comment> list) { Log.e("BB","更新评论成功"+list.size()+"-UpdateService"); if(list.size()>0){ for (Comment c : list) { c.setAvatar(mAvatarUrl); c.update(UpdateService.this, c.getObjectId(), new UpdateListener() { @Override public void onSuccess() { } @Override public void onFailure(int i, String s) { } }); } } updateDone(); } @Override public void onError(int i, String s) { Log.e("BB","更新评论失败-UpdateService"); updateDone(); } });
BmobQuery<Debate> query=new BmobQuery<Debate>();
JoeSteven/BiBi
app/src/main/java/com/joe/bibi/utils/DebateInfoDao.java
// Path: app/src/main/java/com/joe/bibi/domain/Debate.java // public class Debate extends BmobObject implements Serializable{ // private String publisher; // private String title; // private String desc; // private Integer positive; // private Integer negative; // private Integer total; // private String image; // private String avatar; // private String positiveop; // private String negativeop; // private Integer comment; // // public Integer getComment() { // return comment; // } // // public void setComment(Integer comment) { // this.comment = comment; // } // // public String getAvatar() { // return avatar; // } // // public void setAvatar(String avatar) { // this.avatar = avatar; // } // // public String getPositiveop() { // return positiveop; // } // // public void setPositiveop(String positiveop) { // this.positiveop = positiveop; // } // // public String getNegativeop() { // return negativeop; // } // // public void setNegativeop(String negativeop) { // this.negativeop = negativeop; // } // // public String getPublisher() { // return publisher; // } // // public void setPublisher(String publisher) { // this.publisher = publisher; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDesc() { // return desc; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public Integer getPositive() { // return positive; // } // // public void setPositive(Integer positive) { // this.positive = positive; // } // // public Integer getNegative() { // return negative; // } // // public void setNegative(Integer negative) { // this.negative = negative; // } // // public Integer getTotal() { // return total; // } // // public void setTotal(Integer total) { // this.total = total; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // }
import android.app.Activity; import com.joe.bibi.domain.Debate; import java.util.ArrayList; import java.util.List; import cn.bmob.v3.BmobQuery; import cn.bmob.v3.listener.FindListener;
package com.joe.bibi.utils; /** * Created by Joe on 2016/2/6. */ public class DebateInfoDao { private Activity mActivity; public DebateInfoDao(Activity activity) { this.mActivity=activity; }
// Path: app/src/main/java/com/joe/bibi/domain/Debate.java // public class Debate extends BmobObject implements Serializable{ // private String publisher; // private String title; // private String desc; // private Integer positive; // private Integer negative; // private Integer total; // private String image; // private String avatar; // private String positiveop; // private String negativeop; // private Integer comment; // // public Integer getComment() { // return comment; // } // // public void setComment(Integer comment) { // this.comment = comment; // } // // public String getAvatar() { // return avatar; // } // // public void setAvatar(String avatar) { // this.avatar = avatar; // } // // public String getPositiveop() { // return positiveop; // } // // public void setPositiveop(String positiveop) { // this.positiveop = positiveop; // } // // public String getNegativeop() { // return negativeop; // } // // public void setNegativeop(String negativeop) { // this.negativeop = negativeop; // } // // public String getPublisher() { // return publisher; // } // // public void setPublisher(String publisher) { // this.publisher = publisher; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDesc() { // return desc; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public Integer getPositive() { // return positive; // } // // public void setPositive(Integer positive) { // this.positive = positive; // } // // public Integer getNegative() { // return negative; // } // // public void setNegative(Integer negative) { // this.negative = negative; // } // // public Integer getTotal() { // return total; // } // // public void setTotal(Integer total) { // this.total = total; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // } // Path: app/src/main/java/com/joe/bibi/utils/DebateInfoDao.java import android.app.Activity; import com.joe.bibi.domain.Debate; import java.util.ArrayList; import java.util.List; import cn.bmob.v3.BmobQuery; import cn.bmob.v3.listener.FindListener; package com.joe.bibi.utils; /** * Created by Joe on 2016/2/6. */ public class DebateInfoDao { private Activity mActivity; public DebateInfoDao(Activity activity) { this.mActivity=activity; }
public ArrayList<Debate> getAllInfo(){
JoeSteven/BiBi
app/src/main/java/com/joe/bibi/pager/FollowPager.java
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/domain/Debate.java // public class Debate extends BmobObject implements Serializable{ // private String publisher; // private String title; // private String desc; // private Integer positive; // private Integer negative; // private Integer total; // private String image; // private String avatar; // private String positiveop; // private String negativeop; // private Integer comment; // // public Integer getComment() { // return comment; // } // // public void setComment(Integer comment) { // this.comment = comment; // } // // public String getAvatar() { // return avatar; // } // // public void setAvatar(String avatar) { // this.avatar = avatar; // } // // public String getPositiveop() { // return positiveop; // } // // public void setPositiveop(String positiveop) { // this.positiveop = positiveop; // } // // public String getNegativeop() { // return negativeop; // } // // public void setNegativeop(String negativeop) { // this.negativeop = negativeop; // } // // public String getPublisher() { // return publisher; // } // // public void setPublisher(String publisher) { // this.publisher = publisher; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDesc() { // return desc; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public Integer getPositive() { // return positive; // } // // public void setPositive(Integer positive) { // this.positive = positive; // } // // public Integer getNegative() { // return negative; // } // // public void setNegative(Integer negative) { // this.negative = negative; // } // // public Integer getTotal() { // return total; // } // // public void setTotal(Integer total) { // this.total = total; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // } // // Path: app/src/main/java/com/joe/bibi/domain/Follow.java // public class Follow extends BmobObject { // private String followerId; // private String debateId; // private String followerUserName; // private String followerInstallationId; // // public String getFollowerInstallationId() { // return followerInstallationId; // } // // public void setFollowerInstallationId(String followerInstallationId) { // this.followerInstallationId = followerInstallationId; // } // // public String getFollowerUserName() { // return followerUserName; // } // // public void setFollowerUserName(String followerUserName) { // this.followerUserName = followerUserName; // } // // public String getFollowerId() { // return followerId; // } // // public void setFollowerId(String followerId) { // this.followerId = followerId; // } // // public String getDebateId() { // return debateId; // } // // public void setDebateId(String debateId) { // this.debateId = debateId; // } // }
import android.app.Activity; import android.os.Handler; import android.os.Message; import android.support.design.widget.Snackbar; import android.util.Log; import android.view.View; import com.joe.bibi.domain.BBUser; import com.joe.bibi.domain.Debate; import com.joe.bibi.domain.Follow; import java.util.ArrayList; import java.util.List; import cn.bmob.v3.BmobQuery; import cn.bmob.v3.BmobUser; import cn.bmob.v3.listener.FindListener;
package com.joe.bibi.pager; /** * Created by Joe on 2016/2/2. */ public class FollowPager extends BasePager { private List<String> mFollowedIdList; public FollowPager(Activity mActivity) { super(mActivity); mOrder="-comment,-total"; mFollowedIdList = new ArrayList<String>(); } @Override public void initTitle() { mTitle="关注辩题"; } @Override public void initData() { //先查Follow表,找到表中的数据
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/domain/Debate.java // public class Debate extends BmobObject implements Serializable{ // private String publisher; // private String title; // private String desc; // private Integer positive; // private Integer negative; // private Integer total; // private String image; // private String avatar; // private String positiveop; // private String negativeop; // private Integer comment; // // public Integer getComment() { // return comment; // } // // public void setComment(Integer comment) { // this.comment = comment; // } // // public String getAvatar() { // return avatar; // } // // public void setAvatar(String avatar) { // this.avatar = avatar; // } // // public String getPositiveop() { // return positiveop; // } // // public void setPositiveop(String positiveop) { // this.positiveop = positiveop; // } // // public String getNegativeop() { // return negativeop; // } // // public void setNegativeop(String negativeop) { // this.negativeop = negativeop; // } // // public String getPublisher() { // return publisher; // } // // public void setPublisher(String publisher) { // this.publisher = publisher; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDesc() { // return desc; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public Integer getPositive() { // return positive; // } // // public void setPositive(Integer positive) { // this.positive = positive; // } // // public Integer getNegative() { // return negative; // } // // public void setNegative(Integer negative) { // this.negative = negative; // } // // public Integer getTotal() { // return total; // } // // public void setTotal(Integer total) { // this.total = total; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // } // // Path: app/src/main/java/com/joe/bibi/domain/Follow.java // public class Follow extends BmobObject { // private String followerId; // private String debateId; // private String followerUserName; // private String followerInstallationId; // // public String getFollowerInstallationId() { // return followerInstallationId; // } // // public void setFollowerInstallationId(String followerInstallationId) { // this.followerInstallationId = followerInstallationId; // } // // public String getFollowerUserName() { // return followerUserName; // } // // public void setFollowerUserName(String followerUserName) { // this.followerUserName = followerUserName; // } // // public String getFollowerId() { // return followerId; // } // // public void setFollowerId(String followerId) { // this.followerId = followerId; // } // // public String getDebateId() { // return debateId; // } // // public void setDebateId(String debateId) { // this.debateId = debateId; // } // } // Path: app/src/main/java/com/joe/bibi/pager/FollowPager.java import android.app.Activity; import android.os.Handler; import android.os.Message; import android.support.design.widget.Snackbar; import android.util.Log; import android.view.View; import com.joe.bibi.domain.BBUser; import com.joe.bibi.domain.Debate; import com.joe.bibi.domain.Follow; import java.util.ArrayList; import java.util.List; import cn.bmob.v3.BmobQuery; import cn.bmob.v3.BmobUser; import cn.bmob.v3.listener.FindListener; package com.joe.bibi.pager; /** * Created by Joe on 2016/2/2. */ public class FollowPager extends BasePager { private List<String> mFollowedIdList; public FollowPager(Activity mActivity) { super(mActivity); mOrder="-comment,-total"; mFollowedIdList = new ArrayList<String>(); } @Override public void initTitle() { mTitle="关注辩题"; } @Override public void initData() { //先查Follow表,找到表中的数据
BmobQuery<Follow> followQuery=new BmobQuery<Follow>();
JoeSteven/BiBi
app/src/main/java/com/joe/bibi/pager/FollowPager.java
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/domain/Debate.java // public class Debate extends BmobObject implements Serializable{ // private String publisher; // private String title; // private String desc; // private Integer positive; // private Integer negative; // private Integer total; // private String image; // private String avatar; // private String positiveop; // private String negativeop; // private Integer comment; // // public Integer getComment() { // return comment; // } // // public void setComment(Integer comment) { // this.comment = comment; // } // // public String getAvatar() { // return avatar; // } // // public void setAvatar(String avatar) { // this.avatar = avatar; // } // // public String getPositiveop() { // return positiveop; // } // // public void setPositiveop(String positiveop) { // this.positiveop = positiveop; // } // // public String getNegativeop() { // return negativeop; // } // // public void setNegativeop(String negativeop) { // this.negativeop = negativeop; // } // // public String getPublisher() { // return publisher; // } // // public void setPublisher(String publisher) { // this.publisher = publisher; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDesc() { // return desc; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public Integer getPositive() { // return positive; // } // // public void setPositive(Integer positive) { // this.positive = positive; // } // // public Integer getNegative() { // return negative; // } // // public void setNegative(Integer negative) { // this.negative = negative; // } // // public Integer getTotal() { // return total; // } // // public void setTotal(Integer total) { // this.total = total; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // } // // Path: app/src/main/java/com/joe/bibi/domain/Follow.java // public class Follow extends BmobObject { // private String followerId; // private String debateId; // private String followerUserName; // private String followerInstallationId; // // public String getFollowerInstallationId() { // return followerInstallationId; // } // // public void setFollowerInstallationId(String followerInstallationId) { // this.followerInstallationId = followerInstallationId; // } // // public String getFollowerUserName() { // return followerUserName; // } // // public void setFollowerUserName(String followerUserName) { // this.followerUserName = followerUserName; // } // // public String getFollowerId() { // return followerId; // } // // public void setFollowerId(String followerId) { // this.followerId = followerId; // } // // public String getDebateId() { // return debateId; // } // // public void setDebateId(String debateId) { // this.debateId = debateId; // } // }
import android.app.Activity; import android.os.Handler; import android.os.Message; import android.support.design.widget.Snackbar; import android.util.Log; import android.view.View; import com.joe.bibi.domain.BBUser; import com.joe.bibi.domain.Debate; import com.joe.bibi.domain.Follow; import java.util.ArrayList; import java.util.List; import cn.bmob.v3.BmobQuery; import cn.bmob.v3.BmobUser; import cn.bmob.v3.listener.FindListener;
package com.joe.bibi.pager; /** * Created by Joe on 2016/2/2. */ public class FollowPager extends BasePager { private List<String> mFollowedIdList; public FollowPager(Activity mActivity) { super(mActivity); mOrder="-comment,-total"; mFollowedIdList = new ArrayList<String>(); } @Override public void initTitle() { mTitle="关注辩题"; } @Override public void initData() { //先查Follow表,找到表中的数据 BmobQuery<Follow> followQuery=new BmobQuery<Follow>();
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/domain/Debate.java // public class Debate extends BmobObject implements Serializable{ // private String publisher; // private String title; // private String desc; // private Integer positive; // private Integer negative; // private Integer total; // private String image; // private String avatar; // private String positiveop; // private String negativeop; // private Integer comment; // // public Integer getComment() { // return comment; // } // // public void setComment(Integer comment) { // this.comment = comment; // } // // public String getAvatar() { // return avatar; // } // // public void setAvatar(String avatar) { // this.avatar = avatar; // } // // public String getPositiveop() { // return positiveop; // } // // public void setPositiveop(String positiveop) { // this.positiveop = positiveop; // } // // public String getNegativeop() { // return negativeop; // } // // public void setNegativeop(String negativeop) { // this.negativeop = negativeop; // } // // public String getPublisher() { // return publisher; // } // // public void setPublisher(String publisher) { // this.publisher = publisher; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDesc() { // return desc; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public Integer getPositive() { // return positive; // } // // public void setPositive(Integer positive) { // this.positive = positive; // } // // public Integer getNegative() { // return negative; // } // // public void setNegative(Integer negative) { // this.negative = negative; // } // // public Integer getTotal() { // return total; // } // // public void setTotal(Integer total) { // this.total = total; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // } // // Path: app/src/main/java/com/joe/bibi/domain/Follow.java // public class Follow extends BmobObject { // private String followerId; // private String debateId; // private String followerUserName; // private String followerInstallationId; // // public String getFollowerInstallationId() { // return followerInstallationId; // } // // public void setFollowerInstallationId(String followerInstallationId) { // this.followerInstallationId = followerInstallationId; // } // // public String getFollowerUserName() { // return followerUserName; // } // // public void setFollowerUserName(String followerUserName) { // this.followerUserName = followerUserName; // } // // public String getFollowerId() { // return followerId; // } // // public void setFollowerId(String followerId) { // this.followerId = followerId; // } // // public String getDebateId() { // return debateId; // } // // public void setDebateId(String debateId) { // this.debateId = debateId; // } // } // Path: app/src/main/java/com/joe/bibi/pager/FollowPager.java import android.app.Activity; import android.os.Handler; import android.os.Message; import android.support.design.widget.Snackbar; import android.util.Log; import android.view.View; import com.joe.bibi.domain.BBUser; import com.joe.bibi.domain.Debate; import com.joe.bibi.domain.Follow; import java.util.ArrayList; import java.util.List; import cn.bmob.v3.BmobQuery; import cn.bmob.v3.BmobUser; import cn.bmob.v3.listener.FindListener; package com.joe.bibi.pager; /** * Created by Joe on 2016/2/2. */ public class FollowPager extends BasePager { private List<String> mFollowedIdList; public FollowPager(Activity mActivity) { super(mActivity); mOrder="-comment,-total"; mFollowedIdList = new ArrayList<String>(); } @Override public void initTitle() { mTitle="关注辩题"; } @Override public void initData() { //先查Follow表,找到表中的数据 BmobQuery<Follow> followQuery=new BmobQuery<Follow>();
followQuery.addWhereEqualTo("followerId",BmobUser.getCurrentUser(mActivity,BBUser.class).getObjectId());
JoeSteven/BiBi
app/src/main/java/com/joe/bibi/pager/FollowPager.java
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/domain/Debate.java // public class Debate extends BmobObject implements Serializable{ // private String publisher; // private String title; // private String desc; // private Integer positive; // private Integer negative; // private Integer total; // private String image; // private String avatar; // private String positiveop; // private String negativeop; // private Integer comment; // // public Integer getComment() { // return comment; // } // // public void setComment(Integer comment) { // this.comment = comment; // } // // public String getAvatar() { // return avatar; // } // // public void setAvatar(String avatar) { // this.avatar = avatar; // } // // public String getPositiveop() { // return positiveop; // } // // public void setPositiveop(String positiveop) { // this.positiveop = positiveop; // } // // public String getNegativeop() { // return negativeop; // } // // public void setNegativeop(String negativeop) { // this.negativeop = negativeop; // } // // public String getPublisher() { // return publisher; // } // // public void setPublisher(String publisher) { // this.publisher = publisher; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDesc() { // return desc; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public Integer getPositive() { // return positive; // } // // public void setPositive(Integer positive) { // this.positive = positive; // } // // public Integer getNegative() { // return negative; // } // // public void setNegative(Integer negative) { // this.negative = negative; // } // // public Integer getTotal() { // return total; // } // // public void setTotal(Integer total) { // this.total = total; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // } // // Path: app/src/main/java/com/joe/bibi/domain/Follow.java // public class Follow extends BmobObject { // private String followerId; // private String debateId; // private String followerUserName; // private String followerInstallationId; // // public String getFollowerInstallationId() { // return followerInstallationId; // } // // public void setFollowerInstallationId(String followerInstallationId) { // this.followerInstallationId = followerInstallationId; // } // // public String getFollowerUserName() { // return followerUserName; // } // // public void setFollowerUserName(String followerUserName) { // this.followerUserName = followerUserName; // } // // public String getFollowerId() { // return followerId; // } // // public void setFollowerId(String followerId) { // this.followerId = followerId; // } // // public String getDebateId() { // return debateId; // } // // public void setDebateId(String debateId) { // this.debateId = debateId; // } // }
import android.app.Activity; import android.os.Handler; import android.os.Message; import android.support.design.widget.Snackbar; import android.util.Log; import android.view.View; import com.joe.bibi.domain.BBUser; import com.joe.bibi.domain.Debate; import com.joe.bibi.domain.Follow; import java.util.ArrayList; import java.util.List; import cn.bmob.v3.BmobQuery; import cn.bmob.v3.BmobUser; import cn.bmob.v3.listener.FindListener;
followQuery.findObjects(mActivity, new FindListener<Follow>() { @Override public void onSuccess(List<Follow> list) { if(list.size()>0){ mFollowedIdList.clear(); for (Follow f:list) { mFollowedIdList.add(f.getDebateId()); } } initDataParent(); } @Override public void onError(int i, String s) { } }); } private void initDataParent() { if(isInitData==true) return; query.setLimit(mLimit); query.addWhereContainedIn("objectId",mFollowedIdList); if(isRefreshing){ query.setCachePolicy(BmobQuery.CachePolicy.NETWORK_ELSE_CACHE); }else{ query.setCachePolicy(BmobQuery.CachePolicy.CACHE_THEN_NETWORK); }
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/domain/Debate.java // public class Debate extends BmobObject implements Serializable{ // private String publisher; // private String title; // private String desc; // private Integer positive; // private Integer negative; // private Integer total; // private String image; // private String avatar; // private String positiveop; // private String negativeop; // private Integer comment; // // public Integer getComment() { // return comment; // } // // public void setComment(Integer comment) { // this.comment = comment; // } // // public String getAvatar() { // return avatar; // } // // public void setAvatar(String avatar) { // this.avatar = avatar; // } // // public String getPositiveop() { // return positiveop; // } // // public void setPositiveop(String positiveop) { // this.positiveop = positiveop; // } // // public String getNegativeop() { // return negativeop; // } // // public void setNegativeop(String negativeop) { // this.negativeop = negativeop; // } // // public String getPublisher() { // return publisher; // } // // public void setPublisher(String publisher) { // this.publisher = publisher; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDesc() { // return desc; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public Integer getPositive() { // return positive; // } // // public void setPositive(Integer positive) { // this.positive = positive; // } // // public Integer getNegative() { // return negative; // } // // public void setNegative(Integer negative) { // this.negative = negative; // } // // public Integer getTotal() { // return total; // } // // public void setTotal(Integer total) { // this.total = total; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // } // // Path: app/src/main/java/com/joe/bibi/domain/Follow.java // public class Follow extends BmobObject { // private String followerId; // private String debateId; // private String followerUserName; // private String followerInstallationId; // // public String getFollowerInstallationId() { // return followerInstallationId; // } // // public void setFollowerInstallationId(String followerInstallationId) { // this.followerInstallationId = followerInstallationId; // } // // public String getFollowerUserName() { // return followerUserName; // } // // public void setFollowerUserName(String followerUserName) { // this.followerUserName = followerUserName; // } // // public String getFollowerId() { // return followerId; // } // // public void setFollowerId(String followerId) { // this.followerId = followerId; // } // // public String getDebateId() { // return debateId; // } // // public void setDebateId(String debateId) { // this.debateId = debateId; // } // } // Path: app/src/main/java/com/joe/bibi/pager/FollowPager.java import android.app.Activity; import android.os.Handler; import android.os.Message; import android.support.design.widget.Snackbar; import android.util.Log; import android.view.View; import com.joe.bibi.domain.BBUser; import com.joe.bibi.domain.Debate; import com.joe.bibi.domain.Follow; import java.util.ArrayList; import java.util.List; import cn.bmob.v3.BmobQuery; import cn.bmob.v3.BmobUser; import cn.bmob.v3.listener.FindListener; followQuery.findObjects(mActivity, new FindListener<Follow>() { @Override public void onSuccess(List<Follow> list) { if(list.size()>0){ mFollowedIdList.clear(); for (Follow f:list) { mFollowedIdList.add(f.getDebateId()); } } initDataParent(); } @Override public void onError(int i, String s) { } }); } private void initDataParent() { if(isInitData==true) return; query.setLimit(mLimit); query.addWhereContainedIn("objectId",mFollowedIdList); if(isRefreshing){ query.setCachePolicy(BmobQuery.CachePolicy.NETWORK_ELSE_CACHE); }else{ query.setCachePolicy(BmobQuery.CachePolicy.CACHE_THEN_NETWORK); }
final ArrayList<Debate> list = new ArrayList<Debate>();
JoeSteven/BiBi
app/src/main/java/com/joe/bibi/activity/AboutActivity.java
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/domain/FeedBack.java // public class FeedBack extends BmobObject { // private String phone;//手机型号 // private String system;//系统情况 // private String feedback;//问题详述 // private String username; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPhone() { // return phone; // } // // public void setPhone(String phone) { // this.phone = phone; // } // // public String getSystem() { // return system; // } // // public void setSystem(String system) { // this.system = system; // } // // public String getFeedback() { // return feedback; // } // // public void setFeedback(String feedback) { // this.feedback = feedback; // } // } // // Path: app/src/main/java/com/joe/bibi/utils/ToastUtils.java // public class ToastUtils { // public static void make(Context context,String msg){ // Toast.makeText(context,msg,Toast.LENGTH_SHORT).show(); // } // }
import android.app.AlertDialog; import android.content.DialogInterface; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.view.MenuItem; import android.view.View; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; import com.joe.bibi.R; import com.joe.bibi.domain.BBUser; import com.joe.bibi.domain.FeedBack; import com.joe.bibi.utils.ToastUtils; import cn.bmob.v3.listener.SaveListener;
package com.joe.bibi.activity; public class AboutActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); ActionBar ab=getSupportActionBar(); ab.setDisplayHomeAsUpEnabled(true); initView(); } private void initView() { TextView mVersion= (TextView) findViewById(R.id.tv_version_about); LinearLayout mIntroduce= (LinearLayout) findViewById(R.id.ll_introduce_about); LinearLayout mFeedBack= (LinearLayout) findViewById(R.id.ll_feedback_about); LinearLayout mWeiBo= (LinearLayout) findViewById(R.id.ll_weibo_about); mVersion.setText("版本号 " + getVersion()); mIntroduce.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/domain/FeedBack.java // public class FeedBack extends BmobObject { // private String phone;//手机型号 // private String system;//系统情况 // private String feedback;//问题详述 // private String username; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPhone() { // return phone; // } // // public void setPhone(String phone) { // this.phone = phone; // } // // public String getSystem() { // return system; // } // // public void setSystem(String system) { // this.system = system; // } // // public String getFeedback() { // return feedback; // } // // public void setFeedback(String feedback) { // this.feedback = feedback; // } // } // // Path: app/src/main/java/com/joe/bibi/utils/ToastUtils.java // public class ToastUtils { // public static void make(Context context,String msg){ // Toast.makeText(context,msg,Toast.LENGTH_SHORT).show(); // } // } // Path: app/src/main/java/com/joe/bibi/activity/AboutActivity.java import android.app.AlertDialog; import android.content.DialogInterface; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.view.MenuItem; import android.view.View; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; import com.joe.bibi.R; import com.joe.bibi.domain.BBUser; import com.joe.bibi.domain.FeedBack; import com.joe.bibi.utils.ToastUtils; import cn.bmob.v3.listener.SaveListener; package com.joe.bibi.activity; public class AboutActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); ActionBar ab=getSupportActionBar(); ab.setDisplayHomeAsUpEnabled(true); initView(); } private void initView() { TextView mVersion= (TextView) findViewById(R.id.tv_version_about); LinearLayout mIntroduce= (LinearLayout) findViewById(R.id.ll_introduce_about); LinearLayout mFeedBack= (LinearLayout) findViewById(R.id.ll_feedback_about); LinearLayout mWeiBo= (LinearLayout) findViewById(R.id.ll_weibo_about); mVersion.setText("版本号 " + getVersion()); mIntroduce.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
ToastUtils.make(AboutActivity.this,"还未开发,敬请期待");
JoeSteven/BiBi
app/src/main/java/com/joe/bibi/activity/AboutActivity.java
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/domain/FeedBack.java // public class FeedBack extends BmobObject { // private String phone;//手机型号 // private String system;//系统情况 // private String feedback;//问题详述 // private String username; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPhone() { // return phone; // } // // public void setPhone(String phone) { // this.phone = phone; // } // // public String getSystem() { // return system; // } // // public void setSystem(String system) { // this.system = system; // } // // public String getFeedback() { // return feedback; // } // // public void setFeedback(String feedback) { // this.feedback = feedback; // } // } // // Path: app/src/main/java/com/joe/bibi/utils/ToastUtils.java // public class ToastUtils { // public static void make(Context context,String msg){ // Toast.makeText(context,msg,Toast.LENGTH_SHORT).show(); // } // }
import android.app.AlertDialog; import android.content.DialogInterface; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.view.MenuItem; import android.view.View; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; import com.joe.bibi.R; import com.joe.bibi.domain.BBUser; import com.joe.bibi.domain.FeedBack; import com.joe.bibi.utils.ToastUtils; import cn.bmob.v3.listener.SaveListener;
TextView mVersion= (TextView) findViewById(R.id.tv_version_about); LinearLayout mIntroduce= (LinearLayout) findViewById(R.id.ll_introduce_about); LinearLayout mFeedBack= (LinearLayout) findViewById(R.id.ll_feedback_about); LinearLayout mWeiBo= (LinearLayout) findViewById(R.id.ll_weibo_about); mVersion.setText("版本号 " + getVersion()); mIntroduce.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ToastUtils.make(AboutActivity.this,"还未开发,敬请期待"); } }); mFeedBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder=new AlertDialog.Builder(AboutActivity.this); final View feedView=View.inflate(AboutActivity.this,R.layout.dialog_feedback,null); builder.setTitle("问题反馈"); builder.setView(feedView); builder.setPositiveButton("提交问题", new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, int which) { EditText phone = (EditText) feedView.findViewById(R.id.et_phone_feedback); EditText system = (EditText) feedView.findViewById(R.id.et_system_feedback); EditText content = (EditText) feedView.findViewById(R.id.et_content_feedback); if (TextUtils.isEmpty(content.getText().toString())) { ToastUtils.make(AboutActivity.this,"请描述您的问题"); return; } ToastUtils.make(AboutActivity.this, "正在提交");
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/domain/FeedBack.java // public class FeedBack extends BmobObject { // private String phone;//手机型号 // private String system;//系统情况 // private String feedback;//问题详述 // private String username; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPhone() { // return phone; // } // // public void setPhone(String phone) { // this.phone = phone; // } // // public String getSystem() { // return system; // } // // public void setSystem(String system) { // this.system = system; // } // // public String getFeedback() { // return feedback; // } // // public void setFeedback(String feedback) { // this.feedback = feedback; // } // } // // Path: app/src/main/java/com/joe/bibi/utils/ToastUtils.java // public class ToastUtils { // public static void make(Context context,String msg){ // Toast.makeText(context,msg,Toast.LENGTH_SHORT).show(); // } // } // Path: app/src/main/java/com/joe/bibi/activity/AboutActivity.java import android.app.AlertDialog; import android.content.DialogInterface; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.view.MenuItem; import android.view.View; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; import com.joe.bibi.R; import com.joe.bibi.domain.BBUser; import com.joe.bibi.domain.FeedBack; import com.joe.bibi.utils.ToastUtils; import cn.bmob.v3.listener.SaveListener; TextView mVersion= (TextView) findViewById(R.id.tv_version_about); LinearLayout mIntroduce= (LinearLayout) findViewById(R.id.ll_introduce_about); LinearLayout mFeedBack= (LinearLayout) findViewById(R.id.ll_feedback_about); LinearLayout mWeiBo= (LinearLayout) findViewById(R.id.ll_weibo_about); mVersion.setText("版本号 " + getVersion()); mIntroduce.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ToastUtils.make(AboutActivity.this,"还未开发,敬请期待"); } }); mFeedBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder=new AlertDialog.Builder(AboutActivity.this); final View feedView=View.inflate(AboutActivity.this,R.layout.dialog_feedback,null); builder.setTitle("问题反馈"); builder.setView(feedView); builder.setPositiveButton("提交问题", new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, int which) { EditText phone = (EditText) feedView.findViewById(R.id.et_phone_feedback); EditText system = (EditText) feedView.findViewById(R.id.et_system_feedback); EditText content = (EditText) feedView.findViewById(R.id.et_content_feedback); if (TextUtils.isEmpty(content.getText().toString())) { ToastUtils.make(AboutActivity.this,"请描述您的问题"); return; } ToastUtils.make(AboutActivity.this, "正在提交");
FeedBack feedBack=new FeedBack();
JoeSteven/BiBi
app/src/main/java/com/joe/bibi/activity/AboutActivity.java
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/domain/FeedBack.java // public class FeedBack extends BmobObject { // private String phone;//手机型号 // private String system;//系统情况 // private String feedback;//问题详述 // private String username; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPhone() { // return phone; // } // // public void setPhone(String phone) { // this.phone = phone; // } // // public String getSystem() { // return system; // } // // public void setSystem(String system) { // this.system = system; // } // // public String getFeedback() { // return feedback; // } // // public void setFeedback(String feedback) { // this.feedback = feedback; // } // } // // Path: app/src/main/java/com/joe/bibi/utils/ToastUtils.java // public class ToastUtils { // public static void make(Context context,String msg){ // Toast.makeText(context,msg,Toast.LENGTH_SHORT).show(); // } // }
import android.app.AlertDialog; import android.content.DialogInterface; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.view.MenuItem; import android.view.View; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; import com.joe.bibi.R; import com.joe.bibi.domain.BBUser; import com.joe.bibi.domain.FeedBack; import com.joe.bibi.utils.ToastUtils; import cn.bmob.v3.listener.SaveListener;
mVersion.setText("版本号 " + getVersion()); mIntroduce.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ToastUtils.make(AboutActivity.this,"还未开发,敬请期待"); } }); mFeedBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder=new AlertDialog.Builder(AboutActivity.this); final View feedView=View.inflate(AboutActivity.this,R.layout.dialog_feedback,null); builder.setTitle("问题反馈"); builder.setView(feedView); builder.setPositiveButton("提交问题", new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, int which) { EditText phone = (EditText) feedView.findViewById(R.id.et_phone_feedback); EditText system = (EditText) feedView.findViewById(R.id.et_system_feedback); EditText content = (EditText) feedView.findViewById(R.id.et_content_feedback); if (TextUtils.isEmpty(content.getText().toString())) { ToastUtils.make(AboutActivity.this,"请描述您的问题"); return; } ToastUtils.make(AboutActivity.this, "正在提交"); FeedBack feedBack=new FeedBack(); feedBack.setPhone(phone.getText().toString()); feedBack.setSystem(system.getText().toString()); feedBack.setFeedback(content.getText().toString());
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/domain/FeedBack.java // public class FeedBack extends BmobObject { // private String phone;//手机型号 // private String system;//系统情况 // private String feedback;//问题详述 // private String username; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPhone() { // return phone; // } // // public void setPhone(String phone) { // this.phone = phone; // } // // public String getSystem() { // return system; // } // // public void setSystem(String system) { // this.system = system; // } // // public String getFeedback() { // return feedback; // } // // public void setFeedback(String feedback) { // this.feedback = feedback; // } // } // // Path: app/src/main/java/com/joe/bibi/utils/ToastUtils.java // public class ToastUtils { // public static void make(Context context,String msg){ // Toast.makeText(context,msg,Toast.LENGTH_SHORT).show(); // } // } // Path: app/src/main/java/com/joe/bibi/activity/AboutActivity.java import android.app.AlertDialog; import android.content.DialogInterface; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.view.MenuItem; import android.view.View; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; import com.joe.bibi.R; import com.joe.bibi.domain.BBUser; import com.joe.bibi.domain.FeedBack; import com.joe.bibi.utils.ToastUtils; import cn.bmob.v3.listener.SaveListener; mVersion.setText("版本号 " + getVersion()); mIntroduce.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ToastUtils.make(AboutActivity.this,"还未开发,敬请期待"); } }); mFeedBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder=new AlertDialog.Builder(AboutActivity.this); final View feedView=View.inflate(AboutActivity.this,R.layout.dialog_feedback,null); builder.setTitle("问题反馈"); builder.setView(feedView); builder.setPositiveButton("提交问题", new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, int which) { EditText phone = (EditText) feedView.findViewById(R.id.et_phone_feedback); EditText system = (EditText) feedView.findViewById(R.id.et_system_feedback); EditText content = (EditText) feedView.findViewById(R.id.et_content_feedback); if (TextUtils.isEmpty(content.getText().toString())) { ToastUtils.make(AboutActivity.this,"请描述您的问题"); return; } ToastUtils.make(AboutActivity.this, "正在提交"); FeedBack feedBack=new FeedBack(); feedBack.setPhone(phone.getText().toString()); feedBack.setSystem(system.getText().toString()); feedBack.setFeedback(content.getText().toString());
feedBack.setUsername(BBUser.getCurrentUser(AboutActivity.this,BBUser.class).getUsername());
JoeSteven/BiBi
app/src/main/java/com/joe/bibi/activity/PublishActivity.java
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/domain/Debate.java // public class Debate extends BmobObject implements Serializable{ // private String publisher; // private String title; // private String desc; // private Integer positive; // private Integer negative; // private Integer total; // private String image; // private String avatar; // private String positiveop; // private String negativeop; // private Integer comment; // // public Integer getComment() { // return comment; // } // // public void setComment(Integer comment) { // this.comment = comment; // } // // public String getAvatar() { // return avatar; // } // // public void setAvatar(String avatar) { // this.avatar = avatar; // } // // public String getPositiveop() { // return positiveop; // } // // public void setPositiveop(String positiveop) { // this.positiveop = positiveop; // } // // public String getNegativeop() { // return negativeop; // } // // public void setNegativeop(String negativeop) { // this.negativeop = negativeop; // } // // public String getPublisher() { // return publisher; // } // // public void setPublisher(String publisher) { // this.publisher = publisher; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDesc() { // return desc; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public Integer getPositive() { // return positive; // } // // public void setPositive(Integer positive) { // this.positive = positive; // } // // public Integer getNegative() { // return negative; // } // // public void setNegative(Integer negative) { // this.negative = negative; // } // // public Integer getTotal() { // return total; // } // // public void setTotal(Integer total) { // this.total = total; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // } // // Path: app/src/main/java/com/joe/bibi/utils/ToastUtils.java // public class ToastUtils { // public static void make(Context context,String msg){ // Toast.makeText(context,msg,Toast.LENGTH_SHORT).show(); // } // }
import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.widget.EditText; import com.joe.bibi.R; import com.joe.bibi.domain.BBUser; import com.joe.bibi.domain.Debate; import com.joe.bibi.utils.ToastUtils; import cn.bmob.v3.Bmob; import cn.bmob.v3.BmobUser; import cn.bmob.v3.listener.SaveListener;
android.support.v7.app.ActionBar actionBar=getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); mTitle = (EditText) findViewById(R.id.et_title_publish); mDesc = (EditText) findViewById(R.id.et_desc_publish); mPositive = (EditText) findViewById(R.id.et_positive_publish); mNegative = (EditText) findViewById(R.id.et_negative_publish); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_pub, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { if(item.getItemId()==R.id.action_done_pub){ Log.d("BB",checkDebate()+"-Publish"); if(checkDebate()){ //如果符合要求,发布辩题 Log.d("BB","发布话题-Publish"); publishDebate(); } return true; } return super.onOptionsItemSelected(item); } private void publishDebate() {
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/domain/Debate.java // public class Debate extends BmobObject implements Serializable{ // private String publisher; // private String title; // private String desc; // private Integer positive; // private Integer negative; // private Integer total; // private String image; // private String avatar; // private String positiveop; // private String negativeop; // private Integer comment; // // public Integer getComment() { // return comment; // } // // public void setComment(Integer comment) { // this.comment = comment; // } // // public String getAvatar() { // return avatar; // } // // public void setAvatar(String avatar) { // this.avatar = avatar; // } // // public String getPositiveop() { // return positiveop; // } // // public void setPositiveop(String positiveop) { // this.positiveop = positiveop; // } // // public String getNegativeop() { // return negativeop; // } // // public void setNegativeop(String negativeop) { // this.negativeop = negativeop; // } // // public String getPublisher() { // return publisher; // } // // public void setPublisher(String publisher) { // this.publisher = publisher; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDesc() { // return desc; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public Integer getPositive() { // return positive; // } // // public void setPositive(Integer positive) { // this.positive = positive; // } // // public Integer getNegative() { // return negative; // } // // public void setNegative(Integer negative) { // this.negative = negative; // } // // public Integer getTotal() { // return total; // } // // public void setTotal(Integer total) { // this.total = total; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // } // // Path: app/src/main/java/com/joe/bibi/utils/ToastUtils.java // public class ToastUtils { // public static void make(Context context,String msg){ // Toast.makeText(context,msg,Toast.LENGTH_SHORT).show(); // } // } // Path: app/src/main/java/com/joe/bibi/activity/PublishActivity.java import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.widget.EditText; import com.joe.bibi.R; import com.joe.bibi.domain.BBUser; import com.joe.bibi.domain.Debate; import com.joe.bibi.utils.ToastUtils; import cn.bmob.v3.Bmob; import cn.bmob.v3.BmobUser; import cn.bmob.v3.listener.SaveListener; android.support.v7.app.ActionBar actionBar=getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); mTitle = (EditText) findViewById(R.id.et_title_publish); mDesc = (EditText) findViewById(R.id.et_desc_publish); mPositive = (EditText) findViewById(R.id.et_positive_publish); mNegative = (EditText) findViewById(R.id.et_negative_publish); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_pub, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { if(item.getItemId()==R.id.action_done_pub){ Log.d("BB",checkDebate()+"-Publish"); if(checkDebate()){ //如果符合要求,发布辩题 Log.d("BB","发布话题-Publish"); publishDebate(); } return true; } return super.onOptionsItemSelected(item); } private void publishDebate() {
Debate debate=new Debate();
JoeSteven/BiBi
app/src/main/java/com/joe/bibi/activity/PublishActivity.java
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/domain/Debate.java // public class Debate extends BmobObject implements Serializable{ // private String publisher; // private String title; // private String desc; // private Integer positive; // private Integer negative; // private Integer total; // private String image; // private String avatar; // private String positiveop; // private String negativeop; // private Integer comment; // // public Integer getComment() { // return comment; // } // // public void setComment(Integer comment) { // this.comment = comment; // } // // public String getAvatar() { // return avatar; // } // // public void setAvatar(String avatar) { // this.avatar = avatar; // } // // public String getPositiveop() { // return positiveop; // } // // public void setPositiveop(String positiveop) { // this.positiveop = positiveop; // } // // public String getNegativeop() { // return negativeop; // } // // public void setNegativeop(String negativeop) { // this.negativeop = negativeop; // } // // public String getPublisher() { // return publisher; // } // // public void setPublisher(String publisher) { // this.publisher = publisher; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDesc() { // return desc; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public Integer getPositive() { // return positive; // } // // public void setPositive(Integer positive) { // this.positive = positive; // } // // public Integer getNegative() { // return negative; // } // // public void setNegative(Integer negative) { // this.negative = negative; // } // // public Integer getTotal() { // return total; // } // // public void setTotal(Integer total) { // this.total = total; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // } // // Path: app/src/main/java/com/joe/bibi/utils/ToastUtils.java // public class ToastUtils { // public static void make(Context context,String msg){ // Toast.makeText(context,msg,Toast.LENGTH_SHORT).show(); // } // }
import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.widget.EditText; import com.joe.bibi.R; import com.joe.bibi.domain.BBUser; import com.joe.bibi.domain.Debate; import com.joe.bibi.utils.ToastUtils; import cn.bmob.v3.Bmob; import cn.bmob.v3.BmobUser; import cn.bmob.v3.listener.SaveListener;
actionBar.setDisplayHomeAsUpEnabled(true); mTitle = (EditText) findViewById(R.id.et_title_publish); mDesc = (EditText) findViewById(R.id.et_desc_publish); mPositive = (EditText) findViewById(R.id.et_positive_publish); mNegative = (EditText) findViewById(R.id.et_negative_publish); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_pub, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { if(item.getItemId()==R.id.action_done_pub){ Log.d("BB",checkDebate()+"-Publish"); if(checkDebate()){ //如果符合要求,发布辩题 Log.d("BB","发布话题-Publish"); publishDebate(); } return true; } return super.onOptionsItemSelected(item); } private void publishDebate() { Debate debate=new Debate();
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/domain/Debate.java // public class Debate extends BmobObject implements Serializable{ // private String publisher; // private String title; // private String desc; // private Integer positive; // private Integer negative; // private Integer total; // private String image; // private String avatar; // private String positiveop; // private String negativeop; // private Integer comment; // // public Integer getComment() { // return comment; // } // // public void setComment(Integer comment) { // this.comment = comment; // } // // public String getAvatar() { // return avatar; // } // // public void setAvatar(String avatar) { // this.avatar = avatar; // } // // public String getPositiveop() { // return positiveop; // } // // public void setPositiveop(String positiveop) { // this.positiveop = positiveop; // } // // public String getNegativeop() { // return negativeop; // } // // public void setNegativeop(String negativeop) { // this.negativeop = negativeop; // } // // public String getPublisher() { // return publisher; // } // // public void setPublisher(String publisher) { // this.publisher = publisher; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDesc() { // return desc; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public Integer getPositive() { // return positive; // } // // public void setPositive(Integer positive) { // this.positive = positive; // } // // public Integer getNegative() { // return negative; // } // // public void setNegative(Integer negative) { // this.negative = negative; // } // // public Integer getTotal() { // return total; // } // // public void setTotal(Integer total) { // this.total = total; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // } // // Path: app/src/main/java/com/joe/bibi/utils/ToastUtils.java // public class ToastUtils { // public static void make(Context context,String msg){ // Toast.makeText(context,msg,Toast.LENGTH_SHORT).show(); // } // } // Path: app/src/main/java/com/joe/bibi/activity/PublishActivity.java import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.widget.EditText; import com.joe.bibi.R; import com.joe.bibi.domain.BBUser; import com.joe.bibi.domain.Debate; import com.joe.bibi.utils.ToastUtils; import cn.bmob.v3.Bmob; import cn.bmob.v3.BmobUser; import cn.bmob.v3.listener.SaveListener; actionBar.setDisplayHomeAsUpEnabled(true); mTitle = (EditText) findViewById(R.id.et_title_publish); mDesc = (EditText) findViewById(R.id.et_desc_publish); mPositive = (EditText) findViewById(R.id.et_positive_publish); mNegative = (EditText) findViewById(R.id.et_negative_publish); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_pub, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { if(item.getItemId()==R.id.action_done_pub){ Log.d("BB",checkDebate()+"-Publish"); if(checkDebate()){ //如果符合要求,发布辩题 Log.d("BB","发布话题-Publish"); publishDebate(); } return true; } return super.onOptionsItemSelected(item); } private void publishDebate() { Debate debate=new Debate();
BBUser publisher= BmobUser.getCurrentUser(this,BBUser.class);
JoeSteven/BiBi
app/src/main/java/com/joe/bibi/activity/PublishActivity.java
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/domain/Debate.java // public class Debate extends BmobObject implements Serializable{ // private String publisher; // private String title; // private String desc; // private Integer positive; // private Integer negative; // private Integer total; // private String image; // private String avatar; // private String positiveop; // private String negativeop; // private Integer comment; // // public Integer getComment() { // return comment; // } // // public void setComment(Integer comment) { // this.comment = comment; // } // // public String getAvatar() { // return avatar; // } // // public void setAvatar(String avatar) { // this.avatar = avatar; // } // // public String getPositiveop() { // return positiveop; // } // // public void setPositiveop(String positiveop) { // this.positiveop = positiveop; // } // // public String getNegativeop() { // return negativeop; // } // // public void setNegativeop(String negativeop) { // this.negativeop = negativeop; // } // // public String getPublisher() { // return publisher; // } // // public void setPublisher(String publisher) { // this.publisher = publisher; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDesc() { // return desc; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public Integer getPositive() { // return positive; // } // // public void setPositive(Integer positive) { // this.positive = positive; // } // // public Integer getNegative() { // return negative; // } // // public void setNegative(Integer negative) { // this.negative = negative; // } // // public Integer getTotal() { // return total; // } // // public void setTotal(Integer total) { // this.total = total; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // } // // Path: app/src/main/java/com/joe/bibi/utils/ToastUtils.java // public class ToastUtils { // public static void make(Context context,String msg){ // Toast.makeText(context,msg,Toast.LENGTH_SHORT).show(); // } // }
import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.widget.EditText; import com.joe.bibi.R; import com.joe.bibi.domain.BBUser; import com.joe.bibi.domain.Debate; import com.joe.bibi.utils.ToastUtils; import cn.bmob.v3.Bmob; import cn.bmob.v3.BmobUser; import cn.bmob.v3.listener.SaveListener;
public boolean onOptionsItemSelected(MenuItem item) { if(item.getItemId()==R.id.action_done_pub){ Log.d("BB",checkDebate()+"-Publish"); if(checkDebate()){ //如果符合要求,发布辩题 Log.d("BB","发布话题-Publish"); publishDebate(); } return true; } return super.onOptionsItemSelected(item); } private void publishDebate() { Debate debate=new Debate(); BBUser publisher= BmobUser.getCurrentUser(this,BBUser.class); debate.setTitle(mTitle.getText().toString().replace(" ", "")); debate.setDesc(mDesc.getText().toString()); debate.setPositiveop(mPositive.getText().toString().replace(" ", "")); debate.setNegativeop(mNegative.getText().toString().replace(" ", "")); debate.setPositive(0); debate.setNegative(0); debate.setTotal(0); debate.setComment(0); debate.setPublisher(publisher.getUsername()); debate.setAvatar(publisher.getAvatarUrl()); debate.save(this, new SaveListener() { @Override public void onSuccess() {
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/domain/Debate.java // public class Debate extends BmobObject implements Serializable{ // private String publisher; // private String title; // private String desc; // private Integer positive; // private Integer negative; // private Integer total; // private String image; // private String avatar; // private String positiveop; // private String negativeop; // private Integer comment; // // public Integer getComment() { // return comment; // } // // public void setComment(Integer comment) { // this.comment = comment; // } // // public String getAvatar() { // return avatar; // } // // public void setAvatar(String avatar) { // this.avatar = avatar; // } // // public String getPositiveop() { // return positiveop; // } // // public void setPositiveop(String positiveop) { // this.positiveop = positiveop; // } // // public String getNegativeop() { // return negativeop; // } // // public void setNegativeop(String negativeop) { // this.negativeop = negativeop; // } // // public String getPublisher() { // return publisher; // } // // public void setPublisher(String publisher) { // this.publisher = publisher; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDesc() { // return desc; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public Integer getPositive() { // return positive; // } // // public void setPositive(Integer positive) { // this.positive = positive; // } // // public Integer getNegative() { // return negative; // } // // public void setNegative(Integer negative) { // this.negative = negative; // } // // public Integer getTotal() { // return total; // } // // public void setTotal(Integer total) { // this.total = total; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // } // // Path: app/src/main/java/com/joe/bibi/utils/ToastUtils.java // public class ToastUtils { // public static void make(Context context,String msg){ // Toast.makeText(context,msg,Toast.LENGTH_SHORT).show(); // } // } // Path: app/src/main/java/com/joe/bibi/activity/PublishActivity.java import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.widget.EditText; import com.joe.bibi.R; import com.joe.bibi.domain.BBUser; import com.joe.bibi.domain.Debate; import com.joe.bibi.utils.ToastUtils; import cn.bmob.v3.Bmob; import cn.bmob.v3.BmobUser; import cn.bmob.v3.listener.SaveListener; public boolean onOptionsItemSelected(MenuItem item) { if(item.getItemId()==R.id.action_done_pub){ Log.d("BB",checkDebate()+"-Publish"); if(checkDebate()){ //如果符合要求,发布辩题 Log.d("BB","发布话题-Publish"); publishDebate(); } return true; } return super.onOptionsItemSelected(item); } private void publishDebate() { Debate debate=new Debate(); BBUser publisher= BmobUser.getCurrentUser(this,BBUser.class); debate.setTitle(mTitle.getText().toString().replace(" ", "")); debate.setDesc(mDesc.getText().toString()); debate.setPositiveop(mPositive.getText().toString().replace(" ", "")); debate.setNegativeop(mNegative.getText().toString().replace(" ", "")); debate.setPositive(0); debate.setNegative(0); debate.setTotal(0); debate.setComment(0); debate.setPublisher(publisher.getUsername()); debate.setAvatar(publisher.getAvatarUrl()); debate.save(this, new SaveListener() { @Override public void onSuccess() {
ToastUtils.make(PublishActivity.this,"发布辩题成功");
JoeSteven/BiBi
app/src/main/java/com/joe/bibi/application/BBApplication.java
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/utils/PrefUtils.java // public class PrefUtils { // private static SharedPreferences mPref; // // //记录布尔类型 // public static void putBoolean(Context context,String key,Boolean value){ // mPref = context.getSharedPreferences(ConsUtils.SHARED_CONFIG, Context.MODE_PRIVATE); // mPref.edit().putBoolean(key, value).commit(); // } // public static Boolean getBoolean(Context context,String key,Boolean defValue){ // mPref = context.getSharedPreferences(ConsUtils.SHARED_CONFIG, Context.MODE_PRIVATE); // return mPref.getBoolean(key, defValue); // } // public static void putString(Context context,String key,String value){ // mPref = context.getSharedPreferences(ConsUtils.SHARED_CONFIG, Context.MODE_PRIVATE); // mPref.edit().putString(key, value).commit(); // } // //记录String类型 // public static String getString(Context context,String key,String defValue){ // mPref = context.getSharedPreferences(ConsUtils.SHARED_CONFIG, Context.MODE_PRIVATE); // return mPref.getString(key, defValue); // } // // public static void putInt(Context context,String key,int value){ // mPref = context.getSharedPreferences(ConsUtils.SHARED_CONFIG, Context.MODE_PRIVATE); // mPref.edit().putInt(key, value).commit(); // } // //记录int类型 // public static int getInt(Context context,String key,int defValue){ // mPref = context.getSharedPreferences(ConsUtils.SHARED_CONFIG, Context.MODE_PRIVATE); // return mPref.getInt(key, defValue); // } // }
import android.app.Application; import android.text.TextUtils; import com.joe.bibi.domain.BBUser; import com.joe.bibi.utils.ConsUtils; import com.joe.bibi.utils.PrefUtils; import org.xutils.x; import java.util.ArrayList; import java.util.List; import cn.bmob.im.BmobChat; import cn.bmob.im.BmobUserManager; import cn.bmob.im.bean.BmobChatUser; import cn.bmob.v3.BmobInstallation; import cn.bmob.v3.listener.FindListener;
package com.joe.bibi.application; /** * Created by Joe on 2016/1/28. */ public class BBApplication extends Application{ public static BBApplication mInstance; public List<BmobChatUser> getContactList() { return ContactList; } public void setContactList(List<BmobChatUser> contactList) { ContactList = contactList; } public List<BmobChatUser> ContactList; public boolean isCommentAllowed; public boolean isVoiceAllowed; public boolean isVibrateAllowed; public boolean isMessageAllowed; @Override public void onCreate() { super.onCreate(); x.Ext.init(this); x.Ext.setDebug(true); initBmob(); mInstance=this;
// Path: app/src/main/java/com/joe/bibi/domain/BBUser.java // public class BBUser extends BmobChatUser implements Serializable{ // private String Desc;//简介 // private String Tag;//标签 // private String AvatarName; // private String AvatarUrl; // // public String getAvatarUrl() { // return AvatarUrl; // } // // public void setAvatarUrl(String avatarUrl) { // AvatarUrl = avatarUrl; // } // // public String getAvatarName() { // return AvatarName; // } // // public void setAvatarName(String avatarName) { // AvatarName = avatarName; // } // // public String getTag() { // return Tag; // } // // public void setTag(String tag) { // Tag = tag; // } // // public String getDesc() { // return Desc; // } // // public void setDesc(String desc) { // Desc = desc; // } // // // } // // Path: app/src/main/java/com/joe/bibi/utils/PrefUtils.java // public class PrefUtils { // private static SharedPreferences mPref; // // //记录布尔类型 // public static void putBoolean(Context context,String key,Boolean value){ // mPref = context.getSharedPreferences(ConsUtils.SHARED_CONFIG, Context.MODE_PRIVATE); // mPref.edit().putBoolean(key, value).commit(); // } // public static Boolean getBoolean(Context context,String key,Boolean defValue){ // mPref = context.getSharedPreferences(ConsUtils.SHARED_CONFIG, Context.MODE_PRIVATE); // return mPref.getBoolean(key, defValue); // } // public static void putString(Context context,String key,String value){ // mPref = context.getSharedPreferences(ConsUtils.SHARED_CONFIG, Context.MODE_PRIVATE); // mPref.edit().putString(key, value).commit(); // } // //记录String类型 // public static String getString(Context context,String key,String defValue){ // mPref = context.getSharedPreferences(ConsUtils.SHARED_CONFIG, Context.MODE_PRIVATE); // return mPref.getString(key, defValue); // } // // public static void putInt(Context context,String key,int value){ // mPref = context.getSharedPreferences(ConsUtils.SHARED_CONFIG, Context.MODE_PRIVATE); // mPref.edit().putInt(key, value).commit(); // } // //记录int类型 // public static int getInt(Context context,String key,int defValue){ // mPref = context.getSharedPreferences(ConsUtils.SHARED_CONFIG, Context.MODE_PRIVATE); // return mPref.getInt(key, defValue); // } // } // Path: app/src/main/java/com/joe/bibi/application/BBApplication.java import android.app.Application; import android.text.TextUtils; import com.joe.bibi.domain.BBUser; import com.joe.bibi.utils.ConsUtils; import com.joe.bibi.utils.PrefUtils; import org.xutils.x; import java.util.ArrayList; import java.util.List; import cn.bmob.im.BmobChat; import cn.bmob.im.BmobUserManager; import cn.bmob.im.bean.BmobChatUser; import cn.bmob.v3.BmobInstallation; import cn.bmob.v3.listener.FindListener; package com.joe.bibi.application; /** * Created by Joe on 2016/1/28. */ public class BBApplication extends Application{ public static BBApplication mInstance; public List<BmobChatUser> getContactList() { return ContactList; } public void setContactList(List<BmobChatUser> contactList) { ContactList = contactList; } public List<BmobChatUser> ContactList; public boolean isCommentAllowed; public boolean isVoiceAllowed; public boolean isVibrateAllowed; public boolean isMessageAllowed; @Override public void onCreate() { super.onCreate(); x.Ext.init(this); x.Ext.setDebug(true); initBmob(); mInstance=this;
isCommentAllowed=PrefUtils.getBoolean(this, ConsUtils.IS_COMMENT_ALLOWED,true);
xurxodev/Movies-Android-Kata
app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/adapter/MoviesAdapter.java
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java // public class Movie { // private String image; // private String title; // private String overview; // // public Movie(String image, String title, String overview) { // this.image = image; // this.title = title; // this.overview = overview; // } // // public String getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public String getOverview() { // return overview; // } // }
import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.squareup.picasso.Picasso; import com.xurxodev.moviesandroidkata.R; import com.xurxodev.moviesandroidkata.domain.entity.Movie; import java.util.ArrayList; import java.util.List;
package com.xurxodev.moviesandroidkata.presentation.view.adapter; public class MoviesAdapter extends RecyclerView.Adapter<MoviesAdapter.ViewHolder> { public interface OnMovieClickListener {
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/domain/entity/Movie.java // public class Movie { // private String image; // private String title; // private String overview; // // public Movie(String image, String title, String overview) { // this.image = image; // this.title = title; // this.overview = overview; // } // // public String getImage() { // return image; // } // // public String getTitle() { // return title; // } // // public String getOverview() { // return overview; // } // } // Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/adapter/MoviesAdapter.java import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.squareup.picasso.Picasso; import com.xurxodev.moviesandroidkata.R; import com.xurxodev.moviesandroidkata.domain.entity.Movie; import java.util.ArrayList; import java.util.List; package com.xurxodev.moviesandroidkata.presentation.view.adapter; public class MoviesAdapter extends RecyclerView.Adapter<MoviesAdapter.ViewHolder> { public interface OnMovieClickListener {
void onItemClick(View view, Movie movie);