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
SOM-Research/EMFtoCSP
plugins/fr.inria.atlanmod.emftocsp.ui.main/src/fr/inria/atlanmod/emftocsp/ui/main/preferences/PreferencePage.java
// Path: plugins/fr.inria.atlanmod.emftocsp.ui.main/src/fr/inria/atlanmod/emftocsp/ui/main/Activator.java // public class Activator extends AbstractUIPlugin { // // // The plug-in ID // public static final String PLUGIN_ID = "fr.inria.atlanmod.emftocsp.ui.main"; //$NON-NLS-1$ // // // The shared instance // private static Activator plugin; // // /** // * The constructor // */ // public Activator() { // } // // /* // * (non-Javadoc) // * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) // */ // public void start(BundleContext context) throws Exception { // super.start(context); // plugin = this; // } // // /* // * (non-Javadoc) // * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) // */ // public void stop(BundleContext context) throws Exception { // plugin = null; // super.stop(context); // } // // /** // * Returns the shared instance // * // * @return the shared instance // */ // public static Activator getDefault() { // return plugin; // } // // }
import org.eclipse.jface.preference.DirectoryFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import fr.inria.atlanmod.emftocsp.ui.main.Activator;
/******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.ui.main.preferences; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public class PreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { public PreferencePage() { super(GRID);
// Path: plugins/fr.inria.atlanmod.emftocsp.ui.main/src/fr/inria/atlanmod/emftocsp/ui/main/Activator.java // public class Activator extends AbstractUIPlugin { // // // The plug-in ID // public static final String PLUGIN_ID = "fr.inria.atlanmod.emftocsp.ui.main"; //$NON-NLS-1$ // // // The shared instance // private static Activator plugin; // // /** // * The constructor // */ // public Activator() { // } // // /* // * (non-Javadoc) // * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) // */ // public void start(BundleContext context) throws Exception { // super.start(context); // plugin = this; // } // // /* // * (non-Javadoc) // * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) // */ // public void stop(BundleContext context) throws Exception { // plugin = null; // super.stop(context); // } // // /** // * Returns the shared instance // * // * @return the shared instance // */ // public static Activator getDefault() { // return plugin; // } // // } // Path: plugins/fr.inria.atlanmod.emftocsp.ui.main/src/fr/inria/atlanmod/emftocsp/ui/main/preferences/PreferencePage.java import org.eclipse.jface.preference.DirectoryFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import fr.inria.atlanmod.emftocsp.ui.main.Activator; /******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.ui.main.preferences; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public class PreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { public PreferencePage() { super(GRID);
setPreferenceStore(Activator.getDefault().getPreferenceStore());
SOM-Research/EMFtoCSP
plugins/fr.inria.atlanmod.emftocsp.emf/src/fr/inria/atlanmod/emftocsp/emf/impl/EmfCspCodeGenerator.java
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ICspCodeGenerator.java // public interface ICspCodeGenerator<R, P, C, AS, AT, OP, CT> { // // void setModelReader(IModelReader<R, P, C, AS, AT, OP> modelReader); // // void setProperties(List<IModelProperty> properties); // // void setModelElementsDomains(Map<String, String> elementsDomain); // // void setOclParser(IOclParser<CT, R> oclParser); // // void setOclDocument(IFile oclDocument); // // void setModel(R modelResource); // // String getCspCode() throws ProcessingException; // // String getCspCodeFileExtension(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelProperty.java // public interface IModelProperty { // // void setName(String name); // // String getName(); // // void setTargetModelElementsNames(List<String> modelElementsNames); // // List<String> getTargetModelElementsNames(); // // String toString(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelReader.java // public interface IModelReader<R, P, C, AS, AT, OP> { // // public R getModelResource(); // // public List<P> getPackages(); // // public List<C> getClasses(); // // public List<String> getClassesNames(); // // public List<AT> getClassAttributes(C c); // // public List<OP> getClassOperations(C c); // // public List<C> getClassSubtypes(List<C> classList, C c); // // public void getClassSubtypes(List<C> cList, C c, List<C> subTypes); // // public C getBaseClass(C c); // // public List<AS> getAssociations(); // // public List<String> getAssociationsNames(); // // public String getAssociationName(AS as); // // public String getAssociationEndName(AT asEnd); // // public List<String> getAssociationNamesOfNonAbsClasses(); // // public R getResource(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IOclParser.java // public interface IOclParser<CT, R> { // // CT parseOclConstraint(Object context, String key, String constraint); // // List<CT> parseOclDocument(IFile oclDocument, R modelResource) throws ProcessingException; // // List<CT> parseEmbeddedConstraints(R modelResource); // // List<CT> parseModelConstraints(R modelResource, IFile oclDocument) throws ProcessingException; // // List<String> getModelConstraintsNames(R modelResource, IFile oclDocument) throws ProcessingException; // // List<String> getModelInvariantNames(R modelResource, IFile oclDocument) throws ProcessingException; // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ProcessingException.java // public class ProcessingException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ProcessingException(Throwable e) { // super(e); // } // // public ProcessingException(String msg, Throwable th) { // super(msg, th); // } // // public ProcessingException(String string) { // super(string); // } // // }
import java.util.HashMap; import java.util.List; import java.util.Map; import org.eclipse.core.resources.IFile; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EOperation; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.ocl.ecore.Constraint; import fr.inria.atlanmod.emftocsp.ICspCodeGenerator; import fr.inria.atlanmod.emftocsp.IModelProperty; import fr.inria.atlanmod.emftocsp.IModelReader; import fr.inria.atlanmod.emftocsp.IOclParser; import fr.inria.atlanmod.emftocsp.ProcessingException;
/******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.emf.impl; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public abstract class EmfCspCodeGenerator implements ICspCodeGenerator<Resource, EPackage, EClass, EAssociation, EAttribute, EOperation, Constraint> { IModelReader<Resource, EPackage, EClass, EAssociation, EAttribute, EOperation> modelReader;
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ICspCodeGenerator.java // public interface ICspCodeGenerator<R, P, C, AS, AT, OP, CT> { // // void setModelReader(IModelReader<R, P, C, AS, AT, OP> modelReader); // // void setProperties(List<IModelProperty> properties); // // void setModelElementsDomains(Map<String, String> elementsDomain); // // void setOclParser(IOclParser<CT, R> oclParser); // // void setOclDocument(IFile oclDocument); // // void setModel(R modelResource); // // String getCspCode() throws ProcessingException; // // String getCspCodeFileExtension(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelProperty.java // public interface IModelProperty { // // void setName(String name); // // String getName(); // // void setTargetModelElementsNames(List<String> modelElementsNames); // // List<String> getTargetModelElementsNames(); // // String toString(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelReader.java // public interface IModelReader<R, P, C, AS, AT, OP> { // // public R getModelResource(); // // public List<P> getPackages(); // // public List<C> getClasses(); // // public List<String> getClassesNames(); // // public List<AT> getClassAttributes(C c); // // public List<OP> getClassOperations(C c); // // public List<C> getClassSubtypes(List<C> classList, C c); // // public void getClassSubtypes(List<C> cList, C c, List<C> subTypes); // // public C getBaseClass(C c); // // public List<AS> getAssociations(); // // public List<String> getAssociationsNames(); // // public String getAssociationName(AS as); // // public String getAssociationEndName(AT asEnd); // // public List<String> getAssociationNamesOfNonAbsClasses(); // // public R getResource(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IOclParser.java // public interface IOclParser<CT, R> { // // CT parseOclConstraint(Object context, String key, String constraint); // // List<CT> parseOclDocument(IFile oclDocument, R modelResource) throws ProcessingException; // // List<CT> parseEmbeddedConstraints(R modelResource); // // List<CT> parseModelConstraints(R modelResource, IFile oclDocument) throws ProcessingException; // // List<String> getModelConstraintsNames(R modelResource, IFile oclDocument) throws ProcessingException; // // List<String> getModelInvariantNames(R modelResource, IFile oclDocument) throws ProcessingException; // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ProcessingException.java // public class ProcessingException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ProcessingException(Throwable e) { // super(e); // } // // public ProcessingException(String msg, Throwable th) { // super(msg, th); // } // // public ProcessingException(String string) { // super(string); // } // // } // Path: plugins/fr.inria.atlanmod.emftocsp.emf/src/fr/inria/atlanmod/emftocsp/emf/impl/EmfCspCodeGenerator.java import java.util.HashMap; import java.util.List; import java.util.Map; import org.eclipse.core.resources.IFile; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EOperation; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.ocl.ecore.Constraint; import fr.inria.atlanmod.emftocsp.ICspCodeGenerator; import fr.inria.atlanmod.emftocsp.IModelProperty; import fr.inria.atlanmod.emftocsp.IModelReader; import fr.inria.atlanmod.emftocsp.IOclParser; import fr.inria.atlanmod.emftocsp.ProcessingException; /******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.emf.impl; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public abstract class EmfCspCodeGenerator implements ICspCodeGenerator<Resource, EPackage, EClass, EAssociation, EAttribute, EOperation, Constraint> { IModelReader<Resource, EPackage, EClass, EAssociation, EAttribute, EOperation> modelReader;
IOclParser<Constraint, Resource> oclParser;
SOM-Research/EMFtoCSP
plugins/fr.inria.atlanmod.emftocsp.emf/src/fr/inria/atlanmod/emftocsp/emf/impl/EmfCspCodeGenerator.java
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ICspCodeGenerator.java // public interface ICspCodeGenerator<R, P, C, AS, AT, OP, CT> { // // void setModelReader(IModelReader<R, P, C, AS, AT, OP> modelReader); // // void setProperties(List<IModelProperty> properties); // // void setModelElementsDomains(Map<String, String> elementsDomain); // // void setOclParser(IOclParser<CT, R> oclParser); // // void setOclDocument(IFile oclDocument); // // void setModel(R modelResource); // // String getCspCode() throws ProcessingException; // // String getCspCodeFileExtension(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelProperty.java // public interface IModelProperty { // // void setName(String name); // // String getName(); // // void setTargetModelElementsNames(List<String> modelElementsNames); // // List<String> getTargetModelElementsNames(); // // String toString(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelReader.java // public interface IModelReader<R, P, C, AS, AT, OP> { // // public R getModelResource(); // // public List<P> getPackages(); // // public List<C> getClasses(); // // public List<String> getClassesNames(); // // public List<AT> getClassAttributes(C c); // // public List<OP> getClassOperations(C c); // // public List<C> getClassSubtypes(List<C> classList, C c); // // public void getClassSubtypes(List<C> cList, C c, List<C> subTypes); // // public C getBaseClass(C c); // // public List<AS> getAssociations(); // // public List<String> getAssociationsNames(); // // public String getAssociationName(AS as); // // public String getAssociationEndName(AT asEnd); // // public List<String> getAssociationNamesOfNonAbsClasses(); // // public R getResource(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IOclParser.java // public interface IOclParser<CT, R> { // // CT parseOclConstraint(Object context, String key, String constraint); // // List<CT> parseOclDocument(IFile oclDocument, R modelResource) throws ProcessingException; // // List<CT> parseEmbeddedConstraints(R modelResource); // // List<CT> parseModelConstraints(R modelResource, IFile oclDocument) throws ProcessingException; // // List<String> getModelConstraintsNames(R modelResource, IFile oclDocument) throws ProcessingException; // // List<String> getModelInvariantNames(R modelResource, IFile oclDocument) throws ProcessingException; // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ProcessingException.java // public class ProcessingException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ProcessingException(Throwable e) { // super(e); // } // // public ProcessingException(String msg, Throwable th) { // super(msg, th); // } // // public ProcessingException(String string) { // super(string); // } // // }
import java.util.HashMap; import java.util.List; import java.util.Map; import org.eclipse.core.resources.IFile; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EOperation; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.ocl.ecore.Constraint; import fr.inria.atlanmod.emftocsp.ICspCodeGenerator; import fr.inria.atlanmod.emftocsp.IModelProperty; import fr.inria.atlanmod.emftocsp.IModelReader; import fr.inria.atlanmod.emftocsp.IOclParser; import fr.inria.atlanmod.emftocsp.ProcessingException;
/******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.emf.impl; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public abstract class EmfCspCodeGenerator implements ICspCodeGenerator<Resource, EPackage, EClass, EAssociation, EAttribute, EOperation, Constraint> { IModelReader<Resource, EPackage, EClass, EAssociation, EAttribute, EOperation> modelReader; IOclParser<Constraint, Resource> oclParser;
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ICspCodeGenerator.java // public interface ICspCodeGenerator<R, P, C, AS, AT, OP, CT> { // // void setModelReader(IModelReader<R, P, C, AS, AT, OP> modelReader); // // void setProperties(List<IModelProperty> properties); // // void setModelElementsDomains(Map<String, String> elementsDomain); // // void setOclParser(IOclParser<CT, R> oclParser); // // void setOclDocument(IFile oclDocument); // // void setModel(R modelResource); // // String getCspCode() throws ProcessingException; // // String getCspCodeFileExtension(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelProperty.java // public interface IModelProperty { // // void setName(String name); // // String getName(); // // void setTargetModelElementsNames(List<String> modelElementsNames); // // List<String> getTargetModelElementsNames(); // // String toString(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelReader.java // public interface IModelReader<R, P, C, AS, AT, OP> { // // public R getModelResource(); // // public List<P> getPackages(); // // public List<C> getClasses(); // // public List<String> getClassesNames(); // // public List<AT> getClassAttributes(C c); // // public List<OP> getClassOperations(C c); // // public List<C> getClassSubtypes(List<C> classList, C c); // // public void getClassSubtypes(List<C> cList, C c, List<C> subTypes); // // public C getBaseClass(C c); // // public List<AS> getAssociations(); // // public List<String> getAssociationsNames(); // // public String getAssociationName(AS as); // // public String getAssociationEndName(AT asEnd); // // public List<String> getAssociationNamesOfNonAbsClasses(); // // public R getResource(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IOclParser.java // public interface IOclParser<CT, R> { // // CT parseOclConstraint(Object context, String key, String constraint); // // List<CT> parseOclDocument(IFile oclDocument, R modelResource) throws ProcessingException; // // List<CT> parseEmbeddedConstraints(R modelResource); // // List<CT> parseModelConstraints(R modelResource, IFile oclDocument) throws ProcessingException; // // List<String> getModelConstraintsNames(R modelResource, IFile oclDocument) throws ProcessingException; // // List<String> getModelInvariantNames(R modelResource, IFile oclDocument) throws ProcessingException; // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ProcessingException.java // public class ProcessingException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ProcessingException(Throwable e) { // super(e); // } // // public ProcessingException(String msg, Throwable th) { // super(msg, th); // } // // public ProcessingException(String string) { // super(string); // } // // } // Path: plugins/fr.inria.atlanmod.emftocsp.emf/src/fr/inria/atlanmod/emftocsp/emf/impl/EmfCspCodeGenerator.java import java.util.HashMap; import java.util.List; import java.util.Map; import org.eclipse.core.resources.IFile; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EOperation; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.ocl.ecore.Constraint; import fr.inria.atlanmod.emftocsp.ICspCodeGenerator; import fr.inria.atlanmod.emftocsp.IModelProperty; import fr.inria.atlanmod.emftocsp.IModelReader; import fr.inria.atlanmod.emftocsp.IOclParser; import fr.inria.atlanmod.emftocsp.ProcessingException; /******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.emf.impl; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public abstract class EmfCspCodeGenerator implements ICspCodeGenerator<Resource, EPackage, EClass, EAssociation, EAttribute, EOperation, Constraint> { IModelReader<Resource, EPackage, EClass, EAssociation, EAttribute, EOperation> modelReader; IOclParser<Constraint, Resource> oclParser;
List <IModelProperty> properties;
SOM-Research/EMFtoCSP
plugins/fr.inria.atlanmod.emftocsp.emf/src/fr/inria/atlanmod/emftocsp/emf/impl/EmfCspCodeGenerator.java
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ICspCodeGenerator.java // public interface ICspCodeGenerator<R, P, C, AS, AT, OP, CT> { // // void setModelReader(IModelReader<R, P, C, AS, AT, OP> modelReader); // // void setProperties(List<IModelProperty> properties); // // void setModelElementsDomains(Map<String, String> elementsDomain); // // void setOclParser(IOclParser<CT, R> oclParser); // // void setOclDocument(IFile oclDocument); // // void setModel(R modelResource); // // String getCspCode() throws ProcessingException; // // String getCspCodeFileExtension(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelProperty.java // public interface IModelProperty { // // void setName(String name); // // String getName(); // // void setTargetModelElementsNames(List<String> modelElementsNames); // // List<String> getTargetModelElementsNames(); // // String toString(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelReader.java // public interface IModelReader<R, P, C, AS, AT, OP> { // // public R getModelResource(); // // public List<P> getPackages(); // // public List<C> getClasses(); // // public List<String> getClassesNames(); // // public List<AT> getClassAttributes(C c); // // public List<OP> getClassOperations(C c); // // public List<C> getClassSubtypes(List<C> classList, C c); // // public void getClassSubtypes(List<C> cList, C c, List<C> subTypes); // // public C getBaseClass(C c); // // public List<AS> getAssociations(); // // public List<String> getAssociationsNames(); // // public String getAssociationName(AS as); // // public String getAssociationEndName(AT asEnd); // // public List<String> getAssociationNamesOfNonAbsClasses(); // // public R getResource(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IOclParser.java // public interface IOclParser<CT, R> { // // CT parseOclConstraint(Object context, String key, String constraint); // // List<CT> parseOclDocument(IFile oclDocument, R modelResource) throws ProcessingException; // // List<CT> parseEmbeddedConstraints(R modelResource); // // List<CT> parseModelConstraints(R modelResource, IFile oclDocument) throws ProcessingException; // // List<String> getModelConstraintsNames(R modelResource, IFile oclDocument) throws ProcessingException; // // List<String> getModelInvariantNames(R modelResource, IFile oclDocument) throws ProcessingException; // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ProcessingException.java // public class ProcessingException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ProcessingException(Throwable e) { // super(e); // } // // public ProcessingException(String msg, Throwable th) { // super(msg, th); // } // // public ProcessingException(String string) { // super(string); // } // // }
import java.util.HashMap; import java.util.List; import java.util.Map; import org.eclipse.core.resources.IFile; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EOperation; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.ocl.ecore.Constraint; import fr.inria.atlanmod.emftocsp.ICspCodeGenerator; import fr.inria.atlanmod.emftocsp.IModelProperty; import fr.inria.atlanmod.emftocsp.IModelReader; import fr.inria.atlanmod.emftocsp.IOclParser; import fr.inria.atlanmod.emftocsp.ProcessingException;
} @Override public void setOclParser(IOclParser<Constraint, Resource> oclParser) { this.oclParser = oclParser; } protected IOclParser<Constraint, Resource> getOclParser() { return oclParser; } @Override public void setOclDocument(IFile oclDocument) { this.oclDocument = oclDocument; } protected IFile getOclDocument() { return oclDocument; } @Override public void setModel(Resource modelResource) { this.modelResource = modelResource; } protected Resource getModel() { return modelResource; } @Override
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ICspCodeGenerator.java // public interface ICspCodeGenerator<R, P, C, AS, AT, OP, CT> { // // void setModelReader(IModelReader<R, P, C, AS, AT, OP> modelReader); // // void setProperties(List<IModelProperty> properties); // // void setModelElementsDomains(Map<String, String> elementsDomain); // // void setOclParser(IOclParser<CT, R> oclParser); // // void setOclDocument(IFile oclDocument); // // void setModel(R modelResource); // // String getCspCode() throws ProcessingException; // // String getCspCodeFileExtension(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelProperty.java // public interface IModelProperty { // // void setName(String name); // // String getName(); // // void setTargetModelElementsNames(List<String> modelElementsNames); // // List<String> getTargetModelElementsNames(); // // String toString(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelReader.java // public interface IModelReader<R, P, C, AS, AT, OP> { // // public R getModelResource(); // // public List<P> getPackages(); // // public List<C> getClasses(); // // public List<String> getClassesNames(); // // public List<AT> getClassAttributes(C c); // // public List<OP> getClassOperations(C c); // // public List<C> getClassSubtypes(List<C> classList, C c); // // public void getClassSubtypes(List<C> cList, C c, List<C> subTypes); // // public C getBaseClass(C c); // // public List<AS> getAssociations(); // // public List<String> getAssociationsNames(); // // public String getAssociationName(AS as); // // public String getAssociationEndName(AT asEnd); // // public List<String> getAssociationNamesOfNonAbsClasses(); // // public R getResource(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IOclParser.java // public interface IOclParser<CT, R> { // // CT parseOclConstraint(Object context, String key, String constraint); // // List<CT> parseOclDocument(IFile oclDocument, R modelResource) throws ProcessingException; // // List<CT> parseEmbeddedConstraints(R modelResource); // // List<CT> parseModelConstraints(R modelResource, IFile oclDocument) throws ProcessingException; // // List<String> getModelConstraintsNames(R modelResource, IFile oclDocument) throws ProcessingException; // // List<String> getModelInvariantNames(R modelResource, IFile oclDocument) throws ProcessingException; // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ProcessingException.java // public class ProcessingException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ProcessingException(Throwable e) { // super(e); // } // // public ProcessingException(String msg, Throwable th) { // super(msg, th); // } // // public ProcessingException(String string) { // super(string); // } // // } // Path: plugins/fr.inria.atlanmod.emftocsp.emf/src/fr/inria/atlanmod/emftocsp/emf/impl/EmfCspCodeGenerator.java import java.util.HashMap; import java.util.List; import java.util.Map; import org.eclipse.core.resources.IFile; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EOperation; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.ocl.ecore.Constraint; import fr.inria.atlanmod.emftocsp.ICspCodeGenerator; import fr.inria.atlanmod.emftocsp.IModelProperty; import fr.inria.atlanmod.emftocsp.IModelReader; import fr.inria.atlanmod.emftocsp.IOclParser; import fr.inria.atlanmod.emftocsp.ProcessingException; } @Override public void setOclParser(IOclParser<Constraint, Resource> oclParser) { this.oclParser = oclParser; } protected IOclParser<Constraint, Resource> getOclParser() { return oclParser; } @Override public void setOclDocument(IFile oclDocument) { this.oclDocument = oclDocument; } protected IFile getOclDocument() { return oclDocument; } @Override public void setModel(Resource modelResource) { this.modelResource = modelResource; } protected Resource getModel() { return modelResource; } @Override
public abstract String getCspCode() throws ProcessingException;
SOM-Research/EMFtoCSP
plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/wizards/impl/ResultLocationSelectionPage.java
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelToCspSolver.java // public interface IModelToCspSolver<R,ST> { // // public void setModel(R modelResource); // // public R getModel(); // // public void setModelFileName(String filename); // // public String getModelFileName(); // // public String getModelLocation(); // // public IModelReader<R, ?, ?, ?, ?, ?> getModelReader(); // // public IOclParser<?, R> getOclParser(); // // public void setCspCodeGenerator(ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> cspCodeGenerator); // // public ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> getCspCodeGenerator(); // // public void setConstraintsDocument(IFile constraintsDocument); // // public IFile getConstraintsDocument(); // // public void setModelElementsDomain(Map<String, String> modelDomain); // // public Map<String, String> getModelElementsDomain(); // // public void setResultLocation(IFolder resultLocation); // // public IFolder getResultLocation(); // // public void setModelProperties(List<IModelProperty> modelProperties); // // public List<IModelProperty> getModelProperties(); // // public void setSolver(ICspSolver solver); // // public ICspSolver getSolver(); // // public boolean solveModel() throws ProcessingException ; // // public boolean solveModel(List<File> importLibs) throws ProcessingException ; // // public Object getSolverEvaluationResult(); // // public void setLogger(ILogger logger); // // public ILogger getLogger(); // // IModelBuilder<R, ?, ?, ?, ?, ?, ST> getBuilder(); // // void setBuilder(IModelBuilder<R, ?, ?, ?, ?, ?, ST> builder); // // void setConstraintsDocument(URI fileURI) throws CoreException; // // public void setConstraintsDocumentToNull(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/widgets/IElementSelectionWidget.java // public interface IElementSelectionWidget { // // Object getElementSelected(); // // boolean isInSelectionMode(); // // boolean isSelectedElementValid(); // }
import java.util.Collection; import org.eclipse.core.resources.IFolder; import org.eclipse.jface.viewers.IStructuredSelection; import fr.inria.atlanmod.emftocsp.IModelToCspSolver; import fr.inria.atlanmod.emftocsp.ui.widgets.IElementSelectionWidget;
/******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.ui.wizards.impl; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public class ResultLocationSelectionPage extends SelectionPage { IModelToCspSolver<?,?> modelSolver; public ResultLocationSelectionPage(String pageName, String description, IStructuredSelection selection, Collection<String> allowedTypes, IModelToCspSolver<?,?> modelSolver) { super(pageName,description, selection, allowedTypes); this.modelSolver = modelSolver; } public ResultLocationSelectionPage(String pageName, String description, IStructuredSelection selection, Collection<String> allowedTypes, boolean mandatorySelection, IModelToCspSolver<?,?> modelSolver) { super(pageName,description, selection, allowedTypes, mandatorySelection); this.modelSolver = modelSolver; } @Override
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelToCspSolver.java // public interface IModelToCspSolver<R,ST> { // // public void setModel(R modelResource); // // public R getModel(); // // public void setModelFileName(String filename); // // public String getModelFileName(); // // public String getModelLocation(); // // public IModelReader<R, ?, ?, ?, ?, ?> getModelReader(); // // public IOclParser<?, R> getOclParser(); // // public void setCspCodeGenerator(ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> cspCodeGenerator); // // public ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> getCspCodeGenerator(); // // public void setConstraintsDocument(IFile constraintsDocument); // // public IFile getConstraintsDocument(); // // public void setModelElementsDomain(Map<String, String> modelDomain); // // public Map<String, String> getModelElementsDomain(); // // public void setResultLocation(IFolder resultLocation); // // public IFolder getResultLocation(); // // public void setModelProperties(List<IModelProperty> modelProperties); // // public List<IModelProperty> getModelProperties(); // // public void setSolver(ICspSolver solver); // // public ICspSolver getSolver(); // // public boolean solveModel() throws ProcessingException ; // // public boolean solveModel(List<File> importLibs) throws ProcessingException ; // // public Object getSolverEvaluationResult(); // // public void setLogger(ILogger logger); // // public ILogger getLogger(); // // IModelBuilder<R, ?, ?, ?, ?, ?, ST> getBuilder(); // // void setBuilder(IModelBuilder<R, ?, ?, ?, ?, ?, ST> builder); // // void setConstraintsDocument(URI fileURI) throws CoreException; // // public void setConstraintsDocumentToNull(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/widgets/IElementSelectionWidget.java // public interface IElementSelectionWidget { // // Object getElementSelected(); // // boolean isInSelectionMode(); // // boolean isSelectedElementValid(); // } // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/wizards/impl/ResultLocationSelectionPage.java import java.util.Collection; import org.eclipse.core.resources.IFolder; import org.eclipse.jface.viewers.IStructuredSelection; import fr.inria.atlanmod.emftocsp.IModelToCspSolver; import fr.inria.atlanmod.emftocsp.ui.widgets.IElementSelectionWidget; /******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.ui.wizards.impl; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public class ResultLocationSelectionPage extends SelectionPage { IModelToCspSolver<?,?> modelSolver; public ResultLocationSelectionPage(String pageName, String description, IStructuredSelection selection, Collection<String> allowedTypes, IModelToCspSolver<?,?> modelSolver) { super(pageName,description, selection, allowedTypes); this.modelSolver = modelSolver; } public ResultLocationSelectionPage(String pageName, String description, IStructuredSelection selection, Collection<String> allowedTypes, boolean mandatorySelection, IModelToCspSolver<?,?> modelSolver) { super(pageName,description, selection, allowedTypes, mandatorySelection); this.modelSolver = modelSolver; } @Override
public void elementSelectionWidgetChanged(IElementSelectionWidget esWidget) {
SOM-Research/EMFtoCSP
plugins/fr.inria.atlanmod.emftocsp.eclipsecs/src/fr/inria/atlanmod/emftocsp/eclipsecs/EclipseSolver.java
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ICspSolver.java // public interface ICspSolver <ST> { // // public boolean solveCSP(File srcFile, List<File> libs) throws ProcessingException; // // public boolean solveCSP(File srcFile) throws ProcessingException; // // public Object getResult(); // // public ST getSolution(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ProcessingException.java // public class ProcessingException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ProcessingException(Throwable e) { // super(e); // } // // public ProcessingException(String msg, Throwable th) { // super(msg, th); // } // // public ProcessingException(String string) { // super(string); // } // // }
import java.io.File; import java.io.IOException; import java.util.List; import com.parctechnologies.eclipse.CompoundTerm; import com.parctechnologies.eclipse.EclipseEngine; import com.parctechnologies.eclipse.EclipseEngineOptions; import com.parctechnologies.eclipse.EclipseException; import com.parctechnologies.eclipse.Fail; import com.parctechnologies.eclipse.OutOfProcessEclipse; import com.parctechnologies.eclipse.Throw; import fr.inria.atlanmod.emftocsp.ICspSolver; import fr.inria.atlanmod.emftocsp.ProcessingException;
/******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.eclipsecs; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public class EclipseSolver implements ICspSolver <CompoundTerm>{ private String imgGeneratorPath = ""; //$NON-NLS-1$ private File imgResult; private EclipseEngineOptions engineOptions = null; private EclipseEngine engine = null; private CompoundTerm solution = null; @Override public CompoundTerm getSolution(){ return solution; } public EclipseSolver(String solverPath, String imgGeneratorPath) { this.imgGeneratorPath = imgGeneratorPath; engineOptions = new EclipseEngineOptions(new File(solverPath)); engineOptions.setUseQueues(false); } @Override
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ICspSolver.java // public interface ICspSolver <ST> { // // public boolean solveCSP(File srcFile, List<File> libs) throws ProcessingException; // // public boolean solveCSP(File srcFile) throws ProcessingException; // // public Object getResult(); // // public ST getSolution(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ProcessingException.java // public class ProcessingException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ProcessingException(Throwable e) { // super(e); // } // // public ProcessingException(String msg, Throwable th) { // super(msg, th); // } // // public ProcessingException(String string) { // super(string); // } // // } // Path: plugins/fr.inria.atlanmod.emftocsp.eclipsecs/src/fr/inria/atlanmod/emftocsp/eclipsecs/EclipseSolver.java import java.io.File; import java.io.IOException; import java.util.List; import com.parctechnologies.eclipse.CompoundTerm; import com.parctechnologies.eclipse.EclipseEngine; import com.parctechnologies.eclipse.EclipseEngineOptions; import com.parctechnologies.eclipse.EclipseException; import com.parctechnologies.eclipse.Fail; import com.parctechnologies.eclipse.OutOfProcessEclipse; import com.parctechnologies.eclipse.Throw; import fr.inria.atlanmod.emftocsp.ICspSolver; import fr.inria.atlanmod.emftocsp.ProcessingException; /******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.eclipsecs; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public class EclipseSolver implements ICspSolver <CompoundTerm>{ private String imgGeneratorPath = ""; //$NON-NLS-1$ private File imgResult; private EclipseEngineOptions engineOptions = null; private EclipseEngine engine = null; private CompoundTerm solution = null; @Override public CompoundTerm getSolution(){ return solution; } public EclipseSolver(String solverPath, String imgGeneratorPath) { this.imgGeneratorPath = imgGeneratorPath; engineOptions = new EclipseEngineOptions(new File(solverPath)); engineOptions.setUseQueues(false); } @Override
public boolean solveCSP(File srcFile) throws ProcessingException {
SOM-Research/EMFtoCSP
plugins/fr.inria.atlanmod.emftocsp.emf/src/fr/inria/atlanmod/emftocsp/emf/impl/EmfModelToCspSolverFactory.java
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelToCspSolver.java // public interface IModelToCspSolver<R,ST> { // // public void setModel(R modelResource); // // public R getModel(); // // public void setModelFileName(String filename); // // public String getModelFileName(); // // public String getModelLocation(); // // public IModelReader<R, ?, ?, ?, ?, ?> getModelReader(); // // public IOclParser<?, R> getOclParser(); // // public void setCspCodeGenerator(ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> cspCodeGenerator); // // public ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> getCspCodeGenerator(); // // public void setConstraintsDocument(IFile constraintsDocument); // // public IFile getConstraintsDocument(); // // public void setModelElementsDomain(Map<String, String> modelDomain); // // public Map<String, String> getModelElementsDomain(); // // public void setResultLocation(IFolder resultLocation); // // public IFolder getResultLocation(); // // public void setModelProperties(List<IModelProperty> modelProperties); // // public List<IModelProperty> getModelProperties(); // // public void setSolver(ICspSolver solver); // // public ICspSolver getSolver(); // // public boolean solveModel() throws ProcessingException ; // // public boolean solveModel(List<File> importLibs) throws ProcessingException ; // // public Object getSolverEvaluationResult(); // // public void setLogger(ILogger logger); // // public ILogger getLogger(); // // IModelBuilder<R, ?, ?, ?, ?, ?, ST> getBuilder(); // // void setBuilder(IModelBuilder<R, ?, ?, ?, ?, ?, ST> builder); // // void setConstraintsDocument(URI fileURI) throws CoreException; // // public void setConstraintsDocumentToNull(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp.emf/src/fr/inria/atlanmod/emftocsp/emf/IEmfModelToCspSolverFactory.java // public interface IEmfModelToCspSolverFactory extends IModelToCspSolverFactory<Resource,CompoundTerm> { // // }
import fr.inria.atlanmod.emftocsp.IModelToCspSolver; import fr.inria.atlanmod.emftocsp.emf.IEmfModelToCspSolverFactory; import org.eclipse.emf.ecore.resource.Resource; import com.parctechnologies.eclipse.CompoundTerm;
/******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.emf.impl; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public class EmfModelToCspSolverFactory implements IEmfModelToCspSolverFactory { @Override
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelToCspSolver.java // public interface IModelToCspSolver<R,ST> { // // public void setModel(R modelResource); // // public R getModel(); // // public void setModelFileName(String filename); // // public String getModelFileName(); // // public String getModelLocation(); // // public IModelReader<R, ?, ?, ?, ?, ?> getModelReader(); // // public IOclParser<?, R> getOclParser(); // // public void setCspCodeGenerator(ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> cspCodeGenerator); // // public ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> getCspCodeGenerator(); // // public void setConstraintsDocument(IFile constraintsDocument); // // public IFile getConstraintsDocument(); // // public void setModelElementsDomain(Map<String, String> modelDomain); // // public Map<String, String> getModelElementsDomain(); // // public void setResultLocation(IFolder resultLocation); // // public IFolder getResultLocation(); // // public void setModelProperties(List<IModelProperty> modelProperties); // // public List<IModelProperty> getModelProperties(); // // public void setSolver(ICspSolver solver); // // public ICspSolver getSolver(); // // public boolean solveModel() throws ProcessingException ; // // public boolean solveModel(List<File> importLibs) throws ProcessingException ; // // public Object getSolverEvaluationResult(); // // public void setLogger(ILogger logger); // // public ILogger getLogger(); // // IModelBuilder<R, ?, ?, ?, ?, ?, ST> getBuilder(); // // void setBuilder(IModelBuilder<R, ?, ?, ?, ?, ?, ST> builder); // // void setConstraintsDocument(URI fileURI) throws CoreException; // // public void setConstraintsDocumentToNull(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp.emf/src/fr/inria/atlanmod/emftocsp/emf/IEmfModelToCspSolverFactory.java // public interface IEmfModelToCspSolverFactory extends IModelToCspSolverFactory<Resource,CompoundTerm> { // // } // Path: plugins/fr.inria.atlanmod.emftocsp.emf/src/fr/inria/atlanmod/emftocsp/emf/impl/EmfModelToCspSolverFactory.java import fr.inria.atlanmod.emftocsp.IModelToCspSolver; import fr.inria.atlanmod.emftocsp.emf.IEmfModelToCspSolverFactory; import org.eclipse.emf.ecore.resource.Resource; import com.parctechnologies.eclipse.CompoundTerm; /******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.emf.impl; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public class EmfModelToCspSolverFactory implements IEmfModelToCspSolverFactory { @Override
public IModelToCspSolver<Resource,CompoundTerm> getModelToCspSolver() {
SOM-Research/EMFtoCSP
plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/widgets/impl/ElementSelectionWidget.java
// Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/widgets/IElementSelectionWidget.java // public interface IElementSelectionWidget { // // Object getElementSelected(); // // boolean isInSelectionMode(); // // boolean isSelectedElementValid(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/widgets/IElementSelectionWidgetListener.java // public interface IElementSelectionWidgetListener { // // void elementSelectionWidgetChanged(IElementSelectionWidget widget); // // }
import java.util.Collection; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.internal.ui.viewsupport.AppearanceAwareLabelProvider; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.part.DrillDownComposite; import fr.inria.atlanmod.emftocsp.ui.widgets.IElementSelectionWidget; import fr.inria.atlanmod.emftocsp.ui.widgets.IElementSelectionWidgetListener;
class TreeLabelProvider extends AppearanceAwareLabelProvider { public void addListener(ILabelProviderListener listener) { } public void dispose() { } public boolean isLabelProperty(Object element, String property) { return false; } public void removeListener(ILabelProviderListener listener) { } public Image getImage(Object element) { return super.getImage(element); //Discourage access } public String getText(Object element) { if (IResource.class.isInstance(element)) return ((IResource)element).getName(); return ""; //$NON-NLS-1$ } } private TreeViewer treeViewer; private Button chkDisableSelection = null; private IStructuredSelection selection; private Collection<String> allowedTypes;
// Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/widgets/IElementSelectionWidget.java // public interface IElementSelectionWidget { // // Object getElementSelected(); // // boolean isInSelectionMode(); // // boolean isSelectedElementValid(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/widgets/IElementSelectionWidgetListener.java // public interface IElementSelectionWidgetListener { // // void elementSelectionWidgetChanged(IElementSelectionWidget widget); // // } // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/widgets/impl/ElementSelectionWidget.java import java.util.Collection; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.internal.ui.viewsupport.AppearanceAwareLabelProvider; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.part.DrillDownComposite; import fr.inria.atlanmod.emftocsp.ui.widgets.IElementSelectionWidget; import fr.inria.atlanmod.emftocsp.ui.widgets.IElementSelectionWidgetListener; class TreeLabelProvider extends AppearanceAwareLabelProvider { public void addListener(ILabelProviderListener listener) { } public void dispose() { } public boolean isLabelProperty(Object element, String property) { return false; } public void removeListener(ILabelProviderListener listener) { } public Image getImage(Object element) { return super.getImage(element); //Discourage access } public String getText(Object element) { if (IResource.class.isInstance(element)) return ((IResource)element).getName(); return ""; //$NON-NLS-1$ } } private TreeViewer treeViewer; private Button chkDisableSelection = null; private IStructuredSelection selection; private Collection<String> allowedTypes;
private IElementSelectionWidgetListener listener;
SOM-Research/EMFtoCSP
plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/wizards/impl/ModelWizardNavigation.java
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelToCspSolver.java // public interface IModelToCspSolver<R,ST> { // // public void setModel(R modelResource); // // public R getModel(); // // public void setModelFileName(String filename); // // public String getModelFileName(); // // public String getModelLocation(); // // public IModelReader<R, ?, ?, ?, ?, ?> getModelReader(); // // public IOclParser<?, R> getOclParser(); // // public void setCspCodeGenerator(ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> cspCodeGenerator); // // public ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> getCspCodeGenerator(); // // public void setConstraintsDocument(IFile constraintsDocument); // // public IFile getConstraintsDocument(); // // public void setModelElementsDomain(Map<String, String> modelDomain); // // public Map<String, String> getModelElementsDomain(); // // public void setResultLocation(IFolder resultLocation); // // public IFolder getResultLocation(); // // public void setModelProperties(List<IModelProperty> modelProperties); // // public List<IModelProperty> getModelProperties(); // // public void setSolver(ICspSolver solver); // // public ICspSolver getSolver(); // // public boolean solveModel() throws ProcessingException ; // // public boolean solveModel(List<File> importLibs) throws ProcessingException ; // // public Object getSolverEvaluationResult(); // // public void setLogger(ILogger logger); // // public ILogger getLogger(); // // IModelBuilder<R, ?, ?, ?, ?, ?, ST> getBuilder(); // // void setBuilder(IModelBuilder<R, ?, ?, ?, ?, ?, ST> builder); // // void setConstraintsDocument(URI fileURI) throws CoreException; // // public void setConstraintsDocumentToNull(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/messages/Messages.java // public class Messages extends NLS { // private static final String BUNDLE_NAME = "fr.inria.atlanmod.emftocsp.ui.messages.messages"; //$NON-NLS-1$ // public static String ModelElementDomainPage_0; // public static String ModelWizardNavigation_0; // public static String ModelWizardNavigation_1; // public static String ModelWizardNavigation_2; // public static String ModelWizardNavigation_3; // public static String PropertiesSelectionPage_0; // public static String ValidationWizard_0; // public static String ValidationWizard_1; // public static String ValidationWizard_2; // public static String ValidationWizard_3; // public static String ValidationWizard_4; // public static String ValidationWizard_5; // static { // // initialize resource bundle // NLS.initializeMessages(BUNDLE_NAME, Messages.class); // } // // private Messages() { // } // } // // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/wizards/IWizardNavigation.java // public interface IWizardNavigation { // // IWizardPage[] getWizardPages(); // }
import java.util.ArrayList; import java.util.Arrays; import org.eclipse.jface.wizard.IWizardPage; import fr.inria.atlanmod.emftocsp.IModelToCspSolver; import fr.inria.atlanmod.emftocsp.ui.messages.Messages; import fr.inria.atlanmod.emftocsp.ui.wizards.IWizardNavigation;
/******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.ui.wizards.impl; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public class ModelWizardNavigation implements IWizardNavigation { IWizardPage[] wizardPages = new IWizardPage[4];
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelToCspSolver.java // public interface IModelToCspSolver<R,ST> { // // public void setModel(R modelResource); // // public R getModel(); // // public void setModelFileName(String filename); // // public String getModelFileName(); // // public String getModelLocation(); // // public IModelReader<R, ?, ?, ?, ?, ?> getModelReader(); // // public IOclParser<?, R> getOclParser(); // // public void setCspCodeGenerator(ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> cspCodeGenerator); // // public ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> getCspCodeGenerator(); // // public void setConstraintsDocument(IFile constraintsDocument); // // public IFile getConstraintsDocument(); // // public void setModelElementsDomain(Map<String, String> modelDomain); // // public Map<String, String> getModelElementsDomain(); // // public void setResultLocation(IFolder resultLocation); // // public IFolder getResultLocation(); // // public void setModelProperties(List<IModelProperty> modelProperties); // // public List<IModelProperty> getModelProperties(); // // public void setSolver(ICspSolver solver); // // public ICspSolver getSolver(); // // public boolean solveModel() throws ProcessingException ; // // public boolean solveModel(List<File> importLibs) throws ProcessingException ; // // public Object getSolverEvaluationResult(); // // public void setLogger(ILogger logger); // // public ILogger getLogger(); // // IModelBuilder<R, ?, ?, ?, ?, ?, ST> getBuilder(); // // void setBuilder(IModelBuilder<R, ?, ?, ?, ?, ?, ST> builder); // // void setConstraintsDocument(URI fileURI) throws CoreException; // // public void setConstraintsDocumentToNull(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/messages/Messages.java // public class Messages extends NLS { // private static final String BUNDLE_NAME = "fr.inria.atlanmod.emftocsp.ui.messages.messages"; //$NON-NLS-1$ // public static String ModelElementDomainPage_0; // public static String ModelWizardNavigation_0; // public static String ModelWizardNavigation_1; // public static String ModelWizardNavigation_2; // public static String ModelWizardNavigation_3; // public static String PropertiesSelectionPage_0; // public static String ValidationWizard_0; // public static String ValidationWizard_1; // public static String ValidationWizard_2; // public static String ValidationWizard_3; // public static String ValidationWizard_4; // public static String ValidationWizard_5; // static { // // initialize resource bundle // NLS.initializeMessages(BUNDLE_NAME, Messages.class); // } // // private Messages() { // } // } // // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/wizards/IWizardNavigation.java // public interface IWizardNavigation { // // IWizardPage[] getWizardPages(); // } // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/wizards/impl/ModelWizardNavigation.java import java.util.ArrayList; import java.util.Arrays; import org.eclipse.jface.wizard.IWizardPage; import fr.inria.atlanmod.emftocsp.IModelToCspSolver; import fr.inria.atlanmod.emftocsp.ui.messages.Messages; import fr.inria.atlanmod.emftocsp.ui.wizards.IWizardNavigation; /******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.ui.wizards.impl; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public class ModelWizardNavigation implements IWizardNavigation { IWizardPage[] wizardPages = new IWizardPage[4];
public ModelWizardNavigation(IModelToCspSolver<?,?> modelSolver) {
SOM-Research/EMFtoCSP
plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/wizards/impl/ModelWizardNavigation.java
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelToCspSolver.java // public interface IModelToCspSolver<R,ST> { // // public void setModel(R modelResource); // // public R getModel(); // // public void setModelFileName(String filename); // // public String getModelFileName(); // // public String getModelLocation(); // // public IModelReader<R, ?, ?, ?, ?, ?> getModelReader(); // // public IOclParser<?, R> getOclParser(); // // public void setCspCodeGenerator(ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> cspCodeGenerator); // // public ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> getCspCodeGenerator(); // // public void setConstraintsDocument(IFile constraintsDocument); // // public IFile getConstraintsDocument(); // // public void setModelElementsDomain(Map<String, String> modelDomain); // // public Map<String, String> getModelElementsDomain(); // // public void setResultLocation(IFolder resultLocation); // // public IFolder getResultLocation(); // // public void setModelProperties(List<IModelProperty> modelProperties); // // public List<IModelProperty> getModelProperties(); // // public void setSolver(ICspSolver solver); // // public ICspSolver getSolver(); // // public boolean solveModel() throws ProcessingException ; // // public boolean solveModel(List<File> importLibs) throws ProcessingException ; // // public Object getSolverEvaluationResult(); // // public void setLogger(ILogger logger); // // public ILogger getLogger(); // // IModelBuilder<R, ?, ?, ?, ?, ?, ST> getBuilder(); // // void setBuilder(IModelBuilder<R, ?, ?, ?, ?, ?, ST> builder); // // void setConstraintsDocument(URI fileURI) throws CoreException; // // public void setConstraintsDocumentToNull(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/messages/Messages.java // public class Messages extends NLS { // private static final String BUNDLE_NAME = "fr.inria.atlanmod.emftocsp.ui.messages.messages"; //$NON-NLS-1$ // public static String ModelElementDomainPage_0; // public static String ModelWizardNavigation_0; // public static String ModelWizardNavigation_1; // public static String ModelWizardNavigation_2; // public static String ModelWizardNavigation_3; // public static String PropertiesSelectionPage_0; // public static String ValidationWizard_0; // public static String ValidationWizard_1; // public static String ValidationWizard_2; // public static String ValidationWizard_3; // public static String ValidationWizard_4; // public static String ValidationWizard_5; // static { // // initialize resource bundle // NLS.initializeMessages(BUNDLE_NAME, Messages.class); // } // // private Messages() { // } // } // // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/wizards/IWizardNavigation.java // public interface IWizardNavigation { // // IWizardPage[] getWizardPages(); // }
import java.util.ArrayList; import java.util.Arrays; import org.eclipse.jface.wizard.IWizardPage; import fr.inria.atlanmod.emftocsp.IModelToCspSolver; import fr.inria.atlanmod.emftocsp.ui.messages.Messages; import fr.inria.atlanmod.emftocsp.ui.wizards.IWizardNavigation;
/******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.ui.wizards.impl; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public class ModelWizardNavigation implements IWizardNavigation { IWizardPage[] wizardPages = new IWizardPage[4]; public ModelWizardNavigation(IModelToCspSolver<?,?> modelSolver) {
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelToCspSolver.java // public interface IModelToCspSolver<R,ST> { // // public void setModel(R modelResource); // // public R getModel(); // // public void setModelFileName(String filename); // // public String getModelFileName(); // // public String getModelLocation(); // // public IModelReader<R, ?, ?, ?, ?, ?> getModelReader(); // // public IOclParser<?, R> getOclParser(); // // public void setCspCodeGenerator(ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> cspCodeGenerator); // // public ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> getCspCodeGenerator(); // // public void setConstraintsDocument(IFile constraintsDocument); // // public IFile getConstraintsDocument(); // // public void setModelElementsDomain(Map<String, String> modelDomain); // // public Map<String, String> getModelElementsDomain(); // // public void setResultLocation(IFolder resultLocation); // // public IFolder getResultLocation(); // // public void setModelProperties(List<IModelProperty> modelProperties); // // public List<IModelProperty> getModelProperties(); // // public void setSolver(ICspSolver solver); // // public ICspSolver getSolver(); // // public boolean solveModel() throws ProcessingException ; // // public boolean solveModel(List<File> importLibs) throws ProcessingException ; // // public Object getSolverEvaluationResult(); // // public void setLogger(ILogger logger); // // public ILogger getLogger(); // // IModelBuilder<R, ?, ?, ?, ?, ?, ST> getBuilder(); // // void setBuilder(IModelBuilder<R, ?, ?, ?, ?, ?, ST> builder); // // void setConstraintsDocument(URI fileURI) throws CoreException; // // public void setConstraintsDocumentToNull(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/messages/Messages.java // public class Messages extends NLS { // private static final String BUNDLE_NAME = "fr.inria.atlanmod.emftocsp.ui.messages.messages"; //$NON-NLS-1$ // public static String ModelElementDomainPage_0; // public static String ModelWizardNavigation_0; // public static String ModelWizardNavigation_1; // public static String ModelWizardNavigation_2; // public static String ModelWizardNavigation_3; // public static String PropertiesSelectionPage_0; // public static String ValidationWizard_0; // public static String ValidationWizard_1; // public static String ValidationWizard_2; // public static String ValidationWizard_3; // public static String ValidationWizard_4; // public static String ValidationWizard_5; // static { // // initialize resource bundle // NLS.initializeMessages(BUNDLE_NAME, Messages.class); // } // // private Messages() { // } // } // // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/wizards/IWizardNavigation.java // public interface IWizardNavigation { // // IWizardPage[] getWizardPages(); // } // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/wizards/impl/ModelWizardNavigation.java import java.util.ArrayList; import java.util.Arrays; import org.eclipse.jface.wizard.IWizardPage; import fr.inria.atlanmod.emftocsp.IModelToCspSolver; import fr.inria.atlanmod.emftocsp.ui.messages.Messages; import fr.inria.atlanmod.emftocsp.ui.wizards.IWizardNavigation; /******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.ui.wizards.impl; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public class ModelWizardNavigation implements IWizardNavigation { IWizardPage[] wizardPages = new IWizardPage[4]; public ModelWizardNavigation(IModelToCspSolver<?,?> modelSolver) {
wizardPages[0] = new OclFileSelectionPage("OCL constraints selection", Messages.ModelWizardNavigation_0, null, new ArrayList<String>(Arrays.asList("ocl")), false, modelSolver); //$NON-NLS-3$ //$NON-NLS-1$
SOM-Research/EMFtoCSP
plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/wizards/impl/OclFileSelectionPage.java
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelToCspSolver.java // public interface IModelToCspSolver<R,ST> { // // public void setModel(R modelResource); // // public R getModel(); // // public void setModelFileName(String filename); // // public String getModelFileName(); // // public String getModelLocation(); // // public IModelReader<R, ?, ?, ?, ?, ?> getModelReader(); // // public IOclParser<?, R> getOclParser(); // // public void setCspCodeGenerator(ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> cspCodeGenerator); // // public ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> getCspCodeGenerator(); // // public void setConstraintsDocument(IFile constraintsDocument); // // public IFile getConstraintsDocument(); // // public void setModelElementsDomain(Map<String, String> modelDomain); // // public Map<String, String> getModelElementsDomain(); // // public void setResultLocation(IFolder resultLocation); // // public IFolder getResultLocation(); // // public void setModelProperties(List<IModelProperty> modelProperties); // // public List<IModelProperty> getModelProperties(); // // public void setSolver(ICspSolver solver); // // public ICspSolver getSolver(); // // public boolean solveModel() throws ProcessingException ; // // public boolean solveModel(List<File> importLibs) throws ProcessingException ; // // public Object getSolverEvaluationResult(); // // public void setLogger(ILogger logger); // // public ILogger getLogger(); // // IModelBuilder<R, ?, ?, ?, ?, ?, ST> getBuilder(); // // void setBuilder(IModelBuilder<R, ?, ?, ?, ?, ?, ST> builder); // // void setConstraintsDocument(URI fileURI) throws CoreException; // // public void setConstraintsDocumentToNull(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/widgets/IElementSelectionWidget.java // public interface IElementSelectionWidget { // // Object getElementSelected(); // // boolean isInSelectionMode(); // // boolean isSelectedElementValid(); // }
import java.util.Collection; import org.eclipse.core.resources.IFile; import org.eclipse.jface.viewers.IStructuredSelection; import fr.inria.atlanmod.emftocsp.IModelToCspSolver; import fr.inria.atlanmod.emftocsp.ui.widgets.IElementSelectionWidget;
/******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.ui.wizards.impl; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public class OclFileSelectionPage extends SelectionPage { IModelToCspSolver<?,?> modelSolver; public OclFileSelectionPage(String pageName, String description, IStructuredSelection selection, Collection<String> allowedTypes, IModelToCspSolver<?,?> modelSolver) { super(pageName,description, selection, allowedTypes); this.modelSolver = modelSolver; } public OclFileSelectionPage(String pageName, String description, IStructuredSelection selection, Collection<String> allowedTypes, boolean mandatorySelection, IModelToCspSolver<?,?> modelSolver) { super(pageName,description, selection, allowedTypes, mandatorySelection); this.modelSolver = modelSolver; } @Override
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/IModelToCspSolver.java // public interface IModelToCspSolver<R,ST> { // // public void setModel(R modelResource); // // public R getModel(); // // public void setModelFileName(String filename); // // public String getModelFileName(); // // public String getModelLocation(); // // public IModelReader<R, ?, ?, ?, ?, ?> getModelReader(); // // public IOclParser<?, R> getOclParser(); // // public void setCspCodeGenerator(ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> cspCodeGenerator); // // public ICspCodeGenerator<R, ?, ?, ?, ?, ?, ?> getCspCodeGenerator(); // // public void setConstraintsDocument(IFile constraintsDocument); // // public IFile getConstraintsDocument(); // // public void setModelElementsDomain(Map<String, String> modelDomain); // // public Map<String, String> getModelElementsDomain(); // // public void setResultLocation(IFolder resultLocation); // // public IFolder getResultLocation(); // // public void setModelProperties(List<IModelProperty> modelProperties); // // public List<IModelProperty> getModelProperties(); // // public void setSolver(ICspSolver solver); // // public ICspSolver getSolver(); // // public boolean solveModel() throws ProcessingException ; // // public boolean solveModel(List<File> importLibs) throws ProcessingException ; // // public Object getSolverEvaluationResult(); // // public void setLogger(ILogger logger); // // public ILogger getLogger(); // // IModelBuilder<R, ?, ?, ?, ?, ?, ST> getBuilder(); // // void setBuilder(IModelBuilder<R, ?, ?, ?, ?, ?, ST> builder); // // void setConstraintsDocument(URI fileURI) throws CoreException; // // public void setConstraintsDocumentToNull(); // } // // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/widgets/IElementSelectionWidget.java // public interface IElementSelectionWidget { // // Object getElementSelected(); // // boolean isInSelectionMode(); // // boolean isSelectedElementValid(); // } // Path: plugins/fr.inria.atlanmod.emftocsp.ui/src/fr/inria/atlanmod/emftocsp/ui/wizards/impl/OclFileSelectionPage.java import java.util.Collection; import org.eclipse.core.resources.IFile; import org.eclipse.jface.viewers.IStructuredSelection; import fr.inria.atlanmod.emftocsp.IModelToCspSolver; import fr.inria.atlanmod.emftocsp.ui.widgets.IElementSelectionWidget; /******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.ui.wizards.impl; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public class OclFileSelectionPage extends SelectionPage { IModelToCspSolver<?,?> modelSolver; public OclFileSelectionPage(String pageName, String description, IStructuredSelection selection, Collection<String> allowedTypes, IModelToCspSolver<?,?> modelSolver) { super(pageName,description, selection, allowedTypes); this.modelSolver = modelSolver; } public OclFileSelectionPage(String pageName, String description, IStructuredSelection selection, Collection<String> allowedTypes, boolean mandatorySelection, IModelToCspSolver<?,?> modelSolver) { super(pageName,description, selection, allowedTypes, mandatorySelection); this.modelSolver = modelSolver; } @Override
public void elementSelectionWidgetChanged(IElementSelectionWidget esWidget) {
SOM-Research/EMFtoCSP
plugins/fr.inria.atlanmod.emftocsp.emftoecl/src/fr/inria/atlanmod/emftocsp/emftoecl/OclToEcl.java
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ILogger.java // public interface ILogger { // // public void writeInfoMessage(String context, String infoMessage); // // public void writeWarningMessage(String context, String warningMessage); // // public void writeErrorMessage(String context, String errorMessage); // // public void close(); // // public void close(String path); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ProcessingException.java // public class ProcessingException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ProcessingException(Throwable e) { // super(e); // } // // public ProcessingException(String msg, Throwable th) { // super(msg, th); // } // // public ProcessingException(String string) { // super(string); // } // // }
import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Stack; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EClassifier; import org.eclipse.emf.ecore.EEnumLiteral; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EOperation; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EParameter; import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.ocl.Environment; import org.eclipse.ocl.ecore.CallOperationAction; import org.eclipse.ocl.ecore.Constraint; import org.eclipse.ocl.ecore.EcoreEnvironmentFactory; import org.eclipse.ocl.ecore.SendSignalAction; import org.eclipse.ocl.expressions.BooleanLiteralExp; import org.eclipse.ocl.expressions.CollectionItem; import org.eclipse.ocl.expressions.CollectionLiteralExp; import org.eclipse.ocl.expressions.IfExp; import org.eclipse.ocl.expressions.IntegerLiteralExp; import org.eclipse.ocl.expressions.IteratorExp; import org.eclipse.ocl.expressions.NullLiteralExp; import org.eclipse.ocl.expressions.OperationCallExp; import org.eclipse.ocl.expressions.PropertyCallExp; import org.eclipse.ocl.expressions.RealLiteralExp; import org.eclipse.ocl.expressions.StringLiteralExp; import org.eclipse.ocl.expressions.TypeExp; import org.eclipse.ocl.expressions.Variable; import org.eclipse.ocl.expressions.VariableExp; import org.eclipse.ocl.types.BagType; import org.eclipse.ocl.types.OrderedSetType; import org.eclipse.ocl.types.PrimitiveType; import org.eclipse.ocl.types.SequenceType; import org.eclipse.ocl.types.SetType; import org.eclipse.ocl.util.TypeUtil; import org.eclipse.ocl.utilities.AbstractVisitor; import org.eclipse.ocl.utilities.ExpressionInOCL; import org.eclipse.ocl.utilities.PredefinedType; import org.eclipse.ocl.utilities.TypedElement; import org.eclipse.ocl.utilities.UMLReflection; import fr.inria.atlanmod.emftocsp.ILogger; import fr.inria.atlanmod.emftocsp.ProcessingException;
/******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.emftoecl; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public class OclToEcl extends AbstractVisitor<String, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint> { Environment<?, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, ?, ?> env = null; StringBuilder oclTranslation = null; String constraintName; String firstPredicate; int counter; Stack<String> varStack = null; private final UMLReflection<?, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint> uml; private static String XML_NULL_PLACEHOLDER = "NONE";
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ILogger.java // public interface ILogger { // // public void writeInfoMessage(String context, String infoMessage); // // public void writeWarningMessage(String context, String warningMessage); // // public void writeErrorMessage(String context, String errorMessage); // // public void close(); // // public void close(String path); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ProcessingException.java // public class ProcessingException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ProcessingException(Throwable e) { // super(e); // } // // public ProcessingException(String msg, Throwable th) { // super(msg, th); // } // // public ProcessingException(String string) { // super(string); // } // // } // Path: plugins/fr.inria.atlanmod.emftocsp.emftoecl/src/fr/inria/atlanmod/emftocsp/emftoecl/OclToEcl.java import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Stack; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EClassifier; import org.eclipse.emf.ecore.EEnumLiteral; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EOperation; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EParameter; import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.ocl.Environment; import org.eclipse.ocl.ecore.CallOperationAction; import org.eclipse.ocl.ecore.Constraint; import org.eclipse.ocl.ecore.EcoreEnvironmentFactory; import org.eclipse.ocl.ecore.SendSignalAction; import org.eclipse.ocl.expressions.BooleanLiteralExp; import org.eclipse.ocl.expressions.CollectionItem; import org.eclipse.ocl.expressions.CollectionLiteralExp; import org.eclipse.ocl.expressions.IfExp; import org.eclipse.ocl.expressions.IntegerLiteralExp; import org.eclipse.ocl.expressions.IteratorExp; import org.eclipse.ocl.expressions.NullLiteralExp; import org.eclipse.ocl.expressions.OperationCallExp; import org.eclipse.ocl.expressions.PropertyCallExp; import org.eclipse.ocl.expressions.RealLiteralExp; import org.eclipse.ocl.expressions.StringLiteralExp; import org.eclipse.ocl.expressions.TypeExp; import org.eclipse.ocl.expressions.Variable; import org.eclipse.ocl.expressions.VariableExp; import org.eclipse.ocl.types.BagType; import org.eclipse.ocl.types.OrderedSetType; import org.eclipse.ocl.types.PrimitiveType; import org.eclipse.ocl.types.SequenceType; import org.eclipse.ocl.types.SetType; import org.eclipse.ocl.util.TypeUtil; import org.eclipse.ocl.utilities.AbstractVisitor; import org.eclipse.ocl.utilities.ExpressionInOCL; import org.eclipse.ocl.utilities.PredefinedType; import org.eclipse.ocl.utilities.TypedElement; import org.eclipse.ocl.utilities.UMLReflection; import fr.inria.atlanmod.emftocsp.ILogger; import fr.inria.atlanmod.emftocsp.ProcessingException; /******************************************************************************* * Copyright (c) 2011 INRIA Rennes Bretagne-Atlantique. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * INRIA Rennes Bretagne-Atlantique - initial API and implementation *******************************************************************************/ package fr.inria.atlanmod.emftocsp.emftoecl; /** * @author <a href="mailto:carlos.gonzalez@inria.fr">Carlos A. González</a> * */ public class OclToEcl extends AbstractVisitor<String, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint> { Environment<?, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, ?, ?> env = null; StringBuilder oclTranslation = null; String constraintName; String firstPredicate; int counter; Stack<String> varStack = null; private final UMLReflection<?, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint> uml; private static String XML_NULL_PLACEHOLDER = "NONE";
ILogger logger;
SOM-Research/EMFtoCSP
plugins/fr.inria.atlanmod.emftocsp.emftoecl/src/fr/inria/atlanmod/emftocsp/emftoecl/OclToEcl.java
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ILogger.java // public interface ILogger { // // public void writeInfoMessage(String context, String infoMessage); // // public void writeWarningMessage(String context, String warningMessage); // // public void writeErrorMessage(String context, String errorMessage); // // public void close(); // // public void close(String path); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ProcessingException.java // public class ProcessingException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ProcessingException(Throwable e) { // super(e); // } // // public ProcessingException(String msg, Throwable th) { // super(msg, th); // } // // public ProcessingException(String string) { // super(string); // } // // }
import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Stack; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EClassifier; import org.eclipse.emf.ecore.EEnumLiteral; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EOperation; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EParameter; import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.ocl.Environment; import org.eclipse.ocl.ecore.CallOperationAction; import org.eclipse.ocl.ecore.Constraint; import org.eclipse.ocl.ecore.EcoreEnvironmentFactory; import org.eclipse.ocl.ecore.SendSignalAction; import org.eclipse.ocl.expressions.BooleanLiteralExp; import org.eclipse.ocl.expressions.CollectionItem; import org.eclipse.ocl.expressions.CollectionLiteralExp; import org.eclipse.ocl.expressions.IfExp; import org.eclipse.ocl.expressions.IntegerLiteralExp; import org.eclipse.ocl.expressions.IteratorExp; import org.eclipse.ocl.expressions.NullLiteralExp; import org.eclipse.ocl.expressions.OperationCallExp; import org.eclipse.ocl.expressions.PropertyCallExp; import org.eclipse.ocl.expressions.RealLiteralExp; import org.eclipse.ocl.expressions.StringLiteralExp; import org.eclipse.ocl.expressions.TypeExp; import org.eclipse.ocl.expressions.Variable; import org.eclipse.ocl.expressions.VariableExp; import org.eclipse.ocl.types.BagType; import org.eclipse.ocl.types.OrderedSetType; import org.eclipse.ocl.types.PrimitiveType; import org.eclipse.ocl.types.SequenceType; import org.eclipse.ocl.types.SetType; import org.eclipse.ocl.util.TypeUtil; import org.eclipse.ocl.utilities.AbstractVisitor; import org.eclipse.ocl.utilities.ExpressionInOCL; import org.eclipse.ocl.utilities.PredefinedType; import org.eclipse.ocl.utilities.TypedElement; import org.eclipse.ocl.utilities.UMLReflection; import fr.inria.atlanmod.emftocsp.ILogger; import fr.inria.atlanmod.emftocsp.ProcessingException;
} @Override protected String handleConstraint(Constraint constraint, String specificationResult) { return ""; } @Override protected String handleExpressionInOCL(ExpressionInOCL<EClassifier, EParameter> callExp, String contextResult, String resultResult, List<String> parameterResults, String bodyResult) { String predName = constraintName.substring(0,1).toLowerCase().concat(constraintName.substring(1, constraintName.length())); setConstraintFirstPredicate(bodyResult); oclTranslation.append(predName); oclTranslation.append("(Instances):-"); oclTranslation.append("\n\t"); oclTranslation.append(bodyResult); oclTranslation.append("(Instances, [], Result),"); oclTranslation.append("\n\t"); oclTranslation.append("Result #=1.\n"); return oclTranslation.toString(); } private void setConstraintFirstPredicate(String firstPredicate) { this.firstPredicate = firstPredicate; } public String getConstraintFirstPredicate() { return firstPredicate; }
// Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ILogger.java // public interface ILogger { // // public void writeInfoMessage(String context, String infoMessage); // // public void writeWarningMessage(String context, String warningMessage); // // public void writeErrorMessage(String context, String errorMessage); // // public void close(); // // public void close(String path); // } // // Path: plugins/fr.inria.atlanmod.emftocsp/src/fr/inria/atlanmod/emftocsp/ProcessingException.java // public class ProcessingException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ProcessingException(Throwable e) { // super(e); // } // // public ProcessingException(String msg, Throwable th) { // super(msg, th); // } // // public ProcessingException(String string) { // super(string); // } // // } // Path: plugins/fr.inria.atlanmod.emftocsp.emftoecl/src/fr/inria/atlanmod/emftocsp/emftoecl/OclToEcl.java import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Stack; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EClassifier; import org.eclipse.emf.ecore.EEnumLiteral; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EOperation; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EParameter; import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.ocl.Environment; import org.eclipse.ocl.ecore.CallOperationAction; import org.eclipse.ocl.ecore.Constraint; import org.eclipse.ocl.ecore.EcoreEnvironmentFactory; import org.eclipse.ocl.ecore.SendSignalAction; import org.eclipse.ocl.expressions.BooleanLiteralExp; import org.eclipse.ocl.expressions.CollectionItem; import org.eclipse.ocl.expressions.CollectionLiteralExp; import org.eclipse.ocl.expressions.IfExp; import org.eclipse.ocl.expressions.IntegerLiteralExp; import org.eclipse.ocl.expressions.IteratorExp; import org.eclipse.ocl.expressions.NullLiteralExp; import org.eclipse.ocl.expressions.OperationCallExp; import org.eclipse.ocl.expressions.PropertyCallExp; import org.eclipse.ocl.expressions.RealLiteralExp; import org.eclipse.ocl.expressions.StringLiteralExp; import org.eclipse.ocl.expressions.TypeExp; import org.eclipse.ocl.expressions.Variable; import org.eclipse.ocl.expressions.VariableExp; import org.eclipse.ocl.types.BagType; import org.eclipse.ocl.types.OrderedSetType; import org.eclipse.ocl.types.PrimitiveType; import org.eclipse.ocl.types.SequenceType; import org.eclipse.ocl.types.SetType; import org.eclipse.ocl.util.TypeUtil; import org.eclipse.ocl.utilities.AbstractVisitor; import org.eclipse.ocl.utilities.ExpressionInOCL; import org.eclipse.ocl.utilities.PredefinedType; import org.eclipse.ocl.utilities.TypedElement; import org.eclipse.ocl.utilities.UMLReflection; import fr.inria.atlanmod.emftocsp.ILogger; import fr.inria.atlanmod.emftocsp.ProcessingException; } @Override protected String handleConstraint(Constraint constraint, String specificationResult) { return ""; } @Override protected String handleExpressionInOCL(ExpressionInOCL<EClassifier, EParameter> callExp, String contextResult, String resultResult, List<String> parameterResults, String bodyResult) { String predName = constraintName.substring(0,1).toLowerCase().concat(constraintName.substring(1, constraintName.length())); setConstraintFirstPredicate(bodyResult); oclTranslation.append(predName); oclTranslation.append("(Instances):-"); oclTranslation.append("\n\t"); oclTranslation.append(bodyResult); oclTranslation.append("(Instances, [], Result),"); oclTranslation.append("\n\t"); oclTranslation.append("Result #=1.\n"); return oclTranslation.toString(); } private void setConstraintFirstPredicate(String firstPredicate) { this.firstPredicate = firstPredicate; } public String getConstraintFirstPredicate() { return firstPredicate; }
private String getType(TypedElement<EClassifier> exp) throws ProcessingException {
ForkITdev/androidlx_2014
8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/NavigationDrawerFragment.java
// Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/MenuAdapter.java // public class MenuAdapter extends BaseAdapter { // // private ArrayList<Menu> mMenus; // private Context ctx; // private int currentPosition = 0; // LayoutInflater inflater; // // public MenuAdapter(ArrayList<Menu> menus, Context ctx) { // this.ctx = ctx; // this.mMenus = menus; // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // } // // @Override // public int getCount() { // return mMenus.size(); // } // // @Override // public Menu getItem(int i) { // return mMenus.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.list_item_menu, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // Menu mi = getItem(i); // // holder.iv_icon.setImageResource(mi.getMenuIconDrawableId()); // holder.tv_title.setText(mi.getMenuTitle()); // // if(currentPosition == i){ // holder.tv_title.setTextColor(ctx.getResources().getColor(R.color.light_green)); // } else { // holder.tv_title.setTextColor(ctx.getResources().getColor(R.color.white)); // } // // return view; // } // // public void setActive(int position) { // currentPosition = position; // notifyDataSetChanged(); // } // // static class ViewHolder { // @InjectView(R.id.iv_icon) ImageView iv_icon; // @InjectView(R.id.tv_title) TextView tv_title; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // }
import android.app.ActionBar; import android.app.Activity; import android.content.SharedPreferences; import android.content.res.Configuration; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.view.*; import android.widget.AdapterView; import android.widget.ListView; import butterknife.ButterKnife; import butterknife.InjectView; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.MenuAdapter; import java.util.ArrayList;
// Read in the flag indicating whether or not the user has demonstrated awareness of the // drawer. See PREF_USER_LEARNED_DRAWER for details. SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false); if (savedInstanceState != null) { mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION); mFromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(mCurrentSelectedPosition); } @Override public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like to influence the set of actions in the action bar. setHasOptionsMenu(true); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate( R.layout.fragment_menu, container, false); ButterKnife.inject(this, v); ArrayList<pt.forkit.androidlx_2014.domain.Menu> items = new ArrayList<pt.forkit.androidlx_2014.domain.Menu>(); items.add(new pt.forkit.androidlx_2014.domain.Menu("Search", R.drawable.search)); items.add(new pt.forkit.androidlx_2014.domain.Menu("My Music", R.drawable.sound));
// Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/MenuAdapter.java // public class MenuAdapter extends BaseAdapter { // // private ArrayList<Menu> mMenus; // private Context ctx; // private int currentPosition = 0; // LayoutInflater inflater; // // public MenuAdapter(ArrayList<Menu> menus, Context ctx) { // this.ctx = ctx; // this.mMenus = menus; // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // } // // @Override // public int getCount() { // return mMenus.size(); // } // // @Override // public Menu getItem(int i) { // return mMenus.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.list_item_menu, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // Menu mi = getItem(i); // // holder.iv_icon.setImageResource(mi.getMenuIconDrawableId()); // holder.tv_title.setText(mi.getMenuTitle()); // // if(currentPosition == i){ // holder.tv_title.setTextColor(ctx.getResources().getColor(R.color.light_green)); // } else { // holder.tv_title.setTextColor(ctx.getResources().getColor(R.color.white)); // } // // return view; // } // // public void setActive(int position) { // currentPosition = position; // notifyDataSetChanged(); // } // // static class ViewHolder { // @InjectView(R.id.iv_icon) ImageView iv_icon; // @InjectView(R.id.tv_title) TextView tv_title; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // } // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/NavigationDrawerFragment.java import android.app.ActionBar; import android.app.Activity; import android.content.SharedPreferences; import android.content.res.Configuration; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.view.*; import android.widget.AdapterView; import android.widget.ListView; import butterknife.ButterKnife; import butterknife.InjectView; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.MenuAdapter; import java.util.ArrayList; // Read in the flag indicating whether or not the user has demonstrated awareness of the // drawer. See PREF_USER_LEARNED_DRAWER for details. SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false); if (savedInstanceState != null) { mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION); mFromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(mCurrentSelectedPosition); } @Override public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like to influence the set of actions in the action bar. setHasOptionsMenu(true); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate( R.layout.fragment_menu, container, false); ButterKnife.inject(this, v); ArrayList<pt.forkit.androidlx_2014.domain.Menu> items = new ArrayList<pt.forkit.androidlx_2014.domain.Menu>(); items.add(new pt.forkit.androidlx_2014.domain.Menu("Search", R.drawable.search)); items.add(new pt.forkit.androidlx_2014.domain.Menu("My Music", R.drawable.sound));
mLvMenu.setAdapter(new MenuAdapter(items, getActivity()));
ForkITdev/androidlx_2014
8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java
// Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/rest/AuthorizationInterceptor.java // public class AuthorizationInterceptor implements RequestInterceptor { // // @Override // public void intercept(RequestInterceptor.RequestFacade requestFacade) { // requestFacade.addEncodedQueryParam("client_id", Urls.SOUNDCLOUD_CLIENT_ID); // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/rest/Mp3Api.java // public interface Mp3Api { // // @GET("/tracks.json") // public void tracks(@Query("q") String query, @Query("tags") String tags, // Callback<ArrayList<Track>> callback); // // @GET("/track/{track_id}.json") // public void track(@Path("track_id") String track_id, // Callback<Track> callback); // // // }
import android.annotation.SuppressLint; import android.os.Bundle; import android.support.v4.app.Fragment; import pt.forkit.androidlx_2014.rest.AuthorizationInterceptor; import pt.forkit.androidlx_2014.rest.Mp3Api; import retrofit.RestAdapter;
package pt.forkit.androidlx_2014.ui; @SuppressLint("NewApi") public class BaseFragment extends Fragment {
// Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/rest/AuthorizationInterceptor.java // public class AuthorizationInterceptor implements RequestInterceptor { // // @Override // public void intercept(RequestInterceptor.RequestFacade requestFacade) { // requestFacade.addEncodedQueryParam("client_id", Urls.SOUNDCLOUD_CLIENT_ID); // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/rest/Mp3Api.java // public interface Mp3Api { // // @GET("/tracks.json") // public void tracks(@Query("q") String query, @Query("tags") String tags, // Callback<ArrayList<Track>> callback); // // @GET("/track/{track_id}.json") // public void track(@Path("track_id") String track_id, // Callback<Track> callback); // // // } // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java import android.annotation.SuppressLint; import android.os.Bundle; import android.support.v4.app.Fragment; import pt.forkit.androidlx_2014.rest.AuthorizationInterceptor; import pt.forkit.androidlx_2014.rest.Mp3Api; import retrofit.RestAdapter; package pt.forkit.androidlx_2014.ui; @SuppressLint("NewApi") public class BaseFragment extends Fragment {
protected Mp3Api mApi;
ForkITdev/androidlx_2014
8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java
// Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/rest/AuthorizationInterceptor.java // public class AuthorizationInterceptor implements RequestInterceptor { // // @Override // public void intercept(RequestInterceptor.RequestFacade requestFacade) { // requestFacade.addEncodedQueryParam("client_id", Urls.SOUNDCLOUD_CLIENT_ID); // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/rest/Mp3Api.java // public interface Mp3Api { // // @GET("/tracks.json") // public void tracks(@Query("q") String query, @Query("tags") String tags, // Callback<ArrayList<Track>> callback); // // @GET("/track/{track_id}.json") // public void track(@Path("track_id") String track_id, // Callback<Track> callback); // // // }
import android.annotation.SuppressLint; import android.os.Bundle; import android.support.v4.app.Fragment; import pt.forkit.androidlx_2014.rest.AuthorizationInterceptor; import pt.forkit.androidlx_2014.rest.Mp3Api; import retrofit.RestAdapter;
package pt.forkit.androidlx_2014.ui; @SuppressLint("NewApi") public class BaseFragment extends Fragment { protected Mp3Api mApi; public BaseFragment() { super(); } public void onCreate(Bundle s) { super.onCreate(s); RestAdapter restAdapter = new RestAdapter.Builder() .setLogLevel(RestAdapter.LogLevel.FULL)
// Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/rest/AuthorizationInterceptor.java // public class AuthorizationInterceptor implements RequestInterceptor { // // @Override // public void intercept(RequestInterceptor.RequestFacade requestFacade) { // requestFacade.addEncodedQueryParam("client_id", Urls.SOUNDCLOUD_CLIENT_ID); // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/rest/Mp3Api.java // public interface Mp3Api { // // @GET("/tracks.json") // public void tracks(@Query("q") String query, @Query("tags") String tags, // Callback<ArrayList<Track>> callback); // // @GET("/track/{track_id}.json") // public void track(@Path("track_id") String track_id, // Callback<Track> callback); // // // } // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java import android.annotation.SuppressLint; import android.os.Bundle; import android.support.v4.app.Fragment; import pt.forkit.androidlx_2014.rest.AuthorizationInterceptor; import pt.forkit.androidlx_2014.rest.Mp3Api; import retrofit.RestAdapter; package pt.forkit.androidlx_2014.ui; @SuppressLint("NewApi") public class BaseFragment extends Fragment { protected Mp3Api mApi; public BaseFragment() { super(); } public void onCreate(Bundle s) { super.onCreate(s); RestAdapter restAdapter = new RestAdapter.Builder() .setLogLevel(RestAdapter.LogLevel.FULL)
.setRequestInterceptor(new AuthorizationInterceptor())
ForkITdev/androidlx_2014
5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/SearchFragment.java
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java // public class SongAdapter extends BaseAdapter { // // private final boolean showDownload; // private ArrayList<Track> mTracks; // private Context ctx; // LayoutInflater inflater; // // public SongAdapter(ArrayList<Track> tracks, Context ctx, boolean showDownload) { // this.ctx = ctx; // mTracks = new ArrayList<Track>(); // // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // this.showDownload = showDownload; // } // // @Override // public int getCount() { // return mTracks.size(); // } // // @Override // public Track getItem(int i) { // return mTracks.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.grid_item_song, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // final Track t = getItem(i); // // if(showDownload){ // // } else { // holder.tv_label_download.setText(ctx.getString(R.string.play_song)); // } // // return view; // } // // static class ViewHolder { // @InjectView(R.id.tv_title) TextView tv_title; // @InjectView(R.id.iv_artwork) ImageView iv_artwork; // @InjectView(R.id.tv_label_download) TextView tv_label_download; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // // }
import android.app.ProgressDialog; import android.os.Bundle; import android.os.Environment; import android.view.*; import android.widget.GridView; import android.widget.SearchView; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnItemClick; import com.devspark.appmsg.AppMsg; import com.koushikdutta.async.future.FutureCallback; import com.koushikdutta.ion.Ion; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.SongAdapter; import retrofit.Callback; import retrofit.RetrofitError; import retrofit.client.Response; import java.io.File; import java.util.ArrayList;
package pt.forkit.androidlx_2014.ui.fragment; public class SearchFragment extends BaseFragment { @InjectView(R.id.gv_songs) GridView mGvSongs; @OnItemClick(R.id.gv_songs) public void onSongClick(int position){
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java // public class SongAdapter extends BaseAdapter { // // private final boolean showDownload; // private ArrayList<Track> mTracks; // private Context ctx; // LayoutInflater inflater; // // public SongAdapter(ArrayList<Track> tracks, Context ctx, boolean showDownload) { // this.ctx = ctx; // mTracks = new ArrayList<Track>(); // // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // this.showDownload = showDownload; // } // // @Override // public int getCount() { // return mTracks.size(); // } // // @Override // public Track getItem(int i) { // return mTracks.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.grid_item_song, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // final Track t = getItem(i); // // if(showDownload){ // // } else { // holder.tv_label_download.setText(ctx.getString(R.string.play_song)); // } // // return view; // } // // static class ViewHolder { // @InjectView(R.id.tv_title) TextView tv_title; // @InjectView(R.id.iv_artwork) ImageView iv_artwork; // @InjectView(R.id.tv_label_download) TextView tv_label_download; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // // } // Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/SearchFragment.java import android.app.ProgressDialog; import android.os.Bundle; import android.os.Environment; import android.view.*; import android.widget.GridView; import android.widget.SearchView; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnItemClick; import com.devspark.appmsg.AppMsg; import com.koushikdutta.async.future.FutureCallback; import com.koushikdutta.ion.Ion; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.SongAdapter; import retrofit.Callback; import retrofit.RetrofitError; import retrofit.client.Response; import java.io.File; import java.util.ArrayList; package pt.forkit.androidlx_2014.ui.fragment; public class SearchFragment extends BaseFragment { @InjectView(R.id.gv_songs) GridView mGvSongs; @OnItemClick(R.id.gv_songs) public void onSongClick(int position){
Track t = (Track) mGvSongs.getItemAtPosition(position);
ForkITdev/androidlx_2014
8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/MyTracksFragment.java
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java // public class SongAdapter extends BaseAdapter { // // private final boolean showDownload; // private ArrayList<Track> mTracks; // private Context ctx; // LayoutInflater inflater; // // public SongAdapter(ArrayList<Track> tracks, Context ctx, boolean showDownload) { // this.ctx = ctx; // mTracks = new ArrayList<Track>(); // // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // this.showDownload = showDownload; // } // // @Override // public int getCount() { // return mTracks.size(); // } // // @Override // public Track getItem(int i) { // return mTracks.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.grid_item_song, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // final Track t = getItem(i); // // if(showDownload){ // // } else { // holder.tv_label_download.setText(ctx.getString(R.string.play_song)); // } // // return view; // } // // static class ViewHolder { // @InjectView(R.id.tv_title) TextView tv_title; // @InjectView(R.id.iv_artwork) ImageView iv_artwork; // @InjectView(R.id.tv_label_download) TextView tv_label_download; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // // }
import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.GridView; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnItemClick; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.SongAdapter; import java.io.File; import java.util.ArrayList; import java.util.List;
package pt.forkit.androidlx_2014.ui.fragment; public class MyTracksFragment extends BaseFragment { @InjectView(R.id.gv_songs) GridView mGvSongs;
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java // public class SongAdapter extends BaseAdapter { // // private final boolean showDownload; // private ArrayList<Track> mTracks; // private Context ctx; // LayoutInflater inflater; // // public SongAdapter(ArrayList<Track> tracks, Context ctx, boolean showDownload) { // this.ctx = ctx; // mTracks = new ArrayList<Track>(); // // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // this.showDownload = showDownload; // } // // @Override // public int getCount() { // return mTracks.size(); // } // // @Override // public Track getItem(int i) { // return mTracks.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.grid_item_song, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // final Track t = getItem(i); // // if(showDownload){ // // } else { // holder.tv_label_download.setText(ctx.getString(R.string.play_song)); // } // // return view; // } // // static class ViewHolder { // @InjectView(R.id.tv_title) TextView tv_title; // @InjectView(R.id.iv_artwork) ImageView iv_artwork; // @InjectView(R.id.tv_label_download) TextView tv_label_download; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // // } // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/MyTracksFragment.java import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.GridView; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnItemClick; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.SongAdapter; import java.io.File; import java.util.ArrayList; import java.util.List; package pt.forkit.androidlx_2014.ui.fragment; public class MyTracksFragment extends BaseFragment { @InjectView(R.id.gv_songs) GridView mGvSongs;
private List<Track> mTracks;
ForkITdev/androidlx_2014
4 - After Ion/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/SearchFragment.java
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java // public class SongAdapter extends BaseAdapter { // // private final boolean showDownload; // private ArrayList<Track> mTracks; // private Context ctx; // LayoutInflater inflater; // // public SongAdapter(ArrayList<Track> tracks, Context ctx, boolean showDownload) { // this.ctx = ctx; // mTracks = new ArrayList<Track>(); // // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // this.showDownload = showDownload; // } // // @Override // public int getCount() { // return mTracks.size(); // } // // @Override // public Track getItem(int i) { // return mTracks.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.grid_item_song, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // final Track t = getItem(i); // // if(showDownload){ // // } else { // holder.tv_label_download.setText(ctx.getString(R.string.play_song)); // } // // return view; // } // // static class ViewHolder { // @InjectView(R.id.tv_title) TextView tv_title; // @InjectView(R.id.iv_artwork) ImageView iv_artwork; // @InjectView(R.id.tv_label_download) TextView tv_label_download; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // // }
import android.app.ProgressDialog; import android.os.Bundle; import android.os.Environment; import android.view.*; import android.widget.GridView; import android.widget.SearchView; import android.widget.Toast; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnItemClick; import com.koushikdutta.async.future.FutureCallback; import com.koushikdutta.ion.Ion; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.SongAdapter; import retrofit.Callback; import retrofit.RetrofitError; import retrofit.client.Response; import java.io.File; import java.util.ArrayList;
package pt.forkit.androidlx_2014.ui.fragment; public class SearchFragment extends BaseFragment { @InjectView(R.id.gv_songs) GridView mGvSongs; @OnItemClick(R.id.gv_songs) public void onSongClick(int position){
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java // public class SongAdapter extends BaseAdapter { // // private final boolean showDownload; // private ArrayList<Track> mTracks; // private Context ctx; // LayoutInflater inflater; // // public SongAdapter(ArrayList<Track> tracks, Context ctx, boolean showDownload) { // this.ctx = ctx; // mTracks = new ArrayList<Track>(); // // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // this.showDownload = showDownload; // } // // @Override // public int getCount() { // return mTracks.size(); // } // // @Override // public Track getItem(int i) { // return mTracks.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.grid_item_song, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // final Track t = getItem(i); // // if(showDownload){ // // } else { // holder.tv_label_download.setText(ctx.getString(R.string.play_song)); // } // // return view; // } // // static class ViewHolder { // @InjectView(R.id.tv_title) TextView tv_title; // @InjectView(R.id.iv_artwork) ImageView iv_artwork; // @InjectView(R.id.tv_label_download) TextView tv_label_download; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // // } // Path: 4 - After Ion/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/SearchFragment.java import android.app.ProgressDialog; import android.os.Bundle; import android.os.Environment; import android.view.*; import android.widget.GridView; import android.widget.SearchView; import android.widget.Toast; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnItemClick; import com.koushikdutta.async.future.FutureCallback; import com.koushikdutta.ion.Ion; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.SongAdapter; import retrofit.Callback; import retrofit.RetrofitError; import retrofit.client.Response; import java.io.File; import java.util.ArrayList; package pt.forkit.androidlx_2014.ui.fragment; public class SearchFragment extends BaseFragment { @InjectView(R.id.gv_songs) GridView mGvSongs; @OnItemClick(R.id.gv_songs) public void onSongClick(int position){
Track t = (Track) mGvSongs.getItemAtPosition(position);
ForkITdev/androidlx_2014
5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java
// Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/rest/constants/Urls.java // public class Urls { // // public static final String SOUNDCLOUD_CLIENT_ID = "SOUNDCLOUD_ID_HERE"; // // }
import com.google.gson.annotations.SerializedName; import pt.forkit.androidlx_2014.rest.constants.Urls; import java.util.List;
public String getTitle() { return title; } public String getSharing() { return sharing; } public String getArtworkUrl() { return artworkUrl; } public long getDuration() { return duration; } public String getGenre() { return genre; } public boolean isStreamable() { return streamable; } public boolean isDownloadable() { return downloadable; } public String getDownloadUrl() {
// Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/rest/constants/Urls.java // public class Urls { // // public static final String SOUNDCLOUD_CLIENT_ID = "SOUNDCLOUD_ID_HERE"; // // } // Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java import com.google.gson.annotations.SerializedName; import pt.forkit.androidlx_2014.rest.constants.Urls; import java.util.List; public String getTitle() { return title; } public String getSharing() { return sharing; } public String getArtworkUrl() { return artworkUrl; } public long getDuration() { return duration; } public String getGenre() { return genre; } public boolean isStreamable() { return streamable; } public boolean isDownloadable() { return downloadable; } public String getDownloadUrl() {
return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID;
ForkITdev/androidlx_2014
3 - After UrlImageViewHelper/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/SearchFragment.java
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java // public class SongAdapter extends BaseAdapter { // // private final boolean showDownload; // private ArrayList<Track> mTracks; // private Context ctx; // LayoutInflater inflater; // // public SongAdapter(ArrayList<Track> tracks, Context ctx, boolean showDownload) { // this.ctx = ctx; // mTracks = new ArrayList<Track>(); // // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // this.showDownload = showDownload; // } // // @Override // public int getCount() { // return mTracks.size(); // } // // @Override // public Track getItem(int i) { // return mTracks.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.grid_item_song, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // final Track t = getItem(i); // // if(showDownload){ // // } else { // holder.tv_label_download.setText(ctx.getString(R.string.play_song)); // } // // return view; // } // // static class ViewHolder { // @InjectView(R.id.tv_title) TextView tv_title; // @InjectView(R.id.iv_artwork) ImageView iv_artwork; // @InjectView(R.id.tv_label_download) TextView tv_label_download; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // // }
import android.app.ProgressDialog; import android.os.Bundle; import android.os.Environment; import android.view.*; import android.widget.GridView; import android.widget.SearchView; import android.widget.Toast; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnItemClick; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.SongAdapter; import retrofit.Callback; import retrofit.RetrofitError; import retrofit.client.Response; import java.util.ArrayList;
package pt.forkit.androidlx_2014.ui.fragment; public class SearchFragment extends BaseFragment { @InjectView(R.id.gv_songs) GridView mGvSongs; @OnItemClick(R.id.gv_songs) public void onSongClick(int position){
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java // public class SongAdapter extends BaseAdapter { // // private final boolean showDownload; // private ArrayList<Track> mTracks; // private Context ctx; // LayoutInflater inflater; // // public SongAdapter(ArrayList<Track> tracks, Context ctx, boolean showDownload) { // this.ctx = ctx; // mTracks = new ArrayList<Track>(); // // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // this.showDownload = showDownload; // } // // @Override // public int getCount() { // return mTracks.size(); // } // // @Override // public Track getItem(int i) { // return mTracks.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.grid_item_song, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // final Track t = getItem(i); // // if(showDownload){ // // } else { // holder.tv_label_download.setText(ctx.getString(R.string.play_song)); // } // // return view; // } // // static class ViewHolder { // @InjectView(R.id.tv_title) TextView tv_title; // @InjectView(R.id.iv_artwork) ImageView iv_artwork; // @InjectView(R.id.tv_label_download) TextView tv_label_download; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // // } // Path: 3 - After UrlImageViewHelper/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/SearchFragment.java import android.app.ProgressDialog; import android.os.Bundle; import android.os.Environment; import android.view.*; import android.widget.GridView; import android.widget.SearchView; import android.widget.Toast; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnItemClick; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.SongAdapter; import retrofit.Callback; import retrofit.RetrofitError; import retrofit.client.Response; import java.util.ArrayList; package pt.forkit.androidlx_2014.ui.fragment; public class SearchFragment extends BaseFragment { @InjectView(R.id.gv_songs) GridView mGvSongs; @OnItemClick(R.id.gv_songs) public void onSongClick(int position){
Track t = (Track) mGvSongs.getItemAtPosition(position);
ForkITdev/androidlx_2014
5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/MyTracksFragment.java
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java // public class SongAdapter extends BaseAdapter { // // private final boolean showDownload; // private ArrayList<Track> mTracks; // private Context ctx; // LayoutInflater inflater; // // public SongAdapter(ArrayList<Track> tracks, Context ctx, boolean showDownload) { // this.ctx = ctx; // mTracks = new ArrayList<Track>(); // // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // this.showDownload = showDownload; // } // // @Override // public int getCount() { // return mTracks.size(); // } // // @Override // public Track getItem(int i) { // return mTracks.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.grid_item_song, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // final Track t = getItem(i); // // if(showDownload){ // // } else { // holder.tv_label_download.setText(ctx.getString(R.string.play_song)); // } // // return view; // } // // static class ViewHolder { // @InjectView(R.id.tv_title) TextView tv_title; // @InjectView(R.id.iv_artwork) ImageView iv_artwork; // @InjectView(R.id.tv_label_download) TextView tv_label_download; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // // }
import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.GridView; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnItemClick; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.SongAdapter; import java.io.File; import java.util.ArrayList; import java.util.List;
package pt.forkit.androidlx_2014.ui.fragment; public class MyTracksFragment extends BaseFragment { @InjectView(R.id.gv_songs) GridView mGvSongs;
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java // public class SongAdapter extends BaseAdapter { // // private final boolean showDownload; // private ArrayList<Track> mTracks; // private Context ctx; // LayoutInflater inflater; // // public SongAdapter(ArrayList<Track> tracks, Context ctx, boolean showDownload) { // this.ctx = ctx; // mTracks = new ArrayList<Track>(); // // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // this.showDownload = showDownload; // } // // @Override // public int getCount() { // return mTracks.size(); // } // // @Override // public Track getItem(int i) { // return mTracks.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.grid_item_song, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // final Track t = getItem(i); // // if(showDownload){ // // } else { // holder.tv_label_download.setText(ctx.getString(R.string.play_song)); // } // // return view; // } // // static class ViewHolder { // @InjectView(R.id.tv_title) TextView tv_title; // @InjectView(R.id.iv_artwork) ImageView iv_artwork; // @InjectView(R.id.tv_label_download) TextView tv_label_download; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // // } // Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/MyTracksFragment.java import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.GridView; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnItemClick; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.SongAdapter; import java.io.File; import java.util.ArrayList; import java.util.List; package pt.forkit.androidlx_2014.ui.fragment; public class MyTracksFragment extends BaseFragment { @InjectView(R.id.gv_songs) GridView mGvSongs;
private List<Track> mTracks;
ForkITdev/androidlx_2014
1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // }
import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import butterknife.ButterKnife; import butterknife.InjectView; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.ArrayList;
package pt.forkit.androidlx_2014.ui.adapter; /** */ public class SongAdapter extends BaseAdapter { private final boolean showDownload;
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import butterknife.ButterKnife; import butterknife.InjectView; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.ArrayList; package pt.forkit.androidlx_2014.ui.adapter; /** */ public class SongAdapter extends BaseAdapter { private final boolean showDownload;
private ArrayList<Track> mTracks;
ForkITdev/androidlx_2014
8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/rest/Mp3Api.java
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // }
import pt.forkit.androidlx_2014.domain.Track; import retrofit.Callback; import retrofit.http.GET; import retrofit.http.Path; import retrofit.http.Query; import java.util.ArrayList;
package pt.forkit.androidlx_2014.rest; public interface Mp3Api { @GET("/tracks.json") public void tracks(@Query("q") String query, @Query("tags") String tags,
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/rest/Mp3Api.java import pt.forkit.androidlx_2014.domain.Track; import retrofit.Callback; import retrofit.http.GET; import retrofit.http.Path; import retrofit.http.Query; import java.util.ArrayList; package pt.forkit.androidlx_2014.rest; public interface Mp3Api { @GET("/tracks.json") public void tracks(@Query("q") String query, @Query("tags") String tags,
Callback<ArrayList<Track>> callback);
ForkITdev/androidlx_2014
8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // }
import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import butterknife.ButterKnife; import butterknife.InjectView; import com.koushikdutta.urlimageviewhelper.UrlImageViewHelper; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.ArrayList;
package pt.forkit.androidlx_2014.ui.adapter; /** */ public class SongAdapter extends BaseAdapter { private final boolean showDownload;
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import butterknife.ButterKnife; import butterknife.InjectView; import com.koushikdutta.urlimageviewhelper.UrlImageViewHelper; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.ArrayList; package pt.forkit.androidlx_2014.ui.adapter; /** */ public class SongAdapter extends BaseAdapter { private final boolean showDownload;
private ArrayList<Track> mTracks;
ForkITdev/androidlx_2014
8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java
// Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/rest/constants/Urls.java // public class Urls { // // public static final String SOUNDCLOUD_CLIENT_ID = "SOUNDCLOUD_ID_HERE"; // // }
import com.activeandroid.Model; import com.activeandroid.annotation.Column; import com.activeandroid.annotation.Table; import com.activeandroid.query.Select; import com.google.gson.annotations.SerializedName; import pt.forkit.androidlx_2014.rest.constants.Urls; import java.util.List;
public String getTitle() { return title; } public String getSharing() { return sharing; } public String getArtworkUrl() { return artworkUrl; } public long getDuration() { return duration; } public String getGenre() { return genre; } public boolean isStreamable() { return streamable; } public boolean isDownloadable() { return downloadable; } public String getDownloadUrl() {
// Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/rest/constants/Urls.java // public class Urls { // // public static final String SOUNDCLOUD_CLIENT_ID = "SOUNDCLOUD_ID_HERE"; // // } // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java import com.activeandroid.Model; import com.activeandroid.annotation.Column; import com.activeandroid.annotation.Table; import com.activeandroid.query.Select; import com.google.gson.annotations.SerializedName; import pt.forkit.androidlx_2014.rest.constants.Urls; import java.util.List; public String getTitle() { return title; } public String getSharing() { return sharing; } public String getArtworkUrl() { return artworkUrl; } public long getDuration() { return duration; } public String getGenre() { return genre; } public boolean isStreamable() { return streamable; } public boolean isDownloadable() { return downloadable; } public String getDownloadUrl() {
return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID;
ForkITdev/androidlx_2014
0 - And so it begins/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/MyTracksFragment.java
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java // public class SongAdapter extends BaseAdapter { // // private final boolean showDownload; // private ArrayList<Track> mTracks; // private Context ctx; // LayoutInflater inflater; // // public SongAdapter(ArrayList<Track> tracks, Context ctx, boolean showDownload) { // this.ctx = ctx; // mTracks = new ArrayList<Track>(); // // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // this.showDownload = showDownload; // } // // @Override // public int getCount() { // return mTracks.size(); // } // // @Override // public Track getItem(int i) { // return mTracks.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.grid_item_song, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // final Track t = getItem(i); // // if(showDownload){ // // } else { // holder.tv_label_download.setText(ctx.getString(R.string.play_song)); // } // // return view; // } // // static class ViewHolder { // @InjectView(R.id.tv_title) TextView tv_title; // @InjectView(R.id.iv_artwork) ImageView iv_artwork; // @InjectView(R.id.tv_label_download) TextView tv_label_download; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // // }
import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.GridView; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.SongAdapter; import java.io.File; import java.util.ArrayList; import java.util.List;
package pt.forkit.androidlx_2014.ui.fragment; public class MyTracksFragment extends BaseFragment { GridView mGvSongs;
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java // public class SongAdapter extends BaseAdapter { // // private final boolean showDownload; // private ArrayList<Track> mTracks; // private Context ctx; // LayoutInflater inflater; // // public SongAdapter(ArrayList<Track> tracks, Context ctx, boolean showDownload) { // this.ctx = ctx; // mTracks = new ArrayList<Track>(); // // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // this.showDownload = showDownload; // } // // @Override // public int getCount() { // return mTracks.size(); // } // // @Override // public Track getItem(int i) { // return mTracks.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.grid_item_song, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // final Track t = getItem(i); // // if(showDownload){ // // } else { // holder.tv_label_download.setText(ctx.getString(R.string.play_song)); // } // // return view; // } // // static class ViewHolder { // @InjectView(R.id.tv_title) TextView tv_title; // @InjectView(R.id.iv_artwork) ImageView iv_artwork; // @InjectView(R.id.tv_label_download) TextView tv_label_download; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // // } // Path: 0 - And so it begins/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/MyTracksFragment.java import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.GridView; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.SongAdapter; import java.io.File; import java.util.ArrayList; import java.util.List; package pt.forkit.androidlx_2014.ui.fragment; public class MyTracksFragment extends BaseFragment { GridView mGvSongs;
private List<Track> mTracks;
ForkITdev/androidlx_2014
1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/SearchFragment.java
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // }
import android.app.ProgressDialog; import android.os.Bundle; import android.os.Environment; import android.view.*; import android.widget.GridView; import android.widget.SearchView; import android.widget.Toast; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnItemClick; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment;
package pt.forkit.androidlx_2014.ui.fragment; public class SearchFragment extends BaseFragment { @InjectView(R.id.gv_songs) GridView mGvSongs; @OnItemClick(R.id.gv_songs) public void onSongClick(int position){
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/SearchFragment.java import android.app.ProgressDialog; import android.os.Bundle; import android.os.Environment; import android.view.*; import android.widget.GridView; import android.widget.SearchView; import android.widget.Toast; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnItemClick; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment; package pt.forkit.androidlx_2014.ui.fragment; public class SearchFragment extends BaseFragment { @InjectView(R.id.gv_songs) GridView mGvSongs; @OnItemClick(R.id.gv_songs) public void onSongClick(int position){
Track t = (Track) mGvSongs.getItemAtPosition(position);
ForkITdev/androidlx_2014
0 - And so it begins/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // }
import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import java.util.ArrayList;
package pt.forkit.androidlx_2014.ui.adapter; /** */ public class SongAdapter extends BaseAdapter { private final boolean showDownload;
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // Path: 0 - And so it begins/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import java.util.ArrayList; package pt.forkit.androidlx_2014.ui.adapter; /** */ public class SongAdapter extends BaseAdapter { private final boolean showDownload;
private ArrayList<Track> mTracks;
ForkITdev/androidlx_2014
0 - And so it begins/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/NavigationDrawerFragment.java
// Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/MenuAdapter.java // public class MenuAdapter extends BaseAdapter { // // private ArrayList<Menu> mMenus; // private Context ctx; // private int currentPosition = 0; // LayoutInflater inflater; // // public MenuAdapter(ArrayList<Menu> menus, Context ctx) { // this.ctx = ctx; // this.mMenus = menus; // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // } // // @Override // public int getCount() { // return mMenus.size(); // } // // @Override // public Menu getItem(int i) { // return mMenus.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.list_item_menu, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // Menu mi = getItem(i); // // holder.iv_icon.setImageResource(mi.getMenuIconDrawableId()); // holder.tv_title.setText(mi.getMenuTitle()); // // if(currentPosition == i){ // holder.tv_title.setTextColor(ctx.getResources().getColor(R.color.light_green)); // } else { // holder.tv_title.setTextColor(ctx.getResources().getColor(R.color.white)); // } // // return view; // } // // public void setActive(int position) { // currentPosition = position; // notifyDataSetChanged(); // } // // static class ViewHolder { // @InjectView(R.id.iv_icon) ImageView iv_icon; // @InjectView(R.id.tv_title) TextView tv_title; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // }
import android.app.ActionBar; import android.app.Activity; import android.content.SharedPreferences; import android.content.res.Configuration; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.view.*; import android.widget.AdapterView; import android.widget.ListView; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.MenuAdapter; import java.util.ArrayList;
// Read in the flag indicating whether or not the user has demonstrated awareness of the // drawer. See PREF_USER_LEARNED_DRAWER for details. SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false); if (savedInstanceState != null) { mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION); mFromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(mCurrentSelectedPosition); } @Override public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like to influence the set of actions in the action bar. setHasOptionsMenu(true); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate( R.layout.fragment_menu, container, false); mLvMenu = (ListView) v.findViewById(R.id.lv_menu); ArrayList<pt.forkit.androidlx_2014.domain.Menu> items = new ArrayList<pt.forkit.androidlx_2014.domain.Menu>(); items.add(new pt.forkit.androidlx_2014.domain.Menu("Search", R.drawable.search)); items.add(new pt.forkit.androidlx_2014.domain.Menu("My Music", R.drawable.sound));
// Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/MenuAdapter.java // public class MenuAdapter extends BaseAdapter { // // private ArrayList<Menu> mMenus; // private Context ctx; // private int currentPosition = 0; // LayoutInflater inflater; // // public MenuAdapter(ArrayList<Menu> menus, Context ctx) { // this.ctx = ctx; // this.mMenus = menus; // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // } // // @Override // public int getCount() { // return mMenus.size(); // } // // @Override // public Menu getItem(int i) { // return mMenus.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.list_item_menu, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // Menu mi = getItem(i); // // holder.iv_icon.setImageResource(mi.getMenuIconDrawableId()); // holder.tv_title.setText(mi.getMenuTitle()); // // if(currentPosition == i){ // holder.tv_title.setTextColor(ctx.getResources().getColor(R.color.light_green)); // } else { // holder.tv_title.setTextColor(ctx.getResources().getColor(R.color.white)); // } // // return view; // } // // public void setActive(int position) { // currentPosition = position; // notifyDataSetChanged(); // } // // static class ViewHolder { // @InjectView(R.id.iv_icon) ImageView iv_icon; // @InjectView(R.id.tv_title) TextView tv_title; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // } // Path: 0 - And so it begins/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/NavigationDrawerFragment.java import android.app.ActionBar; import android.app.Activity; import android.content.SharedPreferences; import android.content.res.Configuration; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.view.*; import android.widget.AdapterView; import android.widget.ListView; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.MenuAdapter; import java.util.ArrayList; // Read in the flag indicating whether or not the user has demonstrated awareness of the // drawer. See PREF_USER_LEARNED_DRAWER for details. SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false); if (savedInstanceState != null) { mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION); mFromSavedInstanceState = true; } // Select either the default item (0) or the last selected item. selectItem(mCurrentSelectedPosition); } @Override public void onActivityCreated (Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Indicate that this fragment would like to influence the set of actions in the action bar. setHasOptionsMenu(true); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate( R.layout.fragment_menu, container, false); mLvMenu = (ListView) v.findViewById(R.id.lv_menu); ArrayList<pt.forkit.androidlx_2014.domain.Menu> items = new ArrayList<pt.forkit.androidlx_2014.domain.Menu>(); items.add(new pt.forkit.androidlx_2014.domain.Menu("Search", R.drawable.search)); items.add(new pt.forkit.androidlx_2014.domain.Menu("My Music", R.drawable.sound));
mLvMenu.setAdapter(new MenuAdapter(items, getActivity()));
ForkITdev/androidlx_2014
7 - After Calligraphy/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/SearchFragment.java
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java // public class SongAdapter extends BaseAdapter { // // private final boolean showDownload; // private ArrayList<Track> mTracks; // private Context ctx; // LayoutInflater inflater; // // public SongAdapter(ArrayList<Track> tracks, Context ctx, boolean showDownload) { // this.ctx = ctx; // mTracks = new ArrayList<Track>(); // // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // this.showDownload = showDownload; // } // // @Override // public int getCount() { // return mTracks.size(); // } // // @Override // public Track getItem(int i) { // return mTracks.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.grid_item_song, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // final Track t = getItem(i); // // if(showDownload){ // // } else { // holder.tv_label_download.setText(ctx.getString(R.string.play_song)); // } // // return view; // } // // static class ViewHolder { // @InjectView(R.id.tv_title) TextView tv_title; // @InjectView(R.id.iv_artwork) ImageView iv_artwork; // @InjectView(R.id.tv_label_download) TextView tv_label_download; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // // }
import android.app.ProgressDialog; import android.os.Bundle; import android.os.Environment; import android.view.*; import android.widget.GridView; import android.widget.SearchView; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnItemClick; import com.devspark.appmsg.AppMsg; import com.koushikdutta.async.future.FutureCallback; import com.koushikdutta.ion.Ion; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.SongAdapter; import retrofit.Callback; import retrofit.RetrofitError; import retrofit.client.Response; import java.io.File; import java.util.ArrayList;
package pt.forkit.androidlx_2014.ui.fragment; public class SearchFragment extends BaseFragment { @InjectView(R.id.gv_songs) GridView mGvSongs; @OnItemClick(R.id.gv_songs) public void onSongClick(int position){
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java // public class SongAdapter extends BaseAdapter { // // private final boolean showDownload; // private ArrayList<Track> mTracks; // private Context ctx; // LayoutInflater inflater; // // public SongAdapter(ArrayList<Track> tracks, Context ctx, boolean showDownload) { // this.ctx = ctx; // mTracks = new ArrayList<Track>(); // // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // this.showDownload = showDownload; // } // // @Override // public int getCount() { // return mTracks.size(); // } // // @Override // public Track getItem(int i) { // return mTracks.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.grid_item_song, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // final Track t = getItem(i); // // if(showDownload){ // // } else { // holder.tv_label_download.setText(ctx.getString(R.string.play_song)); // } // // return view; // } // // static class ViewHolder { // @InjectView(R.id.tv_title) TextView tv_title; // @InjectView(R.id.iv_artwork) ImageView iv_artwork; // @InjectView(R.id.tv_label_download) TextView tv_label_download; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // // } // Path: 7 - After Calligraphy/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/SearchFragment.java import android.app.ProgressDialog; import android.os.Bundle; import android.os.Environment; import android.view.*; import android.widget.GridView; import android.widget.SearchView; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnItemClick; import com.devspark.appmsg.AppMsg; import com.koushikdutta.async.future.FutureCallback; import com.koushikdutta.ion.Ion; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.SongAdapter; import retrofit.Callback; import retrofit.RetrofitError; import retrofit.client.Response; import java.io.File; import java.util.ArrayList; package pt.forkit.androidlx_2014.ui.fragment; public class SearchFragment extends BaseFragment { @InjectView(R.id.gv_songs) GridView mGvSongs; @OnItemClick(R.id.gv_songs) public void onSongClick(int position){
Track t = (Track) mGvSongs.getItemAtPosition(position);
ForkITdev/androidlx_2014
8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/rest/AuthorizationInterceptor.java
// Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/rest/constants/Urls.java // public class Urls { // // public static final String SOUNDCLOUD_CLIENT_ID = "SOUNDCLOUD_ID_HERE"; // // }
import pt.forkit.androidlx_2014.rest.constants.Urls; import retrofit.RequestInterceptor;
package pt.forkit.androidlx_2014.rest; /** */ public class AuthorizationInterceptor implements RequestInterceptor { @Override public void intercept(RequestInterceptor.RequestFacade requestFacade) {
// Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/rest/constants/Urls.java // public class Urls { // // public static final String SOUNDCLOUD_CLIENT_ID = "SOUNDCLOUD_ID_HERE"; // // } // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/rest/AuthorizationInterceptor.java import pt.forkit.androidlx_2014.rest.constants.Urls; import retrofit.RequestInterceptor; package pt.forkit.androidlx_2014.rest; /** */ public class AuthorizationInterceptor implements RequestInterceptor { @Override public void intercept(RequestInterceptor.RequestFacade requestFacade) {
requestFacade.addEncodedQueryParam("client_id", Urls.SOUNDCLOUD_CLIENT_ID);
ForkITdev/androidlx_2014
2 - After Retrofit/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // }
import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import butterknife.ButterKnife; import butterknife.InjectView; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.ArrayList;
package pt.forkit.androidlx_2014.ui.adapter; /** */ public class SongAdapter extends BaseAdapter { private final boolean showDownload;
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // Path: 2 - After Retrofit/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import butterknife.ButterKnife; import butterknife.InjectView; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.ArrayList; package pt.forkit.androidlx_2014.ui.adapter; /** */ public class SongAdapter extends BaseAdapter { private final boolean showDownload;
private ArrayList<Track> mTracks;
ForkITdev/androidlx_2014
1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/MyTracksFragment.java
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java // public class SongAdapter extends BaseAdapter { // // private final boolean showDownload; // private ArrayList<Track> mTracks; // private Context ctx; // LayoutInflater inflater; // // public SongAdapter(ArrayList<Track> tracks, Context ctx, boolean showDownload) { // this.ctx = ctx; // mTracks = new ArrayList<Track>(); // // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // this.showDownload = showDownload; // } // // @Override // public int getCount() { // return mTracks.size(); // } // // @Override // public Track getItem(int i) { // return mTracks.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.grid_item_song, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // final Track t = getItem(i); // // if(showDownload){ // // } else { // holder.tv_label_download.setText(ctx.getString(R.string.play_song)); // } // // return view; // } // // static class ViewHolder { // @InjectView(R.id.tv_title) TextView tv_title; // @InjectView(R.id.iv_artwork) ImageView iv_artwork; // @InjectView(R.id.tv_label_download) TextView tv_label_download; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // // }
import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.GridView; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnItemClick; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.SongAdapter; import java.io.File; import java.util.ArrayList; import java.util.List;
package pt.forkit.androidlx_2014.ui.fragment; public class MyTracksFragment extends BaseFragment { @InjectView(R.id.gv_songs) GridView mGvSongs;
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/adapter/SongAdapter.java // public class SongAdapter extends BaseAdapter { // // private final boolean showDownload; // private ArrayList<Track> mTracks; // private Context ctx; // LayoutInflater inflater; // // public SongAdapter(ArrayList<Track> tracks, Context ctx, boolean showDownload) { // this.ctx = ctx; // mTracks = new ArrayList<Track>(); // // this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // this.showDownload = showDownload; // } // // @Override // public int getCount() { // return mTracks.size(); // } // // @Override // public Track getItem(int i) { // return mTracks.get(i); // } // // @Override // public long getItemId(int i) { // return 0; // } // // @Override // public View getView(int i, View view, ViewGroup viewGroup) { // // ViewHolder holder; // if (view != null) { // holder = (ViewHolder) view.getTag(); // } else { // view = inflater.inflate(R.layout.grid_item_song, null, false); // holder = new ViewHolder(view); // view.setTag(holder); // } // // final Track t = getItem(i); // // if(showDownload){ // // } else { // holder.tv_label_download.setText(ctx.getString(R.string.play_song)); // } // // return view; // } // // static class ViewHolder { // @InjectView(R.id.tv_title) TextView tv_title; // @InjectView(R.id.iv_artwork) ImageView iv_artwork; // @InjectView(R.id.tv_label_download) TextView tv_label_download; // // public ViewHolder(View view) { // ButterKnife.inject(this, view); // } // } // // } // Path: 1 - After Butterknife/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/MyTracksFragment.java import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.GridView; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnItemClick; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment; import pt.forkit.androidlx_2014.ui.adapter.SongAdapter; import java.io.File; import java.util.ArrayList; import java.util.List; package pt.forkit.androidlx_2014.ui.fragment; public class MyTracksFragment extends BaseFragment { @InjectView(R.id.gv_songs) GridView mGvSongs;
private List<Track> mTracks;
ForkITdev/androidlx_2014
0 - And so it begins/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/SearchFragment.java
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // }
import android.os.Bundle; import android.view.*; import android.widget.GridView; import android.widget.SearchView; import android.widget.Toast; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment;
@Override public boolean onQueryTextChange(String newText) { return true; } }); item.setActionView(sv); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_tracks, container, false); mGvSongs = (GridView) v.findViewById(R.id.gv_songs); return v; } @Override public void onResume() { super.onResume(); searchSongs(""); } private void searchSongs(String query){ if(!query.equals("")) Toast.makeText(getActivity(), "Will search for: " + query, Toast.LENGTH_SHORT).show(); }
// Path: 5 - After AppMsg/app/src/main/java/pt/forkit/androidlx_2014/domain/Track.java // public class Track { // // @SerializedName("id") // private int trackId; // // @SerializedName("title") // private String title; // // @SerializedName("sharing") // private String sharing; // // @SerializedName("artwork_url") // private String artworkUrl; // // @SerializedName("duration") // private long duration; // // @SerializedName("genre") // private String genre; // // @SerializedName("streamable") // private boolean streamable; // // @SerializedName("downloadable") // private boolean downloadable; // // @SerializedName("download_url") // private String downloadUrl; // // @SerializedName("stream_url") // private String streamUrl; // // @SerializedName("original_content_size") // private long originalContentSize; // // private String localPath; // // public Track() { // } // // public int getTrackId() { // return trackId; // } // // public String getTitle() { // return title; // } // // public String getSharing() { // return sharing; // } // // public String getArtworkUrl() { // return artworkUrl; // } // // public long getDuration() { // return duration; // } // // public String getGenre() { // return genre; // } // // public boolean isStreamable() { // return streamable; // } // // public boolean isDownloadable() { // return downloadable; // } // // public String getDownloadUrl() { // return downloadUrl + "?client_id=" + Urls.SOUNDCLOUD_CLIENT_ID; // } // // public long getOriginalContentSize() { // return originalContentSize; // } // // public String getLocalPath() { // return localPath; // } // // public void setLocalPath(String localPath) { // this.localPath = localPath; // } // // } // // Path: 8 - After EventBus/app/src/main/java/pt/forkit/androidlx_2014/ui/BaseFragment.java // @SuppressLint("NewApi") // public class BaseFragment extends Fragment { // // protected Mp3Api mApi; // // public BaseFragment() { // super(); // } // // public void onCreate(Bundle s) { // super.onCreate(s); // // RestAdapter restAdapter = new RestAdapter.Builder() // .setLogLevel(RestAdapter.LogLevel.FULL) // .setRequestInterceptor(new AuthorizationInterceptor()) // .setEndpoint("http://api.soundcloud.com") // .build(); // // mApi = restAdapter.create(Mp3Api.class); // // } // // } // Path: 0 - And so it begins/app/src/main/java/pt/forkit/androidlx_2014/ui/fragment/SearchFragment.java import android.os.Bundle; import android.view.*; import android.widget.GridView; import android.widget.SearchView; import android.widget.Toast; import pt.forkit.androidlx_2014.R; import pt.forkit.androidlx_2014.domain.Track; import pt.forkit.androidlx_2014.ui.BaseFragment; @Override public boolean onQueryTextChange(String newText) { return true; } }); item.setActionView(sv); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_tracks, container, false); mGvSongs = (GridView) v.findViewById(R.id.gv_songs); return v; } @Override public void onResume() { super.onResume(); searchSongs(""); } private void searchSongs(String query){ if(!query.equals("")) Toast.makeText(getActivity(), "Will search for: " + query, Toast.LENGTH_SHORT).show(); }
public void onSongDownload(final Track t) {
Divendo/math-dragon
mathdragon/src/main/java/org/teaminfty/math_dragon/view/TouchFeedbackVibrator.java
// Path: mathdragon/src/main/java/org/teaminfty/math_dragon/model/AppSettings.java // public abstract class AppSettings // { // /** The name of the shared preferences that contains the app settings. */ // public static final String SHARED_PREFS_NAME = "app_settings"; // // /** A boolean settings that indicates whether or not to vibrate on certain input events (true by default). */ // public static final String VIBRATION_ON = "vibration_on"; // // /** // * Returns whether or not to vibrate on certain input events. // * @param context The context that is used to access the settings. // * @return True if vibration is on (default), false otherwise. // */ // public static boolean getVibrationOn(Context context) // { // return context.getSharedPreferences(SHARED_PREFS_NAME, Activity.MODE_PRIVATE).getBoolean(VIBRATION_ON, true); // } // // /** // * Sets whether or not to vibrate on certain input events. // * @param context The context that is used to access the settings. // * @param vibrationOn True if vibration should be on, false otherwise. // */ // public static void setVibrationOn(Context context, boolean vibrationOn) // { // // Get an editor for the settings // SharedPreferences settings = context.getSharedPreferences(SHARED_PREFS_NAME, Activity.MODE_PRIVATE); // SharedPreferences.Editor settingsEditor = settings.edit(); // // // Set the new vibration setting // settingsEditor.putBoolean(VIBRATION_ON, vibrationOn); // // // Commit the changes // settingsEditor.commit(); // } // }
import android.content.Context; import android.os.Vibrator; import org.teaminfty.math_dragon.model.AppSettings;
package org.teaminfty.math_dragon.view; /** Class that handles the vibrating for the touch feedback. */ public abstract class TouchFeedbackVibrator { /** * Vibrates on a long press. * @param context The context that is used to access the vibrator. */ public static void longPressVibrate(Context context) {
// Path: mathdragon/src/main/java/org/teaminfty/math_dragon/model/AppSettings.java // public abstract class AppSettings // { // /** The name of the shared preferences that contains the app settings. */ // public static final String SHARED_PREFS_NAME = "app_settings"; // // /** A boolean settings that indicates whether or not to vibrate on certain input events (true by default). */ // public static final String VIBRATION_ON = "vibration_on"; // // /** // * Returns whether or not to vibrate on certain input events. // * @param context The context that is used to access the settings. // * @return True if vibration is on (default), false otherwise. // */ // public static boolean getVibrationOn(Context context) // { // return context.getSharedPreferences(SHARED_PREFS_NAME, Activity.MODE_PRIVATE).getBoolean(VIBRATION_ON, true); // } // // /** // * Sets whether or not to vibrate on certain input events. // * @param context The context that is used to access the settings. // * @param vibrationOn True if vibration should be on, false otherwise. // */ // public static void setVibrationOn(Context context, boolean vibrationOn) // { // // Get an editor for the settings // SharedPreferences settings = context.getSharedPreferences(SHARED_PREFS_NAME, Activity.MODE_PRIVATE); // SharedPreferences.Editor settingsEditor = settings.edit(); // // // Set the new vibration setting // settingsEditor.putBoolean(VIBRATION_ON, vibrationOn); // // // Commit the changes // settingsEditor.commit(); // } // } // Path: mathdragon/src/main/java/org/teaminfty/math_dragon/view/TouchFeedbackVibrator.java import android.content.Context; import android.os.Vibrator; import org.teaminfty.math_dragon.model.AppSettings; package org.teaminfty.math_dragon.view; /** Class that handles the vibrating for the touch feedback. */ public abstract class TouchFeedbackVibrator { /** * Vibrates on a long press. * @param context The context that is used to access the vibrator. */ public static void longPressVibrate(Context context) {
if(AppSettings.getVibrationOn(context))
Divendo/math-dragon
mathdragon/src/main/java/org/teaminfty/math_dragon/view/math/ExpressionDuplicator.java
// Path: mathdragon/src/main/java/org/teaminfty/math_dragon/exceptions/ParseException.java // public class ParseException extends MathException // { // private static final long serialVersionUID = -5061683875213406313L; // // // note: javadoc copy-pasted from exception, because {@inheritDoc} doesn't // // work for some reason // /** // * Constructs a new parse exception with <code>null</code> as its detail // * message. The cause is not initialized, and may subsequently be // * initialized by a call to {@link #initCause}. // */ // public ParseException() // {} // // /** // * Constructs a new parse exception with the specified detail message. The // * cause is not initialized, and may subsequently be initialized by a call // * to {@link #initCause}. // * // * @param message // * the detail message. The detail message is saved for later // * retrieval by the {@link #getMessage()} method. // */ // public ParseException(String message) // { // super(message); // } // // /** // * Constructs a new parse exception with the specified cause and a detail // * message of <tt>(cause==null ? null : cause.toString())</tt> (which // * typically contains the class and detail message of <tt>cause</tt>). This // * constructor is useful for exceptions that are little more than wrappers // * for other throwables (for example, // * {@link java.security.PrivilegedActionException}). // * // * @param cause // * the cause (which is saved for later retrieval by the // * {@link #getCause()} method). (A <tt>null</tt> value is permitted, // * and indicates that the cause is nonexistent or unknown.) // * @since 1.4 // */ // public ParseException(Throwable cause) // { // super(cause); // } // // /** // * Construct a new parse exception with the specified cause and a detail // * message that describes the error. // * // * @param message // * The detailed human-readable message. // * @param cause // * Some evil demon that wants to crash our program. // */ // public ParseException(String message, Throwable cause) // { // super(message, cause); // } // // /** // * Construct a new parse exception with the specified abstract syntax tree // * that caused this exception to be thrown. // * // * @param ast // * The abstract syntax tree from Symja. // */ // public ParseException(AST ast) // { // super(ast.toString() + ": invalid operation"); // } // // /** // * Construct a new parse exception with the specified mathematical // * expression that caused this exception to be thrown. // * // * @param expr // * The mathematical expression from Symja. // */ // public ParseException(IExpr expr) // { // super(expr.toString() + ": invalid operation"); // } // }
import javax.xml.parsers.ParserConfigurationException; import org.teaminfty.math_dragon.exceptions.ParseException; import org.w3c.dom.Document;
package org.teaminfty.math_dragon.view.math; public final class ExpressionDuplicator { /** Creates a deep copy of the given {@link Expression} * @param src The {@link Expression} to copy * @return The copy of the given {@link Expression} (returns <tt>null</tt> if the function somehow fails) */ public static Expression deepCopy(Expression src) { try { // Create a XML document of the source object Document doc = Expression.createXMLDocument(); src.writeToXML(doc, doc.getDocumentElement()); // Create a new object from the XML and return that object return ExpressionXMLReader.fromXML(doc); } catch(ParserConfigurationException e) { e.printStackTrace(); return null; }
// Path: mathdragon/src/main/java/org/teaminfty/math_dragon/exceptions/ParseException.java // public class ParseException extends MathException // { // private static final long serialVersionUID = -5061683875213406313L; // // // note: javadoc copy-pasted from exception, because {@inheritDoc} doesn't // // work for some reason // /** // * Constructs a new parse exception with <code>null</code> as its detail // * message. The cause is not initialized, and may subsequently be // * initialized by a call to {@link #initCause}. // */ // public ParseException() // {} // // /** // * Constructs a new parse exception with the specified detail message. The // * cause is not initialized, and may subsequently be initialized by a call // * to {@link #initCause}. // * // * @param message // * the detail message. The detail message is saved for later // * retrieval by the {@link #getMessage()} method. // */ // public ParseException(String message) // { // super(message); // } // // /** // * Constructs a new parse exception with the specified cause and a detail // * message of <tt>(cause==null ? null : cause.toString())</tt> (which // * typically contains the class and detail message of <tt>cause</tt>). This // * constructor is useful for exceptions that are little more than wrappers // * for other throwables (for example, // * {@link java.security.PrivilegedActionException}). // * // * @param cause // * the cause (which is saved for later retrieval by the // * {@link #getCause()} method). (A <tt>null</tt> value is permitted, // * and indicates that the cause is nonexistent or unknown.) // * @since 1.4 // */ // public ParseException(Throwable cause) // { // super(cause); // } // // /** // * Construct a new parse exception with the specified cause and a detail // * message that describes the error. // * // * @param message // * The detailed human-readable message. // * @param cause // * Some evil demon that wants to crash our program. // */ // public ParseException(String message, Throwable cause) // { // super(message, cause); // } // // /** // * Construct a new parse exception with the specified abstract syntax tree // * that caused this exception to be thrown. // * // * @param ast // * The abstract syntax tree from Symja. // */ // public ParseException(AST ast) // { // super(ast.toString() + ": invalid operation"); // } // // /** // * Construct a new parse exception with the specified mathematical // * expression that caused this exception to be thrown. // * // * @param expr // * The mathematical expression from Symja. // */ // public ParseException(IExpr expr) // { // super(expr.toString() + ": invalid operation"); // } // } // Path: mathdragon/src/main/java/org/teaminfty/math_dragon/view/math/ExpressionDuplicator.java import javax.xml.parsers.ParserConfigurationException; import org.teaminfty.math_dragon.exceptions.ParseException; import org.w3c.dom.Document; package org.teaminfty.math_dragon.view.math; public final class ExpressionDuplicator { /** Creates a deep copy of the given {@link Expression} * @param src The {@link Expression} to copy * @return The copy of the given {@link Expression} (returns <tt>null</tt> if the function somehow fails) */ public static Expression deepCopy(Expression src) { try { // Create a XML document of the source object Document doc = Expression.createXMLDocument(); src.writeToXML(doc, doc.getDocumentElement()); // Create a new object from the XML and return that object return ExpressionXMLReader.fromXML(doc); } catch(ParserConfigurationException e) { e.printStackTrace(); return null; }
catch(ParseException e)
Divendo/math-dragon
mathdragon/src/main/java/org/teaminfty/math_dragon/view/math/SourceView.java
// Path: mathdragon/src/main/java/org/teaminfty/math_dragon/view/MathShadow.java // public class MathShadow extends DragShadowBuilder // { // /** The {@link Expression} that is being dragged */ // private Expression mathObject = null; // // /** Constructor // * @param mo The {@link Expression} that is to be dragged // */ // public MathShadow(Expression mo) // { // setDragState(mathObject = mo); // mathObject.setLevel(0); // } // // /** Recursively sets the DRAG state for the given {@link Expression} and all of its children // * @param mo The {@link Expression} to set the DRAG state for */ // private void setDragState(Expression mo) // { // // Set the state // mo.setState(HoverState.DRAG); // // // Loop through the children and set their states // for(int i = 0; i < mo.getChildCount(); ++i) // setDragState(mo.getChild(i)); // } // // /** Returns the {@link Expression} in this shadow // * @return The {@link Expression} in this shadow */ // public Expression getExpression() // { return mathObject; } // // /** Returns the bounding box of the current {@link Expression} relative to the touch point // * @return The requested bounding box // */ // public Rect getExpressionBounding() // { // // Calculate the bounding box // Rect boundingBox = mathObject.getBoundingBox(); // // // Translate the bounding, so that our touch point becomes the origin // boundingBox.offset(-boundingBox.width() / 2, -boundingBox.height() - 64); // // // Return the result // return boundingBox; // } // // @Override // public void onProvideShadowMetrics(Point shadowSize, Point shadowTouchPoint) // { // // Calculate the bounding box // Rect boundingBox = mathObject.getBoundingBox(); // // // Set the size and the touch point // shadowSize.set(boundingBox.width(), boundingBox.height()); // shadowTouchPoint.set(boundingBox.width() / 2, boundingBox.height() + 64); // } // // @Override // public void onDrawShadow(Canvas canvas) // { // // Simply draw the math object // mathObject.draw(canvas); // } // // } // // Path: mathdragon/src/main/java/org/teaminfty/math_dragon/view/math/source/Expression.java // public abstract class Expression // { // /** A paint that's used to draw an empty box */ // private Paint paintEmptyBox = new Paint(); // // /** Default constructor */ // public Expression() // { // // Initialise the paint // paintEmptyBox.setStyle(Paint.Style.STROKE); // paintEmptyBox.setPathEffect(new DashPathEffect(new float[] {16.0f, 16.0f}, 0)); // } // // /** Creates a new {@link Expression} that can be dragged // * @return The new {@link Expression} */ // public abstract org.teaminfty.math_dragon.view.math.Expression createMathObject(); // // /** Draws the {@link SourceExpression} // * @param canvas The canvas to draw on // * @param w The maximum width // * @param h The maximum height */ // public abstract void draw(Canvas canvas, int w, int h); // // /** Helper function to draw a dashed empty box // * @param canvas The canvas to draw the box on // * @param rect The rectangle that describes the box that is to be drawn */ // protected void drawEmptyBox(Canvas canvas, Rect rect) // { // // Copy the rectangle and then make it just a bit smaller // Rect copy = new Rect(rect); // final int d = (int) Math.ceil(org.teaminfty.math_dragon.view.math.Expression.lineWidth / 2); // copy.inset(d, d); // // // Draw the dashed rectangle // paintEmptyBox.setStrokeWidth(org.teaminfty.math_dragon.view.math.Expression.lineWidth); // canvas.drawRect(copy, paintEmptyBox); // } // // /** Helper function, returns a rectangle of the given ratio (width : height) that fits exactly in the given maximum rectangle. // * @param maxWidth The maximum width of the rectangle // * @param maxHeight The maximum height of the rectangle // * @param ratio The ratio (width : height) // * @return The rectangle fitting in the given maximum size // */ // protected Rect getRectBoundingBox(int maxWidth, int maxHeight, float ratio) // { // if(maxWidth / ratio <= maxHeight) // return new Rect(0, 0, maxWidth, (int) (maxWidth / ratio)); // else // return new Rect(0, 0, (int) (maxHeight * ratio), maxHeight); // } // }
import org.teaminfty.math_dragon.R; import org.teaminfty.math_dragon.view.MathShadow; import org.teaminfty.math_dragon.view.math.source.Expression; import android.annotation.SuppressLint; import android.content.ClipData; import android.content.Context; import android.graphics.Canvas; import android.graphics.Rect; import android.util.AttributeSet; import android.view.MotionEvent;
package org.teaminfty.math_dragon.view.math; public class SourceView extends android.view.View { /** The {@link Expression} that will be used as a source for {@link org.teaminfty.math_dragon.view.math.Expression}s */
// Path: mathdragon/src/main/java/org/teaminfty/math_dragon/view/MathShadow.java // public class MathShadow extends DragShadowBuilder // { // /** The {@link Expression} that is being dragged */ // private Expression mathObject = null; // // /** Constructor // * @param mo The {@link Expression} that is to be dragged // */ // public MathShadow(Expression mo) // { // setDragState(mathObject = mo); // mathObject.setLevel(0); // } // // /** Recursively sets the DRAG state for the given {@link Expression} and all of its children // * @param mo The {@link Expression} to set the DRAG state for */ // private void setDragState(Expression mo) // { // // Set the state // mo.setState(HoverState.DRAG); // // // Loop through the children and set their states // for(int i = 0; i < mo.getChildCount(); ++i) // setDragState(mo.getChild(i)); // } // // /** Returns the {@link Expression} in this shadow // * @return The {@link Expression} in this shadow */ // public Expression getExpression() // { return mathObject; } // // /** Returns the bounding box of the current {@link Expression} relative to the touch point // * @return The requested bounding box // */ // public Rect getExpressionBounding() // { // // Calculate the bounding box // Rect boundingBox = mathObject.getBoundingBox(); // // // Translate the bounding, so that our touch point becomes the origin // boundingBox.offset(-boundingBox.width() / 2, -boundingBox.height() - 64); // // // Return the result // return boundingBox; // } // // @Override // public void onProvideShadowMetrics(Point shadowSize, Point shadowTouchPoint) // { // // Calculate the bounding box // Rect boundingBox = mathObject.getBoundingBox(); // // // Set the size and the touch point // shadowSize.set(boundingBox.width(), boundingBox.height()); // shadowTouchPoint.set(boundingBox.width() / 2, boundingBox.height() + 64); // } // // @Override // public void onDrawShadow(Canvas canvas) // { // // Simply draw the math object // mathObject.draw(canvas); // } // // } // // Path: mathdragon/src/main/java/org/teaminfty/math_dragon/view/math/source/Expression.java // public abstract class Expression // { // /** A paint that's used to draw an empty box */ // private Paint paintEmptyBox = new Paint(); // // /** Default constructor */ // public Expression() // { // // Initialise the paint // paintEmptyBox.setStyle(Paint.Style.STROKE); // paintEmptyBox.setPathEffect(new DashPathEffect(new float[] {16.0f, 16.0f}, 0)); // } // // /** Creates a new {@link Expression} that can be dragged // * @return The new {@link Expression} */ // public abstract org.teaminfty.math_dragon.view.math.Expression createMathObject(); // // /** Draws the {@link SourceExpression} // * @param canvas The canvas to draw on // * @param w The maximum width // * @param h The maximum height */ // public abstract void draw(Canvas canvas, int w, int h); // // /** Helper function to draw a dashed empty box // * @param canvas The canvas to draw the box on // * @param rect The rectangle that describes the box that is to be drawn */ // protected void drawEmptyBox(Canvas canvas, Rect rect) // { // // Copy the rectangle and then make it just a bit smaller // Rect copy = new Rect(rect); // final int d = (int) Math.ceil(org.teaminfty.math_dragon.view.math.Expression.lineWidth / 2); // copy.inset(d, d); // // // Draw the dashed rectangle // paintEmptyBox.setStrokeWidth(org.teaminfty.math_dragon.view.math.Expression.lineWidth); // canvas.drawRect(copy, paintEmptyBox); // } // // /** Helper function, returns a rectangle of the given ratio (width : height) that fits exactly in the given maximum rectangle. // * @param maxWidth The maximum width of the rectangle // * @param maxHeight The maximum height of the rectangle // * @param ratio The ratio (width : height) // * @return The rectangle fitting in the given maximum size // */ // protected Rect getRectBoundingBox(int maxWidth, int maxHeight, float ratio) // { // if(maxWidth / ratio <= maxHeight) // return new Rect(0, 0, maxWidth, (int) (maxWidth / ratio)); // else // return new Rect(0, 0, (int) (maxHeight * ratio), maxHeight); // } // } // Path: mathdragon/src/main/java/org/teaminfty/math_dragon/view/math/SourceView.java import org.teaminfty.math_dragon.R; import org.teaminfty.math_dragon.view.MathShadow; import org.teaminfty.math_dragon.view.math.source.Expression; import android.annotation.SuppressLint; import android.content.ClipData; import android.content.Context; import android.graphics.Canvas; import android.graphics.Rect; import android.util.AttributeSet; import android.view.MotionEvent; package org.teaminfty.math_dragon.view.math; public class SourceView extends android.view.View { /** The {@link Expression} that will be used as a source for {@link org.teaminfty.math_dragon.view.math.Expression}s */
private Expression mathSourceObject = null;
Divendo/math-dragon
mathdragon/src/main/java/org/teaminfty/math_dragon/view/math/Function.java
// Path: mathdragon/src/main/java/org/teaminfty/math_dragon/view/TypefaceHolder.java // public final class TypefaceHolder // { // /** Initialises the fonts from the given {@link AssetManager} // * @param assets The {@link AssetManager} */ // public static void loadFromAssets(AssetManager assets) // { // dejavuSans = Typeface.createFromAsset(assets, "DejaVuSans.ttf"); // } // // /** The DejaVu sans font */ // public static Typeface dejavuSans = null; // }
import org.teaminfty.math_dragon.view.TypefaceHolder; import org.w3c.dom.Document; import org.w3c.dom.Element; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Point; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Region;
public Function() { this(FunctionType.SIN); } /** * Constructor with specified type * * @param t * The kind of function that we're constructing */ public Function(FunctionType t) { this(t, null); } /** * Constructor with specified type and value. * * @param t * The kind of function that we're constructing * @param value * The mathematical expression */ public Function(FunctionType t, Expression value) { type = t; children.add(value != null ? value : new Empty()); operatorPaint.setAntiAlias(true); operatorPaint.setStrokeWidth(Expression.lineWidth);
// Path: mathdragon/src/main/java/org/teaminfty/math_dragon/view/TypefaceHolder.java // public final class TypefaceHolder // { // /** Initialises the fonts from the given {@link AssetManager} // * @param assets The {@link AssetManager} */ // public static void loadFromAssets(AssetManager assets) // { // dejavuSans = Typeface.createFromAsset(assets, "DejaVuSans.ttf"); // } // // /** The DejaVu sans font */ // public static Typeface dejavuSans = null; // } // Path: mathdragon/src/main/java/org/teaminfty/math_dragon/view/math/Function.java import org.teaminfty.math_dragon.view.TypefaceHolder; import org.w3c.dom.Document; import org.w3c.dom.Element; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Point; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Region; public Function() { this(FunctionType.SIN); } /** * Constructor with specified type * * @param t * The kind of function that we're constructing */ public Function(FunctionType t) { this(t, null); } /** * Constructor with specified type and value. * * @param t * The kind of function that we're constructing * @param value * The mathematical expression */ public Function(FunctionType t, Expression value) { type = t; children.add(value != null ? value : new Empty()); operatorPaint.setAntiAlias(true); operatorPaint.setStrokeWidth(Expression.lineWidth);
operatorPaint.setTypeface(TypefaceHolder.dejavuSans);
sviperll/static-mustache
static-mustache/src/main/java/com/github/sviperll/staticmustache/token/util/PositionHodingTokenProcessor.java
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/Position.java // @SuppressWarnings("serial") // public class Position implements Serializable { // private final String fileName; // private final int row; // private final String currentLine; // private final int col; // public Position(String fileName, int row, String currentLine, int col) { // this.fileName = fileName; // this.row = row; // this.currentLine = currentLine; // this.col = col; // } // // public String fileName() { // return fileName; // } // // public String currentLine() { // return currentLine; // } // // public int row() { // return row; // } // // public int col() { // return col; // } // // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/PositionedToken.java // public class PositionedToken<T> { // private final Position position; // private final T innerToken; // public PositionedToken(Position position, @Nullable T innerToken) { // this.position = position; // this.innerToken = innerToken; // } // // public Position position() { // return position; // } // // public T innerToken() { // return innerToken; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/TokenProcessor.java // public interface TokenProcessor<T> { // static Character EOF = null; // // void processToken(@Nullable T token) throws ProcessingException; // }
import com.github.sviperll.staticmustache.PositionedToken; import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.TokenProcessor; import com.github.sviperll.staticmustache.Position;
/* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token.util; /** * * @author Victor Nazarov <asviraspossible@gmail.com> * @param <T> */ public class PositionHodingTokenProcessor<T> implements TokenProcessor<T> { private final TokenProcessor<PositionedToken<T>> downstream;
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/Position.java // @SuppressWarnings("serial") // public class Position implements Serializable { // private final String fileName; // private final int row; // private final String currentLine; // private final int col; // public Position(String fileName, int row, String currentLine, int col) { // this.fileName = fileName; // this.row = row; // this.currentLine = currentLine; // this.col = col; // } // // public String fileName() { // return fileName; // } // // public String currentLine() { // return currentLine; // } // // public int row() { // return row; // } // // public int col() { // return col; // } // // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/PositionedToken.java // public class PositionedToken<T> { // private final Position position; // private final T innerToken; // public PositionedToken(Position position, @Nullable T innerToken) { // this.position = position; // this.innerToken = innerToken; // } // // public Position position() { // return position; // } // // public T innerToken() { // return innerToken; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/TokenProcessor.java // public interface TokenProcessor<T> { // static Character EOF = null; // // void processToken(@Nullable T token) throws ProcessingException; // } // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/util/PositionHodingTokenProcessor.java import com.github.sviperll.staticmustache.PositionedToken; import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.TokenProcessor; import com.github.sviperll.staticmustache.Position; /* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token.util; /** * * @author Victor Nazarov <asviraspossible@gmail.com> * @param <T> */ public class PositionHodingTokenProcessor<T> implements TokenProcessor<T> { private final TokenProcessor<PositionedToken<T>> downstream;
private Position position = null;
sviperll/static-mustache
static-mustache/src/main/java/com/github/sviperll/staticmustache/token/util/PositionHodingTokenProcessor.java
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/Position.java // @SuppressWarnings("serial") // public class Position implements Serializable { // private final String fileName; // private final int row; // private final String currentLine; // private final int col; // public Position(String fileName, int row, String currentLine, int col) { // this.fileName = fileName; // this.row = row; // this.currentLine = currentLine; // this.col = col; // } // // public String fileName() { // return fileName; // } // // public String currentLine() { // return currentLine; // } // // public int row() { // return row; // } // // public int col() { // return col; // } // // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/PositionedToken.java // public class PositionedToken<T> { // private final Position position; // private final T innerToken; // public PositionedToken(Position position, @Nullable T innerToken) { // this.position = position; // this.innerToken = innerToken; // } // // public Position position() { // return position; // } // // public T innerToken() { // return innerToken; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/TokenProcessor.java // public interface TokenProcessor<T> { // static Character EOF = null; // // void processToken(@Nullable T token) throws ProcessingException; // }
import com.github.sviperll.staticmustache.PositionedToken; import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.TokenProcessor; import com.github.sviperll.staticmustache.Position;
/* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token.util; /** * * @author Victor Nazarov <asviraspossible@gmail.com> * @param <T> */ public class PositionHodingTokenProcessor<T> implements TokenProcessor<T> { private final TokenProcessor<PositionedToken<T>> downstream; private Position position = null; public PositionHodingTokenProcessor(TokenProcessor<PositionedToken<T>> downstream) { this.downstream = downstream; } public void setPosition(Position position) { this.position = position; } @Override
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/Position.java // @SuppressWarnings("serial") // public class Position implements Serializable { // private final String fileName; // private final int row; // private final String currentLine; // private final int col; // public Position(String fileName, int row, String currentLine, int col) { // this.fileName = fileName; // this.row = row; // this.currentLine = currentLine; // this.col = col; // } // // public String fileName() { // return fileName; // } // // public String currentLine() { // return currentLine; // } // // public int row() { // return row; // } // // public int col() { // return col; // } // // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/PositionedToken.java // public class PositionedToken<T> { // private final Position position; // private final T innerToken; // public PositionedToken(Position position, @Nullable T innerToken) { // this.position = position; // this.innerToken = innerToken; // } // // public Position position() { // return position; // } // // public T innerToken() { // return innerToken; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/TokenProcessor.java // public interface TokenProcessor<T> { // static Character EOF = null; // // void processToken(@Nullable T token) throws ProcessingException; // } // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/util/PositionHodingTokenProcessor.java import com.github.sviperll.staticmustache.PositionedToken; import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.TokenProcessor; import com.github.sviperll.staticmustache.Position; /* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token.util; /** * * @author Victor Nazarov <asviraspossible@gmail.com> * @param <T> */ public class PositionHodingTokenProcessor<T> implements TokenProcessor<T> { private final TokenProcessor<PositionedToken<T>> downstream; private Position position = null; public PositionHodingTokenProcessor(TokenProcessor<PositionedToken<T>> downstream) { this.downstream = downstream; } public void setPosition(Position position) { this.position = position; } @Override
public void processToken(T transformedToken) throws ProcessingException {
sviperll/static-mustache
static-mustache/src/main/java/com/github/sviperll/staticmustache/token/EndMustacheTokenizerState.java
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // }
import com.github.sviperll.staticmustache.ProcessingException;
/* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ class EndMustacheTokenizerState implements MustacheTokenizerState { private final MustacheTokenizer tokenizer; private final boolean expectsThree; EndMustacheTokenizerState(final MustacheTokenizer tokenizer, boolean expectsThree) { this.tokenizer = tokenizer; this.expectsThree = expectsThree; } @Override
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/EndMustacheTokenizerState.java import com.github.sviperll.staticmustache.ProcessingException; /* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ class EndMustacheTokenizerState implements MustacheTokenizerState { private final MustacheTokenizer tokenizer; private final boolean expectsThree; EndMustacheTokenizerState(final MustacheTokenizer tokenizer, boolean expectsThree) { this.tokenizer = tokenizer; this.expectsThree = expectsThree; } @Override
public Void twoOpenBraces() throws ProcessingException {
sviperll/static-mustache
static-mustache/src/main/java/com/github/sviperll/staticmustache/token/CommentMustacheTokenizerState.java
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // }
import com.github.sviperll.staticmustache.ProcessingException;
/* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token; class CommentMustacheTokenizerState implements MustacheTokenizerState { private final MustacheTokenizer tokenizer; CommentMustacheTokenizerState(MustacheTokenizer tokenizer) { this.tokenizer = tokenizer; } @Override
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/CommentMustacheTokenizerState.java import com.github.sviperll.staticmustache.ProcessingException; /* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token; class CommentMustacheTokenizerState implements MustacheTokenizerState { private final MustacheTokenizer tokenizer; CommentMustacheTokenizerState(MustacheTokenizer tokenizer) { this.tokenizer = tokenizer; } @Override
public void beforeStateChange() throws ProcessingException {
sviperll/static-mustache
static-mustache/src/main/java/com/github/sviperll/staticmustache/token/BeforeIdentifierMustacheTokenizerState.java
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // }
import com.github.sviperll.staticmustache.ProcessingException;
/* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ class BeforeIdentifierMustacheTokenizerState implements MustacheTokenizerState { final MustacheTagKind kind; private final MustacheTokenizer tokenizer; BeforeIdentifierMustacheTokenizerState(MustacheTagKind kind, final MustacheTokenizer outer) { this.tokenizer = outer; this.kind = kind; } @Override
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/BeforeIdentifierMustacheTokenizerState.java import com.github.sviperll.staticmustache.ProcessingException; /* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ class BeforeIdentifierMustacheTokenizerState implements MustacheTokenizerState { final MustacheTagKind kind; private final MustacheTokenizer tokenizer; BeforeIdentifierMustacheTokenizerState(MustacheTagKind kind, final MustacheTokenizer outer) { this.tokenizer = outer; this.kind = kind; } @Override
public Void twoOpenBraces() throws ProcessingException {
sviperll/static-mustache
static-mustache/src/main/java/com/github/sviperll/staticmustache/token/StartMustacheTokenizerState.java
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // }
import com.github.sviperll.staticmustache.ProcessingException;
/* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ class StartMustacheTokenizerState implements MustacheTokenizerState { private final MustacheTokenizer tokenizer; StartMustacheTokenizerState(final MustacheTokenizer tokenizer) { this.tokenizer = tokenizer; } @Override
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/StartMustacheTokenizerState.java import com.github.sviperll.staticmustache.ProcessingException; /* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ class StartMustacheTokenizerState implements MustacheTokenizerState { private final MustacheTokenizer tokenizer; StartMustacheTokenizerState(final MustacheTokenizer tokenizer) { this.tokenizer = tokenizer; } @Override
public Void twoOpenBraces() throws ProcessingException {
sviperll/static-mustache
static-mustache/src/main/java/com/github/sviperll/staticmustache/token/IdentifierMustacheTokenizerState.java
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/MustacheToken.java // public abstract class MustacheToken { // public static MustacheToken beginSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.beginSection(name); // } // }; // } // public static MustacheToken beginInvertedSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.beginInvertedSection(name); // } // }; // } // public static MustacheToken endSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endSection(name); // } // }; // } // public static MustacheToken variable(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.variable(name); // } // }; // } // public static MustacheToken unescapedVariable(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.unescapedVariable(name); // } // }; // } // public static MustacheToken specialCharacter(final char c) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.specialCharacter(c); // } // }; // } // public static MustacheToken text(final String s) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.text(s); // } // }; // } // public static MustacheToken endOfFile() { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endOfFile(); // } // }; // } // // public abstract <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E; // // private MustacheToken() { // } // public interface Visitor<R, E extends Exception> { // R beginSection(String name) throws E; // R beginInvertedSection(String name) throws E; // R endSection(String name) throws E; // R variable(String name) throws E; // R unescapedVariable(String name) throws E; // R specialCharacter(char c) throws E; // R text(String s) throws E; // R endOfFile() throws E; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // }
import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.MustacheToken;
/* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ class IdentifierMustacheTokenizerState implements MustacheTokenizerState { final MustacheTagKind kind; final StringBuilder name; private final MustacheTokenizer tokenizer; IdentifierMustacheTokenizerState(MustacheTagKind kind, StringBuilder name, MustacheTokenizer tokenizer) { this.tokenizer = tokenizer; this.kind = kind; this.name = name; } @Override
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/MustacheToken.java // public abstract class MustacheToken { // public static MustacheToken beginSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.beginSection(name); // } // }; // } // public static MustacheToken beginInvertedSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.beginInvertedSection(name); // } // }; // } // public static MustacheToken endSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endSection(name); // } // }; // } // public static MustacheToken variable(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.variable(name); // } // }; // } // public static MustacheToken unescapedVariable(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.unescapedVariable(name); // } // }; // } // public static MustacheToken specialCharacter(final char c) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.specialCharacter(c); // } // }; // } // public static MustacheToken text(final String s) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.text(s); // } // }; // } // public static MustacheToken endOfFile() { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endOfFile(); // } // }; // } // // public abstract <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E; // // private MustacheToken() { // } // public interface Visitor<R, E extends Exception> { // R beginSection(String name) throws E; // R beginInvertedSection(String name) throws E; // R endSection(String name) throws E; // R variable(String name) throws E; // R unescapedVariable(String name) throws E; // R specialCharacter(char c) throws E; // R text(String s) throws E; // R endOfFile() throws E; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/IdentifierMustacheTokenizerState.java import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.MustacheToken; /* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ class IdentifierMustacheTokenizerState implements MustacheTokenizerState { final MustacheTagKind kind; final StringBuilder name; private final MustacheTokenizer tokenizer; IdentifierMustacheTokenizerState(MustacheTagKind kind, StringBuilder name, MustacheTokenizer tokenizer) { this.tokenizer = tokenizer; this.kind = kind; this.name = name; } @Override
public Void twoOpenBraces() throws ProcessingException {
sviperll/static-mustache
static-mustache/src/main/java/com/github/sviperll/staticmustache/token/IdentifierMustacheTokenizerState.java
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/MustacheToken.java // public abstract class MustacheToken { // public static MustacheToken beginSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.beginSection(name); // } // }; // } // public static MustacheToken beginInvertedSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.beginInvertedSection(name); // } // }; // } // public static MustacheToken endSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endSection(name); // } // }; // } // public static MustacheToken variable(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.variable(name); // } // }; // } // public static MustacheToken unescapedVariable(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.unescapedVariable(name); // } // }; // } // public static MustacheToken specialCharacter(final char c) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.specialCharacter(c); // } // }; // } // public static MustacheToken text(final String s) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.text(s); // } // }; // } // public static MustacheToken endOfFile() { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endOfFile(); // } // }; // } // // public abstract <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E; // // private MustacheToken() { // } // public interface Visitor<R, E extends Exception> { // R beginSection(String name) throws E; // R beginInvertedSection(String name) throws E; // R endSection(String name) throws E; // R variable(String name) throws E; // R unescapedVariable(String name) throws E; // R specialCharacter(char c) throws E; // R text(String s) throws E; // R endOfFile() throws E; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // }
import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.MustacheToken;
public Void threeClosingBraces() throws ProcessingException { if (kind == MustacheTagKind.UNESCAPED_VARIABLE_THREE_BRACES) tokenizer.setState(new OutsideMustacheTokenizerState(tokenizer)); else tokenizer.error("Expecting two closing braces, not three"); return null; } @Override public Void character(char c) throws ProcessingException { if (Character.isWhitespace(c)) { boolean expectsThree = kind == MustacheTagKind.UNESCAPED_VARIABLE_THREE_BRACES; tokenizer.setState(new EndMustacheTokenizerState(tokenizer, expectsThree)); } else { name.append(c); } return null; } @Override public Void endOfFile() throws ProcessingException { tokenizer.error("Unclosed field at the end of file"); return null; } @Override public void beforeStateChange() throws ProcessingException { String nameString = name.toString(); switch (kind) { case VARIABLE:
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/MustacheToken.java // public abstract class MustacheToken { // public static MustacheToken beginSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.beginSection(name); // } // }; // } // public static MustacheToken beginInvertedSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.beginInvertedSection(name); // } // }; // } // public static MustacheToken endSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endSection(name); // } // }; // } // public static MustacheToken variable(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.variable(name); // } // }; // } // public static MustacheToken unescapedVariable(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.unescapedVariable(name); // } // }; // } // public static MustacheToken specialCharacter(final char c) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.specialCharacter(c); // } // }; // } // public static MustacheToken text(final String s) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.text(s); // } // }; // } // public static MustacheToken endOfFile() { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endOfFile(); // } // }; // } // // public abstract <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E; // // private MustacheToken() { // } // public interface Visitor<R, E extends Exception> { // R beginSection(String name) throws E; // R beginInvertedSection(String name) throws E; // R endSection(String name) throws E; // R variable(String name) throws E; // R unescapedVariable(String name) throws E; // R specialCharacter(char c) throws E; // R text(String s) throws E; // R endOfFile() throws E; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/IdentifierMustacheTokenizerState.java import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.MustacheToken; public Void threeClosingBraces() throws ProcessingException { if (kind == MustacheTagKind.UNESCAPED_VARIABLE_THREE_BRACES) tokenizer.setState(new OutsideMustacheTokenizerState(tokenizer)); else tokenizer.error("Expecting two closing braces, not three"); return null; } @Override public Void character(char c) throws ProcessingException { if (Character.isWhitespace(c)) { boolean expectsThree = kind == MustacheTagKind.UNESCAPED_VARIABLE_THREE_BRACES; tokenizer.setState(new EndMustacheTokenizerState(tokenizer, expectsThree)); } else { name.append(c); } return null; } @Override public Void endOfFile() throws ProcessingException { tokenizer.error("Unclosed field at the end of file"); return null; } @Override public void beforeStateChange() throws ProcessingException { String nameString = name.toString(); switch (kind) { case VARIABLE:
tokenizer.emitToken(MustacheToken.variable(nameString));
sviperll/static-mustache
static-mustache/src/main/java/com/github/sviperll/staticmustache/token/OutsideMustacheTokenizerState.java
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/MustacheToken.java // public abstract class MustacheToken { // public static MustacheToken beginSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.beginSection(name); // } // }; // } // public static MustacheToken beginInvertedSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.beginInvertedSection(name); // } // }; // } // public static MustacheToken endSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endSection(name); // } // }; // } // public static MustacheToken variable(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.variable(name); // } // }; // } // public static MustacheToken unescapedVariable(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.unescapedVariable(name); // } // }; // } // public static MustacheToken specialCharacter(final char c) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.specialCharacter(c); // } // }; // } // public static MustacheToken text(final String s) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.text(s); // } // }; // } // public static MustacheToken endOfFile() { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endOfFile(); // } // }; // } // // public abstract <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E; // // private MustacheToken() { // } // public interface Visitor<R, E extends Exception> { // R beginSection(String name) throws E; // R beginInvertedSection(String name) throws E; // R endSection(String name) throws E; // R variable(String name) throws E; // R unescapedVariable(String name) throws E; // R specialCharacter(char c) throws E; // R text(String s) throws E; // R endOfFile() throws E; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // }
import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.MustacheToken;
/* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ class OutsideMustacheTokenizerState implements MustacheTokenizerState { private final StringBuilder text = new StringBuilder(); private final MustacheTokenizer tokenizer; OutsideMustacheTokenizerState(final MustacheTokenizer tokenizer) { this.tokenizer = tokenizer; } @Override
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/MustacheToken.java // public abstract class MustacheToken { // public static MustacheToken beginSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.beginSection(name); // } // }; // } // public static MustacheToken beginInvertedSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.beginInvertedSection(name); // } // }; // } // public static MustacheToken endSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endSection(name); // } // }; // } // public static MustacheToken variable(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.variable(name); // } // }; // } // public static MustacheToken unescapedVariable(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.unescapedVariable(name); // } // }; // } // public static MustacheToken specialCharacter(final char c) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.specialCharacter(c); // } // }; // } // public static MustacheToken text(final String s) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.text(s); // } // }; // } // public static MustacheToken endOfFile() { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endOfFile(); // } // }; // } // // public abstract <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E; // // private MustacheToken() { // } // public interface Visitor<R, E extends Exception> { // R beginSection(String name) throws E; // R beginInvertedSection(String name) throws E; // R endSection(String name) throws E; // R variable(String name) throws E; // R unescapedVariable(String name) throws E; // R specialCharacter(char c) throws E; // R text(String s) throws E; // R endOfFile() throws E; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/OutsideMustacheTokenizerState.java import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.MustacheToken; /* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ class OutsideMustacheTokenizerState implements MustacheTokenizerState { private final StringBuilder text = new StringBuilder(); private final MustacheTokenizer tokenizer; OutsideMustacheTokenizerState(final MustacheTokenizer tokenizer) { this.tokenizer = tokenizer; } @Override
public Void twoOpenBraces() throws ProcessingException {
sviperll/static-mustache
static-mustache/src/main/java/com/github/sviperll/staticmustache/token/OutsideMustacheTokenizerState.java
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/MustacheToken.java // public abstract class MustacheToken { // public static MustacheToken beginSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.beginSection(name); // } // }; // } // public static MustacheToken beginInvertedSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.beginInvertedSection(name); // } // }; // } // public static MustacheToken endSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endSection(name); // } // }; // } // public static MustacheToken variable(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.variable(name); // } // }; // } // public static MustacheToken unescapedVariable(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.unescapedVariable(name); // } // }; // } // public static MustacheToken specialCharacter(final char c) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.specialCharacter(c); // } // }; // } // public static MustacheToken text(final String s) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.text(s); // } // }; // } // public static MustacheToken endOfFile() { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endOfFile(); // } // }; // } // // public abstract <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E; // // private MustacheToken() { // } // public interface Visitor<R, E extends Exception> { // R beginSection(String name) throws E; // R beginInvertedSection(String name) throws E; // R endSection(String name) throws E; // R variable(String name) throws E; // R unescapedVariable(String name) throws E; // R specialCharacter(char c) throws E; // R text(String s) throws E; // R endOfFile() throws E; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // }
import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.MustacheToken;
@Override public Void twoOpenBraces() throws ProcessingException { tokenizer.setState(new StartMustacheTokenizerState(tokenizer)); return null; } @Override public Void threeOpenBraces() throws ProcessingException { tokenizer.setState(new BeforeIdentifierMustacheTokenizerState(MustacheTagKind.UNESCAPED_VARIABLE_THREE_BRACES, tokenizer)); return null; } @Override public Void threeClosingBraces() throws ProcessingException { text.append("}}}"); return null; } @Override public Void twoClosingBraces() throws ProcessingException { text.append("}}"); return null; } @Override public Void character(char c) throws ProcessingException { if (c != '\n' && c != '"') { text.append(c); } else { tokenizer.setState(new OutsideMustacheTokenizerState(tokenizer));
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/MustacheToken.java // public abstract class MustacheToken { // public static MustacheToken beginSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.beginSection(name); // } // }; // } // public static MustacheToken beginInvertedSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.beginInvertedSection(name); // } // }; // } // public static MustacheToken endSection(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endSection(name); // } // }; // } // public static MustacheToken variable(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.variable(name); // } // }; // } // public static MustacheToken unescapedVariable(final String name) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.unescapedVariable(name); // } // }; // } // public static MustacheToken specialCharacter(final char c) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.specialCharacter(c); // } // }; // } // public static MustacheToken text(final String s) { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.text(s); // } // }; // } // public static MustacheToken endOfFile() { // return new MustacheToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endOfFile(); // } // }; // } // // public abstract <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E; // // private MustacheToken() { // } // public interface Visitor<R, E extends Exception> { // R beginSection(String name) throws E; // R beginInvertedSection(String name) throws E; // R endSection(String name) throws E; // R variable(String name) throws E; // R unescapedVariable(String name) throws E; // R specialCharacter(char c) throws E; // R text(String s) throws E; // R endOfFile() throws E; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/OutsideMustacheTokenizerState.java import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.MustacheToken; @Override public Void twoOpenBraces() throws ProcessingException { tokenizer.setState(new StartMustacheTokenizerState(tokenizer)); return null; } @Override public Void threeOpenBraces() throws ProcessingException { tokenizer.setState(new BeforeIdentifierMustacheTokenizerState(MustacheTagKind.UNESCAPED_VARIABLE_THREE_BRACES, tokenizer)); return null; } @Override public Void threeClosingBraces() throws ProcessingException { text.append("}}}"); return null; } @Override public Void twoClosingBraces() throws ProcessingException { text.append("}}"); return null; } @Override public Void character(char c) throws ProcessingException { if (c != '\n' && c != '"') { text.append(c); } else { tokenizer.setState(new OutsideMustacheTokenizerState(tokenizer));
tokenizer.emitToken(MustacheToken.specialCharacter(c));
sviperll/static-mustache
static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/context/ContextException.java // @SuppressWarnings("serial") // public class ContextException extends Exception { // ContextException(String message, TypeException ex) { // super(message + ": type error: " + ex.getMessage(), ex); // } // // ContextException(String message) { // super(message); // } // }
import com.github.sviperll.staticmustache.context.ContextException;
/* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ @SuppressWarnings("serial") public class ProcessingException extends Exception { private final Position position; private ProcessingException(Position position, String message, Throwable cause) { super(message, cause); this.position = position; } public ProcessingException(Position position, String message) { this(position, message, null); }
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/context/ContextException.java // @SuppressWarnings("serial") // public class ContextException extends Exception { // ContextException(String message, TypeException ex) { // super(message + ": type error: " + ex.getMessage(), ex); // } // // ContextException(String message) { // super(message); // } // } // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java import com.github.sviperll.staticmustache.context.ContextException; /* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ @SuppressWarnings("serial") public class ProcessingException extends Exception { private final Position position; private ProcessingException(Position position, String message, Throwable cause) { super(message, cause); this.position = position; } public ProcessingException(Position position, String message) { this(position, message, null); }
public ProcessingException(Position position, ContextException contextException) {
sviperll/static-mustache
static-mustache/src/main/java/com/github/sviperll/staticmustache/token/util/PositionedTransformer.java
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/PositionedToken.java // public class PositionedToken<T> { // private final Position position; // private final T innerToken; // public PositionedToken(Position position, @Nullable T innerToken) { // this.position = position; // this.innerToken = innerToken; // } // // public Position position() { // return position; // } // // public T innerToken() { // return innerToken; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/TokenProcessor.java // public interface TokenProcessor<T> { // static Character EOF = null; // // void processToken(@Nullable T token) throws ProcessingException; // }
import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.TokenProcessor; import javax.annotation.Nonnull; import com.github.sviperll.staticmustache.PositionedToken;
/* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token.util; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ class PositionedTransformer<T, U> implements TokenProcessor<PositionedToken<T>> { public static <T, U> TokenProcessor<PositionedToken<T>> decorateTokenProcessor(final TokenProcessorDecorator<T, U> decorator, final TokenProcessor<PositionedToken<U>> positionedDownstream) { PositionHodingTokenProcessor<U> downstream = new PositionHodingTokenProcessor<U>(positionedDownstream); TokenProcessor<T> processor = decorator.decorateTokenProcessor(downstream); return new PositionedTransformer<T, U>(downstream, processor); } private final PositionHodingTokenProcessor<U> downstream; private final TokenProcessor<T> processor; private PositionedTransformer(PositionHodingTokenProcessor<U> downstream, TokenProcessor<T> processor) { this.downstream = downstream; this.processor = processor; } @Override
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/PositionedToken.java // public class PositionedToken<T> { // private final Position position; // private final T innerToken; // public PositionedToken(Position position, @Nullable T innerToken) { // this.position = position; // this.innerToken = innerToken; // } // // public Position position() { // return position; // } // // public T innerToken() { // return innerToken; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/TokenProcessor.java // public interface TokenProcessor<T> { // static Character EOF = null; // // void processToken(@Nullable T token) throws ProcessingException; // } // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/util/PositionedTransformer.java import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.TokenProcessor; import javax.annotation.Nonnull; import com.github.sviperll.staticmustache.PositionedToken; /* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token.util; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ class PositionedTransformer<T, U> implements TokenProcessor<PositionedToken<T>> { public static <T, U> TokenProcessor<PositionedToken<T>> decorateTokenProcessor(final TokenProcessorDecorator<T, U> decorator, final TokenProcessor<PositionedToken<U>> positionedDownstream) { PositionHodingTokenProcessor<U> downstream = new PositionHodingTokenProcessor<U>(positionedDownstream); TokenProcessor<T> processor = decorator.decorateTokenProcessor(downstream); return new PositionedTransformer<T, U>(downstream, processor); } private final PositionHodingTokenProcessor<U> downstream; private final TokenProcessor<T> processor; private PositionedTransformer(PositionHodingTokenProcessor<U> downstream, TokenProcessor<T> processor) { this.downstream = downstream; this.processor = processor; } @Override
public void processToken(@Nonnull final PositionedToken<T> sourceToken) throws ProcessingException {
sviperll/static-mustache
static-mustache/src/main/java/com/github/sviperll/staticmustache/token/util/BracesTokenizer.java
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/PositionedToken.java // public class PositionedToken<T> { // private final Position position; // private final T innerToken; // public PositionedToken(Position position, @Nullable T innerToken) { // this.position = position; // this.innerToken = innerToken; // } // // public Position position() { // return position; // } // // public T innerToken() { // return innerToken; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/TokenProcessor.java // public interface TokenProcessor<T> { // static Character EOF = null; // // void processToken(@Nullable T token) throws ProcessingException; // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/BracesToken.java // public abstract class BracesToken { // public static BracesToken twoOpenBraces() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.twoOpenBraces(); // } // }; // } // public static BracesToken twoClosingBraces() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.twoClosingBraces(); // } // }; // } // public static BracesToken threeOpenBraces() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.threeOpenBraces(); // } // }; // } // public static BracesToken threeClosingBraces() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.threeClosingBraces(); // } // }; // } // public static BracesToken character(final char s) { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.character(s); // } // }; // } // public static BracesToken endOfFile() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endOfFile(); // } // }; // } // public abstract <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E; // private BracesToken() { // } // // public interface Visitor<R, E extends Exception> { // R twoOpenBraces() throws E; // R twoClosingBraces() throws E; // R threeOpenBraces() throws E; // R threeClosingBraces() throws E; // R character(char c) throws E; // R endOfFile() throws E; // } // }
import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.TokenProcessor; import com.github.sviperll.staticmustache.token.BracesToken; import com.github.sviperll.staticmustache.PositionedToken;
/* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token.util; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ public class BracesTokenizer implements TokenProcessor<Character> { static TokenProcessorDecorator<Character, BracesToken> decorator() { return new TokenProcessorDecorator<Character, BracesToken>() { @Override public TokenProcessor<Character> decorateTokenProcessor(TokenProcessor<BracesToken> downstream) { return new BracesTokenizer(downstream); } }; }
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/PositionedToken.java // public class PositionedToken<T> { // private final Position position; // private final T innerToken; // public PositionedToken(Position position, @Nullable T innerToken) { // this.position = position; // this.innerToken = innerToken; // } // // public Position position() { // return position; // } // // public T innerToken() { // return innerToken; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/TokenProcessor.java // public interface TokenProcessor<T> { // static Character EOF = null; // // void processToken(@Nullable T token) throws ProcessingException; // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/BracesToken.java // public abstract class BracesToken { // public static BracesToken twoOpenBraces() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.twoOpenBraces(); // } // }; // } // public static BracesToken twoClosingBraces() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.twoClosingBraces(); // } // }; // } // public static BracesToken threeOpenBraces() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.threeOpenBraces(); // } // }; // } // public static BracesToken threeClosingBraces() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.threeClosingBraces(); // } // }; // } // public static BracesToken character(final char s) { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.character(s); // } // }; // } // public static BracesToken endOfFile() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endOfFile(); // } // }; // } // public abstract <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E; // private BracesToken() { // } // // public interface Visitor<R, E extends Exception> { // R twoOpenBraces() throws E; // R twoClosingBraces() throws E; // R threeOpenBraces() throws E; // R threeClosingBraces() throws E; // R character(char c) throws E; // R endOfFile() throws E; // } // } // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/util/BracesTokenizer.java import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.TokenProcessor; import com.github.sviperll.staticmustache.token.BracesToken; import com.github.sviperll.staticmustache.PositionedToken; /* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token.util; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ public class BracesTokenizer implements TokenProcessor<Character> { static TokenProcessorDecorator<Character, BracesToken> decorator() { return new TokenProcessorDecorator<Character, BracesToken>() { @Override public TokenProcessor<Character> decorateTokenProcessor(TokenProcessor<BracesToken> downstream) { return new BracesTokenizer(downstream); } }; }
public static TokenProcessor<Character> createInstance(String fileName, TokenProcessor<PositionedToken<BracesToken>> downstream) {
sviperll/static-mustache
static-mustache/src/main/java/com/github/sviperll/staticmustache/token/util/LoggingBracesTokenizer.java
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/TokenProcessor.java // public interface TokenProcessor<T> { // static Character EOF = null; // // void processToken(@Nullable T token) throws ProcessingException; // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/BracesToken.java // public abstract class BracesToken { // public static BracesToken twoOpenBraces() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.twoOpenBraces(); // } // }; // } // public static BracesToken twoClosingBraces() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.twoClosingBraces(); // } // }; // } // public static BracesToken threeOpenBraces() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.threeOpenBraces(); // } // }; // } // public static BracesToken threeClosingBraces() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.threeClosingBraces(); // } // }; // } // public static BracesToken character(final char s) { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.character(s); // } // }; // } // public static BracesToken endOfFile() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endOfFile(); // } // }; // } // public abstract <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E; // private BracesToken() { // } // // public interface Visitor<R, E extends Exception> { // R twoOpenBraces() throws E; // R twoClosingBraces() throws E; // R threeOpenBraces() throws E; // R threeClosingBraces() throws E; // R character(char c) throws E; // R endOfFile() throws E; // } // }
import com.github.sviperll.staticmustache.TokenProcessor; import com.github.sviperll.staticmustache.token.BracesToken; import javax.annotation.Nonnull; import com.github.sviperll.staticmustache.ProcessingException;
/* * Copyright (c) 2014, vir * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token.util; /** * * @author vir */ class LoggingBracesTokenizer implements TokenProcessor<BracesToken>, BracesToken.Visitor<Void, RuntimeException> { private final TokenProcessor<BracesToken> downstream; LoggingBracesTokenizer(TokenProcessor<BracesToken> downstream) { this.downstream = downstream; } @Override
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/TokenProcessor.java // public interface TokenProcessor<T> { // static Character EOF = null; // // void processToken(@Nullable T token) throws ProcessingException; // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/BracesToken.java // public abstract class BracesToken { // public static BracesToken twoOpenBraces() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.twoOpenBraces(); // } // }; // } // public static BracesToken twoClosingBraces() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.twoClosingBraces(); // } // }; // } // public static BracesToken threeOpenBraces() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.threeOpenBraces(); // } // }; // } // public static BracesToken threeClosingBraces() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.threeClosingBraces(); // } // }; // } // public static BracesToken character(final char s) { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.character(s); // } // }; // } // public static BracesToken endOfFile() { // return new BracesToken() { // @Override // public <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E { // return visitor.endOfFile(); // } // }; // } // public abstract <R, E extends Exception> R accept(Visitor<R, E> visitor) throws E; // private BracesToken() { // } // // public interface Visitor<R, E extends Exception> { // R twoOpenBraces() throws E; // R twoClosingBraces() throws E; // R threeOpenBraces() throws E; // R threeClosingBraces() throws E; // R character(char c) throws E; // R endOfFile() throws E; // } // } // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/util/LoggingBracesTokenizer.java import com.github.sviperll.staticmustache.TokenProcessor; import com.github.sviperll.staticmustache.token.BracesToken; import javax.annotation.Nonnull; import com.github.sviperll.staticmustache.ProcessingException; /* * Copyright (c) 2014, vir * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token.util; /** * * @author vir */ class LoggingBracesTokenizer implements TokenProcessor<BracesToken>, BracesToken.Visitor<Void, RuntimeException> { private final TokenProcessor<BracesToken> downstream; LoggingBracesTokenizer(TokenProcessor<BracesToken> downstream) { this.downstream = downstream; } @Override
public void processToken(@Nonnull BracesToken token) throws ProcessingException {
sviperll/static-mustache
static-mustache/src/main/java/com/github/sviperll/staticmustache/token/util/PositionAnnotator.java
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/Position.java // @SuppressWarnings("serial") // public class Position implements Serializable { // private final String fileName; // private final int row; // private final String currentLine; // private final int col; // public Position(String fileName, int row, String currentLine, int col) { // this.fileName = fileName; // this.row = row; // this.currentLine = currentLine; // this.col = col; // } // // public String fileName() { // return fileName; // } // // public String currentLine() { // return currentLine; // } // // public int row() { // return row; // } // // public int col() { // return col; // } // // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/PositionedToken.java // public class PositionedToken<T> { // private final Position position; // private final T innerToken; // public PositionedToken(Position position, @Nullable T innerToken) { // this.position = position; // this.innerToken = innerToken; // } // // public Position position() { // return position; // } // // public T innerToken() { // return innerToken; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/TokenProcessor.java // public interface TokenProcessor<T> { // static Character EOF = null; // // void processToken(@Nullable T token) throws ProcessingException; // }
import com.github.sviperll.staticmustache.PositionedToken; import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.TokenProcessor; import com.github.sviperll.staticmustache.Position;
/* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token.util; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ class PositionAnnotator implements TokenProcessor<Character>{ private final String fileName;
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/Position.java // @SuppressWarnings("serial") // public class Position implements Serializable { // private final String fileName; // private final int row; // private final String currentLine; // private final int col; // public Position(String fileName, int row, String currentLine, int col) { // this.fileName = fileName; // this.row = row; // this.currentLine = currentLine; // this.col = col; // } // // public String fileName() { // return fileName; // } // // public String currentLine() { // return currentLine; // } // // public int row() { // return row; // } // // public int col() { // return col; // } // // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/PositionedToken.java // public class PositionedToken<T> { // private final Position position; // private final T innerToken; // public PositionedToken(Position position, @Nullable T innerToken) { // this.position = position; // this.innerToken = innerToken; // } // // public Position position() { // return position; // } // // public T innerToken() { // return innerToken; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/TokenProcessor.java // public interface TokenProcessor<T> { // static Character EOF = null; // // void processToken(@Nullable T token) throws ProcessingException; // } // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/util/PositionAnnotator.java import com.github.sviperll.staticmustache.PositionedToken; import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.TokenProcessor; import com.github.sviperll.staticmustache.Position; /* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token.util; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ class PositionAnnotator implements TokenProcessor<Character>{ private final String fileName;
private final TokenProcessor<PositionedToken<Character>> processor;
sviperll/static-mustache
static-mustache/src/main/java/com/github/sviperll/staticmustache/token/util/PositionAnnotator.java
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/Position.java // @SuppressWarnings("serial") // public class Position implements Serializable { // private final String fileName; // private final int row; // private final String currentLine; // private final int col; // public Position(String fileName, int row, String currentLine, int col) { // this.fileName = fileName; // this.row = row; // this.currentLine = currentLine; // this.col = col; // } // // public String fileName() { // return fileName; // } // // public String currentLine() { // return currentLine; // } // // public int row() { // return row; // } // // public int col() { // return col; // } // // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/PositionedToken.java // public class PositionedToken<T> { // private final Position position; // private final T innerToken; // public PositionedToken(Position position, @Nullable T innerToken) { // this.position = position; // this.innerToken = innerToken; // } // // public Position position() { // return position; // } // // public T innerToken() { // return innerToken; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/TokenProcessor.java // public interface TokenProcessor<T> { // static Character EOF = null; // // void processToken(@Nullable T token) throws ProcessingException; // }
import com.github.sviperll.staticmustache.PositionedToken; import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.TokenProcessor; import com.github.sviperll.staticmustache.Position;
/* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token.util; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ class PositionAnnotator implements TokenProcessor<Character>{ private final String fileName; private final TokenProcessor<PositionedToken<Character>> processor; private int row = 1; private StringBuilder currentLine = new StringBuilder(); public PositionAnnotator(String fileName, TokenProcessor<PositionedToken<Character>> processor) { this.fileName = fileName; this.processor = processor; } @Override
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/Position.java // @SuppressWarnings("serial") // public class Position implements Serializable { // private final String fileName; // private final int row; // private final String currentLine; // private final int col; // public Position(String fileName, int row, String currentLine, int col) { // this.fileName = fileName; // this.row = row; // this.currentLine = currentLine; // this.col = col; // } // // public String fileName() { // return fileName; // } // // public String currentLine() { // return currentLine; // } // // public int row() { // return row; // } // // public int col() { // return col; // } // // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/PositionedToken.java // public class PositionedToken<T> { // private final Position position; // private final T innerToken; // public PositionedToken(Position position, @Nullable T innerToken) { // this.position = position; // this.innerToken = innerToken; // } // // public Position position() { // return position; // } // // public T innerToken() { // return innerToken; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/TokenProcessor.java // public interface TokenProcessor<T> { // static Character EOF = null; // // void processToken(@Nullable T token) throws ProcessingException; // } // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/util/PositionAnnotator.java import com.github.sviperll.staticmustache.PositionedToken; import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.TokenProcessor; import com.github.sviperll.staticmustache.Position; /* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token.util; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ class PositionAnnotator implements TokenProcessor<Character>{ private final String fileName; private final TokenProcessor<PositionedToken<Character>> processor; private int row = 1; private StringBuilder currentLine = new StringBuilder(); public PositionAnnotator(String fileName, TokenProcessor<PositionedToken<Character>> processor) { this.fileName = fileName; this.processor = processor; } @Override
public void processToken(Character token) throws ProcessingException {
sviperll/static-mustache
static-mustache/src/main/java/com/github/sviperll/staticmustache/token/util/PositionAnnotator.java
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/Position.java // @SuppressWarnings("serial") // public class Position implements Serializable { // private final String fileName; // private final int row; // private final String currentLine; // private final int col; // public Position(String fileName, int row, String currentLine, int col) { // this.fileName = fileName; // this.row = row; // this.currentLine = currentLine; // this.col = col; // } // // public String fileName() { // return fileName; // } // // public String currentLine() { // return currentLine; // } // // public int row() { // return row; // } // // public int col() { // return col; // } // // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/PositionedToken.java // public class PositionedToken<T> { // private final Position position; // private final T innerToken; // public PositionedToken(Position position, @Nullable T innerToken) { // this.position = position; // this.innerToken = innerToken; // } // // public Position position() { // return position; // } // // public T innerToken() { // return innerToken; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/TokenProcessor.java // public interface TokenProcessor<T> { // static Character EOF = null; // // void processToken(@Nullable T token) throws ProcessingException; // }
import com.github.sviperll.staticmustache.PositionedToken; import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.TokenProcessor; import com.github.sviperll.staticmustache.Position;
/* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token.util; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ class PositionAnnotator implements TokenProcessor<Character>{ private final String fileName; private final TokenProcessor<PositionedToken<Character>> processor; private int row = 1; private StringBuilder currentLine = new StringBuilder(); public PositionAnnotator(String fileName, TokenProcessor<PositionedToken<Character>> processor) { this.fileName = fileName; this.processor = processor; } @Override public void processToken(Character token) throws ProcessingException { if (token != null && token != '\n') { currentLine.append(token.charValue()); } else { String line = currentLine.toString(); char[] chars = line.toCharArray(); for (int i = 0; i < chars.length; i++) {
// Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/Position.java // @SuppressWarnings("serial") // public class Position implements Serializable { // private final String fileName; // private final int row; // private final String currentLine; // private final int col; // public Position(String fileName, int row, String currentLine, int col) { // this.fileName = fileName; // this.row = row; // this.currentLine = currentLine; // this.col = col; // } // // public String fileName() { // return fileName; // } // // public String currentLine() { // return currentLine; // } // // public int row() { // return row; // } // // public int col() { // return col; // } // // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/PositionedToken.java // public class PositionedToken<T> { // private final Position position; // private final T innerToken; // public PositionedToken(Position position, @Nullable T innerToken) { // this.position = position; // this.innerToken = innerToken; // } // // public Position position() { // return position; // } // // public T innerToken() { // return innerToken; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/ProcessingException.java // @SuppressWarnings("serial") // public class ProcessingException extends Exception { // private final Position position; // // private ProcessingException(Position position, String message, Throwable cause) { // super(message, cause); // this.position = position; // } // // public ProcessingException(Position position, String message) { // this(position, message, null); // } // // public ProcessingException(Position position, ContextException contextException) { // this(position, contextException.getMessage(), contextException); // } // // public Position position() { // return position; // } // } // // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/TokenProcessor.java // public interface TokenProcessor<T> { // static Character EOF = null; // // void processToken(@Nullable T token) throws ProcessingException; // } // Path: static-mustache/src/main/java/com/github/sviperll/staticmustache/token/util/PositionAnnotator.java import com.github.sviperll.staticmustache.PositionedToken; import com.github.sviperll.staticmustache.ProcessingException; import com.github.sviperll.staticmustache.TokenProcessor; import com.github.sviperll.staticmustache.Position; /* * Copyright (c) 2014, Victor Nazarov <asviraspossible@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.github.sviperll.staticmustache.token.util; /** * * @author Victor Nazarov <asviraspossible@gmail.com> */ class PositionAnnotator implements TokenProcessor<Character>{ private final String fileName; private final TokenProcessor<PositionedToken<Character>> processor; private int row = 1; private StringBuilder currentLine = new StringBuilder(); public PositionAnnotator(String fileName, TokenProcessor<PositionedToken<Character>> processor) { this.fileName = fileName; this.processor = processor; } @Override public void processToken(Character token) throws ProcessingException { if (token != null && token != '\n') { currentLine.append(token.charValue()); } else { String line = currentLine.toString(); char[] chars = line.toCharArray(); for (int i = 0; i < chars.length; i++) {
processor.processToken(new PositionedToken<Character>(new Position(fileName, row, line, i + 1), chars[i]));
NickstaDB/BaRMIe
src/nb/barmie/net/TCPEndpoint.java
// Path: src/nb/barmie/exceptions/BaRMIeInvalidPortException.java // public class BaRMIeInvalidPortException extends BaRMIeException { // public BaRMIeInvalidPortException(int portNumber) { // super("The given port number (" + portNumber + ") is not a valid TCP port number."); // } // }
import nb.barmie.exceptions.BaRMIeInvalidPortException;
package nb.barmie.net; /*********************************************************** * Holder for host and port properties of a TCP endpoint. * * Written by Nicky Bloor (@NickstaDB). **********************************************************/ public class TCPEndpoint { /******************* * Properties ******************/ private final String _host; private final int _port; /******************* * Construct the TCP endpoint object with a given host and port. * * @param host The host/IP to use. * @param port The port to use. * @throws nb.barmie.exceptions.BaRMIeInvalidPortException If the given port number is not a valid TCP port number. ******************/
// Path: src/nb/barmie/exceptions/BaRMIeInvalidPortException.java // public class BaRMIeInvalidPortException extends BaRMIeException { // public BaRMIeInvalidPortException(int portNumber) { // super("The given port number (" + portNumber + ") is not a valid TCP port number."); // } // } // Path: src/nb/barmie/net/TCPEndpoint.java import nb.barmie.exceptions.BaRMIeInvalidPortException; package nb.barmie.net; /*********************************************************** * Holder for host and port properties of a TCP endpoint. * * Written by Nicky Bloor (@NickstaDB). **********************************************************/ public class TCPEndpoint { /******************* * Properties ******************/ private final String _host; private final int _port; /******************* * Construct the TCP endpoint object with a given host and port. * * @param host The host/IP to use. * @param port The port to use. * @throws nb.barmie.exceptions.BaRMIeInvalidPortException If the given port number is not a valid TCP port number. ******************/
public TCPEndpoint(String host, int port) throws BaRMIeInvalidPortException {
NickstaDB/BaRMIe
src/nb/barmie/util/ProgramOptions.java
// Path: src/nb/barmie/exceptions/BaRMIeIllegalArgumentException.java // public class BaRMIeIllegalArgumentException extends BaRMIeException { // public BaRMIeIllegalArgumentException(String message) { // super(message); // } // // public BaRMIeIllegalArgumentException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/nb/barmie/exceptions/BaRMIeInvalidPortException.java // public class BaRMIeInvalidPortException extends BaRMIeException { // public BaRMIeInvalidPortException(int portNumber) { // super("The given port number (" + portNumber + ") is not a valid TCP port number."); // } // } // // Path: src/nb/barmie/net/TCPEndpoint.java // public class TCPEndpoint { // /******************* // * Properties // ******************/ // private final String _host; // private final int _port; // // /******************* // * Construct the TCP endpoint object with a given host and port. // * // * @param host The host/IP to use. // * @param port The port to use. // * @throws nb.barmie.exceptions.BaRMIeInvalidPortException If the given port number is not a valid TCP port number. // ******************/ // public TCPEndpoint(String host, int port) throws BaRMIeInvalidPortException { // //Store the properties // this._host = host; // this._port = port; // // //Validate the port number // if(this._port < 1 || this._port > 65535) { // throw new BaRMIeInvalidPortException(this._port); // } // } // // /******************* // * Return a string representation of this endpoint. // * // * @return A host:port string. // ******************/ // public String toString() { // return this._host + ":" + this._port; // } // // /******************* // * Getters // ******************/ // public String getHost() { return this._host; } // public int getPort() { return this._port; } // }
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import nb.barmie.exceptions.BaRMIeIllegalArgumentException; import nb.barmie.exceptions.BaRMIeInvalidPortException; import nb.barmie.net.TCPEndpoint; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.xml.sax.SAXException;
package nb.barmie.util; /*********************************************************** * Class to parse, load, validate and provide access to * command line options. ********************************************************** * Command line should be one of the following: * BaRMIe -enum [options] [target-host] [target-port] * BaRMIe -attack [options] [target-host] [target-port] * * Mode flags: * -enum Enumerate the given target(s) to retrieve details of objects and exploits we can perform. * -attack Enumerate the given target(s) and present attack options. * * Options supported by all modes: * --targets Used to specify a file containing targets (supports nmap output). * --timeout Used to set timeout on blocking TCP operations. * * Options supported by enumeration mode only: * --threads Number of threads to use for scanning. ********************************************************** * Written by Nicky Bloor (@NickstaDB). **********************************************************/ public class ProgramOptions { /******************* * Constants and properties ******************/ //Default option values private final String DEFAULT_MODE = "-enum"; //Default to enumeration mode if no mode is specified private final int DEFAULT_THREADS = 10; //Default to using 10 worker threads private final int DEFAULT_SOCKTIMEOUT = 5000; //Default to a 5 second timeout on blocking socket operations private final int DEFAULT_RMIPORT = 1099; //Default TCP port for RMI registry services //Program option properties private String _mode; //Execution mode - enum/attack
// Path: src/nb/barmie/exceptions/BaRMIeIllegalArgumentException.java // public class BaRMIeIllegalArgumentException extends BaRMIeException { // public BaRMIeIllegalArgumentException(String message) { // super(message); // } // // public BaRMIeIllegalArgumentException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/nb/barmie/exceptions/BaRMIeInvalidPortException.java // public class BaRMIeInvalidPortException extends BaRMIeException { // public BaRMIeInvalidPortException(int portNumber) { // super("The given port number (" + portNumber + ") is not a valid TCP port number."); // } // } // // Path: src/nb/barmie/net/TCPEndpoint.java // public class TCPEndpoint { // /******************* // * Properties // ******************/ // private final String _host; // private final int _port; // // /******************* // * Construct the TCP endpoint object with a given host and port. // * // * @param host The host/IP to use. // * @param port The port to use. // * @throws nb.barmie.exceptions.BaRMIeInvalidPortException If the given port number is not a valid TCP port number. // ******************/ // public TCPEndpoint(String host, int port) throws BaRMIeInvalidPortException { // //Store the properties // this._host = host; // this._port = port; // // //Validate the port number // if(this._port < 1 || this._port > 65535) { // throw new BaRMIeInvalidPortException(this._port); // } // } // // /******************* // * Return a string representation of this endpoint. // * // * @return A host:port string. // ******************/ // public String toString() { // return this._host + ":" + this._port; // } // // /******************* // * Getters // ******************/ // public String getHost() { return this._host; } // public int getPort() { return this._port; } // } // Path: src/nb/barmie/util/ProgramOptions.java import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import nb.barmie.exceptions.BaRMIeIllegalArgumentException; import nb.barmie.exceptions.BaRMIeInvalidPortException; import nb.barmie.net.TCPEndpoint; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; package nb.barmie.util; /*********************************************************** * Class to parse, load, validate and provide access to * command line options. ********************************************************** * Command line should be one of the following: * BaRMIe -enum [options] [target-host] [target-port] * BaRMIe -attack [options] [target-host] [target-port] * * Mode flags: * -enum Enumerate the given target(s) to retrieve details of objects and exploits we can perform. * -attack Enumerate the given target(s) and present attack options. * * Options supported by all modes: * --targets Used to specify a file containing targets (supports nmap output). * --timeout Used to set timeout on blocking TCP operations. * * Options supported by enumeration mode only: * --threads Number of threads to use for scanning. ********************************************************** * Written by Nicky Bloor (@NickstaDB). **********************************************************/ public class ProgramOptions { /******************* * Constants and properties ******************/ //Default option values private final String DEFAULT_MODE = "-enum"; //Default to enumeration mode if no mode is specified private final int DEFAULT_THREADS = 10; //Default to using 10 worker threads private final int DEFAULT_SOCKTIMEOUT = 5000; //Default to a 5 second timeout on blocking socket operations private final int DEFAULT_RMIPORT = 1099; //Default TCP port for RMI registry services //Program option properties private String _mode; //Execution mode - enum/attack
private ArrayList<TCPEndpoint> _targets; //Targets
NickstaDB/BaRMIe
src/nb/barmie/util/ProgramOptions.java
// Path: src/nb/barmie/exceptions/BaRMIeIllegalArgumentException.java // public class BaRMIeIllegalArgumentException extends BaRMIeException { // public BaRMIeIllegalArgumentException(String message) { // super(message); // } // // public BaRMIeIllegalArgumentException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/nb/barmie/exceptions/BaRMIeInvalidPortException.java // public class BaRMIeInvalidPortException extends BaRMIeException { // public BaRMIeInvalidPortException(int portNumber) { // super("The given port number (" + portNumber + ") is not a valid TCP port number."); // } // } // // Path: src/nb/barmie/net/TCPEndpoint.java // public class TCPEndpoint { // /******************* // * Properties // ******************/ // private final String _host; // private final int _port; // // /******************* // * Construct the TCP endpoint object with a given host and port. // * // * @param host The host/IP to use. // * @param port The port to use. // * @throws nb.barmie.exceptions.BaRMIeInvalidPortException If the given port number is not a valid TCP port number. // ******************/ // public TCPEndpoint(String host, int port) throws BaRMIeInvalidPortException { // //Store the properties // this._host = host; // this._port = port; // // //Validate the port number // if(this._port < 1 || this._port > 65535) { // throw new BaRMIeInvalidPortException(this._port); // } // } // // /******************* // * Return a string representation of this endpoint. // * // * @return A host:port string. // ******************/ // public String toString() { // return this._host + ":" + this._port; // } // // /******************* // * Getters // ******************/ // public String getHost() { return this._host; } // public int getPort() { return this._port; } // }
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import nb.barmie.exceptions.BaRMIeIllegalArgumentException; import nb.barmie.exceptions.BaRMIeInvalidPortException; import nb.barmie.net.TCPEndpoint; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.xml.sax.SAXException;
package nb.barmie.util; /*********************************************************** * Class to parse, load, validate and provide access to * command line options. ********************************************************** * Command line should be one of the following: * BaRMIe -enum [options] [target-host] [target-port] * BaRMIe -attack [options] [target-host] [target-port] * * Mode flags: * -enum Enumerate the given target(s) to retrieve details of objects and exploits we can perform. * -attack Enumerate the given target(s) and present attack options. * * Options supported by all modes: * --targets Used to specify a file containing targets (supports nmap output). * --timeout Used to set timeout on blocking TCP operations. * * Options supported by enumeration mode only: * --threads Number of threads to use for scanning. ********************************************************** * Written by Nicky Bloor (@NickstaDB). **********************************************************/ public class ProgramOptions { /******************* * Constants and properties ******************/ //Default option values private final String DEFAULT_MODE = "-enum"; //Default to enumeration mode if no mode is specified private final int DEFAULT_THREADS = 10; //Default to using 10 worker threads private final int DEFAULT_SOCKTIMEOUT = 5000; //Default to a 5 second timeout on blocking socket operations private final int DEFAULT_RMIPORT = 1099; //Default TCP port for RMI registry services //Program option properties private String _mode; //Execution mode - enum/attack private ArrayList<TCPEndpoint> _targets; //Targets private int _threadCount; //Number of threads to use private int _socketTimeout; //Timeout for blocking socket operations /******************* * Initialise default options and parse command line arguments. * * @param args The strings passed to the program on the command line. * @throws nb.barmie.exceptions.BaRMIeIllegalArgumentException If invalid parameters were passed to the program. ******************/
// Path: src/nb/barmie/exceptions/BaRMIeIllegalArgumentException.java // public class BaRMIeIllegalArgumentException extends BaRMIeException { // public BaRMIeIllegalArgumentException(String message) { // super(message); // } // // public BaRMIeIllegalArgumentException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/nb/barmie/exceptions/BaRMIeInvalidPortException.java // public class BaRMIeInvalidPortException extends BaRMIeException { // public BaRMIeInvalidPortException(int portNumber) { // super("The given port number (" + portNumber + ") is not a valid TCP port number."); // } // } // // Path: src/nb/barmie/net/TCPEndpoint.java // public class TCPEndpoint { // /******************* // * Properties // ******************/ // private final String _host; // private final int _port; // // /******************* // * Construct the TCP endpoint object with a given host and port. // * // * @param host The host/IP to use. // * @param port The port to use. // * @throws nb.barmie.exceptions.BaRMIeInvalidPortException If the given port number is not a valid TCP port number. // ******************/ // public TCPEndpoint(String host, int port) throws BaRMIeInvalidPortException { // //Store the properties // this._host = host; // this._port = port; // // //Validate the port number // if(this._port < 1 || this._port > 65535) { // throw new BaRMIeInvalidPortException(this._port); // } // } // // /******************* // * Return a string representation of this endpoint. // * // * @return A host:port string. // ******************/ // public String toString() { // return this._host + ":" + this._port; // } // // /******************* // * Getters // ******************/ // public String getHost() { return this._host; } // public int getPort() { return this._port; } // } // Path: src/nb/barmie/util/ProgramOptions.java import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import nb.barmie.exceptions.BaRMIeIllegalArgumentException; import nb.barmie.exceptions.BaRMIeInvalidPortException; import nb.barmie.net.TCPEndpoint; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; package nb.barmie.util; /*********************************************************** * Class to parse, load, validate and provide access to * command line options. ********************************************************** * Command line should be one of the following: * BaRMIe -enum [options] [target-host] [target-port] * BaRMIe -attack [options] [target-host] [target-port] * * Mode flags: * -enum Enumerate the given target(s) to retrieve details of objects and exploits we can perform. * -attack Enumerate the given target(s) and present attack options. * * Options supported by all modes: * --targets Used to specify a file containing targets (supports nmap output). * --timeout Used to set timeout on blocking TCP operations. * * Options supported by enumeration mode only: * --threads Number of threads to use for scanning. ********************************************************** * Written by Nicky Bloor (@NickstaDB). **********************************************************/ public class ProgramOptions { /******************* * Constants and properties ******************/ //Default option values private final String DEFAULT_MODE = "-enum"; //Default to enumeration mode if no mode is specified private final int DEFAULT_THREADS = 10; //Default to using 10 worker threads private final int DEFAULT_SOCKTIMEOUT = 5000; //Default to a 5 second timeout on blocking socket operations private final int DEFAULT_RMIPORT = 1099; //Default TCP port for RMI registry services //Program option properties private String _mode; //Execution mode - enum/attack private ArrayList<TCPEndpoint> _targets; //Targets private int _threadCount; //Number of threads to use private int _socketTimeout; //Timeout for blocking socket operations /******************* * Initialise default options and parse command line arguments. * * @param args The strings passed to the program on the command line. * @throws nb.barmie.exceptions.BaRMIeIllegalArgumentException If invalid parameters were passed to the program. ******************/
public ProgramOptions(String[] args) throws BaRMIeIllegalArgumentException, BaRMIeInvalidPortException {
NickstaDB/BaRMIe
src/nb/barmie/util/ProgramOptions.java
// Path: src/nb/barmie/exceptions/BaRMIeIllegalArgumentException.java // public class BaRMIeIllegalArgumentException extends BaRMIeException { // public BaRMIeIllegalArgumentException(String message) { // super(message); // } // // public BaRMIeIllegalArgumentException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/nb/barmie/exceptions/BaRMIeInvalidPortException.java // public class BaRMIeInvalidPortException extends BaRMIeException { // public BaRMIeInvalidPortException(int portNumber) { // super("The given port number (" + portNumber + ") is not a valid TCP port number."); // } // } // // Path: src/nb/barmie/net/TCPEndpoint.java // public class TCPEndpoint { // /******************* // * Properties // ******************/ // private final String _host; // private final int _port; // // /******************* // * Construct the TCP endpoint object with a given host and port. // * // * @param host The host/IP to use. // * @param port The port to use. // * @throws nb.barmie.exceptions.BaRMIeInvalidPortException If the given port number is not a valid TCP port number. // ******************/ // public TCPEndpoint(String host, int port) throws BaRMIeInvalidPortException { // //Store the properties // this._host = host; // this._port = port; // // //Validate the port number // if(this._port < 1 || this._port > 65535) { // throw new BaRMIeInvalidPortException(this._port); // } // } // // /******************* // * Return a string representation of this endpoint. // * // * @return A host:port string. // ******************/ // public String toString() { // return this._host + ":" + this._port; // } // // /******************* // * Getters // ******************/ // public String getHost() { return this._host; } // public int getPort() { return this._port; } // }
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import nb.barmie.exceptions.BaRMIeIllegalArgumentException; import nb.barmie.exceptions.BaRMIeInvalidPortException; import nb.barmie.net.TCPEndpoint; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.xml.sax.SAXException;
package nb.barmie.util; /*********************************************************** * Class to parse, load, validate and provide access to * command line options. ********************************************************** * Command line should be one of the following: * BaRMIe -enum [options] [target-host] [target-port] * BaRMIe -attack [options] [target-host] [target-port] * * Mode flags: * -enum Enumerate the given target(s) to retrieve details of objects and exploits we can perform. * -attack Enumerate the given target(s) and present attack options. * * Options supported by all modes: * --targets Used to specify a file containing targets (supports nmap output). * --timeout Used to set timeout on blocking TCP operations. * * Options supported by enumeration mode only: * --threads Number of threads to use for scanning. ********************************************************** * Written by Nicky Bloor (@NickstaDB). **********************************************************/ public class ProgramOptions { /******************* * Constants and properties ******************/ //Default option values private final String DEFAULT_MODE = "-enum"; //Default to enumeration mode if no mode is specified private final int DEFAULT_THREADS = 10; //Default to using 10 worker threads private final int DEFAULT_SOCKTIMEOUT = 5000; //Default to a 5 second timeout on blocking socket operations private final int DEFAULT_RMIPORT = 1099; //Default TCP port for RMI registry services //Program option properties private String _mode; //Execution mode - enum/attack private ArrayList<TCPEndpoint> _targets; //Targets private int _threadCount; //Number of threads to use private int _socketTimeout; //Timeout for blocking socket operations /******************* * Initialise default options and parse command line arguments. * * @param args The strings passed to the program on the command line. * @throws nb.barmie.exceptions.BaRMIeIllegalArgumentException If invalid parameters were passed to the program. ******************/
// Path: src/nb/barmie/exceptions/BaRMIeIllegalArgumentException.java // public class BaRMIeIllegalArgumentException extends BaRMIeException { // public BaRMIeIllegalArgumentException(String message) { // super(message); // } // // public BaRMIeIllegalArgumentException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/nb/barmie/exceptions/BaRMIeInvalidPortException.java // public class BaRMIeInvalidPortException extends BaRMIeException { // public BaRMIeInvalidPortException(int portNumber) { // super("The given port number (" + portNumber + ") is not a valid TCP port number."); // } // } // // Path: src/nb/barmie/net/TCPEndpoint.java // public class TCPEndpoint { // /******************* // * Properties // ******************/ // private final String _host; // private final int _port; // // /******************* // * Construct the TCP endpoint object with a given host and port. // * // * @param host The host/IP to use. // * @param port The port to use. // * @throws nb.barmie.exceptions.BaRMIeInvalidPortException If the given port number is not a valid TCP port number. // ******************/ // public TCPEndpoint(String host, int port) throws BaRMIeInvalidPortException { // //Store the properties // this._host = host; // this._port = port; // // //Validate the port number // if(this._port < 1 || this._port > 65535) { // throw new BaRMIeInvalidPortException(this._port); // } // } // // /******************* // * Return a string representation of this endpoint. // * // * @return A host:port string. // ******************/ // public String toString() { // return this._host + ":" + this._port; // } // // /******************* // * Getters // ******************/ // public String getHost() { return this._host; } // public int getPort() { return this._port; } // } // Path: src/nb/barmie/util/ProgramOptions.java import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import nb.barmie.exceptions.BaRMIeIllegalArgumentException; import nb.barmie.exceptions.BaRMIeInvalidPortException; import nb.barmie.net.TCPEndpoint; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; package nb.barmie.util; /*********************************************************** * Class to parse, load, validate and provide access to * command line options. ********************************************************** * Command line should be one of the following: * BaRMIe -enum [options] [target-host] [target-port] * BaRMIe -attack [options] [target-host] [target-port] * * Mode flags: * -enum Enumerate the given target(s) to retrieve details of objects and exploits we can perform. * -attack Enumerate the given target(s) and present attack options. * * Options supported by all modes: * --targets Used to specify a file containing targets (supports nmap output). * --timeout Used to set timeout on blocking TCP operations. * * Options supported by enumeration mode only: * --threads Number of threads to use for scanning. ********************************************************** * Written by Nicky Bloor (@NickstaDB). **********************************************************/ public class ProgramOptions { /******************* * Constants and properties ******************/ //Default option values private final String DEFAULT_MODE = "-enum"; //Default to enumeration mode if no mode is specified private final int DEFAULT_THREADS = 10; //Default to using 10 worker threads private final int DEFAULT_SOCKTIMEOUT = 5000; //Default to a 5 second timeout on blocking socket operations private final int DEFAULT_RMIPORT = 1099; //Default TCP port for RMI registry services //Program option properties private String _mode; //Execution mode - enum/attack private ArrayList<TCPEndpoint> _targets; //Targets private int _threadCount; //Number of threads to use private int _socketTimeout; //Timeout for blocking socket operations /******************* * Initialise default options and parse command line arguments. * * @param args The strings passed to the program on the command line. * @throws nb.barmie.exceptions.BaRMIeIllegalArgumentException If invalid parameters were passed to the program. ******************/
public ProgramOptions(String[] args) throws BaRMIeIllegalArgumentException, BaRMIeInvalidPortException {
NickstaDB/BaRMIe
src/org/springframework/remoting/rmi/RmiInvocationWrapper_Stub.java
// Path: src/org/springframework/remoting/support/RemoteInvocation.java // public class RemoteInvocation implements Serializable { // //Dummy serialVersionUID // private static final long serialVersionUID = 6876024250231820554L; // // /******************* // * Properties // ******************/ // public String methodName; // public Class[] parameterTypes; // public Object[] arguments; // public Map<String, Serializable> attributes; // }
import java.rmi.RemoteException; import java.rmi.server.RemoteStub; import org.springframework.remoting.support.RemoteInvocation;
package org.springframework.remoting.rmi; /*********************************************************** * RmiInvocationHandler stub for Spring Framework 2 * attacks. * * Written by Nicky Bloor (@NickstaDB). **********************************************************/ public class RmiInvocationWrapper_Stub extends RemoteStub implements RmiInvocationHandler { //Dummy serialVersionUID public static final long serialVersionUID = 2L; /******************* * Stub to call the remote invoke() method. ******************/
// Path: src/org/springframework/remoting/support/RemoteInvocation.java // public class RemoteInvocation implements Serializable { // //Dummy serialVersionUID // private static final long serialVersionUID = 6876024250231820554L; // // /******************* // * Properties // ******************/ // public String methodName; // public Class[] parameterTypes; // public Object[] arguments; // public Map<String, Serializable> attributes; // } // Path: src/org/springframework/remoting/rmi/RmiInvocationWrapper_Stub.java import java.rmi.RemoteException; import java.rmi.server.RemoteStub; import org.springframework.remoting.support.RemoteInvocation; package org.springframework.remoting.rmi; /*********************************************************** * RmiInvocationHandler stub for Spring Framework 2 * attacks. * * Written by Nicky Bloor (@NickstaDB). **********************************************************/ public class RmiInvocationWrapper_Stub extends RemoteStub implements RmiInvocationHandler { //Dummy serialVersionUID public static final long serialVersionUID = 2L; /******************* * Stub to call the remote invoke() method. ******************/
public Object invoke(RemoteInvocation ri) throws RemoteException {
NickstaDB/BaRMIe
src/nb/barmie/modes/enumeration/RMIObject.java
// Path: src/nb/barmie/net/TCPEndpoint.java // public class TCPEndpoint { // /******************* // * Properties // ******************/ // private final String _host; // private final int _port; // // /******************* // * Construct the TCP endpoint object with a given host and port. // * // * @param host The host/IP to use. // * @param port The port to use. // * @throws nb.barmie.exceptions.BaRMIeInvalidPortException If the given port number is not a valid TCP port number. // ******************/ // public TCPEndpoint(String host, int port) throws BaRMIeInvalidPortException { // //Store the properties // this._host = host; // this._port = port; // // //Validate the port number // if(this._port < 1 || this._port > 65535) { // throw new BaRMIeInvalidPortException(this._port); // } // } // // /******************* // * Return a string representation of this endpoint. // * // * @return A host:port string. // ******************/ // public String toString() { // return this._host + ":" + this._port; // } // // /******************* // * Getters // ******************/ // public String getHost() { return this._host; } // public int getPort() { return this._port; } // }
import java.util.ArrayList; import java.util.HashMap; import nb.barmie.net.TCPEndpoint;
package nb.barmie.modes.enumeration; /*********************************************************** * A container to manage and provide access to the details * of a single object that has been exposed through an RMI * registry service. * * Written by Nicky Bloor (@NickstaDB). **********************************************************/ public class RMIObject { /******************* * Properties ******************/ private final String _objectName; //The name that the object is bound to in the RMI registry service private final HashMap<String, ArrayList<String>> _classes; //The classes behind the object, mapped to any string annotations attached to the class definitions
// Path: src/nb/barmie/net/TCPEndpoint.java // public class TCPEndpoint { // /******************* // * Properties // ******************/ // private final String _host; // private final int _port; // // /******************* // * Construct the TCP endpoint object with a given host and port. // * // * @param host The host/IP to use. // * @param port The port to use. // * @throws nb.barmie.exceptions.BaRMIeInvalidPortException If the given port number is not a valid TCP port number. // ******************/ // public TCPEndpoint(String host, int port) throws BaRMIeInvalidPortException { // //Store the properties // this._host = host; // this._port = port; // // //Validate the port number // if(this._port < 1 || this._port > 65535) { // throw new BaRMIeInvalidPortException(this._port); // } // } // // /******************* // * Return a string representation of this endpoint. // * // * @return A host:port string. // ******************/ // public String toString() { // return this._host + ":" + this._port; // } // // /******************* // * Getters // ******************/ // public String getHost() { return this._host; } // public int getPort() { return this._port; } // } // Path: src/nb/barmie/modes/enumeration/RMIObject.java import java.util.ArrayList; import java.util.HashMap; import nb.barmie.net.TCPEndpoint; package nb.barmie.modes.enumeration; /*********************************************************** * A container to manage and provide access to the details * of a single object that has been exposed through an RMI * registry service. * * Written by Nicky Bloor (@NickstaDB). **********************************************************/ public class RMIObject { /******************* * Properties ******************/ private final String _objectName; //The name that the object is bound to in the RMI registry service private final HashMap<String, ArrayList<String>> _classes; //The classes behind the object, mapped to any string annotations attached to the class definitions
private TCPEndpoint _objectEndpoint; //The host/port where the object is hosted
NickstaDB/BaRMIe
src/nb/barmie/modes/enumeration/RMIReplyDataParser.java
// Path: src/nb/barmie/exceptions/BaRMIeInvalidPortException.java // public class BaRMIeInvalidPortException extends BaRMIeException { // public BaRMIeInvalidPortException(int portNumber) { // super("The given port number (" + portNumber + ") is not a valid TCP port number."); // } // } // // Path: src/nb/barmie/exceptions/BaRMIeInvalidReplyDataPacketException.java // public class BaRMIeInvalidReplyDataPacketException extends BaRMIeException { // public BaRMIeInvalidReplyDataPacketException(String message) { // super(message); // } // // public BaRMIeInvalidReplyDataPacketException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/nb/barmie/net/TCPEndpoint.java // public class TCPEndpoint { // /******************* // * Properties // ******************/ // private final String _host; // private final int _port; // // /******************* // * Construct the TCP endpoint object with a given host and port. // * // * @param host The host/IP to use. // * @param port The port to use. // * @throws nb.barmie.exceptions.BaRMIeInvalidPortException If the given port number is not a valid TCP port number. // ******************/ // public TCPEndpoint(String host, int port) throws BaRMIeInvalidPortException { // //Store the properties // this._host = host; // this._port = port; // // //Validate the port number // if(this._port < 1 || this._port > 65535) { // throw new BaRMIeInvalidPortException(this._port); // } // } // // /******************* // * Return a string representation of this endpoint. // * // * @return A host:port string. // ******************/ // public String toString() { // return this._host + ":" + this._port; // } // // /******************* // * Getters // ******************/ // public String getHost() { return this._host; } // public int getPort() { return this._port; } // }
import java.io.ObjectStreamConstants; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import nb.barmie.exceptions.BaRMIeInvalidPortException; import nb.barmie.exceptions.BaRMIeInvalidReplyDataPacketException; import nb.barmie.net.TCPEndpoint;
package nb.barmie.modes.enumeration; /*********************************************************** * Parser for RMI ReplyData packets (Java serialisation). * * Extracts class names, string annotations, and the TCP * endpoint details of a remote object from the RMI * ReplyData packet. * * Written by Nicky Bloor (@NickstaDB). **********************************************************/ public class RMIReplyDataParser { /******************* * Properties ******************/ private boolean _recordClasses; //Indicates whether class names should be recorded during object parsing private LinkedList<HashMap<Byte, ArrayList<Character>>> _classDataDesc; //List of classDescFlags mapped to field type codes from an object's classDesc /******************* * Construct the reply data parser. ******************/ public RMIReplyDataParser() { this._recordClasses = true; this._classDataDesc = new LinkedList<HashMap<Byte, ArrayList<Character>>>(); } /******************* * Extract object details from a ReplyData that was captured through the * RMI registry proxy. * * @param objName The object name bound to the RMI registry for which data is being extracted. * @param packetBytes The ReplyData captured from the RMI registry which contains the remote object description. * @return An RMIObject describing the remote object. ******************/ public RMIObject extractObjectDetails(String objName, ArrayList<Byte> packetBytes) { LinkedList<Byte> dataStack; RMIObject obj; byte b; int i; //Create the RMIObject with the given object name obj = new RMIObject(objName); //Copy the given buffer into a stack for parsing dataStack = new LinkedList<Byte>(); dataStack.addAll(packetBytes); //Set the 'recordClasses' flag to true so that class descriptions are added to the object description this._recordClasses = true; //Start parsing the object data try { //Validate the RMI packet type byte
// Path: src/nb/barmie/exceptions/BaRMIeInvalidPortException.java // public class BaRMIeInvalidPortException extends BaRMIeException { // public BaRMIeInvalidPortException(int portNumber) { // super("The given port number (" + portNumber + ") is not a valid TCP port number."); // } // } // // Path: src/nb/barmie/exceptions/BaRMIeInvalidReplyDataPacketException.java // public class BaRMIeInvalidReplyDataPacketException extends BaRMIeException { // public BaRMIeInvalidReplyDataPacketException(String message) { // super(message); // } // // public BaRMIeInvalidReplyDataPacketException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/nb/barmie/net/TCPEndpoint.java // public class TCPEndpoint { // /******************* // * Properties // ******************/ // private final String _host; // private final int _port; // // /******************* // * Construct the TCP endpoint object with a given host and port. // * // * @param host The host/IP to use. // * @param port The port to use. // * @throws nb.barmie.exceptions.BaRMIeInvalidPortException If the given port number is not a valid TCP port number. // ******************/ // public TCPEndpoint(String host, int port) throws BaRMIeInvalidPortException { // //Store the properties // this._host = host; // this._port = port; // // //Validate the port number // if(this._port < 1 || this._port > 65535) { // throw new BaRMIeInvalidPortException(this._port); // } // } // // /******************* // * Return a string representation of this endpoint. // * // * @return A host:port string. // ******************/ // public String toString() { // return this._host + ":" + this._port; // } // // /******************* // * Getters // ******************/ // public String getHost() { return this._host; } // public int getPort() { return this._port; } // } // Path: src/nb/barmie/modes/enumeration/RMIReplyDataParser.java import java.io.ObjectStreamConstants; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import nb.barmie.exceptions.BaRMIeInvalidPortException; import nb.barmie.exceptions.BaRMIeInvalidReplyDataPacketException; import nb.barmie.net.TCPEndpoint; package nb.barmie.modes.enumeration; /*********************************************************** * Parser for RMI ReplyData packets (Java serialisation). * * Extracts class names, string annotations, and the TCP * endpoint details of a remote object from the RMI * ReplyData packet. * * Written by Nicky Bloor (@NickstaDB). **********************************************************/ public class RMIReplyDataParser { /******************* * Properties ******************/ private boolean _recordClasses; //Indicates whether class names should be recorded during object parsing private LinkedList<HashMap<Byte, ArrayList<Character>>> _classDataDesc; //List of classDescFlags mapped to field type codes from an object's classDesc /******************* * Construct the reply data parser. ******************/ public RMIReplyDataParser() { this._recordClasses = true; this._classDataDesc = new LinkedList<HashMap<Byte, ArrayList<Character>>>(); } /******************* * Extract object details from a ReplyData that was captured through the * RMI registry proxy. * * @param objName The object name bound to the RMI registry for which data is being extracted. * @param packetBytes The ReplyData captured from the RMI registry which contains the remote object description. * @return An RMIObject describing the remote object. ******************/ public RMIObject extractObjectDetails(String objName, ArrayList<Byte> packetBytes) { LinkedList<Byte> dataStack; RMIObject obj; byte b; int i; //Create the RMIObject with the given object name obj = new RMIObject(objName); //Copy the given buffer into a stack for parsing dataStack = new LinkedList<Byte>(); dataStack.addAll(packetBytes); //Set the 'recordClasses' flag to true so that class descriptions are added to the object description this._recordClasses = true; //Start parsing the object data try { //Validate the RMI packet type byte
if(dataStack.peek() != 0x51) { throw new BaRMIeInvalidReplyDataPacketException("The data buffer begins with 0x" + String.format("%02x", dataStack.peek()) + ", which is not a ReplyData packet (0x51 expected)."); }
NickstaDB/BaRMIe
src/nb/barmie/modes/enumeration/RMIReplyDataParser.java
// Path: src/nb/barmie/exceptions/BaRMIeInvalidPortException.java // public class BaRMIeInvalidPortException extends BaRMIeException { // public BaRMIeInvalidPortException(int portNumber) { // super("The given port number (" + portNumber + ") is not a valid TCP port number."); // } // } // // Path: src/nb/barmie/exceptions/BaRMIeInvalidReplyDataPacketException.java // public class BaRMIeInvalidReplyDataPacketException extends BaRMIeException { // public BaRMIeInvalidReplyDataPacketException(String message) { // super(message); // } // // public BaRMIeInvalidReplyDataPacketException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/nb/barmie/net/TCPEndpoint.java // public class TCPEndpoint { // /******************* // * Properties // ******************/ // private final String _host; // private final int _port; // // /******************* // * Construct the TCP endpoint object with a given host and port. // * // * @param host The host/IP to use. // * @param port The port to use. // * @throws nb.barmie.exceptions.BaRMIeInvalidPortException If the given port number is not a valid TCP port number. // ******************/ // public TCPEndpoint(String host, int port) throws BaRMIeInvalidPortException { // //Store the properties // this._host = host; // this._port = port; // // //Validate the port number // if(this._port < 1 || this._port > 65535) { // throw new BaRMIeInvalidPortException(this._port); // } // } // // /******************* // * Return a string representation of this endpoint. // * // * @return A host:port string. // ******************/ // public String toString() { // return this._host + ":" + this._port; // } // // /******************* // * Getters // ******************/ // public String getHost() { return this._host; } // public int getPort() { return this._port; } // }
import java.io.ObjectStreamConstants; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import nb.barmie.exceptions.BaRMIeInvalidPortException; import nb.barmie.exceptions.BaRMIeInvalidReplyDataPacketException; import nb.barmie.net.TCPEndpoint;
* @param dataStack The remaining data in the ReplyData packet. ******************/ private void extractObjectEndpointFromBlockData(RMIObject obj, LinkedList<Byte> dataStack) throws BaRMIeInvalidReplyDataPacketException { LinkedList<Byte> blockData; int blockSize; int i; //Read the block data from the stack blockData = new LinkedList<Byte>(); switch(dataStack.pop()) { //Handle TC_BLOCKDATA elements case ObjectStreamConstants.TC_BLOCKDATA: //Read the block size and contents blockSize = Byte.toUnsignedInt(dataStack.pop()); for(i = 0; i < blockSize; ++i) { blockData.add(dataStack.pop()); } break; //Unknown block data type default: throw new BaRMIeInvalidReplyDataPacketException("Invalid block data element type in class annotation."); } //Examine the block data for object endpoint details (note peeking at the block data, not the data stack) if(this.peekShort(blockData) == 10) { //The first two bytes are 0x00 0a, check for the string "UnicastRef" if(this.extractUtf8(blockData).equals("UnicastRef")) { //UnicastRef found in the block data, extract the object's host and port and add them to the object description (note extraction from block data, not data stack) try {
// Path: src/nb/barmie/exceptions/BaRMIeInvalidPortException.java // public class BaRMIeInvalidPortException extends BaRMIeException { // public BaRMIeInvalidPortException(int portNumber) { // super("The given port number (" + portNumber + ") is not a valid TCP port number."); // } // } // // Path: src/nb/barmie/exceptions/BaRMIeInvalidReplyDataPacketException.java // public class BaRMIeInvalidReplyDataPacketException extends BaRMIeException { // public BaRMIeInvalidReplyDataPacketException(String message) { // super(message); // } // // public BaRMIeInvalidReplyDataPacketException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/nb/barmie/net/TCPEndpoint.java // public class TCPEndpoint { // /******************* // * Properties // ******************/ // private final String _host; // private final int _port; // // /******************* // * Construct the TCP endpoint object with a given host and port. // * // * @param host The host/IP to use. // * @param port The port to use. // * @throws nb.barmie.exceptions.BaRMIeInvalidPortException If the given port number is not a valid TCP port number. // ******************/ // public TCPEndpoint(String host, int port) throws BaRMIeInvalidPortException { // //Store the properties // this._host = host; // this._port = port; // // //Validate the port number // if(this._port < 1 || this._port > 65535) { // throw new BaRMIeInvalidPortException(this._port); // } // } // // /******************* // * Return a string representation of this endpoint. // * // * @return A host:port string. // ******************/ // public String toString() { // return this._host + ":" + this._port; // } // // /******************* // * Getters // ******************/ // public String getHost() { return this._host; } // public int getPort() { return this._port; } // } // Path: src/nb/barmie/modes/enumeration/RMIReplyDataParser.java import java.io.ObjectStreamConstants; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import nb.barmie.exceptions.BaRMIeInvalidPortException; import nb.barmie.exceptions.BaRMIeInvalidReplyDataPacketException; import nb.barmie.net.TCPEndpoint; * @param dataStack The remaining data in the ReplyData packet. ******************/ private void extractObjectEndpointFromBlockData(RMIObject obj, LinkedList<Byte> dataStack) throws BaRMIeInvalidReplyDataPacketException { LinkedList<Byte> blockData; int blockSize; int i; //Read the block data from the stack blockData = new LinkedList<Byte>(); switch(dataStack.pop()) { //Handle TC_BLOCKDATA elements case ObjectStreamConstants.TC_BLOCKDATA: //Read the block size and contents blockSize = Byte.toUnsignedInt(dataStack.pop()); for(i = 0; i < blockSize; ++i) { blockData.add(dataStack.pop()); } break; //Unknown block data type default: throw new BaRMIeInvalidReplyDataPacketException("Invalid block data element type in class annotation."); } //Examine the block data for object endpoint details (note peeking at the block data, not the data stack) if(this.peekShort(blockData) == 10) { //The first two bytes are 0x00 0a, check for the string "UnicastRef" if(this.extractUtf8(blockData).equals("UnicastRef")) { //UnicastRef found in the block data, extract the object's host and port and add them to the object description (note extraction from block data, not data stack) try {
obj.setObjectEndpoint(new TCPEndpoint(this.extractUtf8(blockData), this.extractInt(blockData)));
NickstaDB/BaRMIe
src/nb/barmie/modes/enumeration/RMIReplyDataParser.java
// Path: src/nb/barmie/exceptions/BaRMIeInvalidPortException.java // public class BaRMIeInvalidPortException extends BaRMIeException { // public BaRMIeInvalidPortException(int portNumber) { // super("The given port number (" + portNumber + ") is not a valid TCP port number."); // } // } // // Path: src/nb/barmie/exceptions/BaRMIeInvalidReplyDataPacketException.java // public class BaRMIeInvalidReplyDataPacketException extends BaRMIeException { // public BaRMIeInvalidReplyDataPacketException(String message) { // super(message); // } // // public BaRMIeInvalidReplyDataPacketException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/nb/barmie/net/TCPEndpoint.java // public class TCPEndpoint { // /******************* // * Properties // ******************/ // private final String _host; // private final int _port; // // /******************* // * Construct the TCP endpoint object with a given host and port. // * // * @param host The host/IP to use. // * @param port The port to use. // * @throws nb.barmie.exceptions.BaRMIeInvalidPortException If the given port number is not a valid TCP port number. // ******************/ // public TCPEndpoint(String host, int port) throws BaRMIeInvalidPortException { // //Store the properties // this._host = host; // this._port = port; // // //Validate the port number // if(this._port < 1 || this._port > 65535) { // throw new BaRMIeInvalidPortException(this._port); // } // } // // /******************* // * Return a string representation of this endpoint. // * // * @return A host:port string. // ******************/ // public String toString() { // return this._host + ":" + this._port; // } // // /******************* // * Getters // ******************/ // public String getHost() { return this._host; } // public int getPort() { return this._port; } // }
import java.io.ObjectStreamConstants; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import nb.barmie.exceptions.BaRMIeInvalidPortException; import nb.barmie.exceptions.BaRMIeInvalidReplyDataPacketException; import nb.barmie.net.TCPEndpoint;
******************/ private void extractObjectEndpointFromBlockData(RMIObject obj, LinkedList<Byte> dataStack) throws BaRMIeInvalidReplyDataPacketException { LinkedList<Byte> blockData; int blockSize; int i; //Read the block data from the stack blockData = new LinkedList<Byte>(); switch(dataStack.pop()) { //Handle TC_BLOCKDATA elements case ObjectStreamConstants.TC_BLOCKDATA: //Read the block size and contents blockSize = Byte.toUnsignedInt(dataStack.pop()); for(i = 0; i < blockSize; ++i) { blockData.add(dataStack.pop()); } break; //Unknown block data type default: throw new BaRMIeInvalidReplyDataPacketException("Invalid block data element type in class annotation."); } //Examine the block data for object endpoint details (note peeking at the block data, not the data stack) if(this.peekShort(blockData) == 10) { //The first two bytes are 0x00 0a, check for the string "UnicastRef" if(this.extractUtf8(blockData).equals("UnicastRef")) { //UnicastRef found in the block data, extract the object's host and port and add them to the object description (note extraction from block data, not data stack) try { obj.setObjectEndpoint(new TCPEndpoint(this.extractUtf8(blockData), this.extractInt(blockData)));
// Path: src/nb/barmie/exceptions/BaRMIeInvalidPortException.java // public class BaRMIeInvalidPortException extends BaRMIeException { // public BaRMIeInvalidPortException(int portNumber) { // super("The given port number (" + portNumber + ") is not a valid TCP port number."); // } // } // // Path: src/nb/barmie/exceptions/BaRMIeInvalidReplyDataPacketException.java // public class BaRMIeInvalidReplyDataPacketException extends BaRMIeException { // public BaRMIeInvalidReplyDataPacketException(String message) { // super(message); // } // // public BaRMIeInvalidReplyDataPacketException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/nb/barmie/net/TCPEndpoint.java // public class TCPEndpoint { // /******************* // * Properties // ******************/ // private final String _host; // private final int _port; // // /******************* // * Construct the TCP endpoint object with a given host and port. // * // * @param host The host/IP to use. // * @param port The port to use. // * @throws nb.barmie.exceptions.BaRMIeInvalidPortException If the given port number is not a valid TCP port number. // ******************/ // public TCPEndpoint(String host, int port) throws BaRMIeInvalidPortException { // //Store the properties // this._host = host; // this._port = port; // // //Validate the port number // if(this._port < 1 || this._port > 65535) { // throw new BaRMIeInvalidPortException(this._port); // } // } // // /******************* // * Return a string representation of this endpoint. // * // * @return A host:port string. // ******************/ // public String toString() { // return this._host + ":" + this._port; // } // // /******************* // * Getters // ******************/ // public String getHost() { return this._host; } // public int getPort() { return this._port; } // } // Path: src/nb/barmie/modes/enumeration/RMIReplyDataParser.java import java.io.ObjectStreamConstants; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import nb.barmie.exceptions.BaRMIeInvalidPortException; import nb.barmie.exceptions.BaRMIeInvalidReplyDataPacketException; import nb.barmie.net.TCPEndpoint; ******************/ private void extractObjectEndpointFromBlockData(RMIObject obj, LinkedList<Byte> dataStack) throws BaRMIeInvalidReplyDataPacketException { LinkedList<Byte> blockData; int blockSize; int i; //Read the block data from the stack blockData = new LinkedList<Byte>(); switch(dataStack.pop()) { //Handle TC_BLOCKDATA elements case ObjectStreamConstants.TC_BLOCKDATA: //Read the block size and contents blockSize = Byte.toUnsignedInt(dataStack.pop()); for(i = 0; i < blockSize; ++i) { blockData.add(dataStack.pop()); } break; //Unknown block data type default: throw new BaRMIeInvalidReplyDataPacketException("Invalid block data element type in class annotation."); } //Examine the block data for object endpoint details (note peeking at the block data, not the data stack) if(this.peekShort(blockData) == 10) { //The first two bytes are 0x00 0a, check for the string "UnicastRef" if(this.extractUtf8(blockData).equals("UnicastRef")) { //UnicastRef found in the block data, extract the object's host and port and add them to the object description (note extraction from block data, not data stack) try { obj.setObjectEndpoint(new TCPEndpoint(this.extractUtf8(blockData), this.extractInt(blockData)));
} catch(BaRMIeInvalidPortException bipe) {
mattkol/SugarOnRest
tester/src/com/sugaronrest/tester/LinkedModulesTests.java
// Path: tester/src/com/sugaronrest/tester/custommodels/CustomAcccount2.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class CustomAcccount2 extends Accounts { // // public List<Contacts> getContactLink() { // return contactLink; // } // // public void setContactLink(List<Contacts> value) { // contactLink = value; // } // // public List<Leads> getLeadLink() { // return leadLink; // } // // public void setLeadLink(List<Leads> value) { // leadLink = value; // } // // public List<Cases> getCaseLink() { // return caseLink; // } // // public void setCaseLink(List<Cases> value) { // caseLink = value; // } // // // @JsonProperty("contacts") // private List<Contacts> contactLink; // // @JsonProperty("leads") // private List<Leads> leadLink; // // @JsonProperty("cases") // private List<Cases> caseLink; // }
import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.sugaronrest.*; import com.sugaronrest.modules.Accounts; import com.sugaronrest.modules.Contacts; import com.sugaronrest.tester.custommodels.CustomAcccount1; import com.sugaronrest.tester.custommodels.CustomAcccount2; import com.sugaronrest.tester.helpers.AccountsModule; import com.sugaronrest.tester.helpers.LinkedModules; import com.sugaronrest.utils.JsonObjectMapper; import org.apache.commons.lang.StringUtils; import org.apache.http.HttpStatus; import org.junit.Test; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static org.junit.Assert.*;
public static void linkedRead2Test() throws IOException { SugarRestClient client = new SugarRestClient(TestAccount.Url, TestAccount.Username, TestAccount.Password); // -------------------Bulk Read Account------------------- int count = 10; SugarRestResponse response = AccountsModule.bulkReadAccount(client, count); assertNotNull(response); assertEquals(response.getStatusCode(), HttpStatus.SC_OK); List<Accounts> readAccounts = (List<Accounts>)response.getData(); assertNotNull(readAccounts); assertTrue(readAccounts.size() <= count); // -------------------End Bulk Read Account------------------- // -------------------Read Account Link Concat------------------- String accountId = readAccounts.get(count - 1).getId(); response = LinkedModules.readAccountLinkItems(client, accountId); assertNotNull(response); assertEquals(response.getStatusCode(), HttpStatus.SC_OK); String jsonData = response.getJData(); assertNotNull(jsonData); assertNotSame(jsonData, StringUtils.EMPTY ); // Deserialize json data to custom object ObjectMapper mapper = JsonObjectMapper.getMapper();
// Path: tester/src/com/sugaronrest/tester/custommodels/CustomAcccount2.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class CustomAcccount2 extends Accounts { // // public List<Contacts> getContactLink() { // return contactLink; // } // // public void setContactLink(List<Contacts> value) { // contactLink = value; // } // // public List<Leads> getLeadLink() { // return leadLink; // } // // public void setLeadLink(List<Leads> value) { // leadLink = value; // } // // public List<Cases> getCaseLink() { // return caseLink; // } // // public void setCaseLink(List<Cases> value) { // caseLink = value; // } // // // @JsonProperty("contacts") // private List<Contacts> contactLink; // // @JsonProperty("leads") // private List<Leads> leadLink; // // @JsonProperty("cases") // private List<Cases> caseLink; // } // Path: tester/src/com/sugaronrest/tester/LinkedModulesTests.java import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.sugaronrest.*; import com.sugaronrest.modules.Accounts; import com.sugaronrest.modules.Contacts; import com.sugaronrest.tester.custommodels.CustomAcccount1; import com.sugaronrest.tester.custommodels.CustomAcccount2; import com.sugaronrest.tester.helpers.AccountsModule; import com.sugaronrest.tester.helpers.LinkedModules; import com.sugaronrest.utils.JsonObjectMapper; import org.apache.commons.lang.StringUtils; import org.apache.http.HttpStatus; import org.junit.Test; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static org.junit.Assert.*; public static void linkedRead2Test() throws IOException { SugarRestClient client = new SugarRestClient(TestAccount.Url, TestAccount.Username, TestAccount.Password); // -------------------Bulk Read Account------------------- int count = 10; SugarRestResponse response = AccountsModule.bulkReadAccount(client, count); assertNotNull(response); assertEquals(response.getStatusCode(), HttpStatus.SC_OK); List<Accounts> readAccounts = (List<Accounts>)response.getData(); assertNotNull(readAccounts); assertTrue(readAccounts.size() <= count); // -------------------End Bulk Read Account------------------- // -------------------Read Account Link Concat------------------- String accountId = readAccounts.get(count - 1).getId(); response = LinkedModules.readAccountLinkItems(client, accountId); assertNotNull(response); assertEquals(response.getStatusCode(), HttpStatus.SC_OK); String jsonData = response.getJData(); assertNotNull(jsonData); assertNotSame(jsonData, StringUtils.EMPTY ); // Deserialize json data to custom object ObjectMapper mapper = JsonObjectMapper.getMapper();
CustomAcccount2 customAccount = mapper.readValue(jsonData, CustomAcccount2.class);
mattkol/SugarOnRest
sugaronrest/src/test/java/com/sugaronrest/tests/WikiTests.java
// Path: sugaronrest/src/test/java/com/sugaronrest/tests/custommodels/CustomAcccount2.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class CustomAcccount2 extends Accounts { // // public List<Contacts> getContactLink() { // return contactLink; // } // // public void setContactLink(List<Contacts> value) { // contactLink = value; // } // // public List<Leads> getLeadLink() { // return leadLink; // } // // public void setLeadLink(List<Leads> value) { // leadLink = value; // } // // public List<Cases> getCaseLink() { // return caseLink; // } // // public void setCaseLink(List<Cases> value) { // caseLink = value; // } // // // @JsonProperty("contacts") // private List<Contacts> contactLink; // // @JsonProperty("leads") // private List<Leads> leadLink; // // @JsonProperty("cases") // private List<Cases> caseLink; // } // // Path: sugaronrest/src/test/java/com/sugaronrest/tests/custommodels/CustomAcccount3.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class CustomAcccount3 extends Accounts { // // public List<Leads> getLeadLink() { // return leadLink; // } // // public void setLeadLink(List<Leads> value) { // leadLink = value; // } // // public List<Cases> getCaseLink() { // return caseLink; // } // // public void setCaseLink(List<Cases> value) { // caseLink = value; // } // // @JsonProperty("leads") // private List<Leads> leadLink; // // @JsonProperty("cases") // private List<Cases> caseLink; // }
import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.sugaronrest.*; import com.sugaronrest.modules.*; import com.sugaronrest.tests.custommodels.CustomAcccount1; import com.sugaronrest.tests.custommodels.CustomAcccount2; import com.sugaronrest.tests.custommodels.CustomAcccount3; import com.sugaronrest.utils.JsonObjectMapper; import java.io.IOException; import java.text.ParseException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.sugaronrest.QueryOperator.*;
request.getOptions().setMaxResult(5); List<String> selectedFields = new ArrayList<String>(); selectedFields.add(NameOf.Accounts.Id); selectedFields.add(NameOf.Accounts.Name); selectedFields.add(NameOf.Accounts.Industry); selectedFields.add(NameOf.Accounts.Website); selectedFields.add(NameOf.Accounts.ShippingAddressCity); request.getOptions().setSelectFields(selectedFields); Map<Object, List<String>> linkedListInfo = new HashMap<Object, List<String>>(); List<String> selectContactFields = new ArrayList<String>(); selectContactFields.add(NameOf.Contacts.FirstName); selectContactFields.add(NameOf.Contacts.LastName); selectContactFields.add(NameOf.Contacts.Title); selectContactFields.add(NameOf.Contacts.Description); selectContactFields.add(NameOf.Contacts.PrimaryAddressPostalcode); linkedListInfo.put(Contacts.class, selectContactFields); request.getOptions().setLinkedModules(linkedListInfo); SugarRestResponse response = client.execute(request); String jsonData = response.getJData(); // Deserialize json data to custom object ObjectMapper mapper = JsonObjectMapper.getMapper();
// Path: sugaronrest/src/test/java/com/sugaronrest/tests/custommodels/CustomAcccount2.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class CustomAcccount2 extends Accounts { // // public List<Contacts> getContactLink() { // return contactLink; // } // // public void setContactLink(List<Contacts> value) { // contactLink = value; // } // // public List<Leads> getLeadLink() { // return leadLink; // } // // public void setLeadLink(List<Leads> value) { // leadLink = value; // } // // public List<Cases> getCaseLink() { // return caseLink; // } // // public void setCaseLink(List<Cases> value) { // caseLink = value; // } // // // @JsonProperty("contacts") // private List<Contacts> contactLink; // // @JsonProperty("leads") // private List<Leads> leadLink; // // @JsonProperty("cases") // private List<Cases> caseLink; // } // // Path: sugaronrest/src/test/java/com/sugaronrest/tests/custommodels/CustomAcccount3.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class CustomAcccount3 extends Accounts { // // public List<Leads> getLeadLink() { // return leadLink; // } // // public void setLeadLink(List<Leads> value) { // leadLink = value; // } // // public List<Cases> getCaseLink() { // return caseLink; // } // // public void setCaseLink(List<Cases> value) { // caseLink = value; // } // // @JsonProperty("leads") // private List<Leads> leadLink; // // @JsonProperty("cases") // private List<Cases> caseLink; // } // Path: sugaronrest/src/test/java/com/sugaronrest/tests/WikiTests.java import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.sugaronrest.*; import com.sugaronrest.modules.*; import com.sugaronrest.tests.custommodels.CustomAcccount1; import com.sugaronrest.tests.custommodels.CustomAcccount2; import com.sugaronrest.tests.custommodels.CustomAcccount3; import com.sugaronrest.utils.JsonObjectMapper; import java.io.IOException; import java.text.ParseException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.sugaronrest.QueryOperator.*; request.getOptions().setMaxResult(5); List<String> selectedFields = new ArrayList<String>(); selectedFields.add(NameOf.Accounts.Id); selectedFields.add(NameOf.Accounts.Name); selectedFields.add(NameOf.Accounts.Industry); selectedFields.add(NameOf.Accounts.Website); selectedFields.add(NameOf.Accounts.ShippingAddressCity); request.getOptions().setSelectFields(selectedFields); Map<Object, List<String>> linkedListInfo = new HashMap<Object, List<String>>(); List<String> selectContactFields = new ArrayList<String>(); selectContactFields.add(NameOf.Contacts.FirstName); selectContactFields.add(NameOf.Contacts.LastName); selectContactFields.add(NameOf.Contacts.Title); selectContactFields.add(NameOf.Contacts.Description); selectContactFields.add(NameOf.Contacts.PrimaryAddressPostalcode); linkedListInfo.put(Contacts.class, selectContactFields); request.getOptions().setLinkedModules(linkedListInfo); SugarRestResponse response = client.execute(request); String jsonData = response.getJData(); // Deserialize json data to custom object ObjectMapper mapper = JsonObjectMapper.getMapper();
JavaType type = mapper.getTypeFactory().constructCollectionType(ArrayList.class, CustomAcccount2.class) ;
mattkol/SugarOnRest
sugaronrest/src/test/java/com/sugaronrest/tests/WikiTests.java
// Path: sugaronrest/src/test/java/com/sugaronrest/tests/custommodels/CustomAcccount2.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class CustomAcccount2 extends Accounts { // // public List<Contacts> getContactLink() { // return contactLink; // } // // public void setContactLink(List<Contacts> value) { // contactLink = value; // } // // public List<Leads> getLeadLink() { // return leadLink; // } // // public void setLeadLink(List<Leads> value) { // leadLink = value; // } // // public List<Cases> getCaseLink() { // return caseLink; // } // // public void setCaseLink(List<Cases> value) { // caseLink = value; // } // // // @JsonProperty("contacts") // private List<Contacts> contactLink; // // @JsonProperty("leads") // private List<Leads> leadLink; // // @JsonProperty("cases") // private List<Cases> caseLink; // } // // Path: sugaronrest/src/test/java/com/sugaronrest/tests/custommodels/CustomAcccount3.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class CustomAcccount3 extends Accounts { // // public List<Leads> getLeadLink() { // return leadLink; // } // // public void setLeadLink(List<Leads> value) { // leadLink = value; // } // // public List<Cases> getCaseLink() { // return caseLink; // } // // public void setCaseLink(List<Cases> value) { // caseLink = value; // } // // @JsonProperty("leads") // private List<Leads> leadLink; // // @JsonProperty("cases") // private List<Cases> caseLink; // }
import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.sugaronrest.*; import com.sugaronrest.modules.*; import com.sugaronrest.tests.custommodels.CustomAcccount1; import com.sugaronrest.tests.custommodels.CustomAcccount2; import com.sugaronrest.tests.custommodels.CustomAcccount3; import com.sugaronrest.utils.JsonObjectMapper; import java.io.IOException; import java.text.ParseException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.sugaronrest.QueryOperator.*;
String password = "will"; SugarRestClient client = new SugarRestClient(url, username, password); SugarRestRequest request = new SugarRestRequest(RequestType.LinkedBulkRead); request.setModuleName("Accounts"); request.getOptions().setMaxResult(5); List<String> selectedFields = new ArrayList<String>(); selectedFields.add(NameOf.Accounts.Id); selectedFields.add(NameOf.Accounts.Name); selectedFields.add(NameOf.Accounts.Industry); selectedFields.add(NameOf.Accounts.Website); selectedFields.add(NameOf.Accounts.ShippingAddressCity); request.getOptions().setSelectFields(selectedFields); Map<Object, List<String>> linkedListInfo = new HashMap<Object, List<String>>(); linkedListInfo.put(Cases.class, null); linkedListInfo.put("Contacts", new ArrayList<String>()); request.getOptions().setLinkedModules(linkedListInfo); SugarRestResponse response = client.execute(request); String jsonData = response.getJData(); // Deserialize json data to custom object ObjectMapper mapper = JsonObjectMapper.getMapper();
// Path: sugaronrest/src/test/java/com/sugaronrest/tests/custommodels/CustomAcccount2.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class CustomAcccount2 extends Accounts { // // public List<Contacts> getContactLink() { // return contactLink; // } // // public void setContactLink(List<Contacts> value) { // contactLink = value; // } // // public List<Leads> getLeadLink() { // return leadLink; // } // // public void setLeadLink(List<Leads> value) { // leadLink = value; // } // // public List<Cases> getCaseLink() { // return caseLink; // } // // public void setCaseLink(List<Cases> value) { // caseLink = value; // } // // // @JsonProperty("contacts") // private List<Contacts> contactLink; // // @JsonProperty("leads") // private List<Leads> leadLink; // // @JsonProperty("cases") // private List<Cases> caseLink; // } // // Path: sugaronrest/src/test/java/com/sugaronrest/tests/custommodels/CustomAcccount3.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class CustomAcccount3 extends Accounts { // // public List<Leads> getLeadLink() { // return leadLink; // } // // public void setLeadLink(List<Leads> value) { // leadLink = value; // } // // public List<Cases> getCaseLink() { // return caseLink; // } // // public void setCaseLink(List<Cases> value) { // caseLink = value; // } // // @JsonProperty("leads") // private List<Leads> leadLink; // // @JsonProperty("cases") // private List<Cases> caseLink; // } // Path: sugaronrest/src/test/java/com/sugaronrest/tests/WikiTests.java import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.sugaronrest.*; import com.sugaronrest.modules.*; import com.sugaronrest.tests.custommodels.CustomAcccount1; import com.sugaronrest.tests.custommodels.CustomAcccount2; import com.sugaronrest.tests.custommodels.CustomAcccount3; import com.sugaronrest.utils.JsonObjectMapper; import java.io.IOException; import java.text.ParseException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.sugaronrest.QueryOperator.*; String password = "will"; SugarRestClient client = new SugarRestClient(url, username, password); SugarRestRequest request = new SugarRestRequest(RequestType.LinkedBulkRead); request.setModuleName("Accounts"); request.getOptions().setMaxResult(5); List<String> selectedFields = new ArrayList<String>(); selectedFields.add(NameOf.Accounts.Id); selectedFields.add(NameOf.Accounts.Name); selectedFields.add(NameOf.Accounts.Industry); selectedFields.add(NameOf.Accounts.Website); selectedFields.add(NameOf.Accounts.ShippingAddressCity); request.getOptions().setSelectFields(selectedFields); Map<Object, List<String>> linkedListInfo = new HashMap<Object, List<String>>(); linkedListInfo.put(Cases.class, null); linkedListInfo.put("Contacts", new ArrayList<String>()); request.getOptions().setLinkedModules(linkedListInfo); SugarRestResponse response = client.execute(request); String jsonData = response.getJData(); // Deserialize json data to custom object ObjectMapper mapper = JsonObjectMapper.getMapper();
JavaType type = mapper.getTypeFactory().constructCollectionType(ArrayList.class, CustomAcccount3.class) ;
danilolekovic/iode-old
src/iode/ast/nodes/ASTDeclaration.java
// Path: src/iode/ast/Node.java // public abstract class Node { // public abstract String generate(); // } // // Path: src/iode/util/Errors.java // public class Errors // { // @SuppressWarnings("unchecked") // private static <T extends Throwable> void throwException(Throwable exception, Object dummy) throws T // { // throw (T) exception; // } // // public static void throwException(Throwable exception) // { // Errors.<RuntimeException>throwException(exception, null); // } // }
import iode.ast.Node; import iode.util.Errors;
sb.append("typedef enum { false, true } bool;\n"); sb.append("bool "); sb.append(name); } else if (type.equals("Int")) { sb.append("int "); sb.append(name); } else if (type.equals("Double")) { sb.append("double "); sb.append(name); } else if (type.equals("Char")) { sb.append("char "); sb.append(name); } else if (type.equals("String")) { sb.append("char *"); sb.append(name); } else if (value != null && value instanceof ASTArray) { if (type.equals("Bool")) { sb.append("typedef enum { false, true } bool;\n"); sb.append("bool "); sb.append(name); } else if (type.equals("Int")) { sb.append("int "); sb.append(name); } else if (type.equals("String")) { sb.append("char *"); sb.append(name); } sb.append("[]"); } else {
// Path: src/iode/ast/Node.java // public abstract class Node { // public abstract String generate(); // } // // Path: src/iode/util/Errors.java // public class Errors // { // @SuppressWarnings("unchecked") // private static <T extends Throwable> void throwException(Throwable exception, Object dummy) throws T // { // throw (T) exception; // } // // public static void throwException(Throwable exception) // { // Errors.<RuntimeException>throwException(exception, null); // } // } // Path: src/iode/ast/nodes/ASTDeclaration.java import iode.ast.Node; import iode.util.Errors; sb.append("typedef enum { false, true } bool;\n"); sb.append("bool "); sb.append(name); } else if (type.equals("Int")) { sb.append("int "); sb.append(name); } else if (type.equals("Double")) { sb.append("double "); sb.append(name); } else if (type.equals("Char")) { sb.append("char "); sb.append(name); } else if (type.equals("String")) { sb.append("char *"); sb.append(name); } else if (value != null && value instanceof ASTArray) { if (type.equals("Bool")) { sb.append("typedef enum { false, true } bool;\n"); sb.append("bool "); sb.append(name); } else if (type.equals("Int")) { sb.append("int "); sb.append(name); } else if (type.equals("String")) { sb.append("char *"); sb.append(name); } sb.append("[]"); } else {
Errors.throwException(new Exception("'" + type + "' is not a valid object type"));
danilolekovic/iode-old
src/iode/parsing/IParser.java
// Path: src/iode/ast/Node.java // public abstract class Node { // public abstract String generate(); // } // // Path: src/iode/scanning/Token.java // public class Token { // private TokenType type; // private String value; // // public Token(TokenType type, String value) { // this.type = type; // this.value = value; // } // // public TokenType getType() { // return type; // } // // public void setType(TokenType type) { // this.type = type; // } // // public String getValue() { // return value; // } // // public void setValue(String value) { // this.value = value; // } // } // // Path: src/iode/scanning/TokenType.java // public enum TokenType { // // Regular // IDENTIFIER, // STRING, // CHAR, // NUMBER, // DOUBLE, // BOOLEAN, // NIL, // // // Keywords // LET, // VAR, // FUNCTION, // IMPORT, // RETURN, // ENUM, // // // Symbols // EQUALS, // ADD, // SUB, // MUL, // DIV, // GT, // LT, // DOT, // COMMA, // COLON, // LPAREN, // RPAREN, // LBRACE, // RBRACE, // LBRACK, // RBRACK, // NEWLINE // }
import iode.ast.Node; import iode.scanning.Token; import iode.scanning.TokenType;
package iode.parsing; public interface IParser { Token peekToken();
// Path: src/iode/ast/Node.java // public abstract class Node { // public abstract String generate(); // } // // Path: src/iode/scanning/Token.java // public class Token { // private TokenType type; // private String value; // // public Token(TokenType type, String value) { // this.type = type; // this.value = value; // } // // public TokenType getType() { // return type; // } // // public void setType(TokenType type) { // this.type = type; // } // // public String getValue() { // return value; // } // // public void setValue(String value) { // this.value = value; // } // } // // Path: src/iode/scanning/TokenType.java // public enum TokenType { // // Regular // IDENTIFIER, // STRING, // CHAR, // NUMBER, // DOUBLE, // BOOLEAN, // NIL, // // // Keywords // LET, // VAR, // FUNCTION, // IMPORT, // RETURN, // ENUM, // // // Symbols // EQUALS, // ADD, // SUB, // MUL, // DIV, // GT, // LT, // DOT, // COMMA, // COLON, // LPAREN, // RPAREN, // LBRACE, // RBRACE, // LBRACK, // RBRACK, // NEWLINE // } // Path: src/iode/parsing/IParser.java import iode.ast.Node; import iode.scanning.Token; import iode.scanning.TokenType; package iode.parsing; public interface IParser { Token peekToken();
boolean peekCheck(TokenType type);
danilolekovic/iode-old
src/iode/parsing/IParser.java
// Path: src/iode/ast/Node.java // public abstract class Node { // public abstract String generate(); // } // // Path: src/iode/scanning/Token.java // public class Token { // private TokenType type; // private String value; // // public Token(TokenType type, String value) { // this.type = type; // this.value = value; // } // // public TokenType getType() { // return type; // } // // public void setType(TokenType type) { // this.type = type; // } // // public String getValue() { // return value; // } // // public void setValue(String value) { // this.value = value; // } // } // // Path: src/iode/scanning/TokenType.java // public enum TokenType { // // Regular // IDENTIFIER, // STRING, // CHAR, // NUMBER, // DOUBLE, // BOOLEAN, // NIL, // // // Keywords // LET, // VAR, // FUNCTION, // IMPORT, // RETURN, // ENUM, // // // Symbols // EQUALS, // ADD, // SUB, // MUL, // DIV, // GT, // LT, // DOT, // COMMA, // COLON, // LPAREN, // RPAREN, // LBRACE, // RBRACE, // LBRACK, // RBRACK, // NEWLINE // }
import iode.ast.Node; import iode.scanning.Token; import iode.scanning.TokenType;
package iode.parsing; public interface IParser { Token peekToken(); boolean peekCheck(TokenType type); boolean peekSpecificCheck(TokenType type, int i); Token peekSpecific(int i); Token nextToken(); void skipNewline();
// Path: src/iode/ast/Node.java // public abstract class Node { // public abstract String generate(); // } // // Path: src/iode/scanning/Token.java // public class Token { // private TokenType type; // private String value; // // public Token(TokenType type, String value) { // this.type = type; // this.value = value; // } // // public TokenType getType() { // return type; // } // // public void setType(TokenType type) { // this.type = type; // } // // public String getValue() { // return value; // } // // public void setValue(String value) { // this.value = value; // } // } // // Path: src/iode/scanning/TokenType.java // public enum TokenType { // // Regular // IDENTIFIER, // STRING, // CHAR, // NUMBER, // DOUBLE, // BOOLEAN, // NIL, // // // Keywords // LET, // VAR, // FUNCTION, // IMPORT, // RETURN, // ENUM, // // // Symbols // EQUALS, // ADD, // SUB, // MUL, // DIV, // GT, // LT, // DOT, // COMMA, // COLON, // LPAREN, // RPAREN, // LBRACE, // RBRACE, // LBRACK, // RBRACK, // NEWLINE // } // Path: src/iode/parsing/IParser.java import iode.ast.Node; import iode.scanning.Token; import iode.scanning.TokenType; package iode.parsing; public interface IParser { Token peekToken(); boolean peekCheck(TokenType type); boolean peekSpecificCheck(TokenType type, int i); Token peekSpecific(int i); Token nextToken(); void skipNewline();
Node start();
danilolekovic/iode-old
src/iode/scanning/Lexer.java
// Path: src/iode/exceptions/LexerException.java // @SuppressWarnings("serial") // public class LexerException extends Exception { // public LexerException(String message, int line) { // super(message + " on line #" + line); // } // // public LexerException(String message) { // super(message); // } // } // // Path: src/iode/util/Errors.java // public class Errors // { // @SuppressWarnings("unchecked") // private static <T extends Throwable> void throwException(Throwable exception, Object dummy) throws T // { // throw (T) exception; // } // // public static void throwException(Throwable exception) // { // Errors.<RuntimeException>throwException(exception, null); // } // }
import java.util.ArrayList; import iode.exceptions.LexerException; import iode.util.Errors;
if (buffer.equals("let")) { tokens.add(new Token(TokenType.LET, buffer)); } else if (buffer.equals("var")) { tokens.add(new Token(TokenType.VAR, buffer)); } else if (buffer.equals("fn")) { tokens.add(new Token(TokenType.FUNCTION, buffer)); } else if (buffer.equals("import")) { tokens.add(new Token(TokenType.IMPORT, buffer)); } else if (buffer.equals("return")) { tokens.add(new Token(TokenType.RETURN, buffer)); } else if (buffer.equals("enum")) { tokens.add(new Token(TokenType.ENUM, buffer)); } else if (buffer.equals("nil")) { tokens.add(new Token(TokenType.NIL, buffer)); } else if (buffer.equals("true") || buffer.equals("false")) { tokens.add(new Token(TokenType.BOOLEAN, buffer)); } else { tokens.add(new Token(TokenType.IDENTIFIER, buffer)); } sb = new StringBuilder(); } else if (Character.isDigit(code.charAt(pos))) { sb.append(code.charAt(pos)); pos++; boolean decimalPlaced = false; while (pos < code.length() && Character.isDigit(code.charAt(pos)) || code.charAt(pos) == '.' || code.charAt(pos) == '_') { if (code.charAt(pos) == '.') { if (decimalPlaced) {
// Path: src/iode/exceptions/LexerException.java // @SuppressWarnings("serial") // public class LexerException extends Exception { // public LexerException(String message, int line) { // super(message + " on line #" + line); // } // // public LexerException(String message) { // super(message); // } // } // // Path: src/iode/util/Errors.java // public class Errors // { // @SuppressWarnings("unchecked") // private static <T extends Throwable> void throwException(Throwable exception, Object dummy) throws T // { // throw (T) exception; // } // // public static void throwException(Throwable exception) // { // Errors.<RuntimeException>throwException(exception, null); // } // } // Path: src/iode/scanning/Lexer.java import java.util.ArrayList; import iode.exceptions.LexerException; import iode.util.Errors; if (buffer.equals("let")) { tokens.add(new Token(TokenType.LET, buffer)); } else if (buffer.equals("var")) { tokens.add(new Token(TokenType.VAR, buffer)); } else if (buffer.equals("fn")) { tokens.add(new Token(TokenType.FUNCTION, buffer)); } else if (buffer.equals("import")) { tokens.add(new Token(TokenType.IMPORT, buffer)); } else if (buffer.equals("return")) { tokens.add(new Token(TokenType.RETURN, buffer)); } else if (buffer.equals("enum")) { tokens.add(new Token(TokenType.ENUM, buffer)); } else if (buffer.equals("nil")) { tokens.add(new Token(TokenType.NIL, buffer)); } else if (buffer.equals("true") || buffer.equals("false")) { tokens.add(new Token(TokenType.BOOLEAN, buffer)); } else { tokens.add(new Token(TokenType.IDENTIFIER, buffer)); } sb = new StringBuilder(); } else if (Character.isDigit(code.charAt(pos))) { sb.append(code.charAt(pos)); pos++; boolean decimalPlaced = false; while (pos < code.length() && Character.isDigit(code.charAt(pos)) || code.charAt(pos) == '.' || code.charAt(pos) == '_') { if (code.charAt(pos) == '.') { if (decimalPlaced) {
Errors.throwException(new LexerException("Number cannot mathematically have more than one decimal point", line));
danilolekovic/iode-old
src/iode/scanning/Lexer.java
// Path: src/iode/exceptions/LexerException.java // @SuppressWarnings("serial") // public class LexerException extends Exception { // public LexerException(String message, int line) { // super(message + " on line #" + line); // } // // public LexerException(String message) { // super(message); // } // } // // Path: src/iode/util/Errors.java // public class Errors // { // @SuppressWarnings("unchecked") // private static <T extends Throwable> void throwException(Throwable exception, Object dummy) throws T // { // throw (T) exception; // } // // public static void throwException(Throwable exception) // { // Errors.<RuntimeException>throwException(exception, null); // } // }
import java.util.ArrayList; import iode.exceptions.LexerException; import iode.util.Errors;
if (buffer.equals("let")) { tokens.add(new Token(TokenType.LET, buffer)); } else if (buffer.equals("var")) { tokens.add(new Token(TokenType.VAR, buffer)); } else if (buffer.equals("fn")) { tokens.add(new Token(TokenType.FUNCTION, buffer)); } else if (buffer.equals("import")) { tokens.add(new Token(TokenType.IMPORT, buffer)); } else if (buffer.equals("return")) { tokens.add(new Token(TokenType.RETURN, buffer)); } else if (buffer.equals("enum")) { tokens.add(new Token(TokenType.ENUM, buffer)); } else if (buffer.equals("nil")) { tokens.add(new Token(TokenType.NIL, buffer)); } else if (buffer.equals("true") || buffer.equals("false")) { tokens.add(new Token(TokenType.BOOLEAN, buffer)); } else { tokens.add(new Token(TokenType.IDENTIFIER, buffer)); } sb = new StringBuilder(); } else if (Character.isDigit(code.charAt(pos))) { sb.append(code.charAt(pos)); pos++; boolean decimalPlaced = false; while (pos < code.length() && Character.isDigit(code.charAt(pos)) || code.charAt(pos) == '.' || code.charAt(pos) == '_') { if (code.charAt(pos) == '.') { if (decimalPlaced) {
// Path: src/iode/exceptions/LexerException.java // @SuppressWarnings("serial") // public class LexerException extends Exception { // public LexerException(String message, int line) { // super(message + " on line #" + line); // } // // public LexerException(String message) { // super(message); // } // } // // Path: src/iode/util/Errors.java // public class Errors // { // @SuppressWarnings("unchecked") // private static <T extends Throwable> void throwException(Throwable exception, Object dummy) throws T // { // throw (T) exception; // } // // public static void throwException(Throwable exception) // { // Errors.<RuntimeException>throwException(exception, null); // } // } // Path: src/iode/scanning/Lexer.java import java.util.ArrayList; import iode.exceptions.LexerException; import iode.util.Errors; if (buffer.equals("let")) { tokens.add(new Token(TokenType.LET, buffer)); } else if (buffer.equals("var")) { tokens.add(new Token(TokenType.VAR, buffer)); } else if (buffer.equals("fn")) { tokens.add(new Token(TokenType.FUNCTION, buffer)); } else if (buffer.equals("import")) { tokens.add(new Token(TokenType.IMPORT, buffer)); } else if (buffer.equals("return")) { tokens.add(new Token(TokenType.RETURN, buffer)); } else if (buffer.equals("enum")) { tokens.add(new Token(TokenType.ENUM, buffer)); } else if (buffer.equals("nil")) { tokens.add(new Token(TokenType.NIL, buffer)); } else if (buffer.equals("true") || buffer.equals("false")) { tokens.add(new Token(TokenType.BOOLEAN, buffer)); } else { tokens.add(new Token(TokenType.IDENTIFIER, buffer)); } sb = new StringBuilder(); } else if (Character.isDigit(code.charAt(pos))) { sb.append(code.charAt(pos)); pos++; boolean decimalPlaced = false; while (pos < code.length() && Character.isDigit(code.charAt(pos)) || code.charAt(pos) == '.' || code.charAt(pos) == '_') { if (code.charAt(pos) == '.') { if (decimalPlaced) {
Errors.throwException(new LexerException("Number cannot mathematically have more than one decimal point", line));
cettia/asity
action/src/test/java/io/cettia/asity/action/SimpleActionsTest.java
// Path: action/src/main/java/io/cettia/asity/action/Actions.java // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // }
import io.cettia.asity.action.Actions.Options;
/* * Copyright 2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.action; /** * @author Donghwan Kim */ public class SimpleActionsTest extends ActionsTestBase { @Override protected <T> Actions<T> createActions() { return new SimpleActions<>(); } @Override
// Path: action/src/main/java/io/cettia/asity/action/Actions.java // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // Path: action/src/test/java/io/cettia/asity/action/SimpleActionsTest.java import io.cettia.asity.action.Actions.Options; /* * Copyright 2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.action; /** * @author Donghwan Kim */ public class SimpleActionsTest extends ActionsTestBase { @Override protected <T> Actions<T> createActions() { return new SimpleActions<>(); } @Override
protected <T> Actions<T> createActions(Options options) {
cettia/asity
bridge-play2/src/main/java/io/cettia/asity/bridge/play2/AsityWebSocketActor.java
// Path: action/src/main/java/io/cettia/asity/action/Actions.java // public interface Actions<T> { // // /** // * Adds an action. // */ // Actions<T> add(Action<T> action); // // /** // * Disables any operation on the actions. This method is useful when // * multiple events are mutually exclusive. // */ // Actions<T> disable(); // // /** // * Determines if the actions has been disabled. // */ // boolean disabled(); // // /** // * Removes all of the actions. // */ // Actions<T> empty(); // // /** // * Fire all of the actions. // */ // Actions<T> fire(); // // /** // * Fire all of the actions with the given value. // */ // Actions<T> fire(T data); // // /** // * Determines if the actions have been called at least once. // */ // boolean fired(); // // /** // * Determines if the actions contains an action. // */ // boolean has(); // // /** // * Determines whether the actions contains the specified action. // */ // boolean has(Action<T> action); // // /** // * Removes an action. // */ // Actions<T> remove(Action<T> action); // // /** // * Options to create an Actions. With the default options, an Action will // * work like a typical event manager. // * // * @author Donghwan Kim // */ // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // // } // // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * The names of the handshake request headers. HTTP header is not case-sensitive // * but {@link Set} is case-sensitive. // */ // Set<String> headerNames(); // // /** // * Returns the first handshake request header associated with the given name. // */ // String header(String name); // // /** // * Returns the handshake request headers associated with the given name or empty list // * if no header is found. // */ // List<String> headers(String name); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // }
import akka.actor.AbstractActor; import akka.actor.ActorRef; import io.cettia.asity.action.Actions; import io.cettia.asity.websocket.ServerWebSocket; import play.http.websocket.Message;
/* * Copyright 2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.bridge.play2; /** * An actor to handle a WebSocket connection. * * @author Donghwan Kim */ public class AsityWebSocketActor extends AbstractActor { final ActorRef out;
// Path: action/src/main/java/io/cettia/asity/action/Actions.java // public interface Actions<T> { // // /** // * Adds an action. // */ // Actions<T> add(Action<T> action); // // /** // * Disables any operation on the actions. This method is useful when // * multiple events are mutually exclusive. // */ // Actions<T> disable(); // // /** // * Determines if the actions has been disabled. // */ // boolean disabled(); // // /** // * Removes all of the actions. // */ // Actions<T> empty(); // // /** // * Fire all of the actions. // */ // Actions<T> fire(); // // /** // * Fire all of the actions with the given value. // */ // Actions<T> fire(T data); // // /** // * Determines if the actions have been called at least once. // */ // boolean fired(); // // /** // * Determines if the actions contains an action. // */ // boolean has(); // // /** // * Determines whether the actions contains the specified action. // */ // boolean has(Action<T> action); // // /** // * Removes an action. // */ // Actions<T> remove(Action<T> action); // // /** // * Options to create an Actions. With the default options, an Action will // * work like a typical event manager. // * // * @author Donghwan Kim // */ // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // // } // // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * The names of the handshake request headers. HTTP header is not case-sensitive // * but {@link Set} is case-sensitive. // */ // Set<String> headerNames(); // // /** // * Returns the first handshake request header associated with the given name. // */ // String header(String name); // // /** // * Returns the handshake request headers associated with the given name or empty list // * if no header is found. // */ // List<String> headers(String name); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // } // Path: bridge-play2/src/main/java/io/cettia/asity/bridge/play2/AsityWebSocketActor.java import akka.actor.AbstractActor; import akka.actor.ActorRef; import io.cettia.asity.action.Actions; import io.cettia.asity.websocket.ServerWebSocket; import play.http.websocket.Message; /* * Copyright 2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.bridge.play2; /** * An actor to handle a WebSocket connection. * * @author Donghwan Kim */ public class AsityWebSocketActor extends AbstractActor { final ActorRef out;
private final Actions<ServerWebSocket> actions;
cettia/asity
bridge-play2/src/main/java/io/cettia/asity/bridge/play2/AsityWebSocketActor.java
// Path: action/src/main/java/io/cettia/asity/action/Actions.java // public interface Actions<T> { // // /** // * Adds an action. // */ // Actions<T> add(Action<T> action); // // /** // * Disables any operation on the actions. This method is useful when // * multiple events are mutually exclusive. // */ // Actions<T> disable(); // // /** // * Determines if the actions has been disabled. // */ // boolean disabled(); // // /** // * Removes all of the actions. // */ // Actions<T> empty(); // // /** // * Fire all of the actions. // */ // Actions<T> fire(); // // /** // * Fire all of the actions with the given value. // */ // Actions<T> fire(T data); // // /** // * Determines if the actions have been called at least once. // */ // boolean fired(); // // /** // * Determines if the actions contains an action. // */ // boolean has(); // // /** // * Determines whether the actions contains the specified action. // */ // boolean has(Action<T> action); // // /** // * Removes an action. // */ // Actions<T> remove(Action<T> action); // // /** // * Options to create an Actions. With the default options, an Action will // * work like a typical event manager. // * // * @author Donghwan Kim // */ // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // // } // // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * The names of the handshake request headers. HTTP header is not case-sensitive // * but {@link Set} is case-sensitive. // */ // Set<String> headerNames(); // // /** // * Returns the first handshake request header associated with the given name. // */ // String header(String name); // // /** // * Returns the handshake request headers associated with the given name or empty list // * if no header is found. // */ // List<String> headers(String name); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // }
import akka.actor.AbstractActor; import akka.actor.ActorRef; import io.cettia.asity.action.Actions; import io.cettia.asity.websocket.ServerWebSocket; import play.http.websocket.Message;
/* * Copyright 2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.bridge.play2; /** * An actor to handle a WebSocket connection. * * @author Donghwan Kim */ public class AsityWebSocketActor extends AbstractActor { final ActorRef out;
// Path: action/src/main/java/io/cettia/asity/action/Actions.java // public interface Actions<T> { // // /** // * Adds an action. // */ // Actions<T> add(Action<T> action); // // /** // * Disables any operation on the actions. This method is useful when // * multiple events are mutually exclusive. // */ // Actions<T> disable(); // // /** // * Determines if the actions has been disabled. // */ // boolean disabled(); // // /** // * Removes all of the actions. // */ // Actions<T> empty(); // // /** // * Fire all of the actions. // */ // Actions<T> fire(); // // /** // * Fire all of the actions with the given value. // */ // Actions<T> fire(T data); // // /** // * Determines if the actions have been called at least once. // */ // boolean fired(); // // /** // * Determines if the actions contains an action. // */ // boolean has(); // // /** // * Determines whether the actions contains the specified action. // */ // boolean has(Action<T> action); // // /** // * Removes an action. // */ // Actions<T> remove(Action<T> action); // // /** // * Options to create an Actions. With the default options, an Action will // * work like a typical event manager. // * // * @author Donghwan Kim // */ // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // // } // // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * The names of the handshake request headers. HTTP header is not case-sensitive // * but {@link Set} is case-sensitive. // */ // Set<String> headerNames(); // // /** // * Returns the first handshake request header associated with the given name. // */ // String header(String name); // // /** // * Returns the handshake request headers associated with the given name or empty list // * if no header is found. // */ // List<String> headers(String name); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // } // Path: bridge-play2/src/main/java/io/cettia/asity/bridge/play2/AsityWebSocketActor.java import akka.actor.AbstractActor; import akka.actor.ActorRef; import io.cettia.asity.action.Actions; import io.cettia.asity.websocket.ServerWebSocket; import play.http.websocket.Message; /* * Copyright 2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.bridge.play2; /** * An actor to handle a WebSocket connection. * * @author Donghwan Kim */ public class AsityWebSocketActor extends AbstractActor { final ActorRef out;
private final Actions<ServerWebSocket> actions;
cettia/asity
websocket/src/main/java/io/cettia/asity/websocket/AbstractServerWebSocket.java
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: action/src/main/java/io/cettia/asity/action/Actions.java // public interface Actions<T> { // // /** // * Adds an action. // */ // Actions<T> add(Action<T> action); // // /** // * Disables any operation on the actions. This method is useful when // * multiple events are mutually exclusive. // */ // Actions<T> disable(); // // /** // * Determines if the actions has been disabled. // */ // boolean disabled(); // // /** // * Removes all of the actions. // */ // Actions<T> empty(); // // /** // * Fire all of the actions. // */ // Actions<T> fire(); // // /** // * Fire all of the actions with the given value. // */ // Actions<T> fire(T data); // // /** // * Determines if the actions have been called at least once. // */ // boolean fired(); // // /** // * Determines if the actions contains an action. // */ // boolean has(); // // /** // * Determines whether the actions contains the specified action. // */ // boolean has(Action<T> action); // // /** // * Removes an action. // */ // Actions<T> remove(Action<T> action); // // /** // * Options to create an Actions. With the default options, an Action will // * work like a typical event manager. // * // * @author Donghwan Kim // */ // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // // } // // Path: action/src/main/java/io/cettia/asity/action/SimpleActions.java // public class SimpleActions<T> extends AbstractActions<T> { // // private boolean disabled; // private boolean fired; // private T cached; // // public SimpleActions() { // super(); // } // // public SimpleActions(Actions.Options o) { // super(o); // } // // @Override // protected List<Action<T>> createList() { // return new ArrayList<>(); // } // // @Override // protected void setCache(T data) { // this.cached = data; // } // // @Override // protected T cached() { // return cached; // } // // @Override // protected boolean setDisabled() { // boolean answer = !disabled; // if (answer) { // disabled = true; // } // return answer; // } // // @Override // public boolean disabled() { // return disabled; // } // // @Override // protected void setFired() { // fired = true; // } // // @Override // public boolean fired() { // return fired; // } // // }
import io.cettia.asity.action.Action; import io.cettia.asity.action.Actions; import io.cettia.asity.action.SimpleActions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.nio.ByteBuffer; import java.util.List;
state = State.CLOSING; doClose(); } } protected abstract void doClose(); @Override public ServerWebSocket send(String data) { if (logger.isDebugEnabled()) { logger.debug("{} sends a text frame {}", this, data); } doSend(data); return this; } @Override public ServerWebSocket send(ByteBuffer byteBuffer) { if (logger.isDebugEnabled()) { logger.debug("{} sends a binary frame {}", this, byteBuffer); } doSend(byteBuffer); return this; } protected abstract void doSend(ByteBuffer byteBuffer); protected abstract void doSend(String data); @Override
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: action/src/main/java/io/cettia/asity/action/Actions.java // public interface Actions<T> { // // /** // * Adds an action. // */ // Actions<T> add(Action<T> action); // // /** // * Disables any operation on the actions. This method is useful when // * multiple events are mutually exclusive. // */ // Actions<T> disable(); // // /** // * Determines if the actions has been disabled. // */ // boolean disabled(); // // /** // * Removes all of the actions. // */ // Actions<T> empty(); // // /** // * Fire all of the actions. // */ // Actions<T> fire(); // // /** // * Fire all of the actions with the given value. // */ // Actions<T> fire(T data); // // /** // * Determines if the actions have been called at least once. // */ // boolean fired(); // // /** // * Determines if the actions contains an action. // */ // boolean has(); // // /** // * Determines whether the actions contains the specified action. // */ // boolean has(Action<T> action); // // /** // * Removes an action. // */ // Actions<T> remove(Action<T> action); // // /** // * Options to create an Actions. With the default options, an Action will // * work like a typical event manager. // * // * @author Donghwan Kim // */ // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // // } // // Path: action/src/main/java/io/cettia/asity/action/SimpleActions.java // public class SimpleActions<T> extends AbstractActions<T> { // // private boolean disabled; // private boolean fired; // private T cached; // // public SimpleActions() { // super(); // } // // public SimpleActions(Actions.Options o) { // super(o); // } // // @Override // protected List<Action<T>> createList() { // return new ArrayList<>(); // } // // @Override // protected void setCache(T data) { // this.cached = data; // } // // @Override // protected T cached() { // return cached; // } // // @Override // protected boolean setDisabled() { // boolean answer = !disabled; // if (answer) { // disabled = true; // } // return answer; // } // // @Override // public boolean disabled() { // return disabled; // } // // @Override // protected void setFired() { // fired = true; // } // // @Override // public boolean fired() { // return fired; // } // // } // Path: websocket/src/main/java/io/cettia/asity/websocket/AbstractServerWebSocket.java import io.cettia.asity.action.Action; import io.cettia.asity.action.Actions; import io.cettia.asity.action.SimpleActions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.nio.ByteBuffer; import java.util.List; state = State.CLOSING; doClose(); } } protected abstract void doClose(); @Override public ServerWebSocket send(String data) { if (logger.isDebugEnabled()) { logger.debug("{} sends a text frame {}", this, data); } doSend(data); return this; } @Override public ServerWebSocket send(ByteBuffer byteBuffer) { if (logger.isDebugEnabled()) { logger.debug("{} sends a binary frame {}", this, byteBuffer); } doSend(byteBuffer); return this; } protected abstract void doSend(ByteBuffer byteBuffer); protected abstract void doSend(String data); @Override
public ServerWebSocket ontext(Action<String> action) {
cettia/asity
http/src/main/java/io/cettia/asity/http/AbstractServerHttpExchange.java
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: action/src/main/java/io/cettia/asity/action/Actions.java // public interface Actions<T> { // // /** // * Adds an action. // */ // Actions<T> add(Action<T> action); // // /** // * Disables any operation on the actions. This method is useful when // * multiple events are mutually exclusive. // */ // Actions<T> disable(); // // /** // * Determines if the actions has been disabled. // */ // boolean disabled(); // // /** // * Removes all of the actions. // */ // Actions<T> empty(); // // /** // * Fire all of the actions. // */ // Actions<T> fire(); // // /** // * Fire all of the actions with the given value. // */ // Actions<T> fire(T data); // // /** // * Determines if the actions have been called at least once. // */ // boolean fired(); // // /** // * Determines if the actions contains an action. // */ // boolean has(); // // /** // * Determines whether the actions contains the specified action. // */ // boolean has(Action<T> action); // // /** // * Removes an action. // */ // Actions<T> remove(Action<T> action); // // /** // * Options to create an Actions. With the default options, an Action will // * work like a typical event manager. // * // * @author Donghwan Kim // */ // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // // } // // Path: action/src/main/java/io/cettia/asity/action/SimpleActions.java // public class SimpleActions<T> extends AbstractActions<T> { // // private boolean disabled; // private boolean fired; // private T cached; // // public SimpleActions() { // super(); // } // // public SimpleActions(Actions.Options o) { // super(o); // } // // @Override // protected List<Action<T>> createList() { // return new ArrayList<>(); // } // // @Override // protected void setCache(T data) { // this.cached = data; // } // // @Override // protected T cached() { // return cached; // } // // @Override // protected boolean setDisabled() { // boolean answer = !disabled; // if (answer) { // disabled = true; // } // return answer; // } // // @Override // public boolean disabled() { // return disabled; // } // // @Override // protected void setFired() { // fired = true; // } // // @Override // public boolean fired() { // return fired; // } // // }
import io.cettia.asity.action.Action; import io.cettia.asity.action.Actions; import io.cettia.asity.action.SimpleActions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.ByteArrayOutputStream; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.util.Iterator; import java.util.List;
/* * Copyright 2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.http; /** * Abstract base class for {@link ServerHttpExchange}. * * @author Donghwan Kim */ public abstract class AbstractServerHttpExchange implements ServerHttpExchange { // HTTP 1.1 says that the default charset is ISO-8859-1 // http://www.w3.org/International/O-HTTP-charset#charset private static final String DEFAULT_CHARSET_NAME = "ISO-8859-1";
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: action/src/main/java/io/cettia/asity/action/Actions.java // public interface Actions<T> { // // /** // * Adds an action. // */ // Actions<T> add(Action<T> action); // // /** // * Disables any operation on the actions. This method is useful when // * multiple events are mutually exclusive. // */ // Actions<T> disable(); // // /** // * Determines if the actions has been disabled. // */ // boolean disabled(); // // /** // * Removes all of the actions. // */ // Actions<T> empty(); // // /** // * Fire all of the actions. // */ // Actions<T> fire(); // // /** // * Fire all of the actions with the given value. // */ // Actions<T> fire(T data); // // /** // * Determines if the actions have been called at least once. // */ // boolean fired(); // // /** // * Determines if the actions contains an action. // */ // boolean has(); // // /** // * Determines whether the actions contains the specified action. // */ // boolean has(Action<T> action); // // /** // * Removes an action. // */ // Actions<T> remove(Action<T> action); // // /** // * Options to create an Actions. With the default options, an Action will // * work like a typical event manager. // * // * @author Donghwan Kim // */ // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // // } // // Path: action/src/main/java/io/cettia/asity/action/SimpleActions.java // public class SimpleActions<T> extends AbstractActions<T> { // // private boolean disabled; // private boolean fired; // private T cached; // // public SimpleActions() { // super(); // } // // public SimpleActions(Actions.Options o) { // super(o); // } // // @Override // protected List<Action<T>> createList() { // return new ArrayList<>(); // } // // @Override // protected void setCache(T data) { // this.cached = data; // } // // @Override // protected T cached() { // return cached; // } // // @Override // protected boolean setDisabled() { // boolean answer = !disabled; // if (answer) { // disabled = true; // } // return answer; // } // // @Override // public boolean disabled() { // return disabled; // } // // @Override // protected void setFired() { // fired = true; // } // // @Override // public boolean fired() { // return fired; // } // // } // Path: http/src/main/java/io/cettia/asity/http/AbstractServerHttpExchange.java import io.cettia.asity.action.Action; import io.cettia.asity.action.Actions; import io.cettia.asity.action.SimpleActions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.ByteArrayOutputStream; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.util.Iterator; import java.util.List; /* * Copyright 2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.http; /** * Abstract base class for {@link ServerHttpExchange}. * * @author Donghwan Kim */ public abstract class AbstractServerHttpExchange implements ServerHttpExchange { // HTTP 1.1 says that the default charset is ISO-8859-1 // http://www.w3.org/International/O-HTTP-charset#charset private static final String DEFAULT_CHARSET_NAME = "ISO-8859-1";
protected final Actions<Void> endActions = new SimpleActions<>(new Actions.Options().once(true).memory(true));
cettia/asity
http/src/main/java/io/cettia/asity/http/AbstractServerHttpExchange.java
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: action/src/main/java/io/cettia/asity/action/Actions.java // public interface Actions<T> { // // /** // * Adds an action. // */ // Actions<T> add(Action<T> action); // // /** // * Disables any operation on the actions. This method is useful when // * multiple events are mutually exclusive. // */ // Actions<T> disable(); // // /** // * Determines if the actions has been disabled. // */ // boolean disabled(); // // /** // * Removes all of the actions. // */ // Actions<T> empty(); // // /** // * Fire all of the actions. // */ // Actions<T> fire(); // // /** // * Fire all of the actions with the given value. // */ // Actions<T> fire(T data); // // /** // * Determines if the actions have been called at least once. // */ // boolean fired(); // // /** // * Determines if the actions contains an action. // */ // boolean has(); // // /** // * Determines whether the actions contains the specified action. // */ // boolean has(Action<T> action); // // /** // * Removes an action. // */ // Actions<T> remove(Action<T> action); // // /** // * Options to create an Actions. With the default options, an Action will // * work like a typical event manager. // * // * @author Donghwan Kim // */ // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // // } // // Path: action/src/main/java/io/cettia/asity/action/SimpleActions.java // public class SimpleActions<T> extends AbstractActions<T> { // // private boolean disabled; // private boolean fired; // private T cached; // // public SimpleActions() { // super(); // } // // public SimpleActions(Actions.Options o) { // super(o); // } // // @Override // protected List<Action<T>> createList() { // return new ArrayList<>(); // } // // @Override // protected void setCache(T data) { // this.cached = data; // } // // @Override // protected T cached() { // return cached; // } // // @Override // protected boolean setDisabled() { // boolean answer = !disabled; // if (answer) { // disabled = true; // } // return answer; // } // // @Override // public boolean disabled() { // return disabled; // } // // @Override // protected void setFired() { // fired = true; // } // // @Override // public boolean fired() { // return fired; // } // // }
import io.cettia.asity.action.Action; import io.cettia.asity.action.Actions; import io.cettia.asity.action.SimpleActions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.ByteArrayOutputStream; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.util.Iterator; import java.util.List;
/* * Copyright 2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.http; /** * Abstract base class for {@link ServerHttpExchange}. * * @author Donghwan Kim */ public abstract class AbstractServerHttpExchange implements ServerHttpExchange { // HTTP 1.1 says that the default charset is ISO-8859-1 // http://www.w3.org/International/O-HTTP-charset#charset private static final String DEFAULT_CHARSET_NAME = "ISO-8859-1";
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: action/src/main/java/io/cettia/asity/action/Actions.java // public interface Actions<T> { // // /** // * Adds an action. // */ // Actions<T> add(Action<T> action); // // /** // * Disables any operation on the actions. This method is useful when // * multiple events are mutually exclusive. // */ // Actions<T> disable(); // // /** // * Determines if the actions has been disabled. // */ // boolean disabled(); // // /** // * Removes all of the actions. // */ // Actions<T> empty(); // // /** // * Fire all of the actions. // */ // Actions<T> fire(); // // /** // * Fire all of the actions with the given value. // */ // Actions<T> fire(T data); // // /** // * Determines if the actions have been called at least once. // */ // boolean fired(); // // /** // * Determines if the actions contains an action. // */ // boolean has(); // // /** // * Determines whether the actions contains the specified action. // */ // boolean has(Action<T> action); // // /** // * Removes an action. // */ // Actions<T> remove(Action<T> action); // // /** // * Options to create an Actions. With the default options, an Action will // * work like a typical event manager. // * // * @author Donghwan Kim // */ // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // // } // // Path: action/src/main/java/io/cettia/asity/action/SimpleActions.java // public class SimpleActions<T> extends AbstractActions<T> { // // private boolean disabled; // private boolean fired; // private T cached; // // public SimpleActions() { // super(); // } // // public SimpleActions(Actions.Options o) { // super(o); // } // // @Override // protected List<Action<T>> createList() { // return new ArrayList<>(); // } // // @Override // protected void setCache(T data) { // this.cached = data; // } // // @Override // protected T cached() { // return cached; // } // // @Override // protected boolean setDisabled() { // boolean answer = !disabled; // if (answer) { // disabled = true; // } // return answer; // } // // @Override // public boolean disabled() { // return disabled; // } // // @Override // protected void setFired() { // fired = true; // } // // @Override // public boolean fired() { // return fired; // } // // } // Path: http/src/main/java/io/cettia/asity/http/AbstractServerHttpExchange.java import io.cettia.asity.action.Action; import io.cettia.asity.action.Actions; import io.cettia.asity.action.SimpleActions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.ByteArrayOutputStream; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.util.Iterator; import java.util.List; /* * Copyright 2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.http; /** * Abstract base class for {@link ServerHttpExchange}. * * @author Donghwan Kim */ public abstract class AbstractServerHttpExchange implements ServerHttpExchange { // HTTP 1.1 says that the default charset is ISO-8859-1 // http://www.w3.org/International/O-HTTP-charset#charset private static final String DEFAULT_CHARSET_NAME = "ISO-8859-1";
protected final Actions<Void> endActions = new SimpleActions<>(new Actions.Options().once(true).memory(true));
cettia/asity
http/src/main/java/io/cettia/asity/http/AbstractServerHttpExchange.java
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: action/src/main/java/io/cettia/asity/action/Actions.java // public interface Actions<T> { // // /** // * Adds an action. // */ // Actions<T> add(Action<T> action); // // /** // * Disables any operation on the actions. This method is useful when // * multiple events are mutually exclusive. // */ // Actions<T> disable(); // // /** // * Determines if the actions has been disabled. // */ // boolean disabled(); // // /** // * Removes all of the actions. // */ // Actions<T> empty(); // // /** // * Fire all of the actions. // */ // Actions<T> fire(); // // /** // * Fire all of the actions with the given value. // */ // Actions<T> fire(T data); // // /** // * Determines if the actions have been called at least once. // */ // boolean fired(); // // /** // * Determines if the actions contains an action. // */ // boolean has(); // // /** // * Determines whether the actions contains the specified action. // */ // boolean has(Action<T> action); // // /** // * Removes an action. // */ // Actions<T> remove(Action<T> action); // // /** // * Options to create an Actions. With the default options, an Action will // * work like a typical event manager. // * // * @author Donghwan Kim // */ // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // // } // // Path: action/src/main/java/io/cettia/asity/action/SimpleActions.java // public class SimpleActions<T> extends AbstractActions<T> { // // private boolean disabled; // private boolean fired; // private T cached; // // public SimpleActions() { // super(); // } // // public SimpleActions(Actions.Options o) { // super(o); // } // // @Override // protected List<Action<T>> createList() { // return new ArrayList<>(); // } // // @Override // protected void setCache(T data) { // this.cached = data; // } // // @Override // protected T cached() { // return cached; // } // // @Override // protected boolean setDisabled() { // boolean answer = !disabled; // if (answer) { // disabled = true; // } // return answer; // } // // @Override // public boolean disabled() { // return disabled; // } // // @Override // protected void setFired() { // fired = true; // } // // @Override // public boolean fired() { // return fired; // } // // }
import io.cettia.asity.action.Action; import io.cettia.asity.action.Actions; import io.cettia.asity.action.SimpleActions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.ByteArrayOutputStream; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.util.Iterator; import java.util.List;
@Override public ServerHttpExchange readAsText(String charsetName) { if (!reading) { reading = true; final Charset charset = Charset.forName(charsetName); doRead(byteBuffer -> { String chunk = charset.decode(byteBuffer).toString(); if (logger.isDebugEnabled()) { logger.debug("{} reads a text chunk {} with charset {}", this, chunk, charsetName); } chunkActions.fire(chunk); }); } return this; } @Override public ServerHttpExchange readAsBinary() { if (!reading) { reading = true; doRead(byteBuffer -> { if (logger.isDebugEnabled()) { logger.debug("{} reads a binary chunk {}", this, byteBuffer); } chunkActions.fire(byteBuffer); }); } return this; }
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: action/src/main/java/io/cettia/asity/action/Actions.java // public interface Actions<T> { // // /** // * Adds an action. // */ // Actions<T> add(Action<T> action); // // /** // * Disables any operation on the actions. This method is useful when // * multiple events are mutually exclusive. // */ // Actions<T> disable(); // // /** // * Determines if the actions has been disabled. // */ // boolean disabled(); // // /** // * Removes all of the actions. // */ // Actions<T> empty(); // // /** // * Fire all of the actions. // */ // Actions<T> fire(); // // /** // * Fire all of the actions with the given value. // */ // Actions<T> fire(T data); // // /** // * Determines if the actions have been called at least once. // */ // boolean fired(); // // /** // * Determines if the actions contains an action. // */ // boolean has(); // // /** // * Determines whether the actions contains the specified action. // */ // boolean has(Action<T> action); // // /** // * Removes an action. // */ // Actions<T> remove(Action<T> action); // // /** // * Options to create an Actions. With the default options, an Action will // * work like a typical event manager. // * // * @author Donghwan Kim // */ // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // // } // // Path: action/src/main/java/io/cettia/asity/action/SimpleActions.java // public class SimpleActions<T> extends AbstractActions<T> { // // private boolean disabled; // private boolean fired; // private T cached; // // public SimpleActions() { // super(); // } // // public SimpleActions(Actions.Options o) { // super(o); // } // // @Override // protected List<Action<T>> createList() { // return new ArrayList<>(); // } // // @Override // protected void setCache(T data) { // this.cached = data; // } // // @Override // protected T cached() { // return cached; // } // // @Override // protected boolean setDisabled() { // boolean answer = !disabled; // if (answer) { // disabled = true; // } // return answer; // } // // @Override // public boolean disabled() { // return disabled; // } // // @Override // protected void setFired() { // fired = true; // } // // @Override // public boolean fired() { // return fired; // } // // } // Path: http/src/main/java/io/cettia/asity/http/AbstractServerHttpExchange.java import io.cettia.asity.action.Action; import io.cettia.asity.action.Actions; import io.cettia.asity.action.SimpleActions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.ByteArrayOutputStream; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.util.Iterator; import java.util.List; @Override public ServerHttpExchange readAsText(String charsetName) { if (!reading) { reading = true; final Charset charset = Charset.forName(charsetName); doRead(byteBuffer -> { String chunk = charset.decode(byteBuffer).toString(); if (logger.isDebugEnabled()) { logger.debug("{} reads a text chunk {} with charset {}", this, chunk, charsetName); } chunkActions.fire(chunk); }); } return this; } @Override public ServerHttpExchange readAsBinary() { if (!reading) { reading = true; doRead(byteBuffer -> { if (logger.isDebugEnabled()) { logger.debug("{} reads a binary chunk {}", this, byteBuffer); } chunkActions.fire(byteBuffer); }); } return this; }
protected abstract void doRead(Action<ByteBuffer> chunkAction);
cettia/asity
test/src/main/java/io/cettia/asity/test/ServerWebSocketTestBase.java
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * The names of the handshake request headers. HTTP header is not case-sensitive // * but {@link Set} is case-sensitive. // */ // Set<String> headerNames(); // // /** // * Returns the first handshake request header associated with the given name. // */ // String header(String name); // // /** // * Returns the handshake request headers associated with the given name or empty list // * if no header is found. // */ // List<String> headers(String name); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // }
import java.net.ServerSocket; import java.net.URI; import java.nio.ByteBuffer; import java.util.Arrays; import io.cettia.asity.action.Action; import io.cettia.asity.websocket.ServerWebSocket; import net.jodah.concurrentunit.ConcurrentTestCase; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WebSocketAdapter; import org.eclipse.jetty.websocket.api.WebSocketListener; import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.client.WebSocketClient; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout;
/* * Copyright 2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.test; /** * @author Donghwan Kim */ public abstract class ServerWebSocketTestBase extends ConcurrentTestCase { public static final String TEST_PATH = "/websocket"; private static final WebSocketListener NOOP = new WebSocketAdapter(); private static final WriteCallback ASYNC = new WriteCallback() { @Override public void writeSuccess() { } @Override public void writeFailed(Throwable throwable) { } }; @Rule public Timeout globalTimeout = Timeout.seconds(60); protected WebSocketClient client = new WebSocketClient(); private int port;
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * The names of the handshake request headers. HTTP header is not case-sensitive // * but {@link Set} is case-sensitive. // */ // Set<String> headerNames(); // // /** // * Returns the first handshake request header associated with the given name. // */ // String header(String name); // // /** // * Returns the handshake request headers associated with the given name or empty list // * if no header is found. // */ // List<String> headers(String name); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // } // Path: test/src/main/java/io/cettia/asity/test/ServerWebSocketTestBase.java import java.net.ServerSocket; import java.net.URI; import java.nio.ByteBuffer; import java.util.Arrays; import io.cettia.asity.action.Action; import io.cettia.asity.websocket.ServerWebSocket; import net.jodah.concurrentunit.ConcurrentTestCase; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WebSocketAdapter; import org.eclipse.jetty.websocket.api.WebSocketListener; import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.client.WebSocketClient; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout; /* * Copyright 2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.test; /** * @author Donghwan Kim */ public abstract class ServerWebSocketTestBase extends ConcurrentTestCase { public static final String TEST_PATH = "/websocket"; private static final WebSocketListener NOOP = new WebSocketAdapter(); private static final WriteCallback ASYNC = new WriteCallback() { @Override public void writeSuccess() { } @Override public void writeFailed(Throwable throwable) { } }; @Rule public Timeout globalTimeout = Timeout.seconds(60); protected WebSocketClient client = new WebSocketClient(); private int port;
private Action<ServerWebSocket> websocketAction;
cettia/asity
test/src/main/java/io/cettia/asity/test/ServerWebSocketTestBase.java
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * The names of the handshake request headers. HTTP header is not case-sensitive // * but {@link Set} is case-sensitive. // */ // Set<String> headerNames(); // // /** // * Returns the first handshake request header associated with the given name. // */ // String header(String name); // // /** // * Returns the handshake request headers associated with the given name or empty list // * if no header is found. // */ // List<String> headers(String name); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // }
import java.net.ServerSocket; import java.net.URI; import java.nio.ByteBuffer; import java.util.Arrays; import io.cettia.asity.action.Action; import io.cettia.asity.websocket.ServerWebSocket; import net.jodah.concurrentunit.ConcurrentTestCase; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WebSocketAdapter; import org.eclipse.jetty.websocket.api.WebSocketListener; import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.client.WebSocketClient; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout;
/* * Copyright 2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.test; /** * @author Donghwan Kim */ public abstract class ServerWebSocketTestBase extends ConcurrentTestCase { public static final String TEST_PATH = "/websocket"; private static final WebSocketListener NOOP = new WebSocketAdapter(); private static final WriteCallback ASYNC = new WriteCallback() { @Override public void writeSuccess() { } @Override public void writeFailed(Throwable throwable) { } }; @Rule public Timeout globalTimeout = Timeout.seconds(60); protected WebSocketClient client = new WebSocketClient(); private int port;
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * The names of the handshake request headers. HTTP header is not case-sensitive // * but {@link Set} is case-sensitive. // */ // Set<String> headerNames(); // // /** // * Returns the first handshake request header associated with the given name. // */ // String header(String name); // // /** // * Returns the handshake request headers associated with the given name or empty list // * if no header is found. // */ // List<String> headers(String name); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // } // Path: test/src/main/java/io/cettia/asity/test/ServerWebSocketTestBase.java import java.net.ServerSocket; import java.net.URI; import java.nio.ByteBuffer; import java.util.Arrays; import io.cettia.asity.action.Action; import io.cettia.asity.websocket.ServerWebSocket; import net.jodah.concurrentunit.ConcurrentTestCase; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WebSocketAdapter; import org.eclipse.jetty.websocket.api.WebSocketListener; import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.client.WebSocketClient; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout; /* * Copyright 2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.test; /** * @author Donghwan Kim */ public abstract class ServerWebSocketTestBase extends ConcurrentTestCase { public static final String TEST_PATH = "/websocket"; private static final WebSocketListener NOOP = new WebSocketAdapter(); private static final WriteCallback ASYNC = new WriteCallback() { @Override public void writeSuccess() { } @Override public void writeFailed(Throwable throwable) { } }; @Rule public Timeout globalTimeout = Timeout.seconds(60); protected WebSocketClient client = new WebSocketClient(); private int port;
private Action<ServerWebSocket> websocketAction;
cettia/asity
example-play2/app/io/cettia/asity/bridge/play2/WebSocketController.java
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * The names of the handshake request headers. HTTP header is not case-sensitive // * but {@link Set} is case-sensitive. // */ // Set<String> headerNames(); // // /** // * Returns the first handshake request header associated with the given name. // */ // String header(String name); // // /** // * Returns the handshake request headers associated with the given name or empty list // * if no header is found. // */ // List<String> headers(String name); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // }
import akka.actor.ActorSystem; import akka.stream.Materializer; import io.cettia.asity.action.Action; import io.cettia.asity.websocket.ServerWebSocket; import play.mvc.Controller; import play.mvc.WebSocket; import javax.inject.Inject; import javax.inject.Singleton;
/* * Copyright 2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.bridge.play2; /** * @author Donghwan Kim */ @Singleton public class WebSocketController extends Controller { private final ActorSystem actorSystem; private final Materializer materializer;
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * The names of the handshake request headers. HTTP header is not case-sensitive // * but {@link Set} is case-sensitive. // */ // Set<String> headerNames(); // // /** // * Returns the first handshake request header associated with the given name. // */ // String header(String name); // // /** // * Returns the handshake request headers associated with the given name or empty list // * if no header is found. // */ // List<String> headers(String name); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // } // Path: example-play2/app/io/cettia/asity/bridge/play2/WebSocketController.java import akka.actor.ActorSystem; import akka.stream.Materializer; import io.cettia.asity.action.Action; import io.cettia.asity.websocket.ServerWebSocket; import play.mvc.Controller; import play.mvc.WebSocket; import javax.inject.Inject; import javax.inject.Singleton; /* * Copyright 2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.bridge.play2; /** * @author Donghwan Kim */ @Singleton public class WebSocketController extends Controller { private final ActorSystem actorSystem; private final Materializer materializer;
private Action<ServerWebSocket> action;
cettia/asity
example-play2/app/io/cettia/asity/bridge/play2/WebSocketController.java
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * The names of the handshake request headers. HTTP header is not case-sensitive // * but {@link Set} is case-sensitive. // */ // Set<String> headerNames(); // // /** // * Returns the first handshake request header associated with the given name. // */ // String header(String name); // // /** // * Returns the handshake request headers associated with the given name or empty list // * if no header is found. // */ // List<String> headers(String name); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // }
import akka.actor.ActorSystem; import akka.stream.Materializer; import io.cettia.asity.action.Action; import io.cettia.asity.websocket.ServerWebSocket; import play.mvc.Controller; import play.mvc.WebSocket; import javax.inject.Inject; import javax.inject.Singleton;
/* * Copyright 2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.bridge.play2; /** * @author Donghwan Kim */ @Singleton public class WebSocketController extends Controller { private final ActorSystem actorSystem; private final Materializer materializer;
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * The names of the handshake request headers. HTTP header is not case-sensitive // * but {@link Set} is case-sensitive. // */ // Set<String> headerNames(); // // /** // * Returns the first handshake request header associated with the given name. // */ // String header(String name); // // /** // * Returns the handshake request headers associated with the given name or empty list // * if no header is found. // */ // List<String> headers(String name); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // } // Path: example-play2/app/io/cettia/asity/bridge/play2/WebSocketController.java import akka.actor.ActorSystem; import akka.stream.Materializer; import io.cettia.asity.action.Action; import io.cettia.asity.websocket.ServerWebSocket; import play.mvc.Controller; import play.mvc.WebSocket; import javax.inject.Inject; import javax.inject.Singleton; /* * Copyright 2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.bridge.play2; /** * @author Donghwan Kim */ @Singleton public class WebSocketController extends Controller { private final ActorSystem actorSystem; private final Materializer materializer;
private Action<ServerWebSocket> action;
cettia/asity
action/src/test/java/io/cettia/asity/action/ActionsTestBase.java
// Path: action/src/main/java/io/cettia/asity/action/Actions.java // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // }
import io.cettia.asity.action.Actions.Options; import org.junit.Test; import java.util.ArrayList; import java.util.Collections; import java.util.List; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat;
/* * Copyright 2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.action; /** * @author Donghwan Kim */ public abstract class ActionsTestBase { @Test public void testAdd() { Actions<String> actions = null; MemoryAction<String> action = null; // default actions = createActions(); action = new MemoryAction<>(); actions.add(action).add(action).fire("A"); assertThat(action.memory(), contains("A", "A")); actions.add(action); assertThat(action.memory(), contains("A", "A")); // unique
// Path: action/src/main/java/io/cettia/asity/action/Actions.java // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // Path: action/src/test/java/io/cettia/asity/action/ActionsTestBase.java import io.cettia.asity.action.Actions.Options; import org.junit.Test; import java.util.ArrayList; import java.util.Collections; import java.util.List; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; /* * Copyright 2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.action; /** * @author Donghwan Kim */ public abstract class ActionsTestBase { @Test public void testAdd() { Actions<String> actions = null; MemoryAction<String> action = null; // default actions = createActions(); action = new MemoryAction<>(); actions.add(action).add(action).fire("A"); assertThat(action.memory(), contains("A", "A")); actions.add(action); assertThat(action.memory(), contains("A", "A")); // unique
actions = createActions(new Actions.Options().unique(true));
cettia/asity
websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // }
import io.cettia.asity.action.Action; import java.nio.ByteBuffer; import java.util.List; import java.util.Set;
/* * Copyright 2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.websocket; /** * Represents a server-side WebSocket. * <p/> * Implementations are not thread-safe. * * @author Donghwan Kim * @see <a href="http://tools.ietf.org/html/rfc6455">RFC6455 - The WebSocket * Protocol</a> */ public interface ServerWebSocket { /** * The URI used to connect. */ String uri(); /** * The names of the handshake request headers. HTTP header is not case-sensitive * but {@link Set} is case-sensitive. */ Set<String> headerNames(); /** * Returns the first handshake request header associated with the given name. */ String header(String name); /** * Returns the handshake request headers associated with the given name or empty list * if no header is found. */ List<String> headers(String name); /** * Closes the connection. This method has no side effect if called more than * once. */ void close(); /** * Sends a text frame through the connection. */ ServerWebSocket send(String data); /** * Sends a binary frame through the connection. */ ServerWebSocket send(ByteBuffer byteBuffer); /** * Attaches an action for the text frame. */
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java import io.cettia.asity.action.Action; import java.nio.ByteBuffer; import java.util.List; import java.util.Set; /* * Copyright 2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.websocket; /** * Represents a server-side WebSocket. * <p/> * Implementations are not thread-safe. * * @author Donghwan Kim * @see <a href="http://tools.ietf.org/html/rfc6455">RFC6455 - The WebSocket * Protocol</a> */ public interface ServerWebSocket { /** * The URI used to connect. */ String uri(); /** * The names of the handshake request headers. HTTP header is not case-sensitive * but {@link Set} is case-sensitive. */ Set<String> headerNames(); /** * Returns the first handshake request header associated with the given name. */ String header(String name); /** * Returns the handshake request headers associated with the given name or empty list * if no header is found. */ List<String> headers(String name); /** * Closes the connection. This method has no side effect if called more than * once. */ void close(); /** * Sends a text frame through the connection. */ ServerWebSocket send(String data); /** * Sends a binary frame through the connection. */ ServerWebSocket send(ByteBuffer byteBuffer); /** * Attaches an action for the text frame. */
ServerWebSocket ontext(Action<String> action);
cettia/asity
example-jwa1/src/main/java/io/cettia/asity/example/jwa1/EchoServerInitializer.java
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: bridge-jwa1/src/main/java/io/cettia/asity/bridge/jwa1/AsityServerEndpoint.java // public class AsityServerEndpoint extends Endpoint { // // private Actions<ServerWebSocket> wsActions = new ConcurrentActions<>(); // private JwaServerWebSocket ws; // // @Override // public void onOpen(Session session, EndpointConfig config) { // ws = new JwaServerWebSocket(session); // wsActions.fire(ws); // } // // @Override // public void onError(Session session, Throwable throwable) { // ws.onError(throwable); // } // // @Override // public void onClose(Session session, CloseReason closeReason) { // ws.onClose(); // } // // /** // * Registers an action to be called when {@link ServerWebSocket} is // * available. // */ // public AsityServerEndpoint onwebsocket(Action<ServerWebSocket> action) { // wsActions.add(action); // return this; // } // // } // // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * The names of the handshake request headers. HTTP header is not case-sensitive // * but {@link Set} is case-sensitive. // */ // Set<String> headerNames(); // // /** // * Returns the first handshake request header associated with the given name. // */ // String header(String name); // // /** // * Returns the handshake request headers associated with the given name or empty list // * if no header is found. // */ // List<String> headers(String name); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // }
import io.cettia.asity.action.Action; import io.cettia.asity.bridge.jwa1.AsityServerEndpoint; import io.cettia.asity.example.echo.WebSocketEchoServer; import io.cettia.asity.websocket.ServerWebSocket; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import javax.websocket.DeploymentException; import javax.websocket.HandshakeResponse; import javax.websocket.server.HandshakeRequest; import javax.websocket.server.ServerContainer; import javax.websocket.server.ServerEndpointConfig;
/* * Copyright 2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.example.jwa1; @WebListener public class EchoServerInitializer implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent event) { // Web fragments
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: bridge-jwa1/src/main/java/io/cettia/asity/bridge/jwa1/AsityServerEndpoint.java // public class AsityServerEndpoint extends Endpoint { // // private Actions<ServerWebSocket> wsActions = new ConcurrentActions<>(); // private JwaServerWebSocket ws; // // @Override // public void onOpen(Session session, EndpointConfig config) { // ws = new JwaServerWebSocket(session); // wsActions.fire(ws); // } // // @Override // public void onError(Session session, Throwable throwable) { // ws.onError(throwable); // } // // @Override // public void onClose(Session session, CloseReason closeReason) { // ws.onClose(); // } // // /** // * Registers an action to be called when {@link ServerWebSocket} is // * available. // */ // public AsityServerEndpoint onwebsocket(Action<ServerWebSocket> action) { // wsActions.add(action); // return this; // } // // } // // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * The names of the handshake request headers. HTTP header is not case-sensitive // * but {@link Set} is case-sensitive. // */ // Set<String> headerNames(); // // /** // * Returns the first handshake request header associated with the given name. // */ // String header(String name); // // /** // * Returns the handshake request headers associated with the given name or empty list // * if no header is found. // */ // List<String> headers(String name); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // } // Path: example-jwa1/src/main/java/io/cettia/asity/example/jwa1/EchoServerInitializer.java import io.cettia.asity.action.Action; import io.cettia.asity.bridge.jwa1.AsityServerEndpoint; import io.cettia.asity.example.echo.WebSocketEchoServer; import io.cettia.asity.websocket.ServerWebSocket; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import javax.websocket.DeploymentException; import javax.websocket.HandshakeResponse; import javax.websocket.server.HandshakeRequest; import javax.websocket.server.ServerContainer; import javax.websocket.server.ServerEndpointConfig; /* * Copyright 2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.example.jwa1; @WebListener public class EchoServerInitializer implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent event) { // Web fragments
Action<ServerWebSocket> wsAction = new WebSocketEchoServer();
cettia/asity
example-jwa1/src/main/java/io/cettia/asity/example/jwa1/EchoServerInitializer.java
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: bridge-jwa1/src/main/java/io/cettia/asity/bridge/jwa1/AsityServerEndpoint.java // public class AsityServerEndpoint extends Endpoint { // // private Actions<ServerWebSocket> wsActions = new ConcurrentActions<>(); // private JwaServerWebSocket ws; // // @Override // public void onOpen(Session session, EndpointConfig config) { // ws = new JwaServerWebSocket(session); // wsActions.fire(ws); // } // // @Override // public void onError(Session session, Throwable throwable) { // ws.onError(throwable); // } // // @Override // public void onClose(Session session, CloseReason closeReason) { // ws.onClose(); // } // // /** // * Registers an action to be called when {@link ServerWebSocket} is // * available. // */ // public AsityServerEndpoint onwebsocket(Action<ServerWebSocket> action) { // wsActions.add(action); // return this; // } // // } // // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * The names of the handshake request headers. HTTP header is not case-sensitive // * but {@link Set} is case-sensitive. // */ // Set<String> headerNames(); // // /** // * Returns the first handshake request header associated with the given name. // */ // String header(String name); // // /** // * Returns the handshake request headers associated with the given name or empty list // * if no header is found. // */ // List<String> headers(String name); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // }
import io.cettia.asity.action.Action; import io.cettia.asity.bridge.jwa1.AsityServerEndpoint; import io.cettia.asity.example.echo.WebSocketEchoServer; import io.cettia.asity.websocket.ServerWebSocket; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import javax.websocket.DeploymentException; import javax.websocket.HandshakeResponse; import javax.websocket.server.HandshakeRequest; import javax.websocket.server.ServerContainer; import javax.websocket.server.ServerEndpointConfig;
/* * Copyright 2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.example.jwa1; @WebListener public class EchoServerInitializer implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent event) { // Web fragments
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: bridge-jwa1/src/main/java/io/cettia/asity/bridge/jwa1/AsityServerEndpoint.java // public class AsityServerEndpoint extends Endpoint { // // private Actions<ServerWebSocket> wsActions = new ConcurrentActions<>(); // private JwaServerWebSocket ws; // // @Override // public void onOpen(Session session, EndpointConfig config) { // ws = new JwaServerWebSocket(session); // wsActions.fire(ws); // } // // @Override // public void onError(Session session, Throwable throwable) { // ws.onError(throwable); // } // // @Override // public void onClose(Session session, CloseReason closeReason) { // ws.onClose(); // } // // /** // * Registers an action to be called when {@link ServerWebSocket} is // * available. // */ // public AsityServerEndpoint onwebsocket(Action<ServerWebSocket> action) { // wsActions.add(action); // return this; // } // // } // // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * The names of the handshake request headers. HTTP header is not case-sensitive // * but {@link Set} is case-sensitive. // */ // Set<String> headerNames(); // // /** // * Returns the first handshake request header associated with the given name. // */ // String header(String name); // // /** // * Returns the handshake request headers associated with the given name or empty list // * if no header is found. // */ // List<String> headers(String name); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // } // Path: example-jwa1/src/main/java/io/cettia/asity/example/jwa1/EchoServerInitializer.java import io.cettia.asity.action.Action; import io.cettia.asity.bridge.jwa1.AsityServerEndpoint; import io.cettia.asity.example.echo.WebSocketEchoServer; import io.cettia.asity.websocket.ServerWebSocket; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import javax.websocket.DeploymentException; import javax.websocket.HandshakeResponse; import javax.websocket.server.HandshakeRequest; import javax.websocket.server.ServerContainer; import javax.websocket.server.ServerEndpointConfig; /* * Copyright 2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.example.jwa1; @WebListener public class EchoServerInitializer implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent event) { // Web fragments
Action<ServerWebSocket> wsAction = new WebSocketEchoServer();
cettia/asity
example-jwa1/src/main/java/io/cettia/asity/example/jwa1/EchoServerInitializer.java
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: bridge-jwa1/src/main/java/io/cettia/asity/bridge/jwa1/AsityServerEndpoint.java // public class AsityServerEndpoint extends Endpoint { // // private Actions<ServerWebSocket> wsActions = new ConcurrentActions<>(); // private JwaServerWebSocket ws; // // @Override // public void onOpen(Session session, EndpointConfig config) { // ws = new JwaServerWebSocket(session); // wsActions.fire(ws); // } // // @Override // public void onError(Session session, Throwable throwable) { // ws.onError(throwable); // } // // @Override // public void onClose(Session session, CloseReason closeReason) { // ws.onClose(); // } // // /** // * Registers an action to be called when {@link ServerWebSocket} is // * available. // */ // public AsityServerEndpoint onwebsocket(Action<ServerWebSocket> action) { // wsActions.add(action); // return this; // } // // } // // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * The names of the handshake request headers. HTTP header is not case-sensitive // * but {@link Set} is case-sensitive. // */ // Set<String> headerNames(); // // /** // * Returns the first handshake request header associated with the given name. // */ // String header(String name); // // /** // * Returns the handshake request headers associated with the given name or empty list // * if no header is found. // */ // List<String> headers(String name); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // }
import io.cettia.asity.action.Action; import io.cettia.asity.bridge.jwa1.AsityServerEndpoint; import io.cettia.asity.example.echo.WebSocketEchoServer; import io.cettia.asity.websocket.ServerWebSocket; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import javax.websocket.DeploymentException; import javax.websocket.HandshakeResponse; import javax.websocket.server.HandshakeRequest; import javax.websocket.server.ServerContainer; import javax.websocket.server.ServerEndpointConfig;
/* * Copyright 2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.example.jwa1; @WebListener public class EchoServerInitializer implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent event) { // Web fragments Action<ServerWebSocket> wsAction = new WebSocketEchoServer(); ServletContext context = event.getServletContext(); ServerContainer container = (ServerContainer) context.getAttribute(ServerContainer.class.getName()); ServerEndpointConfig.Configurator configurator = new ServerEndpointConfig.Configurator() { @Override public <T> T getEndpointInstance(Class<T> endpointClass) {
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: bridge-jwa1/src/main/java/io/cettia/asity/bridge/jwa1/AsityServerEndpoint.java // public class AsityServerEndpoint extends Endpoint { // // private Actions<ServerWebSocket> wsActions = new ConcurrentActions<>(); // private JwaServerWebSocket ws; // // @Override // public void onOpen(Session session, EndpointConfig config) { // ws = new JwaServerWebSocket(session); // wsActions.fire(ws); // } // // @Override // public void onError(Session session, Throwable throwable) { // ws.onError(throwable); // } // // @Override // public void onClose(Session session, CloseReason closeReason) { // ws.onClose(); // } // // /** // * Registers an action to be called when {@link ServerWebSocket} is // * available. // */ // public AsityServerEndpoint onwebsocket(Action<ServerWebSocket> action) { // wsActions.add(action); // return this; // } // // } // // Path: websocket/src/main/java/io/cettia/asity/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * The names of the handshake request headers. HTTP header is not case-sensitive // * but {@link Set} is case-sensitive. // */ // Set<String> headerNames(); // // /** // * Returns the first handshake request header associated with the given name. // */ // String header(String name); // // /** // * Returns the handshake request headers associated with the given name or empty list // * if no header is found. // */ // List<String> headers(String name); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // } // Path: example-jwa1/src/main/java/io/cettia/asity/example/jwa1/EchoServerInitializer.java import io.cettia.asity.action.Action; import io.cettia.asity.bridge.jwa1.AsityServerEndpoint; import io.cettia.asity.example.echo.WebSocketEchoServer; import io.cettia.asity.websocket.ServerWebSocket; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import javax.websocket.DeploymentException; import javax.websocket.HandshakeResponse; import javax.websocket.server.HandshakeRequest; import javax.websocket.server.ServerContainer; import javax.websocket.server.ServerEndpointConfig; /* * Copyright 2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.example.jwa1; @WebListener public class EchoServerInitializer implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent event) { // Web fragments Action<ServerWebSocket> wsAction = new WebSocketEchoServer(); ServletContext context = event.getServletContext(); ServerContainer container = (ServerContainer) context.getAttribute(ServerContainer.class.getName()); ServerEndpointConfig.Configurator configurator = new ServerEndpointConfig.Configurator() { @Override public <T> T getEndpointInstance(Class<T> endpointClass) {
AsityServerEndpoint asityServerEndpoint = new AsityServerEndpoint().onwebsocket(wsAction);
cettia/asity
http/src/main/java/io/cettia/asity/http/ServerHttpExchange.java
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // }
import io.cettia.asity.action.Action; import java.nio.ByteBuffer; import java.util.List; import java.util.Set;
/* * Copyright 2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.http; /** * Represents a server-side HTTP request-response exchange. * <p/> * Implementations are not thread-safe. * * @author Donghwan Kim * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616.html">RFC2616 - * Hypertext Transfer Protocol -- HTTP/1.1</a> */ public interface ServerHttpExchange { /** * The request URI. */ String uri(); /** * The name of the request method. */ HttpMethod method(); /** * The names of the request headers. HTTP header is not case-sensitive but * {@link Set} is case-sensitive. */ Set<String> headerNames(); /** * Returns the first request header associated with the given name. */ String header(String name); /** * Returns the request headers associated with the given name or empty list * if no header is found. */ List<String> headers(String name); /** * Reads the request body. If the request header, {@code content-type}, * starts with {@code text/}, the body is read as text, and if not, as * binary. In case of text body, the charset is also determined by the same * header. If it's not given, {@code ISO-8859-1} is used by default. * <p/> * The read data will be passed to event handlers as {@link String} if it's * text and {@link ByteBuffer} if it's binary attached through * {@link ServerHttpExchange#onchunk(Action)}. * <p/> * This method should be called after adding * {@link ServerHttpExchange#onchunk(Action)}, * {@link ServerHttpExchange#onbody(Action)}, and * {@link ServerHttpExchange#onend(Action)} and has no side effect if called * more than once. */ ServerHttpExchange read(); /** * Reads the request body as text. The charset is determined by the request * header, {@code content-type}. If it's not given, {@code ISO-8859-1} is * used by default. * <p/> * The read data will be passed to event handlers as {@link String} attached * through {@link ServerHttpExchange#onchunk(Action)}. * <p/> * This method should be called after adding * {@link ServerHttpExchange#onchunk(Action)}, * {@link ServerHttpExchange#onbody(Action)}, and * {@link ServerHttpExchange#onend(Action)} and has no side effect if called * more than once. */ ServerHttpExchange readAsText(); /** * Reads the request body as text using the given charset. * <p/> * The read data will be passed to event handlers as {@link String} attached * through {@link ServerHttpExchange#onchunk(Action)}. * <p/> * This method should be called after adding * {@link ServerHttpExchange#onchunk(Action)}, * {@link ServerHttpExchange#onbody(Action)}, and * {@link ServerHttpExchange#onend(Action)} and has no side effect if called * more than once. */ ServerHttpExchange readAsText(String charsetName); /** * Reads the request body as binary. * <p/> * The read data will be passed to event handlers as {@link ByteBuffer} * attached through {@link ServerHttpExchange#onchunk(Action)}. * <p/> * This method should be called after adding * {@link ServerHttpExchange#onchunk(Action)}, * {@link ServerHttpExchange#onbody(Action)}, and * {@link ServerHttpExchange#onend(Action)} and has no side effect if called * more than once. */ ServerHttpExchange readAsBinary(); /** * Attaches an action to be called with a chunk from the request body. * * @param <T> The allowed data type. {@link String} for text body and {@link ByteBuffer} for * binary body. */
// Path: action/src/main/java/io/cettia/asity/action/Action.java // @FunctionalInterface // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // Path: http/src/main/java/io/cettia/asity/http/ServerHttpExchange.java import io.cettia.asity.action.Action; import java.nio.ByteBuffer; import java.util.List; import java.util.Set; /* * Copyright 2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.cettia.asity.http; /** * Represents a server-side HTTP request-response exchange. * <p/> * Implementations are not thread-safe. * * @author Donghwan Kim * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616.html">RFC2616 - * Hypertext Transfer Protocol -- HTTP/1.1</a> */ public interface ServerHttpExchange { /** * The request URI. */ String uri(); /** * The name of the request method. */ HttpMethod method(); /** * The names of the request headers. HTTP header is not case-sensitive but * {@link Set} is case-sensitive. */ Set<String> headerNames(); /** * Returns the first request header associated with the given name. */ String header(String name); /** * Returns the request headers associated with the given name or empty list * if no header is found. */ List<String> headers(String name); /** * Reads the request body. If the request header, {@code content-type}, * starts with {@code text/}, the body is read as text, and if not, as * binary. In case of text body, the charset is also determined by the same * header. If it's not given, {@code ISO-8859-1} is used by default. * <p/> * The read data will be passed to event handlers as {@link String} if it's * text and {@link ByteBuffer} if it's binary attached through * {@link ServerHttpExchange#onchunk(Action)}. * <p/> * This method should be called after adding * {@link ServerHttpExchange#onchunk(Action)}, * {@link ServerHttpExchange#onbody(Action)}, and * {@link ServerHttpExchange#onend(Action)} and has no side effect if called * more than once. */ ServerHttpExchange read(); /** * Reads the request body as text. The charset is determined by the request * header, {@code content-type}. If it's not given, {@code ISO-8859-1} is * used by default. * <p/> * The read data will be passed to event handlers as {@link String} attached * through {@link ServerHttpExchange#onchunk(Action)}. * <p/> * This method should be called after adding * {@link ServerHttpExchange#onchunk(Action)}, * {@link ServerHttpExchange#onbody(Action)}, and * {@link ServerHttpExchange#onend(Action)} and has no side effect if called * more than once. */ ServerHttpExchange readAsText(); /** * Reads the request body as text using the given charset. * <p/> * The read data will be passed to event handlers as {@link String} attached * through {@link ServerHttpExchange#onchunk(Action)}. * <p/> * This method should be called after adding * {@link ServerHttpExchange#onchunk(Action)}, * {@link ServerHttpExchange#onbody(Action)}, and * {@link ServerHttpExchange#onend(Action)} and has no side effect if called * more than once. */ ServerHttpExchange readAsText(String charsetName); /** * Reads the request body as binary. * <p/> * The read data will be passed to event handlers as {@link ByteBuffer} * attached through {@link ServerHttpExchange#onchunk(Action)}. * <p/> * This method should be called after adding * {@link ServerHttpExchange#onchunk(Action)}, * {@link ServerHttpExchange#onbody(Action)}, and * {@link ServerHttpExchange#onend(Action)} and has no side effect if called * more than once. */ ServerHttpExchange readAsBinary(); /** * Attaches an action to be called with a chunk from the request body. * * @param <T> The allowed data type. {@link String} for text body and {@link ByteBuffer} for * binary body. */
<T> ServerHttpExchange onchunk(Action<T> action);
JessYanCoding/AndroidAutoSize
autosize/src/main/java/me/jessyan/autosize/InitProvider.java
// Path: autosize/src/main/java/me/jessyan/autosize/utils/AutoSizeUtils.java // public class AutoSizeUtils { // // private AutoSizeUtils() { // throw new IllegalStateException("you can't instantiate me!"); // } // // public static int dp2px(Context context, float value) { // return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, context.getResources().getDisplayMetrics()) + 0.5f); // } // // public static int sp2px(Context context, float value) { // return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, value, context.getResources().getDisplayMetrics()) + 0.5f); // } // // public static int pt2px(Context context, float value) { // return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PT, value, context.getResources().getDisplayMetrics()) + 0.5f); // } // // public static int in2px(Context context, float value) { // return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_IN, value, context.getResources().getDisplayMetrics()) + 0.5f); // } // // public static int mm2px(Context context, float value) { // return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_MM, value, context.getResources().getDisplayMetrics()) + 0.5f); // } // // public static Application getApplicationByReflect() { // try { // @SuppressLint("PrivateApi") // Class<?> activityThread = Class.forName("android.app.ActivityThread"); // Object thread = activityThread.getMethod("currentActivityThread").invoke(null); // Object app = activityThread.getMethod("getApplication").invoke(thread); // if (app == null) { // throw new NullPointerException("you should init first"); // } // return (Application) app; // } catch (NoSuchMethodException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } catch (InvocationTargetException e) { // e.printStackTrace(); // } catch (ClassNotFoundException e) { // e.printStackTrace(); // } // throw new NullPointerException("you should init first"); // } // }
import android.content.Context; import android.app.Application; import android.content.ContentProvider; import android.content.ContentValues; import android.database.Cursor; import android.net.Uri; import me.jessyan.autosize.utils.AutoSizeUtils;
/* * Copyright 2018 JessYan * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package me.jessyan.autosize; /** * ================================================ * 通过声明 {@link ContentProvider} 自动完成初始化 * Created by JessYan on 2018/8/19 11:55 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a> * <a href="https://github.com/JessYanCoding">Follow me</a> * ================================================ */ public class InitProvider extends ContentProvider { @Override public boolean onCreate() { Context application = getContext().getApplicationContext(); if (application == null) {
// Path: autosize/src/main/java/me/jessyan/autosize/utils/AutoSizeUtils.java // public class AutoSizeUtils { // // private AutoSizeUtils() { // throw new IllegalStateException("you can't instantiate me!"); // } // // public static int dp2px(Context context, float value) { // return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, context.getResources().getDisplayMetrics()) + 0.5f); // } // // public static int sp2px(Context context, float value) { // return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, value, context.getResources().getDisplayMetrics()) + 0.5f); // } // // public static int pt2px(Context context, float value) { // return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PT, value, context.getResources().getDisplayMetrics()) + 0.5f); // } // // public static int in2px(Context context, float value) { // return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_IN, value, context.getResources().getDisplayMetrics()) + 0.5f); // } // // public static int mm2px(Context context, float value) { // return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_MM, value, context.getResources().getDisplayMetrics()) + 0.5f); // } // // public static Application getApplicationByReflect() { // try { // @SuppressLint("PrivateApi") // Class<?> activityThread = Class.forName("android.app.ActivityThread"); // Object thread = activityThread.getMethod("currentActivityThread").invoke(null); // Object app = activityThread.getMethod("getApplication").invoke(thread); // if (app == null) { // throw new NullPointerException("you should init first"); // } // return (Application) app; // } catch (NoSuchMethodException e) { // e.printStackTrace(); // } catch (IllegalAccessException e) { // e.printStackTrace(); // } catch (InvocationTargetException e) { // e.printStackTrace(); // } catch (ClassNotFoundException e) { // e.printStackTrace(); // } // throw new NullPointerException("you should init first"); // } // } // Path: autosize/src/main/java/me/jessyan/autosize/InitProvider.java import android.content.Context; import android.app.Application; import android.content.ContentProvider; import android.content.ContentValues; import android.database.Cursor; import android.net.Uri; import me.jessyan.autosize.utils.AutoSizeUtils; /* * Copyright 2018 JessYan * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package me.jessyan.autosize; /** * ================================================ * 通过声明 {@link ContentProvider} 自动完成初始化 * Created by JessYan on 2018/8/19 11:55 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a> * <a href="https://github.com/JessYanCoding">Follow me</a> * ================================================ */ public class InitProvider extends ContentProvider { @Override public boolean onCreate() { Context application = getContext().getApplicationContext(); if (application == null) {
application = AutoSizeUtils.getApplicationByReflect();
JessYanCoding/AndroidAutoSize
autosize/src/main/java/me/jessyan/autosize/ActivityLifecycleCallbacksImpl.java
// Path: autosize/src/main/java/me/jessyan/autosize/AutoSizeConfig.java // public static final boolean DEPENDENCY_ANDROIDX; // // Path: autosize/src/main/java/me/jessyan/autosize/AutoSizeConfig.java // public static final boolean DEPENDENCY_SUPPORT;
import android.app.Activity; import android.app.Application; import android.os.Bundle; import static me.jessyan.autosize.AutoSizeConfig.DEPENDENCY_ANDROIDX; import static me.jessyan.autosize.AutoSizeConfig.DEPENDENCY_SUPPORT;
/* * Copyright 2018 JessYan * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package me.jessyan.autosize; /** * ================================================ * {@link ActivityLifecycleCallbacksImpl} 可用来代替在 BaseActivity 中加入适配代码的传统方式 * {@link ActivityLifecycleCallbacksImpl} 这种方案类似于 AOP, 面向接口, 侵入性低, 方便统一管理, 扩展性强, 并且也支持适配三方库的 {@link Activity} * <p> * Created by JessYan on 2018/8/8 14:32 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a> * <a href="https://github.com/JessYanCoding">Follow me</a> * ================================================ */ public class ActivityLifecycleCallbacksImpl implements Application.ActivityLifecycleCallbacks { /** * 屏幕适配逻辑策略类 */ private AutoAdaptStrategy mAutoAdaptStrategy; /** * 让 Fragment 支持自定义适配参数 */ private FragmentLifecycleCallbacksImpl mFragmentLifecycleCallbacks; private FragmentLifecycleCallbacksImplToAndroidx mFragmentLifecycleCallbacksToAndroidx; public ActivityLifecycleCallbacksImpl(AutoAdaptStrategy autoAdaptStrategy) {
// Path: autosize/src/main/java/me/jessyan/autosize/AutoSizeConfig.java // public static final boolean DEPENDENCY_ANDROIDX; // // Path: autosize/src/main/java/me/jessyan/autosize/AutoSizeConfig.java // public static final boolean DEPENDENCY_SUPPORT; // Path: autosize/src/main/java/me/jessyan/autosize/ActivityLifecycleCallbacksImpl.java import android.app.Activity; import android.app.Application; import android.os.Bundle; import static me.jessyan.autosize.AutoSizeConfig.DEPENDENCY_ANDROIDX; import static me.jessyan.autosize.AutoSizeConfig.DEPENDENCY_SUPPORT; /* * Copyright 2018 JessYan * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package me.jessyan.autosize; /** * ================================================ * {@link ActivityLifecycleCallbacksImpl} 可用来代替在 BaseActivity 中加入适配代码的传统方式 * {@link ActivityLifecycleCallbacksImpl} 这种方案类似于 AOP, 面向接口, 侵入性低, 方便统一管理, 扩展性强, 并且也支持适配三方库的 {@link Activity} * <p> * Created by JessYan on 2018/8/8 14:32 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a> * <a href="https://github.com/JessYanCoding">Follow me</a> * ================================================ */ public class ActivityLifecycleCallbacksImpl implements Application.ActivityLifecycleCallbacks { /** * 屏幕适配逻辑策略类 */ private AutoAdaptStrategy mAutoAdaptStrategy; /** * 让 Fragment 支持自定义适配参数 */ private FragmentLifecycleCallbacksImpl mFragmentLifecycleCallbacks; private FragmentLifecycleCallbacksImplToAndroidx mFragmentLifecycleCallbacksToAndroidx; public ActivityLifecycleCallbacksImpl(AutoAdaptStrategy autoAdaptStrategy) {
if (DEPENDENCY_ANDROIDX) {
JessYanCoding/AndroidAutoSize
autosize/src/main/java/me/jessyan/autosize/ActivityLifecycleCallbacksImpl.java
// Path: autosize/src/main/java/me/jessyan/autosize/AutoSizeConfig.java // public static final boolean DEPENDENCY_ANDROIDX; // // Path: autosize/src/main/java/me/jessyan/autosize/AutoSizeConfig.java // public static final boolean DEPENDENCY_SUPPORT;
import android.app.Activity; import android.app.Application; import android.os.Bundle; import static me.jessyan.autosize.AutoSizeConfig.DEPENDENCY_ANDROIDX; import static me.jessyan.autosize.AutoSizeConfig.DEPENDENCY_SUPPORT;
/* * Copyright 2018 JessYan * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package me.jessyan.autosize; /** * ================================================ * {@link ActivityLifecycleCallbacksImpl} 可用来代替在 BaseActivity 中加入适配代码的传统方式 * {@link ActivityLifecycleCallbacksImpl} 这种方案类似于 AOP, 面向接口, 侵入性低, 方便统一管理, 扩展性强, 并且也支持适配三方库的 {@link Activity} * <p> * Created by JessYan on 2018/8/8 14:32 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a> * <a href="https://github.com/JessYanCoding">Follow me</a> * ================================================ */ public class ActivityLifecycleCallbacksImpl implements Application.ActivityLifecycleCallbacks { /** * 屏幕适配逻辑策略类 */ private AutoAdaptStrategy mAutoAdaptStrategy; /** * 让 Fragment 支持自定义适配参数 */ private FragmentLifecycleCallbacksImpl mFragmentLifecycleCallbacks; private FragmentLifecycleCallbacksImplToAndroidx mFragmentLifecycleCallbacksToAndroidx; public ActivityLifecycleCallbacksImpl(AutoAdaptStrategy autoAdaptStrategy) { if (DEPENDENCY_ANDROIDX) { mFragmentLifecycleCallbacksToAndroidx = new FragmentLifecycleCallbacksImplToAndroidx(autoAdaptStrategy);
// Path: autosize/src/main/java/me/jessyan/autosize/AutoSizeConfig.java // public static final boolean DEPENDENCY_ANDROIDX; // // Path: autosize/src/main/java/me/jessyan/autosize/AutoSizeConfig.java // public static final boolean DEPENDENCY_SUPPORT; // Path: autosize/src/main/java/me/jessyan/autosize/ActivityLifecycleCallbacksImpl.java import android.app.Activity; import android.app.Application; import android.os.Bundle; import static me.jessyan.autosize.AutoSizeConfig.DEPENDENCY_ANDROIDX; import static me.jessyan.autosize.AutoSizeConfig.DEPENDENCY_SUPPORT; /* * Copyright 2018 JessYan * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package me.jessyan.autosize; /** * ================================================ * {@link ActivityLifecycleCallbacksImpl} 可用来代替在 BaseActivity 中加入适配代码的传统方式 * {@link ActivityLifecycleCallbacksImpl} 这种方案类似于 AOP, 面向接口, 侵入性低, 方便统一管理, 扩展性强, 并且也支持适配三方库的 {@link Activity} * <p> * Created by JessYan on 2018/8/8 14:32 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a> * <a href="https://github.com/JessYanCoding">Follow me</a> * ================================================ */ public class ActivityLifecycleCallbacksImpl implements Application.ActivityLifecycleCallbacks { /** * 屏幕适配逻辑策略类 */ private AutoAdaptStrategy mAutoAdaptStrategy; /** * 让 Fragment 支持自定义适配参数 */ private FragmentLifecycleCallbacksImpl mFragmentLifecycleCallbacks; private FragmentLifecycleCallbacksImplToAndroidx mFragmentLifecycleCallbacksToAndroidx; public ActivityLifecycleCallbacksImpl(AutoAdaptStrategy autoAdaptStrategy) { if (DEPENDENCY_ANDROIDX) { mFragmentLifecycleCallbacksToAndroidx = new FragmentLifecycleCallbacksImplToAndroidx(autoAdaptStrategy);
} else if (DEPENDENCY_SUPPORT){
d-michail/jheaps
src/test/java/org/jheaps/tree/ReflectedFibonacciHeapDoubleEndedAddressableHeapTest.java
// Path: src/main/java/org/jheaps/DoubleEndedAddressableHeap.java // public interface DoubleEndedAddressableHeap<K, V> extends AddressableHeap<K, V> { // // /** // * Insert a new element into the heap. // * // * @param key // * the element's key // * @param value // * the element's value // * // * @return a handle for the newly added element // */ // Handle<K, V> insert(K key, V value); // // /** // * Insert a new element into the heap with a null value. // * // * @param key // * the element's key // * @return a handle for the newly added element // */ // Handle<K, V> insert(K key); // // /** // * Find an element with the minimum key. // * // * @return a handle to an element with minimum key // */ // Handle<K, V> findMin(); // // /** // * Delete and return an element with the minimum key. If multiple such // * elements exists, only one of them will be deleted. After the element is // * deleted the handle is invalidated and only method {@link Handle#getKey()} // * and {@link Handle#getValue()} can be used. // * // * @return a handle to the deleted element with minimum key // */ // Handle<K, V> deleteMin(); // // /** // * Find an element with the maximum key. // * // * @return an element with the maximum key // * @throws NoSuchElementException // * if the heap is empty // */ // Handle<K, V> findMax(); // // /** // * Delete and return an element with the maximum key. If multiple such // * elements exists, only one of them will be deleted. // * // * @return the deleted element with the maximum key // * @throws NoSuchElementException // * if the heap is empty // */ // Handle<K, V> deleteMax(); // // /** // * A double-ended heap element handle. Allows someone to address an element // * already in a heap and perform additional operations. // * // * @param <K> // * the type of keys maintained by this heap // * @param <V> // * the type of values maintained by this heap // */ // interface Handle<K, V> extends AddressableHeap.Handle<K, V> { // // /** // * Increase the key of the element. // * // * @param newKey // * the new key // * @throws IllegalArgumentException // * if the new key is smaller than the old key according to // * the comparator used when constructing the heap or the // * natural ordering of the elements if no comparator was // * used // */ // void increaseKey(K newKey); // // } // // }
import java.util.Comparator; import org.jheaps.DoubleEndedAddressableHeap;
/* * (C) Copyright 2014-2016, by Dimitrios Michail * * JHeaps Library * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jheaps.tree; public class ReflectedFibonacciHeapDoubleEndedAddressableHeapTest extends AbstractDoubleEndedAddressableHeapTest { @Override
// Path: src/main/java/org/jheaps/DoubleEndedAddressableHeap.java // public interface DoubleEndedAddressableHeap<K, V> extends AddressableHeap<K, V> { // // /** // * Insert a new element into the heap. // * // * @param key // * the element's key // * @param value // * the element's value // * // * @return a handle for the newly added element // */ // Handle<K, V> insert(K key, V value); // // /** // * Insert a new element into the heap with a null value. // * // * @param key // * the element's key // * @return a handle for the newly added element // */ // Handle<K, V> insert(K key); // // /** // * Find an element with the minimum key. // * // * @return a handle to an element with minimum key // */ // Handle<K, V> findMin(); // // /** // * Delete and return an element with the minimum key. If multiple such // * elements exists, only one of them will be deleted. After the element is // * deleted the handle is invalidated and only method {@link Handle#getKey()} // * and {@link Handle#getValue()} can be used. // * // * @return a handle to the deleted element with minimum key // */ // Handle<K, V> deleteMin(); // // /** // * Find an element with the maximum key. // * // * @return an element with the maximum key // * @throws NoSuchElementException // * if the heap is empty // */ // Handle<K, V> findMax(); // // /** // * Delete and return an element with the maximum key. If multiple such // * elements exists, only one of them will be deleted. // * // * @return the deleted element with the maximum key // * @throws NoSuchElementException // * if the heap is empty // */ // Handle<K, V> deleteMax(); // // /** // * A double-ended heap element handle. Allows someone to address an element // * already in a heap and perform additional operations. // * // * @param <K> // * the type of keys maintained by this heap // * @param <V> // * the type of values maintained by this heap // */ // interface Handle<K, V> extends AddressableHeap.Handle<K, V> { // // /** // * Increase the key of the element. // * // * @param newKey // * the new key // * @throws IllegalArgumentException // * if the new key is smaller than the old key according to // * the comparator used when constructing the heap or the // * natural ordering of the elements if no comparator was // * used // */ // void increaseKey(K newKey); // // } // // } // Path: src/test/java/org/jheaps/tree/ReflectedFibonacciHeapDoubleEndedAddressableHeapTest.java import java.util.Comparator; import org.jheaps.DoubleEndedAddressableHeap; /* * (C) Copyright 2014-2016, by Dimitrios Michail * * JHeaps Library * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jheaps.tree; public class ReflectedFibonacciHeapDoubleEndedAddressableHeapTest extends AbstractDoubleEndedAddressableHeapTest { @Override
protected DoubleEndedAddressableHeap<Integer, Void> createHeap() {
d-michail/jheaps
src/test/java/org/jheaps/tree/SimpleFibonacciHeapAddressableHeapTest.java
// Path: src/main/java/org/jheaps/AddressableHeap.java // public interface AddressableHeap<K, V> { // // /** // * A heap element handle. Allows someone to address an element already in a // * heap and perform additional operations. // * // * @param <K> // * the type of keys maintained by this heap // * @param <V> // * the type of values maintained by this heap // */ // interface Handle<K, V> { // // /** // * Return the key of the element. // * // * @return the key of the element // */ // K getKey(); // // /** // * Return the value of the element. // * // * @return the value of the element // */ // V getValue(); // // /** // * Set the value of the element. // * // * @param value // * the new value // */ // void setValue(V value); // // /** // * Decrease the key of the element. // * // * @param newKey // * the new key // * @throws IllegalArgumentException // * if the new key is larger than the old key according to // * the comparator used when constructing the heap or the // * natural ordering of the elements if no comparator was // * used // */ // void decreaseKey(K newKey); // // /** // * Delete the element from the heap that it belongs. // * // * @throws IllegalArgumentException // * in case this function is called twice on the same element // * or the element has already been deleted using // * {@link AddressableHeap#deleteMin()}. // */ // void delete(); // // } // // /** // * Returns the comparator used to order the keys in this AddressableHeap, or // * {@code null} if this heap uses the {@linkplain Comparable natural // * ordering} of its keys. // * // * @return the comparator used to order the keys in this heap, or // * {@code null} if this addressable heap uses the natural ordering // * of its keys // */ // Comparator<? super K> comparator(); // // /** // * Insert a new element into the heap. // * // * @param key // * the element's key // * @param value // * the element's value // * // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key, V value); // // /** // * Insert a new element into the heap with a null value. // * // * @param key // * the element's key // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key); // // /** // * Find an element with the minimum key. // * // * @return a handle to an element with minimum key // */ // AddressableHeap.Handle<K, V> findMin(); // // /** // * Delete and return an element with the minimum key. If multiple such // * elements exists, only one of them will be deleted. After the element is // * deleted the handle is invalidated and only method {@link Handle#getKey()} // * and {@link Handle#getValue()} can be used. // * // * @return a handle to the deleted element with minimum key // */ // AddressableHeap.Handle<K, V> deleteMin(); // // /** // * Returns {@code true} if this heap is empty. // * // * @return {@code true} if this heap is empty, {@code false} otherwise // */ // boolean isEmpty(); // // /** // * Returns the number of elements in the heap. // * // * @return the number of elements in the heap // */ // long size(); // // /** // * Clear all the elements of the heap. After calling this method all handles // * should be considered invalidated and the behavior of methods // * {@link Handle#decreaseKey(Object)} and {@link Handle#delete()} is // * undefined. // */ // void clear(); // // }
import java.util.Comparator; import org.jheaps.AddressableHeap;
/* * (C) Copyright 2014-2016, by Dimitrios Michail * * JHeaps Library * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jheaps.tree; public class SimpleFibonacciHeapAddressableHeapTest extends AbstractAddressableHeapTest { @Override
// Path: src/main/java/org/jheaps/AddressableHeap.java // public interface AddressableHeap<K, V> { // // /** // * A heap element handle. Allows someone to address an element already in a // * heap and perform additional operations. // * // * @param <K> // * the type of keys maintained by this heap // * @param <V> // * the type of values maintained by this heap // */ // interface Handle<K, V> { // // /** // * Return the key of the element. // * // * @return the key of the element // */ // K getKey(); // // /** // * Return the value of the element. // * // * @return the value of the element // */ // V getValue(); // // /** // * Set the value of the element. // * // * @param value // * the new value // */ // void setValue(V value); // // /** // * Decrease the key of the element. // * // * @param newKey // * the new key // * @throws IllegalArgumentException // * if the new key is larger than the old key according to // * the comparator used when constructing the heap or the // * natural ordering of the elements if no comparator was // * used // */ // void decreaseKey(K newKey); // // /** // * Delete the element from the heap that it belongs. // * // * @throws IllegalArgumentException // * in case this function is called twice on the same element // * or the element has already been deleted using // * {@link AddressableHeap#deleteMin()}. // */ // void delete(); // // } // // /** // * Returns the comparator used to order the keys in this AddressableHeap, or // * {@code null} if this heap uses the {@linkplain Comparable natural // * ordering} of its keys. // * // * @return the comparator used to order the keys in this heap, or // * {@code null} if this addressable heap uses the natural ordering // * of its keys // */ // Comparator<? super K> comparator(); // // /** // * Insert a new element into the heap. // * // * @param key // * the element's key // * @param value // * the element's value // * // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key, V value); // // /** // * Insert a new element into the heap with a null value. // * // * @param key // * the element's key // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key); // // /** // * Find an element with the minimum key. // * // * @return a handle to an element with minimum key // */ // AddressableHeap.Handle<K, V> findMin(); // // /** // * Delete and return an element with the minimum key. If multiple such // * elements exists, only one of them will be deleted. After the element is // * deleted the handle is invalidated and only method {@link Handle#getKey()} // * and {@link Handle#getValue()} can be used. // * // * @return a handle to the deleted element with minimum key // */ // AddressableHeap.Handle<K, V> deleteMin(); // // /** // * Returns {@code true} if this heap is empty. // * // * @return {@code true} if this heap is empty, {@code false} otherwise // */ // boolean isEmpty(); // // /** // * Returns the number of elements in the heap. // * // * @return the number of elements in the heap // */ // long size(); // // /** // * Clear all the elements of the heap. After calling this method all handles // * should be considered invalidated and the behavior of methods // * {@link Handle#decreaseKey(Object)} and {@link Handle#delete()} is // * undefined. // */ // void clear(); // // } // Path: src/test/java/org/jheaps/tree/SimpleFibonacciHeapAddressableHeapTest.java import java.util.Comparator; import org.jheaps.AddressableHeap; /* * (C) Copyright 2014-2016, by Dimitrios Michail * * JHeaps Library * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jheaps.tree; public class SimpleFibonacciHeapAddressableHeapTest extends AbstractAddressableHeapTest { @Override
protected AddressableHeap<Integer, Void> createHeap() {
d-michail/jheaps
src/test/java/org/jheaps/tree/SkewHeapAddressableHeapTest.java
// Path: src/main/java/org/jheaps/AddressableHeap.java // public interface AddressableHeap<K, V> { // // /** // * A heap element handle. Allows someone to address an element already in a // * heap and perform additional operations. // * // * @param <K> // * the type of keys maintained by this heap // * @param <V> // * the type of values maintained by this heap // */ // interface Handle<K, V> { // // /** // * Return the key of the element. // * // * @return the key of the element // */ // K getKey(); // // /** // * Return the value of the element. // * // * @return the value of the element // */ // V getValue(); // // /** // * Set the value of the element. // * // * @param value // * the new value // */ // void setValue(V value); // // /** // * Decrease the key of the element. // * // * @param newKey // * the new key // * @throws IllegalArgumentException // * if the new key is larger than the old key according to // * the comparator used when constructing the heap or the // * natural ordering of the elements if no comparator was // * used // */ // void decreaseKey(K newKey); // // /** // * Delete the element from the heap that it belongs. // * // * @throws IllegalArgumentException // * in case this function is called twice on the same element // * or the element has already been deleted using // * {@link AddressableHeap#deleteMin()}. // */ // void delete(); // // } // // /** // * Returns the comparator used to order the keys in this AddressableHeap, or // * {@code null} if this heap uses the {@linkplain Comparable natural // * ordering} of its keys. // * // * @return the comparator used to order the keys in this heap, or // * {@code null} if this addressable heap uses the natural ordering // * of its keys // */ // Comparator<? super K> comparator(); // // /** // * Insert a new element into the heap. // * // * @param key // * the element's key // * @param value // * the element's value // * // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key, V value); // // /** // * Insert a new element into the heap with a null value. // * // * @param key // * the element's key // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key); // // /** // * Find an element with the minimum key. // * // * @return a handle to an element with minimum key // */ // AddressableHeap.Handle<K, V> findMin(); // // /** // * Delete and return an element with the minimum key. If multiple such // * elements exists, only one of them will be deleted. After the element is // * deleted the handle is invalidated and only method {@link Handle#getKey()} // * and {@link Handle#getValue()} can be used. // * // * @return a handle to the deleted element with minimum key // */ // AddressableHeap.Handle<K, V> deleteMin(); // // /** // * Returns {@code true} if this heap is empty. // * // * @return {@code true} if this heap is empty, {@code false} otherwise // */ // boolean isEmpty(); // // /** // * Returns the number of elements in the heap. // * // * @return the number of elements in the heap // */ // long size(); // // /** // * Clear all the elements of the heap. After calling this method all handles // * should be considered invalidated and the behavior of methods // * {@link Handle#decreaseKey(Object)} and {@link Handle#delete()} is // * undefined. // */ // void clear(); // // }
import java.util.Comparator; import org.jheaps.AddressableHeap;
/* * (C) Copyright 2014-2016, by Dimitrios Michail * * JHeaps Library * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jheaps.tree; public class SkewHeapAddressableHeapTest extends AbstractAddressableHeapTest { @Override
// Path: src/main/java/org/jheaps/AddressableHeap.java // public interface AddressableHeap<K, V> { // // /** // * A heap element handle. Allows someone to address an element already in a // * heap and perform additional operations. // * // * @param <K> // * the type of keys maintained by this heap // * @param <V> // * the type of values maintained by this heap // */ // interface Handle<K, V> { // // /** // * Return the key of the element. // * // * @return the key of the element // */ // K getKey(); // // /** // * Return the value of the element. // * // * @return the value of the element // */ // V getValue(); // // /** // * Set the value of the element. // * // * @param value // * the new value // */ // void setValue(V value); // // /** // * Decrease the key of the element. // * // * @param newKey // * the new key // * @throws IllegalArgumentException // * if the new key is larger than the old key according to // * the comparator used when constructing the heap or the // * natural ordering of the elements if no comparator was // * used // */ // void decreaseKey(K newKey); // // /** // * Delete the element from the heap that it belongs. // * // * @throws IllegalArgumentException // * in case this function is called twice on the same element // * or the element has already been deleted using // * {@link AddressableHeap#deleteMin()}. // */ // void delete(); // // } // // /** // * Returns the comparator used to order the keys in this AddressableHeap, or // * {@code null} if this heap uses the {@linkplain Comparable natural // * ordering} of its keys. // * // * @return the comparator used to order the keys in this heap, or // * {@code null} if this addressable heap uses the natural ordering // * of its keys // */ // Comparator<? super K> comparator(); // // /** // * Insert a new element into the heap. // * // * @param key // * the element's key // * @param value // * the element's value // * // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key, V value); // // /** // * Insert a new element into the heap with a null value. // * // * @param key // * the element's key // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key); // // /** // * Find an element with the minimum key. // * // * @return a handle to an element with minimum key // */ // AddressableHeap.Handle<K, V> findMin(); // // /** // * Delete and return an element with the minimum key. If multiple such // * elements exists, only one of them will be deleted. After the element is // * deleted the handle is invalidated and only method {@link Handle#getKey()} // * and {@link Handle#getValue()} can be used. // * // * @return a handle to the deleted element with minimum key // */ // AddressableHeap.Handle<K, V> deleteMin(); // // /** // * Returns {@code true} if this heap is empty. // * // * @return {@code true} if this heap is empty, {@code false} otherwise // */ // boolean isEmpty(); // // /** // * Returns the number of elements in the heap. // * // * @return the number of elements in the heap // */ // long size(); // // /** // * Clear all the elements of the heap. After calling this method all handles // * should be considered invalidated and the behavior of methods // * {@link Handle#decreaseKey(Object)} and {@link Handle#delete()} is // * undefined. // */ // void clear(); // // } // Path: src/test/java/org/jheaps/tree/SkewHeapAddressableHeapTest.java import java.util.Comparator; import org.jheaps.AddressableHeap; /* * (C) Copyright 2014-2016, by Dimitrios Michail * * JHeaps Library * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jheaps.tree; public class SkewHeapAddressableHeapTest extends AbstractAddressableHeapTest { @Override
protected AddressableHeap<Integer, Void> createHeap() {
d-michail/jheaps
src/test/java/org/jheaps/tree/D8DaryTreeAddressableHeapTest.java
// Path: src/main/java/org/jheaps/AddressableHeap.java // public interface AddressableHeap<K, V> { // // /** // * A heap element handle. Allows someone to address an element already in a // * heap and perform additional operations. // * // * @param <K> // * the type of keys maintained by this heap // * @param <V> // * the type of values maintained by this heap // */ // interface Handle<K, V> { // // /** // * Return the key of the element. // * // * @return the key of the element // */ // K getKey(); // // /** // * Return the value of the element. // * // * @return the value of the element // */ // V getValue(); // // /** // * Set the value of the element. // * // * @param value // * the new value // */ // void setValue(V value); // // /** // * Decrease the key of the element. // * // * @param newKey // * the new key // * @throws IllegalArgumentException // * if the new key is larger than the old key according to // * the comparator used when constructing the heap or the // * natural ordering of the elements if no comparator was // * used // */ // void decreaseKey(K newKey); // // /** // * Delete the element from the heap that it belongs. // * // * @throws IllegalArgumentException // * in case this function is called twice on the same element // * or the element has already been deleted using // * {@link AddressableHeap#deleteMin()}. // */ // void delete(); // // } // // /** // * Returns the comparator used to order the keys in this AddressableHeap, or // * {@code null} if this heap uses the {@linkplain Comparable natural // * ordering} of its keys. // * // * @return the comparator used to order the keys in this heap, or // * {@code null} if this addressable heap uses the natural ordering // * of its keys // */ // Comparator<? super K> comparator(); // // /** // * Insert a new element into the heap. // * // * @param key // * the element's key // * @param value // * the element's value // * // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key, V value); // // /** // * Insert a new element into the heap with a null value. // * // * @param key // * the element's key // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key); // // /** // * Find an element with the minimum key. // * // * @return a handle to an element with minimum key // */ // AddressableHeap.Handle<K, V> findMin(); // // /** // * Delete and return an element with the minimum key. If multiple such // * elements exists, only one of them will be deleted. After the element is // * deleted the handle is invalidated and only method {@link Handle#getKey()} // * and {@link Handle#getValue()} can be used. // * // * @return a handle to the deleted element with minimum key // */ // AddressableHeap.Handle<K, V> deleteMin(); // // /** // * Returns {@code true} if this heap is empty. // * // * @return {@code true} if this heap is empty, {@code false} otherwise // */ // boolean isEmpty(); // // /** // * Returns the number of elements in the heap. // * // * @return the number of elements in the heap // */ // long size(); // // /** // * Clear all the elements of the heap. After calling this method all handles // * should be considered invalidated and the behavior of methods // * {@link Handle#decreaseKey(Object)} and {@link Handle#delete()} is // * undefined. // */ // void clear(); // // }
import java.util.Comparator; import org.jheaps.AddressableHeap;
/* * (C) Copyright 2014-2019, by Dimitrios Michail * * JHeaps Library * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jheaps.tree; public class D8DaryTreeAddressableHeapTest extends AbstractAddressableHeapTest { @Override
// Path: src/main/java/org/jheaps/AddressableHeap.java // public interface AddressableHeap<K, V> { // // /** // * A heap element handle. Allows someone to address an element already in a // * heap and perform additional operations. // * // * @param <K> // * the type of keys maintained by this heap // * @param <V> // * the type of values maintained by this heap // */ // interface Handle<K, V> { // // /** // * Return the key of the element. // * // * @return the key of the element // */ // K getKey(); // // /** // * Return the value of the element. // * // * @return the value of the element // */ // V getValue(); // // /** // * Set the value of the element. // * // * @param value // * the new value // */ // void setValue(V value); // // /** // * Decrease the key of the element. // * // * @param newKey // * the new key // * @throws IllegalArgumentException // * if the new key is larger than the old key according to // * the comparator used when constructing the heap or the // * natural ordering of the elements if no comparator was // * used // */ // void decreaseKey(K newKey); // // /** // * Delete the element from the heap that it belongs. // * // * @throws IllegalArgumentException // * in case this function is called twice on the same element // * or the element has already been deleted using // * {@link AddressableHeap#deleteMin()}. // */ // void delete(); // // } // // /** // * Returns the comparator used to order the keys in this AddressableHeap, or // * {@code null} if this heap uses the {@linkplain Comparable natural // * ordering} of its keys. // * // * @return the comparator used to order the keys in this heap, or // * {@code null} if this addressable heap uses the natural ordering // * of its keys // */ // Comparator<? super K> comparator(); // // /** // * Insert a new element into the heap. // * // * @param key // * the element's key // * @param value // * the element's value // * // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key, V value); // // /** // * Insert a new element into the heap with a null value. // * // * @param key // * the element's key // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key); // // /** // * Find an element with the minimum key. // * // * @return a handle to an element with minimum key // */ // AddressableHeap.Handle<K, V> findMin(); // // /** // * Delete and return an element with the minimum key. If multiple such // * elements exists, only one of them will be deleted. After the element is // * deleted the handle is invalidated and only method {@link Handle#getKey()} // * and {@link Handle#getValue()} can be used. // * // * @return a handle to the deleted element with minimum key // */ // AddressableHeap.Handle<K, V> deleteMin(); // // /** // * Returns {@code true} if this heap is empty. // * // * @return {@code true} if this heap is empty, {@code false} otherwise // */ // boolean isEmpty(); // // /** // * Returns the number of elements in the heap. // * // * @return the number of elements in the heap // */ // long size(); // // /** // * Clear all the elements of the heap. After calling this method all handles // * should be considered invalidated and the behavior of methods // * {@link Handle#decreaseKey(Object)} and {@link Handle#delete()} is // * undefined. // */ // void clear(); // // } // Path: src/test/java/org/jheaps/tree/D8DaryTreeAddressableHeapTest.java import java.util.Comparator; import org.jheaps.AddressableHeap; /* * (C) Copyright 2014-2019, by Dimitrios Michail * * JHeaps Library * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jheaps.tree; public class D8DaryTreeAddressableHeapTest extends AbstractAddressableHeapTest { @Override
protected AddressableHeap<Integer, Void> createHeap() {
d-michail/jheaps
src/test/java/org/jheaps/tree/D16DaryTreeAddressableHeapTest.java
// Path: src/main/java/org/jheaps/AddressableHeap.java // public interface AddressableHeap<K, V> { // // /** // * A heap element handle. Allows someone to address an element already in a // * heap and perform additional operations. // * // * @param <K> // * the type of keys maintained by this heap // * @param <V> // * the type of values maintained by this heap // */ // interface Handle<K, V> { // // /** // * Return the key of the element. // * // * @return the key of the element // */ // K getKey(); // // /** // * Return the value of the element. // * // * @return the value of the element // */ // V getValue(); // // /** // * Set the value of the element. // * // * @param value // * the new value // */ // void setValue(V value); // // /** // * Decrease the key of the element. // * // * @param newKey // * the new key // * @throws IllegalArgumentException // * if the new key is larger than the old key according to // * the comparator used when constructing the heap or the // * natural ordering of the elements if no comparator was // * used // */ // void decreaseKey(K newKey); // // /** // * Delete the element from the heap that it belongs. // * // * @throws IllegalArgumentException // * in case this function is called twice on the same element // * or the element has already been deleted using // * {@link AddressableHeap#deleteMin()}. // */ // void delete(); // // } // // /** // * Returns the comparator used to order the keys in this AddressableHeap, or // * {@code null} if this heap uses the {@linkplain Comparable natural // * ordering} of its keys. // * // * @return the comparator used to order the keys in this heap, or // * {@code null} if this addressable heap uses the natural ordering // * of its keys // */ // Comparator<? super K> comparator(); // // /** // * Insert a new element into the heap. // * // * @param key // * the element's key // * @param value // * the element's value // * // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key, V value); // // /** // * Insert a new element into the heap with a null value. // * // * @param key // * the element's key // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key); // // /** // * Find an element with the minimum key. // * // * @return a handle to an element with minimum key // */ // AddressableHeap.Handle<K, V> findMin(); // // /** // * Delete and return an element with the minimum key. If multiple such // * elements exists, only one of them will be deleted. After the element is // * deleted the handle is invalidated and only method {@link Handle#getKey()} // * and {@link Handle#getValue()} can be used. // * // * @return a handle to the deleted element with minimum key // */ // AddressableHeap.Handle<K, V> deleteMin(); // // /** // * Returns {@code true} if this heap is empty. // * // * @return {@code true} if this heap is empty, {@code false} otherwise // */ // boolean isEmpty(); // // /** // * Returns the number of elements in the heap. // * // * @return the number of elements in the heap // */ // long size(); // // /** // * Clear all the elements of the heap. After calling this method all handles // * should be considered invalidated and the behavior of methods // * {@link Handle#decreaseKey(Object)} and {@link Handle#delete()} is // * undefined. // */ // void clear(); // // }
import java.util.Comparator; import org.jheaps.AddressableHeap;
/* * (C) Copyright 2014-2019, by Dimitrios Michail * * JHeaps Library * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jheaps.tree; public class D16DaryTreeAddressableHeapTest extends AbstractAddressableHeapTest { @Override
// Path: src/main/java/org/jheaps/AddressableHeap.java // public interface AddressableHeap<K, V> { // // /** // * A heap element handle. Allows someone to address an element already in a // * heap and perform additional operations. // * // * @param <K> // * the type of keys maintained by this heap // * @param <V> // * the type of values maintained by this heap // */ // interface Handle<K, V> { // // /** // * Return the key of the element. // * // * @return the key of the element // */ // K getKey(); // // /** // * Return the value of the element. // * // * @return the value of the element // */ // V getValue(); // // /** // * Set the value of the element. // * // * @param value // * the new value // */ // void setValue(V value); // // /** // * Decrease the key of the element. // * // * @param newKey // * the new key // * @throws IllegalArgumentException // * if the new key is larger than the old key according to // * the comparator used when constructing the heap or the // * natural ordering of the elements if no comparator was // * used // */ // void decreaseKey(K newKey); // // /** // * Delete the element from the heap that it belongs. // * // * @throws IllegalArgumentException // * in case this function is called twice on the same element // * or the element has already been deleted using // * {@link AddressableHeap#deleteMin()}. // */ // void delete(); // // } // // /** // * Returns the comparator used to order the keys in this AddressableHeap, or // * {@code null} if this heap uses the {@linkplain Comparable natural // * ordering} of its keys. // * // * @return the comparator used to order the keys in this heap, or // * {@code null} if this addressable heap uses the natural ordering // * of its keys // */ // Comparator<? super K> comparator(); // // /** // * Insert a new element into the heap. // * // * @param key // * the element's key // * @param value // * the element's value // * // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key, V value); // // /** // * Insert a new element into the heap with a null value. // * // * @param key // * the element's key // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key); // // /** // * Find an element with the minimum key. // * // * @return a handle to an element with minimum key // */ // AddressableHeap.Handle<K, V> findMin(); // // /** // * Delete and return an element with the minimum key. If multiple such // * elements exists, only one of them will be deleted. After the element is // * deleted the handle is invalidated and only method {@link Handle#getKey()} // * and {@link Handle#getValue()} can be used. // * // * @return a handle to the deleted element with minimum key // */ // AddressableHeap.Handle<K, V> deleteMin(); // // /** // * Returns {@code true} if this heap is empty. // * // * @return {@code true} if this heap is empty, {@code false} otherwise // */ // boolean isEmpty(); // // /** // * Returns the number of elements in the heap. // * // * @return the number of elements in the heap // */ // long size(); // // /** // * Clear all the elements of the heap. After calling this method all handles // * should be considered invalidated and the behavior of methods // * {@link Handle#decreaseKey(Object)} and {@link Handle#delete()} is // * undefined. // */ // void clear(); // // } // Path: src/test/java/org/jheaps/tree/D16DaryTreeAddressableHeapTest.java import java.util.Comparator; import org.jheaps.AddressableHeap; /* * (C) Copyright 2014-2019, by Dimitrios Michail * * JHeaps Library * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jheaps.tree; public class D16DaryTreeAddressableHeapTest extends AbstractAddressableHeapTest { @Override
protected AddressableHeap<Integer, Void> createHeap() {
d-michail/jheaps
src/main/java/org/jheaps/array/DaryArrayAddressableHeap.java
// Path: src/main/java/org/jheaps/AddressableHeap.java // public interface AddressableHeap<K, V> { // // /** // * A heap element handle. Allows someone to address an element already in a // * heap and perform additional operations. // * // * @param <K> // * the type of keys maintained by this heap // * @param <V> // * the type of values maintained by this heap // */ // interface Handle<K, V> { // // /** // * Return the key of the element. // * // * @return the key of the element // */ // K getKey(); // // /** // * Return the value of the element. // * // * @return the value of the element // */ // V getValue(); // // /** // * Set the value of the element. // * // * @param value // * the new value // */ // void setValue(V value); // // /** // * Decrease the key of the element. // * // * @param newKey // * the new key // * @throws IllegalArgumentException // * if the new key is larger than the old key according to // * the comparator used when constructing the heap or the // * natural ordering of the elements if no comparator was // * used // */ // void decreaseKey(K newKey); // // /** // * Delete the element from the heap that it belongs. // * // * @throws IllegalArgumentException // * in case this function is called twice on the same element // * or the element has already been deleted using // * {@link AddressableHeap#deleteMin()}. // */ // void delete(); // // } // // /** // * Returns the comparator used to order the keys in this AddressableHeap, or // * {@code null} if this heap uses the {@linkplain Comparable natural // * ordering} of its keys. // * // * @return the comparator used to order the keys in this heap, or // * {@code null} if this addressable heap uses the natural ordering // * of its keys // */ // Comparator<? super K> comparator(); // // /** // * Insert a new element into the heap. // * // * @param key // * the element's key // * @param value // * the element's value // * // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key, V value); // // /** // * Insert a new element into the heap with a null value. // * // * @param key // * the element's key // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key); // // /** // * Find an element with the minimum key. // * // * @return a handle to an element with minimum key // */ // AddressableHeap.Handle<K, V> findMin(); // // /** // * Delete and return an element with the minimum key. If multiple such // * elements exists, only one of them will be deleted. After the element is // * deleted the handle is invalidated and only method {@link Handle#getKey()} // * and {@link Handle#getValue()} can be used. // * // * @return a handle to the deleted element with minimum key // */ // AddressableHeap.Handle<K, V> deleteMin(); // // /** // * Returns {@code true} if this heap is empty. // * // * @return {@code true} if this heap is empty, {@code false} otherwise // */ // boolean isEmpty(); // // /** // * Returns the number of elements in the heap. // * // * @return the number of elements in the heap // */ // long size(); // // /** // * Clear all the elements of the heap. After calling this method all handles // * should be considered invalidated and the behavior of methods // * {@link Handle#decreaseKey(Object)} and {@link Handle#delete()} is // * undefined. // */ // void clear(); // // }
import java.io.Serializable; import java.lang.reflect.Array; import java.util.Comparator; import java.util.Iterator; import java.util.NoSuchElementException; import org.jheaps.AddressableHeap; import org.jheaps.annotations.LinearTime;
return new DaryArrayAddressableHeap<K, V>(d, comparator); } DaryArrayAddressableHeap<K, V> h = new DaryArrayAddressableHeap<K, V>(d, comparator, keys.length); for (int i = 0; i < keys.length; i++) { K key = keys[i]; V value = (values == null) ? null : values[i]; AbstractArrayAddressableHeap<K, V>.ArrayHandle ah = h.new ArrayHandle(key, value); ah.index = i + 1; h.array[i + 1] = ah; } h.size = keys.length; for (int i = keys.length / d; i > 0; i--) { h.fixdownWithComparator(i); } return h; } /** * Get an iterator for all handles currently in the heap. * * This method is especially useful when building a heap using the heapify * method. Unspecified behavior will occur if the heap is modified while * using this iterator. * * @return an iterator which will return all handles of the heap */
// Path: src/main/java/org/jheaps/AddressableHeap.java // public interface AddressableHeap<K, V> { // // /** // * A heap element handle. Allows someone to address an element already in a // * heap and perform additional operations. // * // * @param <K> // * the type of keys maintained by this heap // * @param <V> // * the type of values maintained by this heap // */ // interface Handle<K, V> { // // /** // * Return the key of the element. // * // * @return the key of the element // */ // K getKey(); // // /** // * Return the value of the element. // * // * @return the value of the element // */ // V getValue(); // // /** // * Set the value of the element. // * // * @param value // * the new value // */ // void setValue(V value); // // /** // * Decrease the key of the element. // * // * @param newKey // * the new key // * @throws IllegalArgumentException // * if the new key is larger than the old key according to // * the comparator used when constructing the heap or the // * natural ordering of the elements if no comparator was // * used // */ // void decreaseKey(K newKey); // // /** // * Delete the element from the heap that it belongs. // * // * @throws IllegalArgumentException // * in case this function is called twice on the same element // * or the element has already been deleted using // * {@link AddressableHeap#deleteMin()}. // */ // void delete(); // // } // // /** // * Returns the comparator used to order the keys in this AddressableHeap, or // * {@code null} if this heap uses the {@linkplain Comparable natural // * ordering} of its keys. // * // * @return the comparator used to order the keys in this heap, or // * {@code null} if this addressable heap uses the natural ordering // * of its keys // */ // Comparator<? super K> comparator(); // // /** // * Insert a new element into the heap. // * // * @param key // * the element's key // * @param value // * the element's value // * // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key, V value); // // /** // * Insert a new element into the heap with a null value. // * // * @param key // * the element's key // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key); // // /** // * Find an element with the minimum key. // * // * @return a handle to an element with minimum key // */ // AddressableHeap.Handle<K, V> findMin(); // // /** // * Delete and return an element with the minimum key. If multiple such // * elements exists, only one of them will be deleted. After the element is // * deleted the handle is invalidated and only method {@link Handle#getKey()} // * and {@link Handle#getValue()} can be used. // * // * @return a handle to the deleted element with minimum key // */ // AddressableHeap.Handle<K, V> deleteMin(); // // /** // * Returns {@code true} if this heap is empty. // * // * @return {@code true} if this heap is empty, {@code false} otherwise // */ // boolean isEmpty(); // // /** // * Returns the number of elements in the heap. // * // * @return the number of elements in the heap // */ // long size(); // // /** // * Clear all the elements of the heap. After calling this method all handles // * should be considered invalidated and the behavior of methods // * {@link Handle#decreaseKey(Object)} and {@link Handle#delete()} is // * undefined. // */ // void clear(); // // } // Path: src/main/java/org/jheaps/array/DaryArrayAddressableHeap.java import java.io.Serializable; import java.lang.reflect.Array; import java.util.Comparator; import java.util.Iterator; import java.util.NoSuchElementException; import org.jheaps.AddressableHeap; import org.jheaps.annotations.LinearTime; return new DaryArrayAddressableHeap<K, V>(d, comparator); } DaryArrayAddressableHeap<K, V> h = new DaryArrayAddressableHeap<K, V>(d, comparator, keys.length); for (int i = 0; i < keys.length; i++) { K key = keys[i]; V value = (values == null) ? null : values[i]; AbstractArrayAddressableHeap<K, V>.ArrayHandle ah = h.new ArrayHandle(key, value); ah.index = i + 1; h.array[i + 1] = ah; } h.size = keys.length; for (int i = keys.length / d; i > 0; i--) { h.fixdownWithComparator(i); } return h; } /** * Get an iterator for all handles currently in the heap. * * This method is especially useful when building a heap using the heapify * method. Unspecified behavior will occur if the heap is modified while * using this iterator. * * @return an iterator which will return all handles of the heap */
public Iterator<AddressableHeap.Handle<K, V>> handlesIterator() {
d-michail/jheaps
src/test/java/org/jheaps/tree/D2DaryTreeAddressableHeapTest.java
// Path: src/main/java/org/jheaps/AddressableHeap.java // public interface AddressableHeap<K, V> { // // /** // * A heap element handle. Allows someone to address an element already in a // * heap and perform additional operations. // * // * @param <K> // * the type of keys maintained by this heap // * @param <V> // * the type of values maintained by this heap // */ // interface Handle<K, V> { // // /** // * Return the key of the element. // * // * @return the key of the element // */ // K getKey(); // // /** // * Return the value of the element. // * // * @return the value of the element // */ // V getValue(); // // /** // * Set the value of the element. // * // * @param value // * the new value // */ // void setValue(V value); // // /** // * Decrease the key of the element. // * // * @param newKey // * the new key // * @throws IllegalArgumentException // * if the new key is larger than the old key according to // * the comparator used when constructing the heap or the // * natural ordering of the elements if no comparator was // * used // */ // void decreaseKey(K newKey); // // /** // * Delete the element from the heap that it belongs. // * // * @throws IllegalArgumentException // * in case this function is called twice on the same element // * or the element has already been deleted using // * {@link AddressableHeap#deleteMin()}. // */ // void delete(); // // } // // /** // * Returns the comparator used to order the keys in this AddressableHeap, or // * {@code null} if this heap uses the {@linkplain Comparable natural // * ordering} of its keys. // * // * @return the comparator used to order the keys in this heap, or // * {@code null} if this addressable heap uses the natural ordering // * of its keys // */ // Comparator<? super K> comparator(); // // /** // * Insert a new element into the heap. // * // * @param key // * the element's key // * @param value // * the element's value // * // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key, V value); // // /** // * Insert a new element into the heap with a null value. // * // * @param key // * the element's key // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key); // // /** // * Find an element with the minimum key. // * // * @return a handle to an element with minimum key // */ // AddressableHeap.Handle<K, V> findMin(); // // /** // * Delete and return an element with the minimum key. If multiple such // * elements exists, only one of them will be deleted. After the element is // * deleted the handle is invalidated and only method {@link Handle#getKey()} // * and {@link Handle#getValue()} can be used. // * // * @return a handle to the deleted element with minimum key // */ // AddressableHeap.Handle<K, V> deleteMin(); // // /** // * Returns {@code true} if this heap is empty. // * // * @return {@code true} if this heap is empty, {@code false} otherwise // */ // boolean isEmpty(); // // /** // * Returns the number of elements in the heap. // * // * @return the number of elements in the heap // */ // long size(); // // /** // * Clear all the elements of the heap. After calling this method all handles // * should be considered invalidated and the behavior of methods // * {@link Handle#decreaseKey(Object)} and {@link Handle#delete()} is // * undefined. // */ // void clear(); // // }
import java.util.Comparator; import org.jheaps.AddressableHeap;
/* * (C) Copyright 2014-2019, by Dimitrios Michail * * JHeaps Library * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jheaps.tree; public class D2DaryTreeAddressableHeapTest extends AbstractAddressableHeapTest { @Override
// Path: src/main/java/org/jheaps/AddressableHeap.java // public interface AddressableHeap<K, V> { // // /** // * A heap element handle. Allows someone to address an element already in a // * heap and perform additional operations. // * // * @param <K> // * the type of keys maintained by this heap // * @param <V> // * the type of values maintained by this heap // */ // interface Handle<K, V> { // // /** // * Return the key of the element. // * // * @return the key of the element // */ // K getKey(); // // /** // * Return the value of the element. // * // * @return the value of the element // */ // V getValue(); // // /** // * Set the value of the element. // * // * @param value // * the new value // */ // void setValue(V value); // // /** // * Decrease the key of the element. // * // * @param newKey // * the new key // * @throws IllegalArgumentException // * if the new key is larger than the old key according to // * the comparator used when constructing the heap or the // * natural ordering of the elements if no comparator was // * used // */ // void decreaseKey(K newKey); // // /** // * Delete the element from the heap that it belongs. // * // * @throws IllegalArgumentException // * in case this function is called twice on the same element // * or the element has already been deleted using // * {@link AddressableHeap#deleteMin()}. // */ // void delete(); // // } // // /** // * Returns the comparator used to order the keys in this AddressableHeap, or // * {@code null} if this heap uses the {@linkplain Comparable natural // * ordering} of its keys. // * // * @return the comparator used to order the keys in this heap, or // * {@code null} if this addressable heap uses the natural ordering // * of its keys // */ // Comparator<? super K> comparator(); // // /** // * Insert a new element into the heap. // * // * @param key // * the element's key // * @param value // * the element's value // * // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key, V value); // // /** // * Insert a new element into the heap with a null value. // * // * @param key // * the element's key // * @return a handle for the newly added element // */ // AddressableHeap.Handle<K, V> insert(K key); // // /** // * Find an element with the minimum key. // * // * @return a handle to an element with minimum key // */ // AddressableHeap.Handle<K, V> findMin(); // // /** // * Delete and return an element with the minimum key. If multiple such // * elements exists, only one of them will be deleted. After the element is // * deleted the handle is invalidated and only method {@link Handle#getKey()} // * and {@link Handle#getValue()} can be used. // * // * @return a handle to the deleted element with minimum key // */ // AddressableHeap.Handle<K, V> deleteMin(); // // /** // * Returns {@code true} if this heap is empty. // * // * @return {@code true} if this heap is empty, {@code false} otherwise // */ // boolean isEmpty(); // // /** // * Returns the number of elements in the heap. // * // * @return the number of elements in the heap // */ // long size(); // // /** // * Clear all the elements of the heap. After calling this method all handles // * should be considered invalidated and the behavior of methods // * {@link Handle#decreaseKey(Object)} and {@link Handle#delete()} is // * undefined. // */ // void clear(); // // } // Path: src/test/java/org/jheaps/tree/D2DaryTreeAddressableHeapTest.java import java.util.Comparator; import org.jheaps.AddressableHeap; /* * (C) Copyright 2014-2019, by Dimitrios Michail * * JHeaps Library * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jheaps.tree; public class D2DaryTreeAddressableHeapTest extends AbstractAddressableHeapTest { @Override
protected AddressableHeap<Integer, Void> createHeap() {