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
edannenberg/maven-magento-plugin
src/main/java/de/bbe_consulting/mavento/helper/DiffUtil.java
// Path: src/main/java/de/bbe_consulting/mavento/type/DiffPatch.java // public class DiffPatch { // // private String targetDirectory; // private String targetFileName = ""; // private String patchFileName; // private List<String> diffContent; // private String statsLine = ""; // // public DiffPatch(String fileName, String targetDir, List<String> patch) { // targetDirectory = targetDir; // patchFileName = fileName; // diffContent = patch; // } // // public String getTargetDirectory() { // return targetDirectory; // } // // public void setTargetDirectory(String targetDirectory) { // this.targetDirectory = targetDirectory; // } // // public String getPatchFileName() { // return patchFileName; // } // // public void setPatchFileName(String patchFileName) { // this.patchFileName = patchFileName; // } // // public List<String> getDiffContent() { // return diffContent; // } // // public void setDiffContent(List<String> diffContent) { // this.diffContent = diffContent; // } // // public String getTargetFileName() { // if (targetFileName.isEmpty()) { // targetFileName = Paths.get(targetDirectory).resolve(Paths.get(patchFileName)).toString(); // } // return targetFileName; // } // // public String getStatsLine() { // if (statsLine.isEmpty()) { // final Iterator<String> patchContent = diffContent.iterator(); // String currentLine = ""; // int addCount = 0; // int delCount = 0; // int blockCount = 0; // while (patchContent.hasNext()) { // currentLine = patchContent.next(); // if (currentLine.startsWith("@@")) { // ++blockCount; // } else if (currentLine.startsWith("- ")) { // ++delCount; // } else if (currentLine.startsWith("+ ")) { // ++addCount; // } // } // statsLine = "[@" + blockCount + "/+" + addCount + "/-" + delCount + "]"; // } // return statsLine; // } // // }
import java.io.IOException; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import de.bbe_consulting.mavento.type.DiffPatch; import difflib.DiffUtils; import difflib.Patch; import difflib.PatchFailedException;
/** * Copyright 2011-2013 BBe Consulting GmbH * * 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 de.bbe_consulting.mavento.helper; /** * Static diff helpers. * * @author Erik Dannenberg */ public class DiffUtil { /** * Private constructor, only static methods in this util class */ private DiffUtil() { } /** * Apply diff style patchFile to targetPath. dryRun will not write any changes to disk. * * @param patchFile * @param targetPath * @param dryRun * @param silent * @param logger * @throws IOException * @throws MojoExecutionException * @throws PatchFailedException */ public static void patchDirectory (String patchFile, String targetPath, boolean dryRun, boolean silent, Log logger) throws IOException, MojoExecutionException, PatchFailedException {
// Path: src/main/java/de/bbe_consulting/mavento/type/DiffPatch.java // public class DiffPatch { // // private String targetDirectory; // private String targetFileName = ""; // private String patchFileName; // private List<String> diffContent; // private String statsLine = ""; // // public DiffPatch(String fileName, String targetDir, List<String> patch) { // targetDirectory = targetDir; // patchFileName = fileName; // diffContent = patch; // } // // public String getTargetDirectory() { // return targetDirectory; // } // // public void setTargetDirectory(String targetDirectory) { // this.targetDirectory = targetDirectory; // } // // public String getPatchFileName() { // return patchFileName; // } // // public void setPatchFileName(String patchFileName) { // this.patchFileName = patchFileName; // } // // public List<String> getDiffContent() { // return diffContent; // } // // public void setDiffContent(List<String> diffContent) { // this.diffContent = diffContent; // } // // public String getTargetFileName() { // if (targetFileName.isEmpty()) { // targetFileName = Paths.get(targetDirectory).resolve(Paths.get(patchFileName)).toString(); // } // return targetFileName; // } // // public String getStatsLine() { // if (statsLine.isEmpty()) { // final Iterator<String> patchContent = diffContent.iterator(); // String currentLine = ""; // int addCount = 0; // int delCount = 0; // int blockCount = 0; // while (patchContent.hasNext()) { // currentLine = patchContent.next(); // if (currentLine.startsWith("@@")) { // ++blockCount; // } else if (currentLine.startsWith("- ")) { // ++delCount; // } else if (currentLine.startsWith("+ ")) { // ++addCount; // } // } // statsLine = "[@" + blockCount + "/+" + addCount + "/-" + delCount + "]"; // } // return statsLine; // } // // } // Path: src/main/java/de/bbe_consulting/mavento/helper/DiffUtil.java import java.io.IOException; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import de.bbe_consulting.mavento.type.DiffPatch; import difflib.DiffUtils; import difflib.Patch; import difflib.PatchFailedException; /** * Copyright 2011-2013 BBe Consulting GmbH * * 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 de.bbe_consulting.mavento.helper; /** * Static diff helpers. * * @author Erik Dannenberg */ public class DiffUtil { /** * Private constructor, only static methods in this util class */ private DiffUtil() { } /** * Apply diff style patchFile to targetPath. dryRun will not write any changes to disk. * * @param patchFile * @param targetPath * @param dryRun * @param silent * @param logger * @throws IOException * @throws MojoExecutionException * @throws PatchFailedException */ public static void patchDirectory (String patchFile, String targetPath, boolean dryRun, boolean silent, Log logger) throws IOException, MojoExecutionException, PatchFailedException {
final List<DiffPatch> filteredPatchList = splitPatch(FileUtil.getFileAsLines(patchFile), targetPath);
edannenberg/maven-magento-plugin
src/main/java/de/bbe_consulting/mavento/helper/MagentoUtil.java
// Path: src/main/java/de/bbe_consulting/mavento/type/MagentoVersion.java // public class MagentoVersion { // // private Integer magentoVersionMajor; // private Integer magentoVersionMinor; // private Integer magentoVersionRevision; // private Integer magentoVersionPatch; // private String magentoVersionStability = ""; // private Integer magentoVersionNumber = 0; // // public MagentoVersion(String magentoVersion) throws Exception { // final Pattern pattern = Pattern.compile("([0-9]+).([0-9]+).([0-9]+).([0-9]+)-?([a-zA-Z]+)?([0-9]+)?"); // final Matcher matcher = pattern.matcher(magentoVersion); // if (matcher.find()) { // magentoVersionMajor = Integer.parseInt(matcher.group(1)); // magentoVersionMinor = Integer.parseInt(matcher.group(2)); // magentoVersionRevision = Integer.parseInt(matcher.group(3)); // magentoVersionPatch = Integer.parseInt(matcher.group(4)); // if (matcher.group(5) != null) { // magentoVersionStability = matcher.group(5); // } // if (matcher.group(6) != null) { // magentoVersionNumber = Integer.parseInt(matcher.group(6)); // } // } else { // throw new Exception("Could not parse Magento version. Check your pom.xml"); // } // } // // public int getMajorVersion() { // return magentoVersionMajor; // } // // public int getMinorVersion() { // return magentoVersionMinor; // } // // public int getRevisionVersion() { // return magentoVersionRevision; // } // // public int getPatchVersion() { // return magentoVersionPatch; // } // // public String getStabilityVersion() { // return magentoVersionStability; // } // // public int getNumberVersion() { // return magentoVersionNumber; // } // // public String toString() { // String v = magentoVersionMajor + "." + magentoVersionMinor + "." // + magentoVersionRevision + "." + magentoVersionPatch; // if (!magentoVersionStability.equals("")) { // v += "-" + magentoVersionStability; // } // if (magentoVersionNumber != 0) { // v += magentoVersionNumber; // } // return v; // } // // }
import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.codehaus.plexus.util.cli.CommandLineException; import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; import org.codehaus.plexus.util.cli.WriterStreamConsumer; import org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer; import de.bbe_consulting.mavento.type.MagentoVersion;
final Path base = Paths.get(baseDirName); final HashMap<String, String> r = new HashMap<String, String>(); if (Files.isDirectory(base)) { DirectoryStream<Path> files = null; try { files = Files.newDirectoryStream(base); for (Path path : files) { if (!path.toString().contains(".svn")) { r.put(path.toAbsolutePath().toString(), targetBaseDir + "/" + path.getFileName()); } } } finally { files.close(); } } return r; } /** * Execute a pear command. * * @param executable * @param arguments * @param targetDir * @param magentoVersion * @param logger * @throws MojoExecutionException */ public static void executePearCommand(String executable,
// Path: src/main/java/de/bbe_consulting/mavento/type/MagentoVersion.java // public class MagentoVersion { // // private Integer magentoVersionMajor; // private Integer magentoVersionMinor; // private Integer magentoVersionRevision; // private Integer magentoVersionPatch; // private String magentoVersionStability = ""; // private Integer magentoVersionNumber = 0; // // public MagentoVersion(String magentoVersion) throws Exception { // final Pattern pattern = Pattern.compile("([0-9]+).([0-9]+).([0-9]+).([0-9]+)-?([a-zA-Z]+)?([0-9]+)?"); // final Matcher matcher = pattern.matcher(magentoVersion); // if (matcher.find()) { // magentoVersionMajor = Integer.parseInt(matcher.group(1)); // magentoVersionMinor = Integer.parseInt(matcher.group(2)); // magentoVersionRevision = Integer.parseInt(matcher.group(3)); // magentoVersionPatch = Integer.parseInt(matcher.group(4)); // if (matcher.group(5) != null) { // magentoVersionStability = matcher.group(5); // } // if (matcher.group(6) != null) { // magentoVersionNumber = Integer.parseInt(matcher.group(6)); // } // } else { // throw new Exception("Could not parse Magento version. Check your pom.xml"); // } // } // // public int getMajorVersion() { // return magentoVersionMajor; // } // // public int getMinorVersion() { // return magentoVersionMinor; // } // // public int getRevisionVersion() { // return magentoVersionRevision; // } // // public int getPatchVersion() { // return magentoVersionPatch; // } // // public String getStabilityVersion() { // return magentoVersionStability; // } // // public int getNumberVersion() { // return magentoVersionNumber; // } // // public String toString() { // String v = magentoVersionMajor + "." + magentoVersionMinor + "." // + magentoVersionRevision + "." + magentoVersionPatch; // if (!magentoVersionStability.equals("")) { // v += "-" + magentoVersionStability; // } // if (magentoVersionNumber != 0) { // v += magentoVersionNumber; // } // return v; // } // // } // Path: src/main/java/de/bbe_consulting/mavento/helper/MagentoUtil.java import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.codehaus.plexus.util.cli.CommandLineException; import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; import org.codehaus.plexus.util.cli.WriterStreamConsumer; import org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer; import de.bbe_consulting.mavento.type.MagentoVersion; final Path base = Paths.get(baseDirName); final HashMap<String, String> r = new HashMap<String, String>(); if (Files.isDirectory(base)) { DirectoryStream<Path> files = null; try { files = Files.newDirectoryStream(base); for (Path path : files) { if (!path.toString().contains(".svn")) { r.put(path.toAbsolutePath().toString(), targetBaseDir + "/" + path.getFileName()); } } } finally { files.close(); } } return r; } /** * Execute a pear command. * * @param executable * @param arguments * @param targetDir * @param magentoVersion * @param logger * @throws MojoExecutionException */ public static void executePearCommand(String executable,
String[] arguments, String targetDir, MagentoVersion magentoVersion, Log logger)
blinskey/greek-reference
GreekReference/src/main/java/com/benlinskey/greekreference/GreekTextView.java
// Path: GreekReference/src/main/java/com/benlinskey/greekreference/TextSize.java // enum TextSize { // SMALL("Small", 14), // MEDIUM("Medium", 18), // LARGE("Large", 22); // // private final String mName; // Size name stored in preference array // private final float mSize; // Text size in scaled pixels // // /** // * Enum type constructor. // * @param name the name of the size defined in the preferences array // * @param size the text size in scaled pixels // */ // TextSize(String name, float size) { // mName = name; // mSize = size; // } // // /** // * Returns the text size in scaled pixels for the specified size. // * @param name the name of the size defined in the preferences array // * @return the corresponding text size in scaled pixels // */ // public static float getScaledPixelSize(String name) { // for (TextSize tx : TextSize.values()) { // if (name.equals(tx.mName)) { // return tx.mSize; // } // } // throw new IllegalArgumentException("Invalid text size name."); // } // }
import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Paint; import android.graphics.Typeface; import android.os.Build; import android.preference.PreferenceManager; import android.support.v4.util.LruCache; import android.text.TextUtils; import android.util.AttributeSet; import android.widget.TextView; import com.benlinskey.greekreference.R; import com.benlinskey.greekreference.TextSize;
} setTypeface(typeface); // Note: This flag is required for proper typeface rendering setPaintFlags(getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG); } } /** * Sets the text color to the value defined in {@link #TEXT_COLOR}. */ private void setTextColor() { int textColor = getResources().getColor(TEXT_COLOR); setTextColor(textColor); } /** * Sets the {@code GreekTextView}'s text size to the size stored in the preferences. This method * will have no effect if {@link #mAllowTextSizeChanges} is set to false. * @param context the {@link Context} to use */ private void setTextSize(Context context) { if (!mAllowTextSizeChanges) { return; } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String textSizeKey = context.getString(R.string.pref_textSize_key); String defaultSize = context.getString(R.string.pref_textSize_item_medium); String textSize = prefs.getString(textSizeKey, defaultSize);
// Path: GreekReference/src/main/java/com/benlinskey/greekreference/TextSize.java // enum TextSize { // SMALL("Small", 14), // MEDIUM("Medium", 18), // LARGE("Large", 22); // // private final String mName; // Size name stored in preference array // private final float mSize; // Text size in scaled pixels // // /** // * Enum type constructor. // * @param name the name of the size defined in the preferences array // * @param size the text size in scaled pixels // */ // TextSize(String name, float size) { // mName = name; // mSize = size; // } // // /** // * Returns the text size in scaled pixels for the specified size. // * @param name the name of the size defined in the preferences array // * @return the corresponding text size in scaled pixels // */ // public static float getScaledPixelSize(String name) { // for (TextSize tx : TextSize.values()) { // if (name.equals(tx.mName)) { // return tx.mSize; // } // } // throw new IllegalArgumentException("Invalid text size name."); // } // } // Path: GreekReference/src/main/java/com/benlinskey/greekreference/GreekTextView.java import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Paint; import android.graphics.Typeface; import android.os.Build; import android.preference.PreferenceManager; import android.support.v4.util.LruCache; import android.text.TextUtils; import android.util.AttributeSet; import android.widget.TextView; import com.benlinskey.greekreference.R; import com.benlinskey.greekreference.TextSize; } setTypeface(typeface); // Note: This flag is required for proper typeface rendering setPaintFlags(getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG); } } /** * Sets the text color to the value defined in {@link #TEXT_COLOR}. */ private void setTextColor() { int textColor = getResources().getColor(TEXT_COLOR); setTextColor(textColor); } /** * Sets the {@code GreekTextView}'s text size to the size stored in the preferences. This method * will have no effect if {@link #mAllowTextSizeChanges} is set to false. * @param context the {@link Context} to use */ private void setTextSize(Context context) { if (!mAllowTextSizeChanges) { return; } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String textSizeKey = context.getString(R.string.pref_textSize_key); String defaultSize = context.getString(R.string.pref_textSize_item_medium); String textSize = prefs.getString(textSizeKey, defaultSize);
float sp = TextSize.getScaledPixelSize(textSize);
blinskey/greek-reference
GreekReference/src/main/java/com/benlinskey/greekreference/views/list/syntax/SyntaxBrowseListFragment.java
// Path: GreekReference/src/main/java/com/benlinskey/greekreference/data/syntax/SyntaxContract.java // public final class SyntaxContract implements BaseColumns { // // TODO: Move content URI to this class. // // public static final Uri CONTENT_URI = SyntaxProvider.CONTENT_URI; // public static final String DB_NAME = "syntax"; // public static final String TABLE_NAME = "syntax"; // public static final String COLUMN_NAME_CHAPTER = "chapter"; // public static final String COLUMN_NAME_SECTION = "section"; // public static final String COLUMN_NAME_XML = "xml"; // // /** // * Empty private construtor to prevent instantiation. // */ // private SyntaxContract() {} // }
import android.app.Activity; import android.app.LoaderManager; import android.content.CursorLoader; import android.content.Loader; import android.database.Cursor; import android.os.Bundle; import android.view.View; import android.widget.ListView; import android.widget.SimpleCursorAdapter; import com.benlinskey.greekreference.data.syntax.SyntaxContract;
/* * Copyright 2014 Benjamin Linskey * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.benlinskey.greekreference.views.list.syntax; /** * A {@link AbstractSyntaxListFragment} used to display a list of all sections in the Overview of Greek * Syntax text. */ public class SyntaxBrowseListFragment extends AbstractSyntaxListFragment implements LoaderManager.LoaderCallbacks<Cursor> { public static final String NAME = "syntax_browse"; private SimpleCursorAdapter mAdapter; private static final String[] PROJECTION = new String[] {
// Path: GreekReference/src/main/java/com/benlinskey/greekreference/data/syntax/SyntaxContract.java // public final class SyntaxContract implements BaseColumns { // // TODO: Move content URI to this class. // // public static final Uri CONTENT_URI = SyntaxProvider.CONTENT_URI; // public static final String DB_NAME = "syntax"; // public static final String TABLE_NAME = "syntax"; // public static final String COLUMN_NAME_CHAPTER = "chapter"; // public static final String COLUMN_NAME_SECTION = "section"; // public static final String COLUMN_NAME_XML = "xml"; // // /** // * Empty private construtor to prevent instantiation. // */ // private SyntaxContract() {} // } // Path: GreekReference/src/main/java/com/benlinskey/greekreference/views/list/syntax/SyntaxBrowseListFragment.java import android.app.Activity; import android.app.LoaderManager; import android.content.CursorLoader; import android.content.Loader; import android.database.Cursor; import android.os.Bundle; import android.view.View; import android.widget.ListView; import android.widget.SimpleCursorAdapter; import com.benlinskey.greekreference.data.syntax.SyntaxContract; /* * Copyright 2014 Benjamin Linskey * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.benlinskey.greekreference.views.list.syntax; /** * A {@link AbstractSyntaxListFragment} used to display a list of all sections in the Overview of Greek * Syntax text. */ public class SyntaxBrowseListFragment extends AbstractSyntaxListFragment implements LoaderManager.LoaderCallbacks<Cursor> { public static final String NAME = "syntax_browse"; private SimpleCursorAdapter mAdapter; private static final String[] PROJECTION = new String[] {
SyntaxContract._ID,
blinskey/greek-reference
GreekReference/src/main/java/com/benlinskey/greekreference/views/list/lexicon/LexiconBrowseListFragment.java
// Path: GreekReference/src/main/java/com/benlinskey/greekreference/data/lexicon/LexiconContract.java // public final class LexiconContract implements BaseColumns { // // TODO: Move content URI to this class. // // public static final String DB_NAME = "lexicon"; // public static final String TABLE_NAME = "lexicon"; // public static final String COLUMN_ENTRY = "entry"; // public static final String COLUMN_GREEK_NO_SYMBOLS = "greekNoSymbols"; // public static final String COLUMN_GREEK_LOWERCASE = "greekLowercase"; // public static final String COLUMN_BETA_SYMBOLS = "betaSymbols"; // public static final String COLUMN_BETA_NO_SYMBOLS = "betaNoSymbols"; // public static final String COLUMN_GREEK_FULL_WORD = "greekFullWord"; // public static final Uri CONTENT_URI = LexiconProvider.CONTENT_URI; // // /** // * Empty private constructor to prevent instantiation. // */ // private LexiconContract() {} // }
import android.app.Activity; import android.app.LoaderManager; import android.content.CursorLoader; import android.content.Loader; import android.database.Cursor; import android.os.Bundle; import android.view.View; import android.widget.ListView; import android.widget.SimpleCursorAdapter; import com.benlinskey.greekreference.R; import com.benlinskey.greekreference.data.lexicon.LexiconContract;
/* * Copyright 2014 Benjamin Linskey * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.benlinskey.greekreference.views.list.lexicon; /** * A {@link AbstractLexiconListFragment} used to display a list of all words in the * lexicon. */ public class LexiconBrowseListFragment extends AbstractLexiconListFragment implements LoaderManager.LoaderCallbacks<Cursor> { public static final String NAME = "lexicon_browse"; private static final String TAG = "LexiconBrowseListFragment"; private static final String[] PROJECTION
// Path: GreekReference/src/main/java/com/benlinskey/greekreference/data/lexicon/LexiconContract.java // public final class LexiconContract implements BaseColumns { // // TODO: Move content URI to this class. // // public static final String DB_NAME = "lexicon"; // public static final String TABLE_NAME = "lexicon"; // public static final String COLUMN_ENTRY = "entry"; // public static final String COLUMN_GREEK_NO_SYMBOLS = "greekNoSymbols"; // public static final String COLUMN_GREEK_LOWERCASE = "greekLowercase"; // public static final String COLUMN_BETA_SYMBOLS = "betaSymbols"; // public static final String COLUMN_BETA_NO_SYMBOLS = "betaNoSymbols"; // public static final String COLUMN_GREEK_FULL_WORD = "greekFullWord"; // public static final Uri CONTENT_URI = LexiconProvider.CONTENT_URI; // // /** // * Empty private constructor to prevent instantiation. // */ // private LexiconContract() {} // } // Path: GreekReference/src/main/java/com/benlinskey/greekreference/views/list/lexicon/LexiconBrowseListFragment.java import android.app.Activity; import android.app.LoaderManager; import android.content.CursorLoader; import android.content.Loader; import android.database.Cursor; import android.os.Bundle; import android.view.View; import android.widget.ListView; import android.widget.SimpleCursorAdapter; import com.benlinskey.greekreference.R; import com.benlinskey.greekreference.data.lexicon.LexiconContract; /* * Copyright 2014 Benjamin Linskey * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.benlinskey.greekreference.views.list.lexicon; /** * A {@link AbstractLexiconListFragment} used to display a list of all words in the * lexicon. */ public class LexiconBrowseListFragment extends AbstractLexiconListFragment implements LoaderManager.LoaderCallbacks<Cursor> { public static final String NAME = "lexicon_browse"; private static final String TAG = "LexiconBrowseListFragment"; private static final String[] PROJECTION
= new String[] {LexiconContract._ID, LexiconContract.COLUMN_GREEK_FULL_WORD,
blinskey/greek-reference
GreekReference/src/main/java/com/benlinskey/greekreference/data/appdata/AppDataDbHelper.java
// Path: GreekReference/src/main/java/com/benlinskey/greekreference/data/lexicon/LexiconContract.java // public final class LexiconContract implements BaseColumns { // // TODO: Move content URI to this class. // // public static final String DB_NAME = "lexicon"; // public static final String TABLE_NAME = "lexicon"; // public static final String COLUMN_ENTRY = "entry"; // public static final String COLUMN_GREEK_NO_SYMBOLS = "greekNoSymbols"; // public static final String COLUMN_GREEK_LOWERCASE = "greekLowercase"; // public static final String COLUMN_BETA_SYMBOLS = "betaSymbols"; // public static final String COLUMN_BETA_NO_SYMBOLS = "betaNoSymbols"; // public static final String COLUMN_GREEK_FULL_WORD = "greekFullWord"; // public static final Uri CONTENT_URI = LexiconProvider.CONTENT_URI; // // /** // * Empty private constructor to prevent instantiation. // */ // private LexiconContract() {} // }
import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import com.benlinskey.greekreference.data.lexicon.LexiconContract;
* Class constructor. * @param context the {@code Context} to use */ public AppDataDbHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); mContext = context; } @Override public void onCreate(SQLiteDatabase db) { db.execSQL(SQL_CREATE_LEXICON_FAVORITES_TABLE); db.execSQL(SQL_CREATE_LEXICON_HISTORY_TABLE); db.execSQL(SQL_CREATE_SYNTAX_BOOKMARKS_TABLE); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // This method handles upgrades from versions 1 and 2 of the database to version 3. // Get a cursor containing the contents of the old Lexicon Favorites table. String table = AppDataContract.LexiconFavorites.TABLE_NAME; String[] columns = {AppDataContract.LexiconFavorites.COLUMN_NAME_WORD}; Cursor oldData = db.query(table, columns, null, null, null, null, null, null); // Drop and recreate the Lexicon Favorites table. db.execSQL(SQL_DELETE_LEXICON_FAVORITES_TABLE); db.execSQL(SQL_CREATE_LEXICON_FAVORITES_TABLE); // Repopulate the table. ContentResolver resolver = mContext.getContentResolver();
// Path: GreekReference/src/main/java/com/benlinskey/greekreference/data/lexicon/LexiconContract.java // public final class LexiconContract implements BaseColumns { // // TODO: Move content URI to this class. // // public static final String DB_NAME = "lexicon"; // public static final String TABLE_NAME = "lexicon"; // public static final String COLUMN_ENTRY = "entry"; // public static final String COLUMN_GREEK_NO_SYMBOLS = "greekNoSymbols"; // public static final String COLUMN_GREEK_LOWERCASE = "greekLowercase"; // public static final String COLUMN_BETA_SYMBOLS = "betaSymbols"; // public static final String COLUMN_BETA_NO_SYMBOLS = "betaNoSymbols"; // public static final String COLUMN_GREEK_FULL_WORD = "greekFullWord"; // public static final Uri CONTENT_URI = LexiconProvider.CONTENT_URI; // // /** // * Empty private constructor to prevent instantiation. // */ // private LexiconContract() {} // } // Path: GreekReference/src/main/java/com/benlinskey/greekreference/data/appdata/AppDataDbHelper.java import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import com.benlinskey.greekreference.data.lexicon.LexiconContract; * Class constructor. * @param context the {@code Context} to use */ public AppDataDbHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); mContext = context; } @Override public void onCreate(SQLiteDatabase db) { db.execSQL(SQL_CREATE_LEXICON_FAVORITES_TABLE); db.execSQL(SQL_CREATE_LEXICON_HISTORY_TABLE); db.execSQL(SQL_CREATE_SYNTAX_BOOKMARKS_TABLE); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // This method handles upgrades from versions 1 and 2 of the database to version 3. // Get a cursor containing the contents of the old Lexicon Favorites table. String table = AppDataContract.LexiconFavorites.TABLE_NAME; String[] columns = {AppDataContract.LexiconFavorites.COLUMN_NAME_WORD}; Cursor oldData = db.query(table, columns, null, null, null, null, null, null); // Drop and recreate the Lexicon Favorites table. db.execSQL(SQL_DELETE_LEXICON_FAVORITES_TABLE); db.execSQL(SQL_CREATE_LEXICON_FAVORITES_TABLE); // Repopulate the table. ContentResolver resolver = mContext.getContentResolver();
String[] projection = {LexiconContract._ID};
blinskey/greek-reference
GreekReference/src/main/java/com/benlinskey/greekreference/views/list/syntax/SyntaxBookmarksListFragment.java
// Path: GreekReference/src/main/java/com/benlinskey/greekreference/data/appdata/AppDataContract.java // public final class AppDataContract { // // /** // * Empty private constructor to prevent instantiation. // */ // private AppDataContract() {} // // /** // * A contract class for the lexicon history table. // */ // public static abstract class LexiconHistory implements BaseColumns { // public static final String TABLE_NAME = "lexicon_history"; // public static final String COLUMN_NAME_LEXICON_ID = "lexiconID"; // public static final String COLUMN_NAME_WORD = "word"; // public static final Uri CONTENT_URI = LexiconHistoryProvider.CONTENT_URI; // } // // /** // * A contract class for the lexicon favorites table. // */ // public static abstract class LexiconFavorites implements BaseColumns { // public static final String TABLE_NAME = "lexicon_favorites"; // public static final String COLUMN_NAME_LEXICON_ID = "lexiconID"; // public static final String COLUMN_NAME_WORD = "word"; // public static final Uri CONTENT_URI = LexiconFavoritesProvider.CONTENT_URI; // } // // /** // * A contract class for the syntax bookmarks table. // */ // public static abstract class SyntaxBookmarks implements BaseColumns { // public static final String TABLE_NAME = "syntax_bookmarks"; // public static final String COLUMN_NAME_SYNTAX_ID = "syntax_id"; // public static final String COLUMN_NAME_SYNTAX_SECTION = "syntax_section"; // public static final Uri CONTENT_URI = SyntaxBookmarksProvider.CONTENT_URI; // } // }
import android.app.Activity; import android.app.LoaderManager; import android.content.ContentResolver; import android.content.CursorLoader; import android.content.Loader; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.widget.ListView; import android.widget.SimpleCursorAdapter; import com.benlinskey.greekreference.R; import com.benlinskey.greekreference.data.appdata.AppDataContract;
/* * Copyright 2014 Benjamin Linskey * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.benlinskey.greekreference.views.list.syntax; /** * A {@link AbstractSyntaxListFragment} used to display a list of all words stored in the syntax bookmarks * list. */ public class SyntaxBookmarksListFragment extends AbstractSyntaxListFragment implements LoaderManager.LoaderCallbacks<Cursor> { public static final String NAME = "syntax_bookmarks"; private static final String[] PROJECTION = new String[] {
// Path: GreekReference/src/main/java/com/benlinskey/greekreference/data/appdata/AppDataContract.java // public final class AppDataContract { // // /** // * Empty private constructor to prevent instantiation. // */ // private AppDataContract() {} // // /** // * A contract class for the lexicon history table. // */ // public static abstract class LexiconHistory implements BaseColumns { // public static final String TABLE_NAME = "lexicon_history"; // public static final String COLUMN_NAME_LEXICON_ID = "lexiconID"; // public static final String COLUMN_NAME_WORD = "word"; // public static final Uri CONTENT_URI = LexiconHistoryProvider.CONTENT_URI; // } // // /** // * A contract class for the lexicon favorites table. // */ // public static abstract class LexiconFavorites implements BaseColumns { // public static final String TABLE_NAME = "lexicon_favorites"; // public static final String COLUMN_NAME_LEXICON_ID = "lexiconID"; // public static final String COLUMN_NAME_WORD = "word"; // public static final Uri CONTENT_URI = LexiconFavoritesProvider.CONTENT_URI; // } // // /** // * A contract class for the syntax bookmarks table. // */ // public static abstract class SyntaxBookmarks implements BaseColumns { // public static final String TABLE_NAME = "syntax_bookmarks"; // public static final String COLUMN_NAME_SYNTAX_ID = "syntax_id"; // public static final String COLUMN_NAME_SYNTAX_SECTION = "syntax_section"; // public static final Uri CONTENT_URI = SyntaxBookmarksProvider.CONTENT_URI; // } // } // Path: GreekReference/src/main/java/com/benlinskey/greekreference/views/list/syntax/SyntaxBookmarksListFragment.java import android.app.Activity; import android.app.LoaderManager; import android.content.ContentResolver; import android.content.CursorLoader; import android.content.Loader; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.widget.ListView; import android.widget.SimpleCursorAdapter; import com.benlinskey.greekreference.R; import com.benlinskey.greekreference.data.appdata.AppDataContract; /* * Copyright 2014 Benjamin Linskey * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.benlinskey.greekreference.views.list.syntax; /** * A {@link AbstractSyntaxListFragment} used to display a list of all words stored in the syntax bookmarks * list. */ public class SyntaxBookmarksListFragment extends AbstractSyntaxListFragment implements LoaderManager.LoaderCallbacks<Cursor> { public static final String NAME = "syntax_bookmarks"; private static final String[] PROJECTION = new String[] {
AppDataContract.SyntaxBookmarks._ID,
blinskey/greek-reference
GreekReference/src/main/java/com/benlinskey/greekreference/presenters/SyntaxPresenter.java
// Path: GreekReference/src/main/java/com/benlinskey/greekreference/data/appdata/AppDataContract.java // public final class AppDataContract { // // /** // * Empty private constructor to prevent instantiation. // */ // private AppDataContract() {} // // /** // * A contract class for the lexicon history table. // */ // public static abstract class LexiconHistory implements BaseColumns { // public static final String TABLE_NAME = "lexicon_history"; // public static final String COLUMN_NAME_LEXICON_ID = "lexiconID"; // public static final String COLUMN_NAME_WORD = "word"; // public static final Uri CONTENT_URI = LexiconHistoryProvider.CONTENT_URI; // } // // /** // * A contract class for the lexicon favorites table. // */ // public static abstract class LexiconFavorites implements BaseColumns { // public static final String TABLE_NAME = "lexicon_favorites"; // public static final String COLUMN_NAME_LEXICON_ID = "lexiconID"; // public static final String COLUMN_NAME_WORD = "word"; // public static final Uri CONTENT_URI = LexiconFavoritesProvider.CONTENT_URI; // } // // /** // * A contract class for the syntax bookmarks table. // */ // public static abstract class SyntaxBookmarks implements BaseColumns { // public static final String TABLE_NAME = "syntax_bookmarks"; // public static final String COLUMN_NAME_SYNTAX_ID = "syntax_id"; // public static final String COLUMN_NAME_SYNTAX_SECTION = "syntax_section"; // public static final Uri CONTENT_URI = SyntaxBookmarksProvider.CONTENT_URI; // } // } // // Path: GreekReference/src/main/java/com/benlinskey/greekreference/data/syntax/SyntaxContract.java // public final class SyntaxContract implements BaseColumns { // // TODO: Move content URI to this class. // // public static final Uri CONTENT_URI = SyntaxProvider.CONTENT_URI; // public static final String DB_NAME = "syntax"; // public static final String TABLE_NAME = "syntax"; // public static final String COLUMN_NAME_CHAPTER = "chapter"; // public static final String COLUMN_NAME_SECTION = "section"; // public static final String COLUMN_NAME_XML = "xml"; // // /** // * Empty private construtor to prevent instantiation. // */ // private SyntaxContract() {} // } // // Path: GreekReference/src/main/java/com/benlinskey/greekreference/views/detail/syntax/SyntaxDetailView.java // public interface SyntaxDetailView extends DetailView { // // int getSelectedSyntaxId(); // }
import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.view.Menu; import android.view.MenuItem; import android.widget.ListView; import com.benlinskey.greekreference.R; import com.benlinskey.greekreference.data.appdata.AppDataContract; import com.benlinskey.greekreference.data.syntax.SyntaxContract; import com.benlinskey.greekreference.views.detail.syntax.SyntaxDetailView;
} /** * Sets the Syntax Bookmark icon to the appropriate state based on the currently selected * syntax section. * @param menu the {@code Menu} containing the Bookmark icon */ private void setBookmarkIcon(Menu menu) { MenuItem addBookmark = menu.findItem(R.id.action_add_bookmark); MenuItem removeBookmark = menu.findItem(R.id.action_remove_bookmark); int id = mView.getSelectedSyntaxId(); if (!mView.isDetailFragmentVisible() || id == ListView.NO_ID) { addBookmark.setVisible(false); removeBookmark.setVisible(false); } else if (isBookmarked(id)) { addBookmark.setVisible(false); removeBookmark.setVisible(true); } else { addBookmark.setVisible(true); removeBookmark.setVisible(false); } } /** * Returns true if the word with the specified syntax ID is a member of the bookmarks list. * @param syntaxId the syntax ID to check * @return true if the specified word is a member of the bookmarks list, or false otherwise */ private boolean isBookmarked(int syntaxId) {
// Path: GreekReference/src/main/java/com/benlinskey/greekreference/data/appdata/AppDataContract.java // public final class AppDataContract { // // /** // * Empty private constructor to prevent instantiation. // */ // private AppDataContract() {} // // /** // * A contract class for the lexicon history table. // */ // public static abstract class LexiconHistory implements BaseColumns { // public static final String TABLE_NAME = "lexicon_history"; // public static final String COLUMN_NAME_LEXICON_ID = "lexiconID"; // public static final String COLUMN_NAME_WORD = "word"; // public static final Uri CONTENT_URI = LexiconHistoryProvider.CONTENT_URI; // } // // /** // * A contract class for the lexicon favorites table. // */ // public static abstract class LexiconFavorites implements BaseColumns { // public static final String TABLE_NAME = "lexicon_favorites"; // public static final String COLUMN_NAME_LEXICON_ID = "lexiconID"; // public static final String COLUMN_NAME_WORD = "word"; // public static final Uri CONTENT_URI = LexiconFavoritesProvider.CONTENT_URI; // } // // /** // * A contract class for the syntax bookmarks table. // */ // public static abstract class SyntaxBookmarks implements BaseColumns { // public static final String TABLE_NAME = "syntax_bookmarks"; // public static final String COLUMN_NAME_SYNTAX_ID = "syntax_id"; // public static final String COLUMN_NAME_SYNTAX_SECTION = "syntax_section"; // public static final Uri CONTENT_URI = SyntaxBookmarksProvider.CONTENT_URI; // } // } // // Path: GreekReference/src/main/java/com/benlinskey/greekreference/data/syntax/SyntaxContract.java // public final class SyntaxContract implements BaseColumns { // // TODO: Move content URI to this class. // // public static final Uri CONTENT_URI = SyntaxProvider.CONTENT_URI; // public static final String DB_NAME = "syntax"; // public static final String TABLE_NAME = "syntax"; // public static final String COLUMN_NAME_CHAPTER = "chapter"; // public static final String COLUMN_NAME_SECTION = "section"; // public static final String COLUMN_NAME_XML = "xml"; // // /** // * Empty private construtor to prevent instantiation. // */ // private SyntaxContract() {} // } // // Path: GreekReference/src/main/java/com/benlinskey/greekreference/views/detail/syntax/SyntaxDetailView.java // public interface SyntaxDetailView extends DetailView { // // int getSelectedSyntaxId(); // } // Path: GreekReference/src/main/java/com/benlinskey/greekreference/presenters/SyntaxPresenter.java import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.view.Menu; import android.view.MenuItem; import android.widget.ListView; import com.benlinskey.greekreference.R; import com.benlinskey.greekreference.data.appdata.AppDataContract; import com.benlinskey.greekreference.data.syntax.SyntaxContract; import com.benlinskey.greekreference.views.detail.syntax.SyntaxDetailView; } /** * Sets the Syntax Bookmark icon to the appropriate state based on the currently selected * syntax section. * @param menu the {@code Menu} containing the Bookmark icon */ private void setBookmarkIcon(Menu menu) { MenuItem addBookmark = menu.findItem(R.id.action_add_bookmark); MenuItem removeBookmark = menu.findItem(R.id.action_remove_bookmark); int id = mView.getSelectedSyntaxId(); if (!mView.isDetailFragmentVisible() || id == ListView.NO_ID) { addBookmark.setVisible(false); removeBookmark.setVisible(false); } else if (isBookmarked(id)) { addBookmark.setVisible(false); removeBookmark.setVisible(true); } else { addBookmark.setVisible(true); removeBookmark.setVisible(false); } } /** * Returns true if the word with the specified syntax ID is a member of the bookmarks list. * @param syntaxId the syntax ID to check * @return true if the specified word is a member of the bookmarks list, or false otherwise */ private boolean isBookmarked(int syntaxId) {
String[] columns = new String[] {AppDataContract.SyntaxBookmarks._ID};
blinskey/greek-reference
GreekReference/src/main/java/com/benlinskey/greekreference/presenters/SyntaxPresenter.java
// Path: GreekReference/src/main/java/com/benlinskey/greekreference/data/appdata/AppDataContract.java // public final class AppDataContract { // // /** // * Empty private constructor to prevent instantiation. // */ // private AppDataContract() {} // // /** // * A contract class for the lexicon history table. // */ // public static abstract class LexiconHistory implements BaseColumns { // public static final String TABLE_NAME = "lexicon_history"; // public static final String COLUMN_NAME_LEXICON_ID = "lexiconID"; // public static final String COLUMN_NAME_WORD = "word"; // public static final Uri CONTENT_URI = LexiconHistoryProvider.CONTENT_URI; // } // // /** // * A contract class for the lexicon favorites table. // */ // public static abstract class LexiconFavorites implements BaseColumns { // public static final String TABLE_NAME = "lexicon_favorites"; // public static final String COLUMN_NAME_LEXICON_ID = "lexiconID"; // public static final String COLUMN_NAME_WORD = "word"; // public static final Uri CONTENT_URI = LexiconFavoritesProvider.CONTENT_URI; // } // // /** // * A contract class for the syntax bookmarks table. // */ // public static abstract class SyntaxBookmarks implements BaseColumns { // public static final String TABLE_NAME = "syntax_bookmarks"; // public static final String COLUMN_NAME_SYNTAX_ID = "syntax_id"; // public static final String COLUMN_NAME_SYNTAX_SECTION = "syntax_section"; // public static final Uri CONTENT_URI = SyntaxBookmarksProvider.CONTENT_URI; // } // } // // Path: GreekReference/src/main/java/com/benlinskey/greekreference/data/syntax/SyntaxContract.java // public final class SyntaxContract implements BaseColumns { // // TODO: Move content URI to this class. // // public static final Uri CONTENT_URI = SyntaxProvider.CONTENT_URI; // public static final String DB_NAME = "syntax"; // public static final String TABLE_NAME = "syntax"; // public static final String COLUMN_NAME_CHAPTER = "chapter"; // public static final String COLUMN_NAME_SECTION = "section"; // public static final String COLUMN_NAME_XML = "xml"; // // /** // * Empty private construtor to prevent instantiation. // */ // private SyntaxContract() {} // } // // Path: GreekReference/src/main/java/com/benlinskey/greekreference/views/detail/syntax/SyntaxDetailView.java // public interface SyntaxDetailView extends DetailView { // // int getSelectedSyntaxId(); // }
import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.view.Menu; import android.view.MenuItem; import android.widget.ListView; import com.benlinskey.greekreference.R; import com.benlinskey.greekreference.data.appdata.AppDataContract; import com.benlinskey.greekreference.data.syntax.SyntaxContract; import com.benlinskey.greekreference.views.detail.syntax.SyntaxDetailView;
String msg = mContext.getString(R.string.toast_bookmark_added); mView.displayToast(msg); } public void onRemoveBookmark() { int id = mView.getSelectedSyntaxId(); String selection = AppDataContract.SyntaxBookmarks.COLUMN_NAME_SYNTAX_ID + " = ?"; String[] selectionArgs = {Integer.toString(id)}; mResolver.delete(AppDataContract.SyntaxBookmarks.CONTENT_URI, selection, selectionArgs); mView.invalidateOptionsMenu(); String msg = mContext.getString(R.string.toast_bookmark_removed); mView.displayToast(msg); } public void onClearBookmarks() { mResolver.delete(AppDataContract.SyntaxBookmarks.CONTENT_URI, null, null); String msg = mContext.getString(R.string.toast_clear_syntax_bookmarks); mView.displayToast(msg); } /** * Returns the section title corresponding to the specified syntax ID. * @param id the syntax ID for which to search * @return the corresponding section title */ private String getSectionFromId(int id) {
// Path: GreekReference/src/main/java/com/benlinskey/greekreference/data/appdata/AppDataContract.java // public final class AppDataContract { // // /** // * Empty private constructor to prevent instantiation. // */ // private AppDataContract() {} // // /** // * A contract class for the lexicon history table. // */ // public static abstract class LexiconHistory implements BaseColumns { // public static final String TABLE_NAME = "lexicon_history"; // public static final String COLUMN_NAME_LEXICON_ID = "lexiconID"; // public static final String COLUMN_NAME_WORD = "word"; // public static final Uri CONTENT_URI = LexiconHistoryProvider.CONTENT_URI; // } // // /** // * A contract class for the lexicon favorites table. // */ // public static abstract class LexiconFavorites implements BaseColumns { // public static final String TABLE_NAME = "lexicon_favorites"; // public static final String COLUMN_NAME_LEXICON_ID = "lexiconID"; // public static final String COLUMN_NAME_WORD = "word"; // public static final Uri CONTENT_URI = LexiconFavoritesProvider.CONTENT_URI; // } // // /** // * A contract class for the syntax bookmarks table. // */ // public static abstract class SyntaxBookmarks implements BaseColumns { // public static final String TABLE_NAME = "syntax_bookmarks"; // public static final String COLUMN_NAME_SYNTAX_ID = "syntax_id"; // public static final String COLUMN_NAME_SYNTAX_SECTION = "syntax_section"; // public static final Uri CONTENT_URI = SyntaxBookmarksProvider.CONTENT_URI; // } // } // // Path: GreekReference/src/main/java/com/benlinskey/greekreference/data/syntax/SyntaxContract.java // public final class SyntaxContract implements BaseColumns { // // TODO: Move content URI to this class. // // public static final Uri CONTENT_URI = SyntaxProvider.CONTENT_URI; // public static final String DB_NAME = "syntax"; // public static final String TABLE_NAME = "syntax"; // public static final String COLUMN_NAME_CHAPTER = "chapter"; // public static final String COLUMN_NAME_SECTION = "section"; // public static final String COLUMN_NAME_XML = "xml"; // // /** // * Empty private construtor to prevent instantiation. // */ // private SyntaxContract() {} // } // // Path: GreekReference/src/main/java/com/benlinskey/greekreference/views/detail/syntax/SyntaxDetailView.java // public interface SyntaxDetailView extends DetailView { // // int getSelectedSyntaxId(); // } // Path: GreekReference/src/main/java/com/benlinskey/greekreference/presenters/SyntaxPresenter.java import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.view.Menu; import android.view.MenuItem; import android.widget.ListView; import com.benlinskey.greekreference.R; import com.benlinskey.greekreference.data.appdata.AppDataContract; import com.benlinskey.greekreference.data.syntax.SyntaxContract; import com.benlinskey.greekreference.views.detail.syntax.SyntaxDetailView; String msg = mContext.getString(R.string.toast_bookmark_added); mView.displayToast(msg); } public void onRemoveBookmark() { int id = mView.getSelectedSyntaxId(); String selection = AppDataContract.SyntaxBookmarks.COLUMN_NAME_SYNTAX_ID + " = ?"; String[] selectionArgs = {Integer.toString(id)}; mResolver.delete(AppDataContract.SyntaxBookmarks.CONTENT_URI, selection, selectionArgs); mView.invalidateOptionsMenu(); String msg = mContext.getString(R.string.toast_bookmark_removed); mView.displayToast(msg); } public void onClearBookmarks() { mResolver.delete(AppDataContract.SyntaxBookmarks.CONTENT_URI, null, null); String msg = mContext.getString(R.string.toast_clear_syntax_bookmarks); mView.displayToast(msg); } /** * Returns the section title corresponding to the specified syntax ID. * @param id the syntax ID for which to search * @return the corresponding section title */ private String getSectionFromId(int id) {
String[] projection = {SyntaxContract.COLUMN_NAME_SECTION};
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorEvent.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // }
import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent;
package es.rogermartinez.paddlemanager.base.view.errors; /** * Created by roger.martinez on 9/10/15. */ public interface ViewErrorEvent {
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorEvent.java import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent; package es.rogermartinez.paddlemanager.base.view.errors; /** * Created by roger.martinez on 9/10/15. */ public interface ViewErrorEvent {
void onError(ErrorEvent event);
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/BaseActivity.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorEvent.java // public interface ViewErrorEvent // { // void onError(ErrorEvent event); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorHandler.java // public class ViewErrorHandler { // // private Bus bus; // ViewErrorEvent errorEvent; // // // public ViewErrorHandler(Bus bus, ViewErrorEvent errorEvent) { // this.bus = bus; // this.errorEvent = errorEvent; // } // // public void register(){ // bus.register(this); // } // // public void unregister(){ // bus.unregister(this); // } // // @Subscribe // public void onErrorEvent(ErrorEvent event) { // errorEvent.onError(event); // } // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ActivityModule.java // @Module // public class ActivityModule { // private final Activity activity; // // public ActivityModule(Activity activity){ // this.activity = activity; // } // // @Provides // @PerActivity // Activity provideActivity(){ // return activity; // } // // @Provides // @PerActivity // DomainErrorHandler provideDomainErrorHandler(Bus bus) { // return new DomainErrorHandler(bus); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationComponent.java // @Singleton // @Component(modules = ApplicationModule.class) // public interface ApplicationComponent { // void inject(BaseActivity baseActivity); // // // Exposed to sub-graphs // Context getContext(); // Bus getBusProvider(); // JobManager getJobManager(); // MainThread getMainThread(); // //Map<QueryPlayer, QueryPlayer> getSearchPlayersCache(); // }
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import com.squareup.otto.Bus; import javax.inject.Inject; import butterknife.ButterKnife; import es.rogermartinez.paddlemanager.BuildConfig; import es.rogermartinez.paddlemanager.R; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorHandler; import es.rogermartinez.paddlemanager.injector.ActivityModule; import es.rogermartinez.paddlemanager.injector.ApplicationComponent;
package es.rogermartinez.paddlemanager.base.view.activity; public abstract class BaseActivity extends AppCompatActivity implements ViewErrorEvent { @Inject Bus bus;
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorEvent.java // public interface ViewErrorEvent // { // void onError(ErrorEvent event); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorHandler.java // public class ViewErrorHandler { // // private Bus bus; // ViewErrorEvent errorEvent; // // // public ViewErrorHandler(Bus bus, ViewErrorEvent errorEvent) { // this.bus = bus; // this.errorEvent = errorEvent; // } // // public void register(){ // bus.register(this); // } // // public void unregister(){ // bus.unregister(this); // } // // @Subscribe // public void onErrorEvent(ErrorEvent event) { // errorEvent.onError(event); // } // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ActivityModule.java // @Module // public class ActivityModule { // private final Activity activity; // // public ActivityModule(Activity activity){ // this.activity = activity; // } // // @Provides // @PerActivity // Activity provideActivity(){ // return activity; // } // // @Provides // @PerActivity // DomainErrorHandler provideDomainErrorHandler(Bus bus) { // return new DomainErrorHandler(bus); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationComponent.java // @Singleton // @Component(modules = ApplicationModule.class) // public interface ApplicationComponent { // void inject(BaseActivity baseActivity); // // // Exposed to sub-graphs // Context getContext(); // Bus getBusProvider(); // JobManager getJobManager(); // MainThread getMainThread(); // //Map<QueryPlayer, QueryPlayer> getSearchPlayersCache(); // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/BaseActivity.java import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import com.squareup.otto.Bus; import javax.inject.Inject; import butterknife.ButterKnife; import es.rogermartinez.paddlemanager.BuildConfig; import es.rogermartinez.paddlemanager.R; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorHandler; import es.rogermartinez.paddlemanager.injector.ActivityModule; import es.rogermartinez.paddlemanager.injector.ApplicationComponent; package es.rogermartinez.paddlemanager.base.view.activity; public abstract class BaseActivity extends AppCompatActivity implements ViewErrorEvent { @Inject Bus bus;
protected ViewErrorHandler viewErrorHandler;
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/BaseActivity.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorEvent.java // public interface ViewErrorEvent // { // void onError(ErrorEvent event); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorHandler.java // public class ViewErrorHandler { // // private Bus bus; // ViewErrorEvent errorEvent; // // // public ViewErrorHandler(Bus bus, ViewErrorEvent errorEvent) { // this.bus = bus; // this.errorEvent = errorEvent; // } // // public void register(){ // bus.register(this); // } // // public void unregister(){ // bus.unregister(this); // } // // @Subscribe // public void onErrorEvent(ErrorEvent event) { // errorEvent.onError(event); // } // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ActivityModule.java // @Module // public class ActivityModule { // private final Activity activity; // // public ActivityModule(Activity activity){ // this.activity = activity; // } // // @Provides // @PerActivity // Activity provideActivity(){ // return activity; // } // // @Provides // @PerActivity // DomainErrorHandler provideDomainErrorHandler(Bus bus) { // return new DomainErrorHandler(bus); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationComponent.java // @Singleton // @Component(modules = ApplicationModule.class) // public interface ApplicationComponent { // void inject(BaseActivity baseActivity); // // // Exposed to sub-graphs // Context getContext(); // Bus getBusProvider(); // JobManager getJobManager(); // MainThread getMainThread(); // //Map<QueryPlayer, QueryPlayer> getSearchPlayersCache(); // }
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import com.squareup.otto.Bus; import javax.inject.Inject; import butterknife.ButterKnife; import es.rogermartinez.paddlemanager.BuildConfig; import es.rogermartinez.paddlemanager.R; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorHandler; import es.rogermartinez.paddlemanager.injector.ActivityModule; import es.rogermartinez.paddlemanager.injector.ApplicationComponent;
package es.rogermartinez.paddlemanager.base.view.activity; public abstract class BaseActivity extends AppCompatActivity implements ViewErrorEvent { @Inject Bus bus; protected ViewErrorHandler viewErrorHandler; protected Toolbar toolbar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.getApplicationComponent().inject(this); overridePendingTransition(R.anim.screen_fade_in, R.anim.screen_fade_out); ButterKnife.setDebug(BuildConfig.DEBUG); ButterKnife.bind(this); viewErrorHandler = new ViewErrorHandler(bus, this); } @Override public void setContentView(int layoutResID) { super.setContentView(layoutResID); } @Override protected void onResume() { super.onResume(); } @Override protected void onStart() { super.onStart(); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); }
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorEvent.java // public interface ViewErrorEvent // { // void onError(ErrorEvent event); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorHandler.java // public class ViewErrorHandler { // // private Bus bus; // ViewErrorEvent errorEvent; // // // public ViewErrorHandler(Bus bus, ViewErrorEvent errorEvent) { // this.bus = bus; // this.errorEvent = errorEvent; // } // // public void register(){ // bus.register(this); // } // // public void unregister(){ // bus.unregister(this); // } // // @Subscribe // public void onErrorEvent(ErrorEvent event) { // errorEvent.onError(event); // } // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ActivityModule.java // @Module // public class ActivityModule { // private final Activity activity; // // public ActivityModule(Activity activity){ // this.activity = activity; // } // // @Provides // @PerActivity // Activity provideActivity(){ // return activity; // } // // @Provides // @PerActivity // DomainErrorHandler provideDomainErrorHandler(Bus bus) { // return new DomainErrorHandler(bus); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationComponent.java // @Singleton // @Component(modules = ApplicationModule.class) // public interface ApplicationComponent { // void inject(BaseActivity baseActivity); // // // Exposed to sub-graphs // Context getContext(); // Bus getBusProvider(); // JobManager getJobManager(); // MainThread getMainThread(); // //Map<QueryPlayer, QueryPlayer> getSearchPlayersCache(); // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/BaseActivity.java import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import com.squareup.otto.Bus; import javax.inject.Inject; import butterknife.ButterKnife; import es.rogermartinez.paddlemanager.BuildConfig; import es.rogermartinez.paddlemanager.R; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorHandler; import es.rogermartinez.paddlemanager.injector.ActivityModule; import es.rogermartinez.paddlemanager.injector.ApplicationComponent; package es.rogermartinez.paddlemanager.base.view.activity; public abstract class BaseActivity extends AppCompatActivity implements ViewErrorEvent { @Inject Bus bus; protected ViewErrorHandler viewErrorHandler; protected Toolbar toolbar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.getApplicationComponent().inject(this); overridePendingTransition(R.anim.screen_fade_in, R.anim.screen_fade_out); ButterKnife.setDebug(BuildConfig.DEBUG); ButterKnife.bind(this); viewErrorHandler = new ViewErrorHandler(bus, this); } @Override public void setContentView(int layoutResID) { super.setContentView(layoutResID); } @Override protected void onResume() { super.onResume(); } @Override protected void onStart() { super.onStart(); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); }
public void onError(ErrorEvent event) {
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/BaseActivity.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorEvent.java // public interface ViewErrorEvent // { // void onError(ErrorEvent event); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorHandler.java // public class ViewErrorHandler { // // private Bus bus; // ViewErrorEvent errorEvent; // // // public ViewErrorHandler(Bus bus, ViewErrorEvent errorEvent) { // this.bus = bus; // this.errorEvent = errorEvent; // } // // public void register(){ // bus.register(this); // } // // public void unregister(){ // bus.unregister(this); // } // // @Subscribe // public void onErrorEvent(ErrorEvent event) { // errorEvent.onError(event); // } // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ActivityModule.java // @Module // public class ActivityModule { // private final Activity activity; // // public ActivityModule(Activity activity){ // this.activity = activity; // } // // @Provides // @PerActivity // Activity provideActivity(){ // return activity; // } // // @Provides // @PerActivity // DomainErrorHandler provideDomainErrorHandler(Bus bus) { // return new DomainErrorHandler(bus); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationComponent.java // @Singleton // @Component(modules = ApplicationModule.class) // public interface ApplicationComponent { // void inject(BaseActivity baseActivity); // // // Exposed to sub-graphs // Context getContext(); // Bus getBusProvider(); // JobManager getJobManager(); // MainThread getMainThread(); // //Map<QueryPlayer, QueryPlayer> getSearchPlayersCache(); // }
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import com.squareup.otto.Bus; import javax.inject.Inject; import butterknife.ButterKnife; import es.rogermartinez.paddlemanager.BuildConfig; import es.rogermartinez.paddlemanager.R; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorHandler; import es.rogermartinez.paddlemanager.injector.ActivityModule; import es.rogermartinez.paddlemanager.injector.ApplicationComponent;
viewErrorHandler = new ViewErrorHandler(bus, this); } @Override public void setContentView(int layoutResID) { super.setContentView(layoutResID); } @Override protected void onResume() { super.onResume(); } @Override protected void onStart() { super.onStart(); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); } public void onError(ErrorEvent event) { boolean redirectToLogin = ErrorEvent.ACTION_REDIRECT_TO_LOGIN == event.getAction(); boolean needsScopes = ErrorEvent.ACTIONS_REQUEST_NEW_SCOPES == event.getAction(); //TODO Errores } protected abstract boolean showError(ErrorEvent event);
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorEvent.java // public interface ViewErrorEvent // { // void onError(ErrorEvent event); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorHandler.java // public class ViewErrorHandler { // // private Bus bus; // ViewErrorEvent errorEvent; // // // public ViewErrorHandler(Bus bus, ViewErrorEvent errorEvent) { // this.bus = bus; // this.errorEvent = errorEvent; // } // // public void register(){ // bus.register(this); // } // // public void unregister(){ // bus.unregister(this); // } // // @Subscribe // public void onErrorEvent(ErrorEvent event) { // errorEvent.onError(event); // } // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ActivityModule.java // @Module // public class ActivityModule { // private final Activity activity; // // public ActivityModule(Activity activity){ // this.activity = activity; // } // // @Provides // @PerActivity // Activity provideActivity(){ // return activity; // } // // @Provides // @PerActivity // DomainErrorHandler provideDomainErrorHandler(Bus bus) { // return new DomainErrorHandler(bus); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationComponent.java // @Singleton // @Component(modules = ApplicationModule.class) // public interface ApplicationComponent { // void inject(BaseActivity baseActivity); // // // Exposed to sub-graphs // Context getContext(); // Bus getBusProvider(); // JobManager getJobManager(); // MainThread getMainThread(); // //Map<QueryPlayer, QueryPlayer> getSearchPlayersCache(); // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/BaseActivity.java import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import com.squareup.otto.Bus; import javax.inject.Inject; import butterknife.ButterKnife; import es.rogermartinez.paddlemanager.BuildConfig; import es.rogermartinez.paddlemanager.R; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorHandler; import es.rogermartinez.paddlemanager.injector.ActivityModule; import es.rogermartinez.paddlemanager.injector.ApplicationComponent; viewErrorHandler = new ViewErrorHandler(bus, this); } @Override public void setContentView(int layoutResID) { super.setContentView(layoutResID); } @Override protected void onResume() { super.onResume(); } @Override protected void onStart() { super.onStart(); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); } public void onError(ErrorEvent event) { boolean redirectToLogin = ErrorEvent.ACTION_REDIRECT_TO_LOGIN == event.getAction(); boolean needsScopes = ErrorEvent.ACTIONS_REQUEST_NEW_SCOPES == event.getAction(); //TODO Errores } protected abstract boolean showError(ErrorEvent event);
protected ApplicationComponent getApplicationComponent() {
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/BaseActivity.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorEvent.java // public interface ViewErrorEvent // { // void onError(ErrorEvent event); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorHandler.java // public class ViewErrorHandler { // // private Bus bus; // ViewErrorEvent errorEvent; // // // public ViewErrorHandler(Bus bus, ViewErrorEvent errorEvent) { // this.bus = bus; // this.errorEvent = errorEvent; // } // // public void register(){ // bus.register(this); // } // // public void unregister(){ // bus.unregister(this); // } // // @Subscribe // public void onErrorEvent(ErrorEvent event) { // errorEvent.onError(event); // } // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ActivityModule.java // @Module // public class ActivityModule { // private final Activity activity; // // public ActivityModule(Activity activity){ // this.activity = activity; // } // // @Provides // @PerActivity // Activity provideActivity(){ // return activity; // } // // @Provides // @PerActivity // DomainErrorHandler provideDomainErrorHandler(Bus bus) { // return new DomainErrorHandler(bus); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationComponent.java // @Singleton // @Component(modules = ApplicationModule.class) // public interface ApplicationComponent { // void inject(BaseActivity baseActivity); // // // Exposed to sub-graphs // Context getContext(); // Bus getBusProvider(); // JobManager getJobManager(); // MainThread getMainThread(); // //Map<QueryPlayer, QueryPlayer> getSearchPlayersCache(); // }
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import com.squareup.otto.Bus; import javax.inject.Inject; import butterknife.ButterKnife; import es.rogermartinez.paddlemanager.BuildConfig; import es.rogermartinez.paddlemanager.R; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorHandler; import es.rogermartinez.paddlemanager.injector.ActivityModule; import es.rogermartinez.paddlemanager.injector.ApplicationComponent;
} @Override public void setContentView(int layoutResID) { super.setContentView(layoutResID); } @Override protected void onResume() { super.onResume(); } @Override protected void onStart() { super.onStart(); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); } public void onError(ErrorEvent event) { boolean redirectToLogin = ErrorEvent.ACTION_REDIRECT_TO_LOGIN == event.getAction(); boolean needsScopes = ErrorEvent.ACTIONS_REQUEST_NEW_SCOPES == event.getAction(); //TODO Errores } protected abstract boolean showError(ErrorEvent event); protected ApplicationComponent getApplicationComponent() {
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorEvent.java // public interface ViewErrorEvent // { // void onError(ErrorEvent event); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorHandler.java // public class ViewErrorHandler { // // private Bus bus; // ViewErrorEvent errorEvent; // // // public ViewErrorHandler(Bus bus, ViewErrorEvent errorEvent) { // this.bus = bus; // this.errorEvent = errorEvent; // } // // public void register(){ // bus.register(this); // } // // public void unregister(){ // bus.unregister(this); // } // // @Subscribe // public void onErrorEvent(ErrorEvent event) { // errorEvent.onError(event); // } // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ActivityModule.java // @Module // public class ActivityModule { // private final Activity activity; // // public ActivityModule(Activity activity){ // this.activity = activity; // } // // @Provides // @PerActivity // Activity provideActivity(){ // return activity; // } // // @Provides // @PerActivity // DomainErrorHandler provideDomainErrorHandler(Bus bus) { // return new DomainErrorHandler(bus); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationComponent.java // @Singleton // @Component(modules = ApplicationModule.class) // public interface ApplicationComponent { // void inject(BaseActivity baseActivity); // // // Exposed to sub-graphs // Context getContext(); // Bus getBusProvider(); // JobManager getJobManager(); // MainThread getMainThread(); // //Map<QueryPlayer, QueryPlayer> getSearchPlayersCache(); // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/BaseActivity.java import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import com.squareup.otto.Bus; import javax.inject.Inject; import butterknife.ButterKnife; import es.rogermartinez.paddlemanager.BuildConfig; import es.rogermartinez.paddlemanager.R; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorHandler; import es.rogermartinez.paddlemanager.injector.ActivityModule; import es.rogermartinez.paddlemanager.injector.ApplicationComponent; } @Override public void setContentView(int layoutResID) { super.setContentView(layoutResID); } @Override protected void onResume() { super.onResume(); } @Override protected void onStart() { super.onStart(); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); } public void onError(ErrorEvent event) { boolean redirectToLogin = ErrorEvent.ACTION_REDIRECT_TO_LOGIN == event.getAction(); boolean needsScopes = ErrorEvent.ACTIONS_REQUEST_NEW_SCOPES == event.getAction(); //TODO Errores } protected abstract boolean showError(ErrorEvent event); protected ApplicationComponent getApplicationComponent() {
return ((AndroidApplication)getApplication()).getApplicationComponent();
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/BaseActivity.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorEvent.java // public interface ViewErrorEvent // { // void onError(ErrorEvent event); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorHandler.java // public class ViewErrorHandler { // // private Bus bus; // ViewErrorEvent errorEvent; // // // public ViewErrorHandler(Bus bus, ViewErrorEvent errorEvent) { // this.bus = bus; // this.errorEvent = errorEvent; // } // // public void register(){ // bus.register(this); // } // // public void unregister(){ // bus.unregister(this); // } // // @Subscribe // public void onErrorEvent(ErrorEvent event) { // errorEvent.onError(event); // } // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ActivityModule.java // @Module // public class ActivityModule { // private final Activity activity; // // public ActivityModule(Activity activity){ // this.activity = activity; // } // // @Provides // @PerActivity // Activity provideActivity(){ // return activity; // } // // @Provides // @PerActivity // DomainErrorHandler provideDomainErrorHandler(Bus bus) { // return new DomainErrorHandler(bus); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationComponent.java // @Singleton // @Component(modules = ApplicationModule.class) // public interface ApplicationComponent { // void inject(BaseActivity baseActivity); // // // Exposed to sub-graphs // Context getContext(); // Bus getBusProvider(); // JobManager getJobManager(); // MainThread getMainThread(); // //Map<QueryPlayer, QueryPlayer> getSearchPlayersCache(); // }
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import com.squareup.otto.Bus; import javax.inject.Inject; import butterknife.ButterKnife; import es.rogermartinez.paddlemanager.BuildConfig; import es.rogermartinez.paddlemanager.R; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorHandler; import es.rogermartinez.paddlemanager.injector.ActivityModule; import es.rogermartinez.paddlemanager.injector.ApplicationComponent;
public void setContentView(int layoutResID) { super.setContentView(layoutResID); } @Override protected void onResume() { super.onResume(); } @Override protected void onStart() { super.onStart(); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); } public void onError(ErrorEvent event) { boolean redirectToLogin = ErrorEvent.ACTION_REDIRECT_TO_LOGIN == event.getAction(); boolean needsScopes = ErrorEvent.ACTIONS_REQUEST_NEW_SCOPES == event.getAction(); //TODO Errores } protected abstract boolean showError(ErrorEvent event); protected ApplicationComponent getApplicationComponent() { return ((AndroidApplication)getApplication()).getApplicationComponent(); }
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorEvent.java // public interface ViewErrorEvent // { // void onError(ErrorEvent event); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorHandler.java // public class ViewErrorHandler { // // private Bus bus; // ViewErrorEvent errorEvent; // // // public ViewErrorHandler(Bus bus, ViewErrorEvent errorEvent) { // this.bus = bus; // this.errorEvent = errorEvent; // } // // public void register(){ // bus.register(this); // } // // public void unregister(){ // bus.unregister(this); // } // // @Subscribe // public void onErrorEvent(ErrorEvent event) { // errorEvent.onError(event); // } // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ActivityModule.java // @Module // public class ActivityModule { // private final Activity activity; // // public ActivityModule(Activity activity){ // this.activity = activity; // } // // @Provides // @PerActivity // Activity provideActivity(){ // return activity; // } // // @Provides // @PerActivity // DomainErrorHandler provideDomainErrorHandler(Bus bus) { // return new DomainErrorHandler(bus); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationComponent.java // @Singleton // @Component(modules = ApplicationModule.class) // public interface ApplicationComponent { // void inject(BaseActivity baseActivity); // // // Exposed to sub-graphs // Context getContext(); // Bus getBusProvider(); // JobManager getJobManager(); // MainThread getMainThread(); // //Map<QueryPlayer, QueryPlayer> getSearchPlayersCache(); // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/BaseActivity.java import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import com.squareup.otto.Bus; import javax.inject.Inject; import butterknife.ButterKnife; import es.rogermartinez.paddlemanager.BuildConfig; import es.rogermartinez.paddlemanager.R; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorEvent; import es.rogermartinez.paddlemanager.base.view.errors.ViewErrorHandler; import es.rogermartinez.paddlemanager.injector.ActivityModule; import es.rogermartinez.paddlemanager.injector.ApplicationComponent; public void setContentView(int layoutResID) { super.setContentView(layoutResID); } @Override protected void onResume() { super.onResume(); } @Override protected void onStart() { super.onStart(); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); } public void onError(ErrorEvent event) { boolean redirectToLogin = ErrorEvent.ACTION_REDIRECT_TO_LOGIN == event.getAction(); boolean needsScopes = ErrorEvent.ACTIONS_REQUEST_NEW_SCOPES == event.getAction(); //TODO Errores } protected abstract boolean showError(ErrorEvent event); protected ApplicationComponent getApplicationComponent() { return ((AndroidApplication)getApplication()).getApplicationComponent(); }
protected ActivityModule getActivityModule() {
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/sqllite/SearchPlayersDDBBSqlLite.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/SearchPlayersDDBB.java // public interface SearchPlayersDDBB { // PlayersSearchResultDDBBModel search(QueryPlayer queryPlayer); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/model/PlayerDDBBModel.java // @DatabaseTable(tableName = "player") // public class PlayerDDBBModel { // // @DatabaseField(generatedId = true) // private long id; // // @DatabaseField // private String name = ""; // // @DatabaseField // private int level = 0; // // @DatabaseField // private int sex = 0; // // @DatabaseField // private int position = 0; // // @DatabaseField // private String comment = ""; // // public PlayerDDBBModel(){ // // } // // public PlayerDDBBModel(long id, String name, int level, int sex, int position, String comment){ // this.id = id; // this.name = name; // this.level = level; // this.sex = sex; // this.position = position; // this.comment = comment; // } // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/model/PlayersSearchResultDDBBModel.java // public class PlayersSearchResultDDBBModel { // private List<PlayerDDBBModel> players = new ArrayList<>(); // // public PlayersSearchResultDDBBModel(List<PlayerDDBBModel> players){ // this.players = players; // } // // public List<PlayerDDBBModel> getPlayers(){ // return players; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // }
import com.j256.ormlite.dao.Dao; import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import javax.inject.Inject; import es.rogermartinez.paddlemanager.search.datasource.ddbb.SearchPlayersDDBB; import es.rogermartinez.paddlemanager.search.datasource.ddbb.model.PlayerDDBBModel; import es.rogermartinez.paddlemanager.search.datasource.ddbb.model.PlayersSearchResultDDBBModel; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer;
package es.rogermartinez.paddlemanager.search.datasource.ddbb.sqllite; /** * Created by roger.martinez on 13/11/15. */ public class SearchPlayersDDBBSqlLite implements SearchPlayersDDBB { private Dao<PlayerDDBBModel, String> playerDao; @Inject public SearchPlayersDDBBSqlLite(Dao<PlayerDDBBModel, String> playerDao){ this.playerDao = playerDao; } @Override
// Path: app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/SearchPlayersDDBB.java // public interface SearchPlayersDDBB { // PlayersSearchResultDDBBModel search(QueryPlayer queryPlayer); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/model/PlayerDDBBModel.java // @DatabaseTable(tableName = "player") // public class PlayerDDBBModel { // // @DatabaseField(generatedId = true) // private long id; // // @DatabaseField // private String name = ""; // // @DatabaseField // private int level = 0; // // @DatabaseField // private int sex = 0; // // @DatabaseField // private int position = 0; // // @DatabaseField // private String comment = ""; // // public PlayerDDBBModel(){ // // } // // public PlayerDDBBModel(long id, String name, int level, int sex, int position, String comment){ // this.id = id; // this.name = name; // this.level = level; // this.sex = sex; // this.position = position; // this.comment = comment; // } // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/model/PlayersSearchResultDDBBModel.java // public class PlayersSearchResultDDBBModel { // private List<PlayerDDBBModel> players = new ArrayList<>(); // // public PlayersSearchResultDDBBModel(List<PlayerDDBBModel> players){ // this.players = players; // } // // public List<PlayerDDBBModel> getPlayers(){ // return players; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/sqllite/SearchPlayersDDBBSqlLite.java import com.j256.ormlite.dao.Dao; import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import javax.inject.Inject; import es.rogermartinez.paddlemanager.search.datasource.ddbb.SearchPlayersDDBB; import es.rogermartinez.paddlemanager.search.datasource.ddbb.model.PlayerDDBBModel; import es.rogermartinez.paddlemanager.search.datasource.ddbb.model.PlayersSearchResultDDBBModel; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; package es.rogermartinez.paddlemanager.search.datasource.ddbb.sqllite; /** * Created by roger.martinez on 13/11/15. */ public class SearchPlayersDDBBSqlLite implements SearchPlayersDDBB { private Dao<PlayerDDBBModel, String> playerDao; @Inject public SearchPlayersDDBBSqlLite(Dao<PlayerDDBBModel, String> playerDao){ this.playerDao = playerDao; } @Override
public PlayersSearchResultDDBBModel search(QueryPlayer queryPlayer) {
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/sqllite/SearchPlayersDDBBSqlLite.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/SearchPlayersDDBB.java // public interface SearchPlayersDDBB { // PlayersSearchResultDDBBModel search(QueryPlayer queryPlayer); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/model/PlayerDDBBModel.java // @DatabaseTable(tableName = "player") // public class PlayerDDBBModel { // // @DatabaseField(generatedId = true) // private long id; // // @DatabaseField // private String name = ""; // // @DatabaseField // private int level = 0; // // @DatabaseField // private int sex = 0; // // @DatabaseField // private int position = 0; // // @DatabaseField // private String comment = ""; // // public PlayerDDBBModel(){ // // } // // public PlayerDDBBModel(long id, String name, int level, int sex, int position, String comment){ // this.id = id; // this.name = name; // this.level = level; // this.sex = sex; // this.position = position; // this.comment = comment; // } // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/model/PlayersSearchResultDDBBModel.java // public class PlayersSearchResultDDBBModel { // private List<PlayerDDBBModel> players = new ArrayList<>(); // // public PlayersSearchResultDDBBModel(List<PlayerDDBBModel> players){ // this.players = players; // } // // public List<PlayerDDBBModel> getPlayers(){ // return players; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // }
import com.j256.ormlite.dao.Dao; import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import javax.inject.Inject; import es.rogermartinez.paddlemanager.search.datasource.ddbb.SearchPlayersDDBB; import es.rogermartinez.paddlemanager.search.datasource.ddbb.model.PlayerDDBBModel; import es.rogermartinez.paddlemanager.search.datasource.ddbb.model.PlayersSearchResultDDBBModel; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer;
package es.rogermartinez.paddlemanager.search.datasource.ddbb.sqllite; /** * Created by roger.martinez on 13/11/15. */ public class SearchPlayersDDBBSqlLite implements SearchPlayersDDBB { private Dao<PlayerDDBBModel, String> playerDao; @Inject public SearchPlayersDDBBSqlLite(Dao<PlayerDDBBModel, String> playerDao){ this.playerDao = playerDao; } @Override
// Path: app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/SearchPlayersDDBB.java // public interface SearchPlayersDDBB { // PlayersSearchResultDDBBModel search(QueryPlayer queryPlayer); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/model/PlayerDDBBModel.java // @DatabaseTable(tableName = "player") // public class PlayerDDBBModel { // // @DatabaseField(generatedId = true) // private long id; // // @DatabaseField // private String name = ""; // // @DatabaseField // private int level = 0; // // @DatabaseField // private int sex = 0; // // @DatabaseField // private int position = 0; // // @DatabaseField // private String comment = ""; // // public PlayerDDBBModel(){ // // } // // public PlayerDDBBModel(long id, String name, int level, int sex, int position, String comment){ // this.id = id; // this.name = name; // this.level = level; // this.sex = sex; // this.position = position; // this.comment = comment; // } // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/model/PlayersSearchResultDDBBModel.java // public class PlayersSearchResultDDBBModel { // private List<PlayerDDBBModel> players = new ArrayList<>(); // // public PlayersSearchResultDDBBModel(List<PlayerDDBBModel> players){ // this.players = players; // } // // public List<PlayerDDBBModel> getPlayers(){ // return players; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/sqllite/SearchPlayersDDBBSqlLite.java import com.j256.ormlite.dao.Dao; import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import javax.inject.Inject; import es.rogermartinez.paddlemanager.search.datasource.ddbb.SearchPlayersDDBB; import es.rogermartinez.paddlemanager.search.datasource.ddbb.model.PlayerDDBBModel; import es.rogermartinez.paddlemanager.search.datasource.ddbb.model.PlayersSearchResultDDBBModel; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; package es.rogermartinez.paddlemanager.search.datasource.ddbb.sqllite; /** * Created by roger.martinez on 13/11/15. */ public class SearchPlayersDDBBSqlLite implements SearchPlayersDDBB { private Dao<PlayerDDBBModel, String> playerDao; @Inject public SearchPlayersDDBBSqlLite(Dao<PlayerDDBBModel, String> playerDao){ this.playerDao = playerDao; } @Override
public PlayersSearchResultDDBBModel search(QueryPlayer queryPlayer) {
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/DomainErrorHandler.java // public class DomainErrorHandler { // // private Bus bus; // // public DomainErrorHandler(Bus bus) { // this.bus = bus; // } // // public void notifyError(ErrorEvent errorObject) throws Throwable { // bus.post(errorObject); // } // // // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/UserCaseJob.java // public abstract class UserCaseJob extends Job { // protected static final int LOW_PRIORITY = 1; // protected static final int DEFAULT_PRIORITY = 2; // protected static final int HIGH_PRIORITY = 3; // // protected static final String GROUP_HIDE_APPLICATION = "hide_application"; // // public static final AtomicInteger COUNTER = new AtomicInteger(0); // // private final MainThread mainThread; // protected JobManager jobManager; // protected DomainErrorHandler domainErrorHandler; // // // protected UserCaseJob(JobManager jobManager, MainThread mainThread, Params params, DomainErrorHandler domainErrorHandler) { // super(params); // this.jobManager = jobManager; // this.mainThread = mainThread; // this.domainErrorHandler = domainErrorHandler; // } // // protected void sendCallback(Runnable callback) { // mainThread.post(callback); // } // // @Override // public void onAdded() { // COUNTER.incrementAndGet(); // } // // @Override // public void onRun() throws Throwable { // try { // //calls abstract method implemented in child UserJob. // doRun(); // COUNTER.decrementAndGet(); // } catch (Exception e) { // //CrashlyticsWrapper.logException(e); // // // TODO manage errors // domainErrorHandler.notifyError(new GeneralErrorEvent(e)); // } // } // // public abstract void doRun() throws Throwable; // // @Override // protected void onCancel() { // COUNTER.decrementAndGet(); // } // // @Override // protected boolean shouldReRunOnThrowable(Throwable throwable) { // return false; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/datasource/CreatePlayerDataSource.java // public interface CreatePlayerDataSource { // void createPlayer(Player player); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/callback/CreatePlayerCallback.java // public interface CreatePlayerCallback { // void onCreatePlayerSuccess(); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // }
import com.path.android.jobqueue.JobManager; import com.path.android.jobqueue.Params; import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.DomainErrorHandler; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.UserCaseJob; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.editplayer.datasource.CreatePlayerDataSource; import es.rogermartinez.paddlemanager.editplayer.domain.callback.CreatePlayerCallback; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer;
package es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl; /** * Created by roger.martinez on 17/11/15. */ public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { private Player player;
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/DomainErrorHandler.java // public class DomainErrorHandler { // // private Bus bus; // // public DomainErrorHandler(Bus bus) { // this.bus = bus; // } // // public void notifyError(ErrorEvent errorObject) throws Throwable { // bus.post(errorObject); // } // // // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/UserCaseJob.java // public abstract class UserCaseJob extends Job { // protected static final int LOW_PRIORITY = 1; // protected static final int DEFAULT_PRIORITY = 2; // protected static final int HIGH_PRIORITY = 3; // // protected static final String GROUP_HIDE_APPLICATION = "hide_application"; // // public static final AtomicInteger COUNTER = new AtomicInteger(0); // // private final MainThread mainThread; // protected JobManager jobManager; // protected DomainErrorHandler domainErrorHandler; // // // protected UserCaseJob(JobManager jobManager, MainThread mainThread, Params params, DomainErrorHandler domainErrorHandler) { // super(params); // this.jobManager = jobManager; // this.mainThread = mainThread; // this.domainErrorHandler = domainErrorHandler; // } // // protected void sendCallback(Runnable callback) { // mainThread.post(callback); // } // // @Override // public void onAdded() { // COUNTER.incrementAndGet(); // } // // @Override // public void onRun() throws Throwable { // try { // //calls abstract method implemented in child UserJob. // doRun(); // COUNTER.decrementAndGet(); // } catch (Exception e) { // //CrashlyticsWrapper.logException(e); // // // TODO manage errors // domainErrorHandler.notifyError(new GeneralErrorEvent(e)); // } // } // // public abstract void doRun() throws Throwable; // // @Override // protected void onCancel() { // COUNTER.decrementAndGet(); // } // // @Override // protected boolean shouldReRunOnThrowable(Throwable throwable) { // return false; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/datasource/CreatePlayerDataSource.java // public interface CreatePlayerDataSource { // void createPlayer(Player player); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/callback/CreatePlayerCallback.java // public interface CreatePlayerCallback { // void onCreatePlayerSuccess(); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java import com.path.android.jobqueue.JobManager; import com.path.android.jobqueue.Params; import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.DomainErrorHandler; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.UserCaseJob; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.editplayer.datasource.CreatePlayerDataSource; import es.rogermartinez.paddlemanager.editplayer.domain.callback.CreatePlayerCallback; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; package es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl; /** * Created by roger.martinez on 17/11/15. */ public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { private Player player;
private CreatePlayerCallback callback;
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/DomainErrorHandler.java // public class DomainErrorHandler { // // private Bus bus; // // public DomainErrorHandler(Bus bus) { // this.bus = bus; // } // // public void notifyError(ErrorEvent errorObject) throws Throwable { // bus.post(errorObject); // } // // // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/UserCaseJob.java // public abstract class UserCaseJob extends Job { // protected static final int LOW_PRIORITY = 1; // protected static final int DEFAULT_PRIORITY = 2; // protected static final int HIGH_PRIORITY = 3; // // protected static final String GROUP_HIDE_APPLICATION = "hide_application"; // // public static final AtomicInteger COUNTER = new AtomicInteger(0); // // private final MainThread mainThread; // protected JobManager jobManager; // protected DomainErrorHandler domainErrorHandler; // // // protected UserCaseJob(JobManager jobManager, MainThread mainThread, Params params, DomainErrorHandler domainErrorHandler) { // super(params); // this.jobManager = jobManager; // this.mainThread = mainThread; // this.domainErrorHandler = domainErrorHandler; // } // // protected void sendCallback(Runnable callback) { // mainThread.post(callback); // } // // @Override // public void onAdded() { // COUNTER.incrementAndGet(); // } // // @Override // public void onRun() throws Throwable { // try { // //calls abstract method implemented in child UserJob. // doRun(); // COUNTER.decrementAndGet(); // } catch (Exception e) { // //CrashlyticsWrapper.logException(e); // // // TODO manage errors // domainErrorHandler.notifyError(new GeneralErrorEvent(e)); // } // } // // public abstract void doRun() throws Throwable; // // @Override // protected void onCancel() { // COUNTER.decrementAndGet(); // } // // @Override // protected boolean shouldReRunOnThrowable(Throwable throwable) { // return false; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/datasource/CreatePlayerDataSource.java // public interface CreatePlayerDataSource { // void createPlayer(Player player); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/callback/CreatePlayerCallback.java // public interface CreatePlayerCallback { // void onCreatePlayerSuccess(); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // }
import com.path.android.jobqueue.JobManager; import com.path.android.jobqueue.Params; import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.DomainErrorHandler; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.UserCaseJob; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.editplayer.datasource.CreatePlayerDataSource; import es.rogermartinez.paddlemanager.editplayer.domain.callback.CreatePlayerCallback; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer;
package es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl; /** * Created by roger.martinez on 17/11/15. */ public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { private Player player; private CreatePlayerCallback callback;
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/DomainErrorHandler.java // public class DomainErrorHandler { // // private Bus bus; // // public DomainErrorHandler(Bus bus) { // this.bus = bus; // } // // public void notifyError(ErrorEvent errorObject) throws Throwable { // bus.post(errorObject); // } // // // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/UserCaseJob.java // public abstract class UserCaseJob extends Job { // protected static final int LOW_PRIORITY = 1; // protected static final int DEFAULT_PRIORITY = 2; // protected static final int HIGH_PRIORITY = 3; // // protected static final String GROUP_HIDE_APPLICATION = "hide_application"; // // public static final AtomicInteger COUNTER = new AtomicInteger(0); // // private final MainThread mainThread; // protected JobManager jobManager; // protected DomainErrorHandler domainErrorHandler; // // // protected UserCaseJob(JobManager jobManager, MainThread mainThread, Params params, DomainErrorHandler domainErrorHandler) { // super(params); // this.jobManager = jobManager; // this.mainThread = mainThread; // this.domainErrorHandler = domainErrorHandler; // } // // protected void sendCallback(Runnable callback) { // mainThread.post(callback); // } // // @Override // public void onAdded() { // COUNTER.incrementAndGet(); // } // // @Override // public void onRun() throws Throwable { // try { // //calls abstract method implemented in child UserJob. // doRun(); // COUNTER.decrementAndGet(); // } catch (Exception e) { // //CrashlyticsWrapper.logException(e); // // // TODO manage errors // domainErrorHandler.notifyError(new GeneralErrorEvent(e)); // } // } // // public abstract void doRun() throws Throwable; // // @Override // protected void onCancel() { // COUNTER.decrementAndGet(); // } // // @Override // protected boolean shouldReRunOnThrowable(Throwable throwable) { // return false; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/datasource/CreatePlayerDataSource.java // public interface CreatePlayerDataSource { // void createPlayer(Player player); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/callback/CreatePlayerCallback.java // public interface CreatePlayerCallback { // void onCreatePlayerSuccess(); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java import com.path.android.jobqueue.JobManager; import com.path.android.jobqueue.Params; import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.DomainErrorHandler; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.UserCaseJob; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.editplayer.datasource.CreatePlayerDataSource; import es.rogermartinez.paddlemanager.editplayer.domain.callback.CreatePlayerCallback; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; package es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl; /** * Created by roger.martinez on 17/11/15. */ public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { private Player player; private CreatePlayerCallback callback;
private CreatePlayerDataSource createPlayerDataSource;
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/DomainErrorHandler.java // public class DomainErrorHandler { // // private Bus bus; // // public DomainErrorHandler(Bus bus) { // this.bus = bus; // } // // public void notifyError(ErrorEvent errorObject) throws Throwable { // bus.post(errorObject); // } // // // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/UserCaseJob.java // public abstract class UserCaseJob extends Job { // protected static final int LOW_PRIORITY = 1; // protected static final int DEFAULT_PRIORITY = 2; // protected static final int HIGH_PRIORITY = 3; // // protected static final String GROUP_HIDE_APPLICATION = "hide_application"; // // public static final AtomicInteger COUNTER = new AtomicInteger(0); // // private final MainThread mainThread; // protected JobManager jobManager; // protected DomainErrorHandler domainErrorHandler; // // // protected UserCaseJob(JobManager jobManager, MainThread mainThread, Params params, DomainErrorHandler domainErrorHandler) { // super(params); // this.jobManager = jobManager; // this.mainThread = mainThread; // this.domainErrorHandler = domainErrorHandler; // } // // protected void sendCallback(Runnable callback) { // mainThread.post(callback); // } // // @Override // public void onAdded() { // COUNTER.incrementAndGet(); // } // // @Override // public void onRun() throws Throwable { // try { // //calls abstract method implemented in child UserJob. // doRun(); // COUNTER.decrementAndGet(); // } catch (Exception e) { // //CrashlyticsWrapper.logException(e); // // // TODO manage errors // domainErrorHandler.notifyError(new GeneralErrorEvent(e)); // } // } // // public abstract void doRun() throws Throwable; // // @Override // protected void onCancel() { // COUNTER.decrementAndGet(); // } // // @Override // protected boolean shouldReRunOnThrowable(Throwable throwable) { // return false; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/datasource/CreatePlayerDataSource.java // public interface CreatePlayerDataSource { // void createPlayer(Player player); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/callback/CreatePlayerCallback.java // public interface CreatePlayerCallback { // void onCreatePlayerSuccess(); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // }
import com.path.android.jobqueue.JobManager; import com.path.android.jobqueue.Params; import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.DomainErrorHandler; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.UserCaseJob; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.editplayer.datasource.CreatePlayerDataSource; import es.rogermartinez.paddlemanager.editplayer.domain.callback.CreatePlayerCallback; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer;
package es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl; /** * Created by roger.martinez on 17/11/15. */ public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { private Player player; private CreatePlayerCallback callback; private CreatePlayerDataSource createPlayerDataSource; @Inject
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/DomainErrorHandler.java // public class DomainErrorHandler { // // private Bus bus; // // public DomainErrorHandler(Bus bus) { // this.bus = bus; // } // // public void notifyError(ErrorEvent errorObject) throws Throwable { // bus.post(errorObject); // } // // // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/UserCaseJob.java // public abstract class UserCaseJob extends Job { // protected static final int LOW_PRIORITY = 1; // protected static final int DEFAULT_PRIORITY = 2; // protected static final int HIGH_PRIORITY = 3; // // protected static final String GROUP_HIDE_APPLICATION = "hide_application"; // // public static final AtomicInteger COUNTER = new AtomicInteger(0); // // private final MainThread mainThread; // protected JobManager jobManager; // protected DomainErrorHandler domainErrorHandler; // // // protected UserCaseJob(JobManager jobManager, MainThread mainThread, Params params, DomainErrorHandler domainErrorHandler) { // super(params); // this.jobManager = jobManager; // this.mainThread = mainThread; // this.domainErrorHandler = domainErrorHandler; // } // // protected void sendCallback(Runnable callback) { // mainThread.post(callback); // } // // @Override // public void onAdded() { // COUNTER.incrementAndGet(); // } // // @Override // public void onRun() throws Throwable { // try { // //calls abstract method implemented in child UserJob. // doRun(); // COUNTER.decrementAndGet(); // } catch (Exception e) { // //CrashlyticsWrapper.logException(e); // // // TODO manage errors // domainErrorHandler.notifyError(new GeneralErrorEvent(e)); // } // } // // public abstract void doRun() throws Throwable; // // @Override // protected void onCancel() { // COUNTER.decrementAndGet(); // } // // @Override // protected boolean shouldReRunOnThrowable(Throwable throwable) { // return false; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/datasource/CreatePlayerDataSource.java // public interface CreatePlayerDataSource { // void createPlayer(Player player); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/callback/CreatePlayerCallback.java // public interface CreatePlayerCallback { // void onCreatePlayerSuccess(); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java import com.path.android.jobqueue.JobManager; import com.path.android.jobqueue.Params; import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.DomainErrorHandler; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.UserCaseJob; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.editplayer.datasource.CreatePlayerDataSource; import es.rogermartinez.paddlemanager.editplayer.domain.callback.CreatePlayerCallback; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; package es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl; /** * Created by roger.martinez on 17/11/15. */ public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { private Player player; private CreatePlayerCallback callback; private CreatePlayerDataSource createPlayerDataSource; @Inject
public CreatePlayerJob(JobManager jobManager, MainThread mainThread,
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/DomainErrorHandler.java // public class DomainErrorHandler { // // private Bus bus; // // public DomainErrorHandler(Bus bus) { // this.bus = bus; // } // // public void notifyError(ErrorEvent errorObject) throws Throwable { // bus.post(errorObject); // } // // // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/UserCaseJob.java // public abstract class UserCaseJob extends Job { // protected static final int LOW_PRIORITY = 1; // protected static final int DEFAULT_PRIORITY = 2; // protected static final int HIGH_PRIORITY = 3; // // protected static final String GROUP_HIDE_APPLICATION = "hide_application"; // // public static final AtomicInteger COUNTER = new AtomicInteger(0); // // private final MainThread mainThread; // protected JobManager jobManager; // protected DomainErrorHandler domainErrorHandler; // // // protected UserCaseJob(JobManager jobManager, MainThread mainThread, Params params, DomainErrorHandler domainErrorHandler) { // super(params); // this.jobManager = jobManager; // this.mainThread = mainThread; // this.domainErrorHandler = domainErrorHandler; // } // // protected void sendCallback(Runnable callback) { // mainThread.post(callback); // } // // @Override // public void onAdded() { // COUNTER.incrementAndGet(); // } // // @Override // public void onRun() throws Throwable { // try { // //calls abstract method implemented in child UserJob. // doRun(); // COUNTER.decrementAndGet(); // } catch (Exception e) { // //CrashlyticsWrapper.logException(e); // // // TODO manage errors // domainErrorHandler.notifyError(new GeneralErrorEvent(e)); // } // } // // public abstract void doRun() throws Throwable; // // @Override // protected void onCancel() { // COUNTER.decrementAndGet(); // } // // @Override // protected boolean shouldReRunOnThrowable(Throwable throwable) { // return false; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/datasource/CreatePlayerDataSource.java // public interface CreatePlayerDataSource { // void createPlayer(Player player); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/callback/CreatePlayerCallback.java // public interface CreatePlayerCallback { // void onCreatePlayerSuccess(); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // }
import com.path.android.jobqueue.JobManager; import com.path.android.jobqueue.Params; import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.DomainErrorHandler; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.UserCaseJob; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.editplayer.datasource.CreatePlayerDataSource; import es.rogermartinez.paddlemanager.editplayer.domain.callback.CreatePlayerCallback; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer;
package es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl; /** * Created by roger.martinez on 17/11/15. */ public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { private Player player; private CreatePlayerCallback callback; private CreatePlayerDataSource createPlayerDataSource; @Inject public CreatePlayerJob(JobManager jobManager, MainThread mainThread,
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/DomainErrorHandler.java // public class DomainErrorHandler { // // private Bus bus; // // public DomainErrorHandler(Bus bus) { // this.bus = bus; // } // // public void notifyError(ErrorEvent errorObject) throws Throwable { // bus.post(errorObject); // } // // // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/UserCaseJob.java // public abstract class UserCaseJob extends Job { // protected static final int LOW_PRIORITY = 1; // protected static final int DEFAULT_PRIORITY = 2; // protected static final int HIGH_PRIORITY = 3; // // protected static final String GROUP_HIDE_APPLICATION = "hide_application"; // // public static final AtomicInteger COUNTER = new AtomicInteger(0); // // private final MainThread mainThread; // protected JobManager jobManager; // protected DomainErrorHandler domainErrorHandler; // // // protected UserCaseJob(JobManager jobManager, MainThread mainThread, Params params, DomainErrorHandler domainErrorHandler) { // super(params); // this.jobManager = jobManager; // this.mainThread = mainThread; // this.domainErrorHandler = domainErrorHandler; // } // // protected void sendCallback(Runnable callback) { // mainThread.post(callback); // } // // @Override // public void onAdded() { // COUNTER.incrementAndGet(); // } // // @Override // public void onRun() throws Throwable { // try { // //calls abstract method implemented in child UserJob. // doRun(); // COUNTER.decrementAndGet(); // } catch (Exception e) { // //CrashlyticsWrapper.logException(e); // // // TODO manage errors // domainErrorHandler.notifyError(new GeneralErrorEvent(e)); // } // } // // public abstract void doRun() throws Throwable; // // @Override // protected void onCancel() { // COUNTER.decrementAndGet(); // } // // @Override // protected boolean shouldReRunOnThrowable(Throwable throwable) { // return false; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/datasource/CreatePlayerDataSource.java // public interface CreatePlayerDataSource { // void createPlayer(Player player); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/callback/CreatePlayerCallback.java // public interface CreatePlayerCallback { // void onCreatePlayerSuccess(); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java import com.path.android.jobqueue.JobManager; import com.path.android.jobqueue.Params; import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.DomainErrorHandler; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.UserCaseJob; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.editplayer.datasource.CreatePlayerDataSource; import es.rogermartinez.paddlemanager.editplayer.domain.callback.CreatePlayerCallback; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; package es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl; /** * Created by roger.martinez on 17/11/15. */ public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { private Player player; private CreatePlayerCallback callback; private CreatePlayerDataSource createPlayerDataSource; @Inject public CreatePlayerJob(JobManager jobManager, MainThread mainThread,
DomainErrorHandler domainErrorHandler, CreatePlayerDataSource createPlayerDataSource){
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/listplayers/view/controller/PrepareListPlayersController.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/usercase/SearchPlayers.java // public interface SearchPlayers { // void search(QueryPlayer queryPlayer, SearchPlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/callback/SearchPlayerCallback.java // public interface SearchPlayerCallback { // void onSearchComplete(SearchPlayersResult searchResult); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/SearchPlayersResult.java // public class SearchPlayersResult { // private List<Player> players = new ArrayList<>(); // // public List<Player> getPlayers() { // return players; // } // // public void setPlayers(List<Player> players) { // this.players = players; // } // }
import java.util.List; import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.listplayers.domain.usercase.SearchPlayers; import es.rogermartinez.paddlemanager.search.domain.callback.SearchPlayerCallback; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; import es.rogermartinez.paddlemanager.search.domain.model.SearchPlayersResult;
package es.rogermartinez.paddlemanager.listplayers.view.controller; /** * Created by roger.martinez on 9/10/15. */ public class PrepareListPlayersController { private View view; public void setView(View view) { this.view = view; }
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/usercase/SearchPlayers.java // public interface SearchPlayers { // void search(QueryPlayer queryPlayer, SearchPlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/callback/SearchPlayerCallback.java // public interface SearchPlayerCallback { // void onSearchComplete(SearchPlayersResult searchResult); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/SearchPlayersResult.java // public class SearchPlayersResult { // private List<Player> players = new ArrayList<>(); // // public List<Player> getPlayers() { // return players; // } // // public void setPlayers(List<Player> players) { // this.players = players; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/view/controller/PrepareListPlayersController.java import java.util.List; import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.listplayers.domain.usercase.SearchPlayers; import es.rogermartinez.paddlemanager.search.domain.callback.SearchPlayerCallback; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; import es.rogermartinez.paddlemanager.search.domain.model.SearchPlayersResult; package es.rogermartinez.paddlemanager.listplayers.view.controller; /** * Created by roger.martinez on 9/10/15. */ public class PrepareListPlayersController { private View view; public void setView(View view) { this.view = view; }
private SearchPlayers searchPlayersJob;
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/listplayers/view/controller/PrepareListPlayersController.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/usercase/SearchPlayers.java // public interface SearchPlayers { // void search(QueryPlayer queryPlayer, SearchPlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/callback/SearchPlayerCallback.java // public interface SearchPlayerCallback { // void onSearchComplete(SearchPlayersResult searchResult); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/SearchPlayersResult.java // public class SearchPlayersResult { // private List<Player> players = new ArrayList<>(); // // public List<Player> getPlayers() { // return players; // } // // public void setPlayers(List<Player> players) { // this.players = players; // } // }
import java.util.List; import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.listplayers.domain.usercase.SearchPlayers; import es.rogermartinez.paddlemanager.search.domain.callback.SearchPlayerCallback; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; import es.rogermartinez.paddlemanager.search.domain.model.SearchPlayersResult;
package es.rogermartinez.paddlemanager.listplayers.view.controller; /** * Created by roger.martinez on 9/10/15. */ public class PrepareListPlayersController { private View view; public void setView(View view) { this.view = view; } private SearchPlayers searchPlayersJob; @Inject public PrepareListPlayersController(SearchPlayers searchPlayers){ this.searchPlayersJob = searchPlayers; }
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/usercase/SearchPlayers.java // public interface SearchPlayers { // void search(QueryPlayer queryPlayer, SearchPlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/callback/SearchPlayerCallback.java // public interface SearchPlayerCallback { // void onSearchComplete(SearchPlayersResult searchResult); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/SearchPlayersResult.java // public class SearchPlayersResult { // private List<Player> players = new ArrayList<>(); // // public List<Player> getPlayers() { // return players; // } // // public void setPlayers(List<Player> players) { // this.players = players; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/view/controller/PrepareListPlayersController.java import java.util.List; import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.listplayers.domain.usercase.SearchPlayers; import es.rogermartinez.paddlemanager.search.domain.callback.SearchPlayerCallback; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; import es.rogermartinez.paddlemanager.search.domain.model.SearchPlayersResult; package es.rogermartinez.paddlemanager.listplayers.view.controller; /** * Created by roger.martinez on 9/10/15. */ public class PrepareListPlayersController { private View view; public void setView(View view) { this.view = view; } private SearchPlayers searchPlayersJob; @Inject public PrepareListPlayersController(SearchPlayers searchPlayers){ this.searchPlayersJob = searchPlayers; }
private SearchPlayerCallback searchPlayerCompleteCallback = new SearchPlayerCallback() {
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/listplayers/view/controller/PrepareListPlayersController.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/usercase/SearchPlayers.java // public interface SearchPlayers { // void search(QueryPlayer queryPlayer, SearchPlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/callback/SearchPlayerCallback.java // public interface SearchPlayerCallback { // void onSearchComplete(SearchPlayersResult searchResult); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/SearchPlayersResult.java // public class SearchPlayersResult { // private List<Player> players = new ArrayList<>(); // // public List<Player> getPlayers() { // return players; // } // // public void setPlayers(List<Player> players) { // this.players = players; // } // }
import java.util.List; import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.listplayers.domain.usercase.SearchPlayers; import es.rogermartinez.paddlemanager.search.domain.callback.SearchPlayerCallback; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; import es.rogermartinez.paddlemanager.search.domain.model.SearchPlayersResult;
package es.rogermartinez.paddlemanager.listplayers.view.controller; /** * Created by roger.martinez on 9/10/15. */ public class PrepareListPlayersController { private View view; public void setView(View view) { this.view = view; } private SearchPlayers searchPlayersJob; @Inject public PrepareListPlayersController(SearchPlayers searchPlayers){ this.searchPlayersJob = searchPlayers; } private SearchPlayerCallback searchPlayerCompleteCallback = new SearchPlayerCallback() { @Override
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/usercase/SearchPlayers.java // public interface SearchPlayers { // void search(QueryPlayer queryPlayer, SearchPlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/callback/SearchPlayerCallback.java // public interface SearchPlayerCallback { // void onSearchComplete(SearchPlayersResult searchResult); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/SearchPlayersResult.java // public class SearchPlayersResult { // private List<Player> players = new ArrayList<>(); // // public List<Player> getPlayers() { // return players; // } // // public void setPlayers(List<Player> players) { // this.players = players; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/view/controller/PrepareListPlayersController.java import java.util.List; import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.listplayers.domain.usercase.SearchPlayers; import es.rogermartinez.paddlemanager.search.domain.callback.SearchPlayerCallback; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; import es.rogermartinez.paddlemanager.search.domain.model.SearchPlayersResult; package es.rogermartinez.paddlemanager.listplayers.view.controller; /** * Created by roger.martinez on 9/10/15. */ public class PrepareListPlayersController { private View view; public void setView(View view) { this.view = view; } private SearchPlayers searchPlayersJob; @Inject public PrepareListPlayersController(SearchPlayers searchPlayers){ this.searchPlayersJob = searchPlayers; } private SearchPlayerCallback searchPlayerCompleteCallback = new SearchPlayerCallback() { @Override
public void onSearchComplete(SearchPlayersResult searchResult) {
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/listplayers/view/controller/PrepareListPlayersController.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/usercase/SearchPlayers.java // public interface SearchPlayers { // void search(QueryPlayer queryPlayer, SearchPlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/callback/SearchPlayerCallback.java // public interface SearchPlayerCallback { // void onSearchComplete(SearchPlayersResult searchResult); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/SearchPlayersResult.java // public class SearchPlayersResult { // private List<Player> players = new ArrayList<>(); // // public List<Player> getPlayers() { // return players; // } // // public void setPlayers(List<Player> players) { // this.players = players; // } // }
import java.util.List; import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.listplayers.domain.usercase.SearchPlayers; import es.rogermartinez.paddlemanager.search.domain.callback.SearchPlayerCallback; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; import es.rogermartinez.paddlemanager.search.domain.model.SearchPlayersResult;
package es.rogermartinez.paddlemanager.listplayers.view.controller; /** * Created by roger.martinez on 9/10/15. */ public class PrepareListPlayersController { private View view; public void setView(View view) { this.view = view; } private SearchPlayers searchPlayersJob; @Inject public PrepareListPlayersController(SearchPlayers searchPlayers){ this.searchPlayersJob = searchPlayers; } private SearchPlayerCallback searchPlayerCompleteCallback = new SearchPlayerCallback() { @Override public void onSearchComplete(SearchPlayersResult searchResult) { view.seachPlayersComplete(searchResult); } }; public void search(){
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/usercase/SearchPlayers.java // public interface SearchPlayers { // void search(QueryPlayer queryPlayer, SearchPlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/callback/SearchPlayerCallback.java // public interface SearchPlayerCallback { // void onSearchComplete(SearchPlayersResult searchResult); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/SearchPlayersResult.java // public class SearchPlayersResult { // private List<Player> players = new ArrayList<>(); // // public List<Player> getPlayers() { // return players; // } // // public void setPlayers(List<Player> players) { // this.players = players; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/view/controller/PrepareListPlayersController.java import java.util.List; import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.listplayers.domain.usercase.SearchPlayers; import es.rogermartinez.paddlemanager.search.domain.callback.SearchPlayerCallback; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; import es.rogermartinez.paddlemanager.search.domain.model.SearchPlayersResult; package es.rogermartinez.paddlemanager.listplayers.view.controller; /** * Created by roger.martinez on 9/10/15. */ public class PrepareListPlayersController { private View view; public void setView(View view) { this.view = view; } private SearchPlayers searchPlayersJob; @Inject public PrepareListPlayersController(SearchPlayers searchPlayers){ this.searchPlayersJob = searchPlayers; } private SearchPlayerCallback searchPlayerCompleteCallback = new SearchPlayerCallback() { @Override public void onSearchComplete(SearchPlayersResult searchResult) { view.seachPlayersComplete(searchResult); } }; public void search(){
searchPlayersJob.search(new QueryPlayer(), searchPlayerCompleteCallback);
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/editplayer/datasource/db/impl/CreatePlayerDataSourceImpl.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/datasource/CreatePlayerDataSource.java // public interface CreatePlayerDataSource { // void createPlayer(Player player); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/model/PlayerDDBBModel.java // @DatabaseTable(tableName = "player") // public class PlayerDDBBModel { // // @DatabaseField(generatedId = true) // private long id; // // @DatabaseField // private String name = ""; // // @DatabaseField // private int level = 0; // // @DatabaseField // private int sex = 0; // // @DatabaseField // private int position = 0; // // @DatabaseField // private String comment = ""; // // public PlayerDDBBModel(){ // // } // // public PlayerDDBBModel(long id, String name, int level, int sex, int position, String comment){ // this.id = id; // this.name = name; // this.level = level; // this.sex = sex; // this.position = position; // this.comment = comment; // } // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // }
import com.j256.ormlite.dao.Dao; import java.sql.SQLException; import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.editplayer.datasource.CreatePlayerDataSource; import es.rogermartinez.paddlemanager.search.datasource.ddbb.model.PlayerDDBBModel;
package es.rogermartinez.paddlemanager.editplayer.datasource.db.impl; public class CreatePlayerDataSourceImpl implements CreatePlayerDataSource { private Dao<PlayerDDBBModel, String> playerDao; @Inject public CreatePlayerDataSourceImpl(Dao<PlayerDDBBModel, String> playerDao){ this.playerDao = playerDao; } @Override
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/datasource/CreatePlayerDataSource.java // public interface CreatePlayerDataSource { // void createPlayer(Player player); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/model/PlayerDDBBModel.java // @DatabaseTable(tableName = "player") // public class PlayerDDBBModel { // // @DatabaseField(generatedId = true) // private long id; // // @DatabaseField // private String name = ""; // // @DatabaseField // private int level = 0; // // @DatabaseField // private int sex = 0; // // @DatabaseField // private int position = 0; // // @DatabaseField // private String comment = ""; // // public PlayerDDBBModel(){ // // } // // public PlayerDDBBModel(long id, String name, int level, int sex, int position, String comment){ // this.id = id; // this.name = name; // this.level = level; // this.sex = sex; // this.position = position; // this.comment = comment; // } // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/datasource/db/impl/CreatePlayerDataSourceImpl.java import com.j256.ormlite.dao.Dao; import java.sql.SQLException; import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.editplayer.datasource.CreatePlayerDataSource; import es.rogermartinez.paddlemanager.search.datasource.ddbb.model.PlayerDDBBModel; package es.rogermartinez.paddlemanager.editplayer.datasource.db.impl; public class CreatePlayerDataSourceImpl implements CreatePlayerDataSource { private Dao<PlayerDDBBModel, String> playerDao; @Inject public CreatePlayerDataSourceImpl(Dao<PlayerDDBBModel, String> playerDao){ this.playerDao = playerDao; } @Override
public void createPlayer(Player player) {
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/DrawerActivity.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/view/activity/phone/ListPlayersActivity.java // public class ListPlayersActivity extends DrawerActivity implements HasComponent<ListPlayersComponent> { // // // public static final int RC_SIGN_IN = 123; // // public static final int CREATE_PLAYER_RESULT_ID = 200; // private ListPlayersActivityFragment playersFragment; // // private ListPlayersComponent listPlayersComponent; // // private FirebaseAuth mFirebaseAuth; // private FirebaseAuth.AuthStateListener mAuthStateListener; // private String mUsername; // // private void initializeInjector() { // this.listPlayersComponent = DaggerListPlayersComponent.builder() // .applicationComponent(getApplicationComponent()) // // .activityModule(getActivityModule()) // .build(); // } // // @Override // public ListPlayersComponent getComponent() { // return listPlayersComponent; // } // // @Override // protected void onCreate(Bundle savedInstanceState) { // // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_players); // // initializeInjector(); // // mFirebaseAuth = FirebaseAuth.getInstance(); // // setTitle(getString(R.string.players)); // // if (savedInstanceState == null) { // playersFragment = new ListPlayersActivityFragment(); // getFragmentManager().beginTransaction().add(R.id.container, playersFragment).commit(); // } // // mAuthStateListener = new FirebaseAuth.AuthStateListener() { // @Override // public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { // FirebaseUser user = firebaseAuth.getCurrentUser(); // if (user != null) { // onSignedInItitialize(user.getDisplayName()); // } else { // onSignedOutCleanup(); // startActivityForResult( // AuthUI.getInstance() // .createSignInIntentBuilder() // .setIsSmartLockEnabled(false) // .setAvailableProviders( // Collections.singletonList(new AuthUI.IdpConfig.GoogleBuilder().build())) // .build(), // RC_SIGN_IN); // } // } // }; // } // // private void onSignedInItitialize(String username) { // mUsername = username; // } // // private void onSignedOutCleanup() { // mUsername = "annon"; // } // // @Override // protected boolean showError(ErrorEvent event) { // if (playersFragment != null) { // return playersFragment.showError(event); // } // return false; // } // // @Override // protected void onPause() { // super.onPause(); // if (mAuthStateListener != null) { // mFirebaseAuth.removeAuthStateListener(mAuthStateListener); // } // } // // @Override // protected void onResume() { // super.onResume(); // mFirebaseAuth.addAuthStateListener(mAuthStateListener); // } // // @Override // protected void onActivityResult(int requestCode, int resultCode, Intent data) { // super.onActivityResult(requestCode, resultCode, data); // if (requestCode == RC_SIGN_IN) { // if (resultCode == RESULT_OK) { // Toast.makeText(this, "Signed in!", Toast.LENGTH_SHORT).show(); // } else if (resultCode == RESULT_CANCELED) { // Toast.makeText(this, "Signed canceled!", Toast.LENGTH_SHORT).show(); // finish(); // } // } // } // }
import android.content.Intent; import android.support.design.widget.NavigationView; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.view.Menu; import android.view.MenuItem; import android.widget.Toast; import es.rogermartinez.paddlemanager.R; import es.rogermartinez.paddlemanager.listplayers.view.activity.phone.ListPlayersActivity;
drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); return super.onOptionsItemSelected(item); } @SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); switch (id){ case R.id.nav_players:
// Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/view/activity/phone/ListPlayersActivity.java // public class ListPlayersActivity extends DrawerActivity implements HasComponent<ListPlayersComponent> { // // // public static final int RC_SIGN_IN = 123; // // public static final int CREATE_PLAYER_RESULT_ID = 200; // private ListPlayersActivityFragment playersFragment; // // private ListPlayersComponent listPlayersComponent; // // private FirebaseAuth mFirebaseAuth; // private FirebaseAuth.AuthStateListener mAuthStateListener; // private String mUsername; // // private void initializeInjector() { // this.listPlayersComponent = DaggerListPlayersComponent.builder() // .applicationComponent(getApplicationComponent()) // // .activityModule(getActivityModule()) // .build(); // } // // @Override // public ListPlayersComponent getComponent() { // return listPlayersComponent; // } // // @Override // protected void onCreate(Bundle savedInstanceState) { // // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_players); // // initializeInjector(); // // mFirebaseAuth = FirebaseAuth.getInstance(); // // setTitle(getString(R.string.players)); // // if (savedInstanceState == null) { // playersFragment = new ListPlayersActivityFragment(); // getFragmentManager().beginTransaction().add(R.id.container, playersFragment).commit(); // } // // mAuthStateListener = new FirebaseAuth.AuthStateListener() { // @Override // public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { // FirebaseUser user = firebaseAuth.getCurrentUser(); // if (user != null) { // onSignedInItitialize(user.getDisplayName()); // } else { // onSignedOutCleanup(); // startActivityForResult( // AuthUI.getInstance() // .createSignInIntentBuilder() // .setIsSmartLockEnabled(false) // .setAvailableProviders( // Collections.singletonList(new AuthUI.IdpConfig.GoogleBuilder().build())) // .build(), // RC_SIGN_IN); // } // } // }; // } // // private void onSignedInItitialize(String username) { // mUsername = username; // } // // private void onSignedOutCleanup() { // mUsername = "annon"; // } // // @Override // protected boolean showError(ErrorEvent event) { // if (playersFragment != null) { // return playersFragment.showError(event); // } // return false; // } // // @Override // protected void onPause() { // super.onPause(); // if (mAuthStateListener != null) { // mFirebaseAuth.removeAuthStateListener(mAuthStateListener); // } // } // // @Override // protected void onResume() { // super.onResume(); // mFirebaseAuth.addAuthStateListener(mAuthStateListener); // } // // @Override // protected void onActivityResult(int requestCode, int resultCode, Intent data) { // super.onActivityResult(requestCode, resultCode, data); // if (requestCode == RC_SIGN_IN) { // if (resultCode == RESULT_OK) { // Toast.makeText(this, "Signed in!", Toast.LENGTH_SHORT).show(); // } else if (resultCode == RESULT_CANCELED) { // Toast.makeText(this, "Signed canceled!", Toast.LENGTH_SHORT).show(); // finish(); // } // } // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/DrawerActivity.java import android.content.Intent; import android.support.design.widget.NavigationView; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.view.Menu; import android.view.MenuItem; import android.widget.Toast; import es.rogermartinez.paddlemanager.R; import es.rogermartinez.paddlemanager.listplayers.view.activity.phone.ListPlayersActivity; drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); return super.onOptionsItemSelected(item); } @SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); switch (id){ case R.id.nav_players:
Intent intent = new Intent(this, ListPlayersActivity.class);
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/ListPlayerDomainModule.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/usercase/SearchPlayers.java // public interface SearchPlayers { // void search(QueryPlayer queryPlayer, SearchPlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/usercase/impl/SearchPlayersJob.java // public class SearchPlayersJob extends UserCaseJob implements SearchPlayers { // // private SearchPlayerCallback callback; // private QueryPlayer queryPlayer; // private SearchPlayerDataSource searchDataSource; // // @Inject // SearchPlayersJob(JobManager jobManager, MainThread mainThread, // DomainErrorHandler domainErrorHandler, SearchPlayerDataSource searchDataSource // ){ // super(jobManager, mainThread, new Params(UserCaseJob.DEFAULT_PRIORITY), domainErrorHandler); // this.searchDataSource = searchDataSource; // } // // @Override // public void search(QueryPlayer queryPlayer, SearchPlayerCallback callback) { // this.queryPlayer = queryPlayer; // this.callback = callback; // jobManager.addJob(this); // } // // @Override // public void doRun() throws Throwable { // SearchPlayersResult result = searchDataSource.search(queryPlayer); // notifySearchPlayerComplete(result); // } // // private void notifySearchPlayerComplete(final SearchPlayersResult searchPlayersResult){ // sendCallback(new Runnable() { // @Override // public void run() { // callback.onSearchComplete(searchPlayersResult); // } // }); // } // }
import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.daggerutils.PerActivity; import es.rogermartinez.paddlemanager.listplayers.domain.usercase.SearchPlayers; import es.rogermartinez.paddlemanager.listplayers.domain.usercase.impl.SearchPlayersJob;
package es.rogermartinez.paddlemanager.listplayers.domain; /** * Created by roger.martinez on 17/11/15. */ @Module public class ListPlayerDomainModule { @Provides @PerActivity
// Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/usercase/SearchPlayers.java // public interface SearchPlayers { // void search(QueryPlayer queryPlayer, SearchPlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/usercase/impl/SearchPlayersJob.java // public class SearchPlayersJob extends UserCaseJob implements SearchPlayers { // // private SearchPlayerCallback callback; // private QueryPlayer queryPlayer; // private SearchPlayerDataSource searchDataSource; // // @Inject // SearchPlayersJob(JobManager jobManager, MainThread mainThread, // DomainErrorHandler domainErrorHandler, SearchPlayerDataSource searchDataSource // ){ // super(jobManager, mainThread, new Params(UserCaseJob.DEFAULT_PRIORITY), domainErrorHandler); // this.searchDataSource = searchDataSource; // } // // @Override // public void search(QueryPlayer queryPlayer, SearchPlayerCallback callback) { // this.queryPlayer = queryPlayer; // this.callback = callback; // jobManager.addJob(this); // } // // @Override // public void doRun() throws Throwable { // SearchPlayersResult result = searchDataSource.search(queryPlayer); // notifySearchPlayerComplete(result); // } // // private void notifySearchPlayerComplete(final SearchPlayersResult searchPlayersResult){ // sendCallback(new Runnable() { // @Override // public void run() { // callback.onSearchComplete(searchPlayersResult); // } // }); // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/ListPlayerDomainModule.java import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.daggerutils.PerActivity; import es.rogermartinez.paddlemanager.listplayers.domain.usercase.SearchPlayers; import es.rogermartinez.paddlemanager.listplayers.domain.usercase.impl.SearchPlayersJob; package es.rogermartinez.paddlemanager.listplayers.domain; /** * Created by roger.martinez on 17/11/15. */ @Module public class ListPlayerDomainModule { @Provides @PerActivity
SearchPlayers provideSearchPlayers(SearchPlayersJob searchPlayersJob){
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/ListPlayerDomainModule.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/usercase/SearchPlayers.java // public interface SearchPlayers { // void search(QueryPlayer queryPlayer, SearchPlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/usercase/impl/SearchPlayersJob.java // public class SearchPlayersJob extends UserCaseJob implements SearchPlayers { // // private SearchPlayerCallback callback; // private QueryPlayer queryPlayer; // private SearchPlayerDataSource searchDataSource; // // @Inject // SearchPlayersJob(JobManager jobManager, MainThread mainThread, // DomainErrorHandler domainErrorHandler, SearchPlayerDataSource searchDataSource // ){ // super(jobManager, mainThread, new Params(UserCaseJob.DEFAULT_PRIORITY), domainErrorHandler); // this.searchDataSource = searchDataSource; // } // // @Override // public void search(QueryPlayer queryPlayer, SearchPlayerCallback callback) { // this.queryPlayer = queryPlayer; // this.callback = callback; // jobManager.addJob(this); // } // // @Override // public void doRun() throws Throwable { // SearchPlayersResult result = searchDataSource.search(queryPlayer); // notifySearchPlayerComplete(result); // } // // private void notifySearchPlayerComplete(final SearchPlayersResult searchPlayersResult){ // sendCallback(new Runnable() { // @Override // public void run() { // callback.onSearchComplete(searchPlayersResult); // } // }); // } // }
import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.daggerutils.PerActivity; import es.rogermartinez.paddlemanager.listplayers.domain.usercase.SearchPlayers; import es.rogermartinez.paddlemanager.listplayers.domain.usercase.impl.SearchPlayersJob;
package es.rogermartinez.paddlemanager.listplayers.domain; /** * Created by roger.martinez on 17/11/15. */ @Module public class ListPlayerDomainModule { @Provides @PerActivity
// Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/usercase/SearchPlayers.java // public interface SearchPlayers { // void search(QueryPlayer queryPlayer, SearchPlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/usercase/impl/SearchPlayersJob.java // public class SearchPlayersJob extends UserCaseJob implements SearchPlayers { // // private SearchPlayerCallback callback; // private QueryPlayer queryPlayer; // private SearchPlayerDataSource searchDataSource; // // @Inject // SearchPlayersJob(JobManager jobManager, MainThread mainThread, // DomainErrorHandler domainErrorHandler, SearchPlayerDataSource searchDataSource // ){ // super(jobManager, mainThread, new Params(UserCaseJob.DEFAULT_PRIORITY), domainErrorHandler); // this.searchDataSource = searchDataSource; // } // // @Override // public void search(QueryPlayer queryPlayer, SearchPlayerCallback callback) { // this.queryPlayer = queryPlayer; // this.callback = callback; // jobManager.addJob(this); // } // // @Override // public void doRun() throws Throwable { // SearchPlayersResult result = searchDataSource.search(queryPlayer); // notifySearchPlayerComplete(result); // } // // private void notifySearchPlayerComplete(final SearchPlayersResult searchPlayersResult){ // sendCallback(new Runnable() { // @Override // public void run() { // callback.onSearchComplete(searchPlayersResult); // } // }); // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/listplayers/domain/ListPlayerDomainModule.java import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.daggerutils.PerActivity; import es.rogermartinez.paddlemanager.listplayers.domain.usercase.SearchPlayers; import es.rogermartinez.paddlemanager.listplayers.domain.usercase.impl.SearchPlayersJob; package es.rogermartinez.paddlemanager.listplayers.domain; /** * Created by roger.martinez on 17/11/15. */ @Module public class ListPlayerDomainModule { @Provides @PerActivity
SearchPlayers provideSearchPlayers(SearchPlayersJob searchPlayersJob){
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/base/view/fragment/BaseFragment.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/daggerutils/HasComponent.java // public interface HasComponent<C> { // C getComponent(); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/BaseActivity.java // public abstract class BaseActivity extends AppCompatActivity implements ViewErrorEvent { // // @Inject // Bus bus; // // protected ViewErrorHandler viewErrorHandler; // // protected Toolbar toolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // this.getApplicationComponent().inject(this); // overridePendingTransition(R.anim.screen_fade_in, R.anim.screen_fade_out); // ButterKnife.setDebug(BuildConfig.DEBUG); // ButterKnife.bind(this); // viewErrorHandler = new ViewErrorHandler(bus, this); // } // // @Override // public void setContentView(int layoutResID) { // super.setContentView(layoutResID); // } // // // @Override // protected void onResume() { // super.onResume(); // } // // @Override // protected void onStart() { // super.onStart(); // toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // // } // // public void onError(ErrorEvent event) { // boolean redirectToLogin = ErrorEvent.ACTION_REDIRECT_TO_LOGIN == event.getAction(); // boolean needsScopes = ErrorEvent.ACTIONS_REQUEST_NEW_SCOPES == event.getAction(); // //TODO Errores // // } // protected abstract boolean showError(ErrorEvent event); // // protected ApplicationComponent getApplicationComponent() { // return ((AndroidApplication)getApplication()).getApplicationComponent(); // } // // protected ActivityModule getActivityModule() { // return new ActivityModule(this); // } // }
import android.app.Activity; import android.app.Fragment; import android.os.Bundle; import android.view.View; import butterknife.ButterKnife; import es.rogermartinez.paddlemanager.base.daggerutils.HasComponent; import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent; import es.rogermartinez.paddlemanager.base.view.activity.BaseActivity;
package es.rogermartinez.paddlemanager.base.view.fragment; /** * Created by roger.martinez on 9/10/15. */ public abstract class BaseFragment extends Fragment { @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ButterKnife.bind(this, view); }
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/daggerutils/HasComponent.java // public interface HasComponent<C> { // C getComponent(); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/BaseActivity.java // public abstract class BaseActivity extends AppCompatActivity implements ViewErrorEvent { // // @Inject // Bus bus; // // protected ViewErrorHandler viewErrorHandler; // // protected Toolbar toolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // this.getApplicationComponent().inject(this); // overridePendingTransition(R.anim.screen_fade_in, R.anim.screen_fade_out); // ButterKnife.setDebug(BuildConfig.DEBUG); // ButterKnife.bind(this); // viewErrorHandler = new ViewErrorHandler(bus, this); // } // // @Override // public void setContentView(int layoutResID) { // super.setContentView(layoutResID); // } // // // @Override // protected void onResume() { // super.onResume(); // } // // @Override // protected void onStart() { // super.onStart(); // toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // // } // // public void onError(ErrorEvent event) { // boolean redirectToLogin = ErrorEvent.ACTION_REDIRECT_TO_LOGIN == event.getAction(); // boolean needsScopes = ErrorEvent.ACTIONS_REQUEST_NEW_SCOPES == event.getAction(); // //TODO Errores // // } // protected abstract boolean showError(ErrorEvent event); // // protected ApplicationComponent getApplicationComponent() { // return ((AndroidApplication)getApplication()).getApplicationComponent(); // } // // protected ActivityModule getActivityModule() { // return new ActivityModule(this); // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/fragment/BaseFragment.java import android.app.Activity; import android.app.Fragment; import android.os.Bundle; import android.view.View; import butterknife.ButterKnife; import es.rogermartinez.paddlemanager.base.daggerutils.HasComponent; import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent; import es.rogermartinez.paddlemanager.base.view.activity.BaseActivity; package es.rogermartinez.paddlemanager.base.view.fragment; /** * Created by roger.martinez on 9/10/15. */ public abstract class BaseFragment extends Fragment { @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ButterKnife.bind(this, view); }
public abstract boolean showError(ErrorEvent event);
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/base/view/fragment/BaseFragment.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/daggerutils/HasComponent.java // public interface HasComponent<C> { // C getComponent(); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/BaseActivity.java // public abstract class BaseActivity extends AppCompatActivity implements ViewErrorEvent { // // @Inject // Bus bus; // // protected ViewErrorHandler viewErrorHandler; // // protected Toolbar toolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // this.getApplicationComponent().inject(this); // overridePendingTransition(R.anim.screen_fade_in, R.anim.screen_fade_out); // ButterKnife.setDebug(BuildConfig.DEBUG); // ButterKnife.bind(this); // viewErrorHandler = new ViewErrorHandler(bus, this); // } // // @Override // public void setContentView(int layoutResID) { // super.setContentView(layoutResID); // } // // // @Override // protected void onResume() { // super.onResume(); // } // // @Override // protected void onStart() { // super.onStart(); // toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // // } // // public void onError(ErrorEvent event) { // boolean redirectToLogin = ErrorEvent.ACTION_REDIRECT_TO_LOGIN == event.getAction(); // boolean needsScopes = ErrorEvent.ACTIONS_REQUEST_NEW_SCOPES == event.getAction(); // //TODO Errores // // } // protected abstract boolean showError(ErrorEvent event); // // protected ApplicationComponent getApplicationComponent() { // return ((AndroidApplication)getApplication()).getApplicationComponent(); // } // // protected ActivityModule getActivityModule() { // return new ActivityModule(this); // } // }
import android.app.Activity; import android.app.Fragment; import android.os.Bundle; import android.view.View; import butterknife.ButterKnife; import es.rogermartinez.paddlemanager.base.daggerutils.HasComponent; import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent; import es.rogermartinez.paddlemanager.base.view.activity.BaseActivity;
package es.rogermartinez.paddlemanager.base.view.fragment; /** * Created by roger.martinez on 9/10/15. */ public abstract class BaseFragment extends Fragment { @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ButterKnife.bind(this, view); } public abstract boolean showError(ErrorEvent event); @Override public void onResume() { super.onResume(); } @SuppressWarnings("unchecked") protected <C> C getComponent(Class<C> componentType) {
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/daggerutils/HasComponent.java // public interface HasComponent<C> { // C getComponent(); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/BaseActivity.java // public abstract class BaseActivity extends AppCompatActivity implements ViewErrorEvent { // // @Inject // Bus bus; // // protected ViewErrorHandler viewErrorHandler; // // protected Toolbar toolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // this.getApplicationComponent().inject(this); // overridePendingTransition(R.anim.screen_fade_in, R.anim.screen_fade_out); // ButterKnife.setDebug(BuildConfig.DEBUG); // ButterKnife.bind(this); // viewErrorHandler = new ViewErrorHandler(bus, this); // } // // @Override // public void setContentView(int layoutResID) { // super.setContentView(layoutResID); // } // // // @Override // protected void onResume() { // super.onResume(); // } // // @Override // protected void onStart() { // super.onStart(); // toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // // } // // public void onError(ErrorEvent event) { // boolean redirectToLogin = ErrorEvent.ACTION_REDIRECT_TO_LOGIN == event.getAction(); // boolean needsScopes = ErrorEvent.ACTIONS_REQUEST_NEW_SCOPES == event.getAction(); // //TODO Errores // // } // protected abstract boolean showError(ErrorEvent event); // // protected ApplicationComponent getApplicationComponent() { // return ((AndroidApplication)getApplication()).getApplicationComponent(); // } // // protected ActivityModule getActivityModule() { // return new ActivityModule(this); // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/fragment/BaseFragment.java import android.app.Activity; import android.app.Fragment; import android.os.Bundle; import android.view.View; import butterknife.ButterKnife; import es.rogermartinez.paddlemanager.base.daggerutils.HasComponent; import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent; import es.rogermartinez.paddlemanager.base.view.activity.BaseActivity; package es.rogermartinez.paddlemanager.base.view.fragment; /** * Created by roger.martinez on 9/10/15. */ public abstract class BaseFragment extends Fragment { @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ButterKnife.bind(this, view); } public abstract boolean showError(ErrorEvent event); @Override public void onResume() { super.onResume(); } @SuppressWarnings("unchecked") protected <C> C getComponent(Class<C> componentType) {
return componentType.cast(((HasComponent<C>) getActivity()).getComponent());
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationModule.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/MainThreadHandler.java // public class MainThreadHandler implements MainThread { // private Handler handler; // // @Inject // MainThreadHandler() { // this.handler = new Handler(Looper.getMainLooper()); // } // // @Override // public void post(Runnable runnable) { // handler.post(runnable); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/utils/module/MainThreadBus.java // public class MainThreadBus extends Bus { // private final Handler mainThread = new Handler(Looper.getMainLooper()); // // @Override // public void post(final Object event) { // if (Looper.myLooper() == Looper.getMainLooper()) { // super.post(event); // } else { // mainThread.post(new Runnable() { // @Override // public void run() { // post(event); // } // }); // } // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // }
import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.MainThreadHandler; import es.rogermartinez.paddlemanager.base.utils.module.MainThreadBus; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; import android.content.Context; import com.path.android.jobqueue.JobManager; import com.squareup.otto.Bus; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.daggerutils.ForApplication;
package es.rogermartinez.paddlemanager.injector; /* * Copyright (C) 2013 Square, Inc. * * 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. */ /** * A module for Android-specific dependencies which require a {@link android.content.Context} or * {@link android.app.Application} to create. */ @Module public class ApplicationModule {
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/MainThreadHandler.java // public class MainThreadHandler implements MainThread { // private Handler handler; // // @Inject // MainThreadHandler() { // this.handler = new Handler(Looper.getMainLooper()); // } // // @Override // public void post(Runnable runnable) { // handler.post(runnable); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/utils/module/MainThreadBus.java // public class MainThreadBus extends Bus { // private final Handler mainThread = new Handler(Looper.getMainLooper()); // // @Override // public void post(final Object event) { // if (Looper.myLooper() == Looper.getMainLooper()) { // super.post(event); // } else { // mainThread.post(new Runnable() { // @Override // public void run() { // post(event); // } // }); // } // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationModule.java import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.MainThreadHandler; import es.rogermartinez.paddlemanager.base.utils.module.MainThreadBus; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; import android.content.Context; import com.path.android.jobqueue.JobManager; import com.squareup.otto.Bus; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.daggerutils.ForApplication; package es.rogermartinez.paddlemanager.injector; /* * Copyright (C) 2013 Square, Inc. * * 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. */ /** * A module for Android-specific dependencies which require a {@link android.content.Context} or * {@link android.app.Application} to create. */ @Module public class ApplicationModule {
private final AndroidApplication application;
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationModule.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/MainThreadHandler.java // public class MainThreadHandler implements MainThread { // private Handler handler; // // @Inject // MainThreadHandler() { // this.handler = new Handler(Looper.getMainLooper()); // } // // @Override // public void post(Runnable runnable) { // handler.post(runnable); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/utils/module/MainThreadBus.java // public class MainThreadBus extends Bus { // private final Handler mainThread = new Handler(Looper.getMainLooper()); // // @Override // public void post(final Object event) { // if (Looper.myLooper() == Looper.getMainLooper()) { // super.post(event); // } else { // mainThread.post(new Runnable() { // @Override // public void run() { // post(event); // } // }); // } // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // }
import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.MainThreadHandler; import es.rogermartinez.paddlemanager.base.utils.module.MainThreadBus; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; import android.content.Context; import com.path.android.jobqueue.JobManager; import com.squareup.otto.Bus; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.daggerutils.ForApplication;
package es.rogermartinez.paddlemanager.injector; /* * Copyright (C) 2013 Square, Inc. * * 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. */ /** * A module for Android-specific dependencies which require a {@link android.content.Context} or * {@link android.app.Application} to create. */ @Module public class ApplicationModule { private final AndroidApplication application; public ApplicationModule(AndroidApplication application) { this.application = application; } @Singleton @Provides Context provideApplicationContext() { return application; } @Singleton @Provides
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/MainThreadHandler.java // public class MainThreadHandler implements MainThread { // private Handler handler; // // @Inject // MainThreadHandler() { // this.handler = new Handler(Looper.getMainLooper()); // } // // @Override // public void post(Runnable runnable) { // handler.post(runnable); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/utils/module/MainThreadBus.java // public class MainThreadBus extends Bus { // private final Handler mainThread = new Handler(Looper.getMainLooper()); // // @Override // public void post(final Object event) { // if (Looper.myLooper() == Looper.getMainLooper()) { // super.post(event); // } else { // mainThread.post(new Runnable() { // @Override // public void run() { // post(event); // } // }); // } // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationModule.java import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.MainThreadHandler; import es.rogermartinez.paddlemanager.base.utils.module.MainThreadBus; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; import android.content.Context; import com.path.android.jobqueue.JobManager; import com.squareup.otto.Bus; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.daggerutils.ForApplication; package es.rogermartinez.paddlemanager.injector; /* * Copyright (C) 2013 Square, Inc. * * 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. */ /** * A module for Android-specific dependencies which require a {@link android.content.Context} or * {@link android.app.Application} to create. */ @Module public class ApplicationModule { private final AndroidApplication application; public ApplicationModule(AndroidApplication application) { this.application = application; } @Singleton @Provides Context provideApplicationContext() { return application; } @Singleton @Provides
Bus provideBusProvider() { return new MainThreadBus(); }
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationModule.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/MainThreadHandler.java // public class MainThreadHandler implements MainThread { // private Handler handler; // // @Inject // MainThreadHandler() { // this.handler = new Handler(Looper.getMainLooper()); // } // // @Override // public void post(Runnable runnable) { // handler.post(runnable); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/utils/module/MainThreadBus.java // public class MainThreadBus extends Bus { // private final Handler mainThread = new Handler(Looper.getMainLooper()); // // @Override // public void post(final Object event) { // if (Looper.myLooper() == Looper.getMainLooper()) { // super.post(event); // } else { // mainThread.post(new Runnable() { // @Override // public void run() { // post(event); // } // }); // } // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // }
import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.MainThreadHandler; import es.rogermartinez.paddlemanager.base.utils.module.MainThreadBus; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; import android.content.Context; import com.path.android.jobqueue.JobManager; import com.squareup.otto.Bus; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.daggerutils.ForApplication;
package es.rogermartinez.paddlemanager.injector; /* * Copyright (C) 2013 Square, Inc. * * 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. */ /** * A module for Android-specific dependencies which require a {@link android.content.Context} or * {@link android.app.Application} to create. */ @Module public class ApplicationModule { private final AndroidApplication application; public ApplicationModule(AndroidApplication application) { this.application = application; } @Singleton @Provides Context provideApplicationContext() { return application; } @Singleton @Provides Bus provideBusProvider() { return new MainThreadBus(); } @Singleton @Provides JobManager provideJobManager() { return new JobManager(application); } @Singleton @Provides
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/MainThreadHandler.java // public class MainThreadHandler implements MainThread { // private Handler handler; // // @Inject // MainThreadHandler() { // this.handler = new Handler(Looper.getMainLooper()); // } // // @Override // public void post(Runnable runnable) { // handler.post(runnable); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/utils/module/MainThreadBus.java // public class MainThreadBus extends Bus { // private final Handler mainThread = new Handler(Looper.getMainLooper()); // // @Override // public void post(final Object event) { // if (Looper.myLooper() == Looper.getMainLooper()) { // super.post(event); // } else { // mainThread.post(new Runnable() { // @Override // public void run() { // post(event); // } // }); // } // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationModule.java import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.MainThreadHandler; import es.rogermartinez.paddlemanager.base.utils.module.MainThreadBus; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; import android.content.Context; import com.path.android.jobqueue.JobManager; import com.squareup.otto.Bus; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.daggerutils.ForApplication; package es.rogermartinez.paddlemanager.injector; /* * Copyright (C) 2013 Square, Inc. * * 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. */ /** * A module for Android-specific dependencies which require a {@link android.content.Context} or * {@link android.app.Application} to create. */ @Module public class ApplicationModule { private final AndroidApplication application; public ApplicationModule(AndroidApplication application) { this.application = application; } @Singleton @Provides Context provideApplicationContext() { return application; } @Singleton @Provides Bus provideBusProvider() { return new MainThreadBus(); } @Singleton @Provides JobManager provideJobManager() { return new JobManager(application); } @Singleton @Provides
MainThread provideMainThread(MainThreadHandler mainThreadHandler) {
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationModule.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/MainThreadHandler.java // public class MainThreadHandler implements MainThread { // private Handler handler; // // @Inject // MainThreadHandler() { // this.handler = new Handler(Looper.getMainLooper()); // } // // @Override // public void post(Runnable runnable) { // handler.post(runnable); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/utils/module/MainThreadBus.java // public class MainThreadBus extends Bus { // private final Handler mainThread = new Handler(Looper.getMainLooper()); // // @Override // public void post(final Object event) { // if (Looper.myLooper() == Looper.getMainLooper()) { // super.post(event); // } else { // mainThread.post(new Runnable() { // @Override // public void run() { // post(event); // } // }); // } // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // }
import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.MainThreadHandler; import es.rogermartinez.paddlemanager.base.utils.module.MainThreadBus; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; import android.content.Context; import com.path.android.jobqueue.JobManager; import com.squareup.otto.Bus; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.daggerutils.ForApplication;
package es.rogermartinez.paddlemanager.injector; /* * Copyright (C) 2013 Square, Inc. * * 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. */ /** * A module for Android-specific dependencies which require a {@link android.content.Context} or * {@link android.app.Application} to create. */ @Module public class ApplicationModule { private final AndroidApplication application; public ApplicationModule(AndroidApplication application) { this.application = application; } @Singleton @Provides Context provideApplicationContext() { return application; } @Singleton @Provides Bus provideBusProvider() { return new MainThreadBus(); } @Singleton @Provides JobManager provideJobManager() { return new JobManager(application); } @Singleton @Provides
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/MainThreadHandler.java // public class MainThreadHandler implements MainThread { // private Handler handler; // // @Inject // MainThreadHandler() { // this.handler = new Handler(Looper.getMainLooper()); // } // // @Override // public void post(Runnable runnable) { // handler.post(runnable); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/utils/module/MainThreadBus.java // public class MainThreadBus extends Bus { // private final Handler mainThread = new Handler(Looper.getMainLooper()); // // @Override // public void post(final Object event) { // if (Looper.myLooper() == Looper.getMainLooper()) { // super.post(event); // } else { // mainThread.post(new Runnable() { // @Override // public void run() { // post(event); // } // }); // } // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationModule.java import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.MainThreadHandler; import es.rogermartinez.paddlemanager.base.utils.module.MainThreadBus; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; import android.content.Context; import com.path.android.jobqueue.JobManager; import com.squareup.otto.Bus; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.daggerutils.ForApplication; package es.rogermartinez.paddlemanager.injector; /* * Copyright (C) 2013 Square, Inc. * * 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. */ /** * A module for Android-specific dependencies which require a {@link android.content.Context} or * {@link android.app.Application} to create. */ @Module public class ApplicationModule { private final AndroidApplication application; public ApplicationModule(AndroidApplication application) { this.application = application; } @Singleton @Provides Context provideApplicationContext() { return application; } @Singleton @Provides Bus provideBusProvider() { return new MainThreadBus(); } @Singleton @Provides JobManager provideJobManager() { return new JobManager(application); } @Singleton @Provides
MainThread provideMainThread(MainThreadHandler mainThreadHandler) {
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationModule.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/MainThreadHandler.java // public class MainThreadHandler implements MainThread { // private Handler handler; // // @Inject // MainThreadHandler() { // this.handler = new Handler(Looper.getMainLooper()); // } // // @Override // public void post(Runnable runnable) { // handler.post(runnable); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/utils/module/MainThreadBus.java // public class MainThreadBus extends Bus { // private final Handler mainThread = new Handler(Looper.getMainLooper()); // // @Override // public void post(final Object event) { // if (Looper.myLooper() == Looper.getMainLooper()) { // super.post(event); // } else { // mainThread.post(new Runnable() { // @Override // public void run() { // post(event); // } // }); // } // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // }
import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.MainThreadHandler; import es.rogermartinez.paddlemanager.base.utils.module.MainThreadBus; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; import android.content.Context; import com.path.android.jobqueue.JobManager; import com.squareup.otto.Bus; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.daggerutils.ForApplication;
package es.rogermartinez.paddlemanager.injector; /* * Copyright (C) 2013 Square, Inc. * * 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. */ /** * A module for Android-specific dependencies which require a {@link android.content.Context} or * {@link android.app.Application} to create. */ @Module public class ApplicationModule { private final AndroidApplication application; public ApplicationModule(AndroidApplication application) { this.application = application; } @Singleton @Provides Context provideApplicationContext() { return application; } @Singleton @Provides Bus provideBusProvider() { return new MainThreadBus(); } @Singleton @Provides JobManager provideJobManager() { return new JobManager(application); } @Singleton @Provides MainThread provideMainThread(MainThreadHandler mainThreadHandler) { return mainThreadHandler; } @Singleton @Provides
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java // public class AndroidApplication extends Application { // // private ApplicationComponent applicationComponent; // // @Override // public void onCreate() { // super.onCreate(); // Fabric.with(this, new Crashlytics()); // initializeInjector(); // } // // private void initializeInjector() { // this.applicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // // public ApplicationComponent getApplicationComponent() { // return this.applicationComponent; // } // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/MainThreadHandler.java // public class MainThreadHandler implements MainThread { // private Handler handler; // // @Inject // MainThreadHandler() { // this.handler = new Handler(Looper.getMainLooper()); // } // // @Override // public void post(Runnable runnable) { // handler.post(runnable); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/utils/module/MainThreadBus.java // public class MainThreadBus extends Bus { // private final Handler mainThread = new Handler(Looper.getMainLooper()); // // @Override // public void post(final Object event) { // if (Looper.myLooper() == Looper.getMainLooper()) { // super.post(event); // } else { // mainThread.post(new Runnable() { // @Override // public void run() { // post(event); // } // }); // } // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationModule.java import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.MainThreadHandler; import es.rogermartinez.paddlemanager.base.utils.module.MainThreadBus; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; import android.content.Context; import com.path.android.jobqueue.JobManager; import com.squareup.otto.Bus; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.application.AndroidApplication; import es.rogermartinez.paddlemanager.base.daggerutils.ForApplication; package es.rogermartinez.paddlemanager.injector; /* * Copyright (C) 2013 Square, Inc. * * 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. */ /** * A module for Android-specific dependencies which require a {@link android.content.Context} or * {@link android.app.Application} to create. */ @Module public class ApplicationModule { private final AndroidApplication application; public ApplicationModule(AndroidApplication application) { this.application = application; } @Singleton @Provides Context provideApplicationContext() { return application; } @Singleton @Provides Bus provideBusProvider() { return new MainThreadBus(); } @Singleton @Provides JobManager provideJobManager() { return new JobManager(application); } @Singleton @Provides MainThread provideMainThread(MainThreadHandler mainThreadHandler) { return mainThreadHandler; } @Singleton @Provides
public Map<QueryPlayer, QueryPlayer> provideSearchPlayersCache() {
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/UserCaseJob.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/DomainErrorHandler.java // public class DomainErrorHandler { // // private Bus bus; // // public DomainErrorHandler(Bus bus) { // this.bus = bus; // } // // public void notifyError(ErrorEvent errorObject) throws Throwable { // bus.post(errorObject); // } // // // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/GeneralErrorEvent.java // public class GeneralErrorEvent extends ErrorEvent { // // // public GeneralErrorEvent(String error) { // super(error); // } // public GeneralErrorEvent(Exception exception) { // super(exception); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // }
import com.path.android.jobqueue.Job; import com.path.android.jobqueue.JobManager; import com.path.android.jobqueue.Params; import java.util.concurrent.atomic.AtomicInteger; import es.rogermartinez.paddlemanager.base.domain.DomainErrorHandler; import es.rogermartinez.paddlemanager.base.domain.events.GeneralErrorEvent; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread;
package es.rogermartinez.paddlemanager.base.domain.interactor.impl; /** * Created by roger.martinez on 13/11/15. */ /** * @see "https://github.com/path/android-priority-jobqueue/wiki/Job-Configuration" */ public abstract class UserCaseJob extends Job { protected static final int LOW_PRIORITY = 1; protected static final int DEFAULT_PRIORITY = 2; protected static final int HIGH_PRIORITY = 3; protected static final String GROUP_HIDE_APPLICATION = "hide_application"; public static final AtomicInteger COUNTER = new AtomicInteger(0);
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/DomainErrorHandler.java // public class DomainErrorHandler { // // private Bus bus; // // public DomainErrorHandler(Bus bus) { // this.bus = bus; // } // // public void notifyError(ErrorEvent errorObject) throws Throwable { // bus.post(errorObject); // } // // // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/GeneralErrorEvent.java // public class GeneralErrorEvent extends ErrorEvent { // // // public GeneralErrorEvent(String error) { // super(error); // } // public GeneralErrorEvent(Exception exception) { // super(exception); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/UserCaseJob.java import com.path.android.jobqueue.Job; import com.path.android.jobqueue.JobManager; import com.path.android.jobqueue.Params; import java.util.concurrent.atomic.AtomicInteger; import es.rogermartinez.paddlemanager.base.domain.DomainErrorHandler; import es.rogermartinez.paddlemanager.base.domain.events.GeneralErrorEvent; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; package es.rogermartinez.paddlemanager.base.domain.interactor.impl; /** * Created by roger.martinez on 13/11/15. */ /** * @see "https://github.com/path/android-priority-jobqueue/wiki/Job-Configuration" */ public abstract class UserCaseJob extends Job { protected static final int LOW_PRIORITY = 1; protected static final int DEFAULT_PRIORITY = 2; protected static final int HIGH_PRIORITY = 3; protected static final String GROUP_HIDE_APPLICATION = "hide_application"; public static final AtomicInteger COUNTER = new AtomicInteger(0);
private final MainThread mainThread;
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/UserCaseJob.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/DomainErrorHandler.java // public class DomainErrorHandler { // // private Bus bus; // // public DomainErrorHandler(Bus bus) { // this.bus = bus; // } // // public void notifyError(ErrorEvent errorObject) throws Throwable { // bus.post(errorObject); // } // // // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/GeneralErrorEvent.java // public class GeneralErrorEvent extends ErrorEvent { // // // public GeneralErrorEvent(String error) { // super(error); // } // public GeneralErrorEvent(Exception exception) { // super(exception); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // }
import com.path.android.jobqueue.Job; import com.path.android.jobqueue.JobManager; import com.path.android.jobqueue.Params; import java.util.concurrent.atomic.AtomicInteger; import es.rogermartinez.paddlemanager.base.domain.DomainErrorHandler; import es.rogermartinez.paddlemanager.base.domain.events.GeneralErrorEvent; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread;
package es.rogermartinez.paddlemanager.base.domain.interactor.impl; /** * Created by roger.martinez on 13/11/15. */ /** * @see "https://github.com/path/android-priority-jobqueue/wiki/Job-Configuration" */ public abstract class UserCaseJob extends Job { protected static final int LOW_PRIORITY = 1; protected static final int DEFAULT_PRIORITY = 2; protected static final int HIGH_PRIORITY = 3; protected static final String GROUP_HIDE_APPLICATION = "hide_application"; public static final AtomicInteger COUNTER = new AtomicInteger(0); private final MainThread mainThread; protected JobManager jobManager;
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/DomainErrorHandler.java // public class DomainErrorHandler { // // private Bus bus; // // public DomainErrorHandler(Bus bus) { // this.bus = bus; // } // // public void notifyError(ErrorEvent errorObject) throws Throwable { // bus.post(errorObject); // } // // // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/GeneralErrorEvent.java // public class GeneralErrorEvent extends ErrorEvent { // // // public GeneralErrorEvent(String error) { // super(error); // } // public GeneralErrorEvent(Exception exception) { // super(exception); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/UserCaseJob.java import com.path.android.jobqueue.Job; import com.path.android.jobqueue.JobManager; import com.path.android.jobqueue.Params; import java.util.concurrent.atomic.AtomicInteger; import es.rogermartinez.paddlemanager.base.domain.DomainErrorHandler; import es.rogermartinez.paddlemanager.base.domain.events.GeneralErrorEvent; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; package es.rogermartinez.paddlemanager.base.domain.interactor.impl; /** * Created by roger.martinez on 13/11/15. */ /** * @see "https://github.com/path/android-priority-jobqueue/wiki/Job-Configuration" */ public abstract class UserCaseJob extends Job { protected static final int LOW_PRIORITY = 1; protected static final int DEFAULT_PRIORITY = 2; protected static final int HIGH_PRIORITY = 3; protected static final String GROUP_HIDE_APPLICATION = "hide_application"; public static final AtomicInteger COUNTER = new AtomicInteger(0); private final MainThread mainThread; protected JobManager jobManager;
protected DomainErrorHandler domainErrorHandler;
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/UserCaseJob.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/DomainErrorHandler.java // public class DomainErrorHandler { // // private Bus bus; // // public DomainErrorHandler(Bus bus) { // this.bus = bus; // } // // public void notifyError(ErrorEvent errorObject) throws Throwable { // bus.post(errorObject); // } // // // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/GeneralErrorEvent.java // public class GeneralErrorEvent extends ErrorEvent { // // // public GeneralErrorEvent(String error) { // super(error); // } // public GeneralErrorEvent(Exception exception) { // super(exception); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // }
import com.path.android.jobqueue.Job; import com.path.android.jobqueue.JobManager; import com.path.android.jobqueue.Params; import java.util.concurrent.atomic.AtomicInteger; import es.rogermartinez.paddlemanager.base.domain.DomainErrorHandler; import es.rogermartinez.paddlemanager.base.domain.events.GeneralErrorEvent; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread;
package es.rogermartinez.paddlemanager.base.domain.interactor.impl; /** * Created by roger.martinez on 13/11/15. */ /** * @see "https://github.com/path/android-priority-jobqueue/wiki/Job-Configuration" */ public abstract class UserCaseJob extends Job { protected static final int LOW_PRIORITY = 1; protected static final int DEFAULT_PRIORITY = 2; protected static final int HIGH_PRIORITY = 3; protected static final String GROUP_HIDE_APPLICATION = "hide_application"; public static final AtomicInteger COUNTER = new AtomicInteger(0); private final MainThread mainThread; protected JobManager jobManager; protected DomainErrorHandler domainErrorHandler; protected UserCaseJob(JobManager jobManager, MainThread mainThread, Params params, DomainErrorHandler domainErrorHandler) { super(params); this.jobManager = jobManager; this.mainThread = mainThread; this.domainErrorHandler = domainErrorHandler; } protected void sendCallback(Runnable callback) { mainThread.post(callback); } @Override public void onAdded() { COUNTER.incrementAndGet(); } @Override public void onRun() throws Throwable { try { //calls abstract method implemented in child UserJob. doRun(); COUNTER.decrementAndGet(); } catch (Exception e) { //CrashlyticsWrapper.logException(e); // TODO manage errors
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/DomainErrorHandler.java // public class DomainErrorHandler { // // private Bus bus; // // public DomainErrorHandler(Bus bus) { // this.bus = bus; // } // // public void notifyError(ErrorEvent errorObject) throws Throwable { // bus.post(errorObject); // } // // // // // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/GeneralErrorEvent.java // public class GeneralErrorEvent extends ErrorEvent { // // // public GeneralErrorEvent(String error) { // super(error); // } // public GeneralErrorEvent(Exception exception) { // super(exception); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/UserCaseJob.java import com.path.android.jobqueue.Job; import com.path.android.jobqueue.JobManager; import com.path.android.jobqueue.Params; import java.util.concurrent.atomic.AtomicInteger; import es.rogermartinez.paddlemanager.base.domain.DomainErrorHandler; import es.rogermartinez.paddlemanager.base.domain.events.GeneralErrorEvent; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; package es.rogermartinez.paddlemanager.base.domain.interactor.impl; /** * Created by roger.martinez on 13/11/15. */ /** * @see "https://github.com/path/android-priority-jobqueue/wiki/Job-Configuration" */ public abstract class UserCaseJob extends Job { protected static final int LOW_PRIORITY = 1; protected static final int DEFAULT_PRIORITY = 2; protected static final int HIGH_PRIORITY = 3; protected static final String GROUP_HIDE_APPLICATION = "hide_application"; public static final AtomicInteger COUNTER = new AtomicInteger(0); private final MainThread mainThread; protected JobManager jobManager; protected DomainErrorHandler domainErrorHandler; protected UserCaseJob(JobManager jobManager, MainThread mainThread, Params params, DomainErrorHandler domainErrorHandler) { super(params); this.jobManager = jobManager; this.mainThread = mainThread; this.domainErrorHandler = domainErrorHandler; } protected void sendCallback(Runnable callback) { mainThread.post(callback); } @Override public void onAdded() { COUNTER.incrementAndGet(); } @Override public void onRun() throws Throwable { try { //calls abstract method implemented in child UserJob. doRun(); COUNTER.decrementAndGet(); } catch (Exception e) { //CrashlyticsWrapper.logException(e); // TODO manage errors
domainErrorHandler.notifyError(new GeneralErrorEvent(e));
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/editplayer/view/controller/PrepareEditPlayerController.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/callback/CreatePlayerCallback.java // public interface CreatePlayerCallback { // void onCreatePlayerSuccess(); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // }
import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.editplayer.domain.callback.CreatePlayerCallback; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer;
package es.rogermartinez.paddlemanager.editplayer.view.controller; /** * Created by roger.martinez on 15/11/15. */ public class PrepareEditPlayerController { private CreatePlayer job; private View view; public void setView(View view) { this.view = view; } @Inject public PrepareEditPlayerController(CreatePlayer createPlayer){ this.job = createPlayer; } public void getPlayer(){
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/callback/CreatePlayerCallback.java // public interface CreatePlayerCallback { // void onCreatePlayerSuccess(); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/view/controller/PrepareEditPlayerController.java import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.editplayer.domain.callback.CreatePlayerCallback; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; package es.rogermartinez.paddlemanager.editplayer.view.controller; /** * Created by roger.martinez on 15/11/15. */ public class PrepareEditPlayerController { private CreatePlayer job; private View view; public void setView(View view) { this.view = view; } @Inject public PrepareEditPlayerController(CreatePlayer createPlayer){ this.job = createPlayer; } public void getPlayer(){
view.findPlayerComplete(new Player());
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/editplayer/view/controller/PrepareEditPlayerController.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/callback/CreatePlayerCallback.java // public interface CreatePlayerCallback { // void onCreatePlayerSuccess(); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // }
import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.editplayer.domain.callback.CreatePlayerCallback; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer;
package es.rogermartinez.paddlemanager.editplayer.view.controller; /** * Created by roger.martinez on 15/11/15. */ public class PrepareEditPlayerController { private CreatePlayer job; private View view; public void setView(View view) { this.view = view; } @Inject public PrepareEditPlayerController(CreatePlayer createPlayer){ this.job = createPlayer; } public void getPlayer(){ view.findPlayerComplete(new Player()); } public void createPlayer(final Player player) {
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/model/Player.java // public class Player implements Serializable { // private long id; // private String name = ""; // private int level = 0; // private int sex = 0; // private int position = 0; // private String comment = ""; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/callback/CreatePlayerCallback.java // public interface CreatePlayerCallback { // void onCreatePlayerSuccess(); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/view/controller/PrepareEditPlayerController.java import javax.inject.Inject; import es.rogermartinez.paddlemanager.base.domain.model.Player; import es.rogermartinez.paddlemanager.editplayer.domain.callback.CreatePlayerCallback; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; package es.rogermartinez.paddlemanager.editplayer.view.controller; /** * Created by roger.martinez on 15/11/15. */ public class PrepareEditPlayerController { private CreatePlayer job; private View view; public void setView(View view) { this.view = view; } @Inject public PrepareEditPlayerController(CreatePlayer createPlayer){ this.job = createPlayer; } public void getPlayer(){ view.findPlayerComplete(new Player()); } public void createPlayer(final Player player) {
job.createPlayer(player, new CreatePlayerCallback() {
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/base/datasource/dao/DatabaseHelper.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/model/PlayerDDBBModel.java // @DatabaseTable(tableName = "player") // public class PlayerDDBBModel { // // @DatabaseField(generatedId = true) // private long id; // // @DatabaseField // private String name = ""; // // @DatabaseField // private int level = 0; // // @DatabaseField // private int sex = 0; // // @DatabaseField // private int position = 0; // // @DatabaseField // private String comment = ""; // // public PlayerDDBBModel(){ // // } // // public PlayerDDBBModel(long id, String name, int level, int sex, int position, String comment){ // this.id = id; // this.name = name; // this.level = level; // this.sex = sex; // this.position = position; // this.comment = comment; // } // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // }
import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.util.Log; import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper; import com.j256.ormlite.dao.Dao; import com.j256.ormlite.support.ConnectionSource; import com.j256.ormlite.table.TableUtils; import java.sql.SQLException; import es.rogermartinez.paddlemanager.search.datasource.ddbb.model.PlayerDDBBModel;
package es.rogermartinez.paddlemanager.base.datasource.dao; public class DatabaseHelper extends OrmLiteSqliteOpenHelper { private static final String DATABASE_NAME = "paddlemanager.db"; private static final int DATABASE_VERSION = 1; // the DAO object we use to access the SimpleData table
// Path: app/src/main/java/es/rogermartinez/paddlemanager/search/datasource/ddbb/model/PlayerDDBBModel.java // @DatabaseTable(tableName = "player") // public class PlayerDDBBModel { // // @DatabaseField(generatedId = true) // private long id; // // @DatabaseField // private String name = ""; // // @DatabaseField // private int level = 0; // // @DatabaseField // private int sex = 0; // // @DatabaseField // private int position = 0; // // @DatabaseField // private String comment = ""; // // public PlayerDDBBModel(){ // // } // // public PlayerDDBBModel(long id, String name, int level, int sex, int position, String comment){ // this.id = id; // this.name = name; // this.level = level; // this.sex = sex; // this.position = position; // this.comment = comment; // } // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getLevel() { // return level; // } // // public void setLevel(int level) { // this.level = level; // } // public int getSex() { // return sex; // } // // public void setSex(int sex) { // this.sex = sex; // } // // public int getPosition() { // return position; // } // // public void setPosition(int position) { // this.position = position; // } // // public String getComment() { // return comment; // } // // public void setComment(String comment) { // this.comment = comment; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/datasource/dao/DatabaseHelper.java import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.util.Log; import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper; import com.j256.ormlite.dao.Dao; import com.j256.ormlite.support.ConnectionSource; import com.j256.ormlite.table.TableUtils; import java.sql.SQLException; import es.rogermartinez.paddlemanager.search.datasource.ddbb.model.PlayerDDBBModel; package es.rogermartinez.paddlemanager.base.datasource.dao; public class DatabaseHelper extends OrmLiteSqliteOpenHelper { private static final String DATABASE_NAME = "paddlemanager.db"; private static final int DATABASE_VERSION = 1; // the DAO object we use to access the SimpleData table
private Dao<PlayerDDBBModel, String> playersDao = null;
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorHandler.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // }
import com.squareup.otto.Bus; import com.squareup.otto.Subscribe; import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent;
package es.rogermartinez.paddlemanager.base.view.errors; /** * Created by roger.martinez on 9/10/15. */ public class ViewErrorHandler { private Bus bus; ViewErrorEvent errorEvent; public ViewErrorHandler(Bus bus, ViewErrorEvent errorEvent) { this.bus = bus; this.errorEvent = errorEvent; } public void register(){ bus.register(this); } public void unregister(){ bus.unregister(this); } @Subscribe
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/errors/ViewErrorHandler.java import com.squareup.otto.Bus; import com.squareup.otto.Subscribe; import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent; package es.rogermartinez.paddlemanager.base.view.errors; /** * Created by roger.martinez on 9/10/15. */ public class ViewErrorHandler { private Bus bus; ViewErrorEvent errorEvent; public ViewErrorHandler(Bus bus, ViewErrorEvent errorEvent) { this.bus = bus; this.errorEvent = errorEvent; } public void register(){ bus.register(this); } public void unregister(){ bus.unregister(this); } @Subscribe
public void onErrorEvent(ErrorEvent event) {
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/base/domain/GlobalDomainModule.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/datasource/dao/DatabaseHelper.java // public class DatabaseHelper extends OrmLiteSqliteOpenHelper { // // private static final String DATABASE_NAME = "paddlemanager.db"; // private static final int DATABASE_VERSION = 1; // // // the DAO object we use to access the SimpleData table // private Dao<PlayerDDBBModel, String> playersDao = null; // // public DatabaseHelper(Context context) { // super(context, DATABASE_NAME, null, DATABASE_VERSION); // } // // /** // * This is called when the database is first created. Usually you should call createTable // * statements here to create the tables that will store your data. // */ // @Override // public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource) { // try { // TableUtils.createTable(connectionSource, PlayerDDBBModel.class); // } catch (SQLException e) { // Log.e(DatabaseHelper.class.getName(), "Can't create database", e); // throw new RuntimeException(e); // } // } // // /** // * This is called when your application is upgraded and it has a higher version number. // * This allows you to adjust the various data to match the new version number. // */ // @Override // public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int oldVersion, // int newVersion) { // // } // // public void clearAllTables(){ // clearTable(PlayerDDBBModel.class); // } // // public void clearTable(Class dbClass) { // try { // TableUtils.clearTable(connectionSource, dbClass); // } catch (SQLException e) { // Log.e(DatabaseHelper.class.getName(), "Can't clean table", e); // throw new RuntimeException(e); // } // } // // /** // * Returns the Database Access Object (DAO) for our SimpleData class. It will create it or // * just give the cached value. // */ // public Dao<PlayerDDBBModel, String> getPlayersDao() throws SQLException { // if (playersDao == null) { // playersDao = getDao(PlayerDDBBModel.class); // } // return playersDao; // } // // /** // * Close the database connections and clear any cached DAOs. // */ // @Override // public void close() { // super.close(); // playersDao = null; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/datasource/dao/DatabaseManager.java // public class DatabaseManager { // private final Context context; // private DatabaseHelper databaseHelper = null; // // public DatabaseManager(Context context) { // this.context = context; // } // // //gets a helper once one is created ensures it doesnt create a new one // public DatabaseHelper getHelper() // { // if (databaseHelper == null) { // databaseHelper = // OpenHelperManager.getHelper(context, DatabaseHelper.class); // } // return databaseHelper; // } // // //releases the helper once usages has ended // public void releaseHelper(DatabaseHelper helper) // { // if (databaseHelper != null) { // OpenHelperManager.releaseHelper(); // databaseHelper = null; // } // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/MainThreadHandler.java // public class MainThreadHandler implements MainThread { // private Handler handler; // // @Inject // MainThreadHandler() { // this.handler = new Handler(Looper.getMainLooper()); // } // // @Override // public void post(Runnable runnable) { // handler.post(runnable); // } // }
import android.content.Context; import com.path.android.jobqueue.JobManager; import com.squareup.otto.Bus; import java.text.SimpleDateFormat; import java.util.Locale; import java.util.TimeZone; import javax.inject.Named; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.daggerutils.ForApplication; import es.rogermartinez.paddlemanager.base.daggerutils.PerActivity; import es.rogermartinez.paddlemanager.base.datasource.dao.DatabaseHelper; import es.rogermartinez.paddlemanager.base.datasource.dao.DatabaseManager; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.MainThreadHandler;
package es.rogermartinez.paddlemanager.base.domain; /** * This module provide global dependencies for all domain objects. */ @Module public class GlobalDomainModule { @Provides @Named("zulu_with_millis") @PerActivity SimpleDateFormat provideSimpleDateFormatZuluWithMillis() { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault()); // This is to solve problem with list offer in Zulu hour simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT0")); return simpleDateFormat; } @Provides @Named("zulu") @PerActivity SimpleDateFormat provideSimpleDateFormatZulu() { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault()); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return simpleDateFormat; } @Provides @Named("general") @PerActivity SimpleDateFormat provideSimpleDateFormatGeneral() { return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.getDefault()); } @Provides @PerActivity
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/datasource/dao/DatabaseHelper.java // public class DatabaseHelper extends OrmLiteSqliteOpenHelper { // // private static final String DATABASE_NAME = "paddlemanager.db"; // private static final int DATABASE_VERSION = 1; // // // the DAO object we use to access the SimpleData table // private Dao<PlayerDDBBModel, String> playersDao = null; // // public DatabaseHelper(Context context) { // super(context, DATABASE_NAME, null, DATABASE_VERSION); // } // // /** // * This is called when the database is first created. Usually you should call createTable // * statements here to create the tables that will store your data. // */ // @Override // public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource) { // try { // TableUtils.createTable(connectionSource, PlayerDDBBModel.class); // } catch (SQLException e) { // Log.e(DatabaseHelper.class.getName(), "Can't create database", e); // throw new RuntimeException(e); // } // } // // /** // * This is called when your application is upgraded and it has a higher version number. // * This allows you to adjust the various data to match the new version number. // */ // @Override // public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int oldVersion, // int newVersion) { // // } // // public void clearAllTables(){ // clearTable(PlayerDDBBModel.class); // } // // public void clearTable(Class dbClass) { // try { // TableUtils.clearTable(connectionSource, dbClass); // } catch (SQLException e) { // Log.e(DatabaseHelper.class.getName(), "Can't clean table", e); // throw new RuntimeException(e); // } // } // // /** // * Returns the Database Access Object (DAO) for our SimpleData class. It will create it or // * just give the cached value. // */ // public Dao<PlayerDDBBModel, String> getPlayersDao() throws SQLException { // if (playersDao == null) { // playersDao = getDao(PlayerDDBBModel.class); // } // return playersDao; // } // // /** // * Close the database connections and clear any cached DAOs. // */ // @Override // public void close() { // super.close(); // playersDao = null; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/datasource/dao/DatabaseManager.java // public class DatabaseManager { // private final Context context; // private DatabaseHelper databaseHelper = null; // // public DatabaseManager(Context context) { // this.context = context; // } // // //gets a helper once one is created ensures it doesnt create a new one // public DatabaseHelper getHelper() // { // if (databaseHelper == null) { // databaseHelper = // OpenHelperManager.getHelper(context, DatabaseHelper.class); // } // return databaseHelper; // } // // //releases the helper once usages has ended // public void releaseHelper(DatabaseHelper helper) // { // if (databaseHelper != null) { // OpenHelperManager.releaseHelper(); // databaseHelper = null; // } // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/MainThreadHandler.java // public class MainThreadHandler implements MainThread { // private Handler handler; // // @Inject // MainThreadHandler() { // this.handler = new Handler(Looper.getMainLooper()); // } // // @Override // public void post(Runnable runnable) { // handler.post(runnable); // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/GlobalDomainModule.java import android.content.Context; import com.path.android.jobqueue.JobManager; import com.squareup.otto.Bus; import java.text.SimpleDateFormat; import java.util.Locale; import java.util.TimeZone; import javax.inject.Named; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.daggerutils.ForApplication; import es.rogermartinez.paddlemanager.base.daggerutils.PerActivity; import es.rogermartinez.paddlemanager.base.datasource.dao.DatabaseHelper; import es.rogermartinez.paddlemanager.base.datasource.dao.DatabaseManager; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.MainThreadHandler; package es.rogermartinez.paddlemanager.base.domain; /** * This module provide global dependencies for all domain objects. */ @Module public class GlobalDomainModule { @Provides @Named("zulu_with_millis") @PerActivity SimpleDateFormat provideSimpleDateFormatZuluWithMillis() { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault()); // This is to solve problem with list offer in Zulu hour simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT0")); return simpleDateFormat; } @Provides @Named("zulu") @PerActivity SimpleDateFormat provideSimpleDateFormatZulu() { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault()); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return simpleDateFormat; } @Provides @Named("general") @PerActivity SimpleDateFormat provideSimpleDateFormatGeneral() { return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.getDefault()); } @Provides @PerActivity
public DatabaseManager provideDbManager(Context context) {
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/base/domain/GlobalDomainModule.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/datasource/dao/DatabaseHelper.java // public class DatabaseHelper extends OrmLiteSqliteOpenHelper { // // private static final String DATABASE_NAME = "paddlemanager.db"; // private static final int DATABASE_VERSION = 1; // // // the DAO object we use to access the SimpleData table // private Dao<PlayerDDBBModel, String> playersDao = null; // // public DatabaseHelper(Context context) { // super(context, DATABASE_NAME, null, DATABASE_VERSION); // } // // /** // * This is called when the database is first created. Usually you should call createTable // * statements here to create the tables that will store your data. // */ // @Override // public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource) { // try { // TableUtils.createTable(connectionSource, PlayerDDBBModel.class); // } catch (SQLException e) { // Log.e(DatabaseHelper.class.getName(), "Can't create database", e); // throw new RuntimeException(e); // } // } // // /** // * This is called when your application is upgraded and it has a higher version number. // * This allows you to adjust the various data to match the new version number. // */ // @Override // public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int oldVersion, // int newVersion) { // // } // // public void clearAllTables(){ // clearTable(PlayerDDBBModel.class); // } // // public void clearTable(Class dbClass) { // try { // TableUtils.clearTable(connectionSource, dbClass); // } catch (SQLException e) { // Log.e(DatabaseHelper.class.getName(), "Can't clean table", e); // throw new RuntimeException(e); // } // } // // /** // * Returns the Database Access Object (DAO) for our SimpleData class. It will create it or // * just give the cached value. // */ // public Dao<PlayerDDBBModel, String> getPlayersDao() throws SQLException { // if (playersDao == null) { // playersDao = getDao(PlayerDDBBModel.class); // } // return playersDao; // } // // /** // * Close the database connections and clear any cached DAOs. // */ // @Override // public void close() { // super.close(); // playersDao = null; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/datasource/dao/DatabaseManager.java // public class DatabaseManager { // private final Context context; // private DatabaseHelper databaseHelper = null; // // public DatabaseManager(Context context) { // this.context = context; // } // // //gets a helper once one is created ensures it doesnt create a new one // public DatabaseHelper getHelper() // { // if (databaseHelper == null) { // databaseHelper = // OpenHelperManager.getHelper(context, DatabaseHelper.class); // } // return databaseHelper; // } // // //releases the helper once usages has ended // public void releaseHelper(DatabaseHelper helper) // { // if (databaseHelper != null) { // OpenHelperManager.releaseHelper(); // databaseHelper = null; // } // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/MainThreadHandler.java // public class MainThreadHandler implements MainThread { // private Handler handler; // // @Inject // MainThreadHandler() { // this.handler = new Handler(Looper.getMainLooper()); // } // // @Override // public void post(Runnable runnable) { // handler.post(runnable); // } // }
import android.content.Context; import com.path.android.jobqueue.JobManager; import com.squareup.otto.Bus; import java.text.SimpleDateFormat; import java.util.Locale; import java.util.TimeZone; import javax.inject.Named; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.daggerutils.ForApplication; import es.rogermartinez.paddlemanager.base.daggerutils.PerActivity; import es.rogermartinez.paddlemanager.base.datasource.dao.DatabaseHelper; import es.rogermartinez.paddlemanager.base.datasource.dao.DatabaseManager; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.MainThreadHandler;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault()); // This is to solve problem with list offer in Zulu hour simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT0")); return simpleDateFormat; } @Provides @Named("zulu") @PerActivity SimpleDateFormat provideSimpleDateFormatZulu() { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault()); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return simpleDateFormat; } @Provides @Named("general") @PerActivity SimpleDateFormat provideSimpleDateFormatGeneral() { return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.getDefault()); } @Provides @PerActivity public DatabaseManager provideDbManager(Context context) { return new DatabaseManager(context); } @Provides @PerActivity
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/datasource/dao/DatabaseHelper.java // public class DatabaseHelper extends OrmLiteSqliteOpenHelper { // // private static final String DATABASE_NAME = "paddlemanager.db"; // private static final int DATABASE_VERSION = 1; // // // the DAO object we use to access the SimpleData table // private Dao<PlayerDDBBModel, String> playersDao = null; // // public DatabaseHelper(Context context) { // super(context, DATABASE_NAME, null, DATABASE_VERSION); // } // // /** // * This is called when the database is first created. Usually you should call createTable // * statements here to create the tables that will store your data. // */ // @Override // public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource) { // try { // TableUtils.createTable(connectionSource, PlayerDDBBModel.class); // } catch (SQLException e) { // Log.e(DatabaseHelper.class.getName(), "Can't create database", e); // throw new RuntimeException(e); // } // } // // /** // * This is called when your application is upgraded and it has a higher version number. // * This allows you to adjust the various data to match the new version number. // */ // @Override // public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int oldVersion, // int newVersion) { // // } // // public void clearAllTables(){ // clearTable(PlayerDDBBModel.class); // } // // public void clearTable(Class dbClass) { // try { // TableUtils.clearTable(connectionSource, dbClass); // } catch (SQLException e) { // Log.e(DatabaseHelper.class.getName(), "Can't clean table", e); // throw new RuntimeException(e); // } // } // // /** // * Returns the Database Access Object (DAO) for our SimpleData class. It will create it or // * just give the cached value. // */ // public Dao<PlayerDDBBModel, String> getPlayersDao() throws SQLException { // if (playersDao == null) { // playersDao = getDao(PlayerDDBBModel.class); // } // return playersDao; // } // // /** // * Close the database connections and clear any cached DAOs. // */ // @Override // public void close() { // super.close(); // playersDao = null; // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/datasource/dao/DatabaseManager.java // public class DatabaseManager { // private final Context context; // private DatabaseHelper databaseHelper = null; // // public DatabaseManager(Context context) { // this.context = context; // } // // //gets a helper once one is created ensures it doesnt create a new one // public DatabaseHelper getHelper() // { // if (databaseHelper == null) { // databaseHelper = // OpenHelperManager.getHelper(context, DatabaseHelper.class); // } // return databaseHelper; // } // // //releases the helper once usages has ended // public void releaseHelper(DatabaseHelper helper) // { // if (databaseHelper != null) { // OpenHelperManager.releaseHelper(); // databaseHelper = null; // } // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/impl/MainThreadHandler.java // public class MainThreadHandler implements MainThread { // private Handler handler; // // @Inject // MainThreadHandler() { // this.handler = new Handler(Looper.getMainLooper()); // } // // @Override // public void post(Runnable runnable) { // handler.post(runnable); // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/GlobalDomainModule.java import android.content.Context; import com.path.android.jobqueue.JobManager; import com.squareup.otto.Bus; import java.text.SimpleDateFormat; import java.util.Locale; import java.util.TimeZone; import javax.inject.Named; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.daggerutils.ForApplication; import es.rogermartinez.paddlemanager.base.daggerutils.PerActivity; import es.rogermartinez.paddlemanager.base.datasource.dao.DatabaseHelper; import es.rogermartinez.paddlemanager.base.datasource.dao.DatabaseManager; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.domain.interactor.impl.MainThreadHandler; SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault()); // This is to solve problem with list offer in Zulu hour simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT0")); return simpleDateFormat; } @Provides @Named("zulu") @PerActivity SimpleDateFormat provideSimpleDateFormatZulu() { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault()); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return simpleDateFormat; } @Provides @Named("general") @PerActivity SimpleDateFormat provideSimpleDateFormatGeneral() { return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.getDefault()); } @Provides @PerActivity public DatabaseManager provideDbManager(Context context) { return new DatabaseManager(context); } @Provides @PerActivity
public DatabaseHelper provideDataBaseHelper(DatabaseManager dbManager) {
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/editplayer/datasource/EditPlayerDatasourceModule.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/datasource/db/impl/CreatePlayerDataSourceImpl.java // public class CreatePlayerDataSourceImpl implements CreatePlayerDataSource { // // private Dao<PlayerDDBBModel, String> playerDao; // // @Inject // public CreatePlayerDataSourceImpl(Dao<PlayerDDBBModel, String> playerDao){ // this.playerDao = playerDao; // } // // @Override // public void createPlayer(Player player) { // try { // playerDao.create(mapperPlayer(player)); // } catch (SQLException e) { // e.printStackTrace(); // } // } // // private PlayerDDBBModel mapperPlayer(Player player) { // PlayerDDBBModel p = new PlayerDDBBModel(player.getId(), player.getName(), player.getLevel(), player.getSex(), player.getPosition(), player.getComment()); // return p; // } // }
import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.editplayer.datasource.db.impl.CreatePlayerDataSourceImpl;
package es.rogermartinez.paddlemanager.editplayer.datasource; /** * Created by roger.martinez on 17/11/15. */ @Module public class EditPlayerDatasourceModule { @Provides
// Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/datasource/db/impl/CreatePlayerDataSourceImpl.java // public class CreatePlayerDataSourceImpl implements CreatePlayerDataSource { // // private Dao<PlayerDDBBModel, String> playerDao; // // @Inject // public CreatePlayerDataSourceImpl(Dao<PlayerDDBBModel, String> playerDao){ // this.playerDao = playerDao; // } // // @Override // public void createPlayer(Player player) { // try { // playerDao.create(mapperPlayer(player)); // } catch (SQLException e) { // e.printStackTrace(); // } // } // // private PlayerDDBBModel mapperPlayer(Player player) { // PlayerDDBBModel p = new PlayerDDBBModel(player.getId(), player.getName(), player.getLevel(), player.getSex(), player.getPosition(), player.getComment()); // return p; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/datasource/EditPlayerDatasourceModule.java import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.editplayer.datasource.db.impl.CreatePlayerDataSourceImpl; package es.rogermartinez.paddlemanager.editplayer.datasource; /** * Created by roger.martinez on 17/11/15. */ @Module public class EditPlayerDatasourceModule { @Provides
public CreatePlayerDataSource providesCreatePlayerDataSource(CreatePlayerDataSourceImpl dataSource){
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/injector/ActivityModule.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/DomainErrorHandler.java // public class DomainErrorHandler { // // private Bus bus; // // public DomainErrorHandler(Bus bus) { // this.bus = bus; // } // // public void notifyError(ErrorEvent errorObject) throws Throwable { // bus.post(errorObject); // } // // // // // }
import android.app.Activity; import com.squareup.otto.Bus; import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.daggerutils.PerActivity; import es.rogermartinez.paddlemanager.base.domain.DomainErrorHandler;
package es.rogermartinez.paddlemanager.injector; /** * Created by roger on 17/5/16. */ @Module public class ActivityModule { private final Activity activity; public ActivityModule(Activity activity){ this.activity = activity; } @Provides @PerActivity Activity provideActivity(){ return activity; } @Provides @PerActivity
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/DomainErrorHandler.java // public class DomainErrorHandler { // // private Bus bus; // // public DomainErrorHandler(Bus bus) { // this.bus = bus; // } // // public void notifyError(ErrorEvent errorObject) throws Throwable { // bus.post(errorObject); // } // // // // // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ActivityModule.java import android.app.Activity; import com.squareup.otto.Bus; import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.base.daggerutils.PerActivity; import es.rogermartinez.paddlemanager.base.domain.DomainErrorHandler; package es.rogermartinez.paddlemanager.injector; /** * Created by roger on 17/5/16. */ @Module public class ActivityModule { private final Activity activity; public ActivityModule(Activity activity){ this.activity = activity; } @Provides @PerActivity Activity provideActivity(){ return activity; } @Provides @PerActivity
DomainErrorHandler provideDomainErrorHandler(Bus bus) {
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationComponent.java // @Singleton // @Component(modules = ApplicationModule.class) // public interface ApplicationComponent { // void inject(BaseActivity baseActivity); // // // Exposed to sub-graphs // Context getContext(); // Bus getBusProvider(); // JobManager getJobManager(); // MainThread getMainThread(); // //Map<QueryPlayer, QueryPlayer> getSearchPlayersCache(); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationModule.java // @Module // public class ApplicationModule { // private final AndroidApplication application; // // public ApplicationModule(AndroidApplication application) { // this.application = application; // } // // @Singleton // @Provides // Context provideApplicationContext() { // return application; // } // // @Singleton // @Provides // Bus provideBusProvider() { return new MainThreadBus(); } // // @Singleton // @Provides // JobManager provideJobManager() { // return new JobManager(application); // } // // @Singleton // @Provides // MainThread provideMainThread(MainThreadHandler mainThreadHandler) { // return mainThreadHandler; // } // // @Singleton // @Provides // public Map<QueryPlayer, QueryPlayer> provideSearchPlayersCache() { // return new ConcurrentHashMap<QueryPlayer, QueryPlayer>(); // } // }
import android.app.Application; import com.crashlytics.android.Crashlytics; import es.rogermartinez.paddlemanager.injector.ApplicationComponent; import es.rogermartinez.paddlemanager.injector.ApplicationModule; import es.rogermartinez.paddlemanager.injector.DaggerApplicationComponent; import io.fabric.sdk.android.Fabric;
package es.rogermartinez.paddlemanager.base.application; public class AndroidApplication extends Application { private ApplicationComponent applicationComponent; @Override public void onCreate() { super.onCreate(); Fabric.with(this, new Crashlytics()); initializeInjector(); } private void initializeInjector() { this.applicationComponent = DaggerApplicationComponent.builder()
// Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationComponent.java // @Singleton // @Component(modules = ApplicationModule.class) // public interface ApplicationComponent { // void inject(BaseActivity baseActivity); // // // Exposed to sub-graphs // Context getContext(); // Bus getBusProvider(); // JobManager getJobManager(); // MainThread getMainThread(); // //Map<QueryPlayer, QueryPlayer> getSearchPlayersCache(); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationModule.java // @Module // public class ApplicationModule { // private final AndroidApplication application; // // public ApplicationModule(AndroidApplication application) { // this.application = application; // } // // @Singleton // @Provides // Context provideApplicationContext() { // return application; // } // // @Singleton // @Provides // Bus provideBusProvider() { return new MainThreadBus(); } // // @Singleton // @Provides // JobManager provideJobManager() { // return new JobManager(application); // } // // @Singleton // @Provides // MainThread provideMainThread(MainThreadHandler mainThreadHandler) { // return mainThreadHandler; // } // // @Singleton // @Provides // public Map<QueryPlayer, QueryPlayer> provideSearchPlayersCache() { // return new ConcurrentHashMap<QueryPlayer, QueryPlayer>(); // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/application/AndroidApplication.java import android.app.Application; import com.crashlytics.android.Crashlytics; import es.rogermartinez.paddlemanager.injector.ApplicationComponent; import es.rogermartinez.paddlemanager.injector.ApplicationModule; import es.rogermartinez.paddlemanager.injector.DaggerApplicationComponent; import io.fabric.sdk.android.Fabric; package es.rogermartinez.paddlemanager.base.application; public class AndroidApplication extends Application { private ApplicationComponent applicationComponent; @Override public void onCreate() { super.onCreate(); Fabric.with(this, new Crashlytics()); initializeInjector(); } private void initializeInjector() { this.applicationComponent = DaggerApplicationComponent.builder()
.applicationModule(new ApplicationModule(this))
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationComponent.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/BaseActivity.java // public abstract class BaseActivity extends AppCompatActivity implements ViewErrorEvent { // // @Inject // Bus bus; // // protected ViewErrorHandler viewErrorHandler; // // protected Toolbar toolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // this.getApplicationComponent().inject(this); // overridePendingTransition(R.anim.screen_fade_in, R.anim.screen_fade_out); // ButterKnife.setDebug(BuildConfig.DEBUG); // ButterKnife.bind(this); // viewErrorHandler = new ViewErrorHandler(bus, this); // } // // @Override // public void setContentView(int layoutResID) { // super.setContentView(layoutResID); // } // // // @Override // protected void onResume() { // super.onResume(); // } // // @Override // protected void onStart() { // super.onStart(); // toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // // } // // public void onError(ErrorEvent event) { // boolean redirectToLogin = ErrorEvent.ACTION_REDIRECT_TO_LOGIN == event.getAction(); // boolean needsScopes = ErrorEvent.ACTIONS_REQUEST_NEW_SCOPES == event.getAction(); // //TODO Errores // // } // protected abstract boolean showError(ErrorEvent event); // // protected ApplicationComponent getApplicationComponent() { // return ((AndroidApplication)getApplication()).getApplicationComponent(); // } // // protected ActivityModule getActivityModule() { // return new ActivityModule(this); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // }
import android.content.Context; import com.path.android.jobqueue.JobManager; import com.squareup.otto.Bus; import java.util.Map; import javax.inject.Singleton; import dagger.Component; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.view.activity.BaseActivity; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer;
package es.rogermartinez.paddlemanager.injector; /** * Created by roger on 17/5/16. */ @Singleton @Component(modules = ApplicationModule.class) public interface ApplicationComponent {
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/BaseActivity.java // public abstract class BaseActivity extends AppCompatActivity implements ViewErrorEvent { // // @Inject // Bus bus; // // protected ViewErrorHandler viewErrorHandler; // // protected Toolbar toolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // this.getApplicationComponent().inject(this); // overridePendingTransition(R.anim.screen_fade_in, R.anim.screen_fade_out); // ButterKnife.setDebug(BuildConfig.DEBUG); // ButterKnife.bind(this); // viewErrorHandler = new ViewErrorHandler(bus, this); // } // // @Override // public void setContentView(int layoutResID) { // super.setContentView(layoutResID); // } // // // @Override // protected void onResume() { // super.onResume(); // } // // @Override // protected void onStart() { // super.onStart(); // toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // // } // // public void onError(ErrorEvent event) { // boolean redirectToLogin = ErrorEvent.ACTION_REDIRECT_TO_LOGIN == event.getAction(); // boolean needsScopes = ErrorEvent.ACTIONS_REQUEST_NEW_SCOPES == event.getAction(); // //TODO Errores // // } // protected abstract boolean showError(ErrorEvent event); // // protected ApplicationComponent getApplicationComponent() { // return ((AndroidApplication)getApplication()).getApplicationComponent(); // } // // protected ActivityModule getActivityModule() { // return new ActivityModule(this); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationComponent.java import android.content.Context; import com.path.android.jobqueue.JobManager; import com.squareup.otto.Bus; import java.util.Map; import javax.inject.Singleton; import dagger.Component; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.view.activity.BaseActivity; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; package es.rogermartinez.paddlemanager.injector; /** * Created by roger on 17/5/16. */ @Singleton @Component(modules = ApplicationModule.class) public interface ApplicationComponent {
void inject(BaseActivity baseActivity);
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationComponent.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/BaseActivity.java // public abstract class BaseActivity extends AppCompatActivity implements ViewErrorEvent { // // @Inject // Bus bus; // // protected ViewErrorHandler viewErrorHandler; // // protected Toolbar toolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // this.getApplicationComponent().inject(this); // overridePendingTransition(R.anim.screen_fade_in, R.anim.screen_fade_out); // ButterKnife.setDebug(BuildConfig.DEBUG); // ButterKnife.bind(this); // viewErrorHandler = new ViewErrorHandler(bus, this); // } // // @Override // public void setContentView(int layoutResID) { // super.setContentView(layoutResID); // } // // // @Override // protected void onResume() { // super.onResume(); // } // // @Override // protected void onStart() { // super.onStart(); // toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // // } // // public void onError(ErrorEvent event) { // boolean redirectToLogin = ErrorEvent.ACTION_REDIRECT_TO_LOGIN == event.getAction(); // boolean needsScopes = ErrorEvent.ACTIONS_REQUEST_NEW_SCOPES == event.getAction(); // //TODO Errores // // } // protected abstract boolean showError(ErrorEvent event); // // protected ApplicationComponent getApplicationComponent() { // return ((AndroidApplication)getApplication()).getApplicationComponent(); // } // // protected ActivityModule getActivityModule() { // return new ActivityModule(this); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // }
import android.content.Context; import com.path.android.jobqueue.JobManager; import com.squareup.otto.Bus; import java.util.Map; import javax.inject.Singleton; import dagger.Component; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.view.activity.BaseActivity; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer;
package es.rogermartinez.paddlemanager.injector; /** * Created by roger on 17/5/16. */ @Singleton @Component(modules = ApplicationModule.class) public interface ApplicationComponent { void inject(BaseActivity baseActivity); // Exposed to sub-graphs Context getContext(); Bus getBusProvider(); JobManager getJobManager();
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/interactor/MainThread.java // public interface MainThread { // void post(Runnable runnable); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/view/activity/BaseActivity.java // public abstract class BaseActivity extends AppCompatActivity implements ViewErrorEvent { // // @Inject // Bus bus; // // protected ViewErrorHandler viewErrorHandler; // // protected Toolbar toolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // this.getApplicationComponent().inject(this); // overridePendingTransition(R.anim.screen_fade_in, R.anim.screen_fade_out); // ButterKnife.setDebug(BuildConfig.DEBUG); // ButterKnife.bind(this); // viewErrorHandler = new ViewErrorHandler(bus, this); // } // // @Override // public void setContentView(int layoutResID) { // super.setContentView(layoutResID); // } // // // @Override // protected void onResume() { // super.onResume(); // } // // @Override // protected void onStart() { // super.onStart(); // toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // // } // // public void onError(ErrorEvent event) { // boolean redirectToLogin = ErrorEvent.ACTION_REDIRECT_TO_LOGIN == event.getAction(); // boolean needsScopes = ErrorEvent.ACTIONS_REQUEST_NEW_SCOPES == event.getAction(); // //TODO Errores // // } // protected abstract boolean showError(ErrorEvent event); // // protected ApplicationComponent getApplicationComponent() { // return ((AndroidApplication)getApplication()).getApplicationComponent(); // } // // protected ActivityModule getActivityModule() { // return new ActivityModule(this); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/search/domain/model/QueryPlayer.java // public class QueryPlayer { // // private String name; // private String surname; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getSurname() { // return surname; // } // // public void setSurname(String surname) { // this.surname = surname; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/injector/ApplicationComponent.java import android.content.Context; import com.path.android.jobqueue.JobManager; import com.squareup.otto.Bus; import java.util.Map; import javax.inject.Singleton; import dagger.Component; import es.rogermartinez.paddlemanager.base.domain.interactor.MainThread; import es.rogermartinez.paddlemanager.base.view.activity.BaseActivity; import es.rogermartinez.paddlemanager.search.domain.model.QueryPlayer; package es.rogermartinez.paddlemanager.injector; /** * Created by roger on 17/5/16. */ @Singleton @Component(modules = ApplicationModule.class) public interface ApplicationComponent { void inject(BaseActivity baseActivity); // Exposed to sub-graphs Context getContext(); Bus getBusProvider(); JobManager getJobManager();
MainThread getMainThread();
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/EditPlayerDomainModule.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/DeletePlayer.java // public interface DeletePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/SelectPlayer.java // public interface SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/UpdatePlayer.java // public interface UpdatePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java // public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { // // private Player player; // private CreatePlayerCallback callback; // private CreatePlayerDataSource createPlayerDataSource; // // @Inject // public CreatePlayerJob(JobManager jobManager, MainThread mainThread, // DomainErrorHandler domainErrorHandler, CreatePlayerDataSource createPlayerDataSource){ // super(jobManager, mainThread, new Params(UserCaseJob.DEFAULT_PRIORITY).setRequiresNetwork(false), domainErrorHandler); // this.createPlayerDataSource = createPlayerDataSource; // } // // // @Override // public void doRun() throws Throwable { // createPlayerDataSource.createPlayer(player); // notifyPlayerCreated(); // } // // public void createPlayer(Player player, CreatePlayerCallback callback){ // this.player = player; // this.callback = callback; // jobManager.addJob(this); // } // // private void notifyPlayerCreated(){ // sendCallback(new Runnable() { // @Override // public void run() { // callback.onCreatePlayerSuccess(); // } // }); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/SelectPlayerJob.java // public class SelectPlayerJob implements SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/UpdatePlayerJob.java // public class UpdatePlayerJob implements UpdatePlayer { // // }
import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.DeletePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.SelectPlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.UpdatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.CreatePlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.SelectPlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.UpdatePlayerJob;
package es.rogermartinez.paddlemanager.editplayer.domain; /** * Created by roger.martinez on 17/11/15. */ @Module public class EditPlayerDomainModule { @Provides
// Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/DeletePlayer.java // public interface DeletePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/SelectPlayer.java // public interface SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/UpdatePlayer.java // public interface UpdatePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java // public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { // // private Player player; // private CreatePlayerCallback callback; // private CreatePlayerDataSource createPlayerDataSource; // // @Inject // public CreatePlayerJob(JobManager jobManager, MainThread mainThread, // DomainErrorHandler domainErrorHandler, CreatePlayerDataSource createPlayerDataSource){ // super(jobManager, mainThread, new Params(UserCaseJob.DEFAULT_PRIORITY).setRequiresNetwork(false), domainErrorHandler); // this.createPlayerDataSource = createPlayerDataSource; // } // // // @Override // public void doRun() throws Throwable { // createPlayerDataSource.createPlayer(player); // notifyPlayerCreated(); // } // // public void createPlayer(Player player, CreatePlayerCallback callback){ // this.player = player; // this.callback = callback; // jobManager.addJob(this); // } // // private void notifyPlayerCreated(){ // sendCallback(new Runnable() { // @Override // public void run() { // callback.onCreatePlayerSuccess(); // } // }); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/SelectPlayerJob.java // public class SelectPlayerJob implements SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/UpdatePlayerJob.java // public class UpdatePlayerJob implements UpdatePlayer { // // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/EditPlayerDomainModule.java import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.DeletePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.SelectPlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.UpdatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.CreatePlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.SelectPlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.UpdatePlayerJob; package es.rogermartinez.paddlemanager.editplayer.domain; /** * Created by roger.martinez on 17/11/15. */ @Module public class EditPlayerDomainModule { @Provides
public SelectPlayer providesSelectPlayer(SelectPlayerJob job){
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/EditPlayerDomainModule.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/DeletePlayer.java // public interface DeletePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/SelectPlayer.java // public interface SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/UpdatePlayer.java // public interface UpdatePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java // public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { // // private Player player; // private CreatePlayerCallback callback; // private CreatePlayerDataSource createPlayerDataSource; // // @Inject // public CreatePlayerJob(JobManager jobManager, MainThread mainThread, // DomainErrorHandler domainErrorHandler, CreatePlayerDataSource createPlayerDataSource){ // super(jobManager, mainThread, new Params(UserCaseJob.DEFAULT_PRIORITY).setRequiresNetwork(false), domainErrorHandler); // this.createPlayerDataSource = createPlayerDataSource; // } // // // @Override // public void doRun() throws Throwable { // createPlayerDataSource.createPlayer(player); // notifyPlayerCreated(); // } // // public void createPlayer(Player player, CreatePlayerCallback callback){ // this.player = player; // this.callback = callback; // jobManager.addJob(this); // } // // private void notifyPlayerCreated(){ // sendCallback(new Runnable() { // @Override // public void run() { // callback.onCreatePlayerSuccess(); // } // }); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/SelectPlayerJob.java // public class SelectPlayerJob implements SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/UpdatePlayerJob.java // public class UpdatePlayerJob implements UpdatePlayer { // // }
import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.DeletePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.SelectPlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.UpdatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.CreatePlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.SelectPlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.UpdatePlayerJob;
package es.rogermartinez.paddlemanager.editplayer.domain; /** * Created by roger.martinez on 17/11/15. */ @Module public class EditPlayerDomainModule { @Provides
// Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/DeletePlayer.java // public interface DeletePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/SelectPlayer.java // public interface SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/UpdatePlayer.java // public interface UpdatePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java // public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { // // private Player player; // private CreatePlayerCallback callback; // private CreatePlayerDataSource createPlayerDataSource; // // @Inject // public CreatePlayerJob(JobManager jobManager, MainThread mainThread, // DomainErrorHandler domainErrorHandler, CreatePlayerDataSource createPlayerDataSource){ // super(jobManager, mainThread, new Params(UserCaseJob.DEFAULT_PRIORITY).setRequiresNetwork(false), domainErrorHandler); // this.createPlayerDataSource = createPlayerDataSource; // } // // // @Override // public void doRun() throws Throwable { // createPlayerDataSource.createPlayer(player); // notifyPlayerCreated(); // } // // public void createPlayer(Player player, CreatePlayerCallback callback){ // this.player = player; // this.callback = callback; // jobManager.addJob(this); // } // // private void notifyPlayerCreated(){ // sendCallback(new Runnable() { // @Override // public void run() { // callback.onCreatePlayerSuccess(); // } // }); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/SelectPlayerJob.java // public class SelectPlayerJob implements SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/UpdatePlayerJob.java // public class UpdatePlayerJob implements UpdatePlayer { // // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/EditPlayerDomainModule.java import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.DeletePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.SelectPlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.UpdatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.CreatePlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.SelectPlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.UpdatePlayerJob; package es.rogermartinez.paddlemanager.editplayer.domain; /** * Created by roger.martinez on 17/11/15. */ @Module public class EditPlayerDomainModule { @Provides
public SelectPlayer providesSelectPlayer(SelectPlayerJob job){
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/EditPlayerDomainModule.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/DeletePlayer.java // public interface DeletePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/SelectPlayer.java // public interface SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/UpdatePlayer.java // public interface UpdatePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java // public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { // // private Player player; // private CreatePlayerCallback callback; // private CreatePlayerDataSource createPlayerDataSource; // // @Inject // public CreatePlayerJob(JobManager jobManager, MainThread mainThread, // DomainErrorHandler domainErrorHandler, CreatePlayerDataSource createPlayerDataSource){ // super(jobManager, mainThread, new Params(UserCaseJob.DEFAULT_PRIORITY).setRequiresNetwork(false), domainErrorHandler); // this.createPlayerDataSource = createPlayerDataSource; // } // // // @Override // public void doRun() throws Throwable { // createPlayerDataSource.createPlayer(player); // notifyPlayerCreated(); // } // // public void createPlayer(Player player, CreatePlayerCallback callback){ // this.player = player; // this.callback = callback; // jobManager.addJob(this); // } // // private void notifyPlayerCreated(){ // sendCallback(new Runnable() { // @Override // public void run() { // callback.onCreatePlayerSuccess(); // } // }); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/SelectPlayerJob.java // public class SelectPlayerJob implements SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/UpdatePlayerJob.java // public class UpdatePlayerJob implements UpdatePlayer { // // }
import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.DeletePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.SelectPlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.UpdatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.CreatePlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.SelectPlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.UpdatePlayerJob;
package es.rogermartinez.paddlemanager.editplayer.domain; /** * Created by roger.martinez on 17/11/15. */ @Module public class EditPlayerDomainModule { @Provides public SelectPlayer providesSelectPlayer(SelectPlayerJob job){ return job; } @Provides
// Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/DeletePlayer.java // public interface DeletePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/SelectPlayer.java // public interface SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/UpdatePlayer.java // public interface UpdatePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java // public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { // // private Player player; // private CreatePlayerCallback callback; // private CreatePlayerDataSource createPlayerDataSource; // // @Inject // public CreatePlayerJob(JobManager jobManager, MainThread mainThread, // DomainErrorHandler domainErrorHandler, CreatePlayerDataSource createPlayerDataSource){ // super(jobManager, mainThread, new Params(UserCaseJob.DEFAULT_PRIORITY).setRequiresNetwork(false), domainErrorHandler); // this.createPlayerDataSource = createPlayerDataSource; // } // // // @Override // public void doRun() throws Throwable { // createPlayerDataSource.createPlayer(player); // notifyPlayerCreated(); // } // // public void createPlayer(Player player, CreatePlayerCallback callback){ // this.player = player; // this.callback = callback; // jobManager.addJob(this); // } // // private void notifyPlayerCreated(){ // sendCallback(new Runnable() { // @Override // public void run() { // callback.onCreatePlayerSuccess(); // } // }); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/SelectPlayerJob.java // public class SelectPlayerJob implements SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/UpdatePlayerJob.java // public class UpdatePlayerJob implements UpdatePlayer { // // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/EditPlayerDomainModule.java import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.DeletePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.SelectPlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.UpdatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.CreatePlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.SelectPlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.UpdatePlayerJob; package es.rogermartinez.paddlemanager.editplayer.domain; /** * Created by roger.martinez on 17/11/15. */ @Module public class EditPlayerDomainModule { @Provides public SelectPlayer providesSelectPlayer(SelectPlayerJob job){ return job; } @Provides
public UpdatePlayer providesUpdatePlayer(UpdatePlayerJob job){
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/EditPlayerDomainModule.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/DeletePlayer.java // public interface DeletePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/SelectPlayer.java // public interface SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/UpdatePlayer.java // public interface UpdatePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java // public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { // // private Player player; // private CreatePlayerCallback callback; // private CreatePlayerDataSource createPlayerDataSource; // // @Inject // public CreatePlayerJob(JobManager jobManager, MainThread mainThread, // DomainErrorHandler domainErrorHandler, CreatePlayerDataSource createPlayerDataSource){ // super(jobManager, mainThread, new Params(UserCaseJob.DEFAULT_PRIORITY).setRequiresNetwork(false), domainErrorHandler); // this.createPlayerDataSource = createPlayerDataSource; // } // // // @Override // public void doRun() throws Throwable { // createPlayerDataSource.createPlayer(player); // notifyPlayerCreated(); // } // // public void createPlayer(Player player, CreatePlayerCallback callback){ // this.player = player; // this.callback = callback; // jobManager.addJob(this); // } // // private void notifyPlayerCreated(){ // sendCallback(new Runnable() { // @Override // public void run() { // callback.onCreatePlayerSuccess(); // } // }); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/SelectPlayerJob.java // public class SelectPlayerJob implements SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/UpdatePlayerJob.java // public class UpdatePlayerJob implements UpdatePlayer { // // }
import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.DeletePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.SelectPlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.UpdatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.CreatePlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.SelectPlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.UpdatePlayerJob;
package es.rogermartinez.paddlemanager.editplayer.domain; /** * Created by roger.martinez on 17/11/15. */ @Module public class EditPlayerDomainModule { @Provides public SelectPlayer providesSelectPlayer(SelectPlayerJob job){ return job; } @Provides
// Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/DeletePlayer.java // public interface DeletePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/SelectPlayer.java // public interface SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/UpdatePlayer.java // public interface UpdatePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java // public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { // // private Player player; // private CreatePlayerCallback callback; // private CreatePlayerDataSource createPlayerDataSource; // // @Inject // public CreatePlayerJob(JobManager jobManager, MainThread mainThread, // DomainErrorHandler domainErrorHandler, CreatePlayerDataSource createPlayerDataSource){ // super(jobManager, mainThread, new Params(UserCaseJob.DEFAULT_PRIORITY).setRequiresNetwork(false), domainErrorHandler); // this.createPlayerDataSource = createPlayerDataSource; // } // // // @Override // public void doRun() throws Throwable { // createPlayerDataSource.createPlayer(player); // notifyPlayerCreated(); // } // // public void createPlayer(Player player, CreatePlayerCallback callback){ // this.player = player; // this.callback = callback; // jobManager.addJob(this); // } // // private void notifyPlayerCreated(){ // sendCallback(new Runnable() { // @Override // public void run() { // callback.onCreatePlayerSuccess(); // } // }); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/SelectPlayerJob.java // public class SelectPlayerJob implements SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/UpdatePlayerJob.java // public class UpdatePlayerJob implements UpdatePlayer { // // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/EditPlayerDomainModule.java import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.DeletePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.SelectPlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.UpdatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.CreatePlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.SelectPlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.UpdatePlayerJob; package es.rogermartinez.paddlemanager.editplayer.domain; /** * Created by roger.martinez on 17/11/15. */ @Module public class EditPlayerDomainModule { @Provides public SelectPlayer providesSelectPlayer(SelectPlayerJob job){ return job; } @Provides
public UpdatePlayer providesUpdatePlayer(UpdatePlayerJob job){
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/EditPlayerDomainModule.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/DeletePlayer.java // public interface DeletePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/SelectPlayer.java // public interface SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/UpdatePlayer.java // public interface UpdatePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java // public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { // // private Player player; // private CreatePlayerCallback callback; // private CreatePlayerDataSource createPlayerDataSource; // // @Inject // public CreatePlayerJob(JobManager jobManager, MainThread mainThread, // DomainErrorHandler domainErrorHandler, CreatePlayerDataSource createPlayerDataSource){ // super(jobManager, mainThread, new Params(UserCaseJob.DEFAULT_PRIORITY).setRequiresNetwork(false), domainErrorHandler); // this.createPlayerDataSource = createPlayerDataSource; // } // // // @Override // public void doRun() throws Throwable { // createPlayerDataSource.createPlayer(player); // notifyPlayerCreated(); // } // // public void createPlayer(Player player, CreatePlayerCallback callback){ // this.player = player; // this.callback = callback; // jobManager.addJob(this); // } // // private void notifyPlayerCreated(){ // sendCallback(new Runnable() { // @Override // public void run() { // callback.onCreatePlayerSuccess(); // } // }); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/SelectPlayerJob.java // public class SelectPlayerJob implements SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/UpdatePlayerJob.java // public class UpdatePlayerJob implements UpdatePlayer { // // }
import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.DeletePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.SelectPlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.UpdatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.CreatePlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.SelectPlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.UpdatePlayerJob;
package es.rogermartinez.paddlemanager.editplayer.domain; /** * Created by roger.martinez on 17/11/15. */ @Module public class EditPlayerDomainModule { @Provides public SelectPlayer providesSelectPlayer(SelectPlayerJob job){ return job; } @Provides public UpdatePlayer providesUpdatePlayer(UpdatePlayerJob job){ return job; } @Provides
// Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/DeletePlayer.java // public interface DeletePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/SelectPlayer.java // public interface SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/UpdatePlayer.java // public interface UpdatePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java // public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { // // private Player player; // private CreatePlayerCallback callback; // private CreatePlayerDataSource createPlayerDataSource; // // @Inject // public CreatePlayerJob(JobManager jobManager, MainThread mainThread, // DomainErrorHandler domainErrorHandler, CreatePlayerDataSource createPlayerDataSource){ // super(jobManager, mainThread, new Params(UserCaseJob.DEFAULT_PRIORITY).setRequiresNetwork(false), domainErrorHandler); // this.createPlayerDataSource = createPlayerDataSource; // } // // // @Override // public void doRun() throws Throwable { // createPlayerDataSource.createPlayer(player); // notifyPlayerCreated(); // } // // public void createPlayer(Player player, CreatePlayerCallback callback){ // this.player = player; // this.callback = callback; // jobManager.addJob(this); // } // // private void notifyPlayerCreated(){ // sendCallback(new Runnable() { // @Override // public void run() { // callback.onCreatePlayerSuccess(); // } // }); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/SelectPlayerJob.java // public class SelectPlayerJob implements SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/UpdatePlayerJob.java // public class UpdatePlayerJob implements UpdatePlayer { // // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/EditPlayerDomainModule.java import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.DeletePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.SelectPlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.UpdatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.CreatePlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.SelectPlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.UpdatePlayerJob; package es.rogermartinez.paddlemanager.editplayer.domain; /** * Created by roger.martinez on 17/11/15. */ @Module public class EditPlayerDomainModule { @Provides public SelectPlayer providesSelectPlayer(SelectPlayerJob job){ return job; } @Provides public UpdatePlayer providesUpdatePlayer(UpdatePlayerJob job){ return job; } @Provides
public CreatePlayer providesCreatePlayer(CreatePlayerJob job){
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/EditPlayerDomainModule.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/DeletePlayer.java // public interface DeletePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/SelectPlayer.java // public interface SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/UpdatePlayer.java // public interface UpdatePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java // public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { // // private Player player; // private CreatePlayerCallback callback; // private CreatePlayerDataSource createPlayerDataSource; // // @Inject // public CreatePlayerJob(JobManager jobManager, MainThread mainThread, // DomainErrorHandler domainErrorHandler, CreatePlayerDataSource createPlayerDataSource){ // super(jobManager, mainThread, new Params(UserCaseJob.DEFAULT_PRIORITY).setRequiresNetwork(false), domainErrorHandler); // this.createPlayerDataSource = createPlayerDataSource; // } // // // @Override // public void doRun() throws Throwable { // createPlayerDataSource.createPlayer(player); // notifyPlayerCreated(); // } // // public void createPlayer(Player player, CreatePlayerCallback callback){ // this.player = player; // this.callback = callback; // jobManager.addJob(this); // } // // private void notifyPlayerCreated(){ // sendCallback(new Runnable() { // @Override // public void run() { // callback.onCreatePlayerSuccess(); // } // }); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/SelectPlayerJob.java // public class SelectPlayerJob implements SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/UpdatePlayerJob.java // public class UpdatePlayerJob implements UpdatePlayer { // // }
import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.DeletePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.SelectPlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.UpdatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.CreatePlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.SelectPlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.UpdatePlayerJob;
package es.rogermartinez.paddlemanager.editplayer.domain; /** * Created by roger.martinez on 17/11/15. */ @Module public class EditPlayerDomainModule { @Provides public SelectPlayer providesSelectPlayer(SelectPlayerJob job){ return job; } @Provides public UpdatePlayer providesUpdatePlayer(UpdatePlayerJob job){ return job; } @Provides
// Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/DeletePlayer.java // public interface DeletePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/SelectPlayer.java // public interface SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/UpdatePlayer.java // public interface UpdatePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java // public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { // // private Player player; // private CreatePlayerCallback callback; // private CreatePlayerDataSource createPlayerDataSource; // // @Inject // public CreatePlayerJob(JobManager jobManager, MainThread mainThread, // DomainErrorHandler domainErrorHandler, CreatePlayerDataSource createPlayerDataSource){ // super(jobManager, mainThread, new Params(UserCaseJob.DEFAULT_PRIORITY).setRequiresNetwork(false), domainErrorHandler); // this.createPlayerDataSource = createPlayerDataSource; // } // // // @Override // public void doRun() throws Throwable { // createPlayerDataSource.createPlayer(player); // notifyPlayerCreated(); // } // // public void createPlayer(Player player, CreatePlayerCallback callback){ // this.player = player; // this.callback = callback; // jobManager.addJob(this); // } // // private void notifyPlayerCreated(){ // sendCallback(new Runnable() { // @Override // public void run() { // callback.onCreatePlayerSuccess(); // } // }); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/SelectPlayerJob.java // public class SelectPlayerJob implements SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/UpdatePlayerJob.java // public class UpdatePlayerJob implements UpdatePlayer { // // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/EditPlayerDomainModule.java import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.DeletePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.SelectPlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.UpdatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.CreatePlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.SelectPlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.UpdatePlayerJob; package es.rogermartinez.paddlemanager.editplayer.domain; /** * Created by roger.martinez on 17/11/15. */ @Module public class EditPlayerDomainModule { @Provides public SelectPlayer providesSelectPlayer(SelectPlayerJob job){ return job; } @Provides public UpdatePlayer providesUpdatePlayer(UpdatePlayerJob job){ return job; } @Provides
public CreatePlayer providesCreatePlayer(CreatePlayerJob job){
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/EditPlayerDomainModule.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/DeletePlayer.java // public interface DeletePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/SelectPlayer.java // public interface SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/UpdatePlayer.java // public interface UpdatePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java // public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { // // private Player player; // private CreatePlayerCallback callback; // private CreatePlayerDataSource createPlayerDataSource; // // @Inject // public CreatePlayerJob(JobManager jobManager, MainThread mainThread, // DomainErrorHandler domainErrorHandler, CreatePlayerDataSource createPlayerDataSource){ // super(jobManager, mainThread, new Params(UserCaseJob.DEFAULT_PRIORITY).setRequiresNetwork(false), domainErrorHandler); // this.createPlayerDataSource = createPlayerDataSource; // } // // // @Override // public void doRun() throws Throwable { // createPlayerDataSource.createPlayer(player); // notifyPlayerCreated(); // } // // public void createPlayer(Player player, CreatePlayerCallback callback){ // this.player = player; // this.callback = callback; // jobManager.addJob(this); // } // // private void notifyPlayerCreated(){ // sendCallback(new Runnable() { // @Override // public void run() { // callback.onCreatePlayerSuccess(); // } // }); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/SelectPlayerJob.java // public class SelectPlayerJob implements SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/UpdatePlayerJob.java // public class UpdatePlayerJob implements UpdatePlayer { // // }
import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.DeletePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.SelectPlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.UpdatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.CreatePlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.SelectPlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.UpdatePlayerJob;
package es.rogermartinez.paddlemanager.editplayer.domain; /** * Created by roger.martinez on 17/11/15. */ @Module public class EditPlayerDomainModule { @Provides public SelectPlayer providesSelectPlayer(SelectPlayerJob job){ return job; } @Provides public UpdatePlayer providesUpdatePlayer(UpdatePlayerJob job){ return job; } @Provides public CreatePlayer providesCreatePlayer(CreatePlayerJob job){ return job; } @Provides
// Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/CreatePlayer.java // public interface CreatePlayer { // void createPlayer(Player player, CreatePlayerCallback callback); // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/DeletePlayer.java // public interface DeletePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/SelectPlayer.java // public interface SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/UpdatePlayer.java // public interface UpdatePlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/CreatePlayerJob.java // public class CreatePlayerJob extends UserCaseJob implements CreatePlayer { // // private Player player; // private CreatePlayerCallback callback; // private CreatePlayerDataSource createPlayerDataSource; // // @Inject // public CreatePlayerJob(JobManager jobManager, MainThread mainThread, // DomainErrorHandler domainErrorHandler, CreatePlayerDataSource createPlayerDataSource){ // super(jobManager, mainThread, new Params(UserCaseJob.DEFAULT_PRIORITY).setRequiresNetwork(false), domainErrorHandler); // this.createPlayerDataSource = createPlayerDataSource; // } // // // @Override // public void doRun() throws Throwable { // createPlayerDataSource.createPlayer(player); // notifyPlayerCreated(); // } // // public void createPlayer(Player player, CreatePlayerCallback callback){ // this.player = player; // this.callback = callback; // jobManager.addJob(this); // } // // private void notifyPlayerCreated(){ // sendCallback(new Runnable() { // @Override // public void run() { // callback.onCreatePlayerSuccess(); // } // }); // } // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/SelectPlayerJob.java // public class SelectPlayerJob implements SelectPlayer { // } // // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/usercase/impl/UpdatePlayerJob.java // public class UpdatePlayerJob implements UpdatePlayer { // // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/editplayer/domain/EditPlayerDomainModule.java import dagger.Module; import dagger.Provides; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.CreatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.DeletePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.SelectPlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.UpdatePlayer; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.CreatePlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.SelectPlayerJob; import es.rogermartinez.paddlemanager.editplayer.domain.usercase.impl.UpdatePlayerJob; package es.rogermartinez.paddlemanager.editplayer.domain; /** * Created by roger.martinez on 17/11/15. */ @Module public class EditPlayerDomainModule { @Provides public SelectPlayer providesSelectPlayer(SelectPlayerJob job){ return job; } @Provides public UpdatePlayer providesUpdatePlayer(UpdatePlayerJob job){ return job; } @Provides public CreatePlayer providesCreatePlayer(CreatePlayerJob job){ return job; } @Provides
public DeletePlayer providesDeletePlayer(DeletePlayer job){
rogermarte/paddle-manager-android-app
app/src/main/java/es/rogermartinez/paddlemanager/base/domain/DomainErrorHandler.java
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // }
import com.squareup.otto.Bus; import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent;
package es.rogermartinez.paddlemanager.base.domain; /** * Created by roger.martinez on 13/11/15. */ public class DomainErrorHandler { private Bus bus; public DomainErrorHandler(Bus bus) { this.bus = bus; }
// Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/events/ErrorEvent.java // public class ErrorEvent { // // public static final int ACTION_NO_ACTION = 0; // public static final int ACTION_REDIRECT_TO_LOGIN = 1; // public static final int ACTIONS_REQUEST_NEW_SCOPES = 2; // public static Exception exception; // // private String message; // private int action = ACTION_NO_ACTION; // // public ErrorEvent() {} // // public ErrorEvent(Exception exception) { // this.exception = exception; // this.message = exception.getMessage(); // } // // public ErrorEvent(Exception exception, int action) { // this.exception = exception; // this.message = exception.getMessage(); // this.action = action; // } // // public ErrorEvent(String message) { // this.message = message; // } // // public String getMessage() { // return message; // } // // public void setMessage(String message) { // this.message = message; // } // // public int getAction() { return action; } // // public void setAction(int action) { this.action = action; } // // public static Exception getException() { // return exception; // } // // public static void setException(Exception exception) { // ErrorEvent.exception = exception; // } // } // Path: app/src/main/java/es/rogermartinez/paddlemanager/base/domain/DomainErrorHandler.java import com.squareup.otto.Bus; import es.rogermartinez.paddlemanager.base.domain.events.ErrorEvent; package es.rogermartinez.paddlemanager.base.domain; /** * Created by roger.martinez on 13/11/15. */ public class DomainErrorHandler { private Bus bus; public DomainErrorHandler(Bus bus) { this.bus = bus; }
public void notifyError(ErrorEvent errorObject) throws Throwable {
devalexx/evilrain
Main/src/com/alex/rain/ui/HintWindow.java
// Path: Main/src/com/alex/rain/managers/I18nManager.java // public class I18nManager { // private static ResourceBundle rootResourceBundle; // private static boolean isInit; // public static String availableLanguages[] = {"en", "ru"}; // public static Locale locale; // // public static void load(Locale l) { // try { // rootResourceBundle = new PropertyResourceBundle(new InputStreamReader( // Gdx.files.internal("data/i18n/messages_" + l.getLanguage() + ".properties").read(), "UTF-8")); // locale = l; // isInit = true; // } catch (IOException e) { // Logger.getGlobal().log(Level.SEVERE, e.getMessage(), e); // } // } // // public static String getString(String key) { // if(!isInit) // load(SettingsManager.getLanguage()); // // try { // return rootResourceBundle.getString(key); // } catch (Exception e) { // Logger.getGlobal().log(Level.WARNING, e.getMessage(), e); // return '!' + key + '!'; // } // } // // public static String getString(String key, Object... params) { // try { // return MessageFormat.format(rootResourceBundle.getString(key), params); // } catch (MissingResourceException e) { // Logger.getGlobal().log(Level.WARNING, e.getMessage(), e); // return '!' + key + '!'; // } // } // // public static boolean isAvailable(Locale locale) { // for(String lang : availableLanguages) // if(lang.equals(locale.getLanguage())) // return true; // // return false; // } // // public static int getCurrentLanguageId() { // for(int i = 0; i < availableLanguages.length; i++) { // if(availableLanguages[i].equals(locale.getLanguage())) // return i; // } // // return -1; // } // // public static String getCurrentLanguage() { // return locale.getLanguage(); // } // } // // Path: Main/src/com/alex/rain/viewports/GameViewport.java // public class GameViewport extends Viewport { // public static final int WIDTH = 800, HEIGHT = 480; // public float offsetX, offsetY; // public float fullWorldWidth, fullWorldHeight; // public float scale; // // public GameViewport() { // setCamera(new OrthographicCamera()); // setWorldSize(WIDTH, HEIGHT); // } // // @Override // public void update(int screenWidth, int screenHeight, boolean centerCamera) { // Vector2 viewFit = Scaling.fit.apply(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), // WIDTH, HEIGHT).cpy(); // Vector2 viewFill = Scaling.fill.apply(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), // WIDTH, HEIGHT); // // setScreenBounds(0, 0, screenWidth, screenHeight); // // boolean isPortrait = viewFit.x - WIDTH < 0.1; // boolean isLandscape = viewFit.y - HEIGHT < 0.1; // offsetX = isLandscape ? viewFill.x / 2 - WIDTH / 2 : 0; // offsetY = isPortrait ? viewFill.y / 2 - HEIGHT / 2 : 0; // setWorldSize(isLandscape ? viewFill.x : WIDTH, // isPortrait ? viewFill.y : HEIGHT); // fullWorldWidth = 2 * offsetX + getWorldWidth(); // fullWorldHeight = 2 * offsetY + getWorldHeight(); // if(offsetX < 0.01) // scale = (float)getScreenWidth() / WIDTH; // else // scale = (float)getScreenHeight() / HEIGHT; // apply(centerCamera); // } // // public void apply(boolean centerCamera) { // Gdx.gl.glViewport(getScreenX(), getScreenY(), getScreenWidth(), getScreenHeight()); // getCamera().viewportWidth = getWorldWidth(); // getCamera().viewportHeight = getWorldHeight(); // if(centerCamera) // getCamera().position.set(- offsetX + getWorldWidth() / 2, - offsetY + getWorldHeight() / 2, 0); // getCamera().update(); // } // }
import com.alex.rain.managers.I18nManager; import com.alex.rain.viewports.GameViewport; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.Window; import com.badlogic.gdx.scenes.scene2d.utils.Align; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
/******************************************************************************* * Copyright 2013 See AUTHORS file. * * Licensed under the GNU GENERAL PUBLIC LICENSE V3 * you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.gnu.org/licenses/gpl.html * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.alex.rain.ui; public class HintWindow extends Window { private Label hintLabel; private int fullHintCounter = 5; public HintWindow(Skin skin, final int levelNumber) {
// Path: Main/src/com/alex/rain/managers/I18nManager.java // public class I18nManager { // private static ResourceBundle rootResourceBundle; // private static boolean isInit; // public static String availableLanguages[] = {"en", "ru"}; // public static Locale locale; // // public static void load(Locale l) { // try { // rootResourceBundle = new PropertyResourceBundle(new InputStreamReader( // Gdx.files.internal("data/i18n/messages_" + l.getLanguage() + ".properties").read(), "UTF-8")); // locale = l; // isInit = true; // } catch (IOException e) { // Logger.getGlobal().log(Level.SEVERE, e.getMessage(), e); // } // } // // public static String getString(String key) { // if(!isInit) // load(SettingsManager.getLanguage()); // // try { // return rootResourceBundle.getString(key); // } catch (Exception e) { // Logger.getGlobal().log(Level.WARNING, e.getMessage(), e); // return '!' + key + '!'; // } // } // // public static String getString(String key, Object... params) { // try { // return MessageFormat.format(rootResourceBundle.getString(key), params); // } catch (MissingResourceException e) { // Logger.getGlobal().log(Level.WARNING, e.getMessage(), e); // return '!' + key + '!'; // } // } // // public static boolean isAvailable(Locale locale) { // for(String lang : availableLanguages) // if(lang.equals(locale.getLanguage())) // return true; // // return false; // } // // public static int getCurrentLanguageId() { // for(int i = 0; i < availableLanguages.length; i++) { // if(availableLanguages[i].equals(locale.getLanguage())) // return i; // } // // return -1; // } // // public static String getCurrentLanguage() { // return locale.getLanguage(); // } // } // // Path: Main/src/com/alex/rain/viewports/GameViewport.java // public class GameViewport extends Viewport { // public static final int WIDTH = 800, HEIGHT = 480; // public float offsetX, offsetY; // public float fullWorldWidth, fullWorldHeight; // public float scale; // // public GameViewport() { // setCamera(new OrthographicCamera()); // setWorldSize(WIDTH, HEIGHT); // } // // @Override // public void update(int screenWidth, int screenHeight, boolean centerCamera) { // Vector2 viewFit = Scaling.fit.apply(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), // WIDTH, HEIGHT).cpy(); // Vector2 viewFill = Scaling.fill.apply(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), // WIDTH, HEIGHT); // // setScreenBounds(0, 0, screenWidth, screenHeight); // // boolean isPortrait = viewFit.x - WIDTH < 0.1; // boolean isLandscape = viewFit.y - HEIGHT < 0.1; // offsetX = isLandscape ? viewFill.x / 2 - WIDTH / 2 : 0; // offsetY = isPortrait ? viewFill.y / 2 - HEIGHT / 2 : 0; // setWorldSize(isLandscape ? viewFill.x : WIDTH, // isPortrait ? viewFill.y : HEIGHT); // fullWorldWidth = 2 * offsetX + getWorldWidth(); // fullWorldHeight = 2 * offsetY + getWorldHeight(); // if(offsetX < 0.01) // scale = (float)getScreenWidth() / WIDTH; // else // scale = (float)getScreenHeight() / HEIGHT; // apply(centerCamera); // } // // public void apply(boolean centerCamera) { // Gdx.gl.glViewport(getScreenX(), getScreenY(), getScreenWidth(), getScreenHeight()); // getCamera().viewportWidth = getWorldWidth(); // getCamera().viewportHeight = getWorldHeight(); // if(centerCamera) // getCamera().position.set(- offsetX + getWorldWidth() / 2, - offsetY + getWorldHeight() / 2, 0); // getCamera().update(); // } // } // Path: Main/src/com/alex/rain/ui/HintWindow.java import com.alex.rain.managers.I18nManager; import com.alex.rain.viewports.GameViewport; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.Window; import com.badlogic.gdx.scenes.scene2d.utils.Align; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; /******************************************************************************* * Copyright 2013 See AUTHORS file. * * Licensed under the GNU GENERAL PUBLIC LICENSE V3 * you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.gnu.org/licenses/gpl.html * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.alex.rain.ui; public class HintWindow extends Window { private Label hintLabel; private int fullHintCounter = 5; public HintWindow(Skin skin, final int levelNumber) {
super(I18nManager.getString("LEVEL") + " " + levelNumber, skin);
devalexx/evilrain
Main/src/com/alex/rain/ui/HintWindow.java
// Path: Main/src/com/alex/rain/managers/I18nManager.java // public class I18nManager { // private static ResourceBundle rootResourceBundle; // private static boolean isInit; // public static String availableLanguages[] = {"en", "ru"}; // public static Locale locale; // // public static void load(Locale l) { // try { // rootResourceBundle = new PropertyResourceBundle(new InputStreamReader( // Gdx.files.internal("data/i18n/messages_" + l.getLanguage() + ".properties").read(), "UTF-8")); // locale = l; // isInit = true; // } catch (IOException e) { // Logger.getGlobal().log(Level.SEVERE, e.getMessage(), e); // } // } // // public static String getString(String key) { // if(!isInit) // load(SettingsManager.getLanguage()); // // try { // return rootResourceBundle.getString(key); // } catch (Exception e) { // Logger.getGlobal().log(Level.WARNING, e.getMessage(), e); // return '!' + key + '!'; // } // } // // public static String getString(String key, Object... params) { // try { // return MessageFormat.format(rootResourceBundle.getString(key), params); // } catch (MissingResourceException e) { // Logger.getGlobal().log(Level.WARNING, e.getMessage(), e); // return '!' + key + '!'; // } // } // // public static boolean isAvailable(Locale locale) { // for(String lang : availableLanguages) // if(lang.equals(locale.getLanguage())) // return true; // // return false; // } // // public static int getCurrentLanguageId() { // for(int i = 0; i < availableLanguages.length; i++) { // if(availableLanguages[i].equals(locale.getLanguage())) // return i; // } // // return -1; // } // // public static String getCurrentLanguage() { // return locale.getLanguage(); // } // } // // Path: Main/src/com/alex/rain/viewports/GameViewport.java // public class GameViewport extends Viewport { // public static final int WIDTH = 800, HEIGHT = 480; // public float offsetX, offsetY; // public float fullWorldWidth, fullWorldHeight; // public float scale; // // public GameViewport() { // setCamera(new OrthographicCamera()); // setWorldSize(WIDTH, HEIGHT); // } // // @Override // public void update(int screenWidth, int screenHeight, boolean centerCamera) { // Vector2 viewFit = Scaling.fit.apply(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), // WIDTH, HEIGHT).cpy(); // Vector2 viewFill = Scaling.fill.apply(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), // WIDTH, HEIGHT); // // setScreenBounds(0, 0, screenWidth, screenHeight); // // boolean isPortrait = viewFit.x - WIDTH < 0.1; // boolean isLandscape = viewFit.y - HEIGHT < 0.1; // offsetX = isLandscape ? viewFill.x / 2 - WIDTH / 2 : 0; // offsetY = isPortrait ? viewFill.y / 2 - HEIGHT / 2 : 0; // setWorldSize(isLandscape ? viewFill.x : WIDTH, // isPortrait ? viewFill.y : HEIGHT); // fullWorldWidth = 2 * offsetX + getWorldWidth(); // fullWorldHeight = 2 * offsetY + getWorldHeight(); // if(offsetX < 0.01) // scale = (float)getScreenWidth() / WIDTH; // else // scale = (float)getScreenHeight() / HEIGHT; // apply(centerCamera); // } // // public void apply(boolean centerCamera) { // Gdx.gl.glViewport(getScreenX(), getScreenY(), getScreenWidth(), getScreenHeight()); // getCamera().viewportWidth = getWorldWidth(); // getCamera().viewportHeight = getWorldHeight(); // if(centerCamera) // getCamera().position.set(- offsetX + getWorldWidth() / 2, - offsetY + getWorldHeight() / 2, 0); // getCamera().update(); // } // }
import com.alex.rain.managers.I18nManager; import com.alex.rain.viewports.GameViewport; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.Window; import com.badlogic.gdx.scenes.scene2d.utils.Align; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
/******************************************************************************* * Copyright 2013 See AUTHORS file. * * Licensed under the GNU GENERAL PUBLIC LICENSE V3 * you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.gnu.org/licenses/gpl.html * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.alex.rain.ui; public class HintWindow extends Window { private Label hintLabel; private int fullHintCounter = 5; public HintWindow(Skin skin, final int levelNumber) { super(I18nManager.getString("LEVEL") + " " + levelNumber, skin);
// Path: Main/src/com/alex/rain/managers/I18nManager.java // public class I18nManager { // private static ResourceBundle rootResourceBundle; // private static boolean isInit; // public static String availableLanguages[] = {"en", "ru"}; // public static Locale locale; // // public static void load(Locale l) { // try { // rootResourceBundle = new PropertyResourceBundle(new InputStreamReader( // Gdx.files.internal("data/i18n/messages_" + l.getLanguage() + ".properties").read(), "UTF-8")); // locale = l; // isInit = true; // } catch (IOException e) { // Logger.getGlobal().log(Level.SEVERE, e.getMessage(), e); // } // } // // public static String getString(String key) { // if(!isInit) // load(SettingsManager.getLanguage()); // // try { // return rootResourceBundle.getString(key); // } catch (Exception e) { // Logger.getGlobal().log(Level.WARNING, e.getMessage(), e); // return '!' + key + '!'; // } // } // // public static String getString(String key, Object... params) { // try { // return MessageFormat.format(rootResourceBundle.getString(key), params); // } catch (MissingResourceException e) { // Logger.getGlobal().log(Level.WARNING, e.getMessage(), e); // return '!' + key + '!'; // } // } // // public static boolean isAvailable(Locale locale) { // for(String lang : availableLanguages) // if(lang.equals(locale.getLanguage())) // return true; // // return false; // } // // public static int getCurrentLanguageId() { // for(int i = 0; i < availableLanguages.length; i++) { // if(availableLanguages[i].equals(locale.getLanguage())) // return i; // } // // return -1; // } // // public static String getCurrentLanguage() { // return locale.getLanguage(); // } // } // // Path: Main/src/com/alex/rain/viewports/GameViewport.java // public class GameViewport extends Viewport { // public static final int WIDTH = 800, HEIGHT = 480; // public float offsetX, offsetY; // public float fullWorldWidth, fullWorldHeight; // public float scale; // // public GameViewport() { // setCamera(new OrthographicCamera()); // setWorldSize(WIDTH, HEIGHT); // } // // @Override // public void update(int screenWidth, int screenHeight, boolean centerCamera) { // Vector2 viewFit = Scaling.fit.apply(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), // WIDTH, HEIGHT).cpy(); // Vector2 viewFill = Scaling.fill.apply(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), // WIDTH, HEIGHT); // // setScreenBounds(0, 0, screenWidth, screenHeight); // // boolean isPortrait = viewFit.x - WIDTH < 0.1; // boolean isLandscape = viewFit.y - HEIGHT < 0.1; // offsetX = isLandscape ? viewFill.x / 2 - WIDTH / 2 : 0; // offsetY = isPortrait ? viewFill.y / 2 - HEIGHT / 2 : 0; // setWorldSize(isLandscape ? viewFill.x : WIDTH, // isPortrait ? viewFill.y : HEIGHT); // fullWorldWidth = 2 * offsetX + getWorldWidth(); // fullWorldHeight = 2 * offsetY + getWorldHeight(); // if(offsetX < 0.01) // scale = (float)getScreenWidth() / WIDTH; // else // scale = (float)getScreenHeight() / HEIGHT; // apply(centerCamera); // } // // public void apply(boolean centerCamera) { // Gdx.gl.glViewport(getScreenX(), getScreenY(), getScreenWidth(), getScreenHeight()); // getCamera().viewportWidth = getWorldWidth(); // getCamera().viewportHeight = getWorldHeight(); // if(centerCamera) // getCamera().position.set(- offsetX + getWorldWidth() / 2, - offsetY + getWorldHeight() / 2, 0); // getCamera().update(); // } // } // Path: Main/src/com/alex/rain/ui/HintWindow.java import com.alex.rain.managers.I18nManager; import com.alex.rain.viewports.GameViewport; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.Window; import com.badlogic.gdx.scenes.scene2d.utils.Align; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; /******************************************************************************* * Copyright 2013 See AUTHORS file. * * Licensed under the GNU GENERAL PUBLIC LICENSE V3 * you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.gnu.org/licenses/gpl.html * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.alex.rain.ui; public class HintWindow extends Window { private Label hintLabel; private int fullHintCounter = 5; public HintWindow(Skin skin, final int levelNumber) { super(I18nManager.getString("LEVEL") + " " + levelNumber, skin);
setSize(GameViewport.WIDTH / 1.5f, GameViewport.HEIGHT / 1.5f);
square/rack-servlet
core/src/test/java/com/squareup/rack/RackLoggerTest.java
// Path: core/src/main/java/com/squareup/rack/RackLogger.java // public static final Marker FATAL = MarkerFactory.getMarker("FATAL");
import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import org.slf4j.Logger; import static com.squareup.rack.RackLogger.FATAL; import static org.mockito.Mockito.verify;
subject = new RackLogger(delegate); } @Test(expected = NullPointerException.class) public void constructorRequiresALogger() { new RackLogger(null); } @Test public void info() { subject.info(MESSAGE); verify(delegate).info(MESSAGE); } @Test public void debug() { subject.debug(MESSAGE); verify(delegate).debug(MESSAGE); } @Test public void warn() { subject.warn(MESSAGE); verify(delegate).warn(MESSAGE); } @Test public void error() { subject.error(MESSAGE); verify(delegate).error(MESSAGE); } @Test public void fatal() { subject.fatal(MESSAGE);
// Path: core/src/main/java/com/squareup/rack/RackLogger.java // public static final Marker FATAL = MarkerFactory.getMarker("FATAL"); // Path: core/src/test/java/com/squareup/rack/RackLoggerTest.java import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import org.slf4j.Logger; import static com.squareup.rack.RackLogger.FATAL; import static org.mockito.Mockito.verify; subject = new RackLogger(delegate); } @Test(expected = NullPointerException.class) public void constructorRequiresALogger() { new RackLogger(null); } @Test public void info() { subject.info(MESSAGE); verify(delegate).info(MESSAGE); } @Test public void debug() { subject.debug(MESSAGE); verify(delegate).debug(MESSAGE); } @Test public void warn() { subject.warn(MESSAGE); verify(delegate).warn(MESSAGE); } @Test public void error() { subject.error(MESSAGE); verify(delegate).error(MESSAGE); } @Test public void fatal() { subject.fatal(MESSAGE);
verify(delegate).error(FATAL, MESSAGE);
square/rack-servlet
core/src/main/java/com/squareup/rack/RackInput.java
// Path: core/src/main/java/com/squareup/rack/io/ByteArrayBuffer.java // public class ByteArrayBuffer extends ByteArrayOutputStream { // /** // * Creates a new buffer with the default initial size. // */ // public ByteArrayBuffer() { // super(); // } // // /** // * Creates an new buffer with the given initial size. // * // * @param initialSize the initial size of the internal buffer. // */ // public ByteArrayBuffer(int initialSize) { // super(initialSize); // } // // /** // * Like {@link #toByteArray()}, but returns a reference to the internal buffer itself rather than // * allocating more memory and returning a copy. // * // * @return the current contents of the internal buffer. // */ // public byte[] getBuffer() { // return buf; // } // // /** // * @return the currently-filled length of the internal buffer. // */ // public int getLength() { // return count; // } // // /** // * Logically adjusts the currently-filled length of internal buffer. // * // * @param length the newly desired length. // */ // public void setLength(int length) { // count = length; // } // }
import com.google.common.io.ByteStreams; import com.squareup.rack.io.ByteArrayBuffer; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull;
/* * Copyright (C) 2013 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.squareup.rack; /** * <p>Adapts an {@link InputStream} to the required interface for {@code rack.input}.</p> * * <p>Speaks {@code byte[]}, not {@code String}, because {@code rack.input} is required to have * binary encoding.</p> */ public class RackInput implements Closeable { private static final int LINEFEED = 0xA; private static final int MAX_LINE_LENGTH = 1024 * 1024; private static final int READ_AHEAD_SUGGESTION = 1024 * 1024; private final InputStream stream;
// Path: core/src/main/java/com/squareup/rack/io/ByteArrayBuffer.java // public class ByteArrayBuffer extends ByteArrayOutputStream { // /** // * Creates a new buffer with the default initial size. // */ // public ByteArrayBuffer() { // super(); // } // // /** // * Creates an new buffer with the given initial size. // * // * @param initialSize the initial size of the internal buffer. // */ // public ByteArrayBuffer(int initialSize) { // super(initialSize); // } // // /** // * Like {@link #toByteArray()}, but returns a reference to the internal buffer itself rather than // * allocating more memory and returning a copy. // * // * @return the current contents of the internal buffer. // */ // public byte[] getBuffer() { // return buf; // } // // /** // * @return the currently-filled length of the internal buffer. // */ // public int getLength() { // return count; // } // // /** // * Logically adjusts the currently-filled length of internal buffer. // * // * @param length the newly desired length. // */ // public void setLength(int length) { // count = length; // } // } // Path: core/src/main/java/com/squareup/rack/RackInput.java import com.google.common.io.ByteStreams; import com.squareup.rack.io.ByteArrayBuffer; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; /* * Copyright (C) 2013 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.squareup.rack; /** * <p>Adapts an {@link InputStream} to the required interface for {@code rack.input}.</p> * * <p>Speaks {@code byte[]}, not {@code String}, because {@code rack.input} is required to have * binary encoding.</p> */ public class RackInput implements Closeable { private static final int LINEFEED = 0xA; private static final int MAX_LINE_LENGTH = 1024 * 1024; private static final int READ_AHEAD_SUGGESTION = 1024 * 1024; private final InputStream stream;
private final ByteArrayBuffer buffer = new ByteArrayBuffer();
square/rack-servlet
integration/src/test/java/com/squareup/rack/integration/MultiValuedHeadersTest.java
// Path: core/src/main/java/com/squareup/rack/jruby/JRubyRackApplication.java // public class JRubyRackApplication implements RackApplication { // private final IRubyObject application; // private final Ruby runtime; // private final ThreadService threadService; // // /** // * <p>Creates a {@link RackApplication} that delegates to the given Ruby Rack application.</p> // * // * <p>To obtain the necessary {@link IRubyObject}, you can create a JRuby // * {@link org.jruby.embed.ScriptingContainer} and {@link org.jruby.embed.ScriptingContainer#parse} // * and {@link org.jruby.embed.EmbedEvalUnit#run()} your Ruby code. See our examples for concrete // * code.</p> // * // * @param application the Ruby Rack application. // */ // public JRubyRackApplication(IRubyObject application) { // this.application = application; // this.runtime = application.getRuntime(); // this.threadService = runtime.getThreadService(); // } // // /** // * Calls the delegate Rack application, translating into and back out of the JRuby interpreter. // * // * @param environment the Rack environment // * @return the Rack response // */ // @Override public RackResponse call(RackEnvironment environment) { // RubyHash environmentHash = convertToRubyHash(environment.entrySet()); // // RubyArray response = callRackApplication(environmentHash); // // return convertToJavaRackResponse(response); // } // // private RubyHash convertToRubyHash(Set<Map.Entry<String, Object>> entries) { // RubyHash hash = newHash(runtime); // // for (Map.Entry<String, Object> entry : entries) { // String key = entry.getKey(); // Object value = entry.getValue(); // // if (key.equals("rack.input")) { // value = new JRubyRackInput(runtime, (RackInput) value); // } // // if (key.equals("rack.version")) { // value = convertToRubyArray((List<Integer>) value); // } // // hash.put(key, value); // } // // return hash; // } // // private RubyArray convertToRubyArray(List<Integer> list) { // RubyArray array = RubyArray.newEmptyArray(runtime); // array.addAll(list); // return array; // } // // private RubyArray callRackApplication(RubyHash rubyHash) { // return (RubyArray) application.callMethod(threadService.getCurrentContext(), "call", rubyHash); // } // // private RackResponse convertToJavaRackResponse(RubyArray response) { // int status = Integer.parseInt(response.get(0).toString(), 10); // Map headers = (Map) response.get(1); // IRubyObject body = (IRubyObject) response.get(2); // // return new RackResponse(status, headers, new JRubyRackBodyIterator(body)); // } // } // // Path: core/src/main/java/com/squareup/rack/servlet/RackServlet.java // public class RackServlet extends HttpServlet { // private final RackEnvironmentBuilder rackEnvironmentBuilder; // private final RackApplication rackApplication; // private final RackResponsePropagator rackResponsePropagator; // // /** // * Creates a servlet hosting the given {@link RackApplication}. // * // * @param rackApplication the application to host. // */ // public RackServlet(RackApplication rackApplication) { // this(new RackEnvironmentBuilder(), rackApplication, new RackResponsePropagator()); // } // // /** // * Creates a servlet hosting the given {@link RackApplication} and that uses the given // * collaborators to translate between the Servlet and Rack environments. // * // * @param rackEnvironmentBuilder turns {@link HttpServletRequest}s into {@link RackEnvironment}s. // * @param rackApplication the application to host. // * @param rackResponsePropagator writes {@link RackResponse}s onto {@link HttpServletResponse}s. // */ // public RackServlet(RackEnvironmentBuilder rackEnvironmentBuilder, // RackApplication rackApplication, // RackResponsePropagator rackResponsePropagator) { // this.rackEnvironmentBuilder = rackEnvironmentBuilder; // this.rackApplication = rackApplication; // this.rackResponsePropagator = rackResponsePropagator; // } // // @Override protected void service(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException { // RackEnvironment rackEnvironment = rackEnvironmentBuilder.build(request); // // try { // RackResponse rackResponse = rackApplication.call(rackEnvironment); // rackResponsePropagator.propagate(rackResponse, response); // } finally { // rackEnvironment.closeRackInput(); // } // } // }
import com.squareup.rack.jruby.JRubyRackApplication; import com.squareup.rack.servlet.RackServlet; import java.io.IOException; import org.apache.http.Header; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.jruby.embed.ScriptingContainer; import org.jruby.runtime.builtin.IRubyObject; import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.fest.assertions.api.Assertions.assertThat; import static org.jruby.embed.PathType.CLASSPATH; import static org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY;
package com.squareup.rack.integration; public class MultiValuedHeadersTest { private HttpClient client; private HttpHost localhost; private ExampleServer server; @Before public void setUp() throws Exception { // Silence logging. System.setProperty(DEFAULT_LOG_LEVEL_KEY, "WARN"); // Build the Rack servlet. ScriptingContainer ruby = new ScriptingContainer(); IRubyObject application = ruby.parse(CLASSPATH, "application.rb").run();
// Path: core/src/main/java/com/squareup/rack/jruby/JRubyRackApplication.java // public class JRubyRackApplication implements RackApplication { // private final IRubyObject application; // private final Ruby runtime; // private final ThreadService threadService; // // /** // * <p>Creates a {@link RackApplication} that delegates to the given Ruby Rack application.</p> // * // * <p>To obtain the necessary {@link IRubyObject}, you can create a JRuby // * {@link org.jruby.embed.ScriptingContainer} and {@link org.jruby.embed.ScriptingContainer#parse} // * and {@link org.jruby.embed.EmbedEvalUnit#run()} your Ruby code. See our examples for concrete // * code.</p> // * // * @param application the Ruby Rack application. // */ // public JRubyRackApplication(IRubyObject application) { // this.application = application; // this.runtime = application.getRuntime(); // this.threadService = runtime.getThreadService(); // } // // /** // * Calls the delegate Rack application, translating into and back out of the JRuby interpreter. // * // * @param environment the Rack environment // * @return the Rack response // */ // @Override public RackResponse call(RackEnvironment environment) { // RubyHash environmentHash = convertToRubyHash(environment.entrySet()); // // RubyArray response = callRackApplication(environmentHash); // // return convertToJavaRackResponse(response); // } // // private RubyHash convertToRubyHash(Set<Map.Entry<String, Object>> entries) { // RubyHash hash = newHash(runtime); // // for (Map.Entry<String, Object> entry : entries) { // String key = entry.getKey(); // Object value = entry.getValue(); // // if (key.equals("rack.input")) { // value = new JRubyRackInput(runtime, (RackInput) value); // } // // if (key.equals("rack.version")) { // value = convertToRubyArray((List<Integer>) value); // } // // hash.put(key, value); // } // // return hash; // } // // private RubyArray convertToRubyArray(List<Integer> list) { // RubyArray array = RubyArray.newEmptyArray(runtime); // array.addAll(list); // return array; // } // // private RubyArray callRackApplication(RubyHash rubyHash) { // return (RubyArray) application.callMethod(threadService.getCurrentContext(), "call", rubyHash); // } // // private RackResponse convertToJavaRackResponse(RubyArray response) { // int status = Integer.parseInt(response.get(0).toString(), 10); // Map headers = (Map) response.get(1); // IRubyObject body = (IRubyObject) response.get(2); // // return new RackResponse(status, headers, new JRubyRackBodyIterator(body)); // } // } // // Path: core/src/main/java/com/squareup/rack/servlet/RackServlet.java // public class RackServlet extends HttpServlet { // private final RackEnvironmentBuilder rackEnvironmentBuilder; // private final RackApplication rackApplication; // private final RackResponsePropagator rackResponsePropagator; // // /** // * Creates a servlet hosting the given {@link RackApplication}. // * // * @param rackApplication the application to host. // */ // public RackServlet(RackApplication rackApplication) { // this(new RackEnvironmentBuilder(), rackApplication, new RackResponsePropagator()); // } // // /** // * Creates a servlet hosting the given {@link RackApplication} and that uses the given // * collaborators to translate between the Servlet and Rack environments. // * // * @param rackEnvironmentBuilder turns {@link HttpServletRequest}s into {@link RackEnvironment}s. // * @param rackApplication the application to host. // * @param rackResponsePropagator writes {@link RackResponse}s onto {@link HttpServletResponse}s. // */ // public RackServlet(RackEnvironmentBuilder rackEnvironmentBuilder, // RackApplication rackApplication, // RackResponsePropagator rackResponsePropagator) { // this.rackEnvironmentBuilder = rackEnvironmentBuilder; // this.rackApplication = rackApplication; // this.rackResponsePropagator = rackResponsePropagator; // } // // @Override protected void service(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException { // RackEnvironment rackEnvironment = rackEnvironmentBuilder.build(request); // // try { // RackResponse rackResponse = rackApplication.call(rackEnvironment); // rackResponsePropagator.propagate(rackResponse, response); // } finally { // rackEnvironment.closeRackInput(); // } // } // } // Path: integration/src/test/java/com/squareup/rack/integration/MultiValuedHeadersTest.java import com.squareup.rack.jruby.JRubyRackApplication; import com.squareup.rack.servlet.RackServlet; import java.io.IOException; import org.apache.http.Header; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.jruby.embed.ScriptingContainer; import org.jruby.runtime.builtin.IRubyObject; import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.fest.assertions.api.Assertions.assertThat; import static org.jruby.embed.PathType.CLASSPATH; import static org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY; package com.squareup.rack.integration; public class MultiValuedHeadersTest { private HttpClient client; private HttpHost localhost; private ExampleServer server; @Before public void setUp() throws Exception { // Silence logging. System.setProperty(DEFAULT_LOG_LEVEL_KEY, "WARN"); // Build the Rack servlet. ScriptingContainer ruby = new ScriptingContainer(); IRubyObject application = ruby.parse(CLASSPATH, "application.rb").run();
RackServlet servlet = new RackServlet(new JRubyRackApplication(application));
square/rack-servlet
integration/src/test/java/com/squareup/rack/integration/MultiValuedHeadersTest.java
// Path: core/src/main/java/com/squareup/rack/jruby/JRubyRackApplication.java // public class JRubyRackApplication implements RackApplication { // private final IRubyObject application; // private final Ruby runtime; // private final ThreadService threadService; // // /** // * <p>Creates a {@link RackApplication} that delegates to the given Ruby Rack application.</p> // * // * <p>To obtain the necessary {@link IRubyObject}, you can create a JRuby // * {@link org.jruby.embed.ScriptingContainer} and {@link org.jruby.embed.ScriptingContainer#parse} // * and {@link org.jruby.embed.EmbedEvalUnit#run()} your Ruby code. See our examples for concrete // * code.</p> // * // * @param application the Ruby Rack application. // */ // public JRubyRackApplication(IRubyObject application) { // this.application = application; // this.runtime = application.getRuntime(); // this.threadService = runtime.getThreadService(); // } // // /** // * Calls the delegate Rack application, translating into and back out of the JRuby interpreter. // * // * @param environment the Rack environment // * @return the Rack response // */ // @Override public RackResponse call(RackEnvironment environment) { // RubyHash environmentHash = convertToRubyHash(environment.entrySet()); // // RubyArray response = callRackApplication(environmentHash); // // return convertToJavaRackResponse(response); // } // // private RubyHash convertToRubyHash(Set<Map.Entry<String, Object>> entries) { // RubyHash hash = newHash(runtime); // // for (Map.Entry<String, Object> entry : entries) { // String key = entry.getKey(); // Object value = entry.getValue(); // // if (key.equals("rack.input")) { // value = new JRubyRackInput(runtime, (RackInput) value); // } // // if (key.equals("rack.version")) { // value = convertToRubyArray((List<Integer>) value); // } // // hash.put(key, value); // } // // return hash; // } // // private RubyArray convertToRubyArray(List<Integer> list) { // RubyArray array = RubyArray.newEmptyArray(runtime); // array.addAll(list); // return array; // } // // private RubyArray callRackApplication(RubyHash rubyHash) { // return (RubyArray) application.callMethod(threadService.getCurrentContext(), "call", rubyHash); // } // // private RackResponse convertToJavaRackResponse(RubyArray response) { // int status = Integer.parseInt(response.get(0).toString(), 10); // Map headers = (Map) response.get(1); // IRubyObject body = (IRubyObject) response.get(2); // // return new RackResponse(status, headers, new JRubyRackBodyIterator(body)); // } // } // // Path: core/src/main/java/com/squareup/rack/servlet/RackServlet.java // public class RackServlet extends HttpServlet { // private final RackEnvironmentBuilder rackEnvironmentBuilder; // private final RackApplication rackApplication; // private final RackResponsePropagator rackResponsePropagator; // // /** // * Creates a servlet hosting the given {@link RackApplication}. // * // * @param rackApplication the application to host. // */ // public RackServlet(RackApplication rackApplication) { // this(new RackEnvironmentBuilder(), rackApplication, new RackResponsePropagator()); // } // // /** // * Creates a servlet hosting the given {@link RackApplication} and that uses the given // * collaborators to translate between the Servlet and Rack environments. // * // * @param rackEnvironmentBuilder turns {@link HttpServletRequest}s into {@link RackEnvironment}s. // * @param rackApplication the application to host. // * @param rackResponsePropagator writes {@link RackResponse}s onto {@link HttpServletResponse}s. // */ // public RackServlet(RackEnvironmentBuilder rackEnvironmentBuilder, // RackApplication rackApplication, // RackResponsePropagator rackResponsePropagator) { // this.rackEnvironmentBuilder = rackEnvironmentBuilder; // this.rackApplication = rackApplication; // this.rackResponsePropagator = rackResponsePropagator; // } // // @Override protected void service(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException { // RackEnvironment rackEnvironment = rackEnvironmentBuilder.build(request); // // try { // RackResponse rackResponse = rackApplication.call(rackEnvironment); // rackResponsePropagator.propagate(rackResponse, response); // } finally { // rackEnvironment.closeRackInput(); // } // } // }
import com.squareup.rack.jruby.JRubyRackApplication; import com.squareup.rack.servlet.RackServlet; import java.io.IOException; import org.apache.http.Header; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.jruby.embed.ScriptingContainer; import org.jruby.runtime.builtin.IRubyObject; import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.fest.assertions.api.Assertions.assertThat; import static org.jruby.embed.PathType.CLASSPATH; import static org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY;
package com.squareup.rack.integration; public class MultiValuedHeadersTest { private HttpClient client; private HttpHost localhost; private ExampleServer server; @Before public void setUp() throws Exception { // Silence logging. System.setProperty(DEFAULT_LOG_LEVEL_KEY, "WARN"); // Build the Rack servlet. ScriptingContainer ruby = new ScriptingContainer(); IRubyObject application = ruby.parse(CLASSPATH, "application.rb").run();
// Path: core/src/main/java/com/squareup/rack/jruby/JRubyRackApplication.java // public class JRubyRackApplication implements RackApplication { // private final IRubyObject application; // private final Ruby runtime; // private final ThreadService threadService; // // /** // * <p>Creates a {@link RackApplication} that delegates to the given Ruby Rack application.</p> // * // * <p>To obtain the necessary {@link IRubyObject}, you can create a JRuby // * {@link org.jruby.embed.ScriptingContainer} and {@link org.jruby.embed.ScriptingContainer#parse} // * and {@link org.jruby.embed.EmbedEvalUnit#run()} your Ruby code. See our examples for concrete // * code.</p> // * // * @param application the Ruby Rack application. // */ // public JRubyRackApplication(IRubyObject application) { // this.application = application; // this.runtime = application.getRuntime(); // this.threadService = runtime.getThreadService(); // } // // /** // * Calls the delegate Rack application, translating into and back out of the JRuby interpreter. // * // * @param environment the Rack environment // * @return the Rack response // */ // @Override public RackResponse call(RackEnvironment environment) { // RubyHash environmentHash = convertToRubyHash(environment.entrySet()); // // RubyArray response = callRackApplication(environmentHash); // // return convertToJavaRackResponse(response); // } // // private RubyHash convertToRubyHash(Set<Map.Entry<String, Object>> entries) { // RubyHash hash = newHash(runtime); // // for (Map.Entry<String, Object> entry : entries) { // String key = entry.getKey(); // Object value = entry.getValue(); // // if (key.equals("rack.input")) { // value = new JRubyRackInput(runtime, (RackInput) value); // } // // if (key.equals("rack.version")) { // value = convertToRubyArray((List<Integer>) value); // } // // hash.put(key, value); // } // // return hash; // } // // private RubyArray convertToRubyArray(List<Integer> list) { // RubyArray array = RubyArray.newEmptyArray(runtime); // array.addAll(list); // return array; // } // // private RubyArray callRackApplication(RubyHash rubyHash) { // return (RubyArray) application.callMethod(threadService.getCurrentContext(), "call", rubyHash); // } // // private RackResponse convertToJavaRackResponse(RubyArray response) { // int status = Integer.parseInt(response.get(0).toString(), 10); // Map headers = (Map) response.get(1); // IRubyObject body = (IRubyObject) response.get(2); // // return new RackResponse(status, headers, new JRubyRackBodyIterator(body)); // } // } // // Path: core/src/main/java/com/squareup/rack/servlet/RackServlet.java // public class RackServlet extends HttpServlet { // private final RackEnvironmentBuilder rackEnvironmentBuilder; // private final RackApplication rackApplication; // private final RackResponsePropagator rackResponsePropagator; // // /** // * Creates a servlet hosting the given {@link RackApplication}. // * // * @param rackApplication the application to host. // */ // public RackServlet(RackApplication rackApplication) { // this(new RackEnvironmentBuilder(), rackApplication, new RackResponsePropagator()); // } // // /** // * Creates a servlet hosting the given {@link RackApplication} and that uses the given // * collaborators to translate between the Servlet and Rack environments. // * // * @param rackEnvironmentBuilder turns {@link HttpServletRequest}s into {@link RackEnvironment}s. // * @param rackApplication the application to host. // * @param rackResponsePropagator writes {@link RackResponse}s onto {@link HttpServletResponse}s. // */ // public RackServlet(RackEnvironmentBuilder rackEnvironmentBuilder, // RackApplication rackApplication, // RackResponsePropagator rackResponsePropagator) { // this.rackEnvironmentBuilder = rackEnvironmentBuilder; // this.rackApplication = rackApplication; // this.rackResponsePropagator = rackResponsePropagator; // } // // @Override protected void service(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException { // RackEnvironment rackEnvironment = rackEnvironmentBuilder.build(request); // // try { // RackResponse rackResponse = rackApplication.call(rackEnvironment); // rackResponsePropagator.propagate(rackResponse, response); // } finally { // rackEnvironment.closeRackInput(); // } // } // } // Path: integration/src/test/java/com/squareup/rack/integration/MultiValuedHeadersTest.java import com.squareup.rack.jruby.JRubyRackApplication; import com.squareup.rack.servlet.RackServlet; import java.io.IOException; import org.apache.http.Header; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.jruby.embed.ScriptingContainer; import org.jruby.runtime.builtin.IRubyObject; import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.fest.assertions.api.Assertions.assertThat; import static org.jruby.embed.PathType.CLASSPATH; import static org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY; package com.squareup.rack.integration; public class MultiValuedHeadersTest { private HttpClient client; private HttpHost localhost; private ExampleServer server; @Before public void setUp() throws Exception { // Silence logging. System.setProperty(DEFAULT_LOG_LEVEL_KEY, "WARN"); // Build the Rack servlet. ScriptingContainer ruby = new ScriptingContainer(); IRubyObject application = ruby.parse(CLASSPATH, "application.rb").run();
RackServlet servlet = new RackServlet(new JRubyRackApplication(application));
square/rack-servlet
core/src/main/java/com/squareup/rack/servlet/RackResponsePropagator.java
// Path: core/src/main/java/com/squareup/rack/RackResponse.java // public class RackResponse { // private final int status; // private final Map<String, String> headers; // private final Iterator<byte[]> body; // // /** // * Creates a {@link RackResponse} with the given contents. // * // * @param status the HTTP status code. // * @param headers the HTTP response headers. // * @param body the HTTP response body. // */ // public RackResponse(int status, Map<String, String> headers, Iterator<byte[]> body) { // this.status = status; // this.headers = headers; // this.body = body; // } // // /** // * @return the HTTP status code. // */ // public int getStatus() { // return status; // } // // /** // * @return the HTTP response headers. // */ // public Map<String, String> getHeaders() { // return headers; // } // // /** // * @return the HTTP response body. // */ // public Iterator<byte[]> getBody() { // return body; // } // }
import com.google.common.base.Throwables; import com.squareup.rack.RackResponse; import java.io.IOException; import java.util.Iterator; import java.util.Map; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse;
/* * Copyright (C) 2013 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.squareup.rack.servlet; /** * Writes a {@link RackResponse} onto an {@link HttpServletResponse}. */ public class RackResponsePropagator { private static final String RACK_INTERNAL_HEADER_PREFIX = "rack.";
// Path: core/src/main/java/com/squareup/rack/RackResponse.java // public class RackResponse { // private final int status; // private final Map<String, String> headers; // private final Iterator<byte[]> body; // // /** // * Creates a {@link RackResponse} with the given contents. // * // * @param status the HTTP status code. // * @param headers the HTTP response headers. // * @param body the HTTP response body. // */ // public RackResponse(int status, Map<String, String> headers, Iterator<byte[]> body) { // this.status = status; // this.headers = headers; // this.body = body; // } // // /** // * @return the HTTP status code. // */ // public int getStatus() { // return status; // } // // /** // * @return the HTTP response headers. // */ // public Map<String, String> getHeaders() { // return headers; // } // // /** // * @return the HTTP response body. // */ // public Iterator<byte[]> getBody() { // return body; // } // } // Path: core/src/main/java/com/squareup/rack/servlet/RackResponsePropagator.java import com.google.common.base.Throwables; import com.squareup.rack.RackResponse; import java.io.IOException; import java.util.Iterator; import java.util.Map; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; /* * Copyright (C) 2013 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.squareup.rack.servlet; /** * Writes a {@link RackResponse} onto an {@link HttpServletResponse}. */ public class RackResponsePropagator { private static final String RACK_INTERNAL_HEADER_PREFIX = "rack.";
public void propagate(RackResponse rackResponse, HttpServletResponse response) {
square/rack-servlet
examples/jetty/src/test/java/com/squareup/rack/examples/jetty/ExampleServerTest.java
// Path: core/src/main/java/com/squareup/rack/jruby/JRubyRackApplication.java // public class JRubyRackApplication implements RackApplication { // private final IRubyObject application; // private final Ruby runtime; // private final ThreadService threadService; // // /** // * <p>Creates a {@link RackApplication} that delegates to the given Ruby Rack application.</p> // * // * <p>To obtain the necessary {@link IRubyObject}, you can create a JRuby // * {@link org.jruby.embed.ScriptingContainer} and {@link org.jruby.embed.ScriptingContainer#parse} // * and {@link org.jruby.embed.EmbedEvalUnit#run()} your Ruby code. See our examples for concrete // * code.</p> // * // * @param application the Ruby Rack application. // */ // public JRubyRackApplication(IRubyObject application) { // this.application = application; // this.runtime = application.getRuntime(); // this.threadService = runtime.getThreadService(); // } // // /** // * Calls the delegate Rack application, translating into and back out of the JRuby interpreter. // * // * @param environment the Rack environment // * @return the Rack response // */ // @Override public RackResponse call(RackEnvironment environment) { // RubyHash environmentHash = convertToRubyHash(environment.entrySet()); // // RubyArray response = callRackApplication(environmentHash); // // return convertToJavaRackResponse(response); // } // // private RubyHash convertToRubyHash(Set<Map.Entry<String, Object>> entries) { // RubyHash hash = newHash(runtime); // // for (Map.Entry<String, Object> entry : entries) { // String key = entry.getKey(); // Object value = entry.getValue(); // // if (key.equals("rack.input")) { // value = new JRubyRackInput(runtime, (RackInput) value); // } // // if (key.equals("rack.version")) { // value = convertToRubyArray((List<Integer>) value); // } // // hash.put(key, value); // } // // return hash; // } // // private RubyArray convertToRubyArray(List<Integer> list) { // RubyArray array = RubyArray.newEmptyArray(runtime); // array.addAll(list); // return array; // } // // private RubyArray callRackApplication(RubyHash rubyHash) { // return (RubyArray) application.callMethod(threadService.getCurrentContext(), "call", rubyHash); // } // // private RackResponse convertToJavaRackResponse(RubyArray response) { // int status = Integer.parseInt(response.get(0).toString(), 10); // Map headers = (Map) response.get(1); // IRubyObject body = (IRubyObject) response.get(2); // // return new RackResponse(status, headers, new JRubyRackBodyIterator(body)); // } // } // // Path: core/src/main/java/com/squareup/rack/servlet/RackServlet.java // public class RackServlet extends HttpServlet { // private final RackEnvironmentBuilder rackEnvironmentBuilder; // private final RackApplication rackApplication; // private final RackResponsePropagator rackResponsePropagator; // // /** // * Creates a servlet hosting the given {@link RackApplication}. // * // * @param rackApplication the application to host. // */ // public RackServlet(RackApplication rackApplication) { // this(new RackEnvironmentBuilder(), rackApplication, new RackResponsePropagator()); // } // // /** // * Creates a servlet hosting the given {@link RackApplication} and that uses the given // * collaborators to translate between the Servlet and Rack environments. // * // * @param rackEnvironmentBuilder turns {@link HttpServletRequest}s into {@link RackEnvironment}s. // * @param rackApplication the application to host. // * @param rackResponsePropagator writes {@link RackResponse}s onto {@link HttpServletResponse}s. // */ // public RackServlet(RackEnvironmentBuilder rackEnvironmentBuilder, // RackApplication rackApplication, // RackResponsePropagator rackResponsePropagator) { // this.rackEnvironmentBuilder = rackEnvironmentBuilder; // this.rackApplication = rackApplication; // this.rackResponsePropagator = rackResponsePropagator; // } // // @Override protected void service(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException { // RackEnvironment rackEnvironment = rackEnvironmentBuilder.build(request); // // try { // RackResponse rackResponse = rackApplication.call(rackEnvironment); // rackResponsePropagator.propagate(rackResponse, response); // } finally { // rackEnvironment.closeRackInput(); // } // } // }
import com.squareup.rack.jruby.JRubyRackApplication; import com.squareup.rack.servlet.RackServlet; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import javax.servlet.Servlet; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.NetworkConnector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.jruby.embed.ScriptingContainer; import org.jruby.runtime.builtin.IRubyObject; import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.fest.assertions.api.Assertions.assertThat; import static org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY;
package com.squareup.rack.examples.jetty; public class ExampleServerTest { private HttpClient client; private HttpHost localhost; private ExampleServer server; @Before public void setUp() throws Exception { // Silence logging. System.setProperty(DEFAULT_LOG_LEVEL_KEY, "WARN"); // Build the Rack servlet. ScriptingContainer ruby = new ScriptingContainer(); IRubyObject application = ruby.parse("lambda { |env| [200, {}, ['Hello, World!']] }").run();
// Path: core/src/main/java/com/squareup/rack/jruby/JRubyRackApplication.java // public class JRubyRackApplication implements RackApplication { // private final IRubyObject application; // private final Ruby runtime; // private final ThreadService threadService; // // /** // * <p>Creates a {@link RackApplication} that delegates to the given Ruby Rack application.</p> // * // * <p>To obtain the necessary {@link IRubyObject}, you can create a JRuby // * {@link org.jruby.embed.ScriptingContainer} and {@link org.jruby.embed.ScriptingContainer#parse} // * and {@link org.jruby.embed.EmbedEvalUnit#run()} your Ruby code. See our examples for concrete // * code.</p> // * // * @param application the Ruby Rack application. // */ // public JRubyRackApplication(IRubyObject application) { // this.application = application; // this.runtime = application.getRuntime(); // this.threadService = runtime.getThreadService(); // } // // /** // * Calls the delegate Rack application, translating into and back out of the JRuby interpreter. // * // * @param environment the Rack environment // * @return the Rack response // */ // @Override public RackResponse call(RackEnvironment environment) { // RubyHash environmentHash = convertToRubyHash(environment.entrySet()); // // RubyArray response = callRackApplication(environmentHash); // // return convertToJavaRackResponse(response); // } // // private RubyHash convertToRubyHash(Set<Map.Entry<String, Object>> entries) { // RubyHash hash = newHash(runtime); // // for (Map.Entry<String, Object> entry : entries) { // String key = entry.getKey(); // Object value = entry.getValue(); // // if (key.equals("rack.input")) { // value = new JRubyRackInput(runtime, (RackInput) value); // } // // if (key.equals("rack.version")) { // value = convertToRubyArray((List<Integer>) value); // } // // hash.put(key, value); // } // // return hash; // } // // private RubyArray convertToRubyArray(List<Integer> list) { // RubyArray array = RubyArray.newEmptyArray(runtime); // array.addAll(list); // return array; // } // // private RubyArray callRackApplication(RubyHash rubyHash) { // return (RubyArray) application.callMethod(threadService.getCurrentContext(), "call", rubyHash); // } // // private RackResponse convertToJavaRackResponse(RubyArray response) { // int status = Integer.parseInt(response.get(0).toString(), 10); // Map headers = (Map) response.get(1); // IRubyObject body = (IRubyObject) response.get(2); // // return new RackResponse(status, headers, new JRubyRackBodyIterator(body)); // } // } // // Path: core/src/main/java/com/squareup/rack/servlet/RackServlet.java // public class RackServlet extends HttpServlet { // private final RackEnvironmentBuilder rackEnvironmentBuilder; // private final RackApplication rackApplication; // private final RackResponsePropagator rackResponsePropagator; // // /** // * Creates a servlet hosting the given {@link RackApplication}. // * // * @param rackApplication the application to host. // */ // public RackServlet(RackApplication rackApplication) { // this(new RackEnvironmentBuilder(), rackApplication, new RackResponsePropagator()); // } // // /** // * Creates a servlet hosting the given {@link RackApplication} and that uses the given // * collaborators to translate between the Servlet and Rack environments. // * // * @param rackEnvironmentBuilder turns {@link HttpServletRequest}s into {@link RackEnvironment}s. // * @param rackApplication the application to host. // * @param rackResponsePropagator writes {@link RackResponse}s onto {@link HttpServletResponse}s. // */ // public RackServlet(RackEnvironmentBuilder rackEnvironmentBuilder, // RackApplication rackApplication, // RackResponsePropagator rackResponsePropagator) { // this.rackEnvironmentBuilder = rackEnvironmentBuilder; // this.rackApplication = rackApplication; // this.rackResponsePropagator = rackResponsePropagator; // } // // @Override protected void service(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException { // RackEnvironment rackEnvironment = rackEnvironmentBuilder.build(request); // // try { // RackResponse rackResponse = rackApplication.call(rackEnvironment); // rackResponsePropagator.propagate(rackResponse, response); // } finally { // rackEnvironment.closeRackInput(); // } // } // } // Path: examples/jetty/src/test/java/com/squareup/rack/examples/jetty/ExampleServerTest.java import com.squareup.rack.jruby.JRubyRackApplication; import com.squareup.rack.servlet.RackServlet; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import javax.servlet.Servlet; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.NetworkConnector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.jruby.embed.ScriptingContainer; import org.jruby.runtime.builtin.IRubyObject; import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.fest.assertions.api.Assertions.assertThat; import static org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY; package com.squareup.rack.examples.jetty; public class ExampleServerTest { private HttpClient client; private HttpHost localhost; private ExampleServer server; @Before public void setUp() throws Exception { // Silence logging. System.setProperty(DEFAULT_LOG_LEVEL_KEY, "WARN"); // Build the Rack servlet. ScriptingContainer ruby = new ScriptingContainer(); IRubyObject application = ruby.parse("lambda { |env| [200, {}, ['Hello, World!']] }").run();
RackServlet servlet = new RackServlet(new JRubyRackApplication(application));
square/rack-servlet
examples/jetty/src/test/java/com/squareup/rack/examples/jetty/ExampleServerTest.java
// Path: core/src/main/java/com/squareup/rack/jruby/JRubyRackApplication.java // public class JRubyRackApplication implements RackApplication { // private final IRubyObject application; // private final Ruby runtime; // private final ThreadService threadService; // // /** // * <p>Creates a {@link RackApplication} that delegates to the given Ruby Rack application.</p> // * // * <p>To obtain the necessary {@link IRubyObject}, you can create a JRuby // * {@link org.jruby.embed.ScriptingContainer} and {@link org.jruby.embed.ScriptingContainer#parse} // * and {@link org.jruby.embed.EmbedEvalUnit#run()} your Ruby code. See our examples for concrete // * code.</p> // * // * @param application the Ruby Rack application. // */ // public JRubyRackApplication(IRubyObject application) { // this.application = application; // this.runtime = application.getRuntime(); // this.threadService = runtime.getThreadService(); // } // // /** // * Calls the delegate Rack application, translating into and back out of the JRuby interpreter. // * // * @param environment the Rack environment // * @return the Rack response // */ // @Override public RackResponse call(RackEnvironment environment) { // RubyHash environmentHash = convertToRubyHash(environment.entrySet()); // // RubyArray response = callRackApplication(environmentHash); // // return convertToJavaRackResponse(response); // } // // private RubyHash convertToRubyHash(Set<Map.Entry<String, Object>> entries) { // RubyHash hash = newHash(runtime); // // for (Map.Entry<String, Object> entry : entries) { // String key = entry.getKey(); // Object value = entry.getValue(); // // if (key.equals("rack.input")) { // value = new JRubyRackInput(runtime, (RackInput) value); // } // // if (key.equals("rack.version")) { // value = convertToRubyArray((List<Integer>) value); // } // // hash.put(key, value); // } // // return hash; // } // // private RubyArray convertToRubyArray(List<Integer> list) { // RubyArray array = RubyArray.newEmptyArray(runtime); // array.addAll(list); // return array; // } // // private RubyArray callRackApplication(RubyHash rubyHash) { // return (RubyArray) application.callMethod(threadService.getCurrentContext(), "call", rubyHash); // } // // private RackResponse convertToJavaRackResponse(RubyArray response) { // int status = Integer.parseInt(response.get(0).toString(), 10); // Map headers = (Map) response.get(1); // IRubyObject body = (IRubyObject) response.get(2); // // return new RackResponse(status, headers, new JRubyRackBodyIterator(body)); // } // } // // Path: core/src/main/java/com/squareup/rack/servlet/RackServlet.java // public class RackServlet extends HttpServlet { // private final RackEnvironmentBuilder rackEnvironmentBuilder; // private final RackApplication rackApplication; // private final RackResponsePropagator rackResponsePropagator; // // /** // * Creates a servlet hosting the given {@link RackApplication}. // * // * @param rackApplication the application to host. // */ // public RackServlet(RackApplication rackApplication) { // this(new RackEnvironmentBuilder(), rackApplication, new RackResponsePropagator()); // } // // /** // * Creates a servlet hosting the given {@link RackApplication} and that uses the given // * collaborators to translate between the Servlet and Rack environments. // * // * @param rackEnvironmentBuilder turns {@link HttpServletRequest}s into {@link RackEnvironment}s. // * @param rackApplication the application to host. // * @param rackResponsePropagator writes {@link RackResponse}s onto {@link HttpServletResponse}s. // */ // public RackServlet(RackEnvironmentBuilder rackEnvironmentBuilder, // RackApplication rackApplication, // RackResponsePropagator rackResponsePropagator) { // this.rackEnvironmentBuilder = rackEnvironmentBuilder; // this.rackApplication = rackApplication; // this.rackResponsePropagator = rackResponsePropagator; // } // // @Override protected void service(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException { // RackEnvironment rackEnvironment = rackEnvironmentBuilder.build(request); // // try { // RackResponse rackResponse = rackApplication.call(rackEnvironment); // rackResponsePropagator.propagate(rackResponse, response); // } finally { // rackEnvironment.closeRackInput(); // } // } // }
import com.squareup.rack.jruby.JRubyRackApplication; import com.squareup.rack.servlet.RackServlet; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import javax.servlet.Servlet; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.NetworkConnector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.jruby.embed.ScriptingContainer; import org.jruby.runtime.builtin.IRubyObject; import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.fest.assertions.api.Assertions.assertThat; import static org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY;
package com.squareup.rack.examples.jetty; public class ExampleServerTest { private HttpClient client; private HttpHost localhost; private ExampleServer server; @Before public void setUp() throws Exception { // Silence logging. System.setProperty(DEFAULT_LOG_LEVEL_KEY, "WARN"); // Build the Rack servlet. ScriptingContainer ruby = new ScriptingContainer(); IRubyObject application = ruby.parse("lambda { |env| [200, {}, ['Hello, World!']] }").run();
// Path: core/src/main/java/com/squareup/rack/jruby/JRubyRackApplication.java // public class JRubyRackApplication implements RackApplication { // private final IRubyObject application; // private final Ruby runtime; // private final ThreadService threadService; // // /** // * <p>Creates a {@link RackApplication} that delegates to the given Ruby Rack application.</p> // * // * <p>To obtain the necessary {@link IRubyObject}, you can create a JRuby // * {@link org.jruby.embed.ScriptingContainer} and {@link org.jruby.embed.ScriptingContainer#parse} // * and {@link org.jruby.embed.EmbedEvalUnit#run()} your Ruby code. See our examples for concrete // * code.</p> // * // * @param application the Ruby Rack application. // */ // public JRubyRackApplication(IRubyObject application) { // this.application = application; // this.runtime = application.getRuntime(); // this.threadService = runtime.getThreadService(); // } // // /** // * Calls the delegate Rack application, translating into and back out of the JRuby interpreter. // * // * @param environment the Rack environment // * @return the Rack response // */ // @Override public RackResponse call(RackEnvironment environment) { // RubyHash environmentHash = convertToRubyHash(environment.entrySet()); // // RubyArray response = callRackApplication(environmentHash); // // return convertToJavaRackResponse(response); // } // // private RubyHash convertToRubyHash(Set<Map.Entry<String, Object>> entries) { // RubyHash hash = newHash(runtime); // // for (Map.Entry<String, Object> entry : entries) { // String key = entry.getKey(); // Object value = entry.getValue(); // // if (key.equals("rack.input")) { // value = new JRubyRackInput(runtime, (RackInput) value); // } // // if (key.equals("rack.version")) { // value = convertToRubyArray((List<Integer>) value); // } // // hash.put(key, value); // } // // return hash; // } // // private RubyArray convertToRubyArray(List<Integer> list) { // RubyArray array = RubyArray.newEmptyArray(runtime); // array.addAll(list); // return array; // } // // private RubyArray callRackApplication(RubyHash rubyHash) { // return (RubyArray) application.callMethod(threadService.getCurrentContext(), "call", rubyHash); // } // // private RackResponse convertToJavaRackResponse(RubyArray response) { // int status = Integer.parseInt(response.get(0).toString(), 10); // Map headers = (Map) response.get(1); // IRubyObject body = (IRubyObject) response.get(2); // // return new RackResponse(status, headers, new JRubyRackBodyIterator(body)); // } // } // // Path: core/src/main/java/com/squareup/rack/servlet/RackServlet.java // public class RackServlet extends HttpServlet { // private final RackEnvironmentBuilder rackEnvironmentBuilder; // private final RackApplication rackApplication; // private final RackResponsePropagator rackResponsePropagator; // // /** // * Creates a servlet hosting the given {@link RackApplication}. // * // * @param rackApplication the application to host. // */ // public RackServlet(RackApplication rackApplication) { // this(new RackEnvironmentBuilder(), rackApplication, new RackResponsePropagator()); // } // // /** // * Creates a servlet hosting the given {@link RackApplication} and that uses the given // * collaborators to translate between the Servlet and Rack environments. // * // * @param rackEnvironmentBuilder turns {@link HttpServletRequest}s into {@link RackEnvironment}s. // * @param rackApplication the application to host. // * @param rackResponsePropagator writes {@link RackResponse}s onto {@link HttpServletResponse}s. // */ // public RackServlet(RackEnvironmentBuilder rackEnvironmentBuilder, // RackApplication rackApplication, // RackResponsePropagator rackResponsePropagator) { // this.rackEnvironmentBuilder = rackEnvironmentBuilder; // this.rackApplication = rackApplication; // this.rackResponsePropagator = rackResponsePropagator; // } // // @Override protected void service(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException { // RackEnvironment rackEnvironment = rackEnvironmentBuilder.build(request); // // try { // RackResponse rackResponse = rackApplication.call(rackEnvironment); // rackResponsePropagator.propagate(rackResponse, response); // } finally { // rackEnvironment.closeRackInput(); // } // } // } // Path: examples/jetty/src/test/java/com/squareup/rack/examples/jetty/ExampleServerTest.java import com.squareup.rack.jruby.JRubyRackApplication; import com.squareup.rack.servlet.RackServlet; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import javax.servlet.Servlet; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.NetworkConnector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.jruby.embed.ScriptingContainer; import org.jruby.runtime.builtin.IRubyObject; import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.fest.assertions.api.Assertions.assertThat; import static org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY; package com.squareup.rack.examples.jetty; public class ExampleServerTest { private HttpClient client; private HttpHost localhost; private ExampleServer server; @Before public void setUp() throws Exception { // Silence logging. System.setProperty(DEFAULT_LOG_LEVEL_KEY, "WARN"); // Build the Rack servlet. ScriptingContainer ruby = new ScriptingContainer(); IRubyObject application = ruby.parse("lambda { |env| [200, {}, ['Hello, World!']] }").run();
RackServlet servlet = new RackServlet(new JRubyRackApplication(application));
square/rack-servlet
integration/src/test/java/com/squareup/rack/integration/HeaderFlushingTest.java
// Path: core/src/main/java/com/squareup/rack/jruby/JRubyRackApplication.java // public class JRubyRackApplication implements RackApplication { // private final IRubyObject application; // private final Ruby runtime; // private final ThreadService threadService; // // /** // * <p>Creates a {@link RackApplication} that delegates to the given Ruby Rack application.</p> // * // * <p>To obtain the necessary {@link IRubyObject}, you can create a JRuby // * {@link org.jruby.embed.ScriptingContainer} and {@link org.jruby.embed.ScriptingContainer#parse} // * and {@link org.jruby.embed.EmbedEvalUnit#run()} your Ruby code. See our examples for concrete // * code.</p> // * // * @param application the Ruby Rack application. // */ // public JRubyRackApplication(IRubyObject application) { // this.application = application; // this.runtime = application.getRuntime(); // this.threadService = runtime.getThreadService(); // } // // /** // * Calls the delegate Rack application, translating into and back out of the JRuby interpreter. // * // * @param environment the Rack environment // * @return the Rack response // */ // @Override public RackResponse call(RackEnvironment environment) { // RubyHash environmentHash = convertToRubyHash(environment.entrySet()); // // RubyArray response = callRackApplication(environmentHash); // // return convertToJavaRackResponse(response); // } // // private RubyHash convertToRubyHash(Set<Map.Entry<String, Object>> entries) { // RubyHash hash = newHash(runtime); // // for (Map.Entry<String, Object> entry : entries) { // String key = entry.getKey(); // Object value = entry.getValue(); // // if (key.equals("rack.input")) { // value = new JRubyRackInput(runtime, (RackInput) value); // } // // if (key.equals("rack.version")) { // value = convertToRubyArray((List<Integer>) value); // } // // hash.put(key, value); // } // // return hash; // } // // private RubyArray convertToRubyArray(List<Integer> list) { // RubyArray array = RubyArray.newEmptyArray(runtime); // array.addAll(list); // return array; // } // // private RubyArray callRackApplication(RubyHash rubyHash) { // return (RubyArray) application.callMethod(threadService.getCurrentContext(), "call", rubyHash); // } // // private RackResponse convertToJavaRackResponse(RubyArray response) { // int status = Integer.parseInt(response.get(0).toString(), 10); // Map headers = (Map) response.get(1); // IRubyObject body = (IRubyObject) response.get(2); // // return new RackResponse(status, headers, new JRubyRackBodyIterator(body)); // } // } // // Path: core/src/main/java/com/squareup/rack/servlet/RackServlet.java // public class RackServlet extends HttpServlet { // private final RackEnvironmentBuilder rackEnvironmentBuilder; // private final RackApplication rackApplication; // private final RackResponsePropagator rackResponsePropagator; // // /** // * Creates a servlet hosting the given {@link RackApplication}. // * // * @param rackApplication the application to host. // */ // public RackServlet(RackApplication rackApplication) { // this(new RackEnvironmentBuilder(), rackApplication, new RackResponsePropagator()); // } // // /** // * Creates a servlet hosting the given {@link RackApplication} and that uses the given // * collaborators to translate between the Servlet and Rack environments. // * // * @param rackEnvironmentBuilder turns {@link HttpServletRequest}s into {@link RackEnvironment}s. // * @param rackApplication the application to host. // * @param rackResponsePropagator writes {@link RackResponse}s onto {@link HttpServletResponse}s. // */ // public RackServlet(RackEnvironmentBuilder rackEnvironmentBuilder, // RackApplication rackApplication, // RackResponsePropagator rackResponsePropagator) { // this.rackEnvironmentBuilder = rackEnvironmentBuilder; // this.rackApplication = rackApplication; // this.rackResponsePropagator = rackResponsePropagator; // } // // @Override protected void service(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException { // RackEnvironment rackEnvironment = rackEnvironmentBuilder.build(request); // // try { // RackResponse rackResponse = rackApplication.call(rackEnvironment); // rackResponsePropagator.propagate(rackResponse, response); // } finally { // rackEnvironment.closeRackInput(); // } // } // }
import com.squareup.rack.jruby.JRubyRackApplication; import com.squareup.rack.servlet.RackServlet; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.jruby.embed.ScriptingContainer; import org.jruby.runtime.builtin.IRubyObject; import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.fest.assertions.api.Assertions.assertThat; import static org.jruby.embed.PathType.CLASSPATH; import static org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY;
package com.squareup.rack.integration; public class HeaderFlushingTest { private HttpClient client; private HttpHost localhost; private ExampleServer server; @Before public void setUp() throws Exception { // Silence logging. System.setProperty(DEFAULT_LOG_LEVEL_KEY, "WARN"); // Build the Rack servlet. ScriptingContainer ruby = new ScriptingContainer(); IRubyObject application = ruby.parse(CLASSPATH, "application.rb").run();
// Path: core/src/main/java/com/squareup/rack/jruby/JRubyRackApplication.java // public class JRubyRackApplication implements RackApplication { // private final IRubyObject application; // private final Ruby runtime; // private final ThreadService threadService; // // /** // * <p>Creates a {@link RackApplication} that delegates to the given Ruby Rack application.</p> // * // * <p>To obtain the necessary {@link IRubyObject}, you can create a JRuby // * {@link org.jruby.embed.ScriptingContainer} and {@link org.jruby.embed.ScriptingContainer#parse} // * and {@link org.jruby.embed.EmbedEvalUnit#run()} your Ruby code. See our examples for concrete // * code.</p> // * // * @param application the Ruby Rack application. // */ // public JRubyRackApplication(IRubyObject application) { // this.application = application; // this.runtime = application.getRuntime(); // this.threadService = runtime.getThreadService(); // } // // /** // * Calls the delegate Rack application, translating into and back out of the JRuby interpreter. // * // * @param environment the Rack environment // * @return the Rack response // */ // @Override public RackResponse call(RackEnvironment environment) { // RubyHash environmentHash = convertToRubyHash(environment.entrySet()); // // RubyArray response = callRackApplication(environmentHash); // // return convertToJavaRackResponse(response); // } // // private RubyHash convertToRubyHash(Set<Map.Entry<String, Object>> entries) { // RubyHash hash = newHash(runtime); // // for (Map.Entry<String, Object> entry : entries) { // String key = entry.getKey(); // Object value = entry.getValue(); // // if (key.equals("rack.input")) { // value = new JRubyRackInput(runtime, (RackInput) value); // } // // if (key.equals("rack.version")) { // value = convertToRubyArray((List<Integer>) value); // } // // hash.put(key, value); // } // // return hash; // } // // private RubyArray convertToRubyArray(List<Integer> list) { // RubyArray array = RubyArray.newEmptyArray(runtime); // array.addAll(list); // return array; // } // // private RubyArray callRackApplication(RubyHash rubyHash) { // return (RubyArray) application.callMethod(threadService.getCurrentContext(), "call", rubyHash); // } // // private RackResponse convertToJavaRackResponse(RubyArray response) { // int status = Integer.parseInt(response.get(0).toString(), 10); // Map headers = (Map) response.get(1); // IRubyObject body = (IRubyObject) response.get(2); // // return new RackResponse(status, headers, new JRubyRackBodyIterator(body)); // } // } // // Path: core/src/main/java/com/squareup/rack/servlet/RackServlet.java // public class RackServlet extends HttpServlet { // private final RackEnvironmentBuilder rackEnvironmentBuilder; // private final RackApplication rackApplication; // private final RackResponsePropagator rackResponsePropagator; // // /** // * Creates a servlet hosting the given {@link RackApplication}. // * // * @param rackApplication the application to host. // */ // public RackServlet(RackApplication rackApplication) { // this(new RackEnvironmentBuilder(), rackApplication, new RackResponsePropagator()); // } // // /** // * Creates a servlet hosting the given {@link RackApplication} and that uses the given // * collaborators to translate between the Servlet and Rack environments. // * // * @param rackEnvironmentBuilder turns {@link HttpServletRequest}s into {@link RackEnvironment}s. // * @param rackApplication the application to host. // * @param rackResponsePropagator writes {@link RackResponse}s onto {@link HttpServletResponse}s. // */ // public RackServlet(RackEnvironmentBuilder rackEnvironmentBuilder, // RackApplication rackApplication, // RackResponsePropagator rackResponsePropagator) { // this.rackEnvironmentBuilder = rackEnvironmentBuilder; // this.rackApplication = rackApplication; // this.rackResponsePropagator = rackResponsePropagator; // } // // @Override protected void service(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException { // RackEnvironment rackEnvironment = rackEnvironmentBuilder.build(request); // // try { // RackResponse rackResponse = rackApplication.call(rackEnvironment); // rackResponsePropagator.propagate(rackResponse, response); // } finally { // rackEnvironment.closeRackInput(); // } // } // } // Path: integration/src/test/java/com/squareup/rack/integration/HeaderFlushingTest.java import com.squareup.rack.jruby.JRubyRackApplication; import com.squareup.rack.servlet.RackServlet; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.jruby.embed.ScriptingContainer; import org.jruby.runtime.builtin.IRubyObject; import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.fest.assertions.api.Assertions.assertThat; import static org.jruby.embed.PathType.CLASSPATH; import static org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY; package com.squareup.rack.integration; public class HeaderFlushingTest { private HttpClient client; private HttpHost localhost; private ExampleServer server; @Before public void setUp() throws Exception { // Silence logging. System.setProperty(DEFAULT_LOG_LEVEL_KEY, "WARN"); // Build the Rack servlet. ScriptingContainer ruby = new ScriptingContainer(); IRubyObject application = ruby.parse(CLASSPATH, "application.rb").run();
RackServlet servlet = new RackServlet(new JRubyRackApplication(application));
square/rack-servlet
integration/src/test/java/com/squareup/rack/integration/HeaderFlushingTest.java
// Path: core/src/main/java/com/squareup/rack/jruby/JRubyRackApplication.java // public class JRubyRackApplication implements RackApplication { // private final IRubyObject application; // private final Ruby runtime; // private final ThreadService threadService; // // /** // * <p>Creates a {@link RackApplication} that delegates to the given Ruby Rack application.</p> // * // * <p>To obtain the necessary {@link IRubyObject}, you can create a JRuby // * {@link org.jruby.embed.ScriptingContainer} and {@link org.jruby.embed.ScriptingContainer#parse} // * and {@link org.jruby.embed.EmbedEvalUnit#run()} your Ruby code. See our examples for concrete // * code.</p> // * // * @param application the Ruby Rack application. // */ // public JRubyRackApplication(IRubyObject application) { // this.application = application; // this.runtime = application.getRuntime(); // this.threadService = runtime.getThreadService(); // } // // /** // * Calls the delegate Rack application, translating into and back out of the JRuby interpreter. // * // * @param environment the Rack environment // * @return the Rack response // */ // @Override public RackResponse call(RackEnvironment environment) { // RubyHash environmentHash = convertToRubyHash(environment.entrySet()); // // RubyArray response = callRackApplication(environmentHash); // // return convertToJavaRackResponse(response); // } // // private RubyHash convertToRubyHash(Set<Map.Entry<String, Object>> entries) { // RubyHash hash = newHash(runtime); // // for (Map.Entry<String, Object> entry : entries) { // String key = entry.getKey(); // Object value = entry.getValue(); // // if (key.equals("rack.input")) { // value = new JRubyRackInput(runtime, (RackInput) value); // } // // if (key.equals("rack.version")) { // value = convertToRubyArray((List<Integer>) value); // } // // hash.put(key, value); // } // // return hash; // } // // private RubyArray convertToRubyArray(List<Integer> list) { // RubyArray array = RubyArray.newEmptyArray(runtime); // array.addAll(list); // return array; // } // // private RubyArray callRackApplication(RubyHash rubyHash) { // return (RubyArray) application.callMethod(threadService.getCurrentContext(), "call", rubyHash); // } // // private RackResponse convertToJavaRackResponse(RubyArray response) { // int status = Integer.parseInt(response.get(0).toString(), 10); // Map headers = (Map) response.get(1); // IRubyObject body = (IRubyObject) response.get(2); // // return new RackResponse(status, headers, new JRubyRackBodyIterator(body)); // } // } // // Path: core/src/main/java/com/squareup/rack/servlet/RackServlet.java // public class RackServlet extends HttpServlet { // private final RackEnvironmentBuilder rackEnvironmentBuilder; // private final RackApplication rackApplication; // private final RackResponsePropagator rackResponsePropagator; // // /** // * Creates a servlet hosting the given {@link RackApplication}. // * // * @param rackApplication the application to host. // */ // public RackServlet(RackApplication rackApplication) { // this(new RackEnvironmentBuilder(), rackApplication, new RackResponsePropagator()); // } // // /** // * Creates a servlet hosting the given {@link RackApplication} and that uses the given // * collaborators to translate between the Servlet and Rack environments. // * // * @param rackEnvironmentBuilder turns {@link HttpServletRequest}s into {@link RackEnvironment}s. // * @param rackApplication the application to host. // * @param rackResponsePropagator writes {@link RackResponse}s onto {@link HttpServletResponse}s. // */ // public RackServlet(RackEnvironmentBuilder rackEnvironmentBuilder, // RackApplication rackApplication, // RackResponsePropagator rackResponsePropagator) { // this.rackEnvironmentBuilder = rackEnvironmentBuilder; // this.rackApplication = rackApplication; // this.rackResponsePropagator = rackResponsePropagator; // } // // @Override protected void service(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException { // RackEnvironment rackEnvironment = rackEnvironmentBuilder.build(request); // // try { // RackResponse rackResponse = rackApplication.call(rackEnvironment); // rackResponsePropagator.propagate(rackResponse, response); // } finally { // rackEnvironment.closeRackInput(); // } // } // }
import com.squareup.rack.jruby.JRubyRackApplication; import com.squareup.rack.servlet.RackServlet; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.jruby.embed.ScriptingContainer; import org.jruby.runtime.builtin.IRubyObject; import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.fest.assertions.api.Assertions.assertThat; import static org.jruby.embed.PathType.CLASSPATH; import static org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY;
package com.squareup.rack.integration; public class HeaderFlushingTest { private HttpClient client; private HttpHost localhost; private ExampleServer server; @Before public void setUp() throws Exception { // Silence logging. System.setProperty(DEFAULT_LOG_LEVEL_KEY, "WARN"); // Build the Rack servlet. ScriptingContainer ruby = new ScriptingContainer(); IRubyObject application = ruby.parse(CLASSPATH, "application.rb").run();
// Path: core/src/main/java/com/squareup/rack/jruby/JRubyRackApplication.java // public class JRubyRackApplication implements RackApplication { // private final IRubyObject application; // private final Ruby runtime; // private final ThreadService threadService; // // /** // * <p>Creates a {@link RackApplication} that delegates to the given Ruby Rack application.</p> // * // * <p>To obtain the necessary {@link IRubyObject}, you can create a JRuby // * {@link org.jruby.embed.ScriptingContainer} and {@link org.jruby.embed.ScriptingContainer#parse} // * and {@link org.jruby.embed.EmbedEvalUnit#run()} your Ruby code. See our examples for concrete // * code.</p> // * // * @param application the Ruby Rack application. // */ // public JRubyRackApplication(IRubyObject application) { // this.application = application; // this.runtime = application.getRuntime(); // this.threadService = runtime.getThreadService(); // } // // /** // * Calls the delegate Rack application, translating into and back out of the JRuby interpreter. // * // * @param environment the Rack environment // * @return the Rack response // */ // @Override public RackResponse call(RackEnvironment environment) { // RubyHash environmentHash = convertToRubyHash(environment.entrySet()); // // RubyArray response = callRackApplication(environmentHash); // // return convertToJavaRackResponse(response); // } // // private RubyHash convertToRubyHash(Set<Map.Entry<String, Object>> entries) { // RubyHash hash = newHash(runtime); // // for (Map.Entry<String, Object> entry : entries) { // String key = entry.getKey(); // Object value = entry.getValue(); // // if (key.equals("rack.input")) { // value = new JRubyRackInput(runtime, (RackInput) value); // } // // if (key.equals("rack.version")) { // value = convertToRubyArray((List<Integer>) value); // } // // hash.put(key, value); // } // // return hash; // } // // private RubyArray convertToRubyArray(List<Integer> list) { // RubyArray array = RubyArray.newEmptyArray(runtime); // array.addAll(list); // return array; // } // // private RubyArray callRackApplication(RubyHash rubyHash) { // return (RubyArray) application.callMethod(threadService.getCurrentContext(), "call", rubyHash); // } // // private RackResponse convertToJavaRackResponse(RubyArray response) { // int status = Integer.parseInt(response.get(0).toString(), 10); // Map headers = (Map) response.get(1); // IRubyObject body = (IRubyObject) response.get(2); // // return new RackResponse(status, headers, new JRubyRackBodyIterator(body)); // } // } // // Path: core/src/main/java/com/squareup/rack/servlet/RackServlet.java // public class RackServlet extends HttpServlet { // private final RackEnvironmentBuilder rackEnvironmentBuilder; // private final RackApplication rackApplication; // private final RackResponsePropagator rackResponsePropagator; // // /** // * Creates a servlet hosting the given {@link RackApplication}. // * // * @param rackApplication the application to host. // */ // public RackServlet(RackApplication rackApplication) { // this(new RackEnvironmentBuilder(), rackApplication, new RackResponsePropagator()); // } // // /** // * Creates a servlet hosting the given {@link RackApplication} and that uses the given // * collaborators to translate between the Servlet and Rack environments. // * // * @param rackEnvironmentBuilder turns {@link HttpServletRequest}s into {@link RackEnvironment}s. // * @param rackApplication the application to host. // * @param rackResponsePropagator writes {@link RackResponse}s onto {@link HttpServletResponse}s. // */ // public RackServlet(RackEnvironmentBuilder rackEnvironmentBuilder, // RackApplication rackApplication, // RackResponsePropagator rackResponsePropagator) { // this.rackEnvironmentBuilder = rackEnvironmentBuilder; // this.rackApplication = rackApplication; // this.rackResponsePropagator = rackResponsePropagator; // } // // @Override protected void service(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException { // RackEnvironment rackEnvironment = rackEnvironmentBuilder.build(request); // // try { // RackResponse rackResponse = rackApplication.call(rackEnvironment); // rackResponsePropagator.propagate(rackResponse, response); // } finally { // rackEnvironment.closeRackInput(); // } // } // } // Path: integration/src/test/java/com/squareup/rack/integration/HeaderFlushingTest.java import com.squareup.rack.jruby.JRubyRackApplication; import com.squareup.rack.servlet.RackServlet; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.jruby.embed.ScriptingContainer; import org.jruby.runtime.builtin.IRubyObject; import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.fest.assertions.api.Assertions.assertThat; import static org.jruby.embed.PathType.CLASSPATH; import static org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY; package com.squareup.rack.integration; public class HeaderFlushingTest { private HttpClient client; private HttpHost localhost; private ExampleServer server; @Before public void setUp() throws Exception { // Silence logging. System.setProperty(DEFAULT_LOG_LEVEL_KEY, "WARN"); // Build the Rack servlet. ScriptingContainer ruby = new ScriptingContainer(); IRubyObject application = ruby.parse(CLASSPATH, "application.rb").run();
RackServlet servlet = new RackServlet(new JRubyRackApplication(application));
square/rack-servlet
core/src/test/java/com/squareup/rack/servlet/RackResponsePropagatorTest.java
// Path: core/src/main/java/com/squareup/rack/RackResponse.java // public class RackResponse { // private final int status; // private final Map<String, String> headers; // private final Iterator<byte[]> body; // // /** // * Creates a {@link RackResponse} with the given contents. // * // * @param status the HTTP status code. // * @param headers the HTTP response headers. // * @param body the HTTP response body. // */ // public RackResponse(int status, Map<String, String> headers, Iterator<byte[]> body) { // this.status = status; // this.headers = headers; // this.body = body; // } // // /** // * @return the HTTP status code. // */ // public int getStatus() { // return status; // } // // /** // * @return the HTTP response headers. // */ // public Map<String, String> getHeaders() { // return headers; // } // // /** // * @return the HTTP response body. // */ // public Iterator<byte[]> getBody() { // return body; // } // }
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.squareup.rack.RackResponse; import java.io.IOException; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when;
inOrder.verify(outputStream).write("parts.".getBytes()); inOrder.verify(outputStream).flush(); } private static class RackResponseBuilder { private int status; private final ImmutableMap.Builder<String, String> headers; private final ImmutableList.Builder<byte[]> body; public RackResponseBuilder() { this.status = 200; this.headers = ImmutableMap.builder(); this.body = ImmutableList.builder(); } public RackResponseBuilder status(int status) { this.status = status; return this; } public RackResponseBuilder header(String key, String value) { this.headers.put(key, value); return this; } public RackResponseBuilder body(byte[]... parts) { body.add(parts); return this; }
// Path: core/src/main/java/com/squareup/rack/RackResponse.java // public class RackResponse { // private final int status; // private final Map<String, String> headers; // private final Iterator<byte[]> body; // // /** // * Creates a {@link RackResponse} with the given contents. // * // * @param status the HTTP status code. // * @param headers the HTTP response headers. // * @param body the HTTP response body. // */ // public RackResponse(int status, Map<String, String> headers, Iterator<byte[]> body) { // this.status = status; // this.headers = headers; // this.body = body; // } // // /** // * @return the HTTP status code. // */ // public int getStatus() { // return status; // } // // /** // * @return the HTTP response headers. // */ // public Map<String, String> getHeaders() { // return headers; // } // // /** // * @return the HTTP response body. // */ // public Iterator<byte[]> getBody() { // return body; // } // } // Path: core/src/test/java/com/squareup/rack/servlet/RackResponsePropagatorTest.java import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.squareup.rack.RackResponse; import java.io.IOException; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; inOrder.verify(outputStream).write("parts.".getBytes()); inOrder.verify(outputStream).flush(); } private static class RackResponseBuilder { private int status; private final ImmutableMap.Builder<String, String> headers; private final ImmutableList.Builder<byte[]> body; public RackResponseBuilder() { this.status = 200; this.headers = ImmutableMap.builder(); this.body = ImmutableList.builder(); } public RackResponseBuilder status(int status) { this.status = status; return this; } public RackResponseBuilder header(String key, String value) { this.headers.put(key, value); return this; } public RackResponseBuilder body(byte[]... parts) { body.add(parts); return this; }
public RackResponse build() {
square/rack-servlet
core/src/test/java/com/squareup/rack/servlet/RackServletTest.java
// Path: core/src/main/java/com/squareup/rack/RackApplication.java // public interface RackApplication { // /** // * Processes a single HTTP request. // * // * @param environment the HTTP request environment. // * @return the HTTP response. // */ // RackResponse call(RackEnvironment environment); // } // // Path: core/src/main/java/com/squareup/rack/RackEnvironment.java // public class RackEnvironment extends ForwardingMap<String, Object> { // public static final String REQUEST_METHOD = "REQUEST_METHOD"; // public static final String SCRIPT_NAME = "SCRIPT_NAME"; // public static final String PATH_INFO = "PATH_INFO"; // public static final String QUERY_STRING = "QUERY_STRING"; // public static final String SERVER_NAME = "SERVER_NAME"; // public static final String SERVER_PORT = "SERVER_PORT"; // public static final String CONTENT_LENGTH = "CONTENT_LENGTH"; // public static final String CONTENT_TYPE = "CONTENT_TYPE"; // public static final String HTTP_HEADER_PREFIX = "HTTP_"; // public static final String RACK_VERSION = "rack.version"; // public static final String RACK_URL_SCHEME = "rack.url_scheme"; // public static final String RACK_INPUT = "rack.input"; // public static final String RACK_ERRORS = "rack.errors"; // public static final String RACK_LOGGER = "rack.logger"; // public static final String RACK_MULTITHREAD = "rack.multithread"; // public static final String RACK_MULTIPROCESS = "rack.multiprocess"; // public static final String RACK_RUN_ONCE = "rack.run_once"; // public static final String RACK_HIJACK = "rack.hijack?"; // public static final String MINECART_HTTP_SERVLET_REQUEST = "minecart.http_servlet_request"; // // private final Map<String, Object> contents; // // /** // * Creates a {@link RackEnvironment} with the given contents. // * // * @see com.squareup.rack.servlet.RackEnvironmentBuilder // * @param contents // */ // public RackEnvironment(Map<String, Object> contents) { // this.contents = contents; // } // // /** // * Closes the rack.input stream. // * // * @throws IOException // */ // public void closeRackInput() throws IOException { // ((Closeable) contents.get(RACK_INPUT)).close(); // } // // @Override protected Map<String, Object> delegate() { // return contents; // } // } // // Path: core/src/main/java/com/squareup/rack/RackResponse.java // public class RackResponse { // private final int status; // private final Map<String, String> headers; // private final Iterator<byte[]> body; // // /** // * Creates a {@link RackResponse} with the given contents. // * // * @param status the HTTP status code. // * @param headers the HTTP response headers. // * @param body the HTTP response body. // */ // public RackResponse(int status, Map<String, String> headers, Iterator<byte[]> body) { // this.status = status; // this.headers = headers; // this.body = body; // } // // /** // * @return the HTTP status code. // */ // public int getStatus() { // return status; // } // // /** // * @return the HTTP response headers. // */ // public Map<String, String> getHeaders() { // return headers; // } // // /** // * @return the HTTP response body. // */ // public Iterator<byte[]> getBody() { // return body; // } // }
import com.squareup.rack.RackApplication; import com.squareup.rack.RackEnvironment; import com.squareup.rack.RackResponse; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.when;
package com.squareup.rack.servlet; @RunWith(MockitoJUnitRunner.class) public class RackServletTest { private RackServlet subject; @Mock private HttpServletRequest request; @Mock private HttpServletResponse response;
// Path: core/src/main/java/com/squareup/rack/RackApplication.java // public interface RackApplication { // /** // * Processes a single HTTP request. // * // * @param environment the HTTP request environment. // * @return the HTTP response. // */ // RackResponse call(RackEnvironment environment); // } // // Path: core/src/main/java/com/squareup/rack/RackEnvironment.java // public class RackEnvironment extends ForwardingMap<String, Object> { // public static final String REQUEST_METHOD = "REQUEST_METHOD"; // public static final String SCRIPT_NAME = "SCRIPT_NAME"; // public static final String PATH_INFO = "PATH_INFO"; // public static final String QUERY_STRING = "QUERY_STRING"; // public static final String SERVER_NAME = "SERVER_NAME"; // public static final String SERVER_PORT = "SERVER_PORT"; // public static final String CONTENT_LENGTH = "CONTENT_LENGTH"; // public static final String CONTENT_TYPE = "CONTENT_TYPE"; // public static final String HTTP_HEADER_PREFIX = "HTTP_"; // public static final String RACK_VERSION = "rack.version"; // public static final String RACK_URL_SCHEME = "rack.url_scheme"; // public static final String RACK_INPUT = "rack.input"; // public static final String RACK_ERRORS = "rack.errors"; // public static final String RACK_LOGGER = "rack.logger"; // public static final String RACK_MULTITHREAD = "rack.multithread"; // public static final String RACK_MULTIPROCESS = "rack.multiprocess"; // public static final String RACK_RUN_ONCE = "rack.run_once"; // public static final String RACK_HIJACK = "rack.hijack?"; // public static final String MINECART_HTTP_SERVLET_REQUEST = "minecart.http_servlet_request"; // // private final Map<String, Object> contents; // // /** // * Creates a {@link RackEnvironment} with the given contents. // * // * @see com.squareup.rack.servlet.RackEnvironmentBuilder // * @param contents // */ // public RackEnvironment(Map<String, Object> contents) { // this.contents = contents; // } // // /** // * Closes the rack.input stream. // * // * @throws IOException // */ // public void closeRackInput() throws IOException { // ((Closeable) contents.get(RACK_INPUT)).close(); // } // // @Override protected Map<String, Object> delegate() { // return contents; // } // } // // Path: core/src/main/java/com/squareup/rack/RackResponse.java // public class RackResponse { // private final int status; // private final Map<String, String> headers; // private final Iterator<byte[]> body; // // /** // * Creates a {@link RackResponse} with the given contents. // * // * @param status the HTTP status code. // * @param headers the HTTP response headers. // * @param body the HTTP response body. // */ // public RackResponse(int status, Map<String, String> headers, Iterator<byte[]> body) { // this.status = status; // this.headers = headers; // this.body = body; // } // // /** // * @return the HTTP status code. // */ // public int getStatus() { // return status; // } // // /** // * @return the HTTP response headers. // */ // public Map<String, String> getHeaders() { // return headers; // } // // /** // * @return the HTTP response body. // */ // public Iterator<byte[]> getBody() { // return body; // } // } // Path: core/src/test/java/com/squareup/rack/servlet/RackServletTest.java import com.squareup.rack.RackApplication; import com.squareup.rack.RackEnvironment; import com.squareup.rack.RackResponse; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.when; package com.squareup.rack.servlet; @RunWith(MockitoJUnitRunner.class) public class RackServletTest { private RackServlet subject; @Mock private HttpServletRequest request; @Mock private HttpServletResponse response;
@Mock private RackApplication rackApplication;
square/rack-servlet
core/src/test/java/com/squareup/rack/servlet/RackServletTest.java
// Path: core/src/main/java/com/squareup/rack/RackApplication.java // public interface RackApplication { // /** // * Processes a single HTTP request. // * // * @param environment the HTTP request environment. // * @return the HTTP response. // */ // RackResponse call(RackEnvironment environment); // } // // Path: core/src/main/java/com/squareup/rack/RackEnvironment.java // public class RackEnvironment extends ForwardingMap<String, Object> { // public static final String REQUEST_METHOD = "REQUEST_METHOD"; // public static final String SCRIPT_NAME = "SCRIPT_NAME"; // public static final String PATH_INFO = "PATH_INFO"; // public static final String QUERY_STRING = "QUERY_STRING"; // public static final String SERVER_NAME = "SERVER_NAME"; // public static final String SERVER_PORT = "SERVER_PORT"; // public static final String CONTENT_LENGTH = "CONTENT_LENGTH"; // public static final String CONTENT_TYPE = "CONTENT_TYPE"; // public static final String HTTP_HEADER_PREFIX = "HTTP_"; // public static final String RACK_VERSION = "rack.version"; // public static final String RACK_URL_SCHEME = "rack.url_scheme"; // public static final String RACK_INPUT = "rack.input"; // public static final String RACK_ERRORS = "rack.errors"; // public static final String RACK_LOGGER = "rack.logger"; // public static final String RACK_MULTITHREAD = "rack.multithread"; // public static final String RACK_MULTIPROCESS = "rack.multiprocess"; // public static final String RACK_RUN_ONCE = "rack.run_once"; // public static final String RACK_HIJACK = "rack.hijack?"; // public static final String MINECART_HTTP_SERVLET_REQUEST = "minecart.http_servlet_request"; // // private final Map<String, Object> contents; // // /** // * Creates a {@link RackEnvironment} with the given contents. // * // * @see com.squareup.rack.servlet.RackEnvironmentBuilder // * @param contents // */ // public RackEnvironment(Map<String, Object> contents) { // this.contents = contents; // } // // /** // * Closes the rack.input stream. // * // * @throws IOException // */ // public void closeRackInput() throws IOException { // ((Closeable) contents.get(RACK_INPUT)).close(); // } // // @Override protected Map<String, Object> delegate() { // return contents; // } // } // // Path: core/src/main/java/com/squareup/rack/RackResponse.java // public class RackResponse { // private final int status; // private final Map<String, String> headers; // private final Iterator<byte[]> body; // // /** // * Creates a {@link RackResponse} with the given contents. // * // * @param status the HTTP status code. // * @param headers the HTTP response headers. // * @param body the HTTP response body. // */ // public RackResponse(int status, Map<String, String> headers, Iterator<byte[]> body) { // this.status = status; // this.headers = headers; // this.body = body; // } // // /** // * @return the HTTP status code. // */ // public int getStatus() { // return status; // } // // /** // * @return the HTTP response headers. // */ // public Map<String, String> getHeaders() { // return headers; // } // // /** // * @return the HTTP response body. // */ // public Iterator<byte[]> getBody() { // return body; // } // }
import com.squareup.rack.RackApplication; import com.squareup.rack.RackEnvironment; import com.squareup.rack.RackResponse; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.when;
package com.squareup.rack.servlet; @RunWith(MockitoJUnitRunner.class) public class RackServletTest { private RackServlet subject; @Mock private HttpServletRequest request; @Mock private HttpServletResponse response; @Mock private RackApplication rackApplication; @Mock private RackEnvironmentBuilder rackEnvironmentBuilder;
// Path: core/src/main/java/com/squareup/rack/RackApplication.java // public interface RackApplication { // /** // * Processes a single HTTP request. // * // * @param environment the HTTP request environment. // * @return the HTTP response. // */ // RackResponse call(RackEnvironment environment); // } // // Path: core/src/main/java/com/squareup/rack/RackEnvironment.java // public class RackEnvironment extends ForwardingMap<String, Object> { // public static final String REQUEST_METHOD = "REQUEST_METHOD"; // public static final String SCRIPT_NAME = "SCRIPT_NAME"; // public static final String PATH_INFO = "PATH_INFO"; // public static final String QUERY_STRING = "QUERY_STRING"; // public static final String SERVER_NAME = "SERVER_NAME"; // public static final String SERVER_PORT = "SERVER_PORT"; // public static final String CONTENT_LENGTH = "CONTENT_LENGTH"; // public static final String CONTENT_TYPE = "CONTENT_TYPE"; // public static final String HTTP_HEADER_PREFIX = "HTTP_"; // public static final String RACK_VERSION = "rack.version"; // public static final String RACK_URL_SCHEME = "rack.url_scheme"; // public static final String RACK_INPUT = "rack.input"; // public static final String RACK_ERRORS = "rack.errors"; // public static final String RACK_LOGGER = "rack.logger"; // public static final String RACK_MULTITHREAD = "rack.multithread"; // public static final String RACK_MULTIPROCESS = "rack.multiprocess"; // public static final String RACK_RUN_ONCE = "rack.run_once"; // public static final String RACK_HIJACK = "rack.hijack?"; // public static final String MINECART_HTTP_SERVLET_REQUEST = "minecart.http_servlet_request"; // // private final Map<String, Object> contents; // // /** // * Creates a {@link RackEnvironment} with the given contents. // * // * @see com.squareup.rack.servlet.RackEnvironmentBuilder // * @param contents // */ // public RackEnvironment(Map<String, Object> contents) { // this.contents = contents; // } // // /** // * Closes the rack.input stream. // * // * @throws IOException // */ // public void closeRackInput() throws IOException { // ((Closeable) contents.get(RACK_INPUT)).close(); // } // // @Override protected Map<String, Object> delegate() { // return contents; // } // } // // Path: core/src/main/java/com/squareup/rack/RackResponse.java // public class RackResponse { // private final int status; // private final Map<String, String> headers; // private final Iterator<byte[]> body; // // /** // * Creates a {@link RackResponse} with the given contents. // * // * @param status the HTTP status code. // * @param headers the HTTP response headers. // * @param body the HTTP response body. // */ // public RackResponse(int status, Map<String, String> headers, Iterator<byte[]> body) { // this.status = status; // this.headers = headers; // this.body = body; // } // // /** // * @return the HTTP status code. // */ // public int getStatus() { // return status; // } // // /** // * @return the HTTP response headers. // */ // public Map<String, String> getHeaders() { // return headers; // } // // /** // * @return the HTTP response body. // */ // public Iterator<byte[]> getBody() { // return body; // } // } // Path: core/src/test/java/com/squareup/rack/servlet/RackServletTest.java import com.squareup.rack.RackApplication; import com.squareup.rack.RackEnvironment; import com.squareup.rack.RackResponse; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.when; package com.squareup.rack.servlet; @RunWith(MockitoJUnitRunner.class) public class RackServletTest { private RackServlet subject; @Mock private HttpServletRequest request; @Mock private HttpServletResponse response; @Mock private RackApplication rackApplication; @Mock private RackEnvironmentBuilder rackEnvironmentBuilder;
@Mock private RackEnvironment rackEnvironment;
square/rack-servlet
core/src/test/java/com/squareup/rack/servlet/RackServletTest.java
// Path: core/src/main/java/com/squareup/rack/RackApplication.java // public interface RackApplication { // /** // * Processes a single HTTP request. // * // * @param environment the HTTP request environment. // * @return the HTTP response. // */ // RackResponse call(RackEnvironment environment); // } // // Path: core/src/main/java/com/squareup/rack/RackEnvironment.java // public class RackEnvironment extends ForwardingMap<String, Object> { // public static final String REQUEST_METHOD = "REQUEST_METHOD"; // public static final String SCRIPT_NAME = "SCRIPT_NAME"; // public static final String PATH_INFO = "PATH_INFO"; // public static final String QUERY_STRING = "QUERY_STRING"; // public static final String SERVER_NAME = "SERVER_NAME"; // public static final String SERVER_PORT = "SERVER_PORT"; // public static final String CONTENT_LENGTH = "CONTENT_LENGTH"; // public static final String CONTENT_TYPE = "CONTENT_TYPE"; // public static final String HTTP_HEADER_PREFIX = "HTTP_"; // public static final String RACK_VERSION = "rack.version"; // public static final String RACK_URL_SCHEME = "rack.url_scheme"; // public static final String RACK_INPUT = "rack.input"; // public static final String RACK_ERRORS = "rack.errors"; // public static final String RACK_LOGGER = "rack.logger"; // public static final String RACK_MULTITHREAD = "rack.multithread"; // public static final String RACK_MULTIPROCESS = "rack.multiprocess"; // public static final String RACK_RUN_ONCE = "rack.run_once"; // public static final String RACK_HIJACK = "rack.hijack?"; // public static final String MINECART_HTTP_SERVLET_REQUEST = "minecart.http_servlet_request"; // // private final Map<String, Object> contents; // // /** // * Creates a {@link RackEnvironment} with the given contents. // * // * @see com.squareup.rack.servlet.RackEnvironmentBuilder // * @param contents // */ // public RackEnvironment(Map<String, Object> contents) { // this.contents = contents; // } // // /** // * Closes the rack.input stream. // * // * @throws IOException // */ // public void closeRackInput() throws IOException { // ((Closeable) contents.get(RACK_INPUT)).close(); // } // // @Override protected Map<String, Object> delegate() { // return contents; // } // } // // Path: core/src/main/java/com/squareup/rack/RackResponse.java // public class RackResponse { // private final int status; // private final Map<String, String> headers; // private final Iterator<byte[]> body; // // /** // * Creates a {@link RackResponse} with the given contents. // * // * @param status the HTTP status code. // * @param headers the HTTP response headers. // * @param body the HTTP response body. // */ // public RackResponse(int status, Map<String, String> headers, Iterator<byte[]> body) { // this.status = status; // this.headers = headers; // this.body = body; // } // // /** // * @return the HTTP status code. // */ // public int getStatus() { // return status; // } // // /** // * @return the HTTP response headers. // */ // public Map<String, String> getHeaders() { // return headers; // } // // /** // * @return the HTTP response body. // */ // public Iterator<byte[]> getBody() { // return body; // } // }
import com.squareup.rack.RackApplication; import com.squareup.rack.RackEnvironment; import com.squareup.rack.RackResponse; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.when;
package com.squareup.rack.servlet; @RunWith(MockitoJUnitRunner.class) public class RackServletTest { private RackServlet subject; @Mock private HttpServletRequest request; @Mock private HttpServletResponse response; @Mock private RackApplication rackApplication; @Mock private RackEnvironmentBuilder rackEnvironmentBuilder; @Mock private RackEnvironment rackEnvironment;
// Path: core/src/main/java/com/squareup/rack/RackApplication.java // public interface RackApplication { // /** // * Processes a single HTTP request. // * // * @param environment the HTTP request environment. // * @return the HTTP response. // */ // RackResponse call(RackEnvironment environment); // } // // Path: core/src/main/java/com/squareup/rack/RackEnvironment.java // public class RackEnvironment extends ForwardingMap<String, Object> { // public static final String REQUEST_METHOD = "REQUEST_METHOD"; // public static final String SCRIPT_NAME = "SCRIPT_NAME"; // public static final String PATH_INFO = "PATH_INFO"; // public static final String QUERY_STRING = "QUERY_STRING"; // public static final String SERVER_NAME = "SERVER_NAME"; // public static final String SERVER_PORT = "SERVER_PORT"; // public static final String CONTENT_LENGTH = "CONTENT_LENGTH"; // public static final String CONTENT_TYPE = "CONTENT_TYPE"; // public static final String HTTP_HEADER_PREFIX = "HTTP_"; // public static final String RACK_VERSION = "rack.version"; // public static final String RACK_URL_SCHEME = "rack.url_scheme"; // public static final String RACK_INPUT = "rack.input"; // public static final String RACK_ERRORS = "rack.errors"; // public static final String RACK_LOGGER = "rack.logger"; // public static final String RACK_MULTITHREAD = "rack.multithread"; // public static final String RACK_MULTIPROCESS = "rack.multiprocess"; // public static final String RACK_RUN_ONCE = "rack.run_once"; // public static final String RACK_HIJACK = "rack.hijack?"; // public static final String MINECART_HTTP_SERVLET_REQUEST = "minecart.http_servlet_request"; // // private final Map<String, Object> contents; // // /** // * Creates a {@link RackEnvironment} with the given contents. // * // * @see com.squareup.rack.servlet.RackEnvironmentBuilder // * @param contents // */ // public RackEnvironment(Map<String, Object> contents) { // this.contents = contents; // } // // /** // * Closes the rack.input stream. // * // * @throws IOException // */ // public void closeRackInput() throws IOException { // ((Closeable) contents.get(RACK_INPUT)).close(); // } // // @Override protected Map<String, Object> delegate() { // return contents; // } // } // // Path: core/src/main/java/com/squareup/rack/RackResponse.java // public class RackResponse { // private final int status; // private final Map<String, String> headers; // private final Iterator<byte[]> body; // // /** // * Creates a {@link RackResponse} with the given contents. // * // * @param status the HTTP status code. // * @param headers the HTTP response headers. // * @param body the HTTP response body. // */ // public RackResponse(int status, Map<String, String> headers, Iterator<byte[]> body) { // this.status = status; // this.headers = headers; // this.body = body; // } // // /** // * @return the HTTP status code. // */ // public int getStatus() { // return status; // } // // /** // * @return the HTTP response headers. // */ // public Map<String, String> getHeaders() { // return headers; // } // // /** // * @return the HTTP response body. // */ // public Iterator<byte[]> getBody() { // return body; // } // } // Path: core/src/test/java/com/squareup/rack/servlet/RackServletTest.java import com.squareup.rack.RackApplication; import com.squareup.rack.RackEnvironment; import com.squareup.rack.RackResponse; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.when; package com.squareup.rack.servlet; @RunWith(MockitoJUnitRunner.class) public class RackServletTest { private RackServlet subject; @Mock private HttpServletRequest request; @Mock private HttpServletResponse response; @Mock private RackApplication rackApplication; @Mock private RackEnvironmentBuilder rackEnvironmentBuilder; @Mock private RackEnvironment rackEnvironment;
@Mock private RackResponse rackResponse;
square/rack-servlet
core/src/main/java/com/squareup/rack/servlet/RackServlet.java
// Path: core/src/main/java/com/squareup/rack/RackApplication.java // public interface RackApplication { // /** // * Processes a single HTTP request. // * // * @param environment the HTTP request environment. // * @return the HTTP response. // */ // RackResponse call(RackEnvironment environment); // } // // Path: core/src/main/java/com/squareup/rack/RackEnvironment.java // public class RackEnvironment extends ForwardingMap<String, Object> { // public static final String REQUEST_METHOD = "REQUEST_METHOD"; // public static final String SCRIPT_NAME = "SCRIPT_NAME"; // public static final String PATH_INFO = "PATH_INFO"; // public static final String QUERY_STRING = "QUERY_STRING"; // public static final String SERVER_NAME = "SERVER_NAME"; // public static final String SERVER_PORT = "SERVER_PORT"; // public static final String CONTENT_LENGTH = "CONTENT_LENGTH"; // public static final String CONTENT_TYPE = "CONTENT_TYPE"; // public static final String HTTP_HEADER_PREFIX = "HTTP_"; // public static final String RACK_VERSION = "rack.version"; // public static final String RACK_URL_SCHEME = "rack.url_scheme"; // public static final String RACK_INPUT = "rack.input"; // public static final String RACK_ERRORS = "rack.errors"; // public static final String RACK_LOGGER = "rack.logger"; // public static final String RACK_MULTITHREAD = "rack.multithread"; // public static final String RACK_MULTIPROCESS = "rack.multiprocess"; // public static final String RACK_RUN_ONCE = "rack.run_once"; // public static final String RACK_HIJACK = "rack.hijack?"; // public static final String MINECART_HTTP_SERVLET_REQUEST = "minecart.http_servlet_request"; // // private final Map<String, Object> contents; // // /** // * Creates a {@link RackEnvironment} with the given contents. // * // * @see com.squareup.rack.servlet.RackEnvironmentBuilder // * @param contents // */ // public RackEnvironment(Map<String, Object> contents) { // this.contents = contents; // } // // /** // * Closes the rack.input stream. // * // * @throws IOException // */ // public void closeRackInput() throws IOException { // ((Closeable) contents.get(RACK_INPUT)).close(); // } // // @Override protected Map<String, Object> delegate() { // return contents; // } // } // // Path: core/src/main/java/com/squareup/rack/RackResponse.java // public class RackResponse { // private final int status; // private final Map<String, String> headers; // private final Iterator<byte[]> body; // // /** // * Creates a {@link RackResponse} with the given contents. // * // * @param status the HTTP status code. // * @param headers the HTTP response headers. // * @param body the HTTP response body. // */ // public RackResponse(int status, Map<String, String> headers, Iterator<byte[]> body) { // this.status = status; // this.headers = headers; // this.body = body; // } // // /** // * @return the HTTP status code. // */ // public int getStatus() { // return status; // } // // /** // * @return the HTTP response headers. // */ // public Map<String, String> getHeaders() { // return headers; // } // // /** // * @return the HTTP response body. // */ // public Iterator<byte[]> getBody() { // return body; // } // }
import com.squareup.rack.RackApplication; import com.squareup.rack.RackEnvironment; import com.squareup.rack.RackResponse; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;
/* * Copyright (C) 2013 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.squareup.rack.servlet; /** * <p>Hosts a {@link RackApplication}.</p> * * <p>Since RackServlet lacks a zero-argument constructor, you'll need to manually instantiate and * install it in your container, rather than declaring it in a {@code web.xml} file. See our * examples for concrete code.</p> */ public class RackServlet extends HttpServlet { private final RackEnvironmentBuilder rackEnvironmentBuilder;
// Path: core/src/main/java/com/squareup/rack/RackApplication.java // public interface RackApplication { // /** // * Processes a single HTTP request. // * // * @param environment the HTTP request environment. // * @return the HTTP response. // */ // RackResponse call(RackEnvironment environment); // } // // Path: core/src/main/java/com/squareup/rack/RackEnvironment.java // public class RackEnvironment extends ForwardingMap<String, Object> { // public static final String REQUEST_METHOD = "REQUEST_METHOD"; // public static final String SCRIPT_NAME = "SCRIPT_NAME"; // public static final String PATH_INFO = "PATH_INFO"; // public static final String QUERY_STRING = "QUERY_STRING"; // public static final String SERVER_NAME = "SERVER_NAME"; // public static final String SERVER_PORT = "SERVER_PORT"; // public static final String CONTENT_LENGTH = "CONTENT_LENGTH"; // public static final String CONTENT_TYPE = "CONTENT_TYPE"; // public static final String HTTP_HEADER_PREFIX = "HTTP_"; // public static final String RACK_VERSION = "rack.version"; // public static final String RACK_URL_SCHEME = "rack.url_scheme"; // public static final String RACK_INPUT = "rack.input"; // public static final String RACK_ERRORS = "rack.errors"; // public static final String RACK_LOGGER = "rack.logger"; // public static final String RACK_MULTITHREAD = "rack.multithread"; // public static final String RACK_MULTIPROCESS = "rack.multiprocess"; // public static final String RACK_RUN_ONCE = "rack.run_once"; // public static final String RACK_HIJACK = "rack.hijack?"; // public static final String MINECART_HTTP_SERVLET_REQUEST = "minecart.http_servlet_request"; // // private final Map<String, Object> contents; // // /** // * Creates a {@link RackEnvironment} with the given contents. // * // * @see com.squareup.rack.servlet.RackEnvironmentBuilder // * @param contents // */ // public RackEnvironment(Map<String, Object> contents) { // this.contents = contents; // } // // /** // * Closes the rack.input stream. // * // * @throws IOException // */ // public void closeRackInput() throws IOException { // ((Closeable) contents.get(RACK_INPUT)).close(); // } // // @Override protected Map<String, Object> delegate() { // return contents; // } // } // // Path: core/src/main/java/com/squareup/rack/RackResponse.java // public class RackResponse { // private final int status; // private final Map<String, String> headers; // private final Iterator<byte[]> body; // // /** // * Creates a {@link RackResponse} with the given contents. // * // * @param status the HTTP status code. // * @param headers the HTTP response headers. // * @param body the HTTP response body. // */ // public RackResponse(int status, Map<String, String> headers, Iterator<byte[]> body) { // this.status = status; // this.headers = headers; // this.body = body; // } // // /** // * @return the HTTP status code. // */ // public int getStatus() { // return status; // } // // /** // * @return the HTTP response headers. // */ // public Map<String, String> getHeaders() { // return headers; // } // // /** // * @return the HTTP response body. // */ // public Iterator<byte[]> getBody() { // return body; // } // } // Path: core/src/main/java/com/squareup/rack/servlet/RackServlet.java import com.squareup.rack.RackApplication; import com.squareup.rack.RackEnvironment; import com.squareup.rack.RackResponse; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /* * Copyright (C) 2013 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.squareup.rack.servlet; /** * <p>Hosts a {@link RackApplication}.</p> * * <p>Since RackServlet lacks a zero-argument constructor, you'll need to manually instantiate and * install it in your container, rather than declaring it in a {@code web.xml} file. See our * examples for concrete code.</p> */ public class RackServlet extends HttpServlet { private final RackEnvironmentBuilder rackEnvironmentBuilder;
private final RackApplication rackApplication;
square/rack-servlet
core/src/main/java/com/squareup/rack/servlet/RackServlet.java
// Path: core/src/main/java/com/squareup/rack/RackApplication.java // public interface RackApplication { // /** // * Processes a single HTTP request. // * // * @param environment the HTTP request environment. // * @return the HTTP response. // */ // RackResponse call(RackEnvironment environment); // } // // Path: core/src/main/java/com/squareup/rack/RackEnvironment.java // public class RackEnvironment extends ForwardingMap<String, Object> { // public static final String REQUEST_METHOD = "REQUEST_METHOD"; // public static final String SCRIPT_NAME = "SCRIPT_NAME"; // public static final String PATH_INFO = "PATH_INFO"; // public static final String QUERY_STRING = "QUERY_STRING"; // public static final String SERVER_NAME = "SERVER_NAME"; // public static final String SERVER_PORT = "SERVER_PORT"; // public static final String CONTENT_LENGTH = "CONTENT_LENGTH"; // public static final String CONTENT_TYPE = "CONTENT_TYPE"; // public static final String HTTP_HEADER_PREFIX = "HTTP_"; // public static final String RACK_VERSION = "rack.version"; // public static final String RACK_URL_SCHEME = "rack.url_scheme"; // public static final String RACK_INPUT = "rack.input"; // public static final String RACK_ERRORS = "rack.errors"; // public static final String RACK_LOGGER = "rack.logger"; // public static final String RACK_MULTITHREAD = "rack.multithread"; // public static final String RACK_MULTIPROCESS = "rack.multiprocess"; // public static final String RACK_RUN_ONCE = "rack.run_once"; // public static final String RACK_HIJACK = "rack.hijack?"; // public static final String MINECART_HTTP_SERVLET_REQUEST = "minecart.http_servlet_request"; // // private final Map<String, Object> contents; // // /** // * Creates a {@link RackEnvironment} with the given contents. // * // * @see com.squareup.rack.servlet.RackEnvironmentBuilder // * @param contents // */ // public RackEnvironment(Map<String, Object> contents) { // this.contents = contents; // } // // /** // * Closes the rack.input stream. // * // * @throws IOException // */ // public void closeRackInput() throws IOException { // ((Closeable) contents.get(RACK_INPUT)).close(); // } // // @Override protected Map<String, Object> delegate() { // return contents; // } // } // // Path: core/src/main/java/com/squareup/rack/RackResponse.java // public class RackResponse { // private final int status; // private final Map<String, String> headers; // private final Iterator<byte[]> body; // // /** // * Creates a {@link RackResponse} with the given contents. // * // * @param status the HTTP status code. // * @param headers the HTTP response headers. // * @param body the HTTP response body. // */ // public RackResponse(int status, Map<String, String> headers, Iterator<byte[]> body) { // this.status = status; // this.headers = headers; // this.body = body; // } // // /** // * @return the HTTP status code. // */ // public int getStatus() { // return status; // } // // /** // * @return the HTTP response headers. // */ // public Map<String, String> getHeaders() { // return headers; // } // // /** // * @return the HTTP response body. // */ // public Iterator<byte[]> getBody() { // return body; // } // }
import com.squareup.rack.RackApplication; import com.squareup.rack.RackEnvironment; import com.squareup.rack.RackResponse; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;
/* * Copyright (C) 2013 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.squareup.rack.servlet; /** * <p>Hosts a {@link RackApplication}.</p> * * <p>Since RackServlet lacks a zero-argument constructor, you'll need to manually instantiate and * install it in your container, rather than declaring it in a {@code web.xml} file. See our * examples for concrete code.</p> */ public class RackServlet extends HttpServlet { private final RackEnvironmentBuilder rackEnvironmentBuilder; private final RackApplication rackApplication; private final RackResponsePropagator rackResponsePropagator; /** * Creates a servlet hosting the given {@link RackApplication}. * * @param rackApplication the application to host. */ public RackServlet(RackApplication rackApplication) { this(new RackEnvironmentBuilder(), rackApplication, new RackResponsePropagator()); } /** * Creates a servlet hosting the given {@link RackApplication} and that uses the given * collaborators to translate between the Servlet and Rack environments. * * @param rackEnvironmentBuilder turns {@link HttpServletRequest}s into {@link RackEnvironment}s. * @param rackApplication the application to host. * @param rackResponsePropagator writes {@link RackResponse}s onto {@link HttpServletResponse}s. */ public RackServlet(RackEnvironmentBuilder rackEnvironmentBuilder, RackApplication rackApplication, RackResponsePropagator rackResponsePropagator) { this.rackEnvironmentBuilder = rackEnvironmentBuilder; this.rackApplication = rackApplication; this.rackResponsePropagator = rackResponsePropagator; } @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Path: core/src/main/java/com/squareup/rack/RackApplication.java // public interface RackApplication { // /** // * Processes a single HTTP request. // * // * @param environment the HTTP request environment. // * @return the HTTP response. // */ // RackResponse call(RackEnvironment environment); // } // // Path: core/src/main/java/com/squareup/rack/RackEnvironment.java // public class RackEnvironment extends ForwardingMap<String, Object> { // public static final String REQUEST_METHOD = "REQUEST_METHOD"; // public static final String SCRIPT_NAME = "SCRIPT_NAME"; // public static final String PATH_INFO = "PATH_INFO"; // public static final String QUERY_STRING = "QUERY_STRING"; // public static final String SERVER_NAME = "SERVER_NAME"; // public static final String SERVER_PORT = "SERVER_PORT"; // public static final String CONTENT_LENGTH = "CONTENT_LENGTH"; // public static final String CONTENT_TYPE = "CONTENT_TYPE"; // public static final String HTTP_HEADER_PREFIX = "HTTP_"; // public static final String RACK_VERSION = "rack.version"; // public static final String RACK_URL_SCHEME = "rack.url_scheme"; // public static final String RACK_INPUT = "rack.input"; // public static final String RACK_ERRORS = "rack.errors"; // public static final String RACK_LOGGER = "rack.logger"; // public static final String RACK_MULTITHREAD = "rack.multithread"; // public static final String RACK_MULTIPROCESS = "rack.multiprocess"; // public static final String RACK_RUN_ONCE = "rack.run_once"; // public static final String RACK_HIJACK = "rack.hijack?"; // public static final String MINECART_HTTP_SERVLET_REQUEST = "minecart.http_servlet_request"; // // private final Map<String, Object> contents; // // /** // * Creates a {@link RackEnvironment} with the given contents. // * // * @see com.squareup.rack.servlet.RackEnvironmentBuilder // * @param contents // */ // public RackEnvironment(Map<String, Object> contents) { // this.contents = contents; // } // // /** // * Closes the rack.input stream. // * // * @throws IOException // */ // public void closeRackInput() throws IOException { // ((Closeable) contents.get(RACK_INPUT)).close(); // } // // @Override protected Map<String, Object> delegate() { // return contents; // } // } // // Path: core/src/main/java/com/squareup/rack/RackResponse.java // public class RackResponse { // private final int status; // private final Map<String, String> headers; // private final Iterator<byte[]> body; // // /** // * Creates a {@link RackResponse} with the given contents. // * // * @param status the HTTP status code. // * @param headers the HTTP response headers. // * @param body the HTTP response body. // */ // public RackResponse(int status, Map<String, String> headers, Iterator<byte[]> body) { // this.status = status; // this.headers = headers; // this.body = body; // } // // /** // * @return the HTTP status code. // */ // public int getStatus() { // return status; // } // // /** // * @return the HTTP response headers. // */ // public Map<String, String> getHeaders() { // return headers; // } // // /** // * @return the HTTP response body. // */ // public Iterator<byte[]> getBody() { // return body; // } // } // Path: core/src/main/java/com/squareup/rack/servlet/RackServlet.java import com.squareup.rack.RackApplication; import com.squareup.rack.RackEnvironment; import com.squareup.rack.RackResponse; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /* * Copyright (C) 2013 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.squareup.rack.servlet; /** * <p>Hosts a {@link RackApplication}.</p> * * <p>Since RackServlet lacks a zero-argument constructor, you'll need to manually instantiate and * install it in your container, rather than declaring it in a {@code web.xml} file. See our * examples for concrete code.</p> */ public class RackServlet extends HttpServlet { private final RackEnvironmentBuilder rackEnvironmentBuilder; private final RackApplication rackApplication; private final RackResponsePropagator rackResponsePropagator; /** * Creates a servlet hosting the given {@link RackApplication}. * * @param rackApplication the application to host. */ public RackServlet(RackApplication rackApplication) { this(new RackEnvironmentBuilder(), rackApplication, new RackResponsePropagator()); } /** * Creates a servlet hosting the given {@link RackApplication} and that uses the given * collaborators to translate between the Servlet and Rack environments. * * @param rackEnvironmentBuilder turns {@link HttpServletRequest}s into {@link RackEnvironment}s. * @param rackApplication the application to host. * @param rackResponsePropagator writes {@link RackResponse}s onto {@link HttpServletResponse}s. */ public RackServlet(RackEnvironmentBuilder rackEnvironmentBuilder, RackApplication rackApplication, RackResponsePropagator rackResponsePropagator) { this.rackEnvironmentBuilder = rackEnvironmentBuilder; this.rackApplication = rackApplication; this.rackResponsePropagator = rackResponsePropagator; } @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
RackEnvironment rackEnvironment = rackEnvironmentBuilder.build(request);
square/rack-servlet
core/src/main/java/com/squareup/rack/servlet/RackServlet.java
// Path: core/src/main/java/com/squareup/rack/RackApplication.java // public interface RackApplication { // /** // * Processes a single HTTP request. // * // * @param environment the HTTP request environment. // * @return the HTTP response. // */ // RackResponse call(RackEnvironment environment); // } // // Path: core/src/main/java/com/squareup/rack/RackEnvironment.java // public class RackEnvironment extends ForwardingMap<String, Object> { // public static final String REQUEST_METHOD = "REQUEST_METHOD"; // public static final String SCRIPT_NAME = "SCRIPT_NAME"; // public static final String PATH_INFO = "PATH_INFO"; // public static final String QUERY_STRING = "QUERY_STRING"; // public static final String SERVER_NAME = "SERVER_NAME"; // public static final String SERVER_PORT = "SERVER_PORT"; // public static final String CONTENT_LENGTH = "CONTENT_LENGTH"; // public static final String CONTENT_TYPE = "CONTENT_TYPE"; // public static final String HTTP_HEADER_PREFIX = "HTTP_"; // public static final String RACK_VERSION = "rack.version"; // public static final String RACK_URL_SCHEME = "rack.url_scheme"; // public static final String RACK_INPUT = "rack.input"; // public static final String RACK_ERRORS = "rack.errors"; // public static final String RACK_LOGGER = "rack.logger"; // public static final String RACK_MULTITHREAD = "rack.multithread"; // public static final String RACK_MULTIPROCESS = "rack.multiprocess"; // public static final String RACK_RUN_ONCE = "rack.run_once"; // public static final String RACK_HIJACK = "rack.hijack?"; // public static final String MINECART_HTTP_SERVLET_REQUEST = "minecart.http_servlet_request"; // // private final Map<String, Object> contents; // // /** // * Creates a {@link RackEnvironment} with the given contents. // * // * @see com.squareup.rack.servlet.RackEnvironmentBuilder // * @param contents // */ // public RackEnvironment(Map<String, Object> contents) { // this.contents = contents; // } // // /** // * Closes the rack.input stream. // * // * @throws IOException // */ // public void closeRackInput() throws IOException { // ((Closeable) contents.get(RACK_INPUT)).close(); // } // // @Override protected Map<String, Object> delegate() { // return contents; // } // } // // Path: core/src/main/java/com/squareup/rack/RackResponse.java // public class RackResponse { // private final int status; // private final Map<String, String> headers; // private final Iterator<byte[]> body; // // /** // * Creates a {@link RackResponse} with the given contents. // * // * @param status the HTTP status code. // * @param headers the HTTP response headers. // * @param body the HTTP response body. // */ // public RackResponse(int status, Map<String, String> headers, Iterator<byte[]> body) { // this.status = status; // this.headers = headers; // this.body = body; // } // // /** // * @return the HTTP status code. // */ // public int getStatus() { // return status; // } // // /** // * @return the HTTP response headers. // */ // public Map<String, String> getHeaders() { // return headers; // } // // /** // * @return the HTTP response body. // */ // public Iterator<byte[]> getBody() { // return body; // } // }
import com.squareup.rack.RackApplication; import com.squareup.rack.RackEnvironment; import com.squareup.rack.RackResponse; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;
/* * Copyright (C) 2013 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.squareup.rack.servlet; /** * <p>Hosts a {@link RackApplication}.</p> * * <p>Since RackServlet lacks a zero-argument constructor, you'll need to manually instantiate and * install it in your container, rather than declaring it in a {@code web.xml} file. See our * examples for concrete code.</p> */ public class RackServlet extends HttpServlet { private final RackEnvironmentBuilder rackEnvironmentBuilder; private final RackApplication rackApplication; private final RackResponsePropagator rackResponsePropagator; /** * Creates a servlet hosting the given {@link RackApplication}. * * @param rackApplication the application to host. */ public RackServlet(RackApplication rackApplication) { this(new RackEnvironmentBuilder(), rackApplication, new RackResponsePropagator()); } /** * Creates a servlet hosting the given {@link RackApplication} and that uses the given * collaborators to translate between the Servlet and Rack environments. * * @param rackEnvironmentBuilder turns {@link HttpServletRequest}s into {@link RackEnvironment}s. * @param rackApplication the application to host. * @param rackResponsePropagator writes {@link RackResponse}s onto {@link HttpServletResponse}s. */ public RackServlet(RackEnvironmentBuilder rackEnvironmentBuilder, RackApplication rackApplication, RackResponsePropagator rackResponsePropagator) { this.rackEnvironmentBuilder = rackEnvironmentBuilder; this.rackApplication = rackApplication; this.rackResponsePropagator = rackResponsePropagator; } @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { RackEnvironment rackEnvironment = rackEnvironmentBuilder.build(request); try {
// Path: core/src/main/java/com/squareup/rack/RackApplication.java // public interface RackApplication { // /** // * Processes a single HTTP request. // * // * @param environment the HTTP request environment. // * @return the HTTP response. // */ // RackResponse call(RackEnvironment environment); // } // // Path: core/src/main/java/com/squareup/rack/RackEnvironment.java // public class RackEnvironment extends ForwardingMap<String, Object> { // public static final String REQUEST_METHOD = "REQUEST_METHOD"; // public static final String SCRIPT_NAME = "SCRIPT_NAME"; // public static final String PATH_INFO = "PATH_INFO"; // public static final String QUERY_STRING = "QUERY_STRING"; // public static final String SERVER_NAME = "SERVER_NAME"; // public static final String SERVER_PORT = "SERVER_PORT"; // public static final String CONTENT_LENGTH = "CONTENT_LENGTH"; // public static final String CONTENT_TYPE = "CONTENT_TYPE"; // public static final String HTTP_HEADER_PREFIX = "HTTP_"; // public static final String RACK_VERSION = "rack.version"; // public static final String RACK_URL_SCHEME = "rack.url_scheme"; // public static final String RACK_INPUT = "rack.input"; // public static final String RACK_ERRORS = "rack.errors"; // public static final String RACK_LOGGER = "rack.logger"; // public static final String RACK_MULTITHREAD = "rack.multithread"; // public static final String RACK_MULTIPROCESS = "rack.multiprocess"; // public static final String RACK_RUN_ONCE = "rack.run_once"; // public static final String RACK_HIJACK = "rack.hijack?"; // public static final String MINECART_HTTP_SERVLET_REQUEST = "minecart.http_servlet_request"; // // private final Map<String, Object> contents; // // /** // * Creates a {@link RackEnvironment} with the given contents. // * // * @see com.squareup.rack.servlet.RackEnvironmentBuilder // * @param contents // */ // public RackEnvironment(Map<String, Object> contents) { // this.contents = contents; // } // // /** // * Closes the rack.input stream. // * // * @throws IOException // */ // public void closeRackInput() throws IOException { // ((Closeable) contents.get(RACK_INPUT)).close(); // } // // @Override protected Map<String, Object> delegate() { // return contents; // } // } // // Path: core/src/main/java/com/squareup/rack/RackResponse.java // public class RackResponse { // private final int status; // private final Map<String, String> headers; // private final Iterator<byte[]> body; // // /** // * Creates a {@link RackResponse} with the given contents. // * // * @param status the HTTP status code. // * @param headers the HTTP response headers. // * @param body the HTTP response body. // */ // public RackResponse(int status, Map<String, String> headers, Iterator<byte[]> body) { // this.status = status; // this.headers = headers; // this.body = body; // } // // /** // * @return the HTTP status code. // */ // public int getStatus() { // return status; // } // // /** // * @return the HTTP response headers. // */ // public Map<String, String> getHeaders() { // return headers; // } // // /** // * @return the HTTP response body. // */ // public Iterator<byte[]> getBody() { // return body; // } // } // Path: core/src/main/java/com/squareup/rack/servlet/RackServlet.java import com.squareup.rack.RackApplication; import com.squareup.rack.RackEnvironment; import com.squareup.rack.RackResponse; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /* * Copyright (C) 2013 Square, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.squareup.rack.servlet; /** * <p>Hosts a {@link RackApplication}.</p> * * <p>Since RackServlet lacks a zero-argument constructor, you'll need to manually instantiate and * install it in your container, rather than declaring it in a {@code web.xml} file. See our * examples for concrete code.</p> */ public class RackServlet extends HttpServlet { private final RackEnvironmentBuilder rackEnvironmentBuilder; private final RackApplication rackApplication; private final RackResponsePropagator rackResponsePropagator; /** * Creates a servlet hosting the given {@link RackApplication}. * * @param rackApplication the application to host. */ public RackServlet(RackApplication rackApplication) { this(new RackEnvironmentBuilder(), rackApplication, new RackResponsePropagator()); } /** * Creates a servlet hosting the given {@link RackApplication} and that uses the given * collaborators to translate between the Servlet and Rack environments. * * @param rackEnvironmentBuilder turns {@link HttpServletRequest}s into {@link RackEnvironment}s. * @param rackApplication the application to host. * @param rackResponsePropagator writes {@link RackResponse}s onto {@link HttpServletResponse}s. */ public RackServlet(RackEnvironmentBuilder rackEnvironmentBuilder, RackApplication rackApplication, RackResponsePropagator rackResponsePropagator) { this.rackEnvironmentBuilder = rackEnvironmentBuilder; this.rackApplication = rackApplication; this.rackResponsePropagator = rackResponsePropagator; } @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { RackEnvironment rackEnvironment = rackEnvironmentBuilder.build(request); try {
RackResponse rackResponse = rackApplication.call(rackEnvironment);
Mahoney/sysout-over-slf4j
sysout-over-slf4j-context/src/test/java/uk/org/lidalia/sysoutslf4j/context/LoggingOutputStreamTests.java
// Path: sysout-over-slf4j-context/src/test/java/uk/org/lidalia/sysoutslf4j/SysOutOverSLF4JTestCase.java // public abstract class SysOutOverSLF4JTestCase { // // protected ClassLoader originalContextClassLoader; // protected PrintStream SYS_OUT; // protected PrintStream SYS_ERR; // // @Before // public void resetLoggers() { // TestLoggerFactory.clearAll(); // } // // @Before // public void storeOriginalSystemOutAndErr() { // SYS_OUT = System.out; // SYS_ERR = System.err; // } // // @After // public void restoreOriginalSystemOutAndErr() { // System.setOut(SYS_OUT); // System.setErr(SYS_ERR); // } // // @Before // public void storeOriginalContextClassLoader() { // originalContextClassLoader = Thread.currentThread().getContextClassLoader(); // } // // @After // public void restoreOriginalContextClassLoader() { // Thread.currentThread().setContextClassLoader(originalContextClassLoader); // } // } // // Path: sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/exceptionhandlers/ExceptionHandlingStrategy.java // public interface ExceptionHandlingStrategy { // // /** // * Called for each line of the stack trace as sent to the System.out/err PrintStream. // * // * @param line The stacktrace line // * @param log The {@link org.slf4j.Logger} with a name matching the fully qualified name of the // * class where printStacktrace was called // */ // void handleExceptionLine(String line, Logger log); // // /** // * Called whenever any other calls are intercepted by sysout-over-slf4j // * - may be a useful trigger for flushing a buffer. // */ // void notifyNotStackTrace(); // }
import java.io.PrintStream; import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.reflect.Whitebox; import org.slf4j.Logger; import uk.org.lidalia.slf4jtest.TestLogger; import uk.org.lidalia.slf4jtest.TestLoggerFactory; import uk.org.lidalia.slf4jext.Level; import uk.org.lidalia.sysoutslf4j.SysOutOverSLF4JTestCase; import uk.org.lidalia.sysoutslf4j.context.exceptionhandlers.ExceptionHandlingStrategy; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.powermock.api.mockito.PowerMockito.mock; import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.when; import static uk.org.lidalia.slf4jtest.LoggingEvent.info; import static uk.org.lidalia.slf4jtest.LoggingEvent.warn;
/* * Copyright (c) 2009-2012 Robert Elliot * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package uk.org.lidalia.sysoutslf4j.context; @RunWith(PowerMockRunner.class) @PrepareForTest({CallOrigin.class, LoggingSystemRegister.class})
// Path: sysout-over-slf4j-context/src/test/java/uk/org/lidalia/sysoutslf4j/SysOutOverSLF4JTestCase.java // public abstract class SysOutOverSLF4JTestCase { // // protected ClassLoader originalContextClassLoader; // protected PrintStream SYS_OUT; // protected PrintStream SYS_ERR; // // @Before // public void resetLoggers() { // TestLoggerFactory.clearAll(); // } // // @Before // public void storeOriginalSystemOutAndErr() { // SYS_OUT = System.out; // SYS_ERR = System.err; // } // // @After // public void restoreOriginalSystemOutAndErr() { // System.setOut(SYS_OUT); // System.setErr(SYS_ERR); // } // // @Before // public void storeOriginalContextClassLoader() { // originalContextClassLoader = Thread.currentThread().getContextClassLoader(); // } // // @After // public void restoreOriginalContextClassLoader() { // Thread.currentThread().setContextClassLoader(originalContextClassLoader); // } // } // // Path: sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/exceptionhandlers/ExceptionHandlingStrategy.java // public interface ExceptionHandlingStrategy { // // /** // * Called for each line of the stack trace as sent to the System.out/err PrintStream. // * // * @param line The stacktrace line // * @param log The {@link org.slf4j.Logger} with a name matching the fully qualified name of the // * class where printStacktrace was called // */ // void handleExceptionLine(String line, Logger log); // // /** // * Called whenever any other calls are intercepted by sysout-over-slf4j // * - may be a useful trigger for flushing a buffer. // */ // void notifyNotStackTrace(); // } // Path: sysout-over-slf4j-context/src/test/java/uk/org/lidalia/sysoutslf4j/context/LoggingOutputStreamTests.java import java.io.PrintStream; import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.reflect.Whitebox; import org.slf4j.Logger; import uk.org.lidalia.slf4jtest.TestLogger; import uk.org.lidalia.slf4jtest.TestLoggerFactory; import uk.org.lidalia.slf4jext.Level; import uk.org.lidalia.sysoutslf4j.SysOutOverSLF4JTestCase; import uk.org.lidalia.sysoutslf4j.context.exceptionhandlers.ExceptionHandlingStrategy; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.powermock.api.mockito.PowerMockito.mock; import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.when; import static uk.org.lidalia.slf4jtest.LoggingEvent.info; import static uk.org.lidalia.slf4jtest.LoggingEvent.warn; /* * Copyright (c) 2009-2012 Robert Elliot * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package uk.org.lidalia.sysoutslf4j.context; @RunWith(PowerMockRunner.class) @PrepareForTest({CallOrigin.class, LoggingSystemRegister.class})
public class LoggingOutputStreamTests extends SysOutOverSLF4JTestCase {
Mahoney/sysout-over-slf4j
sysout-over-slf4j-context/src/test/java/uk/org/lidalia/sysoutslf4j/context/LoggingOutputStreamTests.java
// Path: sysout-over-slf4j-context/src/test/java/uk/org/lidalia/sysoutslf4j/SysOutOverSLF4JTestCase.java // public abstract class SysOutOverSLF4JTestCase { // // protected ClassLoader originalContextClassLoader; // protected PrintStream SYS_OUT; // protected PrintStream SYS_ERR; // // @Before // public void resetLoggers() { // TestLoggerFactory.clearAll(); // } // // @Before // public void storeOriginalSystemOutAndErr() { // SYS_OUT = System.out; // SYS_ERR = System.err; // } // // @After // public void restoreOriginalSystemOutAndErr() { // System.setOut(SYS_OUT); // System.setErr(SYS_ERR); // } // // @Before // public void storeOriginalContextClassLoader() { // originalContextClassLoader = Thread.currentThread().getContextClassLoader(); // } // // @After // public void restoreOriginalContextClassLoader() { // Thread.currentThread().setContextClassLoader(originalContextClassLoader); // } // } // // Path: sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/exceptionhandlers/ExceptionHandlingStrategy.java // public interface ExceptionHandlingStrategy { // // /** // * Called for each line of the stack trace as sent to the System.out/err PrintStream. // * // * @param line The stacktrace line // * @param log The {@link org.slf4j.Logger} with a name matching the fully qualified name of the // * class where printStacktrace was called // */ // void handleExceptionLine(String line, Logger log); // // /** // * Called whenever any other calls are intercepted by sysout-over-slf4j // * - may be a useful trigger for flushing a buffer. // */ // void notifyNotStackTrace(); // }
import java.io.PrintStream; import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.reflect.Whitebox; import org.slf4j.Logger; import uk.org.lidalia.slf4jtest.TestLogger; import uk.org.lidalia.slf4jtest.TestLoggerFactory; import uk.org.lidalia.slf4jext.Level; import uk.org.lidalia.sysoutslf4j.SysOutOverSLF4JTestCase; import uk.org.lidalia.sysoutslf4j.context.exceptionhandlers.ExceptionHandlingStrategy; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.powermock.api.mockito.PowerMockito.mock; import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.when; import static uk.org.lidalia.slf4jtest.LoggingEvent.info; import static uk.org.lidalia.slf4jtest.LoggingEvent.warn;
/* * Copyright (c) 2009-2012 Robert Elliot * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package uk.org.lidalia.sysoutslf4j.context; @RunWith(PowerMockRunner.class) @PrepareForTest({CallOrigin.class, LoggingSystemRegister.class}) public class LoggingOutputStreamTests extends SysOutOverSLF4JTestCase { private static final String CLASS_IN_LOGGING_SYSTEM = "org.logging.LoggerClass"; private static final String CLASS_NAME = "org.something.SomeClass"; private Level level = Level.INFO;
// Path: sysout-over-slf4j-context/src/test/java/uk/org/lidalia/sysoutslf4j/SysOutOverSLF4JTestCase.java // public abstract class SysOutOverSLF4JTestCase { // // protected ClassLoader originalContextClassLoader; // protected PrintStream SYS_OUT; // protected PrintStream SYS_ERR; // // @Before // public void resetLoggers() { // TestLoggerFactory.clearAll(); // } // // @Before // public void storeOriginalSystemOutAndErr() { // SYS_OUT = System.out; // SYS_ERR = System.err; // } // // @After // public void restoreOriginalSystemOutAndErr() { // System.setOut(SYS_OUT); // System.setErr(SYS_ERR); // } // // @Before // public void storeOriginalContextClassLoader() { // originalContextClassLoader = Thread.currentThread().getContextClassLoader(); // } // // @After // public void restoreOriginalContextClassLoader() { // Thread.currentThread().setContextClassLoader(originalContextClassLoader); // } // } // // Path: sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/exceptionhandlers/ExceptionHandlingStrategy.java // public interface ExceptionHandlingStrategy { // // /** // * Called for each line of the stack trace as sent to the System.out/err PrintStream. // * // * @param line The stacktrace line // * @param log The {@link org.slf4j.Logger} with a name matching the fully qualified name of the // * class where printStacktrace was called // */ // void handleExceptionLine(String line, Logger log); // // /** // * Called whenever any other calls are intercepted by sysout-over-slf4j // * - may be a useful trigger for flushing a buffer. // */ // void notifyNotStackTrace(); // } // Path: sysout-over-slf4j-context/src/test/java/uk/org/lidalia/sysoutslf4j/context/LoggingOutputStreamTests.java import java.io.PrintStream; import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.reflect.Whitebox; import org.slf4j.Logger; import uk.org.lidalia.slf4jtest.TestLogger; import uk.org.lidalia.slf4jtest.TestLoggerFactory; import uk.org.lidalia.slf4jext.Level; import uk.org.lidalia.sysoutslf4j.SysOutOverSLF4JTestCase; import uk.org.lidalia.sysoutslf4j.context.exceptionhandlers.ExceptionHandlingStrategy; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.powermock.api.mockito.PowerMockito.mock; import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.when; import static uk.org.lidalia.slf4jtest.LoggingEvent.info; import static uk.org.lidalia.slf4jtest.LoggingEvent.warn; /* * Copyright (c) 2009-2012 Robert Elliot * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package uk.org.lidalia.sysoutslf4j.context; @RunWith(PowerMockRunner.class) @PrepareForTest({CallOrigin.class, LoggingSystemRegister.class}) public class LoggingOutputStreamTests extends SysOutOverSLF4JTestCase { private static final String CLASS_IN_LOGGING_SYSTEM = "org.logging.LoggerClass"; private static final String CLASS_NAME = "org.something.SomeClass"; private Level level = Level.INFO;
private ExceptionHandlingStrategy exceptionHandlingStrategyMock = mock(ExceptionHandlingStrategy.class);
Mahoney/sysout-over-slf4j
sysout-over-slf4j-context/src/test/java/uk/org/lidalia/sysoutslf4j/context/ServletContextListenerTests.java
// Path: sysout-over-slf4j-context/src/test/java/uk/org/lidalia/sysoutslf4j/SysOutOverSLF4JTestCase.java // public abstract class SysOutOverSLF4JTestCase { // // protected ClassLoader originalContextClassLoader; // protected PrintStream SYS_OUT; // protected PrintStream SYS_ERR; // // @Before // public void resetLoggers() { // TestLoggerFactory.clearAll(); // } // // @Before // public void storeOriginalSystemOutAndErr() { // SYS_OUT = System.out; // SYS_ERR = System.err; // } // // @After // public void restoreOriginalSystemOutAndErr() { // System.setOut(SYS_OUT); // System.setErr(SYS_ERR); // } // // @Before // public void storeOriginalContextClassLoader() { // originalContextClassLoader = Thread.currentThread().getContextClassLoader(); // } // // @After // public void restoreOriginalContextClassLoader() { // Thread.currentThread().setContextClassLoader(originalContextClassLoader); // } // }
import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.verifyStatic; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import uk.org.lidalia.sysoutslf4j.SysOutOverSLF4JTestCase;
/* * Copyright (c) 2009-2012 Robert Elliot * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package uk.org.lidalia.sysoutslf4j.context; @RunWith(PowerMockRunner.class) @PrepareForTest({ SysOutOverSLF4J.class })
// Path: sysout-over-slf4j-context/src/test/java/uk/org/lidalia/sysoutslf4j/SysOutOverSLF4JTestCase.java // public abstract class SysOutOverSLF4JTestCase { // // protected ClassLoader originalContextClassLoader; // protected PrintStream SYS_OUT; // protected PrintStream SYS_ERR; // // @Before // public void resetLoggers() { // TestLoggerFactory.clearAll(); // } // // @Before // public void storeOriginalSystemOutAndErr() { // SYS_OUT = System.out; // SYS_ERR = System.err; // } // // @After // public void restoreOriginalSystemOutAndErr() { // System.setOut(SYS_OUT); // System.setErr(SYS_ERR); // } // // @Before // public void storeOriginalContextClassLoader() { // originalContextClassLoader = Thread.currentThread().getContextClassLoader(); // } // // @After // public void restoreOriginalContextClassLoader() { // Thread.currentThread().setContextClassLoader(originalContextClassLoader); // } // } // Path: sysout-over-slf4j-context/src/test/java/uk/org/lidalia/sysoutslf4j/context/ServletContextListenerTests.java import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.verifyStatic; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import uk.org.lidalia.sysoutslf4j.SysOutOverSLF4JTestCase; /* * Copyright (c) 2009-2012 Robert Elliot * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package uk.org.lidalia.sysoutslf4j.context; @RunWith(PowerMockRunner.class) @PrepareForTest({ SysOutOverSLF4J.class })
public class ServletContextListenerTests extends SysOutOverSLF4JTestCase {
Mahoney/sysout-over-slf4j
sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/jul/ConsoleHandler.java
// Path: sysout-over-slf4j-system/src/main/java/uk/org/lidalia/sysoutslf4j/system/PerContextSystemOutput.java // public enum PerContextSystemOutput { // // OUT(SystemOutput.OUT), ERR(SystemOutput.ERR); // // private final SystemOutput systemOutput; // // private PerContextSystemOutput(final SystemOutput systemOutput) { // this.systemOutput = systemOutput; // } // // public boolean isPerContextPrintStream() { // return systemOutput.get() instanceof PerContextPrintStream; // } // // public void restoreOriginalPrintStream() { // final Lock writeLock = systemOutput.getLock().writeLock(); // writeLock.lock(); // try { // if (isPerContextPrintStream()) { // systemOutput.set(getPerContextPrintStream().getOriginalPrintStream()); // } // } finally { // writeLock.unlock(); // } // } // // public PrintStream getOriginalPrintStream() { // final PrintStream result; // final Lock readLock = systemOutput.getLock().readLock(); // readLock.lock(); // try { // if (isPerContextPrintStream()) { // result = getPerContextPrintStream().getOriginalPrintStream(); // } else { // result = systemOutput.get(); // } // return result; // } finally { // readLock.unlock(); // } // } // // private PerContextPrintStream getPerContextPrintStream() { // return (PerContextPrintStream) systemOutput.get(); // } // // public void deregisterPrintStreamForThisContext() { // final Lock readLock = systemOutput.getLock().readLock(); // readLock.lock(); // try { // if (isPerContextPrintStream()) { // getPerContextPrintStream().deregisterPrintStreamForThisContext(); // } // } finally { // readLock.unlock(); // } // } // // public void registerPrintStreamForThisContext(final PrintStream printStreamForThisContext) { // final Lock writeLock = systemOutput.getLock().writeLock(); // writeLock.lock(); // try { // makePerContextPrintStream(); // getPerContextPrintStream().registerPrintStreamForThisContext(printStreamForThisContext); // } finally { // writeLock.unlock(); // } // } // // private void makePerContextPrintStream() { // if (!isPerContextPrintStream()) { // systemOutput.set(buildPerContextPrintStream()); // } // } // // private PerContextPrintStream buildPerContextPrintStream() { // final PrintStream originalPrintStream = systemOutput.get(); // return new PerContextPrintStream(originalPrintStream); // } // // public static PerContextSystemOutput findByName(String name) { // for (PerContextSystemOutput systemOutput : PerContextSystemOutput.values()) { // if (systemOutput.systemOutput.getName().equalsIgnoreCase(name)) { // return systemOutput; // } // } // throw new IllegalArgumentException("No system output [" + name + "]; valid values are " + names()); // } // // private static String names() { // StringBuilder builder = new StringBuilder("["); // PerContextSystemOutput[] values = values(); // for (int i = 0; i < values.length; i++) { // builder.append(values[i].systemOutput.getName()); // if (i < values.length - 1) { // builder.append(","); // } // } // builder.append("]"); // return builder.toString(); // } // }
import java.util.logging.LogRecord; import java.util.logging.StreamHandler; import uk.org.lidalia.sysoutslf4j.system.PerContextSystemOutput;
package uk.org.lidalia.sysoutslf4j.context.jul; public class ConsoleHandler extends StreamHandler { /** * Create a <tt>ConsoleHandler</tt> for <tt>System.err</tt>. * <p> * The <tt>ConsoleHandler</tt> is configured based on * <tt>LogManager</tt> properties (or their default values). * */ public ConsoleHandler() {
// Path: sysout-over-slf4j-system/src/main/java/uk/org/lidalia/sysoutslf4j/system/PerContextSystemOutput.java // public enum PerContextSystemOutput { // // OUT(SystemOutput.OUT), ERR(SystemOutput.ERR); // // private final SystemOutput systemOutput; // // private PerContextSystemOutput(final SystemOutput systemOutput) { // this.systemOutput = systemOutput; // } // // public boolean isPerContextPrintStream() { // return systemOutput.get() instanceof PerContextPrintStream; // } // // public void restoreOriginalPrintStream() { // final Lock writeLock = systemOutput.getLock().writeLock(); // writeLock.lock(); // try { // if (isPerContextPrintStream()) { // systemOutput.set(getPerContextPrintStream().getOriginalPrintStream()); // } // } finally { // writeLock.unlock(); // } // } // // public PrintStream getOriginalPrintStream() { // final PrintStream result; // final Lock readLock = systemOutput.getLock().readLock(); // readLock.lock(); // try { // if (isPerContextPrintStream()) { // result = getPerContextPrintStream().getOriginalPrintStream(); // } else { // result = systemOutput.get(); // } // return result; // } finally { // readLock.unlock(); // } // } // // private PerContextPrintStream getPerContextPrintStream() { // return (PerContextPrintStream) systemOutput.get(); // } // // public void deregisterPrintStreamForThisContext() { // final Lock readLock = systemOutput.getLock().readLock(); // readLock.lock(); // try { // if (isPerContextPrintStream()) { // getPerContextPrintStream().deregisterPrintStreamForThisContext(); // } // } finally { // readLock.unlock(); // } // } // // public void registerPrintStreamForThisContext(final PrintStream printStreamForThisContext) { // final Lock writeLock = systemOutput.getLock().writeLock(); // writeLock.lock(); // try { // makePerContextPrintStream(); // getPerContextPrintStream().registerPrintStreamForThisContext(printStreamForThisContext); // } finally { // writeLock.unlock(); // } // } // // private void makePerContextPrintStream() { // if (!isPerContextPrintStream()) { // systemOutput.set(buildPerContextPrintStream()); // } // } // // private PerContextPrintStream buildPerContextPrintStream() { // final PrintStream originalPrintStream = systemOutput.get(); // return new PerContextPrintStream(originalPrintStream); // } // // public static PerContextSystemOutput findByName(String name) { // for (PerContextSystemOutput systemOutput : PerContextSystemOutput.values()) { // if (systemOutput.systemOutput.getName().equalsIgnoreCase(name)) { // return systemOutput; // } // } // throw new IllegalArgumentException("No system output [" + name + "]; valid values are " + names()); // } // // private static String names() { // StringBuilder builder = new StringBuilder("["); // PerContextSystemOutput[] values = values(); // for (int i = 0; i < values.length; i++) { // builder.append(values[i].systemOutput.getName()); // if (i < values.length - 1) { // builder.append(","); // } // } // builder.append("]"); // return builder.toString(); // } // } // Path: sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/jul/ConsoleHandler.java import java.util.logging.LogRecord; import java.util.logging.StreamHandler; import uk.org.lidalia.sysoutslf4j.system.PerContextSystemOutput; package uk.org.lidalia.sysoutslf4j.context.jul; public class ConsoleHandler extends StreamHandler { /** * Create a <tt>ConsoleHandler</tt> for <tt>System.err</tt>. * <p> * The <tt>ConsoleHandler</tt> is configured based on * <tt>LogManager</tt> properties (or their default values). * */ public ConsoleHandler() {
setOutputStream(PerContextSystemOutput.ERR.getOriginalPrintStream());
Mahoney/sysout-over-slf4j
sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/LoggingOutputStream.java
// Path: sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/exceptionhandlers/ExceptionHandlingStrategy.java // public interface ExceptionHandlingStrategy { // // /** // * Called for each line of the stack trace as sent to the System.out/err PrintStream. // * // * @param line The stacktrace line // * @param log The {@link org.slf4j.Logger} with a name matching the fully qualified name of the // * class where printStacktrace was called // */ // void handleExceptionLine(String line, Logger log); // // /** // * Called whenever any other calls are intercepted by sysout-over-slf4j // * - may be a useful trigger for flushing a buffer. // */ // void notifyNotStackTrace(); // } // // Path: sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/CallOrigin.java // static CallOrigin getCallOrigin(LoggingSystemRegister loggingSystemRegister) { // Thread currentThread = Thread.currentThread(); // final List<StackTraceElement> stackTraceElements = asList(currentThread.getStackTrace()); // int firstPerContextPrintStreamFrame = frameWithPrintStreamClassName(stackTraceElements, 0).or(THROW_ILLEGAL_STATE_EXCEPTION); // int secondPerContextPrintStreamFrame = frameWithPrintStreamClassName(stackTraceElements, firstPerContextPrintStreamFrame + 1).or(stackTraceElements.size()); // // final List<StackTraceElement> interestingStackTraceElements = stackTraceElements.subList(firstPerContextPrintStreamFrame + 1, secondPerContextPrintStreamFrame); // // for (int i = interestingStackTraceElements.size() - 2; i >= 0; i--) { // StackTraceElement stackTraceElement = interestingStackTraceElements.get(i); // String currentClassName = stackTraceElement.getClassName(); // if (currentClassName.equals(Throwable.class.getName()) && stackTraceElement.getMethodName().equals("printStackTrace")) { // return new CallOrigin(true, false, getOuterClassName(interestingStackTraceElements.get(i + 1).getClassName())); // } // if (loggingSystemRegister.isInLoggingSystem(currentClassName)) { // return new CallOrigin(false, true, null); // } // } // return new CallOrigin(false, false, getOuterClassName(interestingStackTraceElements.get(0).getClassName())); // }
import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import uk.org.lidalia.slf4jext.Level; import uk.org.lidalia.slf4jext.Logger; import uk.org.lidalia.slf4jext.LoggerFactory; import uk.org.lidalia.sysoutslf4j.context.exceptionhandlers.ExceptionHandlingStrategy; import static uk.org.lidalia.sysoutslf4j.context.CallOrigin.getCallOrigin;
package uk.org.lidalia.sysoutslf4j.context; class LoggingOutputStream extends ByteArrayOutputStream { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggingOutputStream.class); private final Level level;
// Path: sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/exceptionhandlers/ExceptionHandlingStrategy.java // public interface ExceptionHandlingStrategy { // // /** // * Called for each line of the stack trace as sent to the System.out/err PrintStream. // * // * @param line The stacktrace line // * @param log The {@link org.slf4j.Logger} with a name matching the fully qualified name of the // * class where printStacktrace was called // */ // void handleExceptionLine(String line, Logger log); // // /** // * Called whenever any other calls are intercepted by sysout-over-slf4j // * - may be a useful trigger for flushing a buffer. // */ // void notifyNotStackTrace(); // } // // Path: sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/CallOrigin.java // static CallOrigin getCallOrigin(LoggingSystemRegister loggingSystemRegister) { // Thread currentThread = Thread.currentThread(); // final List<StackTraceElement> stackTraceElements = asList(currentThread.getStackTrace()); // int firstPerContextPrintStreamFrame = frameWithPrintStreamClassName(stackTraceElements, 0).or(THROW_ILLEGAL_STATE_EXCEPTION); // int secondPerContextPrintStreamFrame = frameWithPrintStreamClassName(stackTraceElements, firstPerContextPrintStreamFrame + 1).or(stackTraceElements.size()); // // final List<StackTraceElement> interestingStackTraceElements = stackTraceElements.subList(firstPerContextPrintStreamFrame + 1, secondPerContextPrintStreamFrame); // // for (int i = interestingStackTraceElements.size() - 2; i >= 0; i--) { // StackTraceElement stackTraceElement = interestingStackTraceElements.get(i); // String currentClassName = stackTraceElement.getClassName(); // if (currentClassName.equals(Throwable.class.getName()) && stackTraceElement.getMethodName().equals("printStackTrace")) { // return new CallOrigin(true, false, getOuterClassName(interestingStackTraceElements.get(i + 1).getClassName())); // } // if (loggingSystemRegister.isInLoggingSystem(currentClassName)) { // return new CallOrigin(false, true, null); // } // } // return new CallOrigin(false, false, getOuterClassName(interestingStackTraceElements.get(0).getClassName())); // } // Path: sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/LoggingOutputStream.java import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import uk.org.lidalia.slf4jext.Level; import uk.org.lidalia.slf4jext.Logger; import uk.org.lidalia.slf4jext.LoggerFactory; import uk.org.lidalia.sysoutslf4j.context.exceptionhandlers.ExceptionHandlingStrategy; import static uk.org.lidalia.sysoutslf4j.context.CallOrigin.getCallOrigin; package uk.org.lidalia.sysoutslf4j.context; class LoggingOutputStream extends ByteArrayOutputStream { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggingOutputStream.class); private final Level level;
private final ExceptionHandlingStrategy exceptionHandlingStrategy;
Mahoney/sysout-over-slf4j
sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/LoggingOutputStream.java
// Path: sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/exceptionhandlers/ExceptionHandlingStrategy.java // public interface ExceptionHandlingStrategy { // // /** // * Called for each line of the stack trace as sent to the System.out/err PrintStream. // * // * @param line The stacktrace line // * @param log The {@link org.slf4j.Logger} with a name matching the fully qualified name of the // * class where printStacktrace was called // */ // void handleExceptionLine(String line, Logger log); // // /** // * Called whenever any other calls are intercepted by sysout-over-slf4j // * - may be a useful trigger for flushing a buffer. // */ // void notifyNotStackTrace(); // } // // Path: sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/CallOrigin.java // static CallOrigin getCallOrigin(LoggingSystemRegister loggingSystemRegister) { // Thread currentThread = Thread.currentThread(); // final List<StackTraceElement> stackTraceElements = asList(currentThread.getStackTrace()); // int firstPerContextPrintStreamFrame = frameWithPrintStreamClassName(stackTraceElements, 0).or(THROW_ILLEGAL_STATE_EXCEPTION); // int secondPerContextPrintStreamFrame = frameWithPrintStreamClassName(stackTraceElements, firstPerContextPrintStreamFrame + 1).or(stackTraceElements.size()); // // final List<StackTraceElement> interestingStackTraceElements = stackTraceElements.subList(firstPerContextPrintStreamFrame + 1, secondPerContextPrintStreamFrame); // // for (int i = interestingStackTraceElements.size() - 2; i >= 0; i--) { // StackTraceElement stackTraceElement = interestingStackTraceElements.get(i); // String currentClassName = stackTraceElement.getClassName(); // if (currentClassName.equals(Throwable.class.getName()) && stackTraceElement.getMethodName().equals("printStackTrace")) { // return new CallOrigin(true, false, getOuterClassName(interestingStackTraceElements.get(i + 1).getClassName())); // } // if (loggingSystemRegister.isInLoggingSystem(currentClassName)) { // return new CallOrigin(false, true, null); // } // } // return new CallOrigin(false, false, getOuterClassName(interestingStackTraceElements.get(0).getClassName())); // }
import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import uk.org.lidalia.slf4jext.Level; import uk.org.lidalia.slf4jext.Logger; import uk.org.lidalia.slf4jext.LoggerFactory; import uk.org.lidalia.sysoutslf4j.context.exceptionhandlers.ExceptionHandlingStrategy; import static uk.org.lidalia.sysoutslf4j.context.CallOrigin.getCallOrigin;
package uk.org.lidalia.sysoutslf4j.context; class LoggingOutputStream extends ByteArrayOutputStream { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggingOutputStream.class); private final Level level; private final ExceptionHandlingStrategy exceptionHandlingStrategy; private final PrintStream originalPrintStream; private final LoggingSystemRegister loggingSystemRegister; LoggingOutputStream(final Level level, final ExceptionHandlingStrategy exceptionHandlingStrategy, final PrintStream originalPrintStream, final LoggingSystemRegister loggingSystemRegister) { super(); this.level = level; this.exceptionHandlingStrategy = exceptionHandlingStrategy; this.originalPrintStream = originalPrintStream; this.loggingSystemRegister = loggingSystemRegister; } @Override public synchronized void flush() throws IOException {
// Path: sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/exceptionhandlers/ExceptionHandlingStrategy.java // public interface ExceptionHandlingStrategy { // // /** // * Called for each line of the stack trace as sent to the System.out/err PrintStream. // * // * @param line The stacktrace line // * @param log The {@link org.slf4j.Logger} with a name matching the fully qualified name of the // * class where printStacktrace was called // */ // void handleExceptionLine(String line, Logger log); // // /** // * Called whenever any other calls are intercepted by sysout-over-slf4j // * - may be a useful trigger for flushing a buffer. // */ // void notifyNotStackTrace(); // } // // Path: sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/CallOrigin.java // static CallOrigin getCallOrigin(LoggingSystemRegister loggingSystemRegister) { // Thread currentThread = Thread.currentThread(); // final List<StackTraceElement> stackTraceElements = asList(currentThread.getStackTrace()); // int firstPerContextPrintStreamFrame = frameWithPrintStreamClassName(stackTraceElements, 0).or(THROW_ILLEGAL_STATE_EXCEPTION); // int secondPerContextPrintStreamFrame = frameWithPrintStreamClassName(stackTraceElements, firstPerContextPrintStreamFrame + 1).or(stackTraceElements.size()); // // final List<StackTraceElement> interestingStackTraceElements = stackTraceElements.subList(firstPerContextPrintStreamFrame + 1, secondPerContextPrintStreamFrame); // // for (int i = interestingStackTraceElements.size() - 2; i >= 0; i--) { // StackTraceElement stackTraceElement = interestingStackTraceElements.get(i); // String currentClassName = stackTraceElement.getClassName(); // if (currentClassName.equals(Throwable.class.getName()) && stackTraceElement.getMethodName().equals("printStackTrace")) { // return new CallOrigin(true, false, getOuterClassName(interestingStackTraceElements.get(i + 1).getClassName())); // } // if (loggingSystemRegister.isInLoggingSystem(currentClassName)) { // return new CallOrigin(false, true, null); // } // } // return new CallOrigin(false, false, getOuterClassName(interestingStackTraceElements.get(0).getClassName())); // } // Path: sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/LoggingOutputStream.java import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import uk.org.lidalia.slf4jext.Level; import uk.org.lidalia.slf4jext.Logger; import uk.org.lidalia.slf4jext.LoggerFactory; import uk.org.lidalia.sysoutslf4j.context.exceptionhandlers.ExceptionHandlingStrategy; import static uk.org.lidalia.sysoutslf4j.context.CallOrigin.getCallOrigin; package uk.org.lidalia.sysoutslf4j.context; class LoggingOutputStream extends ByteArrayOutputStream { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggingOutputStream.class); private final Level level; private final ExceptionHandlingStrategy exceptionHandlingStrategy; private final PrintStream originalPrintStream; private final LoggingSystemRegister loggingSystemRegister; LoggingOutputStream(final Level level, final ExceptionHandlingStrategy exceptionHandlingStrategy, final PrintStream originalPrintStream, final LoggingSystemRegister loggingSystemRegister) { super(); this.level = level; this.exceptionHandlingStrategy = exceptionHandlingStrategy; this.originalPrintStream = originalPrintStream; this.loggingSystemRegister = loggingSystemRegister; } @Override public synchronized void flush() throws IOException {
final CallOrigin callOrigin = getCallOrigin(loggingSystemRegister);
Mahoney/sysout-over-slf4j
functional-tests/sysout-over-slf4j-webapps/webapp-with-jdk14/src/main/java/uk/org/lidalia/sysoutslf4j/webapps/PrinterServlet.java
// Path: sysout-over-slf4j-system/src/main/java/uk/org/lidalia/sysoutslf4j/system/SystemOutput.java // public enum SystemOutput { // // OUT("System.out") { // public PrintStream get() { // final Lock readLock = getLock().readLock(); // readLock.lock(); // try { // return System.out; // } finally { // readLock.unlock(); // } // } // // public void set(final PrintStream newPrintStream) { // final Lock writeLock = getLock().writeLock(); // writeLock.lock(); // try { // System.setOut(newPrintStream); // } finally { // writeLock.unlock(); // } // } // }, ERR("System.err") { // public PrintStream get() { // final Lock readLock = getLock().readLock(); // readLock.lock(); // try { // return System.err; // } finally { // readLock.unlock(); // } // } // // public void set(final PrintStream newPrintStream) { // final Lock writeLock = getLock().writeLock(); // writeLock.lock(); // try { // System.setErr(newPrintStream); // } finally { // writeLock.unlock(); // } // } // }; // // public abstract PrintStream get(); // public abstract void set(PrintStream newPrintStream); // // private final String name; // private final ReadWriteLock lock = new ReentrantReadWriteLock(); // // private SystemOutput(final String name) { // this.name = name; // } // // public ReadWriteLock getLock() { // return lock; // } // // @Override // public String toString() { // return name; // } // // public String getName() { // return name; // } // // public static SystemOutput findByName(String name) { // for (SystemOutput systemOutput : SystemOutput.values()) { // if (systemOutput.name.equalsIgnoreCase(name)) { // return systemOutput; // } // } // throw new IllegalArgumentException("No system output [" + name + "]; valid values are " + names()); // } // // private static String names() { // StringBuilder builder = new StringBuilder("["); // SystemOutput[] values = values(); // for (int i = 0; i < values.length; i++) { // builder.append(values[i].getName()); // if (i < values.length - 1) { // builder.append(","); // } // } // builder.append("]"); // return builder.toString(); // } // }
import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import uk.org.lidalia.sysoutslf4j.system.SystemOutput; import static com.google.common.base.Optional.fromNullable;
package uk.org.lidalia.sysoutslf4j.webapps; public class PrinterServlet extends HttpServlet { private static final long serialVersionUID = 1; protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String name = fromNullable(request.getParameter("output")).or("System.out");
// Path: sysout-over-slf4j-system/src/main/java/uk/org/lidalia/sysoutslf4j/system/SystemOutput.java // public enum SystemOutput { // // OUT("System.out") { // public PrintStream get() { // final Lock readLock = getLock().readLock(); // readLock.lock(); // try { // return System.out; // } finally { // readLock.unlock(); // } // } // // public void set(final PrintStream newPrintStream) { // final Lock writeLock = getLock().writeLock(); // writeLock.lock(); // try { // System.setOut(newPrintStream); // } finally { // writeLock.unlock(); // } // } // }, ERR("System.err") { // public PrintStream get() { // final Lock readLock = getLock().readLock(); // readLock.lock(); // try { // return System.err; // } finally { // readLock.unlock(); // } // } // // public void set(final PrintStream newPrintStream) { // final Lock writeLock = getLock().writeLock(); // writeLock.lock(); // try { // System.setErr(newPrintStream); // } finally { // writeLock.unlock(); // } // } // }; // // public abstract PrintStream get(); // public abstract void set(PrintStream newPrintStream); // // private final String name; // private final ReadWriteLock lock = new ReentrantReadWriteLock(); // // private SystemOutput(final String name) { // this.name = name; // } // // public ReadWriteLock getLock() { // return lock; // } // // @Override // public String toString() { // return name; // } // // public String getName() { // return name; // } // // public static SystemOutput findByName(String name) { // for (SystemOutput systemOutput : SystemOutput.values()) { // if (systemOutput.name.equalsIgnoreCase(name)) { // return systemOutput; // } // } // throw new IllegalArgumentException("No system output [" + name + "]; valid values are " + names()); // } // // private static String names() { // StringBuilder builder = new StringBuilder("["); // SystemOutput[] values = values(); // for (int i = 0; i < values.length; i++) { // builder.append(values[i].getName()); // if (i < values.length - 1) { // builder.append(","); // } // } // builder.append("]"); // return builder.toString(); // } // } // Path: functional-tests/sysout-over-slf4j-webapps/webapp-with-jdk14/src/main/java/uk/org/lidalia/sysoutslf4j/webapps/PrinterServlet.java import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import uk.org.lidalia.sysoutslf4j.system.SystemOutput; import static com.google.common.base.Optional.fromNullable; package uk.org.lidalia.sysoutslf4j.webapps; public class PrinterServlet extends HttpServlet { private static final long serialVersionUID = 1; protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String name = fromNullable(request.getParameter("output")).or("System.out");
SystemOutput output = SystemOutput.findByName(name);
Mahoney/sysout-over-slf4j
sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/log4j/ConsoleAppender.java
// Path: sysout-over-slf4j-system/src/main/java/uk/org/lidalia/sysoutslf4j/system/PerContextSystemOutput.java // public enum PerContextSystemOutput { // // OUT(SystemOutput.OUT), ERR(SystemOutput.ERR); // // private final SystemOutput systemOutput; // // private PerContextSystemOutput(final SystemOutput systemOutput) { // this.systemOutput = systemOutput; // } // // public boolean isPerContextPrintStream() { // return systemOutput.get() instanceof PerContextPrintStream; // } // // public void restoreOriginalPrintStream() { // final Lock writeLock = systemOutput.getLock().writeLock(); // writeLock.lock(); // try { // if (isPerContextPrintStream()) { // systemOutput.set(getPerContextPrintStream().getOriginalPrintStream()); // } // } finally { // writeLock.unlock(); // } // } // // public PrintStream getOriginalPrintStream() { // final PrintStream result; // final Lock readLock = systemOutput.getLock().readLock(); // readLock.lock(); // try { // if (isPerContextPrintStream()) { // result = getPerContextPrintStream().getOriginalPrintStream(); // } else { // result = systemOutput.get(); // } // return result; // } finally { // readLock.unlock(); // } // } // // private PerContextPrintStream getPerContextPrintStream() { // return (PerContextPrintStream) systemOutput.get(); // } // // public void deregisterPrintStreamForThisContext() { // final Lock readLock = systemOutput.getLock().readLock(); // readLock.lock(); // try { // if (isPerContextPrintStream()) { // getPerContextPrintStream().deregisterPrintStreamForThisContext(); // } // } finally { // readLock.unlock(); // } // } // // public void registerPrintStreamForThisContext(final PrintStream printStreamForThisContext) { // final Lock writeLock = systemOutput.getLock().writeLock(); // writeLock.lock(); // try { // makePerContextPrintStream(); // getPerContextPrintStream().registerPrintStreamForThisContext(printStreamForThisContext); // } finally { // writeLock.unlock(); // } // } // // private void makePerContextPrintStream() { // if (!isPerContextPrintStream()) { // systemOutput.set(buildPerContextPrintStream()); // } // } // // private PerContextPrintStream buildPerContextPrintStream() { // final PrintStream originalPrintStream = systemOutput.get(); // return new PerContextPrintStream(originalPrintStream); // } // // public static PerContextSystemOutput findByName(String name) { // for (PerContextSystemOutput systemOutput : PerContextSystemOutput.values()) { // if (systemOutput.systemOutput.getName().equalsIgnoreCase(name)) { // return systemOutput; // } // } // throw new IllegalArgumentException("No system output [" + name + "]; valid values are " + names()); // } // // private static String names() { // StringBuilder builder = new StringBuilder("["); // PerContextSystemOutput[] values = values(); // for (int i = 0; i < values.length; i++) { // builder.append(values[i].systemOutput.getName()); // if (i < values.length - 1) { // builder.append(","); // } // } // builder.append("]"); // return builder.toString(); // } // }
import org.apache.log4j.Layout; import org.apache.log4j.WriterAppender; import org.apache.log4j.helpers.LogLog; import uk.org.lidalia.sysoutslf4j.system.PerContextSystemOutput;
if (SYSTEM_OUT.equalsIgnoreCase(v)) { target = SYSTEM_OUT; } else if (SYSTEM_ERR.equalsIgnoreCase(v)) { target = SYSTEM_ERR; } else { targetWarn(value); } } /** * Returns the current value of the <b>Target</b> property. The * default value of the option is "System.out". * * See also {@link #setTarget}. * */ public String getTarget() { return target; } void targetWarn(String val) { LogLog.warn("["+val+"] should be System.out or System.err."); LogLog.warn("Using previously set target, System.out by default."); } /** * Prepares the appender for use. */ public void activateOptions() { if (target.equals(SYSTEM_ERR)) {
// Path: sysout-over-slf4j-system/src/main/java/uk/org/lidalia/sysoutslf4j/system/PerContextSystemOutput.java // public enum PerContextSystemOutput { // // OUT(SystemOutput.OUT), ERR(SystemOutput.ERR); // // private final SystemOutput systemOutput; // // private PerContextSystemOutput(final SystemOutput systemOutput) { // this.systemOutput = systemOutput; // } // // public boolean isPerContextPrintStream() { // return systemOutput.get() instanceof PerContextPrintStream; // } // // public void restoreOriginalPrintStream() { // final Lock writeLock = systemOutput.getLock().writeLock(); // writeLock.lock(); // try { // if (isPerContextPrintStream()) { // systemOutput.set(getPerContextPrintStream().getOriginalPrintStream()); // } // } finally { // writeLock.unlock(); // } // } // // public PrintStream getOriginalPrintStream() { // final PrintStream result; // final Lock readLock = systemOutput.getLock().readLock(); // readLock.lock(); // try { // if (isPerContextPrintStream()) { // result = getPerContextPrintStream().getOriginalPrintStream(); // } else { // result = systemOutput.get(); // } // return result; // } finally { // readLock.unlock(); // } // } // // private PerContextPrintStream getPerContextPrintStream() { // return (PerContextPrintStream) systemOutput.get(); // } // // public void deregisterPrintStreamForThisContext() { // final Lock readLock = systemOutput.getLock().readLock(); // readLock.lock(); // try { // if (isPerContextPrintStream()) { // getPerContextPrintStream().deregisterPrintStreamForThisContext(); // } // } finally { // readLock.unlock(); // } // } // // public void registerPrintStreamForThisContext(final PrintStream printStreamForThisContext) { // final Lock writeLock = systemOutput.getLock().writeLock(); // writeLock.lock(); // try { // makePerContextPrintStream(); // getPerContextPrintStream().registerPrintStreamForThisContext(printStreamForThisContext); // } finally { // writeLock.unlock(); // } // } // // private void makePerContextPrintStream() { // if (!isPerContextPrintStream()) { // systemOutput.set(buildPerContextPrintStream()); // } // } // // private PerContextPrintStream buildPerContextPrintStream() { // final PrintStream originalPrintStream = systemOutput.get(); // return new PerContextPrintStream(originalPrintStream); // } // // public static PerContextSystemOutput findByName(String name) { // for (PerContextSystemOutput systemOutput : PerContextSystemOutput.values()) { // if (systemOutput.systemOutput.getName().equalsIgnoreCase(name)) { // return systemOutput; // } // } // throw new IllegalArgumentException("No system output [" + name + "]; valid values are " + names()); // } // // private static String names() { // StringBuilder builder = new StringBuilder("["); // PerContextSystemOutput[] values = values(); // for (int i = 0; i < values.length; i++) { // builder.append(values[i].systemOutput.getName()); // if (i < values.length - 1) { // builder.append(","); // } // } // builder.append("]"); // return builder.toString(); // } // } // Path: sysout-over-slf4j-context/src/main/java/uk/org/lidalia/sysoutslf4j/context/log4j/ConsoleAppender.java import org.apache.log4j.Layout; import org.apache.log4j.WriterAppender; import org.apache.log4j.helpers.LogLog; import uk.org.lidalia.sysoutslf4j.system.PerContextSystemOutput; if (SYSTEM_OUT.equalsIgnoreCase(v)) { target = SYSTEM_OUT; } else if (SYSTEM_ERR.equalsIgnoreCase(v)) { target = SYSTEM_ERR; } else { targetWarn(value); } } /** * Returns the current value of the <b>Target</b> property. The * default value of the option is "System.out". * * See also {@link #setTarget}. * */ public String getTarget() { return target; } void targetWarn(String val) { LogLog.warn("["+val+"] should be System.out or System.err."); LogLog.warn("Using previously set target, System.out by default."); } /** * Prepares the appender for use. */ public void activateOptions() { if (target.equals(SYSTEM_ERR)) {
setWriter(createWriter(PerContextSystemOutput.ERR.getOriginalPrintStream()));
Alfresco/alfresco-sdk
archetypes/alfresco-platform-jar-archetype/src/main/resources/archetype-resources/src/test/java/platformsample/DemoComponentIT.java
// Path: modules/alfresco-rad/src/main/java/org/alfresco/rad/test/AbstractAlfrescoIT.java // public abstract class AbstractAlfrescoIT { // private ApplicationContext applicationContext = null; // private ServiceRegistry serviceRegistry = null; // // /** // * Print the test we are currently running, useful if the test is running remotely // * and we don't see the server logs // */ // @Rule // public MethodRule testAnnouncer = new MethodRule() { // @Override // public Statement apply(Statement base, FrameworkMethod method, Object target) { // System.out.println("Running " + getClassName() + " Integration Test: " + method.getName() + "()"); // return base; // } // }; // // protected String getClassName() { // Class<?> enclosingClass = getClass().getEnclosingClass(); // if (enclosingClass != null) { // return enclosingClass.getName(); // } else { // return getClass().getName(); // } // } // // protected ApplicationContext getApplicationContext() { // if (applicationContext == null) { // SpringContextHolder springContextHolder = SpringContextHolder.Instance(); // if (springContextHolder != null) { // applicationContext = springContextHolder.getApplicationContext(); // } // } // // return applicationContext; // } // // protected ServiceRegistry getServiceRegistry() { // if (serviceRegistry == null) { // ApplicationContext ctx = getApplicationContext(); // if (ctx != null) { // Object bean = ctx.getBean("ServiceRegistry"); // if (bean != null && bean instanceof ServiceRegistry) { // serviceRegistry = (ServiceRegistry) bean; // } // } // } // // return serviceRegistry; // } // }
import org.alfresco.rad.test.AbstractAlfrescoIT; import org.alfresco.rad.test.AlfrescoTestRunner; import org.alfresco.rad.test.Remote; import org.alfresco.model.ContentModel; import org.alfresco.service.cmr.repository.NodeRef; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull;
#set($symbol_pound='#') #set($symbol_dollar='$') #set($symbol_escape='\' ) /** * Copyright (C) 2017 Alfresco Software Limited. * <p/> * This file is part of the Alfresco SDK project. * <p/> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p/> * http://www.apache.org/licenses/LICENSE-2.0 * <p/> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package ${package}.platformsample; /** * Integration Test of the DemoComponent using the Alfresco Test Runner. * The Alfresco Test Runner (i.e. AlfrescoTestRunner.class) will check if it is running in an Alfresco instance, * if so it will execute normally locally. On the other hand, if it detects no * Alfresco Spring context, then it will make a call to a custom Web Script that * will execute this test in the running container remotely. The remote location is * determined by the @Remote config. * * @author martin.bergljung@alfresco.com * @since 3.0 */ @RunWith(value = AlfrescoTestRunner.class)
// Path: modules/alfresco-rad/src/main/java/org/alfresco/rad/test/AbstractAlfrescoIT.java // public abstract class AbstractAlfrescoIT { // private ApplicationContext applicationContext = null; // private ServiceRegistry serviceRegistry = null; // // /** // * Print the test we are currently running, useful if the test is running remotely // * and we don't see the server logs // */ // @Rule // public MethodRule testAnnouncer = new MethodRule() { // @Override // public Statement apply(Statement base, FrameworkMethod method, Object target) { // System.out.println("Running " + getClassName() + " Integration Test: " + method.getName() + "()"); // return base; // } // }; // // protected String getClassName() { // Class<?> enclosingClass = getClass().getEnclosingClass(); // if (enclosingClass != null) { // return enclosingClass.getName(); // } else { // return getClass().getName(); // } // } // // protected ApplicationContext getApplicationContext() { // if (applicationContext == null) { // SpringContextHolder springContextHolder = SpringContextHolder.Instance(); // if (springContextHolder != null) { // applicationContext = springContextHolder.getApplicationContext(); // } // } // // return applicationContext; // } // // protected ServiceRegistry getServiceRegistry() { // if (serviceRegistry == null) { // ApplicationContext ctx = getApplicationContext(); // if (ctx != null) { // Object bean = ctx.getBean("ServiceRegistry"); // if (bean != null && bean instanceof ServiceRegistry) { // serviceRegistry = (ServiceRegistry) bean; // } // } // } // // return serviceRegistry; // } // } // Path: archetypes/alfresco-platform-jar-archetype/src/main/resources/archetype-resources/src/test/java/platformsample/DemoComponentIT.java import org.alfresco.rad.test.AbstractAlfrescoIT; import org.alfresco.rad.test.AlfrescoTestRunner; import org.alfresco.rad.test.Remote; import org.alfresco.model.ContentModel; import org.alfresco.service.cmr.repository.NodeRef; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; #set($symbol_pound='#') #set($symbol_dollar='$') #set($symbol_escape='\' ) /** * Copyright (C) 2017 Alfresco Software Limited. * <p/> * This file is part of the Alfresco SDK project. * <p/> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p/> * http://www.apache.org/licenses/LICENSE-2.0 * <p/> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package ${package}.platformsample; /** * Integration Test of the DemoComponent using the Alfresco Test Runner. * The Alfresco Test Runner (i.e. AlfrescoTestRunner.class) will check if it is running in an Alfresco instance, * if so it will execute normally locally. On the other hand, if it detects no * Alfresco Spring context, then it will make a call to a custom Web Script that * will execute this test in the running container remotely. The remote location is * determined by the @Remote config. * * @author martin.bergljung@alfresco.com * @since 3.0 */ @RunWith(value = AlfrescoTestRunner.class)
public class DemoComponentIT extends AbstractAlfrescoIT {
Alfresco/alfresco-sdk
plugins/alfresco-maven-plugin/src/main/java/org/alfresco/maven/plugin/IntegrationTestMojo.java
// Path: plugins/alfresco-maven-plugin/src/main/java/org/alfresco/maven/plugin/config/ModuleDependency.java // public class ModuleDependency extends MavenDependency { // public static final String TYPE_JAR = "jar"; // public static final String TYPE_AMP = "amp"; // // private String type = TYPE_JAR; // // public ModuleDependency() { // super(); // } // // public ModuleDependency(String g, String a, String v, String t) { // super(g,a,v); // // this.type = t; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public boolean isAmp() { // return StringUtils.equalsIgnoreCase(this.type, TYPE_AMP); // } // // public boolean isJar() { // return StringUtils.equalsIgnoreCase(this.type, TYPE_JAR); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof ModuleDependency)) return false; // if (!super.equals(o)) return false; // // ModuleDependency that = (ModuleDependency) o; // // return !(type != null ? !type.equals(that.type) : that.type != null); // } // // @Override // public int hashCode() { // int result = super.hashCode(); // result = 31 * result + (type != null ? type.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "ModuleDependency{" + // "groupId='" + getGroupId() + '\'' + // ", artifactId='" + getArtifactId() + '\'' + // ", version='" + getVersion() + '\'' + // ", type='" + type + '\'' + // '}'; // } // }
import java.util.Properties; import static org.twdata.maven.mojoexecutor.MojoExecutor.*; import org.alfresco.maven.plugin.config.ModuleDependency; import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; import org.zeroturnaround.zip.ZipUtil; import java.io.File; import java.util.ArrayList; import java.util.List;
// skipped by the user Properties sysProperties = execEnv.getMavenSession().getSystemProperties(); boolean skipThisMojo = sysProperties.containsKey("skipTests") || sysProperties.containsKey("skipITs") || sysProperties.containsKey("maven.test.skip"); if (skipThisMojo) { getLog().info("Skipping integration testing."); return; } List<String> goals = execEnv.getMavenSession().getGoals(); if (goals.contains("alfresco:run")) { sysProperties.put("skipTests", "true"); getLog().info("Skipping integration testing as alfresco:run is active."); return; } getLog().info("Checking if Tomcat is already running on port " + ""); if ( ! tomcatIsRunning() ) { if (enableTestProperties && enablePlatform) { copyAlfrescoGlobalProperties(); } if (enablePlatform) { // Add alfresco-rad module to platform WAR // So we got access to Alfresco Test Runner in the server platformModules.add(
// Path: plugins/alfresco-maven-plugin/src/main/java/org/alfresco/maven/plugin/config/ModuleDependency.java // public class ModuleDependency extends MavenDependency { // public static final String TYPE_JAR = "jar"; // public static final String TYPE_AMP = "amp"; // // private String type = TYPE_JAR; // // public ModuleDependency() { // super(); // } // // public ModuleDependency(String g, String a, String v, String t) { // super(g,a,v); // // this.type = t; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public boolean isAmp() { // return StringUtils.equalsIgnoreCase(this.type, TYPE_AMP); // } // // public boolean isJar() { // return StringUtils.equalsIgnoreCase(this.type, TYPE_JAR); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof ModuleDependency)) return false; // if (!super.equals(o)) return false; // // ModuleDependency that = (ModuleDependency) o; // // return !(type != null ? !type.equals(that.type) : that.type != null); // } // // @Override // public int hashCode() { // int result = super.hashCode(); // result = 31 * result + (type != null ? type.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "ModuleDependency{" + // "groupId='" + getGroupId() + '\'' + // ", artifactId='" + getArtifactId() + '\'' + // ", version='" + getVersion() + '\'' + // ", type='" + type + '\'' + // '}'; // } // } // Path: plugins/alfresco-maven-plugin/src/main/java/org/alfresco/maven/plugin/IntegrationTestMojo.java import java.util.Properties; import static org.twdata.maven.mojoexecutor.MojoExecutor.*; import org.alfresco.maven.plugin.config.ModuleDependency; import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; import org.zeroturnaround.zip.ZipUtil; import java.io.File; import java.util.ArrayList; import java.util.List; // skipped by the user Properties sysProperties = execEnv.getMavenSession().getSystemProperties(); boolean skipThisMojo = sysProperties.containsKey("skipTests") || sysProperties.containsKey("skipITs") || sysProperties.containsKey("maven.test.skip"); if (skipThisMojo) { getLog().info("Skipping integration testing."); return; } List<String> goals = execEnv.getMavenSession().getGoals(); if (goals.contains("alfresco:run")) { sysProperties.put("skipTests", "true"); getLog().info("Skipping integration testing as alfresco:run is active."); return; } getLog().info("Checking if Tomcat is already running on port " + ""); if ( ! tomcatIsRunning() ) { if (enableTestProperties && enablePlatform) { copyAlfrescoGlobalProperties(); } if (enablePlatform) { // Add alfresco-rad module to platform WAR // So we got access to Alfresco Test Runner in the server platformModules.add(
new ModuleDependency(
Alfresco/alfresco-sdk
modules/alfresco-rad/src/main/java/org/alfresco/rad/test/AbstractAlfrescoIT.java
// Path: modules/alfresco-rad/src/main/java/org/alfresco/rad/SpringContextHolder.java // public class SpringContextHolder implements ApplicationContextAware { // // /** // * The instance of SpringContextHolder // */ // private static SpringContextHolder springContextHolderInstance; // // /** // * The Alfresco Spring Application Context. // */ // private ApplicationContext applicationContext; // // /** // * Default constructor. // */ // public SpringContextHolder() { // //System.out.println("Initializing the SpringContextHolder class."); // springContextHolderInstance = this; // } // // /** // * Return the singleton instance // * // * @return the singleton instance // */ // public static SpringContextHolder Instance() { // return springContextHolderInstance; // } // // public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { // this.applicationContext = applicationContext; // } // // public ApplicationContext getApplicationContext() { // return applicationContext; // } // // }
import org.alfresco.rad.SpringContextHolder; import org.alfresco.service.ServiceRegistry; import org.junit.Rule; import org.junit.rules.MethodRule; import org.junit.runners.model.FrameworkMethod; import org.junit.runners.model.Statement; import org.springframework.context.ApplicationContext;
/** * Copyright (C) 2017 Alfresco Software Limited. * <p/> * This file is part of the Alfresco SDK project. * <p/> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p/> * http://www.apache.org/licenses/LICENSE-2.0 * <p/> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.alfresco.rad.test; /** * Abstract Integration Test class to be used * by Alfresco Integration Tests. Gives access to * Alfresco Spring Application context and the * {@link ServiceRegistry} that should be used when * accessing Alfresco Services. * * @author martin.bergljung@alfresco.com * @since 3.0 */ public abstract class AbstractAlfrescoIT { private ApplicationContext applicationContext = null; private ServiceRegistry serviceRegistry = null; /** * Print the test we are currently running, useful if the test is running remotely * and we don't see the server logs */ @Rule public MethodRule testAnnouncer = new MethodRule() { @Override public Statement apply(Statement base, FrameworkMethod method, Object target) { System.out.println("Running " + getClassName() + " Integration Test: " + method.getName() + "()"); return base; } }; protected String getClassName() { Class<?> enclosingClass = getClass().getEnclosingClass(); if (enclosingClass != null) { return enclosingClass.getName(); } else { return getClass().getName(); } } protected ApplicationContext getApplicationContext() { if (applicationContext == null) {
// Path: modules/alfresco-rad/src/main/java/org/alfresco/rad/SpringContextHolder.java // public class SpringContextHolder implements ApplicationContextAware { // // /** // * The instance of SpringContextHolder // */ // private static SpringContextHolder springContextHolderInstance; // // /** // * The Alfresco Spring Application Context. // */ // private ApplicationContext applicationContext; // // /** // * Default constructor. // */ // public SpringContextHolder() { // //System.out.println("Initializing the SpringContextHolder class."); // springContextHolderInstance = this; // } // // /** // * Return the singleton instance // * // * @return the singleton instance // */ // public static SpringContextHolder Instance() { // return springContextHolderInstance; // } // // public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { // this.applicationContext = applicationContext; // } // // public ApplicationContext getApplicationContext() { // return applicationContext; // } // // } // Path: modules/alfresco-rad/src/main/java/org/alfresco/rad/test/AbstractAlfrescoIT.java import org.alfresco.rad.SpringContextHolder; import org.alfresco.service.ServiceRegistry; import org.junit.Rule; import org.junit.rules.MethodRule; import org.junit.runners.model.FrameworkMethod; import org.junit.runners.model.Statement; import org.springframework.context.ApplicationContext; /** * Copyright (C) 2017 Alfresco Software Limited. * <p/> * This file is part of the Alfresco SDK project. * <p/> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p/> * http://www.apache.org/licenses/LICENSE-2.0 * <p/> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.alfresco.rad.test; /** * Abstract Integration Test class to be used * by Alfresco Integration Tests. Gives access to * Alfresco Spring Application context and the * {@link ServiceRegistry} that should be used when * accessing Alfresco Services. * * @author martin.bergljung@alfresco.com * @since 3.0 */ public abstract class AbstractAlfrescoIT { private ApplicationContext applicationContext = null; private ServiceRegistry serviceRegistry = null; /** * Print the test we are currently running, useful if the test is running remotely * and we don't see the server logs */ @Rule public MethodRule testAnnouncer = new MethodRule() { @Override public Statement apply(Statement base, FrameworkMethod method, Object target) { System.out.println("Running " + getClassName() + " Integration Test: " + method.getName() + "()"); return base; } }; protected String getClassName() { Class<?> enclosingClass = getClass().getEnclosingClass(); if (enclosingClass != null) { return enclosingClass.getName(); } else { return getClass().getName(); } } protected ApplicationContext getApplicationContext() { if (applicationContext == null) {
SpringContextHolder springContextHolder = SpringContextHolder.Instance();
w3c/epubcheck
src/main/java/com/adobe/epubcheck/util/WriterReportImpl.java
// Path: src/main/java/com/adobe/epubcheck/api/EPUBLocation.java // public final class EPUBLocation implements Comparable<EPUBLocation> // { // // public static EPUBLocation create(String fileName) // { // return new EPUBLocation(fileName, -1, -1, null); // } // // public static EPUBLocation create(String fileName, String context) // { // return new EPUBLocation(fileName, -1, -1, context); // } // // public static EPUBLocation create(String fileName, int lineNumber, int column) // { // return new EPUBLocation(fileName, lineNumber, column, null); // } // // public static EPUBLocation create(String fileName, int lineNumber, int column, String context) // { // return new EPUBLocation(fileName, lineNumber, column, context); // } // // @JsonProperty // private final String path; // @JsonProperty // private final int line; // @JsonProperty // private final int column; // @JsonProperty // @JsonSerialize(using = JsonWriter.OptionalJsonSerializer.class) // private final Optional<String> context; // // private EPUBLocation(String path, int lineNumber, int column, String context) // { // Preconditions.checkNotNull(path); // this.path = path; // this.line = lineNumber; // this.column = column; // this.context = Optional.fromNullable(context); // } // // public String getPath() // { // return this.path; // } // // public int getLine() // { // return this.line; // } // // public int getColumn() // { // return this.column; // } // // public Optional<String> getContext() // { // return this.context; // } // // // // @Override // public String toString() // { // return path + "[" + line + "," + column + "]"; // } // // @Override // public boolean equals(Object obj) // { // if (obj == this) // { // return true; // } // if (obj == null || obj.getClass() != this.getClass()) // { // return false; // } // // EPUBLocation other = (EPUBLocation) obj; // return !(this.getContext() == null && other.getContext() != null) // && this.getPath().equals(other.getPath()) && this.getLine() == other.getLine() // && this.getColumn() == other.getColumn() // && (this.getContext() == null || this.getContext().equals(other.getContext())); // } // // int safeCompare(String a, String b) // { // if (a == null && b != null) return -1; // if (a != null && b == null) return 1; // if (a == null /* && b == null */) return 0; // return a.compareTo(b); // } // // @Override // public int compareTo(EPUBLocation o) // { // int comp = safeCompare(this.path, o.path); // if (comp != 0) // { // return comp; // } // // comp = line - o.line; // if (comp != 0) // { // return comp < 0 ? -1 : 1; // } // // comp = column - o.column; // if (comp != 0) // { // return comp < 0 ? -1 : 1; // } // comp = safeCompare(context.orNull(), o.context.orNull()); // if (comp != 0) // { // return comp; // } // // return 0; // } // }
import com.adobe.epubcheck.api.MasterReport; import com.adobe.epubcheck.api.EPUBLocation; import com.adobe.epubcheck.messages.Message; import com.adobe.epubcheck.messages.Severity; import java.io.PrintWriter;
/* * Copyright (c) 2007 Adobe Systems Incorporated * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package com.adobe.epubcheck.util; public class WriterReportImpl extends MasterReport { static boolean DEBUG = false; boolean quiet; final PrintWriter out; public WriterReportImpl(PrintWriter out) { this(out, "", false); } public WriterReportImpl(PrintWriter out, String info) { this(out, info, false); } public WriterReportImpl(PrintWriter out, String info, boolean quiet) { this.out = out; warning("", 0, 0, info); this.quiet = quiet; } String fixMessage(String message) { if (message == null) return ""; return message.replaceAll("[\\s]+", " "); } @Override
// Path: src/main/java/com/adobe/epubcheck/api/EPUBLocation.java // public final class EPUBLocation implements Comparable<EPUBLocation> // { // // public static EPUBLocation create(String fileName) // { // return new EPUBLocation(fileName, -1, -1, null); // } // // public static EPUBLocation create(String fileName, String context) // { // return new EPUBLocation(fileName, -1, -1, context); // } // // public static EPUBLocation create(String fileName, int lineNumber, int column) // { // return new EPUBLocation(fileName, lineNumber, column, null); // } // // public static EPUBLocation create(String fileName, int lineNumber, int column, String context) // { // return new EPUBLocation(fileName, lineNumber, column, context); // } // // @JsonProperty // private final String path; // @JsonProperty // private final int line; // @JsonProperty // private final int column; // @JsonProperty // @JsonSerialize(using = JsonWriter.OptionalJsonSerializer.class) // private final Optional<String> context; // // private EPUBLocation(String path, int lineNumber, int column, String context) // { // Preconditions.checkNotNull(path); // this.path = path; // this.line = lineNumber; // this.column = column; // this.context = Optional.fromNullable(context); // } // // public String getPath() // { // return this.path; // } // // public int getLine() // { // return this.line; // } // // public int getColumn() // { // return this.column; // } // // public Optional<String> getContext() // { // return this.context; // } // // // // @Override // public String toString() // { // return path + "[" + line + "," + column + "]"; // } // // @Override // public boolean equals(Object obj) // { // if (obj == this) // { // return true; // } // if (obj == null || obj.getClass() != this.getClass()) // { // return false; // } // // EPUBLocation other = (EPUBLocation) obj; // return !(this.getContext() == null && other.getContext() != null) // && this.getPath().equals(other.getPath()) && this.getLine() == other.getLine() // && this.getColumn() == other.getColumn() // && (this.getContext() == null || this.getContext().equals(other.getContext())); // } // // int safeCompare(String a, String b) // { // if (a == null && b != null) return -1; // if (a != null && b == null) return 1; // if (a == null /* && b == null */) return 0; // return a.compareTo(b); // } // // @Override // public int compareTo(EPUBLocation o) // { // int comp = safeCompare(this.path, o.path); // if (comp != 0) // { // return comp; // } // // comp = line - o.line; // if (comp != 0) // { // return comp < 0 ? -1 : 1; // } // // comp = column - o.column; // if (comp != 0) // { // return comp < 0 ? -1 : 1; // } // comp = safeCompare(context.orNull(), o.context.orNull()); // if (comp != 0) // { // return comp; // } // // return 0; // } // } // Path: src/main/java/com/adobe/epubcheck/util/WriterReportImpl.java import com.adobe.epubcheck.api.MasterReport; import com.adobe.epubcheck.api.EPUBLocation; import com.adobe.epubcheck.messages.Message; import com.adobe.epubcheck.messages.Severity; import java.io.PrintWriter; /* * Copyright (c) 2007 Adobe Systems Incorporated * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package com.adobe.epubcheck.util; public class WriterReportImpl extends MasterReport { static boolean DEBUG = false; boolean quiet; final PrintWriter out; public WriterReportImpl(PrintWriter out) { this(out, "", false); } public WriterReportImpl(PrintWriter out, String info) { this(out, info, false); } public WriterReportImpl(PrintWriter out, String info, boolean quiet) { this.out = out; warning("", 0, 0, info); this.quiet = quiet; } String fixMessage(String message) { if (message == null) return ""; return message.replaceAll("[\\s]+", " "); } @Override
public void message(Message message, EPUBLocation location, Object... args)
w3c/epubcheck
src/main/java/com/adobe/epubcheck/ctc/epubpackage/EpubPackage.java
// Path: src/main/java/com/adobe/epubcheck/util/PathUtil.java // public class PathUtil // { // // private static final Pattern REGEX_URI_SCHEME = Pattern // .compile("^\\p{Alpha}(\\p{Alnum}|\\.|\\+|-)*:"); // private static final Pattern REGEX_URI = Pattern // .compile("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?"); // private static final Pattern REGEX_URI_FRAGMENT = Pattern.compile("#"); // private static final Pattern REGEX_REMOTE_URI = Pattern.compile("^[^:/?#]+://.*"); // // public static boolean isRemote(String path) // { // return REGEX_REMOTE_URI.matcher(Preconditions.checkNotNull(path)).matches(); // } // // public static String resolveRelativeReference(String base, String ref) // throws IllegalArgumentException // { // Preconditions.checkNotNull(ref); // // // If we can find a URI scheme, return ref // if (REGEX_URI_SCHEME.matcher(ref).lookingAt()) // { // return ref; // } // if (base == null) // { // return normalizePath(ref); // } // // try // { // ref = URLDecoder.decode(ref.replace("+", "%2B"), "UTF-8"); // } catch (UnsupportedEncodingException e) // { // // UTF-8 is guaranteed to be supported // throw new InternalError(e.toString()); // } // // // Normalize base // base = normalizePath(REGEX_URI_FRAGMENT.split(base)[0]); // // if (ref.startsWith("#")) // { // ref = base + normalizePath(ref); // } // else // { // ref = base.substring(0, base.lastIndexOf("/") + 1) + normalizePath(ref); // } // return normalizePath(ref); // } // // public static String normalizePath(String path) // throws IllegalArgumentException // { // Preconditions.checkNotNull(path); // // if (path.startsWith("data:")) // { // return path; // } // // Matcher matcher = REGEX_URI.matcher(path); // String prepath = ""; // String postpath = ""; // if (matcher.matches()) // { // prepath = ((matcher.group(1) != null) ? matcher.group(1) : "") // + ((matcher.group(3) != null) ? matcher.group(3) : ""); // path = matcher.group(5); // postpath = ((matcher.group(6) != null) ? matcher.group(6) : "") // + ((matcher.group(8) != null) ? matcher.group(8) : ""); // } // // Stack<String> segments = new Stack<String>(); // Iterator<String> tokenized = Splitter.on('/').trimResults().split(path).iterator(); // while (tokenized.hasNext()) // { // String segment = (String) tokenized.next(); // switch (segment) // { // case ".": // if (!tokenized.hasNext()) segments.push(""); // break; // case "": // if (segments.empty() || !tokenized.hasNext()) segments.push(""); // break; // case "..": // if (segments.size() > 0 && !"..".equals(segments.peek()) && !"".equals(segments.peek())) // { // segments.pop(); // } // else // { // segments.push(segment); // } // if (!tokenized.hasNext()) segments.push(""); // break; // default: // segments.push(segment); // break; // } // } // return prepath + Joiner.on('/').join(segments) + postpath; // } // // public static String removeWorkingDirectory(String path) // { // if (path == null || path.length() == 0) // { // return path; // } // String workingDirectory = System.getProperty("user.dir"); // if ("/".equals(workingDirectory) || !path.startsWith(workingDirectory)) { // return path; // } // return ".".concat(path.substring(workingDirectory.length())); // } // // public static String getFragment(String uri) // { // int hash = Preconditions.checkNotNull(uri).indexOf("#") + 1; // return (hash > 0) ? Strings.emptyToNull(uri.substring(hash)) : null; // } // // public static String removeFragment(String uri) // { // int hash = Preconditions.checkNotNull(uri).indexOf("#"); // return (hash > -1) ? uri.substring(0, hash) : uri; // } // }
import com.adobe.epubcheck.util.EPUBVersion; import com.adobe.epubcheck.util.PathUtil; import org.w3c.dom.Document; import java.io.File; import java.util.zip.ZipFile;
else if ("meta".equals(me.getName())) { String property = me.getAttribute("property"); if ("rendition:layout".equals(property)) { return ("pre-paginated".equals(me.getValue())); } } } return false; } public String getManifestItemFileName(ManifestItem mi) { if (mi != null) { return getManifestItemFileName(mi.getHref()); } return ""; } public String getManifestItemFileName(String entryName) { if (entryName == null) return ""; String fileToParse; if (this.getPackageMainPath() != null && this.getPackageMainPath().length() > 0) {
// Path: src/main/java/com/adobe/epubcheck/util/PathUtil.java // public class PathUtil // { // // private static final Pattern REGEX_URI_SCHEME = Pattern // .compile("^\\p{Alpha}(\\p{Alnum}|\\.|\\+|-)*:"); // private static final Pattern REGEX_URI = Pattern // .compile("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?"); // private static final Pattern REGEX_URI_FRAGMENT = Pattern.compile("#"); // private static final Pattern REGEX_REMOTE_URI = Pattern.compile("^[^:/?#]+://.*"); // // public static boolean isRemote(String path) // { // return REGEX_REMOTE_URI.matcher(Preconditions.checkNotNull(path)).matches(); // } // // public static String resolveRelativeReference(String base, String ref) // throws IllegalArgumentException // { // Preconditions.checkNotNull(ref); // // // If we can find a URI scheme, return ref // if (REGEX_URI_SCHEME.matcher(ref).lookingAt()) // { // return ref; // } // if (base == null) // { // return normalizePath(ref); // } // // try // { // ref = URLDecoder.decode(ref.replace("+", "%2B"), "UTF-8"); // } catch (UnsupportedEncodingException e) // { // // UTF-8 is guaranteed to be supported // throw new InternalError(e.toString()); // } // // // Normalize base // base = normalizePath(REGEX_URI_FRAGMENT.split(base)[0]); // // if (ref.startsWith("#")) // { // ref = base + normalizePath(ref); // } // else // { // ref = base.substring(0, base.lastIndexOf("/") + 1) + normalizePath(ref); // } // return normalizePath(ref); // } // // public static String normalizePath(String path) // throws IllegalArgumentException // { // Preconditions.checkNotNull(path); // // if (path.startsWith("data:")) // { // return path; // } // // Matcher matcher = REGEX_URI.matcher(path); // String prepath = ""; // String postpath = ""; // if (matcher.matches()) // { // prepath = ((matcher.group(1) != null) ? matcher.group(1) : "") // + ((matcher.group(3) != null) ? matcher.group(3) : ""); // path = matcher.group(5); // postpath = ((matcher.group(6) != null) ? matcher.group(6) : "") // + ((matcher.group(8) != null) ? matcher.group(8) : ""); // } // // Stack<String> segments = new Stack<String>(); // Iterator<String> tokenized = Splitter.on('/').trimResults().split(path).iterator(); // while (tokenized.hasNext()) // { // String segment = (String) tokenized.next(); // switch (segment) // { // case ".": // if (!tokenized.hasNext()) segments.push(""); // break; // case "": // if (segments.empty() || !tokenized.hasNext()) segments.push(""); // break; // case "..": // if (segments.size() > 0 && !"..".equals(segments.peek()) && !"".equals(segments.peek())) // { // segments.pop(); // } // else // { // segments.push(segment); // } // if (!tokenized.hasNext()) segments.push(""); // break; // default: // segments.push(segment); // break; // } // } // return prepath + Joiner.on('/').join(segments) + postpath; // } // // public static String removeWorkingDirectory(String path) // { // if (path == null || path.length() == 0) // { // return path; // } // String workingDirectory = System.getProperty("user.dir"); // if ("/".equals(workingDirectory) || !path.startsWith(workingDirectory)) { // return path; // } // return ".".concat(path.substring(workingDirectory.length())); // } // // public static String getFragment(String uri) // { // int hash = Preconditions.checkNotNull(uri).indexOf("#") + 1; // return (hash > 0) ? Strings.emptyToNull(uri.substring(hash)) : null; // } // // public static String removeFragment(String uri) // { // int hash = Preconditions.checkNotNull(uri).indexOf("#"); // return (hash > -1) ? uri.substring(0, hash) : uri; // } // } // Path: src/main/java/com/adobe/epubcheck/ctc/epubpackage/EpubPackage.java import com.adobe.epubcheck.util.EPUBVersion; import com.adobe.epubcheck.util.PathUtil; import org.w3c.dom.Document; import java.io.File; import java.util.zip.ZipFile; else if ("meta".equals(me.getName())) { String property = me.getAttribute("property"); if ("rendition:layout".equals(property)) { return ("pre-paginated".equals(me.getValue())); } } } return false; } public String getManifestItemFileName(ManifestItem mi) { if (mi != null) { return getManifestItemFileName(mi.getHref()); } return ""; } public String getManifestItemFileName(String entryName) { if (entryName == null) return ""; String fileToParse; if (this.getPackageMainPath() != null && this.getPackageMainPath().length() > 0) {
fileToParse = PathUtil.resolveRelativeReference(this.getPackageMainFile(), entryName);
w3c/epubcheck
src/main/java/com/adobe/epubcheck/messages/OverriddenMessageDictionary.java
// Path: src/main/java/com/adobe/epubcheck/api/Report.java // public interface Report // { // /** // * Called when a violation of the standard is found in epub. // * // * @param id Id of the message being reported // * @param location location information for the message // * @param args Arguments referenced by the format // * string for the message. // */ // public void message(MessageId id, EPUBLocation location, Object... args); // // /** // * Called when a violation of the standard is found in epub. // * // * @param message The message being reported // * @param location location information for the message // * @param args Arguments referenced by the format // * string for the message. // */ // void message(Message message, EPUBLocation location, Object... args); // // /** // * Called when when a feature is found in epub. // * // * @param resource name of the resource in the epub zip container that has this feature // * or null if the feature is on the container level. // * @param feature a keyword to know what kind of feature has been found // * @param value value found // */ // public void info(String resource, FeatureEnum feature, String value); // // public int getErrorCount(); // // public int getWarningCount(); // // public int getFatalErrorCount(); // // public int getInfoCount(); // // public int getUsageCount(); // // /** // * Called to create a report after the checks have been made // */ // public int generate(); // // /** // * Called when a report if first created // */ // public void initialize(); // // public void setEpubFileName(String value); // // public String getEpubFileName(); // // void setCustomMessageFile(String customMessageFileName); // // String getCustomMessageFile(); // // public int getReportingLevel(); // // public void setReportingLevel(int level); // // void close(); // // void setOverrideFile(File customMessageFile); // // MessageDictionary getDictionary(); // }
import com.adobe.epubcheck.api.Report; import java.io.File;
package com.adobe.epubcheck.messages; /** * Maps a message to a severity using overrides provided in a file. Falls back * to default messages and severities when an override isn't available. */ public class OverriddenMessageDictionary implements MessageDictionary { private final OverriddenMessages messages;
// Path: src/main/java/com/adobe/epubcheck/api/Report.java // public interface Report // { // /** // * Called when a violation of the standard is found in epub. // * // * @param id Id of the message being reported // * @param location location information for the message // * @param args Arguments referenced by the format // * string for the message. // */ // public void message(MessageId id, EPUBLocation location, Object... args); // // /** // * Called when a violation of the standard is found in epub. // * // * @param message The message being reported // * @param location location information for the message // * @param args Arguments referenced by the format // * string for the message. // */ // void message(Message message, EPUBLocation location, Object... args); // // /** // * Called when when a feature is found in epub. // * // * @param resource name of the resource in the epub zip container that has this feature // * or null if the feature is on the container level. // * @param feature a keyword to know what kind of feature has been found // * @param value value found // */ // public void info(String resource, FeatureEnum feature, String value); // // public int getErrorCount(); // // public int getWarningCount(); // // public int getFatalErrorCount(); // // public int getInfoCount(); // // public int getUsageCount(); // // /** // * Called to create a report after the checks have been made // */ // public int generate(); // // /** // * Called when a report if first created // */ // public void initialize(); // // public void setEpubFileName(String value); // // public String getEpubFileName(); // // void setCustomMessageFile(String customMessageFileName); // // String getCustomMessageFile(); // // public int getReportingLevel(); // // public void setReportingLevel(int level); // // void close(); // // void setOverrideFile(File customMessageFile); // // MessageDictionary getDictionary(); // } // Path: src/main/java/com/adobe/epubcheck/messages/OverriddenMessageDictionary.java import com.adobe.epubcheck.api.Report; import java.io.File; package com.adobe.epubcheck.messages; /** * Maps a message to a severity using overrides provided in a file. Falls back * to default messages and severities when an override isn't available. */ public class OverriddenMessageDictionary implements MessageDictionary { private final OverriddenMessages messages;
public OverriddenMessageDictionary(File overrideFile, Report report )
w3c/epubcheck
src/main/java/com/adobe/epubcheck/opf/OPFItems.java
// Path: src/main/java/com/adobe/epubcheck/opf/OPFItem.java // public static final class Builder // { // // private String id; // private String path; // private String mimeType; // private int lineNumber; // private int columnNumber; // private String fallback = null; // private String fallbackStyle = null; // private boolean ncx = false; // private boolean linear = true; // private int spinePosition = -1; // private boolean fxl = false; // private String mediaOverlay; // private ImmutableSet.Builder<Property> propertiesBuilder = new ImmutableSet.Builder<Property>(); // // /** // * Creates a new builder // * // * @param id // * the item ID, can be <code>null</code> // * @param path // * the item path,, cannot be <code>null</code> // * @param mimeType // * the item media type, can be <code>null</code> // * @param lineNumber // * the line number of the corresponding <code>item</code> or // * <code>link</code> element // * @param columnNumber // * the column number of the corresponding <code>item</code> or // * <code>link</code> element // */ // public Builder(String id, String path, String mimeType, int lineNumber, int columnNumber) // { // this.id = Preconditions.checkNotNull(id).trim(); // this.path = Preconditions.checkNotNull(path).trim(); // this.mimeType = Optional.fromNullable(mimeType).or("undefined").trim(); // this.lineNumber = lineNumber; // this.columnNumber = columnNumber; // } // // public Builder fallback(String fallback) // { // this.fallback = fallback; // return this; // } // // public Builder fallbackStyle(String fallbackStyle) // { // this.fallbackStyle = fallbackStyle; // return this; // } // // public Builder fixedLayout() // { // this.fxl = true; // return this; // // } // // public Builder mediaOverlay(String path) // { // this.mediaOverlay = path; // return this; // } // // public Builder ncx() // { // this.ncx = true; // return this; // } // // public Builder nonlinear() // { // this.linear = false; // return this; // } // // public Builder inSpine(int position) // { // this.spinePosition = Preconditions.checkNotNull(position); // return this; // } // // public Builder properties(Set<Property> properties) // { // if (properties != null) // { // this.propertiesBuilder.addAll(properties); // } // return this; // } // // /** // * Builds a new immutable {@link OPFItem} from this builder. // */ // public OPFItem build() // { // if (spinePosition < 0 || !linear) // { // this.propertiesBuilder.add(EpubCheckVocab.VOCAB.get(EpubCheckVocab.PROPERTIES.NON_LINEAR)); // } // if (fxl) // { // this.propertiesBuilder // .add(EpubCheckVocab.VOCAB.get(EpubCheckVocab.PROPERTIES.FIXED_LAYOUT)); // } // Set<Property> properties = propertiesBuilder.build(); // // return new OPFItem(id, path, mimeType, lineNumber, columnNumber, // Optional.fromNullable(Strings.emptyToNull(Strings.nullToEmpty(fallback).trim())), // Optional.fromNullable(Strings.emptyToNull(Strings.nullToEmpty(fallbackStyle).trim())), // properties, ncx, spinePosition, // properties.contains(PackageVocabs.ITEM_VOCAB.get(PackageVocabs.ITEM_PROPERTIES.NAV)), // properties.contains(PackageVocabs.ITEM_VOCAB.get(PackageVocabs.ITEM_PROPERTIES.SCRIPTED)), // linear, fxl, mediaOverlay); // } // }
import java.util.List; import java.util.Map; import com.adobe.epubcheck.opf.OPFItem.Builder; import com.google.common.base.Function; import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.base.Predicates; import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Maps;
Map<String, OPFItem> itemsById = Maps.newHashMap(); Map<String, OPFItem> itemsByPath = Maps.newHashMap(); for (OPFItem item : this.items) { itemsById.put(item.getId(), item); itemsByPath.put(item.getPath(), item); } this.itemsById = ImmutableMap.copyOf(itemsById); this.itemsByPath = ImmutableMap.copyOf(itemsByPath); // Build the spine view this.spine = FluentIterable.from(spineIDs).transform(new Function<String, OPFItem>() { @Override public OPFItem apply(final String id) { return OPFItems.this.itemsById.get(id.trim()); } }).filter(Predicates.notNull()).toList(); } /** * Creates a consolidated set of {@link OPFItem} from item builders and a list * of spine item IDs. * * @param itemBuilders * the builders of the {@link OPFItem} in the set. * @param spineIDs * the IDs of the items in the spine. * @return a consolidated set of {@link OPFItem}s. */
// Path: src/main/java/com/adobe/epubcheck/opf/OPFItem.java // public static final class Builder // { // // private String id; // private String path; // private String mimeType; // private int lineNumber; // private int columnNumber; // private String fallback = null; // private String fallbackStyle = null; // private boolean ncx = false; // private boolean linear = true; // private int spinePosition = -1; // private boolean fxl = false; // private String mediaOverlay; // private ImmutableSet.Builder<Property> propertiesBuilder = new ImmutableSet.Builder<Property>(); // // /** // * Creates a new builder // * // * @param id // * the item ID, can be <code>null</code> // * @param path // * the item path,, cannot be <code>null</code> // * @param mimeType // * the item media type, can be <code>null</code> // * @param lineNumber // * the line number of the corresponding <code>item</code> or // * <code>link</code> element // * @param columnNumber // * the column number of the corresponding <code>item</code> or // * <code>link</code> element // */ // public Builder(String id, String path, String mimeType, int lineNumber, int columnNumber) // { // this.id = Preconditions.checkNotNull(id).trim(); // this.path = Preconditions.checkNotNull(path).trim(); // this.mimeType = Optional.fromNullable(mimeType).or("undefined").trim(); // this.lineNumber = lineNumber; // this.columnNumber = columnNumber; // } // // public Builder fallback(String fallback) // { // this.fallback = fallback; // return this; // } // // public Builder fallbackStyle(String fallbackStyle) // { // this.fallbackStyle = fallbackStyle; // return this; // } // // public Builder fixedLayout() // { // this.fxl = true; // return this; // // } // // public Builder mediaOverlay(String path) // { // this.mediaOverlay = path; // return this; // } // // public Builder ncx() // { // this.ncx = true; // return this; // } // // public Builder nonlinear() // { // this.linear = false; // return this; // } // // public Builder inSpine(int position) // { // this.spinePosition = Preconditions.checkNotNull(position); // return this; // } // // public Builder properties(Set<Property> properties) // { // if (properties != null) // { // this.propertiesBuilder.addAll(properties); // } // return this; // } // // /** // * Builds a new immutable {@link OPFItem} from this builder. // */ // public OPFItem build() // { // if (spinePosition < 0 || !linear) // { // this.propertiesBuilder.add(EpubCheckVocab.VOCAB.get(EpubCheckVocab.PROPERTIES.NON_LINEAR)); // } // if (fxl) // { // this.propertiesBuilder // .add(EpubCheckVocab.VOCAB.get(EpubCheckVocab.PROPERTIES.FIXED_LAYOUT)); // } // Set<Property> properties = propertiesBuilder.build(); // // return new OPFItem(id, path, mimeType, lineNumber, columnNumber, // Optional.fromNullable(Strings.emptyToNull(Strings.nullToEmpty(fallback).trim())), // Optional.fromNullable(Strings.emptyToNull(Strings.nullToEmpty(fallbackStyle).trim())), // properties, ncx, spinePosition, // properties.contains(PackageVocabs.ITEM_VOCAB.get(PackageVocabs.ITEM_PROPERTIES.NAV)), // properties.contains(PackageVocabs.ITEM_VOCAB.get(PackageVocabs.ITEM_PROPERTIES.SCRIPTED)), // linear, fxl, mediaOverlay); // } // } // Path: src/main/java/com/adobe/epubcheck/opf/OPFItems.java import java.util.List; import java.util.Map; import com.adobe.epubcheck.opf.OPFItem.Builder; import com.google.common.base.Function; import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.base.Predicates; import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; Map<String, OPFItem> itemsById = Maps.newHashMap(); Map<String, OPFItem> itemsByPath = Maps.newHashMap(); for (OPFItem item : this.items) { itemsById.put(item.getId(), item); itemsByPath.put(item.getPath(), item); } this.itemsById = ImmutableMap.copyOf(itemsById); this.itemsByPath = ImmutableMap.copyOf(itemsByPath); // Build the spine view this.spine = FluentIterable.from(spineIDs).transform(new Function<String, OPFItem>() { @Override public OPFItem apply(final String id) { return OPFItems.this.itemsById.get(id.trim()); } }).filter(Predicates.notNull()).toList(); } /** * Creates a consolidated set of {@link OPFItem} from item builders and a list * of spine item IDs. * * @param itemBuilders * the builders of the {@link OPFItem} in the set. * @param spineIDs * the IDs of the items in the spine. * @return a consolidated set of {@link OPFItem}s. */
public static OPFItems build(Iterable<Builder> itemBuilders, Iterable<String> spineIDs)
w3c/epubcheck
src/main/java/org/idpf/epubcheck/util/css/CssScanner.java
// Path: src/main/java/org/idpf/epubcheck/util/css/CssExceptions.java // public enum CssErrorCode // { // SCANNER_ILLEGAL_SYNTAX(SCANNER_TOKEN_SYNTAX), //a general error code, below refines // SCANNER_ILLEGAL_CHAR(SCANNER_TOKEN_SYNTAX + ".char"), // SCANNER_ILLEGAL_FIRSTCHAR(SCANNER_TOKEN_SYNTAX + ".firstChar"), // SCANNER_MALFORMED_ESCAPE(SCANNER_TOKEN_SYNTAX + ".escape"), // SCANNER_ILLEGAL_URANGE(SCANNER_TOKEN_SYNTAX + ".urange"), // SCANNER_PREMATURE_EOF(SCANNER + ".prematureEOF"), // // GRAMMAR_PREMATURE_EOF(GRAMMAR + ".prematureEOF"), // GRAMMAR_UNEXPECTED_TOKEN(GRAMMAR_TOKEN + ".unexpected"), // GRAMMAR_EXPECTING_TOKEN(GRAMMAR_TOKEN + ".expecting"), // GRAMMAR_INVALID_SELECTOR(GRAMMAR + ".invalidSelector"),; // // final String value; // // CssErrorCode(String value) // { // this.value = value; // } // // @Override // public String toString() // { // return MoreObjects.toStringHelper(this.getClass()).addValue(value).toString(); // } // // } // // Path: src/main/java/org/idpf/epubcheck/util/css/CssExceptions.java // public static abstract class CssException extends Exception // { // final CssErrorCode errorCode; // final CssLocation location; // final Optional<CssToken> token; // // CssException(final CssToken token, final CssErrorCode errorCode, final CssLocation location, // final Locale locale, final Object... arguments) // { // super(Messages.getInstance(locale, CssExceptions.class).get(errorCode.value, arguments)); // this.errorCode = checkNotNull(errorCode); // this.location = checkNotNull(location); // this.token = token == null ? absent : Optional.of(token); // } // // CssException(final CssErrorCode errorCode, final CssLocation location, final Locale locale, // final Object... arguments) // { // this(null, errorCode, location, locale, arguments); // } // // public CssErrorCode getErrorCode() // { // return errorCode; // } // // public CssLocation getLocation() // { // return location; // } // // @Override // public String toString() // { // return MoreObjects.toStringHelper(this.getClass()).add("errorCode", errorCode) // .add("location", location.toString()).toString(); // } // // @Override // public boolean equals(Object obj) // { // if (obj instanceof CssException) // { // CssException exc = (CssException) obj; // if (exc.errorCode.equals(this.errorCode) && exc.location.equals(this.location)) // { // return true; // } // } // return false; // } // // private static final long serialVersionUID = -4635263495562931206L; // }
import com.google.common.base.Ascii; import com.google.common.base.CharMatcher; import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.primitives.Ints; import org.idpf.epubcheck.util.css.CssExceptions.CssErrorCode; import org.idpf.epubcheck.util.css.CssExceptions.CssException; import org.idpf.epubcheck.util.css.CssReader.Mark; import org.idpf.epubcheck.util.css.CssToken.CssTokenConsumer; import org.idpf.epubcheck.util.css.CssToken.TokenBuilder; import org.idpf.epubcheck.util.css.CssToken.Type; import java.io.IOException; import java.io.Reader; import java.util.List; import java.util.Locale; import java.util.Map; import static com.google.common.base.Preconditions.*; import static org.idpf.epubcheck.util.css.CssExceptions.CssErrorCode.SCANNER_ILLEGAL_CHAR; import static org.idpf.epubcheck.util.css.CssExceptions.CssErrorCode.SCANNER_PREMATURE_EOF;
// unquoted uri builder.append(uristart); if (debug) { checkArgument(NOT_WHITESPACE.matches((char) reader.curChar)); } StringBuilder buf = new StringBuilder(); while (true) { CssReader.Mark mark = reader.mark(); int ch = reader.next(); if (ch == -1) { builder.error(SCANNER_PREMATURE_EOF, reader); reader.unread(ch, mark); break; } else if (ch == ')') { break; } buf.append((char) ch); } builder.append(WHITESPACE.trimTrailingFrom(buf.toString())); } builder.append(')'); builder.type = Type.URI; if (')' != reader.curChar && builder.errors.size() == 0) {
// Path: src/main/java/org/idpf/epubcheck/util/css/CssExceptions.java // public enum CssErrorCode // { // SCANNER_ILLEGAL_SYNTAX(SCANNER_TOKEN_SYNTAX), //a general error code, below refines // SCANNER_ILLEGAL_CHAR(SCANNER_TOKEN_SYNTAX + ".char"), // SCANNER_ILLEGAL_FIRSTCHAR(SCANNER_TOKEN_SYNTAX + ".firstChar"), // SCANNER_MALFORMED_ESCAPE(SCANNER_TOKEN_SYNTAX + ".escape"), // SCANNER_ILLEGAL_URANGE(SCANNER_TOKEN_SYNTAX + ".urange"), // SCANNER_PREMATURE_EOF(SCANNER + ".prematureEOF"), // // GRAMMAR_PREMATURE_EOF(GRAMMAR + ".prematureEOF"), // GRAMMAR_UNEXPECTED_TOKEN(GRAMMAR_TOKEN + ".unexpected"), // GRAMMAR_EXPECTING_TOKEN(GRAMMAR_TOKEN + ".expecting"), // GRAMMAR_INVALID_SELECTOR(GRAMMAR + ".invalidSelector"),; // // final String value; // // CssErrorCode(String value) // { // this.value = value; // } // // @Override // public String toString() // { // return MoreObjects.toStringHelper(this.getClass()).addValue(value).toString(); // } // // } // // Path: src/main/java/org/idpf/epubcheck/util/css/CssExceptions.java // public static abstract class CssException extends Exception // { // final CssErrorCode errorCode; // final CssLocation location; // final Optional<CssToken> token; // // CssException(final CssToken token, final CssErrorCode errorCode, final CssLocation location, // final Locale locale, final Object... arguments) // { // super(Messages.getInstance(locale, CssExceptions.class).get(errorCode.value, arguments)); // this.errorCode = checkNotNull(errorCode); // this.location = checkNotNull(location); // this.token = token == null ? absent : Optional.of(token); // } // // CssException(final CssErrorCode errorCode, final CssLocation location, final Locale locale, // final Object... arguments) // { // this(null, errorCode, location, locale, arguments); // } // // public CssErrorCode getErrorCode() // { // return errorCode; // } // // public CssLocation getLocation() // { // return location; // } // // @Override // public String toString() // { // return MoreObjects.toStringHelper(this.getClass()).add("errorCode", errorCode) // .add("location", location.toString()).toString(); // } // // @Override // public boolean equals(Object obj) // { // if (obj instanceof CssException) // { // CssException exc = (CssException) obj; // if (exc.errorCode.equals(this.errorCode) && exc.location.equals(this.location)) // { // return true; // } // } // return false; // } // // private static final long serialVersionUID = -4635263495562931206L; // } // Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java import com.google.common.base.Ascii; import com.google.common.base.CharMatcher; import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.primitives.Ints; import org.idpf.epubcheck.util.css.CssExceptions.CssErrorCode; import org.idpf.epubcheck.util.css.CssExceptions.CssException; import org.idpf.epubcheck.util.css.CssReader.Mark; import org.idpf.epubcheck.util.css.CssToken.CssTokenConsumer; import org.idpf.epubcheck.util.css.CssToken.TokenBuilder; import org.idpf.epubcheck.util.css.CssToken.Type; import java.io.IOException; import java.io.Reader; import java.util.List; import java.util.Locale; import java.util.Map; import static com.google.common.base.Preconditions.*; import static org.idpf.epubcheck.util.css.CssExceptions.CssErrorCode.SCANNER_ILLEGAL_CHAR; import static org.idpf.epubcheck.util.css.CssExceptions.CssErrorCode.SCANNER_PREMATURE_EOF; // unquoted uri builder.append(uristart); if (debug) { checkArgument(NOT_WHITESPACE.matches((char) reader.curChar)); } StringBuilder buf = new StringBuilder(); while (true) { CssReader.Mark mark = reader.mark(); int ch = reader.next(); if (ch == -1) { builder.error(SCANNER_PREMATURE_EOF, reader); reader.unread(ch, mark); break; } else if (ch == ')') { break; } buf.append((char) ch); } builder.append(WHITESPACE.trimTrailingFrom(buf.toString())); } builder.append(')'); builder.type = Type.URI; if (')' != reader.curChar && builder.errors.size() == 0) {
builder.error(CssErrorCode.SCANNER_ILLEGAL_SYNTAX, reader, reader.curChar);
w3c/epubcheck
src/main/java/com/adobe/epubcheck/xml/XMLValidator.java
// Path: src/main/java/org/idpf/epubcheck/util/saxon/SystemIdFunction.java // public class SystemIdFunction extends ExtensionFunctionDefinition // { // // private static final long serialVersionUID = -4202710868367933385L; // // public static StructuredQName QNAME = new StructuredQName("saxon", "http://saxon.sf.net/", "system-id"); // // @Override // public StructuredQName getFunctionQName() // { // return QNAME; // } // // @Override // public int getMaximumNumberOfArguments() // { // return 0; // } // // @Override // public int getMinimumNumberOfArguments() // { // return 0; // } // // @Override // public SequenceType[] getArgumentTypes() // { // return new SequenceType[]{}; // } // // @Override // public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) // { // return SequenceType.SINGLE_STRING; // } // // @Override // public boolean dependsOnFocus() // { // return true; // } // // @Override // public boolean trustResultType() // { // return true; // } // // @Override // public ExtensionFunctionCall makeCallExpression() // { // return new ExtensionFunctionCall() // { // private static final long serialVersionUID = -4202710868367933385L; // // public Sequence call(XPathContext context, @SuppressWarnings("rawtypes") Sequence[] arguments) throws XPathException // { // if (context.getContextItem() instanceof NodeInfo) // { // return new SystemIdSequence(new AnyURIValue(((NodeInfo) context.getContextItem()).getSystemId())); // } // throw new XPathException("Unexpected XPath context for saxon:line-number"); // } // }; // } // // class SystemIdSequence implements Sequence // { // private AnyURIValue item; // // public SystemIdSequence(AnyURIValue item) // { // this.item = item; // } // // public Item head() // { // return item; // } // // @Override // public SequenceIterator iterate() throws // XPathException // { // return item.iterate(); // } // } // }
import java.io.IOException; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import org.idpf.epubcheck.util.saxon.ColumnNumberFunction; import org.idpf.epubcheck.util.saxon.LineNumberFunction; import org.idpf.epubcheck.util.saxon.SystemIdFunction; import org.xml.sax.ErrorHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import com.adobe.epubcheck.util.ResourceUtil; import com.thaiopensource.resolver.Identifier; import com.thaiopensource.resolver.Input; import com.thaiopensource.resolver.Resolver; import com.thaiopensource.resolver.ResolverException; import com.thaiopensource.util.PropertyMapBuilder; import com.thaiopensource.validate.Schema; import com.thaiopensource.validate.SchemaReader; import com.thaiopensource.validate.ValidateProperty; import com.thaiopensource.validate.auto.AutoSchemaReader; import com.thaiopensource.validate.auto.SchemaReaderFactorySchemaReceiverFactory; import com.thaiopensource.validate.rng.CompactSchemaReader; import com.thaiopensource.validate.schematron.NewSaxonSchemaReaderFactory; import net.sf.saxon.Configuration; import net.sf.saxon.TransformerFactoryImpl; import net.sf.saxon.lib.FeatureKeys; import net.sf.saxon.lib.StandardErrorListener; import net.sf.saxon.sxpath.IndependentContext; import net.sf.saxon.sxpath.XPathStaticContext; import net.sf.saxon.trans.SymbolicName; import net.sf.saxon.trans.XPathException;
{ uriRef = baseURI.resolve(uri).toString(); } } } return uriRef; } catch (URISyntaxException e) { throw new ResolverException(e); } catch (MalformedURLException e) { throw new ResolverException(e); } } } /** * Extends Jing's Saxon 9 schema reader factory by registering * extension functions. */ static public class ExtendedSaxonSchemaReaderFactory extends NewSaxonSchemaReaderFactory { public void initTransformerFactory(TransformerFactory factory) { super.initTransformerFactory(factory); SymbolicName.F lineNumberFn = new SymbolicName.F(LineNumberFunction.QNAME, 0); SymbolicName.F columnNumberFn = new SymbolicName.F(ColumnNumberFunction.QNAME, 0);
// Path: src/main/java/org/idpf/epubcheck/util/saxon/SystemIdFunction.java // public class SystemIdFunction extends ExtensionFunctionDefinition // { // // private static final long serialVersionUID = -4202710868367933385L; // // public static StructuredQName QNAME = new StructuredQName("saxon", "http://saxon.sf.net/", "system-id"); // // @Override // public StructuredQName getFunctionQName() // { // return QNAME; // } // // @Override // public int getMaximumNumberOfArguments() // { // return 0; // } // // @Override // public int getMinimumNumberOfArguments() // { // return 0; // } // // @Override // public SequenceType[] getArgumentTypes() // { // return new SequenceType[]{}; // } // // @Override // public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) // { // return SequenceType.SINGLE_STRING; // } // // @Override // public boolean dependsOnFocus() // { // return true; // } // // @Override // public boolean trustResultType() // { // return true; // } // // @Override // public ExtensionFunctionCall makeCallExpression() // { // return new ExtensionFunctionCall() // { // private static final long serialVersionUID = -4202710868367933385L; // // public Sequence call(XPathContext context, @SuppressWarnings("rawtypes") Sequence[] arguments) throws XPathException // { // if (context.getContextItem() instanceof NodeInfo) // { // return new SystemIdSequence(new AnyURIValue(((NodeInfo) context.getContextItem()).getSystemId())); // } // throw new XPathException("Unexpected XPath context for saxon:line-number"); // } // }; // } // // class SystemIdSequence implements Sequence // { // private AnyURIValue item; // // public SystemIdSequence(AnyURIValue item) // { // this.item = item; // } // // public Item head() // { // return item; // } // // @Override // public SequenceIterator iterate() throws // XPathException // { // return item.iterate(); // } // } // } // Path: src/main/java/com/adobe/epubcheck/xml/XMLValidator.java import java.io.IOException; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import org.idpf.epubcheck.util.saxon.ColumnNumberFunction; import org.idpf.epubcheck.util.saxon.LineNumberFunction; import org.idpf.epubcheck.util.saxon.SystemIdFunction; import org.xml.sax.ErrorHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import com.adobe.epubcheck.util.ResourceUtil; import com.thaiopensource.resolver.Identifier; import com.thaiopensource.resolver.Input; import com.thaiopensource.resolver.Resolver; import com.thaiopensource.resolver.ResolverException; import com.thaiopensource.util.PropertyMapBuilder; import com.thaiopensource.validate.Schema; import com.thaiopensource.validate.SchemaReader; import com.thaiopensource.validate.ValidateProperty; import com.thaiopensource.validate.auto.AutoSchemaReader; import com.thaiopensource.validate.auto.SchemaReaderFactorySchemaReceiverFactory; import com.thaiopensource.validate.rng.CompactSchemaReader; import com.thaiopensource.validate.schematron.NewSaxonSchemaReaderFactory; import net.sf.saxon.Configuration; import net.sf.saxon.TransformerFactoryImpl; import net.sf.saxon.lib.FeatureKeys; import net.sf.saxon.lib.StandardErrorListener; import net.sf.saxon.sxpath.IndependentContext; import net.sf.saxon.sxpath.XPathStaticContext; import net.sf.saxon.trans.SymbolicName; import net.sf.saxon.trans.XPathException; { uriRef = baseURI.resolve(uri).toString(); } } } return uriRef; } catch (URISyntaxException e) { throw new ResolverException(e); } catch (MalformedURLException e) { throw new ResolverException(e); } } } /** * Extends Jing's Saxon 9 schema reader factory by registering * extension functions. */ static public class ExtendedSaxonSchemaReaderFactory extends NewSaxonSchemaReaderFactory { public void initTransformerFactory(TransformerFactory factory) { super.initTransformerFactory(factory); SymbolicName.F lineNumberFn = new SymbolicName.F(LineNumberFunction.QNAME, 0); SymbolicName.F columnNumberFn = new SymbolicName.F(ColumnNumberFunction.QNAME, 0);
SymbolicName.F systemIdFn = new SymbolicName.F(SystemIdFunction.QNAME, 0);
w3c/epubcheck
src/main/java/com/adobe/epubcheck/util/XmpReportImpl.java
// Path: src/main/java/com/adobe/epubcheck/api/EPUBLocation.java // public final class EPUBLocation implements Comparable<EPUBLocation> // { // // public static EPUBLocation create(String fileName) // { // return new EPUBLocation(fileName, -1, -1, null); // } // // public static EPUBLocation create(String fileName, String context) // { // return new EPUBLocation(fileName, -1, -1, context); // } // // public static EPUBLocation create(String fileName, int lineNumber, int column) // { // return new EPUBLocation(fileName, lineNumber, column, null); // } // // public static EPUBLocation create(String fileName, int lineNumber, int column, String context) // { // return new EPUBLocation(fileName, lineNumber, column, context); // } // // @JsonProperty // private final String path; // @JsonProperty // private final int line; // @JsonProperty // private final int column; // @JsonProperty // @JsonSerialize(using = JsonWriter.OptionalJsonSerializer.class) // private final Optional<String> context; // // private EPUBLocation(String path, int lineNumber, int column, String context) // { // Preconditions.checkNotNull(path); // this.path = path; // this.line = lineNumber; // this.column = column; // this.context = Optional.fromNullable(context); // } // // public String getPath() // { // return this.path; // } // // public int getLine() // { // return this.line; // } // // public int getColumn() // { // return this.column; // } // // public Optional<String> getContext() // { // return this.context; // } // // // // @Override // public String toString() // { // return path + "[" + line + "," + column + "]"; // } // // @Override // public boolean equals(Object obj) // { // if (obj == this) // { // return true; // } // if (obj == null || obj.getClass() != this.getClass()) // { // return false; // } // // EPUBLocation other = (EPUBLocation) obj; // return !(this.getContext() == null && other.getContext() != null) // && this.getPath().equals(other.getPath()) && this.getLine() == other.getLine() // && this.getColumn() == other.getColumn() // && (this.getContext() == null || this.getContext().equals(other.getContext())); // } // // int safeCompare(String a, String b) // { // if (a == null && b != null) return -1; // if (a != null && b == null) return 1; // if (a == null /* && b == null */) return 0; // return a.compareTo(b); // } // // @Override // public int compareTo(EPUBLocation o) // { // int comp = safeCompare(this.path, o.path); // if (comp != 0) // { // return comp; // } // // comp = line - o.line; // if (comp != 0) // { // return comp < 0 ? -1 : 1; // } // // comp = column - o.column; // if (comp != 0) // { // return comp < 0 ? -1 : 1; // } // comp = safeCompare(context.orNull(), o.context.orNull()); // if (comp != 0) // { // return comp; // } // // return 0; // } // }
import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import com.adobe.epubcheck.api.EPUBLocation; import com.adobe.epubcheck.reporting.CheckMessage;
} protected void generateFont(String font, boolean embeded) { // stFnt:fontName, stFnt:fontType, stFnt:versionString, stFnt:composite, stFnt:fontFileName String[] elFont = font.split(","); List<KeyValue<String, String>> attrs = new ArrayList<KeyValue<String, String>>(); attrs.add(KeyValue.with("stFnt:fontFamily", capitalize(elFont[0]))); String fontFace = ""; for (int i = 1; i < elFont.length; i++) { fontFace += capitalize(elFont[i]) + " "; } fontFace = fontFace.trim(); if (fontFace.length() == 0) { attrs.add(KeyValue.with("stFnt:fontFace", "Regular")); } else { attrs.add(KeyValue.with("stFnt:fontFace", fontFace)); } generateElement("rdf:li", null, attrs); } @SuppressWarnings("unchecked") private void generateEventOutcome(List<CheckMessage> messages, String sev) { for (CheckMessage c : messages) { startElement("rdf:li", KeyValue.with("rdf:parseType", "Resource")); generateElement("premis:hasEventOutcome", c.getID() + ", " + sev + ", " + c.getMessage()); if (c.getLocations().size() != 0) { startElement("premis:hasEventOutcomeDetail"); startElement("rdf:Seq"); String previousValue = "";
// Path: src/main/java/com/adobe/epubcheck/api/EPUBLocation.java // public final class EPUBLocation implements Comparable<EPUBLocation> // { // // public static EPUBLocation create(String fileName) // { // return new EPUBLocation(fileName, -1, -1, null); // } // // public static EPUBLocation create(String fileName, String context) // { // return new EPUBLocation(fileName, -1, -1, context); // } // // public static EPUBLocation create(String fileName, int lineNumber, int column) // { // return new EPUBLocation(fileName, lineNumber, column, null); // } // // public static EPUBLocation create(String fileName, int lineNumber, int column, String context) // { // return new EPUBLocation(fileName, lineNumber, column, context); // } // // @JsonProperty // private final String path; // @JsonProperty // private final int line; // @JsonProperty // private final int column; // @JsonProperty // @JsonSerialize(using = JsonWriter.OptionalJsonSerializer.class) // private final Optional<String> context; // // private EPUBLocation(String path, int lineNumber, int column, String context) // { // Preconditions.checkNotNull(path); // this.path = path; // this.line = lineNumber; // this.column = column; // this.context = Optional.fromNullable(context); // } // // public String getPath() // { // return this.path; // } // // public int getLine() // { // return this.line; // } // // public int getColumn() // { // return this.column; // } // // public Optional<String> getContext() // { // return this.context; // } // // // // @Override // public String toString() // { // return path + "[" + line + "," + column + "]"; // } // // @Override // public boolean equals(Object obj) // { // if (obj == this) // { // return true; // } // if (obj == null || obj.getClass() != this.getClass()) // { // return false; // } // // EPUBLocation other = (EPUBLocation) obj; // return !(this.getContext() == null && other.getContext() != null) // && this.getPath().equals(other.getPath()) && this.getLine() == other.getLine() // && this.getColumn() == other.getColumn() // && (this.getContext() == null || this.getContext().equals(other.getContext())); // } // // int safeCompare(String a, String b) // { // if (a == null && b != null) return -1; // if (a != null && b == null) return 1; // if (a == null /* && b == null */) return 0; // return a.compareTo(b); // } // // @Override // public int compareTo(EPUBLocation o) // { // int comp = safeCompare(this.path, o.path); // if (comp != 0) // { // return comp; // } // // comp = line - o.line; // if (comp != 0) // { // return comp < 0 ? -1 : 1; // } // // comp = column - o.column; // if (comp != 0) // { // return comp < 0 ? -1 : 1; // } // comp = safeCompare(context.orNull(), o.context.orNull()); // if (comp != 0) // { // return comp; // } // // return 0; // } // } // Path: src/main/java/com/adobe/epubcheck/util/XmpReportImpl.java import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import com.adobe.epubcheck.api.EPUBLocation; import com.adobe.epubcheck.reporting.CheckMessage; } protected void generateFont(String font, boolean embeded) { // stFnt:fontName, stFnt:fontType, stFnt:versionString, stFnt:composite, stFnt:fontFileName String[] elFont = font.split(","); List<KeyValue<String, String>> attrs = new ArrayList<KeyValue<String, String>>(); attrs.add(KeyValue.with("stFnt:fontFamily", capitalize(elFont[0]))); String fontFace = ""; for (int i = 1; i < elFont.length; i++) { fontFace += capitalize(elFont[i]) + " "; } fontFace = fontFace.trim(); if (fontFace.length() == 0) { attrs.add(KeyValue.with("stFnt:fontFace", "Regular")); } else { attrs.add(KeyValue.with("stFnt:fontFace", fontFace)); } generateElement("rdf:li", null, attrs); } @SuppressWarnings("unchecked") private void generateEventOutcome(List<CheckMessage> messages, String sev) { for (CheckMessage c : messages) { startElement("rdf:li", KeyValue.with("rdf:parseType", "Resource")); generateElement("premis:hasEventOutcome", c.getID() + ", " + sev + ", " + c.getMessage()); if (c.getLocations().size() != 0) { startElement("premis:hasEventOutcomeDetail"); startElement("rdf:Seq"); String previousValue = "";
for (EPUBLocation ml : c.getLocations()) {
w3c/epubcheck
src/main/java/org/idpf/epubcheck/util/css/CssEscape.java
// Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static final CharMatcher HEXCHAR = CharMatcher.anyOf( // "AaBbCcDdEeFf0123456789").precomputed(); // // Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static final CharMatcher WHITESPACE = CharMatcher.anyOf(" \t\n\r\f") // .precomputed(); // // Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static int isNewLine(int[] chars) // { // checkArgument(chars.length > 1); // // nl \n|\r\n|\r|\f // if (chars[0] == '\r' && chars[1] == '\n') // { // return 2; // } // else if (chars[0] == '\n' || chars[0] == '\r' || chars[0] == '\f') // { // return 1; // } // return 0; // } // // Path: src/main/java/org/idpf/epubcheck/util/css/CssExceptions.java // public static abstract class CssException extends Exception // { // final CssErrorCode errorCode; // final CssLocation location; // final Optional<CssToken> token; // // CssException(final CssToken token, final CssErrorCode errorCode, final CssLocation location, // final Locale locale, final Object... arguments) // { // super(Messages.getInstance(locale, CssExceptions.class).get(errorCode.value, arguments)); // this.errorCode = checkNotNull(errorCode); // this.location = checkNotNull(location); // this.token = token == null ? absent : Optional.of(token); // } // // CssException(final CssErrorCode errorCode, final CssLocation location, final Locale locale, // final Object... arguments) // { // this(null, errorCode, location, locale, arguments); // } // // public CssErrorCode getErrorCode() // { // return errorCode; // } // // public CssLocation getLocation() // { // return location; // } // // @Override // public String toString() // { // return MoreObjects.toStringHelper(this.getClass()).add("errorCode", errorCode) // .add("location", location.toString()).toString(); // } // // @Override // public boolean equals(Object obj) // { // if (obj instanceof CssException) // { // CssException exc = (CssException) obj; // if (exc.errorCode.equals(this.errorCode) && exc.location.equals(this.location)) // { // return true; // } // } // return false; // } // // private static final long serialVersionUID = -4635263495562931206L; // }
import org.idpf.epubcheck.util.css.CssToken.TokenBuilder; import com.google.common.base.CharMatcher; import com.google.common.base.MoreObjects; import com.google.common.base.Optional; import static com.google.common.base.Preconditions.checkArgument; import static org.idpf.epubcheck.util.css.CssExceptions.CssErrorCode.SCANNER_PREMATURE_EOF; import static org.idpf.epubcheck.util.css.CssScanner.HEXCHAR; import static org.idpf.epubcheck.util.css.CssScanner.WHITESPACE; import static org.idpf.epubcheck.util.css.CssScanner.isNewLine; import java.io.IOException; import org.idpf.epubcheck.util.css.CssExceptions.CssException;
/* * Copyright (c) 2012 International Digital Publishing Forum * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package org.idpf.epubcheck.util.css; /** * Represents a CSS escape sequence. * * @author mgylling */ class CssEscape { static final Optional<CssEscape> ABSENT = Optional.absent(); private final boolean debug = false; private final CssReader reader; private final TokenBuilder err; /** * The original escape sequence */ private CharSequence sequence; /** * The character resulting from unescaping the original escape sequence */ int character; /** * Constructor. * * @param reader A CssReader whose current char is the backslash. * @param err token builder */ CssEscape(final CssReader reader, final TokenBuilder err) { this.reader = reader; this.err = err; } Optional<CssEscape> create() throws IOException,
// Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static final CharMatcher HEXCHAR = CharMatcher.anyOf( // "AaBbCcDdEeFf0123456789").precomputed(); // // Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static final CharMatcher WHITESPACE = CharMatcher.anyOf(" \t\n\r\f") // .precomputed(); // // Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static int isNewLine(int[] chars) // { // checkArgument(chars.length > 1); // // nl \n|\r\n|\r|\f // if (chars[0] == '\r' && chars[1] == '\n') // { // return 2; // } // else if (chars[0] == '\n' || chars[0] == '\r' || chars[0] == '\f') // { // return 1; // } // return 0; // } // // Path: src/main/java/org/idpf/epubcheck/util/css/CssExceptions.java // public static abstract class CssException extends Exception // { // final CssErrorCode errorCode; // final CssLocation location; // final Optional<CssToken> token; // // CssException(final CssToken token, final CssErrorCode errorCode, final CssLocation location, // final Locale locale, final Object... arguments) // { // super(Messages.getInstance(locale, CssExceptions.class).get(errorCode.value, arguments)); // this.errorCode = checkNotNull(errorCode); // this.location = checkNotNull(location); // this.token = token == null ? absent : Optional.of(token); // } // // CssException(final CssErrorCode errorCode, final CssLocation location, final Locale locale, // final Object... arguments) // { // this(null, errorCode, location, locale, arguments); // } // // public CssErrorCode getErrorCode() // { // return errorCode; // } // // public CssLocation getLocation() // { // return location; // } // // @Override // public String toString() // { // return MoreObjects.toStringHelper(this.getClass()).add("errorCode", errorCode) // .add("location", location.toString()).toString(); // } // // @Override // public boolean equals(Object obj) // { // if (obj instanceof CssException) // { // CssException exc = (CssException) obj; // if (exc.errorCode.equals(this.errorCode) && exc.location.equals(this.location)) // { // return true; // } // } // return false; // } // // private static final long serialVersionUID = -4635263495562931206L; // } // Path: src/main/java/org/idpf/epubcheck/util/css/CssEscape.java import org.idpf.epubcheck.util.css.CssToken.TokenBuilder; import com.google.common.base.CharMatcher; import com.google.common.base.MoreObjects; import com.google.common.base.Optional; import static com.google.common.base.Preconditions.checkArgument; import static org.idpf.epubcheck.util.css.CssExceptions.CssErrorCode.SCANNER_PREMATURE_EOF; import static org.idpf.epubcheck.util.css.CssScanner.HEXCHAR; import static org.idpf.epubcheck.util.css.CssScanner.WHITESPACE; import static org.idpf.epubcheck.util.css.CssScanner.isNewLine; import java.io.IOException; import org.idpf.epubcheck.util.css.CssExceptions.CssException; /* * Copyright (c) 2012 International Digital Publishing Forum * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package org.idpf.epubcheck.util.css; /** * Represents a CSS escape sequence. * * @author mgylling */ class CssEscape { static final Optional<CssEscape> ABSENT = Optional.absent(); private final boolean debug = false; private final CssReader reader; private final TokenBuilder err; /** * The original escape sequence */ private CharSequence sequence; /** * The character resulting from unescaping the original escape sequence */ int character; /** * Constructor. * * @param reader A CssReader whose current char is the backslash. * @param err token builder */ CssEscape(final CssReader reader, final TokenBuilder err) { this.reader = reader; this.err = err; } Optional<CssEscape> create() throws IOException,
CssException
w3c/epubcheck
src/main/java/org/idpf/epubcheck/util/css/CssEscape.java
// Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static final CharMatcher HEXCHAR = CharMatcher.anyOf( // "AaBbCcDdEeFf0123456789").precomputed(); // // Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static final CharMatcher WHITESPACE = CharMatcher.anyOf(" \t\n\r\f") // .precomputed(); // // Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static int isNewLine(int[] chars) // { // checkArgument(chars.length > 1); // // nl \n|\r\n|\r|\f // if (chars[0] == '\r' && chars[1] == '\n') // { // return 2; // } // else if (chars[0] == '\n' || chars[0] == '\r' || chars[0] == '\f') // { // return 1; // } // return 0; // } // // Path: src/main/java/org/idpf/epubcheck/util/css/CssExceptions.java // public static abstract class CssException extends Exception // { // final CssErrorCode errorCode; // final CssLocation location; // final Optional<CssToken> token; // // CssException(final CssToken token, final CssErrorCode errorCode, final CssLocation location, // final Locale locale, final Object... arguments) // { // super(Messages.getInstance(locale, CssExceptions.class).get(errorCode.value, arguments)); // this.errorCode = checkNotNull(errorCode); // this.location = checkNotNull(location); // this.token = token == null ? absent : Optional.of(token); // } // // CssException(final CssErrorCode errorCode, final CssLocation location, final Locale locale, // final Object... arguments) // { // this(null, errorCode, location, locale, arguments); // } // // public CssErrorCode getErrorCode() // { // return errorCode; // } // // public CssLocation getLocation() // { // return location; // } // // @Override // public String toString() // { // return MoreObjects.toStringHelper(this.getClass()).add("errorCode", errorCode) // .add("location", location.toString()).toString(); // } // // @Override // public boolean equals(Object obj) // { // if (obj instanceof CssException) // { // CssException exc = (CssException) obj; // if (exc.errorCode.equals(this.errorCode) && exc.location.equals(this.location)) // { // return true; // } // } // return false; // } // // private static final long serialVersionUID = -4635263495562931206L; // }
import org.idpf.epubcheck.util.css.CssToken.TokenBuilder; import com.google.common.base.CharMatcher; import com.google.common.base.MoreObjects; import com.google.common.base.Optional; import static com.google.common.base.Preconditions.checkArgument; import static org.idpf.epubcheck.util.css.CssExceptions.CssErrorCode.SCANNER_PREMATURE_EOF; import static org.idpf.epubcheck.util.css.CssScanner.HEXCHAR; import static org.idpf.epubcheck.util.css.CssScanner.WHITESPACE; import static org.idpf.epubcheck.util.css.CssScanner.isNewLine; import java.io.IOException; import org.idpf.epubcheck.util.css.CssExceptions.CssException;
/* * Copyright (c) 2012 International Digital Publishing Forum * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package org.idpf.epubcheck.util.css; /** * Represents a CSS escape sequence. * * @author mgylling */ class CssEscape { static final Optional<CssEscape> ABSENT = Optional.absent(); private final boolean debug = false; private final CssReader reader; private final TokenBuilder err; /** * The original escape sequence */ private CharSequence sequence; /** * The character resulting from unescaping the original escape sequence */ int character; /** * Constructor. * * @param reader A CssReader whose current char is the backslash. * @param err token builder */ CssEscape(final CssReader reader, final TokenBuilder err) { this.reader = reader; this.err = err; } Optional<CssEscape> create() throws IOException, CssException { if (debug) { checkArgument(reader.curChar == '\\', "must be backslash, was: %s", (char) reader.curChar); } /* * The incoming is either a hex escape or single char escape, max 8 chars long */ StringBuilder sb = new StringBuilder(); int[] eight = reader.peek(8); int first = eight[0]; if (first == -1) { err.error(SCANNER_PREMATURE_EOF, reader); return Optional.absent(); }
// Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static final CharMatcher HEXCHAR = CharMatcher.anyOf( // "AaBbCcDdEeFf0123456789").precomputed(); // // Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static final CharMatcher WHITESPACE = CharMatcher.anyOf(" \t\n\r\f") // .precomputed(); // // Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static int isNewLine(int[] chars) // { // checkArgument(chars.length > 1); // // nl \n|\r\n|\r|\f // if (chars[0] == '\r' && chars[1] == '\n') // { // return 2; // } // else if (chars[0] == '\n' || chars[0] == '\r' || chars[0] == '\f') // { // return 1; // } // return 0; // } // // Path: src/main/java/org/idpf/epubcheck/util/css/CssExceptions.java // public static abstract class CssException extends Exception // { // final CssErrorCode errorCode; // final CssLocation location; // final Optional<CssToken> token; // // CssException(final CssToken token, final CssErrorCode errorCode, final CssLocation location, // final Locale locale, final Object... arguments) // { // super(Messages.getInstance(locale, CssExceptions.class).get(errorCode.value, arguments)); // this.errorCode = checkNotNull(errorCode); // this.location = checkNotNull(location); // this.token = token == null ? absent : Optional.of(token); // } // // CssException(final CssErrorCode errorCode, final CssLocation location, final Locale locale, // final Object... arguments) // { // this(null, errorCode, location, locale, arguments); // } // // public CssErrorCode getErrorCode() // { // return errorCode; // } // // public CssLocation getLocation() // { // return location; // } // // @Override // public String toString() // { // return MoreObjects.toStringHelper(this.getClass()).add("errorCode", errorCode) // .add("location", location.toString()).toString(); // } // // @Override // public boolean equals(Object obj) // { // if (obj instanceof CssException) // { // CssException exc = (CssException) obj; // if (exc.errorCode.equals(this.errorCode) && exc.location.equals(this.location)) // { // return true; // } // } // return false; // } // // private static final long serialVersionUID = -4635263495562931206L; // } // Path: src/main/java/org/idpf/epubcheck/util/css/CssEscape.java import org.idpf.epubcheck.util.css.CssToken.TokenBuilder; import com.google.common.base.CharMatcher; import com.google.common.base.MoreObjects; import com.google.common.base.Optional; import static com.google.common.base.Preconditions.checkArgument; import static org.idpf.epubcheck.util.css.CssExceptions.CssErrorCode.SCANNER_PREMATURE_EOF; import static org.idpf.epubcheck.util.css.CssScanner.HEXCHAR; import static org.idpf.epubcheck.util.css.CssScanner.WHITESPACE; import static org.idpf.epubcheck.util.css.CssScanner.isNewLine; import java.io.IOException; import org.idpf.epubcheck.util.css.CssExceptions.CssException; /* * Copyright (c) 2012 International Digital Publishing Forum * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package org.idpf.epubcheck.util.css; /** * Represents a CSS escape sequence. * * @author mgylling */ class CssEscape { static final Optional<CssEscape> ABSENT = Optional.absent(); private final boolean debug = false; private final CssReader reader; private final TokenBuilder err; /** * The original escape sequence */ private CharSequence sequence; /** * The character resulting from unescaping the original escape sequence */ int character; /** * Constructor. * * @param reader A CssReader whose current char is the backslash. * @param err token builder */ CssEscape(final CssReader reader, final TokenBuilder err) { this.reader = reader; this.err = err; } Optional<CssEscape> create() throws IOException, CssException { if (debug) { checkArgument(reader.curChar == '\\', "must be backslash, was: %s", (char) reader.curChar); } /* * The incoming is either a hex escape or single char escape, max 8 chars long */ StringBuilder sb = new StringBuilder(); int[] eight = reader.peek(8); int first = eight[0]; if (first == -1) { err.error(SCANNER_PREMATURE_EOF, reader); return Optional.absent(); }
else if (isNewLine(eight) > 0)
w3c/epubcheck
src/main/java/org/idpf/epubcheck/util/css/CssEscape.java
// Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static final CharMatcher HEXCHAR = CharMatcher.anyOf( // "AaBbCcDdEeFf0123456789").precomputed(); // // Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static final CharMatcher WHITESPACE = CharMatcher.anyOf(" \t\n\r\f") // .precomputed(); // // Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static int isNewLine(int[] chars) // { // checkArgument(chars.length > 1); // // nl \n|\r\n|\r|\f // if (chars[0] == '\r' && chars[1] == '\n') // { // return 2; // } // else if (chars[0] == '\n' || chars[0] == '\r' || chars[0] == '\f') // { // return 1; // } // return 0; // } // // Path: src/main/java/org/idpf/epubcheck/util/css/CssExceptions.java // public static abstract class CssException extends Exception // { // final CssErrorCode errorCode; // final CssLocation location; // final Optional<CssToken> token; // // CssException(final CssToken token, final CssErrorCode errorCode, final CssLocation location, // final Locale locale, final Object... arguments) // { // super(Messages.getInstance(locale, CssExceptions.class).get(errorCode.value, arguments)); // this.errorCode = checkNotNull(errorCode); // this.location = checkNotNull(location); // this.token = token == null ? absent : Optional.of(token); // } // // CssException(final CssErrorCode errorCode, final CssLocation location, final Locale locale, // final Object... arguments) // { // this(null, errorCode, location, locale, arguments); // } // // public CssErrorCode getErrorCode() // { // return errorCode; // } // // public CssLocation getLocation() // { // return location; // } // // @Override // public String toString() // { // return MoreObjects.toStringHelper(this.getClass()).add("errorCode", errorCode) // .add("location", location.toString()).toString(); // } // // @Override // public boolean equals(Object obj) // { // if (obj instanceof CssException) // { // CssException exc = (CssException) obj; // if (exc.errorCode.equals(this.errorCode) && exc.location.equals(this.location)) // { // return true; // } // } // return false; // } // // private static final long serialVersionUID = -4635263495562931206L; // }
import org.idpf.epubcheck.util.css.CssToken.TokenBuilder; import com.google.common.base.CharMatcher; import com.google.common.base.MoreObjects; import com.google.common.base.Optional; import static com.google.common.base.Preconditions.checkArgument; import static org.idpf.epubcheck.util.css.CssExceptions.CssErrorCode.SCANNER_PREMATURE_EOF; import static org.idpf.epubcheck.util.css.CssScanner.HEXCHAR; import static org.idpf.epubcheck.util.css.CssScanner.WHITESPACE; import static org.idpf.epubcheck.util.css.CssScanner.isNewLine; import java.io.IOException; import org.idpf.epubcheck.util.css.CssExceptions.CssException;
this.reader = reader; this.err = err; } Optional<CssEscape> create() throws IOException, CssException { if (debug) { checkArgument(reader.curChar == '\\', "must be backslash, was: %s", (char) reader.curChar); } /* * The incoming is either a hex escape or single char escape, max 8 chars long */ StringBuilder sb = new StringBuilder(); int[] eight = reader.peek(8); int first = eight[0]; if (first == -1) { err.error(SCANNER_PREMATURE_EOF, reader); return Optional.absent(); } else if (isNewLine(eight) > 0) { //"a backslash followed by a newline stands by itself" return Optional.absent(); }
// Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static final CharMatcher HEXCHAR = CharMatcher.anyOf( // "AaBbCcDdEeFf0123456789").precomputed(); // // Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static final CharMatcher WHITESPACE = CharMatcher.anyOf(" \t\n\r\f") // .precomputed(); // // Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static int isNewLine(int[] chars) // { // checkArgument(chars.length > 1); // // nl \n|\r\n|\r|\f // if (chars[0] == '\r' && chars[1] == '\n') // { // return 2; // } // else if (chars[0] == '\n' || chars[0] == '\r' || chars[0] == '\f') // { // return 1; // } // return 0; // } // // Path: src/main/java/org/idpf/epubcheck/util/css/CssExceptions.java // public static abstract class CssException extends Exception // { // final CssErrorCode errorCode; // final CssLocation location; // final Optional<CssToken> token; // // CssException(final CssToken token, final CssErrorCode errorCode, final CssLocation location, // final Locale locale, final Object... arguments) // { // super(Messages.getInstance(locale, CssExceptions.class).get(errorCode.value, arguments)); // this.errorCode = checkNotNull(errorCode); // this.location = checkNotNull(location); // this.token = token == null ? absent : Optional.of(token); // } // // CssException(final CssErrorCode errorCode, final CssLocation location, final Locale locale, // final Object... arguments) // { // this(null, errorCode, location, locale, arguments); // } // // public CssErrorCode getErrorCode() // { // return errorCode; // } // // public CssLocation getLocation() // { // return location; // } // // @Override // public String toString() // { // return MoreObjects.toStringHelper(this.getClass()).add("errorCode", errorCode) // .add("location", location.toString()).toString(); // } // // @Override // public boolean equals(Object obj) // { // if (obj instanceof CssException) // { // CssException exc = (CssException) obj; // if (exc.errorCode.equals(this.errorCode) && exc.location.equals(this.location)) // { // return true; // } // } // return false; // } // // private static final long serialVersionUID = -4635263495562931206L; // } // Path: src/main/java/org/idpf/epubcheck/util/css/CssEscape.java import org.idpf.epubcheck.util.css.CssToken.TokenBuilder; import com.google.common.base.CharMatcher; import com.google.common.base.MoreObjects; import com.google.common.base.Optional; import static com.google.common.base.Preconditions.checkArgument; import static org.idpf.epubcheck.util.css.CssExceptions.CssErrorCode.SCANNER_PREMATURE_EOF; import static org.idpf.epubcheck.util.css.CssScanner.HEXCHAR; import static org.idpf.epubcheck.util.css.CssScanner.WHITESPACE; import static org.idpf.epubcheck.util.css.CssScanner.isNewLine; import java.io.IOException; import org.idpf.epubcheck.util.css.CssExceptions.CssException; this.reader = reader; this.err = err; } Optional<CssEscape> create() throws IOException, CssException { if (debug) { checkArgument(reader.curChar == '\\', "must be backslash, was: %s", (char) reader.curChar); } /* * The incoming is either a hex escape or single char escape, max 8 chars long */ StringBuilder sb = new StringBuilder(); int[] eight = reader.peek(8); int first = eight[0]; if (first == -1) { err.error(SCANNER_PREMATURE_EOF, reader); return Optional.absent(); } else if (isNewLine(eight) > 0) { //"a backslash followed by a newline stands by itself" return Optional.absent(); }
if (CssScanner.HEXCHAR.matches((char) first))
w3c/epubcheck
src/main/java/org/idpf/epubcheck/util/css/CssEscape.java
// Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static final CharMatcher HEXCHAR = CharMatcher.anyOf( // "AaBbCcDdEeFf0123456789").precomputed(); // // Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static final CharMatcher WHITESPACE = CharMatcher.anyOf(" \t\n\r\f") // .precomputed(); // // Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static int isNewLine(int[] chars) // { // checkArgument(chars.length > 1); // // nl \n|\r\n|\r|\f // if (chars[0] == '\r' && chars[1] == '\n') // { // return 2; // } // else if (chars[0] == '\n' || chars[0] == '\r' || chars[0] == '\f') // { // return 1; // } // return 0; // } // // Path: src/main/java/org/idpf/epubcheck/util/css/CssExceptions.java // public static abstract class CssException extends Exception // { // final CssErrorCode errorCode; // final CssLocation location; // final Optional<CssToken> token; // // CssException(final CssToken token, final CssErrorCode errorCode, final CssLocation location, // final Locale locale, final Object... arguments) // { // super(Messages.getInstance(locale, CssExceptions.class).get(errorCode.value, arguments)); // this.errorCode = checkNotNull(errorCode); // this.location = checkNotNull(location); // this.token = token == null ? absent : Optional.of(token); // } // // CssException(final CssErrorCode errorCode, final CssLocation location, final Locale locale, // final Object... arguments) // { // this(null, errorCode, location, locale, arguments); // } // // public CssErrorCode getErrorCode() // { // return errorCode; // } // // public CssLocation getLocation() // { // return location; // } // // @Override // public String toString() // { // return MoreObjects.toStringHelper(this.getClass()).add("errorCode", errorCode) // .add("location", location.toString()).toString(); // } // // @Override // public boolean equals(Object obj) // { // if (obj instanceof CssException) // { // CssException exc = (CssException) obj; // if (exc.errorCode.equals(this.errorCode) && exc.location.equals(this.location)) // { // return true; // } // } // return false; // } // // private static final long serialVersionUID = -4635263495562931206L; // }
import org.idpf.epubcheck.util.css.CssToken.TokenBuilder; import com.google.common.base.CharMatcher; import com.google.common.base.MoreObjects; import com.google.common.base.Optional; import static com.google.common.base.Preconditions.checkArgument; import static org.idpf.epubcheck.util.css.CssExceptions.CssErrorCode.SCANNER_PREMATURE_EOF; import static org.idpf.epubcheck.util.css.CssScanner.HEXCHAR; import static org.idpf.epubcheck.util.css.CssScanner.WHITESPACE; import static org.idpf.epubcheck.util.css.CssScanner.isNewLine; import java.io.IOException; import org.idpf.epubcheck.util.css.CssExceptions.CssException;
StringBuilder sb = new StringBuilder(); int[] eight = reader.peek(8); int first = eight[0]; if (first == -1) { err.error(SCANNER_PREMATURE_EOF, reader); return Optional.absent(); } else if (isNewLine(eight) > 0) { //"a backslash followed by a newline stands by itself" return Optional.absent(); } if (CssScanner.HEXCHAR.matches((char) first)) { //a hex escape, max six chars, + optionally single whitespace or cr+lf boolean seenSpace = false; for (int cur : eight) { if (cur == -1) { break; } char ch = (char) cur; boolean isHexChar = HEXCHAR.matches(ch);
// Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static final CharMatcher HEXCHAR = CharMatcher.anyOf( // "AaBbCcDdEeFf0123456789").precomputed(); // // Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static final CharMatcher WHITESPACE = CharMatcher.anyOf(" \t\n\r\f") // .precomputed(); // // Path: src/main/java/org/idpf/epubcheck/util/css/CssScanner.java // static int isNewLine(int[] chars) // { // checkArgument(chars.length > 1); // // nl \n|\r\n|\r|\f // if (chars[0] == '\r' && chars[1] == '\n') // { // return 2; // } // else if (chars[0] == '\n' || chars[0] == '\r' || chars[0] == '\f') // { // return 1; // } // return 0; // } // // Path: src/main/java/org/idpf/epubcheck/util/css/CssExceptions.java // public static abstract class CssException extends Exception // { // final CssErrorCode errorCode; // final CssLocation location; // final Optional<CssToken> token; // // CssException(final CssToken token, final CssErrorCode errorCode, final CssLocation location, // final Locale locale, final Object... arguments) // { // super(Messages.getInstance(locale, CssExceptions.class).get(errorCode.value, arguments)); // this.errorCode = checkNotNull(errorCode); // this.location = checkNotNull(location); // this.token = token == null ? absent : Optional.of(token); // } // // CssException(final CssErrorCode errorCode, final CssLocation location, final Locale locale, // final Object... arguments) // { // this(null, errorCode, location, locale, arguments); // } // // public CssErrorCode getErrorCode() // { // return errorCode; // } // // public CssLocation getLocation() // { // return location; // } // // @Override // public String toString() // { // return MoreObjects.toStringHelper(this.getClass()).add("errorCode", errorCode) // .add("location", location.toString()).toString(); // } // // @Override // public boolean equals(Object obj) // { // if (obj instanceof CssException) // { // CssException exc = (CssException) obj; // if (exc.errorCode.equals(this.errorCode) && exc.location.equals(this.location)) // { // return true; // } // } // return false; // } // // private static final long serialVersionUID = -4635263495562931206L; // } // Path: src/main/java/org/idpf/epubcheck/util/css/CssEscape.java import org.idpf.epubcheck.util.css.CssToken.TokenBuilder; import com.google.common.base.CharMatcher; import com.google.common.base.MoreObjects; import com.google.common.base.Optional; import static com.google.common.base.Preconditions.checkArgument; import static org.idpf.epubcheck.util.css.CssExceptions.CssErrorCode.SCANNER_PREMATURE_EOF; import static org.idpf.epubcheck.util.css.CssScanner.HEXCHAR; import static org.idpf.epubcheck.util.css.CssScanner.WHITESPACE; import static org.idpf.epubcheck.util.css.CssScanner.isNewLine; import java.io.IOException; import org.idpf.epubcheck.util.css.CssExceptions.CssException; StringBuilder sb = new StringBuilder(); int[] eight = reader.peek(8); int first = eight[0]; if (first == -1) { err.error(SCANNER_PREMATURE_EOF, reader); return Optional.absent(); } else if (isNewLine(eight) > 0) { //"a backslash followed by a newline stands by itself" return Optional.absent(); } if (CssScanner.HEXCHAR.matches((char) first)) { //a hex escape, max six chars, + optionally single whitespace or cr+lf boolean seenSpace = false; for (int cur : eight) { if (cur == -1) { break; } char ch = (char) cur; boolean isHexChar = HEXCHAR.matches(ch);
boolean isSpace = WHITESPACE.matches(ch);
w3c/epubcheck
src/main/java/com/adobe/epubcheck/ctc/TextSearch.java
// Path: src/main/java/com/adobe/epubcheck/api/Report.java // public interface Report // { // /** // * Called when a violation of the standard is found in epub. // * // * @param id Id of the message being reported // * @param location location information for the message // * @param args Arguments referenced by the format // * string for the message. // */ // public void message(MessageId id, EPUBLocation location, Object... args); // // /** // * Called when a violation of the standard is found in epub. // * // * @param message The message being reported // * @param location location information for the message // * @param args Arguments referenced by the format // * string for the message. // */ // void message(Message message, EPUBLocation location, Object... args); // // /** // * Called when when a feature is found in epub. // * // * @param resource name of the resource in the epub zip container that has this feature // * or null if the feature is on the container level. // * @param feature a keyword to know what kind of feature has been found // * @param value value found // */ // public void info(String resource, FeatureEnum feature, String value); // // public int getErrorCount(); // // public int getWarningCount(); // // public int getFatalErrorCount(); // // public int getInfoCount(); // // public int getUsageCount(); // // /** // * Called to create a report after the checks have been made // */ // public int generate(); // // /** // * Called when a report if first created // */ // public void initialize(); // // public void setEpubFileName(String value); // // public String getEpubFileName(); // // void setCustomMessageFile(String customMessageFileName); // // String getCustomMessageFile(); // // public int getReportingLevel(); // // public void setReportingLevel(int level); // // void close(); // // void setOverrideFile(File customMessageFile); // // MessageDictionary getDictionary(); // }
import com.adobe.epubcheck.api.Report; import com.adobe.epubcheck.ocf.EncryptionFilter; import com.adobe.epubcheck.util.EPUBVersion; import java.io.IOException; import java.io.InputStream; import java.util.Hashtable; import java.util.Vector; import java.util.zip.ZipEntry; import java.util.zip.ZipFile;
package com.adobe.epubcheck.ctc; /** * === WARNING ==========================================<br/> * This class is scheduled to be refactored and integrated<br/> * in another package.<br/> * Please keep changes minimal (bug fixes only) until then.<br/> * ========================================================<br/> */ abstract class TextSearch { private final Hashtable<String, EncryptionFilter> enc; final ZipFile zip;
// Path: src/main/java/com/adobe/epubcheck/api/Report.java // public interface Report // { // /** // * Called when a violation of the standard is found in epub. // * // * @param id Id of the message being reported // * @param location location information for the message // * @param args Arguments referenced by the format // * string for the message. // */ // public void message(MessageId id, EPUBLocation location, Object... args); // // /** // * Called when a violation of the standard is found in epub. // * // * @param message The message being reported // * @param location location information for the message // * @param args Arguments referenced by the format // * string for the message. // */ // void message(Message message, EPUBLocation location, Object... args); // // /** // * Called when when a feature is found in epub. // * // * @param resource name of the resource in the epub zip container that has this feature // * or null if the feature is on the container level. // * @param feature a keyword to know what kind of feature has been found // * @param value value found // */ // public void info(String resource, FeatureEnum feature, String value); // // public int getErrorCount(); // // public int getWarningCount(); // // public int getFatalErrorCount(); // // public int getInfoCount(); // // public int getUsageCount(); // // /** // * Called to create a report after the checks have been made // */ // public int generate(); // // /** // * Called when a report if first created // */ // public void initialize(); // // public void setEpubFileName(String value); // // public String getEpubFileName(); // // void setCustomMessageFile(String customMessageFileName); // // String getCustomMessageFile(); // // public int getReportingLevel(); // // public void setReportingLevel(int level); // // void close(); // // void setOverrideFile(File customMessageFile); // // MessageDictionary getDictionary(); // } // Path: src/main/java/com/adobe/epubcheck/ctc/TextSearch.java import com.adobe.epubcheck.api.Report; import com.adobe.epubcheck.ocf.EncryptionFilter; import com.adobe.epubcheck.util.EPUBVersion; import java.io.IOException; import java.io.InputStream; import java.util.Hashtable; import java.util.Vector; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; package com.adobe.epubcheck.ctc; /** * === WARNING ==========================================<br/> * This class is scheduled to be refactored and integrated<br/> * in another package.<br/> * Please keep changes minimal (bug fixes only) until then.<br/> * ========================================================<br/> */ abstract class TextSearch { private final Hashtable<String, EncryptionFilter> enc; final ZipFile zip;
final Report report;
w3c/epubcheck
src/test/java/com/adobe/epubcheck/util/SourceSetTest.java
// Path: src/main/java/com/adobe/epubcheck/util/SourceSet.java // public interface ErrorHandler // { // public void error(ParseError error, int position); // } // // Path: src/main/java/com/adobe/epubcheck/util/SourceSet.java // public static enum ParseError // { // NULL_OR_EMPTY, // EMPTY_START, // EMPTY_MIDDLE, // DESCRIPTOR_MIX_WIDTH_DENSITY, // DESCRIPTOR_DENSITY_MORE_THAN_ONCE, // DESCRIPTOR_DENSITY_NEGATIVE, // DESCRIPTOR_DENSITY_NOT_FLOAT, // DESCRIPTOR_WIDTH_MORE_THAN_ONCE, // DESCRIPTOR_WIDTH_SIGNED, // DESCRIPTOR_WIDTH_NOT_INT, // DESCRIPTOR_WIDTH_ZERO, // DESCRIPTOR_FUTURE_H_ZERO, // DESCRIPTOR_FUTURE_H_MORE_THAN_ONCE, // DESCRIPTOR_FUTURE_H_NOT_INT, // DESCRIPTOR_FUTURE_H_WITHOUT_WIDTH, // DESCRIPTOR_FUTURE_H_WITH_DENSITY, // DESCRIPTOR_UNKNOWN_SUFFIX, // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; import java.util.List; import org.junit.Before; import org.junit.Test; import com.adobe.epubcheck.util.SourceSet.ErrorHandler; import com.adobe.epubcheck.util.SourceSet.ParseError;
package com.adobe.epubcheck.util; public class SourceSetTest {
// Path: src/main/java/com/adobe/epubcheck/util/SourceSet.java // public interface ErrorHandler // { // public void error(ParseError error, int position); // } // // Path: src/main/java/com/adobe/epubcheck/util/SourceSet.java // public static enum ParseError // { // NULL_OR_EMPTY, // EMPTY_START, // EMPTY_MIDDLE, // DESCRIPTOR_MIX_WIDTH_DENSITY, // DESCRIPTOR_DENSITY_MORE_THAN_ONCE, // DESCRIPTOR_DENSITY_NEGATIVE, // DESCRIPTOR_DENSITY_NOT_FLOAT, // DESCRIPTOR_WIDTH_MORE_THAN_ONCE, // DESCRIPTOR_WIDTH_SIGNED, // DESCRIPTOR_WIDTH_NOT_INT, // DESCRIPTOR_WIDTH_ZERO, // DESCRIPTOR_FUTURE_H_ZERO, // DESCRIPTOR_FUTURE_H_MORE_THAN_ONCE, // DESCRIPTOR_FUTURE_H_NOT_INT, // DESCRIPTOR_FUTURE_H_WITHOUT_WIDTH, // DESCRIPTOR_FUTURE_H_WITH_DENSITY, // DESCRIPTOR_UNKNOWN_SUFFIX, // } // Path: src/test/java/com/adobe/epubcheck/util/SourceSetTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; import java.util.List; import org.junit.Before; import org.junit.Test; import com.adobe.epubcheck.util.SourceSet.ErrorHandler; import com.adobe.epubcheck.util.SourceSet.ParseError; package com.adobe.epubcheck.util; public class SourceSetTest {
private static class TestErrorHandler implements ErrorHandler