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
|
---|---|---|---|---|---|---|
Sleeksnap/sleeksnap | jkeymaster/com/tulskiy/keymaster/windows/KeyMap.java | // Path: jkeymaster/com/tulskiy/keymaster/windows/User32.java
// public static final int MOD_ALT = 0x0001;
//
// Path: jkeymaster/com/tulskiy/keymaster/windows/User32.java
// public static final int MOD_CONTROL = 0x0002;
//
// Path: jkeymaster/com/tulskiy/keymaster/windows/User32.java
// public static final int MOD_NOREPEAT = 0x4000;
//
// Path: jkeymaster/com/tulskiy/keymaster/windows/User32.java
// public static final int MOD_SHIFT = 0x0004;
//
// Path: jkeymaster/com/tulskiy/keymaster/windows/User32.java
// public static final int MOD_WIN = 0x0008;
//
// Path: jkeymaster/com/tulskiy/keymaster/windows/User32.java
// public static final int VK_MEDIA_NEXT_TRACK = 0xB0;
//
// Path: jkeymaster/com/tulskiy/keymaster/windows/User32.java
// public static final int VK_MEDIA_PLAY_PAUSE = 0xB3;
//
// Path: jkeymaster/com/tulskiy/keymaster/windows/User32.java
// public static final int VK_MEDIA_PREV_TRACK = 0xB1;
//
// Path: jkeymaster/com/tulskiy/keymaster/windows/User32.java
// public static final int VK_MEDIA_STOP = 0xB2;
//
// Path: jkeymaster/com/tulskiy/keymaster/common/HotKey.java
// public class HotKey {
// private KeyStroke keyStroke;
// private MediaKey mediaKey;
// private HotKeyListener listener;
//
// public HotKey(KeyStroke keyStroke, HotKeyListener listener) {
// this.keyStroke = keyStroke;
// this.listener = listener;
// }
//
// public HotKey(MediaKey mediaKey, HotKeyListener listener) {
// this.mediaKey = mediaKey;
// this.listener = listener;
// }
//
// public boolean isMedia() {
// return mediaKey != null;
// }
//
// public KeyStroke getKeyStroke() {
// return keyStroke;
// }
//
// public void setKeyStroke(KeyStroke keyStroke) {
// this.keyStroke = keyStroke;
// }
//
// public MediaKey getMediaKey() {
// return mediaKey;
// }
//
// public void setMediaKey(MediaKey mediaKey) {
// this.mediaKey = mediaKey;
// }
//
// public HotKeyListener getListener() {
// return listener;
// }
//
// public void setListener(HotKeyListener listener) {
// this.listener = listener;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder();
// sb.append("HotKey");
// if (keyStroke != null)
// sb.append("{").append(keyStroke.toString().replaceAll("pressed ", ""));
// if (mediaKey != null)
// sb.append("{").append(mediaKey);
// sb.append('}');
// return sb.toString();
// }
// }
| import static com.tulskiy.keymaster.windows.User32.MOD_ALT;
import static com.tulskiy.keymaster.windows.User32.MOD_CONTROL;
import static com.tulskiy.keymaster.windows.User32.MOD_NOREPEAT;
import static com.tulskiy.keymaster.windows.User32.MOD_SHIFT;
import static com.tulskiy.keymaster.windows.User32.MOD_WIN;
import static com.tulskiy.keymaster.windows.User32.VK_MEDIA_NEXT_TRACK;
import static com.tulskiy.keymaster.windows.User32.VK_MEDIA_PLAY_PAUSE;
import static com.tulskiy.keymaster.windows.User32.VK_MEDIA_PREV_TRACK;
import static com.tulskiy.keymaster.windows.User32.VK_MEDIA_STOP;
import static java.awt.event.KeyEvent.VK_COMMA;
import static java.awt.event.KeyEvent.VK_DELETE;
import static java.awt.event.KeyEvent.VK_ENTER;
import static java.awt.event.KeyEvent.VK_INSERT;
import static java.awt.event.KeyEvent.VK_MINUS;
import static java.awt.event.KeyEvent.VK_PERIOD;
import static java.awt.event.KeyEvent.VK_PLUS;
import static java.awt.event.KeyEvent.VK_PRINTSCREEN;
import static java.awt.event.KeyEvent.VK_SEMICOLON;
import static java.awt.event.KeyEvent.VK_SLASH;
import java.awt.event.InputEvent;
import java.util.HashMap;
import java.util.Map;
import javax.swing.KeyStroke;
import com.tulskiy.keymaster.common.HotKey; |
return code;
} else {
KeyStroke keyStroke = hotKey.getKeyStroke();
Integer code = codeExceptions.get(keyStroke.getKeyCode());
if (code != null) {
return code;
} else
return keyStroke.getKeyCode();
}
}
public static int getModifiers(KeyStroke keyCode) {
int modifiers = 0;
if (keyCode != null) {
if ((keyCode.getModifiers() & InputEvent.SHIFT_DOWN_MASK) != 0) {
modifiers |= MOD_SHIFT;
}
if ((keyCode.getModifiers() & InputEvent.CTRL_DOWN_MASK) != 0) {
modifiers |= MOD_CONTROL;
}
if ((keyCode.getModifiers() & InputEvent.META_DOWN_MASK) != 0) {
modifiers |= MOD_WIN;
}
if ((keyCode.getModifiers() & InputEvent.ALT_DOWN_MASK) != 0) {
modifiers |= MOD_ALT;
}
}
if (System.getProperty("os.name", "").startsWith("Windows 7")) { | // Path: jkeymaster/com/tulskiy/keymaster/windows/User32.java
// public static final int MOD_ALT = 0x0001;
//
// Path: jkeymaster/com/tulskiy/keymaster/windows/User32.java
// public static final int MOD_CONTROL = 0x0002;
//
// Path: jkeymaster/com/tulskiy/keymaster/windows/User32.java
// public static final int MOD_NOREPEAT = 0x4000;
//
// Path: jkeymaster/com/tulskiy/keymaster/windows/User32.java
// public static final int MOD_SHIFT = 0x0004;
//
// Path: jkeymaster/com/tulskiy/keymaster/windows/User32.java
// public static final int MOD_WIN = 0x0008;
//
// Path: jkeymaster/com/tulskiy/keymaster/windows/User32.java
// public static final int VK_MEDIA_NEXT_TRACK = 0xB0;
//
// Path: jkeymaster/com/tulskiy/keymaster/windows/User32.java
// public static final int VK_MEDIA_PLAY_PAUSE = 0xB3;
//
// Path: jkeymaster/com/tulskiy/keymaster/windows/User32.java
// public static final int VK_MEDIA_PREV_TRACK = 0xB1;
//
// Path: jkeymaster/com/tulskiy/keymaster/windows/User32.java
// public static final int VK_MEDIA_STOP = 0xB2;
//
// Path: jkeymaster/com/tulskiy/keymaster/common/HotKey.java
// public class HotKey {
// private KeyStroke keyStroke;
// private MediaKey mediaKey;
// private HotKeyListener listener;
//
// public HotKey(KeyStroke keyStroke, HotKeyListener listener) {
// this.keyStroke = keyStroke;
// this.listener = listener;
// }
//
// public HotKey(MediaKey mediaKey, HotKeyListener listener) {
// this.mediaKey = mediaKey;
// this.listener = listener;
// }
//
// public boolean isMedia() {
// return mediaKey != null;
// }
//
// public KeyStroke getKeyStroke() {
// return keyStroke;
// }
//
// public void setKeyStroke(KeyStroke keyStroke) {
// this.keyStroke = keyStroke;
// }
//
// public MediaKey getMediaKey() {
// return mediaKey;
// }
//
// public void setMediaKey(MediaKey mediaKey) {
// this.mediaKey = mediaKey;
// }
//
// public HotKeyListener getListener() {
// return listener;
// }
//
// public void setListener(HotKeyListener listener) {
// this.listener = listener;
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder();
// sb.append("HotKey");
// if (keyStroke != null)
// sb.append("{").append(keyStroke.toString().replaceAll("pressed ", ""));
// if (mediaKey != null)
// sb.append("{").append(mediaKey);
// sb.append('}');
// return sb.toString();
// }
// }
// Path: jkeymaster/com/tulskiy/keymaster/windows/KeyMap.java
import static com.tulskiy.keymaster.windows.User32.MOD_ALT;
import static com.tulskiy.keymaster.windows.User32.MOD_CONTROL;
import static com.tulskiy.keymaster.windows.User32.MOD_NOREPEAT;
import static com.tulskiy.keymaster.windows.User32.MOD_SHIFT;
import static com.tulskiy.keymaster.windows.User32.MOD_WIN;
import static com.tulskiy.keymaster.windows.User32.VK_MEDIA_NEXT_TRACK;
import static com.tulskiy.keymaster.windows.User32.VK_MEDIA_PLAY_PAUSE;
import static com.tulskiy.keymaster.windows.User32.VK_MEDIA_PREV_TRACK;
import static com.tulskiy.keymaster.windows.User32.VK_MEDIA_STOP;
import static java.awt.event.KeyEvent.VK_COMMA;
import static java.awt.event.KeyEvent.VK_DELETE;
import static java.awt.event.KeyEvent.VK_ENTER;
import static java.awt.event.KeyEvent.VK_INSERT;
import static java.awt.event.KeyEvent.VK_MINUS;
import static java.awt.event.KeyEvent.VK_PERIOD;
import static java.awt.event.KeyEvent.VK_PLUS;
import static java.awt.event.KeyEvent.VK_PRINTSCREEN;
import static java.awt.event.KeyEvent.VK_SEMICOLON;
import static java.awt.event.KeyEvent.VK_SLASH;
import java.awt.event.InputEvent;
import java.util.HashMap;
import java.util.Map;
import javax.swing.KeyStroke;
import com.tulskiy.keymaster.common.HotKey;
return code;
} else {
KeyStroke keyStroke = hotKey.getKeyStroke();
Integer code = codeExceptions.get(keyStroke.getKeyCode());
if (code != null) {
return code;
} else
return keyStroke.getKeyCode();
}
}
public static int getModifiers(KeyStroke keyCode) {
int modifiers = 0;
if (keyCode != null) {
if ((keyCode.getModifiers() & InputEvent.SHIFT_DOWN_MASK) != 0) {
modifiers |= MOD_SHIFT;
}
if ((keyCode.getModifiers() & InputEvent.CTRL_DOWN_MASK) != 0) {
modifiers |= MOD_CONTROL;
}
if ((keyCode.getModifiers() & InputEvent.META_DOWN_MASK) != 0) {
modifiers |= MOD_WIN;
}
if ((keyCode.getModifiers() & InputEvent.ALT_DOWN_MASK) != 0) {
modifiers |= MOD_ALT;
}
}
if (System.getProperty("os.name", "").startsWith("Windows 7")) { | modifiers |= MOD_NOREPEAT; |
Sleeksnap/sleeksnap | src/org/sleeksnap/impl/LoggingManager.java | // Path: src/org/sleeksnap/util/logging/FileLogHandler.java
// public class FileLogHandler extends java.util.logging.Handler {
//
// /**
// * The buffered writer for this logger
// */
// private BufferedWriter writer;
//
// /**
// * A simple file logger!
// */
// public FileLogHandler() {
// configure();
// }
//
// /**
// * Configure the logger
// */
// private void configure() {
// File file = new File(Util.getWorkingDirectory(), "log.txt");
// try {
// writer = new BufferedWriter(new FileWriter(file));
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void publish(LogRecord record) {
// if (getFormatter() == null)
// setFormatter(new SimpleFormatter());
// if (!isLoggable(record)) {
// return;
// }
// try {
// writer.write(getFormatter().format(record));
// } catch (IOException e) {
// e.printStackTrace();
// }
// flush();
// }
//
// @Override
// public void flush() {
// try {
// writer.flush();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void close() throws SecurityException {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/org/sleeksnap/util/logging/LogPanelHandler.java
// public class LogPanelHandler extends java.util.logging.Handler {
//
// private static LogPanel logPanel;
//
// /**
// * A simple file logger!
// */
// public LogPanelHandler() {
// }
//
// @Override
// public void publish(LogRecord record) {
// if(logPanel == null) {
// return;
// }
// if (getFormatter() == null)
// setFormatter(new SimpleFormatter());
//
// if (!isLoggable(record))
// return;
//
// logPanel.appendLog(getFormatter().format(record));
// }
//
// @Override
// public void flush() {
// }
//
// @Override
// public void close() throws SecurityException {
// }
//
// /**
// * Bind this logging handler to a LogPanel instance to update the log screen
// * @param logPanel
// * The panel to bind
// */
// public static void bindTo(LogPanel logPanel) {
// LogPanelHandler.logPanel = logPanel;
// }
//
// /**
// * Unbind the LogPanel instance (Always done when the settings gui is closed)
// */
// public static void unbind() {
// LogPanelHandler.logPanel = null;
// }
// }
| import java.io.IOException;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import org.sleeksnap.util.logging.FileLogHandler;
import org.sleeksnap.util.logging.LogPanelHandler; | /**
* Sleeksnap, the open source cross-platform screenshot uploader
* Copyright (C) 2012 Nikki <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sleeksnap.impl;
/**
* A class to load the logging properties of this application, allows the use of
* file logging for the Log panel
*
* @author Nikki
*
*/
public class LoggingManager {
/**
* Load the configuration from a byte array
* @throws IOException
*/
@SuppressWarnings("unchecked")
public static void configure() throws IOException {
LoggerConfiguration config = new LoggerConfiguration(); | // Path: src/org/sleeksnap/util/logging/FileLogHandler.java
// public class FileLogHandler extends java.util.logging.Handler {
//
// /**
// * The buffered writer for this logger
// */
// private BufferedWriter writer;
//
// /**
// * A simple file logger!
// */
// public FileLogHandler() {
// configure();
// }
//
// /**
// * Configure the logger
// */
// private void configure() {
// File file = new File(Util.getWorkingDirectory(), "log.txt");
// try {
// writer = new BufferedWriter(new FileWriter(file));
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void publish(LogRecord record) {
// if (getFormatter() == null)
// setFormatter(new SimpleFormatter());
// if (!isLoggable(record)) {
// return;
// }
// try {
// writer.write(getFormatter().format(record));
// } catch (IOException e) {
// e.printStackTrace();
// }
// flush();
// }
//
// @Override
// public void flush() {
// try {
// writer.flush();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void close() throws SecurityException {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/org/sleeksnap/util/logging/LogPanelHandler.java
// public class LogPanelHandler extends java.util.logging.Handler {
//
// private static LogPanel logPanel;
//
// /**
// * A simple file logger!
// */
// public LogPanelHandler() {
// }
//
// @Override
// public void publish(LogRecord record) {
// if(logPanel == null) {
// return;
// }
// if (getFormatter() == null)
// setFormatter(new SimpleFormatter());
//
// if (!isLoggable(record))
// return;
//
// logPanel.appendLog(getFormatter().format(record));
// }
//
// @Override
// public void flush() {
// }
//
// @Override
// public void close() throws SecurityException {
// }
//
// /**
// * Bind this logging handler to a LogPanel instance to update the log screen
// * @param logPanel
// * The panel to bind
// */
// public static void bindTo(LogPanel logPanel) {
// LogPanelHandler.logPanel = logPanel;
// }
//
// /**
// * Unbind the LogPanel instance (Always done when the settings gui is closed)
// */
// public static void unbind() {
// LogPanelHandler.logPanel = null;
// }
// }
// Path: src/org/sleeksnap/impl/LoggingManager.java
import java.io.IOException;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import org.sleeksnap.util.logging.FileLogHandler;
import org.sleeksnap.util.logging.LogPanelHandler;
/**
* Sleeksnap, the open source cross-platform screenshot uploader
* Copyright (C) 2012 Nikki <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sleeksnap.impl;
/**
* A class to load the logging properties of this application, allows the use of
* file logging for the Log panel
*
* @author Nikki
*
*/
public class LoggingManager {
/**
* Load the configuration from a byte array
* @throws IOException
*/
@SuppressWarnings("unchecked")
public static void configure() throws IOException {
LoggerConfiguration config = new LoggerConfiguration(); | config.addHandlers(ConsoleHandler.class, FileLogHandler.class, LogPanelHandler.class); |
Sleeksnap/sleeksnap | src/org/sleeksnap/impl/LoggingManager.java | // Path: src/org/sleeksnap/util/logging/FileLogHandler.java
// public class FileLogHandler extends java.util.logging.Handler {
//
// /**
// * The buffered writer for this logger
// */
// private BufferedWriter writer;
//
// /**
// * A simple file logger!
// */
// public FileLogHandler() {
// configure();
// }
//
// /**
// * Configure the logger
// */
// private void configure() {
// File file = new File(Util.getWorkingDirectory(), "log.txt");
// try {
// writer = new BufferedWriter(new FileWriter(file));
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void publish(LogRecord record) {
// if (getFormatter() == null)
// setFormatter(new SimpleFormatter());
// if (!isLoggable(record)) {
// return;
// }
// try {
// writer.write(getFormatter().format(record));
// } catch (IOException e) {
// e.printStackTrace();
// }
// flush();
// }
//
// @Override
// public void flush() {
// try {
// writer.flush();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void close() throws SecurityException {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/org/sleeksnap/util/logging/LogPanelHandler.java
// public class LogPanelHandler extends java.util.logging.Handler {
//
// private static LogPanel logPanel;
//
// /**
// * A simple file logger!
// */
// public LogPanelHandler() {
// }
//
// @Override
// public void publish(LogRecord record) {
// if(logPanel == null) {
// return;
// }
// if (getFormatter() == null)
// setFormatter(new SimpleFormatter());
//
// if (!isLoggable(record))
// return;
//
// logPanel.appendLog(getFormatter().format(record));
// }
//
// @Override
// public void flush() {
// }
//
// @Override
// public void close() throws SecurityException {
// }
//
// /**
// * Bind this logging handler to a LogPanel instance to update the log screen
// * @param logPanel
// * The panel to bind
// */
// public static void bindTo(LogPanel logPanel) {
// LogPanelHandler.logPanel = logPanel;
// }
//
// /**
// * Unbind the LogPanel instance (Always done when the settings gui is closed)
// */
// public static void unbind() {
// LogPanelHandler.logPanel = null;
// }
// }
| import java.io.IOException;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import org.sleeksnap.util.logging.FileLogHandler;
import org.sleeksnap.util.logging.LogPanelHandler; | /**
* Sleeksnap, the open source cross-platform screenshot uploader
* Copyright (C) 2012 Nikki <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sleeksnap.impl;
/**
* A class to load the logging properties of this application, allows the use of
* file logging for the Log panel
*
* @author Nikki
*
*/
public class LoggingManager {
/**
* Load the configuration from a byte array
* @throws IOException
*/
@SuppressWarnings("unchecked")
public static void configure() throws IOException {
LoggerConfiguration config = new LoggerConfiguration(); | // Path: src/org/sleeksnap/util/logging/FileLogHandler.java
// public class FileLogHandler extends java.util.logging.Handler {
//
// /**
// * The buffered writer for this logger
// */
// private BufferedWriter writer;
//
// /**
// * A simple file logger!
// */
// public FileLogHandler() {
// configure();
// }
//
// /**
// * Configure the logger
// */
// private void configure() {
// File file = new File(Util.getWorkingDirectory(), "log.txt");
// try {
// writer = new BufferedWriter(new FileWriter(file));
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void publish(LogRecord record) {
// if (getFormatter() == null)
// setFormatter(new SimpleFormatter());
// if (!isLoggable(record)) {
// return;
// }
// try {
// writer.write(getFormatter().format(record));
// } catch (IOException e) {
// e.printStackTrace();
// }
// flush();
// }
//
// @Override
// public void flush() {
// try {
// writer.flush();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// @Override
// public void close() throws SecurityException {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/org/sleeksnap/util/logging/LogPanelHandler.java
// public class LogPanelHandler extends java.util.logging.Handler {
//
// private static LogPanel logPanel;
//
// /**
// * A simple file logger!
// */
// public LogPanelHandler() {
// }
//
// @Override
// public void publish(LogRecord record) {
// if(logPanel == null) {
// return;
// }
// if (getFormatter() == null)
// setFormatter(new SimpleFormatter());
//
// if (!isLoggable(record))
// return;
//
// logPanel.appendLog(getFormatter().format(record));
// }
//
// @Override
// public void flush() {
// }
//
// @Override
// public void close() throws SecurityException {
// }
//
// /**
// * Bind this logging handler to a LogPanel instance to update the log screen
// * @param logPanel
// * The panel to bind
// */
// public static void bindTo(LogPanel logPanel) {
// LogPanelHandler.logPanel = logPanel;
// }
//
// /**
// * Unbind the LogPanel instance (Always done when the settings gui is closed)
// */
// public static void unbind() {
// LogPanelHandler.logPanel = null;
// }
// }
// Path: src/org/sleeksnap/impl/LoggingManager.java
import java.io.IOException;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import org.sleeksnap.util.logging.FileLogHandler;
import org.sleeksnap.util.logging.LogPanelHandler;
/**
* Sleeksnap, the open source cross-platform screenshot uploader
* Copyright (C) 2012 Nikki <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sleeksnap.impl;
/**
* A class to load the logging properties of this application, allows the use of
* file logging for the Log panel
*
* @author Nikki
*
*/
public class LoggingManager {
/**
* Load the configuration from a byte array
* @throws IOException
*/
@SuppressWarnings("unchecked")
public static void configure() throws IOException {
LoggerConfiguration config = new LoggerConfiguration(); | config.addHandlers(ConsoleHandler.class, FileLogHandler.class, LogPanelHandler.class); |
Sleeksnap/sleeksnap | src/org/sleeksnap/util/active/linux/GnomeWindowUtil.java | // Path: src/org/sleeksnap/util/active/ActiveWindow.java
// public class ActiveWindow {
//
// /**
// * The window name
// */
// private String name;
//
// /**
// * The window's bounds
// */
// private Rectangle bounds;
//
// public ActiveWindow(String name, Rectangle bounds) {
// this.name = name;
// this.bounds = bounds;
// }
//
// /**
// * Get the window's bounds as a rectangle
// * @return
// * A rectangle containing the window's bounds
// */
// public Rectangle getBounds() {
// return bounds;
// }
//
// /**
// * Get the window name
// * @return
// * The window name
// */
// public String getName() {
// return name;
// }
//
// @Override
// public String toString() {
// return name + " [x=" + bounds.x + ",y=" + bounds.y + ",width="
// + bounds.width + ",height=" + bounds.height + "]";
// }
// }
//
// Path: src/org/sleeksnap/util/active/WindowUtil.java
// public interface WindowUtil {
//
// /**
// * Get the active window
// *
// * @return The active desktop window
// * @throws Exception
// * If we failed to get the window
// */
// public ActiveWindow getActiveWindow() throws Exception;
// }
//
// Path: src/org/sleeksnap/util/active/linux/Gtk.java
// public static class GdkRectangle extends Structure {
// public int x;
// public int y;
// public int width;
// public int height;
//
// public Rectangle toRectangle() {
// Rectangle out = new Rectangle(x, y, width, height);
// if (out.x < 0) {
// out.width = out.width + out.x;
// out.x = 0;
// }
// if (out.y < 0) {
// out.height = out.height + out.y;
// out.y = 0;
// }
// return out;
// }
// }
| import org.sleeksnap.util.active.ActiveWindow;
import org.sleeksnap.util.active.WindowUtil;
import org.sleeksnap.util.active.linux.Gtk.GdkRectangle;
import com.sun.jna.Native;
import com.sun.jna.NativeLong; | /**
* Sleeksnap, the open source cross-platform screenshot uploader
* Copyright (C) 2012 Nikki <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sleeksnap.util.active.linux;
/**
* Gets the active window by using Gtk/Gdk functions This method does not return
* a window title, but is still preferred over XPropWindowUtil since it will get
* the window location including the title bar
*
* @author Nikki
*
*/
public class GnomeWindowUtil implements WindowUtil {
private static Gtk gtk;
@Override | // Path: src/org/sleeksnap/util/active/ActiveWindow.java
// public class ActiveWindow {
//
// /**
// * The window name
// */
// private String name;
//
// /**
// * The window's bounds
// */
// private Rectangle bounds;
//
// public ActiveWindow(String name, Rectangle bounds) {
// this.name = name;
// this.bounds = bounds;
// }
//
// /**
// * Get the window's bounds as a rectangle
// * @return
// * A rectangle containing the window's bounds
// */
// public Rectangle getBounds() {
// return bounds;
// }
//
// /**
// * Get the window name
// * @return
// * The window name
// */
// public String getName() {
// return name;
// }
//
// @Override
// public String toString() {
// return name + " [x=" + bounds.x + ",y=" + bounds.y + ",width="
// + bounds.width + ",height=" + bounds.height + "]";
// }
// }
//
// Path: src/org/sleeksnap/util/active/WindowUtil.java
// public interface WindowUtil {
//
// /**
// * Get the active window
// *
// * @return The active desktop window
// * @throws Exception
// * If we failed to get the window
// */
// public ActiveWindow getActiveWindow() throws Exception;
// }
//
// Path: src/org/sleeksnap/util/active/linux/Gtk.java
// public static class GdkRectangle extends Structure {
// public int x;
// public int y;
// public int width;
// public int height;
//
// public Rectangle toRectangle() {
// Rectangle out = new Rectangle(x, y, width, height);
// if (out.x < 0) {
// out.width = out.width + out.x;
// out.x = 0;
// }
// if (out.y < 0) {
// out.height = out.height + out.y;
// out.y = 0;
// }
// return out;
// }
// }
// Path: src/org/sleeksnap/util/active/linux/GnomeWindowUtil.java
import org.sleeksnap.util.active.ActiveWindow;
import org.sleeksnap.util.active.WindowUtil;
import org.sleeksnap.util.active.linux.Gtk.GdkRectangle;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
/**
* Sleeksnap, the open source cross-platform screenshot uploader
* Copyright (C) 2012 Nikki <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sleeksnap.util.active.linux;
/**
* Gets the active window by using Gtk/Gdk functions This method does not return
* a window title, but is still preferred over XPropWindowUtil since it will get
* the window location including the title bar
*
* @author Nikki
*
*/
public class GnomeWindowUtil implements WindowUtil {
private static Gtk gtk;
@Override | public ActiveWindow getActiveWindow() throws Exception { |
Sleeksnap/sleeksnap | src/org/sleeksnap/util/active/linux/GnomeWindowUtil.java | // Path: src/org/sleeksnap/util/active/ActiveWindow.java
// public class ActiveWindow {
//
// /**
// * The window name
// */
// private String name;
//
// /**
// * The window's bounds
// */
// private Rectangle bounds;
//
// public ActiveWindow(String name, Rectangle bounds) {
// this.name = name;
// this.bounds = bounds;
// }
//
// /**
// * Get the window's bounds as a rectangle
// * @return
// * A rectangle containing the window's bounds
// */
// public Rectangle getBounds() {
// return bounds;
// }
//
// /**
// * Get the window name
// * @return
// * The window name
// */
// public String getName() {
// return name;
// }
//
// @Override
// public String toString() {
// return name + " [x=" + bounds.x + ",y=" + bounds.y + ",width="
// + bounds.width + ",height=" + bounds.height + "]";
// }
// }
//
// Path: src/org/sleeksnap/util/active/WindowUtil.java
// public interface WindowUtil {
//
// /**
// * Get the active window
// *
// * @return The active desktop window
// * @throws Exception
// * If we failed to get the window
// */
// public ActiveWindow getActiveWindow() throws Exception;
// }
//
// Path: src/org/sleeksnap/util/active/linux/Gtk.java
// public static class GdkRectangle extends Structure {
// public int x;
// public int y;
// public int width;
// public int height;
//
// public Rectangle toRectangle() {
// Rectangle out = new Rectangle(x, y, width, height);
// if (out.x < 0) {
// out.width = out.width + out.x;
// out.x = 0;
// }
// if (out.y < 0) {
// out.height = out.height + out.y;
// out.y = 0;
// }
// return out;
// }
// }
| import org.sleeksnap.util.active.ActiveWindow;
import org.sleeksnap.util.active.WindowUtil;
import org.sleeksnap.util.active.linux.Gtk.GdkRectangle;
import com.sun.jna.Native;
import com.sun.jna.NativeLong; | /**
* Sleeksnap, the open source cross-platform screenshot uploader
* Copyright (C) 2012 Nikki <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sleeksnap.util.active.linux;
/**
* Gets the active window by using Gtk/Gdk functions This method does not return
* a window title, but is still preferred over XPropWindowUtil since it will get
* the window location including the title bar
*
* @author Nikki
*
*/
public class GnomeWindowUtil implements WindowUtil {
private static Gtk gtk;
@Override
public ActiveWindow getActiveWindow() throws Exception {
if (gtk == null) {
throw new Exception("Gtk library not loaded!");
}
gtk.gtk_init(null, null);
// Display and window are pointers...
NativeLong display = gtk.gdk_screen_get_default();
if (display == null) {
throw new Exception("Unable to find the default screen");
}
// Try to get the active window
NativeLong window = gtk.gdk_screen_get_active_window(display);
// If not, try to get the window under the cursor
if (window == null) {
window = gtk.gdk_window_at_pointer(null, null);
}
// If we didn't find a window, throw an exception
if (window == null) {
throw new Exception("Unable to get the active window!");
}
// Get the frame bounds as a GdkRectangle, why not a structure since
// we'd get it in an int[] the other way | // Path: src/org/sleeksnap/util/active/ActiveWindow.java
// public class ActiveWindow {
//
// /**
// * The window name
// */
// private String name;
//
// /**
// * The window's bounds
// */
// private Rectangle bounds;
//
// public ActiveWindow(String name, Rectangle bounds) {
// this.name = name;
// this.bounds = bounds;
// }
//
// /**
// * Get the window's bounds as a rectangle
// * @return
// * A rectangle containing the window's bounds
// */
// public Rectangle getBounds() {
// return bounds;
// }
//
// /**
// * Get the window name
// * @return
// * The window name
// */
// public String getName() {
// return name;
// }
//
// @Override
// public String toString() {
// return name + " [x=" + bounds.x + ",y=" + bounds.y + ",width="
// + bounds.width + ",height=" + bounds.height + "]";
// }
// }
//
// Path: src/org/sleeksnap/util/active/WindowUtil.java
// public interface WindowUtil {
//
// /**
// * Get the active window
// *
// * @return The active desktop window
// * @throws Exception
// * If we failed to get the window
// */
// public ActiveWindow getActiveWindow() throws Exception;
// }
//
// Path: src/org/sleeksnap/util/active/linux/Gtk.java
// public static class GdkRectangle extends Structure {
// public int x;
// public int y;
// public int width;
// public int height;
//
// public Rectangle toRectangle() {
// Rectangle out = new Rectangle(x, y, width, height);
// if (out.x < 0) {
// out.width = out.width + out.x;
// out.x = 0;
// }
// if (out.y < 0) {
// out.height = out.height + out.y;
// out.y = 0;
// }
// return out;
// }
// }
// Path: src/org/sleeksnap/util/active/linux/GnomeWindowUtil.java
import org.sleeksnap.util.active.ActiveWindow;
import org.sleeksnap.util.active.WindowUtil;
import org.sleeksnap.util.active.linux.Gtk.GdkRectangle;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
/**
* Sleeksnap, the open source cross-platform screenshot uploader
* Copyright (C) 2012 Nikki <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sleeksnap.util.active.linux;
/**
* Gets the active window by using Gtk/Gdk functions This method does not return
* a window title, but is still preferred over XPropWindowUtil since it will get
* the window location including the title bar
*
* @author Nikki
*
*/
public class GnomeWindowUtil implements WindowUtil {
private static Gtk gtk;
@Override
public ActiveWindow getActiveWindow() throws Exception {
if (gtk == null) {
throw new Exception("Gtk library not loaded!");
}
gtk.gtk_init(null, null);
// Display and window are pointers...
NativeLong display = gtk.gdk_screen_get_default();
if (display == null) {
throw new Exception("Unable to find the default screen");
}
// Try to get the active window
NativeLong window = gtk.gdk_screen_get_active_window(display);
// If not, try to get the window under the cursor
if (window == null) {
window = gtk.gdk_window_at_pointer(null, null);
}
// If we didn't find a window, throw an exception
if (window == null) {
throw new Exception("Unable to get the active window!");
}
// Get the frame bounds as a GdkRectangle, why not a structure since
// we'd get it in an int[] the other way | GdkRectangle rect = new GdkRectangle(); |
Sleeksnap/sleeksnap | src/org/sleeksnap/util/active/linux/XPropWindowUtil.java | // Path: src/org/sleeksnap/util/StreamUtils.java
// public class StreamUtils {
//
// /**
// * Read all of the data from an InputStream into a string
// * @param inputStream
// * The stream to read from
// * @return
// * The data, lines separated by \n
// * @throws IOException
// * If a problem occurred while reading
// */
// public static String readContents(InputStream inputStream)
// throws IOException {
// StringBuilder contents = new StringBuilder();
// BufferedReader reader = new BufferedReader(new InputStreamReader(
// inputStream));
// try {
// String line;
// while ((line = reader.readLine()) != null) {
// contents.append(line).append("\n");
// }
// } finally {
// reader.close();
// }
// return contents.toString().trim();
// }
//
// public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException {
// int read;
// byte[] buf = new byte[1024];
// while((read = inputStream.read(buf, 0, buf.length)) != -1) {
// outputStream.write(buf, 0, read);
// }
// }
// }
//
// Path: src/org/sleeksnap/util/active/ActiveWindow.java
// public class ActiveWindow {
//
// /**
// * The window name
// */
// private String name;
//
// /**
// * The window's bounds
// */
// private Rectangle bounds;
//
// public ActiveWindow(String name, Rectangle bounds) {
// this.name = name;
// this.bounds = bounds;
// }
//
// /**
// * Get the window's bounds as a rectangle
// * @return
// * A rectangle containing the window's bounds
// */
// public Rectangle getBounds() {
// return bounds;
// }
//
// /**
// * Get the window name
// * @return
// * The window name
// */
// public String getName() {
// return name;
// }
//
// @Override
// public String toString() {
// return name + " [x=" + bounds.x + ",y=" + bounds.y + ",width="
// + bounds.width + ",height=" + bounds.height + "]";
// }
// }
//
// Path: src/org/sleeksnap/util/active/WindowUtil.java
// public interface WindowUtil {
//
// /**
// * Get the active window
// *
// * @return The active desktop window
// * @throws Exception
// * If we failed to get the window
// */
// public ActiveWindow getActiveWindow() throws Exception;
// }
| import java.awt.Rectangle;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.sleeksnap.util.StreamUtils;
import org.sleeksnap.util.active.ActiveWindow;
import org.sleeksnap.util.active.WindowUtil; | /**
* Sleeksnap, the open source cross-platform screenshot uploader
* Copyright (C) 2012 Nikki <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sleeksnap.util.active.linux;
/**
* A WindowUtil that uses xprop/xwininfo to get the active window bounds. Note:
* This does not include the title bar, which is why GnomeWindowUtil is
* preferred... However, GnomeWindowUtil does not have the actual window title,
* however it is currently not used.
*
* @author Nikki
*
*/
public class XPropWindowUtil implements WindowUtil {
/**
* The pattern to match width/height variables
*/
private static Pattern pattern = Pattern
.compile("Width:\\s*(\\d+)\\s*Height:\\s*(\\d+)");
/**
* The pattern to match the window location (Does not include title bar)
*/
private static Pattern locationPattern = Pattern
.compile("Absolute upper-left X:\\s*(\\d+)\\s*Absolute upper-left Y:\\s*(\\d+)");
/**
* The pattern to match the window name
*/
private static Pattern namePattern = Pattern
.compile("xwininfo\\: Window id\\: .*? \"(.*?)\"");
/**
* The pattern to match the window id from the xprop -root command
*/
private static Pattern windowid = Pattern
.compile("_NET_ACTIVE_WINDOW\\(WINDOW\\): window id # (.*)");
@Override | // Path: src/org/sleeksnap/util/StreamUtils.java
// public class StreamUtils {
//
// /**
// * Read all of the data from an InputStream into a string
// * @param inputStream
// * The stream to read from
// * @return
// * The data, lines separated by \n
// * @throws IOException
// * If a problem occurred while reading
// */
// public static String readContents(InputStream inputStream)
// throws IOException {
// StringBuilder contents = new StringBuilder();
// BufferedReader reader = new BufferedReader(new InputStreamReader(
// inputStream));
// try {
// String line;
// while ((line = reader.readLine()) != null) {
// contents.append(line).append("\n");
// }
// } finally {
// reader.close();
// }
// return contents.toString().trim();
// }
//
// public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException {
// int read;
// byte[] buf = new byte[1024];
// while((read = inputStream.read(buf, 0, buf.length)) != -1) {
// outputStream.write(buf, 0, read);
// }
// }
// }
//
// Path: src/org/sleeksnap/util/active/ActiveWindow.java
// public class ActiveWindow {
//
// /**
// * The window name
// */
// private String name;
//
// /**
// * The window's bounds
// */
// private Rectangle bounds;
//
// public ActiveWindow(String name, Rectangle bounds) {
// this.name = name;
// this.bounds = bounds;
// }
//
// /**
// * Get the window's bounds as a rectangle
// * @return
// * A rectangle containing the window's bounds
// */
// public Rectangle getBounds() {
// return bounds;
// }
//
// /**
// * Get the window name
// * @return
// * The window name
// */
// public String getName() {
// return name;
// }
//
// @Override
// public String toString() {
// return name + " [x=" + bounds.x + ",y=" + bounds.y + ",width="
// + bounds.width + ",height=" + bounds.height + "]";
// }
// }
//
// Path: src/org/sleeksnap/util/active/WindowUtil.java
// public interface WindowUtil {
//
// /**
// * Get the active window
// *
// * @return The active desktop window
// * @throws Exception
// * If we failed to get the window
// */
// public ActiveWindow getActiveWindow() throws Exception;
// }
// Path: src/org/sleeksnap/util/active/linux/XPropWindowUtil.java
import java.awt.Rectangle;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.sleeksnap.util.StreamUtils;
import org.sleeksnap.util.active.ActiveWindow;
import org.sleeksnap.util.active.WindowUtil;
/**
* Sleeksnap, the open source cross-platform screenshot uploader
* Copyright (C) 2012 Nikki <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sleeksnap.util.active.linux;
/**
* A WindowUtil that uses xprop/xwininfo to get the active window bounds. Note:
* This does not include the title bar, which is why GnomeWindowUtil is
* preferred... However, GnomeWindowUtil does not have the actual window title,
* however it is currently not used.
*
* @author Nikki
*
*/
public class XPropWindowUtil implements WindowUtil {
/**
* The pattern to match width/height variables
*/
private static Pattern pattern = Pattern
.compile("Width:\\s*(\\d+)\\s*Height:\\s*(\\d+)");
/**
* The pattern to match the window location (Does not include title bar)
*/
private static Pattern locationPattern = Pattern
.compile("Absolute upper-left X:\\s*(\\d+)\\s*Absolute upper-left Y:\\s*(\\d+)");
/**
* The pattern to match the window name
*/
private static Pattern namePattern = Pattern
.compile("xwininfo\\: Window id\\: .*? \"(.*?)\"");
/**
* The pattern to match the window id from the xprop -root command
*/
private static Pattern windowid = Pattern
.compile("_NET_ACTIVE_WINDOW\\(WINDOW\\): window id # (.*)");
@Override | public ActiveWindow getActiveWindow() throws Exception { |
Sleeksnap/sleeksnap | src/org/sleeksnap/util/active/linux/XPropWindowUtil.java | // Path: src/org/sleeksnap/util/StreamUtils.java
// public class StreamUtils {
//
// /**
// * Read all of the data from an InputStream into a string
// * @param inputStream
// * The stream to read from
// * @return
// * The data, lines separated by \n
// * @throws IOException
// * If a problem occurred while reading
// */
// public static String readContents(InputStream inputStream)
// throws IOException {
// StringBuilder contents = new StringBuilder();
// BufferedReader reader = new BufferedReader(new InputStreamReader(
// inputStream));
// try {
// String line;
// while ((line = reader.readLine()) != null) {
// contents.append(line).append("\n");
// }
// } finally {
// reader.close();
// }
// return contents.toString().trim();
// }
//
// public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException {
// int read;
// byte[] buf = new byte[1024];
// while((read = inputStream.read(buf, 0, buf.length)) != -1) {
// outputStream.write(buf, 0, read);
// }
// }
// }
//
// Path: src/org/sleeksnap/util/active/ActiveWindow.java
// public class ActiveWindow {
//
// /**
// * The window name
// */
// private String name;
//
// /**
// * The window's bounds
// */
// private Rectangle bounds;
//
// public ActiveWindow(String name, Rectangle bounds) {
// this.name = name;
// this.bounds = bounds;
// }
//
// /**
// * Get the window's bounds as a rectangle
// * @return
// * A rectangle containing the window's bounds
// */
// public Rectangle getBounds() {
// return bounds;
// }
//
// /**
// * Get the window name
// * @return
// * The window name
// */
// public String getName() {
// return name;
// }
//
// @Override
// public String toString() {
// return name + " [x=" + bounds.x + ",y=" + bounds.y + ",width="
// + bounds.width + ",height=" + bounds.height + "]";
// }
// }
//
// Path: src/org/sleeksnap/util/active/WindowUtil.java
// public interface WindowUtil {
//
// /**
// * Get the active window
// *
// * @return The active desktop window
// * @throws Exception
// * If we failed to get the window
// */
// public ActiveWindow getActiveWindow() throws Exception;
// }
| import java.awt.Rectangle;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.sleeksnap.util.StreamUtils;
import org.sleeksnap.util.active.ActiveWindow;
import org.sleeksnap.util.active.WindowUtil; | throw new Exception("XWinInfo did not provide location info!");
}
int x = Integer.parseInt(matcher.group(1));
int y = Integer.parseInt(matcher.group(2));
matcher = pattern.matcher(resp);
if (!matcher.find()) {
throw new Exception("XWinInfo did not provide size info!");
}
int width = Integer.parseInt(matcher.group(1));
int height = Integer.parseInt(matcher.group(2));
// Return a new ActiveWindow object
return new ActiveWindow(name, new Rectangle(x, y, width, height));
}
/**
* Execute a command and get the response
*
* @param cmdline
* The command to be run
* @return The output of the comman
* @throws IOException
* If an error occurred while reading from the process
* @throws InterruptedException
* If the process is interrupted while waiting
*/
public static String runProcess(String cmdline) throws IOException,
InterruptedException {
Process p = Runtime.getRuntime().exec(cmdline);
p.waitFor();
try { | // Path: src/org/sleeksnap/util/StreamUtils.java
// public class StreamUtils {
//
// /**
// * Read all of the data from an InputStream into a string
// * @param inputStream
// * The stream to read from
// * @return
// * The data, lines separated by \n
// * @throws IOException
// * If a problem occurred while reading
// */
// public static String readContents(InputStream inputStream)
// throws IOException {
// StringBuilder contents = new StringBuilder();
// BufferedReader reader = new BufferedReader(new InputStreamReader(
// inputStream));
// try {
// String line;
// while ((line = reader.readLine()) != null) {
// contents.append(line).append("\n");
// }
// } finally {
// reader.close();
// }
// return contents.toString().trim();
// }
//
// public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException {
// int read;
// byte[] buf = new byte[1024];
// while((read = inputStream.read(buf, 0, buf.length)) != -1) {
// outputStream.write(buf, 0, read);
// }
// }
// }
//
// Path: src/org/sleeksnap/util/active/ActiveWindow.java
// public class ActiveWindow {
//
// /**
// * The window name
// */
// private String name;
//
// /**
// * The window's bounds
// */
// private Rectangle bounds;
//
// public ActiveWindow(String name, Rectangle bounds) {
// this.name = name;
// this.bounds = bounds;
// }
//
// /**
// * Get the window's bounds as a rectangle
// * @return
// * A rectangle containing the window's bounds
// */
// public Rectangle getBounds() {
// return bounds;
// }
//
// /**
// * Get the window name
// * @return
// * The window name
// */
// public String getName() {
// return name;
// }
//
// @Override
// public String toString() {
// return name + " [x=" + bounds.x + ",y=" + bounds.y + ",width="
// + bounds.width + ",height=" + bounds.height + "]";
// }
// }
//
// Path: src/org/sleeksnap/util/active/WindowUtil.java
// public interface WindowUtil {
//
// /**
// * Get the active window
// *
// * @return The active desktop window
// * @throws Exception
// * If we failed to get the window
// */
// public ActiveWindow getActiveWindow() throws Exception;
// }
// Path: src/org/sleeksnap/util/active/linux/XPropWindowUtil.java
import java.awt.Rectangle;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.sleeksnap.util.StreamUtils;
import org.sleeksnap.util.active.ActiveWindow;
import org.sleeksnap.util.active.WindowUtil;
throw new Exception("XWinInfo did not provide location info!");
}
int x = Integer.parseInt(matcher.group(1));
int y = Integer.parseInt(matcher.group(2));
matcher = pattern.matcher(resp);
if (!matcher.find()) {
throw new Exception("XWinInfo did not provide size info!");
}
int width = Integer.parseInt(matcher.group(1));
int height = Integer.parseInt(matcher.group(2));
// Return a new ActiveWindow object
return new ActiveWindow(name, new Rectangle(x, y, width, height));
}
/**
* Execute a command and get the response
*
* @param cmdline
* The command to be run
* @return The output of the comman
* @throws IOException
* If an error occurred while reading from the process
* @throws InterruptedException
* If the process is interrupted while waiting
*/
public static String runProcess(String cmdline) throws IOException,
InterruptedException {
Process p = Runtime.getRuntime().exec(cmdline);
p.waitFor();
try { | return StreamUtils.readContents(p.getInputStream()); |
Sleeksnap/sleeksnap | src/org/sleeksnap/uploaders/settings/Setting.java | // Path: src/org/sleeksnap/uploaders/settings/types/AutoDetectSettingType.java
// public class AutoDetectSettingType implements UploaderSettingType {
//
// @Override
// public JComponent constructComponent(String[] defaults) {
// return null;
// }
//
// @Override
// public void setValue(JComponent component, Object value) {
// }
//
// @Override
// public Object getValue(JComponent component) {
// return null;
// }
//
// }
| import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.sleeksnap.uploaders.settings.types.AutoDetectSettingType; | package org.sleeksnap.uploaders.settings;
/**
* Defines a Setting, this is only used in the {@link ParametersDialog}
*
* @author Nikki
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Setting {
public String name();
public String description() default "";
public boolean optional() default false;
| // Path: src/org/sleeksnap/uploaders/settings/types/AutoDetectSettingType.java
// public class AutoDetectSettingType implements UploaderSettingType {
//
// @Override
// public JComponent constructComponent(String[] defaults) {
// return null;
// }
//
// @Override
// public void setValue(JComponent component, Object value) {
// }
//
// @Override
// public Object getValue(JComponent component) {
// return null;
// }
//
// }
// Path: src/org/sleeksnap/uploaders/settings/Setting.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.sleeksnap.uploaders.settings.types.AutoDetectSettingType;
package org.sleeksnap.uploaders.settings;
/**
* Defines a Setting, this is only used in the {@link ParametersDialog}
*
* @author Nikki
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Setting {
public String name();
public String description() default "";
public boolean optional() default false;
| public Class<? extends UploaderSettingType> type() default AutoDetectSettingType.class; |
Sleeksnap/sleeksnap | src/org/sleeksnap/util/ScreenshotUtil.java | // Path: src/org/sleeksnap/util/Utils.java
// public static class DisplayUtil {
//
// /**
// * Get the real screen size, multiple screens..
// *
// * @return The screen size
// */
// public static Rectangle getRealScreenSize() {
// GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
// GraphicsDevice[] screens = ge.getScreenDevices();
//
// Rectangle allScreenBounds = new Rectangle();
// for (GraphicsDevice screen : screens) {
// Rectangle screenBounds = screen.getDefaultConfiguration().getBounds();
//
// allScreenBounds.width += screenBounds.width;
// allScreenBounds.height = Math.max(allScreenBounds.height, screenBounds.height);
//
// if (screenBounds.x < allScreenBounds.y || screenBounds.y < allScreenBounds.y) {
// allScreenBounds.x = Math.min(allScreenBounds.x, screenBounds.x);
// allScreenBounds.y = Math.min(allScreenBounds.y, screenBounds.y);
// }
// }
// return allScreenBounds;
// }
//
// /**
// * Get the real screen size, multiple screens..
// *
// * @return The screen size
// */
// public static Rectangle[] getAllScreenBounds() {
// GraphicsEnvironment ge = GraphicsEnvironment
// .getLocalGraphicsEnvironment();
// GraphicsDevice[] screens = ge.getScreenDevices();
//
// Rectangle[] allScreenBounds = new Rectangle[screens.length];
// for (int i = 0; i < screens.length; i++) {
// allScreenBounds[i] = screens[i].getDefaultConfiguration().getBounds();
// }
// return allScreenBounds;
// }
// }
| import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import org.sleeksnap.util.Utils.DisplayUtil; | /**
* Sleeksnap, the open source cross-platform screenshot uploader
* Copyright (C) 2012 Nikki <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sleeksnap.util;
/**
* A basic screenshot utility
*
* @author Nikki
*
*/
public class ScreenshotUtil {
/**
* The robot instance
*/
private static Robot robot;
/**
* Initialize it..
*/
static {
try {
robot = new Robot();
} catch (AWTException e) {
// We can't run without this!
throw new RuntimeException(
"Robot not initialized, shutting down...");
}
}
/**
* Capture a simple screenshot
*
* @return The screenshot
*/
public static BufferedImage capture() { | // Path: src/org/sleeksnap/util/Utils.java
// public static class DisplayUtil {
//
// /**
// * Get the real screen size, multiple screens..
// *
// * @return The screen size
// */
// public static Rectangle getRealScreenSize() {
// GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
// GraphicsDevice[] screens = ge.getScreenDevices();
//
// Rectangle allScreenBounds = new Rectangle();
// for (GraphicsDevice screen : screens) {
// Rectangle screenBounds = screen.getDefaultConfiguration().getBounds();
//
// allScreenBounds.width += screenBounds.width;
// allScreenBounds.height = Math.max(allScreenBounds.height, screenBounds.height);
//
// if (screenBounds.x < allScreenBounds.y || screenBounds.y < allScreenBounds.y) {
// allScreenBounds.x = Math.min(allScreenBounds.x, screenBounds.x);
// allScreenBounds.y = Math.min(allScreenBounds.y, screenBounds.y);
// }
// }
// return allScreenBounds;
// }
//
// /**
// * Get the real screen size, multiple screens..
// *
// * @return The screen size
// */
// public static Rectangle[] getAllScreenBounds() {
// GraphicsEnvironment ge = GraphicsEnvironment
// .getLocalGraphicsEnvironment();
// GraphicsDevice[] screens = ge.getScreenDevices();
//
// Rectangle[] allScreenBounds = new Rectangle[screens.length];
// for (int i = 0; i < screens.length; i++) {
// allScreenBounds[i] = screens[i].getDefaultConfiguration().getBounds();
// }
// return allScreenBounds;
// }
// }
// Path: src/org/sleeksnap/util/ScreenshotUtil.java
import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import org.sleeksnap.util.Utils.DisplayUtil;
/**
* Sleeksnap, the open source cross-platform screenshot uploader
* Copyright (C) 2012 Nikki <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sleeksnap.util;
/**
* A basic screenshot utility
*
* @author Nikki
*
*/
public class ScreenshotUtil {
/**
* The robot instance
*/
private static Robot robot;
/**
* Initialize it..
*/
static {
try {
robot = new Robot();
} catch (AWTException e) {
// We can't run without this!
throw new RuntimeException(
"Robot not initialized, shutting down...");
}
}
/**
* Capture a simple screenshot
*
* @return The screenshot
*/
public static BufferedImage capture() { | return capture(DisplayUtil.getRealScreenSize()); |
Sleeksnap/sleeksnap | src/org/sleeksnap/util/Util.java | // Path: src/org/sleeksnap/Constants.java
// public class Constants {
// public static class Application {
// public static final String NAME = "Sleeksnap";
// public static final String URL = "http://sleeksnap.com";
// public static final String UPDATE_URL = "http://sleeksnap.com/build/";
// }
//
// public static class Configuration {
// public static final String FILE_NAME = Application.NAME.toLowerCase()
// + ".conf";
//
// public static final int DEFAULT_MAX_RETRIES = 3;
//
// public static final String DEFAULT_LANGUAGE = "english";
// }
//
// public static class Resources {
// public static final String LOGO_PATH = "/logo.png";
// public static final String ICON_PATH = "/icon.png";
// public static final String ICON_BUSY_PATH = "/icon-busy.png";
//
// public static final URL ICON = Util.getResourceByName(Resources.ICON_PATH);
// public static final URL ICON_BUSY = Util.getResourceByName(Resources.ICON_BUSY_PATH);
//
// public static final Image ICON_IMAGE = Toolkit.getDefaultToolkit().getImage(ICON);
// public static final Image ICON_BUSY_IMAGE = Toolkit.getDefaultToolkit().getImage(ICON_BUSY);
// }
//
// public static class Version {
// public static final int MAJOR = 1;
// public static final int MINOR = 4;
// public static final int PATCH = 9;
//
// private static String versionString = null;
//
// public static String getVersionString() {
// if(versionString == null) {
// // Construct string normally
// versionString = MAJOR + "." + MINOR + "." + PATCH;
// }
// return versionString;
// }
// }
// }
//
// Path: src/org/sleeksnap/Constants.java
// public static class Application {
// public static final String NAME = "Sleeksnap";
// public static final String URL = "http://sleeksnap.com";
// public static final String UPDATE_URL = "http://sleeksnap.com/build/";
// }
//
// Path: src/org/sleeksnap/Constants.java
// public static class Version {
// public static final int MAJOR = 1;
// public static final int MINOR = 4;
// public static final int PATCH = 9;
//
// private static String versionString = null;
//
// public static String getVersionString() {
// if(versionString == null) {
// // Construct string normally
// versionString = MAJOR + "." + MINOR + "." + PATCH;
// }
// return versionString;
// }
// }
| import org.sleeksnap.Constants;
import org.sleeksnap.Constants.Application;
import org.sleeksnap.Constants.Version;
import java.awt.Desktop;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.io.File;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.swing.JFrame;
import javax.swing.UIManager; | /**
* Sleeksnap, the open source cross-platform screenshot uploader
* Copyright (C) 2012 Nikki <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sleeksnap.util;
/**
* A basic utility class
*
* @author Nikki
*
*/
public class Util {
/**
* An enum containing operating system types
*
* @author Nikki
*
*/
public static enum OperatingSystem {
LINUX, SOLARIS, WINDOWS, MAC, UNKNOWN
}
/**
* The cached operating system
*/
public static final OperatingSystem SYSTEM = getPlatform();
/**
* The saved working directory
*/
private static File workDir;
/**
* A method to get the unix time...
* @return
* The current time in seconds
*/
public static long currentTimeSeconds() {
return (System.currentTimeMillis() / 1000);
}
/**
* Get the last part of a class name
*
* @param key
* The full name
* @return The class name formatted
*/
public static String formatClassName(Class<?> key) {
return key.getName().substring(key.getName().lastIndexOf('.') + 1);
}
/**
* Get the computer's user agent
*
*/
public static String getHttpUserAgent() { | // Path: src/org/sleeksnap/Constants.java
// public class Constants {
// public static class Application {
// public static final String NAME = "Sleeksnap";
// public static final String URL = "http://sleeksnap.com";
// public static final String UPDATE_URL = "http://sleeksnap.com/build/";
// }
//
// public static class Configuration {
// public static final String FILE_NAME = Application.NAME.toLowerCase()
// + ".conf";
//
// public static final int DEFAULT_MAX_RETRIES = 3;
//
// public static final String DEFAULT_LANGUAGE = "english";
// }
//
// public static class Resources {
// public static final String LOGO_PATH = "/logo.png";
// public static final String ICON_PATH = "/icon.png";
// public static final String ICON_BUSY_PATH = "/icon-busy.png";
//
// public static final URL ICON = Util.getResourceByName(Resources.ICON_PATH);
// public static final URL ICON_BUSY = Util.getResourceByName(Resources.ICON_BUSY_PATH);
//
// public static final Image ICON_IMAGE = Toolkit.getDefaultToolkit().getImage(ICON);
// public static final Image ICON_BUSY_IMAGE = Toolkit.getDefaultToolkit().getImage(ICON_BUSY);
// }
//
// public static class Version {
// public static final int MAJOR = 1;
// public static final int MINOR = 4;
// public static final int PATCH = 9;
//
// private static String versionString = null;
//
// public static String getVersionString() {
// if(versionString == null) {
// // Construct string normally
// versionString = MAJOR + "." + MINOR + "." + PATCH;
// }
// return versionString;
// }
// }
// }
//
// Path: src/org/sleeksnap/Constants.java
// public static class Application {
// public static final String NAME = "Sleeksnap";
// public static final String URL = "http://sleeksnap.com";
// public static final String UPDATE_URL = "http://sleeksnap.com/build/";
// }
//
// Path: src/org/sleeksnap/Constants.java
// public static class Version {
// public static final int MAJOR = 1;
// public static final int MINOR = 4;
// public static final int PATCH = 9;
//
// private static String versionString = null;
//
// public static String getVersionString() {
// if(versionString == null) {
// // Construct string normally
// versionString = MAJOR + "." + MINOR + "." + PATCH;
// }
// return versionString;
// }
// }
// Path: src/org/sleeksnap/util/Util.java
import org.sleeksnap.Constants;
import org.sleeksnap.Constants.Application;
import org.sleeksnap.Constants.Version;
import java.awt.Desktop;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.io.File;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.swing.JFrame;
import javax.swing.UIManager;
/**
* Sleeksnap, the open source cross-platform screenshot uploader
* Copyright (C) 2012 Nikki <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sleeksnap.util;
/**
* A basic utility class
*
* @author Nikki
*
*/
public class Util {
/**
* An enum containing operating system types
*
* @author Nikki
*
*/
public static enum OperatingSystem {
LINUX, SOLARIS, WINDOWS, MAC, UNKNOWN
}
/**
* The cached operating system
*/
public static final OperatingSystem SYSTEM = getPlatform();
/**
* The saved working directory
*/
private static File workDir;
/**
* A method to get the unix time...
* @return
* The current time in seconds
*/
public static long currentTimeSeconds() {
return (System.currentTimeMillis() / 1000);
}
/**
* Get the last part of a class name
*
* @param key
* The full name
* @return The class name formatted
*/
public static String formatClassName(Class<?> key) {
return key.getName().substring(key.getName().lastIndexOf('.') + 1);
}
/**
* Get the computer's user agent
*
*/
public static String getHttpUserAgent() { | return Application.NAME + " v" + Version.getVersionString(); |
Sleeksnap/sleeksnap | src/org/sleeksnap/util/Util.java | // Path: src/org/sleeksnap/Constants.java
// public class Constants {
// public static class Application {
// public static final String NAME = "Sleeksnap";
// public static final String URL = "http://sleeksnap.com";
// public static final String UPDATE_URL = "http://sleeksnap.com/build/";
// }
//
// public static class Configuration {
// public static final String FILE_NAME = Application.NAME.toLowerCase()
// + ".conf";
//
// public static final int DEFAULT_MAX_RETRIES = 3;
//
// public static final String DEFAULT_LANGUAGE = "english";
// }
//
// public static class Resources {
// public static final String LOGO_PATH = "/logo.png";
// public static final String ICON_PATH = "/icon.png";
// public static final String ICON_BUSY_PATH = "/icon-busy.png";
//
// public static final URL ICON = Util.getResourceByName(Resources.ICON_PATH);
// public static final URL ICON_BUSY = Util.getResourceByName(Resources.ICON_BUSY_PATH);
//
// public static final Image ICON_IMAGE = Toolkit.getDefaultToolkit().getImage(ICON);
// public static final Image ICON_BUSY_IMAGE = Toolkit.getDefaultToolkit().getImage(ICON_BUSY);
// }
//
// public static class Version {
// public static final int MAJOR = 1;
// public static final int MINOR = 4;
// public static final int PATCH = 9;
//
// private static String versionString = null;
//
// public static String getVersionString() {
// if(versionString == null) {
// // Construct string normally
// versionString = MAJOR + "." + MINOR + "." + PATCH;
// }
// return versionString;
// }
// }
// }
//
// Path: src/org/sleeksnap/Constants.java
// public static class Application {
// public static final String NAME = "Sleeksnap";
// public static final String URL = "http://sleeksnap.com";
// public static final String UPDATE_URL = "http://sleeksnap.com/build/";
// }
//
// Path: src/org/sleeksnap/Constants.java
// public static class Version {
// public static final int MAJOR = 1;
// public static final int MINOR = 4;
// public static final int PATCH = 9;
//
// private static String versionString = null;
//
// public static String getVersionString() {
// if(versionString == null) {
// // Construct string normally
// versionString = MAJOR + "." + MINOR + "." + PATCH;
// }
// return versionString;
// }
// }
| import org.sleeksnap.Constants;
import org.sleeksnap.Constants.Application;
import org.sleeksnap.Constants.Version;
import java.awt.Desktop;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.io.File;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.swing.JFrame;
import javax.swing.UIManager; | /**
* Sleeksnap, the open source cross-platform screenshot uploader
* Copyright (C) 2012 Nikki <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sleeksnap.util;
/**
* A basic utility class
*
* @author Nikki
*
*/
public class Util {
/**
* An enum containing operating system types
*
* @author Nikki
*
*/
public static enum OperatingSystem {
LINUX, SOLARIS, WINDOWS, MAC, UNKNOWN
}
/**
* The cached operating system
*/
public static final OperatingSystem SYSTEM = getPlatform();
/**
* The saved working directory
*/
private static File workDir;
/**
* A method to get the unix time...
* @return
* The current time in seconds
*/
public static long currentTimeSeconds() {
return (System.currentTimeMillis() / 1000);
}
/**
* Get the last part of a class name
*
* @param key
* The full name
* @return The class name formatted
*/
public static String formatClassName(Class<?> key) {
return key.getName().substring(key.getName().lastIndexOf('.') + 1);
}
/**
* Get the computer's user agent
*
*/
public static String getHttpUserAgent() { | // Path: src/org/sleeksnap/Constants.java
// public class Constants {
// public static class Application {
// public static final String NAME = "Sleeksnap";
// public static final String URL = "http://sleeksnap.com";
// public static final String UPDATE_URL = "http://sleeksnap.com/build/";
// }
//
// public static class Configuration {
// public static final String FILE_NAME = Application.NAME.toLowerCase()
// + ".conf";
//
// public static final int DEFAULT_MAX_RETRIES = 3;
//
// public static final String DEFAULT_LANGUAGE = "english";
// }
//
// public static class Resources {
// public static final String LOGO_PATH = "/logo.png";
// public static final String ICON_PATH = "/icon.png";
// public static final String ICON_BUSY_PATH = "/icon-busy.png";
//
// public static final URL ICON = Util.getResourceByName(Resources.ICON_PATH);
// public static final URL ICON_BUSY = Util.getResourceByName(Resources.ICON_BUSY_PATH);
//
// public static final Image ICON_IMAGE = Toolkit.getDefaultToolkit().getImage(ICON);
// public static final Image ICON_BUSY_IMAGE = Toolkit.getDefaultToolkit().getImage(ICON_BUSY);
// }
//
// public static class Version {
// public static final int MAJOR = 1;
// public static final int MINOR = 4;
// public static final int PATCH = 9;
//
// private static String versionString = null;
//
// public static String getVersionString() {
// if(versionString == null) {
// // Construct string normally
// versionString = MAJOR + "." + MINOR + "." + PATCH;
// }
// return versionString;
// }
// }
// }
//
// Path: src/org/sleeksnap/Constants.java
// public static class Application {
// public static final String NAME = "Sleeksnap";
// public static final String URL = "http://sleeksnap.com";
// public static final String UPDATE_URL = "http://sleeksnap.com/build/";
// }
//
// Path: src/org/sleeksnap/Constants.java
// public static class Version {
// public static final int MAJOR = 1;
// public static final int MINOR = 4;
// public static final int PATCH = 9;
//
// private static String versionString = null;
//
// public static String getVersionString() {
// if(versionString == null) {
// // Construct string normally
// versionString = MAJOR + "." + MINOR + "." + PATCH;
// }
// return versionString;
// }
// }
// Path: src/org/sleeksnap/util/Util.java
import org.sleeksnap.Constants;
import org.sleeksnap.Constants.Application;
import org.sleeksnap.Constants.Version;
import java.awt.Desktop;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.io.File;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.swing.JFrame;
import javax.swing.UIManager;
/**
* Sleeksnap, the open source cross-platform screenshot uploader
* Copyright (C) 2012 Nikki <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sleeksnap.util;
/**
* A basic utility class
*
* @author Nikki
*
*/
public class Util {
/**
* An enum containing operating system types
*
* @author Nikki
*
*/
public static enum OperatingSystem {
LINUX, SOLARIS, WINDOWS, MAC, UNKNOWN
}
/**
* The cached operating system
*/
public static final OperatingSystem SYSTEM = getPlatform();
/**
* The saved working directory
*/
private static File workDir;
/**
* A method to get the unix time...
* @return
* The current time in seconds
*/
public static long currentTimeSeconds() {
return (System.currentTimeMillis() / 1000);
}
/**
* Get the last part of a class name
*
* @param key
* The full name
* @return The class name formatted
*/
public static String formatClassName(Class<?> key) {
return key.getName().substring(key.getName().lastIndexOf('.') + 1);
}
/**
* Get the computer's user agent
*
*/
public static String getHttpUserAgent() { | return Application.NAME + " v" + Version.getVersionString(); |
Sleeksnap/sleeksnap | src/org/sleeksnap/util/Util.java | // Path: src/org/sleeksnap/Constants.java
// public class Constants {
// public static class Application {
// public static final String NAME = "Sleeksnap";
// public static final String URL = "http://sleeksnap.com";
// public static final String UPDATE_URL = "http://sleeksnap.com/build/";
// }
//
// public static class Configuration {
// public static final String FILE_NAME = Application.NAME.toLowerCase()
// + ".conf";
//
// public static final int DEFAULT_MAX_RETRIES = 3;
//
// public static final String DEFAULT_LANGUAGE = "english";
// }
//
// public static class Resources {
// public static final String LOGO_PATH = "/logo.png";
// public static final String ICON_PATH = "/icon.png";
// public static final String ICON_BUSY_PATH = "/icon-busy.png";
//
// public static final URL ICON = Util.getResourceByName(Resources.ICON_PATH);
// public static final URL ICON_BUSY = Util.getResourceByName(Resources.ICON_BUSY_PATH);
//
// public static final Image ICON_IMAGE = Toolkit.getDefaultToolkit().getImage(ICON);
// public static final Image ICON_BUSY_IMAGE = Toolkit.getDefaultToolkit().getImage(ICON_BUSY);
// }
//
// public static class Version {
// public static final int MAJOR = 1;
// public static final int MINOR = 4;
// public static final int PATCH = 9;
//
// private static String versionString = null;
//
// public static String getVersionString() {
// if(versionString == null) {
// // Construct string normally
// versionString = MAJOR + "." + MINOR + "." + PATCH;
// }
// return versionString;
// }
// }
// }
//
// Path: src/org/sleeksnap/Constants.java
// public static class Application {
// public static final String NAME = "Sleeksnap";
// public static final String URL = "http://sleeksnap.com";
// public static final String UPDATE_URL = "http://sleeksnap.com/build/";
// }
//
// Path: src/org/sleeksnap/Constants.java
// public static class Version {
// public static final int MAJOR = 1;
// public static final int MINOR = 4;
// public static final int PATCH = 9;
//
// private static String versionString = null;
//
// public static String getVersionString() {
// if(versionString == null) {
// // Construct string normally
// versionString = MAJOR + "." + MINOR + "." + PATCH;
// }
// return versionString;
// }
// }
| import org.sleeksnap.Constants;
import org.sleeksnap.Constants.Application;
import org.sleeksnap.Constants.Version;
import java.awt.Desktop;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.io.File;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.swing.JFrame;
import javax.swing.UIManager; | } else {
File file = null;
if ((file = new File("resources" + name)).exists() || (file = new File(Util.getWorkingDirectory(), "resources" + name)).exists()) {
try {
return file.toURI().toURL();
} catch (Exception e) {
e.printStackTrace();
}
}
}
return null;
}
/**
* Get the system architecture
*
* @return The system architecture integer
*/
public static int getSystemArch() {
String archs = System.getProperty("os.arch");
return Integer.parseInt(archs.substring(archs.length() - 2));
}
/**
* Get the current working directory
*
* @return The working directory for the application
*/
public static File getWorkingDirectory() {
if (workDir == null) | // Path: src/org/sleeksnap/Constants.java
// public class Constants {
// public static class Application {
// public static final String NAME = "Sleeksnap";
// public static final String URL = "http://sleeksnap.com";
// public static final String UPDATE_URL = "http://sleeksnap.com/build/";
// }
//
// public static class Configuration {
// public static final String FILE_NAME = Application.NAME.toLowerCase()
// + ".conf";
//
// public static final int DEFAULT_MAX_RETRIES = 3;
//
// public static final String DEFAULT_LANGUAGE = "english";
// }
//
// public static class Resources {
// public static final String LOGO_PATH = "/logo.png";
// public static final String ICON_PATH = "/icon.png";
// public static final String ICON_BUSY_PATH = "/icon-busy.png";
//
// public static final URL ICON = Util.getResourceByName(Resources.ICON_PATH);
// public static final URL ICON_BUSY = Util.getResourceByName(Resources.ICON_BUSY_PATH);
//
// public static final Image ICON_IMAGE = Toolkit.getDefaultToolkit().getImage(ICON);
// public static final Image ICON_BUSY_IMAGE = Toolkit.getDefaultToolkit().getImage(ICON_BUSY);
// }
//
// public static class Version {
// public static final int MAJOR = 1;
// public static final int MINOR = 4;
// public static final int PATCH = 9;
//
// private static String versionString = null;
//
// public static String getVersionString() {
// if(versionString == null) {
// // Construct string normally
// versionString = MAJOR + "." + MINOR + "." + PATCH;
// }
// return versionString;
// }
// }
// }
//
// Path: src/org/sleeksnap/Constants.java
// public static class Application {
// public static final String NAME = "Sleeksnap";
// public static final String URL = "http://sleeksnap.com";
// public static final String UPDATE_URL = "http://sleeksnap.com/build/";
// }
//
// Path: src/org/sleeksnap/Constants.java
// public static class Version {
// public static final int MAJOR = 1;
// public static final int MINOR = 4;
// public static final int PATCH = 9;
//
// private static String versionString = null;
//
// public static String getVersionString() {
// if(versionString == null) {
// // Construct string normally
// versionString = MAJOR + "." + MINOR + "." + PATCH;
// }
// return versionString;
// }
// }
// Path: src/org/sleeksnap/util/Util.java
import org.sleeksnap.Constants;
import org.sleeksnap.Constants.Application;
import org.sleeksnap.Constants.Version;
import java.awt.Desktop;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.io.File;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.swing.JFrame;
import javax.swing.UIManager;
} else {
File file = null;
if ((file = new File("resources" + name)).exists() || (file = new File(Util.getWorkingDirectory(), "resources" + name)).exists()) {
try {
return file.toURI().toURL();
} catch (Exception e) {
e.printStackTrace();
}
}
}
return null;
}
/**
* Get the system architecture
*
* @return The system architecture integer
*/
public static int getSystemArch() {
String archs = System.getProperty("os.arch");
return Integer.parseInt(archs.substring(archs.length() - 2));
}
/**
* Get the current working directory
*
* @return The working directory for the application
*/
public static File getWorkingDirectory() {
if (workDir == null) | workDir = getWorkingDirectory(Constants.Application.NAME |
eviltester/testtoolhub | src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/CounterString.java | // Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/CounterStringCreator.java
// public interface CounterStringCreator {
// void append(String nextPart);
// void finished();
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/StringCounterStringCreator.java
// public class StringCounterStringCreator implements CounterStringCreator {
//
// private final StringBuilder string;
//
// public StringCounterStringCreator(){
// string = new StringBuilder();
//
// }
//
// @Override
// public void append(String nextPart) {
// string.append(nextPart);
// }
//
// @Override
// public void finished() {
// // string is ready to output now
// }
//
// @Override
// public String toString() {
// return string.toString();
// }
// }
| import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.CounterStringCreator;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.StringCounterStringCreator;
import java.util.List; | package uk.co.compendiumdev.javafortesters.domain.counterstrings;
/**
* Created by alan on 08/12/2014.
*/
public class CounterString {
/*
forward counterstring algorithm
assumptions - blocks of numbers are lengths of strings
35* is length 3
so 2 digit numbers are represented as 3 chars
2* is length 2
so 1 digit numbers are represented as 2 chars
if 35* then how many 3 digit strings are there?
9
why?
2*4*6*8*11*14*17*20*23*26*29*32*35*
35 - 10 = 25
25/3 = 8.33
int(8.3) = 8 + 1 = 9 * 3 char numbers
9 * 3 = 27
35-27 = 8
7 is not a 3 char number so lowest 3 char number is 8 + 3 = 11
lowest 3 char number is 11
so highest 2 char number is
8 (11 - 3)
with 1-9, when odd start with 1
, when even start with 2
if 34* then
*3*5*7*10*13*16*19*22*25*28*31*34*
9 3 chars
34-10 - 24
24/3 = 8
int(8) = 8 + 1 = 9 * 3 char numbers
3*9 = 27
34-27 = 7
7 is not a 3 char number so lowest 3 char number is 7 + 3 = 10
lowest 3 char number is 10
so highest 2 char number is
7 (10 - 3)
with 1-9, when odd start with 1
, when even start with 2
if 33* then
*3*5*7*9*12*15*18*21*24*27*30*33*
8 3 chars
33-10 - 23
23/3 = 7.
int(7.) = 7 + 1 = 8 * 3 char numbers
lowest 3 char number is 12
3*8 - 24
33 - 24 = 9
9 is not a 3 char number so next 3 char number is 9+3 = 12
if 10* then
1 3 chars
10-10 = 0
0/3 = 0
how many 2 chars?
lowest 3 char number is 10
so highest 2 char number is
7 (10 - 3)
with 1-9, when odd start with 1
, when even start with 2
*/
public String create(int length) throws CounterStringCreationError {
return create(length,"*");
}
public String create(int lengthOfCounterString, String limiter) throws CounterStringCreationError {
| // Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/CounterStringCreator.java
// public interface CounterStringCreator {
// void append(String nextPart);
// void finished();
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/StringCounterStringCreator.java
// public class StringCounterStringCreator implements CounterStringCreator {
//
// private final StringBuilder string;
//
// public StringCounterStringCreator(){
// string = new StringBuilder();
//
// }
//
// @Override
// public void append(String nextPart) {
// string.append(nextPart);
// }
//
// @Override
// public void finished() {
// // string is ready to output now
// }
//
// @Override
// public String toString() {
// return string.toString();
// }
// }
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/CounterString.java
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.CounterStringCreator;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.StringCounterStringCreator;
import java.util.List;
package uk.co.compendiumdev.javafortesters.domain.counterstrings;
/**
* Created by alan on 08/12/2014.
*/
public class CounterString {
/*
forward counterstring algorithm
assumptions - blocks of numbers are lengths of strings
35* is length 3
so 2 digit numbers are represented as 3 chars
2* is length 2
so 1 digit numbers are represented as 2 chars
if 35* then how many 3 digit strings are there?
9
why?
2*4*6*8*11*14*17*20*23*26*29*32*35*
35 - 10 = 25
25/3 = 8.33
int(8.3) = 8 + 1 = 9 * 3 char numbers
9 * 3 = 27
35-27 = 8
7 is not a 3 char number so lowest 3 char number is 8 + 3 = 11
lowest 3 char number is 11
so highest 2 char number is
8 (11 - 3)
with 1-9, when odd start with 1
, when even start with 2
if 34* then
*3*5*7*10*13*16*19*22*25*28*31*34*
9 3 chars
34-10 - 24
24/3 = 8
int(8) = 8 + 1 = 9 * 3 char numbers
3*9 = 27
34-27 = 7
7 is not a 3 char number so lowest 3 char number is 7 + 3 = 10
lowest 3 char number is 10
so highest 2 char number is
7 (10 - 3)
with 1-9, when odd start with 1
, when even start with 2
if 33* then
*3*5*7*9*12*15*18*21*24*27*30*33*
8 3 chars
33-10 - 23
23/3 = 7.
int(7.) = 7 + 1 = 8 * 3 char numbers
lowest 3 char number is 12
3*8 - 24
33 - 24 = 9
9 is not a 3 char number so next 3 char number is 9+3 = 12
if 10* then
1 3 chars
10-10 = 0
0/3 = 0
how many 2 chars?
lowest 3 char number is 10
so highest 2 char number is
7 (10 - 3)
with 1-9, when odd start with 1
, when even start with 2
*/
public String create(int length) throws CounterStringCreationError {
return create(length,"*");
}
public String create(int lengthOfCounterString, String limiter) throws CounterStringCreationError {
| return createWith(lengthOfCounterString, limiter, new StringCounterStringCreator()).toString(); |
eviltester/testtoolhub | src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/CounterString.java | // Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/CounterStringCreator.java
// public interface CounterStringCreator {
// void append(String nextPart);
// void finished();
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/StringCounterStringCreator.java
// public class StringCounterStringCreator implements CounterStringCreator {
//
// private final StringBuilder string;
//
// public StringCounterStringCreator(){
// string = new StringBuilder();
//
// }
//
// @Override
// public void append(String nextPart) {
// string.append(nextPart);
// }
//
// @Override
// public void finished() {
// // string is ready to output now
// }
//
// @Override
// public String toString() {
// return string.toString();
// }
// }
| import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.CounterStringCreator;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.StringCounterStringCreator;
import java.util.List; | package uk.co.compendiumdev.javafortesters.domain.counterstrings;
/**
* Created by alan on 08/12/2014.
*/
public class CounterString {
/*
forward counterstring algorithm
assumptions - blocks of numbers are lengths of strings
35* is length 3
so 2 digit numbers are represented as 3 chars
2* is length 2
so 1 digit numbers are represented as 2 chars
if 35* then how many 3 digit strings are there?
9
why?
2*4*6*8*11*14*17*20*23*26*29*32*35*
35 - 10 = 25
25/3 = 8.33
int(8.3) = 8 + 1 = 9 * 3 char numbers
9 * 3 = 27
35-27 = 8
7 is not a 3 char number so lowest 3 char number is 8 + 3 = 11
lowest 3 char number is 11
so highest 2 char number is
8 (11 - 3)
with 1-9, when odd start with 1
, when even start with 2
if 34* then
*3*5*7*10*13*16*19*22*25*28*31*34*
9 3 chars
34-10 - 24
24/3 = 8
int(8) = 8 + 1 = 9 * 3 char numbers
3*9 = 27
34-27 = 7
7 is not a 3 char number so lowest 3 char number is 7 + 3 = 10
lowest 3 char number is 10
so highest 2 char number is
7 (10 - 3)
with 1-9, when odd start with 1
, when even start with 2
if 33* then
*3*5*7*9*12*15*18*21*24*27*30*33*
8 3 chars
33-10 - 23
23/3 = 7.
int(7.) = 7 + 1 = 8 * 3 char numbers
lowest 3 char number is 12
3*8 - 24
33 - 24 = 9
9 is not a 3 char number so next 3 char number is 9+3 = 12
if 10* then
1 3 chars
10-10 = 0
0/3 = 0
how many 2 chars?
lowest 3 char number is 10
so highest 2 char number is
7 (10 - 3)
with 1-9, when odd start with 1
, when even start with 2
*/
public String create(int length) throws CounterStringCreationError {
return create(length,"*");
}
public String create(int lengthOfCounterString, String limiter) throws CounterStringCreationError {
return createWith(lengthOfCounterString, limiter, new StringCounterStringCreator()).toString();
}
| // Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/CounterStringCreator.java
// public interface CounterStringCreator {
// void append(String nextPart);
// void finished();
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/StringCounterStringCreator.java
// public class StringCounterStringCreator implements CounterStringCreator {
//
// private final StringBuilder string;
//
// public StringCounterStringCreator(){
// string = new StringBuilder();
//
// }
//
// @Override
// public void append(String nextPart) {
// string.append(nextPart);
// }
//
// @Override
// public void finished() {
// // string is ready to output now
// }
//
// @Override
// public String toString() {
// return string.toString();
// }
// }
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/CounterString.java
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.CounterStringCreator;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.StringCounterStringCreator;
import java.util.List;
package uk.co.compendiumdev.javafortesters.domain.counterstrings;
/**
* Created by alan on 08/12/2014.
*/
public class CounterString {
/*
forward counterstring algorithm
assumptions - blocks of numbers are lengths of strings
35* is length 3
so 2 digit numbers are represented as 3 chars
2* is length 2
so 1 digit numbers are represented as 2 chars
if 35* then how many 3 digit strings are there?
9
why?
2*4*6*8*11*14*17*20*23*26*29*32*35*
35 - 10 = 25
25/3 = 8.33
int(8.3) = 8 + 1 = 9 * 3 char numbers
9 * 3 = 27
35-27 = 8
7 is not a 3 char number so lowest 3 char number is 8 + 3 = 11
lowest 3 char number is 11
so highest 2 char number is
8 (11 - 3)
with 1-9, when odd start with 1
, when even start with 2
if 34* then
*3*5*7*10*13*16*19*22*25*28*31*34*
9 3 chars
34-10 - 24
24/3 = 8
int(8) = 8 + 1 = 9 * 3 char numbers
3*9 = 27
34-27 = 7
7 is not a 3 char number so lowest 3 char number is 7 + 3 = 10
lowest 3 char number is 10
so highest 2 char number is
7 (10 - 3)
with 1-9, when odd start with 1
, when even start with 2
if 33* then
*3*5*7*9*12*15*18*21*24*27*30*33*
8 3 chars
33-10 - 23
23/3 = 7.
int(7.) = 7 + 1 = 8 * 3 char numbers
lowest 3 char number is 12
3*8 - 24
33 - 24 = 9
9 is not a 3 char number so next 3 char number is 9+3 = 12
if 10* then
1 3 chars
10-10 = 0
0/3 = 0
how many 2 chars?
lowest 3 char number is 10
so highest 2 char number is
7 (10 - 3)
with 1-9, when odd start with 1
, when even start with 2
*/
public String create(int length) throws CounterStringCreationError {
return create(length,"*");
}
public String create(int lengthOfCounterString, String limiter) throws CounterStringCreationError {
return createWith(lengthOfCounterString, limiter, new StringCounterStringCreator()).toString();
}
| public CounterStringCreator createWith(int lengthOfCounterString, String limiter, CounterStringCreator creator) throws CounterStringCreationError { |
eviltester/testtoolhub | src/main/java/uk/co/compendiumdev/javafortesters/gui/awtbridge/RobotTyper.java | // Path: src/main/java/uk/co/compendiumdev/javafortesters/gui/javafx/Config.java
// public class Config {
//
// public static int getDefaultWindowWidth(){
// return 600;
// }
//
// public static int getDefaultWindowHeight(){
// return 200;
// }
//
// // string of paired characters, first is the 'wanted' char, next is the 'shifted' char
// // escaped modifier in string representation are at the end
// private static String defaultShiftModifiers = "~`!1@2$4%5^6&7*8(9)0_-+={[}]:;<,>.?/" + '"' + "'" + "|" + '\\';
//
// // £3
// // had to take £ out of the above as it failed when added to the default config
//
// public static String currentShiftModifiers = defaultShiftModifiers;
//
// public static String getCurrentShiftModifiers() {
// return currentShiftModifiers;
// }
//
// public static void setCurrentShiftModifiers(String currentShiftModifiers) {
// Config.currentShiftModifiers = currentShiftModifiers;
// }
//
// public static String getDefaultShiftModifiers() {
// return defaultShiftModifiers;
// }
// }
| import uk.co.compendiumdev.javafortesters.gui.javafx.Config;
import java.awt.*;
import java.util.HashSet;
import java.util.Set; |
public Robot getRobot(){
if(this.robot==null) {
try {
this.robot = new Robot();
} catch (AWTException e) {
e.printStackTrace();
}
}
return this.robot;
}
public boolean hasAnotherCharToType(){
if(this.textToType!=null && this.currentChar<this.textToType.length()){
return true;
}
return false;
}
public void setTextToType(String textToType) {
this.textToType = textToType;
this.currentChar = 0;
this.totalChars = textToType.length();
collateCouldNotTypeKeys();
awtKeys = new AwtKeyBridge(getRobot()); | // Path: src/main/java/uk/co/compendiumdev/javafortesters/gui/javafx/Config.java
// public class Config {
//
// public static int getDefaultWindowWidth(){
// return 600;
// }
//
// public static int getDefaultWindowHeight(){
// return 200;
// }
//
// // string of paired characters, first is the 'wanted' char, next is the 'shifted' char
// // escaped modifier in string representation are at the end
// private static String defaultShiftModifiers = "~`!1@2$4%5^6&7*8(9)0_-+={[}]:;<,>.?/" + '"' + "'" + "|" + '\\';
//
// // £3
// // had to take £ out of the above as it failed when added to the default config
//
// public static String currentShiftModifiers = defaultShiftModifiers;
//
// public static String getCurrentShiftModifiers() {
// return currentShiftModifiers;
// }
//
// public static void setCurrentShiftModifiers(String currentShiftModifiers) {
// Config.currentShiftModifiers = currentShiftModifiers;
// }
//
// public static String getDefaultShiftModifiers() {
// return defaultShiftModifiers;
// }
// }
// Path: src/main/java/uk/co/compendiumdev/javafortesters/gui/awtbridge/RobotTyper.java
import uk.co.compendiumdev.javafortesters.gui.javafx.Config;
import java.awt.*;
import java.util.HashSet;
import java.util.Set;
public Robot getRobot(){
if(this.robot==null) {
try {
this.robot = new Robot();
} catch (AWTException e) {
e.printStackTrace();
}
}
return this.robot;
}
public boolean hasAnotherCharToType(){
if(this.textToType!=null && this.currentChar<this.textToType.length()){
return true;
}
return false;
}
public void setTextToType(String textToType) {
this.textToType = textToType;
this.currentChar = 0;
this.totalChars = textToType.length();
collateCouldNotTypeKeys();
awtKeys = new AwtKeyBridge(getRobot()); | awtKeys.setShiftModifiers(Config.getCurrentShiftModifiers()); |
eviltester/testtoolhub | src/main/java/uk/co/compendiumdev/javafortesters/domain/cannedtext/CannedText.java | // Path: src/main/java/uk/co/compendiumdev/javafortesters/files/InputStreamReaderUtils.java
// public class InputStreamReaderUtils {
//
// public static String stringFromStream(InputStream in) throws IOException
// {
// BufferedReader reader = new BufferedReader(new java.io.InputStreamReader(in));
// StringBuilder out = new StringBuilder();
// String newLine = System.getProperty("line.separator");
// String line;
// while ((line = reader.readLine()) != null) {
// out.append(line);
// out.append(newLine);
// }
// return out.toString();
// }
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/tree/TreeBranch.java
// public class TreeBranch<T> {
// private final ArrayList<TreeBranch> children;
// private T leaf;
// private String label;
//
// public TreeBranch(){
// this("branch");
// }
//
// public TreeBranch(String label){
// this(label, null);
// }
//
// public TreeBranch(String label, T entity) {
// this.leaf = entity;
// this.label = label;
// this.children = new ArrayList<TreeBranch>();
// }
//
// public boolean isLeaf() {
// return leaf!=null;
// }
//
// public String getLabel() {
// return label;
// }
//
// public void setLabel(String label) {
// this.label = label;
// }
//
// public TreeBranch addChild(String branchLabel) {
// TreeBranch<T> child = new TreeBranch<T>(branchLabel);
// children.add(child);
// return child;
// }
//
// public TreeBranch addChild(String branchLabel, T entity){
// TreeBranch<T> child = new TreeBranch<T>(branchLabel, entity);
// children.add(child);
// return child;
// }
//
// public int countChildren() {
// return children.size();
// }
//
// public T getLeaf() {
// return leaf;
// }
//
// public String toString(){
// return stringify(0);
//
// }
//
// private String stringify(int indent) {
// StringBuilder out = new StringBuilder();
//
// for(int i=0; i<indent; i++){
// out.append(" ");
// }
//
// out.append(label).append("\n");
//
// for(TreeBranch child : children){
// out.append(child.stringify(indent+1));
// }
//
// return out.toString();
// }
//
//
// public ArrayList<TreeBranch> getChildren() {
// return children;
// }
//
// public void addChild(TreeBranch<T> lastBranch) {
// children.add(lastBranch);
// }
// }
| import uk.co.compendiumdev.javafortesters.files.InputStreamReaderUtils;
import uk.co.compendiumdev.javafortesters.domain.tree.TreeBranch;
import java.io.*;
import java.util.ArrayList; | package uk.co.compendiumdev.javafortesters.domain.cannedtext;
/**
* Created by Alan on 27/02/2015.
*/
public class CannedText {
private static TreeBranch<CannedTextItem> defaultTree;
public static TreeBranch<CannedTextItem> getDefaultTree() {
TreeBranch<CannedTextItem> root = null;
// does a resource file exist?
if(CannedText.class.getResource("defaultCannedText.txt")!=null){
InputStream defaultStream = CannedText.class.getResourceAsStream("defaultCannedText.txt");
try { | // Path: src/main/java/uk/co/compendiumdev/javafortesters/files/InputStreamReaderUtils.java
// public class InputStreamReaderUtils {
//
// public static String stringFromStream(InputStream in) throws IOException
// {
// BufferedReader reader = new BufferedReader(new java.io.InputStreamReader(in));
// StringBuilder out = new StringBuilder();
// String newLine = System.getProperty("line.separator");
// String line;
// while ((line = reader.readLine()) != null) {
// out.append(line);
// out.append(newLine);
// }
// return out.toString();
// }
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/tree/TreeBranch.java
// public class TreeBranch<T> {
// private final ArrayList<TreeBranch> children;
// private T leaf;
// private String label;
//
// public TreeBranch(){
// this("branch");
// }
//
// public TreeBranch(String label){
// this(label, null);
// }
//
// public TreeBranch(String label, T entity) {
// this.leaf = entity;
// this.label = label;
// this.children = new ArrayList<TreeBranch>();
// }
//
// public boolean isLeaf() {
// return leaf!=null;
// }
//
// public String getLabel() {
// return label;
// }
//
// public void setLabel(String label) {
// this.label = label;
// }
//
// public TreeBranch addChild(String branchLabel) {
// TreeBranch<T> child = new TreeBranch<T>(branchLabel);
// children.add(child);
// return child;
// }
//
// public TreeBranch addChild(String branchLabel, T entity){
// TreeBranch<T> child = new TreeBranch<T>(branchLabel, entity);
// children.add(child);
// return child;
// }
//
// public int countChildren() {
// return children.size();
// }
//
// public T getLeaf() {
// return leaf;
// }
//
// public String toString(){
// return stringify(0);
//
// }
//
// private String stringify(int indent) {
// StringBuilder out = new StringBuilder();
//
// for(int i=0; i<indent; i++){
// out.append(" ");
// }
//
// out.append(label).append("\n");
//
// for(TreeBranch child : children){
// out.append(child.stringify(indent+1));
// }
//
// return out.toString();
// }
//
//
// public ArrayList<TreeBranch> getChildren() {
// return children;
// }
//
// public void addChild(TreeBranch<T> lastBranch) {
// children.add(lastBranch);
// }
// }
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/cannedtext/CannedText.java
import uk.co.compendiumdev.javafortesters.files.InputStreamReaderUtils;
import uk.co.compendiumdev.javafortesters.domain.tree.TreeBranch;
import java.io.*;
import java.util.ArrayList;
package uk.co.compendiumdev.javafortesters.domain.cannedtext;
/**
* Created by Alan on 27/02/2015.
*/
public class CannedText {
private static TreeBranch<CannedTextItem> defaultTree;
public static TreeBranch<CannedTextItem> getDefaultTree() {
TreeBranch<CannedTextItem> root = null;
// does a resource file exist?
if(CannedText.class.getResource("defaultCannedText.txt")!=null){
InputStream defaultStream = CannedText.class.getResourceAsStream("defaultCannedText.txt");
try { | String cannedText = InputStreamReaderUtils.stringFromStream(defaultStream); |
eviltester/testtoolhub | src/main/java/uk/co/compendiumdev/javafortesters/gui/javafx/stages/ConfigEditStage.java | // Path: src/main/java/uk/co/compendiumdev/javafortesters/gui/javafx/Config.java
// public class Config {
//
// public static int getDefaultWindowWidth(){
// return 600;
// }
//
// public static int getDefaultWindowHeight(){
// return 200;
// }
//
// // string of paired characters, first is the 'wanted' char, next is the 'shifted' char
// // escaped modifier in string representation are at the end
// private static String defaultShiftModifiers = "~`!1@2$4%5^6&7*8(9)0_-+={[}]:;<,>.?/" + '"' + "'" + "|" + '\\';
//
// // £3
// // had to take £ out of the above as it failed when added to the default config
//
// public static String currentShiftModifiers = defaultShiftModifiers;
//
// public static String getCurrentShiftModifiers() {
// return currentShiftModifiers;
// }
//
// public static void setCurrentShiftModifiers(String currentShiftModifiers) {
// Config.currentShiftModifiers = currentShiftModifiers;
// }
//
// public static String getDefaultShiftModifiers() {
// return defaultShiftModifiers;
// }
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/gui/javafx/utils/JavaFX.java
// public class JavaFX {
//
// public static Button button(String text, String tooltip) {
// Button abutton = new Button();
// abutton.setText(text);
// abutton.setTooltip(new Tooltip(tooltip));
// return abutton;
// }
//
// public static TextField textField(String text, String tooltip) {
// TextField aTextField = new TextField ();
// aTextField.setText(text);
// aTextField.setTooltip(new Tooltip(tooltip));
// return aTextField;
// }
//
// public static TextField textField(String text, String tooltip, int maxWidth) {
// TextField aTextField = textField(text, tooltip);
// aTextField.setMaxWidth(maxWidth);
// return aTextField;
// }
//
// public static void alertErrorDialogWithException(Throwable ex, String title) {
// Alert alert = new Alert(Alert.AlertType.ERROR);
// alert.setTitle("Exception Dialog");
// alert.setHeaderText(title);
// alert.setContentText(ex.getMessage());
//
// // Create expandable Exception.
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// ex.printStackTrace(pw);
// String exceptionText = sw.toString();
//
// Label label = new Label("The exception stacktrace was:");
//
// TextArea textArea = new TextArea(exceptionText);
// textArea.setEditable(false);
// textArea.setWrapText(true);
//
// textArea.setMaxWidth(Double.MAX_VALUE);
// textArea.setMaxHeight(Double.MAX_VALUE);
// GridPane.setVgrow(textArea, Priority.ALWAYS);
// GridPane.setHgrow(textArea, Priority.ALWAYS);
//
// GridPane expContent = new GridPane();
// expContent.setMaxWidth(Double.MAX_VALUE);
// expContent.add(label, 0, 0);
// expContent.add(textArea, 0, 1);
//
// // Set expandable Exception into the dialog pane.
// alert.getDialogPane().setExpandableContent(expContent);
//
// alert.showAndWait();
//
// }
// public static void alertErrorDialogWithException(Throwable ex) {
// alertErrorDialogWithException(ex, "General Exception");
// }
//
// public static void showSimpleErrorAlert(String title, String message) {
// // http://code.makery.ch/blog/javafx-dialogs-official/
// Alert alert = new Alert(Alert.AlertType.ERROR);
// alert.setTitle(title);
// alert.setHeaderText(null);
// alert.setContentText(message);
// alert.showAndWait();
//
// }
//
// public static void sendTextToClipboard(String textToSend) {
// Clipboard clipboard = Clipboard.getSystemClipboard();
// clipboard.clear();
// ClipboardContent content = new ClipboardContent();
// content.putString(textToSend);
// clipboard.setContent(content);
// }
// }
| import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
import uk.co.compendiumdev.javafortesters.gui.javafx.Config;
import uk.co.compendiumdev.javafortesters.gui.javafx.utils.JavaFX; | package uk.co.compendiumdev.javafortesters.gui.javafx.stages;
/*
20170306 knocked up quick typer for my use
Not ready for prime time
- does not handle upper case
- does not handle special chars (except * which is hard coded
- when fix this then can enable in MainGui
*/
public class ConfigEditStage extends Stage {
private static ConfigEditStage configEditStage =null;
public static void singletonActivate(){
if(configEditStage ==null)
configEditStage = new ConfigEditStage(false);
configEditStage.show();
configEditStage.requestFocus();
}
public static EventHandler<ActionEvent> getActivationEvent() {
return new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
ConfigEditStage.singletonActivate();
}
};
}
public ConfigEditStage(boolean hidden) {
BorderPane root = new BorderPane();
HBox modifiersControl = new HBox();
final Label modifiersLabel = new Label("Shift Modifiers:"); | // Path: src/main/java/uk/co/compendiumdev/javafortesters/gui/javafx/Config.java
// public class Config {
//
// public static int getDefaultWindowWidth(){
// return 600;
// }
//
// public static int getDefaultWindowHeight(){
// return 200;
// }
//
// // string of paired characters, first is the 'wanted' char, next is the 'shifted' char
// // escaped modifier in string representation are at the end
// private static String defaultShiftModifiers = "~`!1@2$4%5^6&7*8(9)0_-+={[}]:;<,>.?/" + '"' + "'" + "|" + '\\';
//
// // £3
// // had to take £ out of the above as it failed when added to the default config
//
// public static String currentShiftModifiers = defaultShiftModifiers;
//
// public static String getCurrentShiftModifiers() {
// return currentShiftModifiers;
// }
//
// public static void setCurrentShiftModifiers(String currentShiftModifiers) {
// Config.currentShiftModifiers = currentShiftModifiers;
// }
//
// public static String getDefaultShiftModifiers() {
// return defaultShiftModifiers;
// }
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/gui/javafx/utils/JavaFX.java
// public class JavaFX {
//
// public static Button button(String text, String tooltip) {
// Button abutton = new Button();
// abutton.setText(text);
// abutton.setTooltip(new Tooltip(tooltip));
// return abutton;
// }
//
// public static TextField textField(String text, String tooltip) {
// TextField aTextField = new TextField ();
// aTextField.setText(text);
// aTextField.setTooltip(new Tooltip(tooltip));
// return aTextField;
// }
//
// public static TextField textField(String text, String tooltip, int maxWidth) {
// TextField aTextField = textField(text, tooltip);
// aTextField.setMaxWidth(maxWidth);
// return aTextField;
// }
//
// public static void alertErrorDialogWithException(Throwable ex, String title) {
// Alert alert = new Alert(Alert.AlertType.ERROR);
// alert.setTitle("Exception Dialog");
// alert.setHeaderText(title);
// alert.setContentText(ex.getMessage());
//
// // Create expandable Exception.
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// ex.printStackTrace(pw);
// String exceptionText = sw.toString();
//
// Label label = new Label("The exception stacktrace was:");
//
// TextArea textArea = new TextArea(exceptionText);
// textArea.setEditable(false);
// textArea.setWrapText(true);
//
// textArea.setMaxWidth(Double.MAX_VALUE);
// textArea.setMaxHeight(Double.MAX_VALUE);
// GridPane.setVgrow(textArea, Priority.ALWAYS);
// GridPane.setHgrow(textArea, Priority.ALWAYS);
//
// GridPane expContent = new GridPane();
// expContent.setMaxWidth(Double.MAX_VALUE);
// expContent.add(label, 0, 0);
// expContent.add(textArea, 0, 1);
//
// // Set expandable Exception into the dialog pane.
// alert.getDialogPane().setExpandableContent(expContent);
//
// alert.showAndWait();
//
// }
// public static void alertErrorDialogWithException(Throwable ex) {
// alertErrorDialogWithException(ex, "General Exception");
// }
//
// public static void showSimpleErrorAlert(String title, String message) {
// // http://code.makery.ch/blog/javafx-dialogs-official/
// Alert alert = new Alert(Alert.AlertType.ERROR);
// alert.setTitle(title);
// alert.setHeaderText(null);
// alert.setContentText(message);
// alert.showAndWait();
//
// }
//
// public static void sendTextToClipboard(String textToSend) {
// Clipboard clipboard = Clipboard.getSystemClipboard();
// clipboard.clear();
// ClipboardContent content = new ClipboardContent();
// content.putString(textToSend);
// clipboard.setContent(content);
// }
// }
// Path: src/main/java/uk/co/compendiumdev/javafortesters/gui/javafx/stages/ConfigEditStage.java
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
import uk.co.compendiumdev.javafortesters.gui.javafx.Config;
import uk.co.compendiumdev.javafortesters.gui.javafx.utils.JavaFX;
package uk.co.compendiumdev.javafortesters.gui.javafx.stages;
/*
20170306 knocked up quick typer for my use
Not ready for prime time
- does not handle upper case
- does not handle special chars (except * which is hard coded
- when fix this then can enable in MainGui
*/
public class ConfigEditStage extends Stage {
private static ConfigEditStage configEditStage =null;
public static void singletonActivate(){
if(configEditStage ==null)
configEditStage = new ConfigEditStage(false);
configEditStage.show();
configEditStage.requestFocus();
}
public static EventHandler<ActionEvent> getActivationEvent() {
return new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
ConfigEditStage.singletonActivate();
}
};
}
public ConfigEditStage(boolean hidden) {
BorderPane root = new BorderPane();
HBox modifiersControl = new HBox();
final Label modifiersLabel = new Label("Shift Modifiers:"); | final TextField modifiers = JavaFX.textField(Config.getCurrentShiftModifiers(), "A list of pairs of chars - \n first char is the char we want to type, \n next char is the key we press with \n shift to get the wanted char \n e.g. !1 means I want ! so press 1 with shift key"); |
eviltester/testtoolhub | src/main/java/uk/co/compendiumdev/javafortesters/gui/javafx/stages/ConfigEditStage.java | // Path: src/main/java/uk/co/compendiumdev/javafortesters/gui/javafx/Config.java
// public class Config {
//
// public static int getDefaultWindowWidth(){
// return 600;
// }
//
// public static int getDefaultWindowHeight(){
// return 200;
// }
//
// // string of paired characters, first is the 'wanted' char, next is the 'shifted' char
// // escaped modifier in string representation are at the end
// private static String defaultShiftModifiers = "~`!1@2$4%5^6&7*8(9)0_-+={[}]:;<,>.?/" + '"' + "'" + "|" + '\\';
//
// // £3
// // had to take £ out of the above as it failed when added to the default config
//
// public static String currentShiftModifiers = defaultShiftModifiers;
//
// public static String getCurrentShiftModifiers() {
// return currentShiftModifiers;
// }
//
// public static void setCurrentShiftModifiers(String currentShiftModifiers) {
// Config.currentShiftModifiers = currentShiftModifiers;
// }
//
// public static String getDefaultShiftModifiers() {
// return defaultShiftModifiers;
// }
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/gui/javafx/utils/JavaFX.java
// public class JavaFX {
//
// public static Button button(String text, String tooltip) {
// Button abutton = new Button();
// abutton.setText(text);
// abutton.setTooltip(new Tooltip(tooltip));
// return abutton;
// }
//
// public static TextField textField(String text, String tooltip) {
// TextField aTextField = new TextField ();
// aTextField.setText(text);
// aTextField.setTooltip(new Tooltip(tooltip));
// return aTextField;
// }
//
// public static TextField textField(String text, String tooltip, int maxWidth) {
// TextField aTextField = textField(text, tooltip);
// aTextField.setMaxWidth(maxWidth);
// return aTextField;
// }
//
// public static void alertErrorDialogWithException(Throwable ex, String title) {
// Alert alert = new Alert(Alert.AlertType.ERROR);
// alert.setTitle("Exception Dialog");
// alert.setHeaderText(title);
// alert.setContentText(ex.getMessage());
//
// // Create expandable Exception.
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// ex.printStackTrace(pw);
// String exceptionText = sw.toString();
//
// Label label = new Label("The exception stacktrace was:");
//
// TextArea textArea = new TextArea(exceptionText);
// textArea.setEditable(false);
// textArea.setWrapText(true);
//
// textArea.setMaxWidth(Double.MAX_VALUE);
// textArea.setMaxHeight(Double.MAX_VALUE);
// GridPane.setVgrow(textArea, Priority.ALWAYS);
// GridPane.setHgrow(textArea, Priority.ALWAYS);
//
// GridPane expContent = new GridPane();
// expContent.setMaxWidth(Double.MAX_VALUE);
// expContent.add(label, 0, 0);
// expContent.add(textArea, 0, 1);
//
// // Set expandable Exception into the dialog pane.
// alert.getDialogPane().setExpandableContent(expContent);
//
// alert.showAndWait();
//
// }
// public static void alertErrorDialogWithException(Throwable ex) {
// alertErrorDialogWithException(ex, "General Exception");
// }
//
// public static void showSimpleErrorAlert(String title, String message) {
// // http://code.makery.ch/blog/javafx-dialogs-official/
// Alert alert = new Alert(Alert.AlertType.ERROR);
// alert.setTitle(title);
// alert.setHeaderText(null);
// alert.setContentText(message);
// alert.showAndWait();
//
// }
//
// public static void sendTextToClipboard(String textToSend) {
// Clipboard clipboard = Clipboard.getSystemClipboard();
// clipboard.clear();
// ClipboardContent content = new ClipboardContent();
// content.putString(textToSend);
// clipboard.setContent(content);
// }
// }
| import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
import uk.co.compendiumdev.javafortesters.gui.javafx.Config;
import uk.co.compendiumdev.javafortesters.gui.javafx.utils.JavaFX; | package uk.co.compendiumdev.javafortesters.gui.javafx.stages;
/*
20170306 knocked up quick typer for my use
Not ready for prime time
- does not handle upper case
- does not handle special chars (except * which is hard coded
- when fix this then can enable in MainGui
*/
public class ConfigEditStage extends Stage {
private static ConfigEditStage configEditStage =null;
public static void singletonActivate(){
if(configEditStage ==null)
configEditStage = new ConfigEditStage(false);
configEditStage.show();
configEditStage.requestFocus();
}
public static EventHandler<ActionEvent> getActivationEvent() {
return new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
ConfigEditStage.singletonActivate();
}
};
}
public ConfigEditStage(boolean hidden) {
BorderPane root = new BorderPane();
HBox modifiersControl = new HBox();
final Label modifiersLabel = new Label("Shift Modifiers:"); | // Path: src/main/java/uk/co/compendiumdev/javafortesters/gui/javafx/Config.java
// public class Config {
//
// public static int getDefaultWindowWidth(){
// return 600;
// }
//
// public static int getDefaultWindowHeight(){
// return 200;
// }
//
// // string of paired characters, first is the 'wanted' char, next is the 'shifted' char
// // escaped modifier in string representation are at the end
// private static String defaultShiftModifiers = "~`!1@2$4%5^6&7*8(9)0_-+={[}]:;<,>.?/" + '"' + "'" + "|" + '\\';
//
// // £3
// // had to take £ out of the above as it failed when added to the default config
//
// public static String currentShiftModifiers = defaultShiftModifiers;
//
// public static String getCurrentShiftModifiers() {
// return currentShiftModifiers;
// }
//
// public static void setCurrentShiftModifiers(String currentShiftModifiers) {
// Config.currentShiftModifiers = currentShiftModifiers;
// }
//
// public static String getDefaultShiftModifiers() {
// return defaultShiftModifiers;
// }
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/gui/javafx/utils/JavaFX.java
// public class JavaFX {
//
// public static Button button(String text, String tooltip) {
// Button abutton = new Button();
// abutton.setText(text);
// abutton.setTooltip(new Tooltip(tooltip));
// return abutton;
// }
//
// public static TextField textField(String text, String tooltip) {
// TextField aTextField = new TextField ();
// aTextField.setText(text);
// aTextField.setTooltip(new Tooltip(tooltip));
// return aTextField;
// }
//
// public static TextField textField(String text, String tooltip, int maxWidth) {
// TextField aTextField = textField(text, tooltip);
// aTextField.setMaxWidth(maxWidth);
// return aTextField;
// }
//
// public static void alertErrorDialogWithException(Throwable ex, String title) {
// Alert alert = new Alert(Alert.AlertType.ERROR);
// alert.setTitle("Exception Dialog");
// alert.setHeaderText(title);
// alert.setContentText(ex.getMessage());
//
// // Create expandable Exception.
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// ex.printStackTrace(pw);
// String exceptionText = sw.toString();
//
// Label label = new Label("The exception stacktrace was:");
//
// TextArea textArea = new TextArea(exceptionText);
// textArea.setEditable(false);
// textArea.setWrapText(true);
//
// textArea.setMaxWidth(Double.MAX_VALUE);
// textArea.setMaxHeight(Double.MAX_VALUE);
// GridPane.setVgrow(textArea, Priority.ALWAYS);
// GridPane.setHgrow(textArea, Priority.ALWAYS);
//
// GridPane expContent = new GridPane();
// expContent.setMaxWidth(Double.MAX_VALUE);
// expContent.add(label, 0, 0);
// expContent.add(textArea, 0, 1);
//
// // Set expandable Exception into the dialog pane.
// alert.getDialogPane().setExpandableContent(expContent);
//
// alert.showAndWait();
//
// }
// public static void alertErrorDialogWithException(Throwable ex) {
// alertErrorDialogWithException(ex, "General Exception");
// }
//
// public static void showSimpleErrorAlert(String title, String message) {
// // http://code.makery.ch/blog/javafx-dialogs-official/
// Alert alert = new Alert(Alert.AlertType.ERROR);
// alert.setTitle(title);
// alert.setHeaderText(null);
// alert.setContentText(message);
// alert.showAndWait();
//
// }
//
// public static void sendTextToClipboard(String textToSend) {
// Clipboard clipboard = Clipboard.getSystemClipboard();
// clipboard.clear();
// ClipboardContent content = new ClipboardContent();
// content.putString(textToSend);
// clipboard.setContent(content);
// }
// }
// Path: src/main/java/uk/co/compendiumdev/javafortesters/gui/javafx/stages/ConfigEditStage.java
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
import uk.co.compendiumdev.javafortesters.gui.javafx.Config;
import uk.co.compendiumdev.javafortesters.gui.javafx.utils.JavaFX;
package uk.co.compendiumdev.javafortesters.gui.javafx.stages;
/*
20170306 knocked up quick typer for my use
Not ready for prime time
- does not handle upper case
- does not handle special chars (except * which is hard coded
- when fix this then can enable in MainGui
*/
public class ConfigEditStage extends Stage {
private static ConfigEditStage configEditStage =null;
public static void singletonActivate(){
if(configEditStage ==null)
configEditStage = new ConfigEditStage(false);
configEditStage.show();
configEditStage.requestFocus();
}
public static EventHandler<ActionEvent> getActivationEvent() {
return new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
ConfigEditStage.singletonActivate();
}
};
}
public ConfigEditStage(boolean hidden) {
BorderPane root = new BorderPane();
HBox modifiersControl = new HBox();
final Label modifiersLabel = new Label("Shift Modifiers:"); | final TextField modifiers = JavaFX.textField(Config.getCurrentShiftModifiers(), "A list of pairs of chars - \n first char is the char we want to type, \n next char is the key we press with \n shift to get the wanted char \n e.g. !1 means I want ! so press 1 with shift key"); |
eviltester/testtoolhub | src/test/java/uk/co/compendiumdev/javafortesters/domain/cannedtext/CannedTextCreationTest.java | // Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/tree/TreeBranch.java
// public class TreeBranch<T> {
// private final ArrayList<TreeBranch> children;
// private T leaf;
// private String label;
//
// public TreeBranch(){
// this("branch");
// }
//
// public TreeBranch(String label){
// this(label, null);
// }
//
// public TreeBranch(String label, T entity) {
// this.leaf = entity;
// this.label = label;
// this.children = new ArrayList<TreeBranch>();
// }
//
// public boolean isLeaf() {
// return leaf!=null;
// }
//
// public String getLabel() {
// return label;
// }
//
// public void setLabel(String label) {
// this.label = label;
// }
//
// public TreeBranch addChild(String branchLabel) {
// TreeBranch<T> child = new TreeBranch<T>(branchLabel);
// children.add(child);
// return child;
// }
//
// public TreeBranch addChild(String branchLabel, T entity){
// TreeBranch<T> child = new TreeBranch<T>(branchLabel, entity);
// children.add(child);
// return child;
// }
//
// public int countChildren() {
// return children.size();
// }
//
// public T getLeaf() {
// return leaf;
// }
//
// public String toString(){
// return stringify(0);
//
// }
//
// private String stringify(int indent) {
// StringBuilder out = new StringBuilder();
//
// for(int i=0; i<indent; i++){
// out.append(" ");
// }
//
// out.append(label).append("\n");
//
// for(TreeBranch child : children){
// out.append(child.stringify(indent+1));
// }
//
// return out.toString();
// }
//
//
// public ArrayList<TreeBranch> getChildren() {
// return children;
// }
//
// public void addChild(TreeBranch<T> lastBranch) {
// children.add(lastBranch);
// }
// }
| import uk.co.compendiumdev.javafortesters.domain.tree.TreeBranch;
import org.junit.Assert;
import org.junit.Test; | package uk.co.compendiumdev.javafortesters.domain.cannedtext;
/**
* Created by Alan on 27/02/2015.
* To allow creation and exploration of canned text functionality
*/
public class CannedTextCreationTest {
@Test
public void canCreateASimpleCannedTextItem(){
CannedTextItem text = new CannedTextItem("0");
Assert.assertEquals("0",text.getTextValue());
}
@Test
public void canCreateASimpleCannedTextItemWithDefaultLabel(){
CannedTextItem text = new CannedTextItem("defaultLabel");
Assert.assertEquals("defaultLabel",text.getTextValue());
Assert.assertEquals("defaultLabel",text.getLabel());
}
@Test
public void canCreateCannedTextItemWithLabel(){
CannedTextItem text = new CannedTextItem("number1","1");
Assert.assertEquals("1",text.getTextValue());
Assert.assertEquals("number1",text.getLabel());
}
@Test
public void canCreateCannedTextItemsWithUniqueIDs(){
CannedTextItem text1 = new CannedTextItem("number2","2");
CannedTextItem text2 = new CannedTextItem("number3","3");
Assert.assertTrue(text1.getId().length() > 0);
Assert.assertTrue(text2.getId().length()>0);
Assert.assertNotEquals(text1.getId(), text2.getId());
}
@Test
public void canCreateATreeOfCannedTextItems(){
| // Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/tree/TreeBranch.java
// public class TreeBranch<T> {
// private final ArrayList<TreeBranch> children;
// private T leaf;
// private String label;
//
// public TreeBranch(){
// this("branch");
// }
//
// public TreeBranch(String label){
// this(label, null);
// }
//
// public TreeBranch(String label, T entity) {
// this.leaf = entity;
// this.label = label;
// this.children = new ArrayList<TreeBranch>();
// }
//
// public boolean isLeaf() {
// return leaf!=null;
// }
//
// public String getLabel() {
// return label;
// }
//
// public void setLabel(String label) {
// this.label = label;
// }
//
// public TreeBranch addChild(String branchLabel) {
// TreeBranch<T> child = new TreeBranch<T>(branchLabel);
// children.add(child);
// return child;
// }
//
// public TreeBranch addChild(String branchLabel, T entity){
// TreeBranch<T> child = new TreeBranch<T>(branchLabel, entity);
// children.add(child);
// return child;
// }
//
// public int countChildren() {
// return children.size();
// }
//
// public T getLeaf() {
// return leaf;
// }
//
// public String toString(){
// return stringify(0);
//
// }
//
// private String stringify(int indent) {
// StringBuilder out = new StringBuilder();
//
// for(int i=0; i<indent; i++){
// out.append(" ");
// }
//
// out.append(label).append("\n");
//
// for(TreeBranch child : children){
// out.append(child.stringify(indent+1));
// }
//
// return out.toString();
// }
//
//
// public ArrayList<TreeBranch> getChildren() {
// return children;
// }
//
// public void addChild(TreeBranch<T> lastBranch) {
// children.add(lastBranch);
// }
// }
// Path: src/test/java/uk/co/compendiumdev/javafortesters/domain/cannedtext/CannedTextCreationTest.java
import uk.co.compendiumdev.javafortesters.domain.tree.TreeBranch;
import org.junit.Assert;
import org.junit.Test;
package uk.co.compendiumdev.javafortesters.domain.cannedtext;
/**
* Created by Alan on 27/02/2015.
* To allow creation and exploration of canned text functionality
*/
public class CannedTextCreationTest {
@Test
public void canCreateASimpleCannedTextItem(){
CannedTextItem text = new CannedTextItem("0");
Assert.assertEquals("0",text.getTextValue());
}
@Test
public void canCreateASimpleCannedTextItemWithDefaultLabel(){
CannedTextItem text = new CannedTextItem("defaultLabel");
Assert.assertEquals("defaultLabel",text.getTextValue());
Assert.assertEquals("defaultLabel",text.getLabel());
}
@Test
public void canCreateCannedTextItemWithLabel(){
CannedTextItem text = new CannedTextItem("number1","1");
Assert.assertEquals("1",text.getTextValue());
Assert.assertEquals("number1",text.getLabel());
}
@Test
public void canCreateCannedTextItemsWithUniqueIDs(){
CannedTextItem text1 = new CannedTextItem("number2","2");
CannedTextItem text2 = new CannedTextItem("number3","3");
Assert.assertTrue(text1.getId().length() > 0);
Assert.assertTrue(text2.getId().length()>0);
Assert.assertNotEquals(text1.getId(), text2.getId());
}
@Test
public void canCreateATreeOfCannedTextItems(){
| TreeBranch<CannedTextItem> root = new TreeBranch<CannedTextItem>(); |
eviltester/testtoolhub | src/test/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/CounterStringCreatorTest.java | // Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/CounterStringCreator.java
// public interface CounterStringCreator {
// void append(String nextPart);
// void finished();
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/StringCounterStringCreator.java
// public class StringCounterStringCreator implements CounterStringCreator {
//
// private final StringBuilder string;
//
// public StringCounterStringCreator(){
// string = new StringBuilder();
//
// }
//
// @Override
// public void append(String nextPart) {
// string.append(nextPart);
// }
//
// @Override
// public void finished() {
// // string is ready to output now
// }
//
// @Override
// public String toString() {
// return string.toString();
// }
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/SystemOutCounterStringCreator.java
// public class SystemOutCounterStringCreator implements CounterStringCreator {
//
// private final StringBuilder string;
//
// public SystemOutCounterStringCreator(){
// string = new StringBuilder();
// }
// @Override
// public void append(String nextPart) {
// string.append(nextPart);
// }
//
// @Override
// public void finished() {
// System.out.print(string.toString());
// }
//
// @Override
// public String toString() {
// return string.toString();
// }
//
//
// }
| import org.junit.Assert;
import org.junit.Test;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.CounterStringCreator;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.StringCounterStringCreator;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.SystemOutCounterStringCreator; | package uk.co.compendiumdev.javafortesters.domain.counterstrings;
public class CounterStringCreatorTest {
@Test
public void haveACounterStringCreatorInterface() throws CounterStringCreationError {
| // Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/CounterStringCreator.java
// public interface CounterStringCreator {
// void append(String nextPart);
// void finished();
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/StringCounterStringCreator.java
// public class StringCounterStringCreator implements CounterStringCreator {
//
// private final StringBuilder string;
//
// public StringCounterStringCreator(){
// string = new StringBuilder();
//
// }
//
// @Override
// public void append(String nextPart) {
// string.append(nextPart);
// }
//
// @Override
// public void finished() {
// // string is ready to output now
// }
//
// @Override
// public String toString() {
// return string.toString();
// }
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/SystemOutCounterStringCreator.java
// public class SystemOutCounterStringCreator implements CounterStringCreator {
//
// private final StringBuilder string;
//
// public SystemOutCounterStringCreator(){
// string = new StringBuilder();
// }
// @Override
// public void append(String nextPart) {
// string.append(nextPart);
// }
//
// @Override
// public void finished() {
// System.out.print(string.toString());
// }
//
// @Override
// public String toString() {
// return string.toString();
// }
//
//
// }
// Path: src/test/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/CounterStringCreatorTest.java
import org.junit.Assert;
import org.junit.Test;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.CounterStringCreator;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.StringCounterStringCreator;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.SystemOutCounterStringCreator;
package uk.co.compendiumdev.javafortesters.domain.counterstrings;
public class CounterStringCreatorTest {
@Test
public void haveACounterStringCreatorInterface() throws CounterStringCreationError {
| CounterStringCreator creator = new StringCounterStringCreator(); |
eviltester/testtoolhub | src/test/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/CounterStringCreatorTest.java | // Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/CounterStringCreator.java
// public interface CounterStringCreator {
// void append(String nextPart);
// void finished();
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/StringCounterStringCreator.java
// public class StringCounterStringCreator implements CounterStringCreator {
//
// private final StringBuilder string;
//
// public StringCounterStringCreator(){
// string = new StringBuilder();
//
// }
//
// @Override
// public void append(String nextPart) {
// string.append(nextPart);
// }
//
// @Override
// public void finished() {
// // string is ready to output now
// }
//
// @Override
// public String toString() {
// return string.toString();
// }
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/SystemOutCounterStringCreator.java
// public class SystemOutCounterStringCreator implements CounterStringCreator {
//
// private final StringBuilder string;
//
// public SystemOutCounterStringCreator(){
// string = new StringBuilder();
// }
// @Override
// public void append(String nextPart) {
// string.append(nextPart);
// }
//
// @Override
// public void finished() {
// System.out.print(string.toString());
// }
//
// @Override
// public String toString() {
// return string.toString();
// }
//
//
// }
| import org.junit.Assert;
import org.junit.Test;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.CounterStringCreator;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.StringCounterStringCreator;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.SystemOutCounterStringCreator; | package uk.co.compendiumdev.javafortesters.domain.counterstrings;
public class CounterStringCreatorTest {
@Test
public void haveACounterStringCreatorInterface() throws CounterStringCreationError {
| // Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/CounterStringCreator.java
// public interface CounterStringCreator {
// void append(String nextPart);
// void finished();
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/StringCounterStringCreator.java
// public class StringCounterStringCreator implements CounterStringCreator {
//
// private final StringBuilder string;
//
// public StringCounterStringCreator(){
// string = new StringBuilder();
//
// }
//
// @Override
// public void append(String nextPart) {
// string.append(nextPart);
// }
//
// @Override
// public void finished() {
// // string is ready to output now
// }
//
// @Override
// public String toString() {
// return string.toString();
// }
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/SystemOutCounterStringCreator.java
// public class SystemOutCounterStringCreator implements CounterStringCreator {
//
// private final StringBuilder string;
//
// public SystemOutCounterStringCreator(){
// string = new StringBuilder();
// }
// @Override
// public void append(String nextPart) {
// string.append(nextPart);
// }
//
// @Override
// public void finished() {
// System.out.print(string.toString());
// }
//
// @Override
// public String toString() {
// return string.toString();
// }
//
//
// }
// Path: src/test/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/CounterStringCreatorTest.java
import org.junit.Assert;
import org.junit.Test;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.CounterStringCreator;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.StringCounterStringCreator;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.SystemOutCounterStringCreator;
package uk.co.compendiumdev.javafortesters.domain.counterstrings;
public class CounterStringCreatorTest {
@Test
public void haveACounterStringCreatorInterface() throws CounterStringCreationError {
| CounterStringCreator creator = new StringCounterStringCreator(); |
eviltester/testtoolhub | src/test/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/CounterStringCreatorTest.java | // Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/CounterStringCreator.java
// public interface CounterStringCreator {
// void append(String nextPart);
// void finished();
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/StringCounterStringCreator.java
// public class StringCounterStringCreator implements CounterStringCreator {
//
// private final StringBuilder string;
//
// public StringCounterStringCreator(){
// string = new StringBuilder();
//
// }
//
// @Override
// public void append(String nextPart) {
// string.append(nextPart);
// }
//
// @Override
// public void finished() {
// // string is ready to output now
// }
//
// @Override
// public String toString() {
// return string.toString();
// }
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/SystemOutCounterStringCreator.java
// public class SystemOutCounterStringCreator implements CounterStringCreator {
//
// private final StringBuilder string;
//
// public SystemOutCounterStringCreator(){
// string = new StringBuilder();
// }
// @Override
// public void append(String nextPart) {
// string.append(nextPart);
// }
//
// @Override
// public void finished() {
// System.out.print(string.toString());
// }
//
// @Override
// public String toString() {
// return string.toString();
// }
//
//
// }
| import org.junit.Assert;
import org.junit.Test;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.CounterStringCreator;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.StringCounterStringCreator;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.SystemOutCounterStringCreator; | package uk.co.compendiumdev.javafortesters.domain.counterstrings;
public class CounterStringCreatorTest {
@Test
public void haveACounterStringCreatorInterface() throws CounterStringCreationError {
CounterStringCreator creator = new StringCounterStringCreator();
new CounterString().createWith(35, "*", creator);
Assert.assertEquals("2*4*6*8*11*14*17*20*23*26*29*32*35*", creator.toString());
}
@Test
public void haveACounterStringSysOutCreator() throws CounterStringCreationError {
| // Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/CounterStringCreator.java
// public interface CounterStringCreator {
// void append(String nextPart);
// void finished();
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/StringCounterStringCreator.java
// public class StringCounterStringCreator implements CounterStringCreator {
//
// private final StringBuilder string;
//
// public StringCounterStringCreator(){
// string = new StringBuilder();
//
// }
//
// @Override
// public void append(String nextPart) {
// string.append(nextPart);
// }
//
// @Override
// public void finished() {
// // string is ready to output now
// }
//
// @Override
// public String toString() {
// return string.toString();
// }
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/Creators/SystemOutCounterStringCreator.java
// public class SystemOutCounterStringCreator implements CounterStringCreator {
//
// private final StringBuilder string;
//
// public SystemOutCounterStringCreator(){
// string = new StringBuilder();
// }
// @Override
// public void append(String nextPart) {
// string.append(nextPart);
// }
//
// @Override
// public void finished() {
// System.out.print(string.toString());
// }
//
// @Override
// public String toString() {
// return string.toString();
// }
//
//
// }
// Path: src/test/java/uk/co/compendiumdev/javafortesters/domain/counterstrings/CounterStringCreatorTest.java
import org.junit.Assert;
import org.junit.Test;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.CounterStringCreator;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.StringCounterStringCreator;
import uk.co.compendiumdev.javafortesters.domain.counterstrings.Creators.SystemOutCounterStringCreator;
package uk.co.compendiumdev.javafortesters.domain.counterstrings;
public class CounterStringCreatorTest {
@Test
public void haveACounterStringCreatorInterface() throws CounterStringCreationError {
CounterStringCreator creator = new StringCounterStringCreator();
new CounterString().createWith(35, "*", creator);
Assert.assertEquals("2*4*6*8*11*14*17*20*23*26*29*32*35*", creator.toString());
}
@Test
public void haveACounterStringSysOutCreator() throws CounterStringCreationError {
| CounterStringCreator creator = new SystemOutCounterStringCreator(); |
eviltester/testtoolhub | src/main/java/uk/co/compendiumdev/javafortesters/gui/urllauncher/PhysicalUrlLauncher.java | // Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/launcher/LauncherUrl.java
// public class LauncherUrl {
// private final String name;
// private final String url;
//
// public LauncherUrl(String name, String url) {
// this.name = name;
// this.url = url;
// }
//
// public String getName() {
// return name;
// }
//
// public String getUrl(){
// return url;
// }
//
//
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/launcher/LauncherUrlSet.java
// public class LauncherUrlSet {
// public static final int DEFAULT_MILLIS = 1000;
// public static final int DEFAULT_RETRIES = 3;
// private String name;
// private Map<String, LauncherUrl> urls;
//
// public LauncherUrlSet(String name) {
// this.name = name;
// this.urls = new HashMap<String, LauncherUrl>();
// }
//
// public void add(LauncherUrl aUrl) {
// urls.put(aUrl.getName(), aUrl);
// }
//
//
//
// public String getName() {
// return name;
// }
//
// public Map<String, LauncherUrl> getUrls(){
// return urls;
// }
// }
| import uk.co.compendiumdev.javafortesters.domain.launcher.LauncherUrl;
import uk.co.compendiumdev.javafortesters.domain.launcher.LauncherUrlSet;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map; | package uk.co.compendiumdev.javafortesters.gui.urllauncher;
public class PhysicalUrlLauncher {
public static boolean canLaunch(){
return Desktop.isDesktopSupported();
}
public static boolean launch(String aUrl) {
if(!canLaunch()) return false;
try {
Desktop.getDesktop().browse(new URI(aUrl));
return true;
} catch (IOException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
}
return false;
}
| // Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/launcher/LauncherUrl.java
// public class LauncherUrl {
// private final String name;
// private final String url;
//
// public LauncherUrl(String name, String url) {
// this.name = name;
// this.url = url;
// }
//
// public String getName() {
// return name;
// }
//
// public String getUrl(){
// return url;
// }
//
//
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/launcher/LauncherUrlSet.java
// public class LauncherUrlSet {
// public static final int DEFAULT_MILLIS = 1000;
// public static final int DEFAULT_RETRIES = 3;
// private String name;
// private Map<String, LauncherUrl> urls;
//
// public LauncherUrlSet(String name) {
// this.name = name;
// this.urls = new HashMap<String, LauncherUrl>();
// }
//
// public void add(LauncherUrl aUrl) {
// urls.put(aUrl.getName(), aUrl);
// }
//
//
//
// public String getName() {
// return name;
// }
//
// public Map<String, LauncherUrl> getUrls(){
// return urls;
// }
// }
// Path: src/main/java/uk/co/compendiumdev/javafortesters/gui/urllauncher/PhysicalUrlLauncher.java
import uk.co.compendiumdev.javafortesters.domain.launcher.LauncherUrl;
import uk.co.compendiumdev.javafortesters.domain.launcher.LauncherUrlSet;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;
package uk.co.compendiumdev.javafortesters.gui.urllauncher;
public class PhysicalUrlLauncher {
public static boolean canLaunch(){
return Desktop.isDesktopSupported();
}
public static boolean launch(String aUrl) {
if(!canLaunch()) return false;
try {
Desktop.getDesktop().browse(new URI(aUrl));
return true;
} catch (IOException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
}
return false;
}
| public static void launch(LauncherUrlSet aLauncherUrlSet){ |
eviltester/testtoolhub | src/main/java/uk/co/compendiumdev/javafortesters/gui/urllauncher/PhysicalUrlLauncher.java | // Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/launcher/LauncherUrl.java
// public class LauncherUrl {
// private final String name;
// private final String url;
//
// public LauncherUrl(String name, String url) {
// this.name = name;
// this.url = url;
// }
//
// public String getName() {
// return name;
// }
//
// public String getUrl(){
// return url;
// }
//
//
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/launcher/LauncherUrlSet.java
// public class LauncherUrlSet {
// public static final int DEFAULT_MILLIS = 1000;
// public static final int DEFAULT_RETRIES = 3;
// private String name;
// private Map<String, LauncherUrl> urls;
//
// public LauncherUrlSet(String name) {
// this.name = name;
// this.urls = new HashMap<String, LauncherUrl>();
// }
//
// public void add(LauncherUrl aUrl) {
// urls.put(aUrl.getName(), aUrl);
// }
//
//
//
// public String getName() {
// return name;
// }
//
// public Map<String, LauncherUrl> getUrls(){
// return urls;
// }
// }
| import uk.co.compendiumdev.javafortesters.domain.launcher.LauncherUrl;
import uk.co.compendiumdev.javafortesters.domain.launcher.LauncherUrlSet;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map; | package uk.co.compendiumdev.javafortesters.gui.urllauncher;
public class PhysicalUrlLauncher {
public static boolean canLaunch(){
return Desktop.isDesktopSupported();
}
public static boolean launch(String aUrl) {
if(!canLaunch()) return false;
try {
Desktop.getDesktop().browse(new URI(aUrl));
return true;
} catch (IOException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
}
return false;
}
public static void launch(LauncherUrlSet aLauncherUrlSet){
launch(aLauncherUrlSet.DEFAULT_MILLIS, aLauncherUrlSet.DEFAULT_RETRIES, aLauncherUrlSet);
}
public static void launch(int millisBetweenLaunches, int retries, LauncherUrlSet aLauncherUrlSet) {
if(!canLaunch()) {
System.out.println("Cannot launch, desktop launching not supported by JVM");
return;
}
| // Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/launcher/LauncherUrl.java
// public class LauncherUrl {
// private final String name;
// private final String url;
//
// public LauncherUrl(String name, String url) {
// this.name = name;
// this.url = url;
// }
//
// public String getName() {
// return name;
// }
//
// public String getUrl(){
// return url;
// }
//
//
// }
//
// Path: src/main/java/uk/co/compendiumdev/javafortesters/domain/launcher/LauncherUrlSet.java
// public class LauncherUrlSet {
// public static final int DEFAULT_MILLIS = 1000;
// public static final int DEFAULT_RETRIES = 3;
// private String name;
// private Map<String, LauncherUrl> urls;
//
// public LauncherUrlSet(String name) {
// this.name = name;
// this.urls = new HashMap<String, LauncherUrl>();
// }
//
// public void add(LauncherUrl aUrl) {
// urls.put(aUrl.getName(), aUrl);
// }
//
//
//
// public String getName() {
// return name;
// }
//
// public Map<String, LauncherUrl> getUrls(){
// return urls;
// }
// }
// Path: src/main/java/uk/co/compendiumdev/javafortesters/gui/urllauncher/PhysicalUrlLauncher.java
import uk.co.compendiumdev.javafortesters.domain.launcher.LauncherUrl;
import uk.co.compendiumdev.javafortesters.domain.launcher.LauncherUrlSet;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;
package uk.co.compendiumdev.javafortesters.gui.urllauncher;
public class PhysicalUrlLauncher {
public static boolean canLaunch(){
return Desktop.isDesktopSupported();
}
public static boolean launch(String aUrl) {
if(!canLaunch()) return false;
try {
Desktop.getDesktop().browse(new URI(aUrl));
return true;
} catch (IOException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
}
return false;
}
public static void launch(LauncherUrlSet aLauncherUrlSet){
launch(aLauncherUrlSet.DEFAULT_MILLIS, aLauncherUrlSet.DEFAULT_RETRIES, aLauncherUrlSet);
}
public static void launch(int millisBetweenLaunches, int retries, LauncherUrlSet aLauncherUrlSet) {
if(!canLaunch()) {
System.out.println("Cannot launch, desktop launching not supported by JVM");
return;
}
| for( Map.Entry<String, LauncherUrl> aUrl : aLauncherUrlSet.getUrls().entrySet()){ |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/parser/ImagePushParser.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/Push.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class Push extends AbstractToStringBuilder{
// @XmlElement(name = "ToUserName")
// private String toUserName;
//
// @XmlElement(name = "FromUserName")
// private String fromUserName;
//
// @XmlElement(name = "CreateTime")
// private long createTime;
//
// @XmlElement(name = "MsgType")
// private String msgType;
//
// @XmlElement(name = "MsgId")
// private String msgId;
//
// public String getToUserName() {
// return toUserName;
// }
//
// public void setToUserName(String toUserName) {
// this.toUserName = toUserName;
// }
//
// public String getFromUserName() {
// return fromUserName;
// }
//
// public void setFromUserName(String fromUserName) {
// this.fromUserName = fromUserName;
// }
//
// public long getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(long createTime) {
// this.createTime = createTime;
// }
//
// public String getMsgType() {
// return msgType;
// }
//
// public void setMsgType(String msgType) {
// this.msgType = msgType;
// }
//
// public String getMsgId() {
// return msgId;
// }
//
// public void setMsgId(String msgId) {
// this.msgId = msgId;
// }
//
// }
| import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.push.Push; | package org.usc.wechat.mp.sdk.factory.parser;
/**
*
* @author Shunli
*/
public class ImagePushParser implements PushParser {
@Override | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/Push.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class Push extends AbstractToStringBuilder{
// @XmlElement(name = "ToUserName")
// private String toUserName;
//
// @XmlElement(name = "FromUserName")
// private String fromUserName;
//
// @XmlElement(name = "CreateTime")
// private long createTime;
//
// @XmlElement(name = "MsgType")
// private String msgType;
//
// @XmlElement(name = "MsgId")
// private String msgId;
//
// public String getToUserName() {
// return toUserName;
// }
//
// public void setToUserName(String toUserName) {
// this.toUserName = toUserName;
// }
//
// public String getFromUserName() {
// return fromUserName;
// }
//
// public void setFromUserName(String fromUserName) {
// this.fromUserName = fromUserName;
// }
//
// public long getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(long createTime) {
// this.createTime = createTime;
// }
//
// public String getMsgType() {
// return msgType;
// }
//
// public void setMsgType(String msgType) {
// this.msgType = msgType;
// }
//
// public String getMsgId() {
// return msgId;
// }
//
// public void setMsgId(String msgId) {
// this.msgId = msgId;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/parser/ImagePushParser.java
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.push.Push;
package org.usc.wechat.mp.sdk.factory.parser;
/**
*
* @author Shunli
*/
public class ImagePushParser implements PushParser {
@Override | public Reply parse(Push push) { |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/ImageReply.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/MediaDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MediaDetail extends AbstractToStringBuilder {
// @XmlElement(name = "MediaId")
// private String mediaId;
//
// public MediaDetail() {
// }
//
// public MediaDetail(String mediaId) {
// this.mediaId = mediaId;
// }
//
// public String getMediaId() {
// return mediaId;
// }
//
// public void setMediaId(String mediaId) {
// this.mediaId = mediaId;
// }
//
// }
| import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.MediaDetail; | package org.usc.wechat.mp.sdk.vo.message.reply;
/**
*
* @author Shunli
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class ImageReply extends Reply {
@XmlElement(name = "Image") | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/MediaDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MediaDetail extends AbstractToStringBuilder {
// @XmlElement(name = "MediaId")
// private String mediaId;
//
// public MediaDetail() {
// }
//
// public MediaDetail(String mediaId) {
// this.mediaId = mediaId;
// }
//
// public String getMediaId() {
// return mediaId;
// }
//
// public void setMediaId(String mediaId) {
// this.mediaId = mediaId;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/ImageReply.java
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.MediaDetail;
package org.usc.wechat.mp.sdk.vo.message.reply;
/**
*
* @author Shunli
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class ImageReply extends Reply {
@XmlElement(name = "Image") | private MediaDetail imageDetail; |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/ImageReply.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/MediaDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MediaDetail extends AbstractToStringBuilder {
// @XmlElement(name = "MediaId")
// private String mediaId;
//
// public MediaDetail() {
// }
//
// public MediaDetail(String mediaId) {
// this.mediaId = mediaId;
// }
//
// public String getMediaId() {
// return mediaId;
// }
//
// public void setMediaId(String mediaId) {
// this.mediaId = mediaId;
// }
//
// }
| import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.MediaDetail; | package org.usc.wechat.mp.sdk.vo.message.reply;
/**
*
* @author Shunli
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class ImageReply extends Reply {
@XmlElement(name = "Image")
private MediaDetail imageDetail;
{ | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/MediaDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MediaDetail extends AbstractToStringBuilder {
// @XmlElement(name = "MediaId")
// private String mediaId;
//
// public MediaDetail() {
// }
//
// public MediaDetail(String mediaId) {
// this.mediaId = mediaId;
// }
//
// public String getMediaId() {
// return mediaId;
// }
//
// public void setMediaId(String mediaId) {
// this.mediaId = mediaId;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/ImageReply.java
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.MediaDetail;
package org.usc.wechat.mp.sdk.vo.message.reply;
/**
*
* @author Shunli
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class ImageReply extends Reply {
@XmlElement(name = "Image")
private MediaDetail imageDetail;
{ | super.setMsgType(ReplyEnumFactory.IMAGE.getReplyType()); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/EventPush.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/Push.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class Push extends AbstractToStringBuilder{
// @XmlElement(name = "ToUserName")
// private String toUserName;
//
// @XmlElement(name = "FromUserName")
// private String fromUserName;
//
// @XmlElement(name = "CreateTime")
// private long createTime;
//
// @XmlElement(name = "MsgType")
// private String msgType;
//
// @XmlElement(name = "MsgId")
// private String msgId;
//
// public String getToUserName() {
// return toUserName;
// }
//
// public void setToUserName(String toUserName) {
// this.toUserName = toUserName;
// }
//
// public String getFromUserName() {
// return fromUserName;
// }
//
// public void setFromUserName(String fromUserName) {
// this.fromUserName = fromUserName;
// }
//
// public long getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(long createTime) {
// this.createTime = createTime;
// }
//
// public String getMsgType() {
// return msgType;
// }
//
// public void setMsgType(String msgType) {
// this.msgType = msgType;
// }
//
// public String getMsgId() {
// return msgId;
// }
//
// public void setMsgId(String msgId) {
// this.msgId = msgId;
// }
//
// }
| import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.usc.wechat.mp.sdk.vo.push.Push; | package org.usc.wechat.mp.sdk.vo.push.event;
/**
*
* @author Shunli
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD) | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/Push.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class Push extends AbstractToStringBuilder{
// @XmlElement(name = "ToUserName")
// private String toUserName;
//
// @XmlElement(name = "FromUserName")
// private String fromUserName;
//
// @XmlElement(name = "CreateTime")
// private long createTime;
//
// @XmlElement(name = "MsgType")
// private String msgType;
//
// @XmlElement(name = "MsgId")
// private String msgId;
//
// public String getToUserName() {
// return toUserName;
// }
//
// public void setToUserName(String toUserName) {
// this.toUserName = toUserName;
// }
//
// public String getFromUserName() {
// return fromUserName;
// }
//
// public void setFromUserName(String fromUserName) {
// this.fromUserName = fromUserName;
// }
//
// public long getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(long createTime) {
// this.createTime = createTime;
// }
//
// public String getMsgType() {
// return msgType;
// }
//
// public void setMsgType(String msgType) {
// this.msgType = msgType;
// }
//
// public String getMsgId() {
// return msgId;
// }
//
// public void setMsgId(String msgId) {
// this.msgId = msgId;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/EventPush.java
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.usc.wechat.mp.sdk.vo.push.Push;
package org.usc.wechat.mp.sdk.vo.push.event;
/**
*
* @author Shunli
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD) | public abstract class EventPush extends Push { |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/parser/VoicePushParser.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/Push.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class Push extends AbstractToStringBuilder{
// @XmlElement(name = "ToUserName")
// private String toUserName;
//
// @XmlElement(name = "FromUserName")
// private String fromUserName;
//
// @XmlElement(name = "CreateTime")
// private long createTime;
//
// @XmlElement(name = "MsgType")
// private String msgType;
//
// @XmlElement(name = "MsgId")
// private String msgId;
//
// public String getToUserName() {
// return toUserName;
// }
//
// public void setToUserName(String toUserName) {
// this.toUserName = toUserName;
// }
//
// public String getFromUserName() {
// return fromUserName;
// }
//
// public void setFromUserName(String fromUserName) {
// this.fromUserName = fromUserName;
// }
//
// public long getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(long createTime) {
// this.createTime = createTime;
// }
//
// public String getMsgType() {
// return msgType;
// }
//
// public void setMsgType(String msgType) {
// this.msgType = msgType;
// }
//
// public String getMsgId() {
// return msgId;
// }
//
// public void setMsgId(String msgId) {
// this.msgId = msgId;
// }
//
// }
| import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.push.Push; | package org.usc.wechat.mp.sdk.factory.parser;
/**
*
* @author Shunli
*/
public class VoicePushParser implements PushParser {
@Override | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/Push.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class Push extends AbstractToStringBuilder{
// @XmlElement(name = "ToUserName")
// private String toUserName;
//
// @XmlElement(name = "FromUserName")
// private String fromUserName;
//
// @XmlElement(name = "CreateTime")
// private long createTime;
//
// @XmlElement(name = "MsgType")
// private String msgType;
//
// @XmlElement(name = "MsgId")
// private String msgId;
//
// public String getToUserName() {
// return toUserName;
// }
//
// public void setToUserName(String toUserName) {
// this.toUserName = toUserName;
// }
//
// public String getFromUserName() {
// return fromUserName;
// }
//
// public void setFromUserName(String fromUserName) {
// this.fromUserName = fromUserName;
// }
//
// public long getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(long createTime) {
// this.createTime = createTime;
// }
//
// public String getMsgType() {
// return msgType;
// }
//
// public void setMsgType(String msgType) {
// this.msgType = msgType;
// }
//
// public String getMsgId() {
// return msgId;
// }
//
// public void setMsgId(String msgId) {
// this.msgId = msgId;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/parser/VoicePushParser.java
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.push.Push;
package org.usc.wechat.mp.sdk.factory.parser;
/**
*
* @author Shunli
*/
public class VoicePushParser implements PushParser {
@Override | public Reply parse(Push push) { |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/EventPushType.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/EventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class EventPush extends Push {
// @XmlElement(name = "Event")
// private String event;
//
// public String getEvent() {
// return event;
// }
//
// public void setEvent(String event) {
// this.event = event;
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/LocationEventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class LocationEventPush extends EventPush {
// @XmlElement(name = "Latitude")
// private String latitude;
//
// @XmlElement(name = "Longitude")
// private String longitude;
//
// @XmlElement(name = "Precision")
// private String precision;
//
// public LocationEventPush() {
// }
//
// public String getLatitude() {
// return latitude;
// }
//
// public void setLatitude(String latitude) {
// this.latitude = latitude;
// }
//
// public String getLongitude() {
// return longitude;
// }
//
// public void setLongitude(String longitude) {
// this.longitude = longitude;
// }
//
// public String getPrecision() {
// return precision;
// }
//
// public void setPrecision(String precision) {
// this.precision = precision;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/MassEndJobFinishEventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MassEndJobFinishEventPush extends EventPush {
// @XmlElement(name = "MsgID")
// private String massMsgId;
//
// @XmlElement(name = "Status")
// private String status;
//
// @XmlElement(name = "TotalCount")
// private long totalCount;
//
// @XmlElement(name = "FilterCount")
// private long filterCount;
//
// @XmlElement(name = "SentCount")
// private long sentCount;
//
// @XmlElement(name = "ErrorCount")
// private long errorCount;
//
// public MassEndJobFinishEventPush() {
// }
//
// public String getMassMsgId() {
// return massMsgId;
// }
//
// public void setMassMsgId(String massMsgId) {
// this.massMsgId = massMsgId;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// public long getTotalCount() {
// return totalCount;
// }
//
// public void setTotalCount(long totalCount) {
// this.totalCount = totalCount;
// }
//
// public long getFilterCount() {
// return filterCount;
// }
//
// public void setFilterCount(long filterCount) {
// this.filterCount = filterCount;
// }
//
// public long getSentCount() {
// return sentCount;
// }
//
// public void setSentCount(long sentCount) {
// this.sentCount = sentCount;
// }
//
// public long getErrorCount() {
// return errorCount;
// }
//
// public void setErrorCount(long errorCount) {
// this.errorCount = errorCount;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/NormalEventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class NormalEventPush extends EventPush {
// @XmlElement(name = "EventKey")
// private String eventKey;
//
// @XmlElement(name = "Ticket")
// private String ticket;
//
// public NormalEventPush() {
// }
//
// public String getEventKey() {
// return eventKey;
// }
//
// public void setEventKey(String eventKey) {
// this.eventKey = eventKey;
// }
//
// public String getTicket() {
// return ticket;
// }
//
// public void setTicket(String ticket) {
// this.ticket = ticket;
// }
// }
| import org.usc.wechat.mp.sdk.vo.push.event.EventPush;
import org.usc.wechat.mp.sdk.vo.push.event.LocationEventPush;
import org.usc.wechat.mp.sdk.vo.push.event.MassEndJobFinishEventPush;
import org.usc.wechat.mp.sdk.vo.push.event.NormalEventPush; | package org.usc.wechat.mp.sdk.vo;
/**
*
* @author Shunli
*/
public enum EventPushType {
SUBSCRIBE("subscribe", NormalEventPush.class),
UNSUBSCRIBE("unsubscribe", NormalEventPush.class),
CLICK("CLICK", NormalEventPush.class),
VIEW("VIEW", NormalEventPush.class),
SCAN("scan", NormalEventPush.class), | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/EventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class EventPush extends Push {
// @XmlElement(name = "Event")
// private String event;
//
// public String getEvent() {
// return event;
// }
//
// public void setEvent(String event) {
// this.event = event;
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/LocationEventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class LocationEventPush extends EventPush {
// @XmlElement(name = "Latitude")
// private String latitude;
//
// @XmlElement(name = "Longitude")
// private String longitude;
//
// @XmlElement(name = "Precision")
// private String precision;
//
// public LocationEventPush() {
// }
//
// public String getLatitude() {
// return latitude;
// }
//
// public void setLatitude(String latitude) {
// this.latitude = latitude;
// }
//
// public String getLongitude() {
// return longitude;
// }
//
// public void setLongitude(String longitude) {
// this.longitude = longitude;
// }
//
// public String getPrecision() {
// return precision;
// }
//
// public void setPrecision(String precision) {
// this.precision = precision;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/MassEndJobFinishEventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MassEndJobFinishEventPush extends EventPush {
// @XmlElement(name = "MsgID")
// private String massMsgId;
//
// @XmlElement(name = "Status")
// private String status;
//
// @XmlElement(name = "TotalCount")
// private long totalCount;
//
// @XmlElement(name = "FilterCount")
// private long filterCount;
//
// @XmlElement(name = "SentCount")
// private long sentCount;
//
// @XmlElement(name = "ErrorCount")
// private long errorCount;
//
// public MassEndJobFinishEventPush() {
// }
//
// public String getMassMsgId() {
// return massMsgId;
// }
//
// public void setMassMsgId(String massMsgId) {
// this.massMsgId = massMsgId;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// public long getTotalCount() {
// return totalCount;
// }
//
// public void setTotalCount(long totalCount) {
// this.totalCount = totalCount;
// }
//
// public long getFilterCount() {
// return filterCount;
// }
//
// public void setFilterCount(long filterCount) {
// this.filterCount = filterCount;
// }
//
// public long getSentCount() {
// return sentCount;
// }
//
// public void setSentCount(long sentCount) {
// this.sentCount = sentCount;
// }
//
// public long getErrorCount() {
// return errorCount;
// }
//
// public void setErrorCount(long errorCount) {
// this.errorCount = errorCount;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/NormalEventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class NormalEventPush extends EventPush {
// @XmlElement(name = "EventKey")
// private String eventKey;
//
// @XmlElement(name = "Ticket")
// private String ticket;
//
// public NormalEventPush() {
// }
//
// public String getEventKey() {
// return eventKey;
// }
//
// public void setEventKey(String eventKey) {
// this.eventKey = eventKey;
// }
//
// public String getTicket() {
// return ticket;
// }
//
// public void setTicket(String ticket) {
// this.ticket = ticket;
// }
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/EventPushType.java
import org.usc.wechat.mp.sdk.vo.push.event.EventPush;
import org.usc.wechat.mp.sdk.vo.push.event.LocationEventPush;
import org.usc.wechat.mp.sdk.vo.push.event.MassEndJobFinishEventPush;
import org.usc.wechat.mp.sdk.vo.push.event.NormalEventPush;
package org.usc.wechat.mp.sdk.vo;
/**
*
* @author Shunli
*/
public enum EventPushType {
SUBSCRIBE("subscribe", NormalEventPush.class),
UNSUBSCRIBE("unsubscribe", NormalEventPush.class),
CLICK("CLICK", NormalEventPush.class),
VIEW("VIEW", NormalEventPush.class),
SCAN("scan", NormalEventPush.class), | LOCATION("LOCATION", LocationEventPush.class), |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/EventPushType.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/EventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class EventPush extends Push {
// @XmlElement(name = "Event")
// private String event;
//
// public String getEvent() {
// return event;
// }
//
// public void setEvent(String event) {
// this.event = event;
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/LocationEventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class LocationEventPush extends EventPush {
// @XmlElement(name = "Latitude")
// private String latitude;
//
// @XmlElement(name = "Longitude")
// private String longitude;
//
// @XmlElement(name = "Precision")
// private String precision;
//
// public LocationEventPush() {
// }
//
// public String getLatitude() {
// return latitude;
// }
//
// public void setLatitude(String latitude) {
// this.latitude = latitude;
// }
//
// public String getLongitude() {
// return longitude;
// }
//
// public void setLongitude(String longitude) {
// this.longitude = longitude;
// }
//
// public String getPrecision() {
// return precision;
// }
//
// public void setPrecision(String precision) {
// this.precision = precision;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/MassEndJobFinishEventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MassEndJobFinishEventPush extends EventPush {
// @XmlElement(name = "MsgID")
// private String massMsgId;
//
// @XmlElement(name = "Status")
// private String status;
//
// @XmlElement(name = "TotalCount")
// private long totalCount;
//
// @XmlElement(name = "FilterCount")
// private long filterCount;
//
// @XmlElement(name = "SentCount")
// private long sentCount;
//
// @XmlElement(name = "ErrorCount")
// private long errorCount;
//
// public MassEndJobFinishEventPush() {
// }
//
// public String getMassMsgId() {
// return massMsgId;
// }
//
// public void setMassMsgId(String massMsgId) {
// this.massMsgId = massMsgId;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// public long getTotalCount() {
// return totalCount;
// }
//
// public void setTotalCount(long totalCount) {
// this.totalCount = totalCount;
// }
//
// public long getFilterCount() {
// return filterCount;
// }
//
// public void setFilterCount(long filterCount) {
// this.filterCount = filterCount;
// }
//
// public long getSentCount() {
// return sentCount;
// }
//
// public void setSentCount(long sentCount) {
// this.sentCount = sentCount;
// }
//
// public long getErrorCount() {
// return errorCount;
// }
//
// public void setErrorCount(long errorCount) {
// this.errorCount = errorCount;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/NormalEventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class NormalEventPush extends EventPush {
// @XmlElement(name = "EventKey")
// private String eventKey;
//
// @XmlElement(name = "Ticket")
// private String ticket;
//
// public NormalEventPush() {
// }
//
// public String getEventKey() {
// return eventKey;
// }
//
// public void setEventKey(String eventKey) {
// this.eventKey = eventKey;
// }
//
// public String getTicket() {
// return ticket;
// }
//
// public void setTicket(String ticket) {
// this.ticket = ticket;
// }
// }
| import org.usc.wechat.mp.sdk.vo.push.event.EventPush;
import org.usc.wechat.mp.sdk.vo.push.event.LocationEventPush;
import org.usc.wechat.mp.sdk.vo.push.event.MassEndJobFinishEventPush;
import org.usc.wechat.mp.sdk.vo.push.event.NormalEventPush; | package org.usc.wechat.mp.sdk.vo;
/**
*
* @author Shunli
*/
public enum EventPushType {
SUBSCRIBE("subscribe", NormalEventPush.class),
UNSUBSCRIBE("unsubscribe", NormalEventPush.class),
CLICK("CLICK", NormalEventPush.class),
VIEW("VIEW", NormalEventPush.class),
SCAN("scan", NormalEventPush.class),
LOCATION("LOCATION", LocationEventPush.class), | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/EventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class EventPush extends Push {
// @XmlElement(name = "Event")
// private String event;
//
// public String getEvent() {
// return event;
// }
//
// public void setEvent(String event) {
// this.event = event;
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/LocationEventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class LocationEventPush extends EventPush {
// @XmlElement(name = "Latitude")
// private String latitude;
//
// @XmlElement(name = "Longitude")
// private String longitude;
//
// @XmlElement(name = "Precision")
// private String precision;
//
// public LocationEventPush() {
// }
//
// public String getLatitude() {
// return latitude;
// }
//
// public void setLatitude(String latitude) {
// this.latitude = latitude;
// }
//
// public String getLongitude() {
// return longitude;
// }
//
// public void setLongitude(String longitude) {
// this.longitude = longitude;
// }
//
// public String getPrecision() {
// return precision;
// }
//
// public void setPrecision(String precision) {
// this.precision = precision;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/MassEndJobFinishEventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MassEndJobFinishEventPush extends EventPush {
// @XmlElement(name = "MsgID")
// private String massMsgId;
//
// @XmlElement(name = "Status")
// private String status;
//
// @XmlElement(name = "TotalCount")
// private long totalCount;
//
// @XmlElement(name = "FilterCount")
// private long filterCount;
//
// @XmlElement(name = "SentCount")
// private long sentCount;
//
// @XmlElement(name = "ErrorCount")
// private long errorCount;
//
// public MassEndJobFinishEventPush() {
// }
//
// public String getMassMsgId() {
// return massMsgId;
// }
//
// public void setMassMsgId(String massMsgId) {
// this.massMsgId = massMsgId;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// public long getTotalCount() {
// return totalCount;
// }
//
// public void setTotalCount(long totalCount) {
// this.totalCount = totalCount;
// }
//
// public long getFilterCount() {
// return filterCount;
// }
//
// public void setFilterCount(long filterCount) {
// this.filterCount = filterCount;
// }
//
// public long getSentCount() {
// return sentCount;
// }
//
// public void setSentCount(long sentCount) {
// this.sentCount = sentCount;
// }
//
// public long getErrorCount() {
// return errorCount;
// }
//
// public void setErrorCount(long errorCount) {
// this.errorCount = errorCount;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/NormalEventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class NormalEventPush extends EventPush {
// @XmlElement(name = "EventKey")
// private String eventKey;
//
// @XmlElement(name = "Ticket")
// private String ticket;
//
// public NormalEventPush() {
// }
//
// public String getEventKey() {
// return eventKey;
// }
//
// public void setEventKey(String eventKey) {
// this.eventKey = eventKey;
// }
//
// public String getTicket() {
// return ticket;
// }
//
// public void setTicket(String ticket) {
// this.ticket = ticket;
// }
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/EventPushType.java
import org.usc.wechat.mp.sdk.vo.push.event.EventPush;
import org.usc.wechat.mp.sdk.vo.push.event.LocationEventPush;
import org.usc.wechat.mp.sdk.vo.push.event.MassEndJobFinishEventPush;
import org.usc.wechat.mp.sdk.vo.push.event.NormalEventPush;
package org.usc.wechat.mp.sdk.vo;
/**
*
* @author Shunli
*/
public enum EventPushType {
SUBSCRIBE("subscribe", NormalEventPush.class),
UNSUBSCRIBE("unsubscribe", NormalEventPush.class),
CLICK("CLICK", NormalEventPush.class),
VIEW("VIEW", NormalEventPush.class),
SCAN("scan", NormalEventPush.class),
LOCATION("LOCATION", LocationEventPush.class), | MASSSENDJOBFINISH("MASSSENDJOBFINISH", MassEndJobFinishEventPush.class); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/EventPushType.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/EventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class EventPush extends Push {
// @XmlElement(name = "Event")
// private String event;
//
// public String getEvent() {
// return event;
// }
//
// public void setEvent(String event) {
// this.event = event;
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/LocationEventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class LocationEventPush extends EventPush {
// @XmlElement(name = "Latitude")
// private String latitude;
//
// @XmlElement(name = "Longitude")
// private String longitude;
//
// @XmlElement(name = "Precision")
// private String precision;
//
// public LocationEventPush() {
// }
//
// public String getLatitude() {
// return latitude;
// }
//
// public void setLatitude(String latitude) {
// this.latitude = latitude;
// }
//
// public String getLongitude() {
// return longitude;
// }
//
// public void setLongitude(String longitude) {
// this.longitude = longitude;
// }
//
// public String getPrecision() {
// return precision;
// }
//
// public void setPrecision(String precision) {
// this.precision = precision;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/MassEndJobFinishEventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MassEndJobFinishEventPush extends EventPush {
// @XmlElement(name = "MsgID")
// private String massMsgId;
//
// @XmlElement(name = "Status")
// private String status;
//
// @XmlElement(name = "TotalCount")
// private long totalCount;
//
// @XmlElement(name = "FilterCount")
// private long filterCount;
//
// @XmlElement(name = "SentCount")
// private long sentCount;
//
// @XmlElement(name = "ErrorCount")
// private long errorCount;
//
// public MassEndJobFinishEventPush() {
// }
//
// public String getMassMsgId() {
// return massMsgId;
// }
//
// public void setMassMsgId(String massMsgId) {
// this.massMsgId = massMsgId;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// public long getTotalCount() {
// return totalCount;
// }
//
// public void setTotalCount(long totalCount) {
// this.totalCount = totalCount;
// }
//
// public long getFilterCount() {
// return filterCount;
// }
//
// public void setFilterCount(long filterCount) {
// this.filterCount = filterCount;
// }
//
// public long getSentCount() {
// return sentCount;
// }
//
// public void setSentCount(long sentCount) {
// this.sentCount = sentCount;
// }
//
// public long getErrorCount() {
// return errorCount;
// }
//
// public void setErrorCount(long errorCount) {
// this.errorCount = errorCount;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/NormalEventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class NormalEventPush extends EventPush {
// @XmlElement(name = "EventKey")
// private String eventKey;
//
// @XmlElement(name = "Ticket")
// private String ticket;
//
// public NormalEventPush() {
// }
//
// public String getEventKey() {
// return eventKey;
// }
//
// public void setEventKey(String eventKey) {
// this.eventKey = eventKey;
// }
//
// public String getTicket() {
// return ticket;
// }
//
// public void setTicket(String ticket) {
// this.ticket = ticket;
// }
// }
| import org.usc.wechat.mp.sdk.vo.push.event.EventPush;
import org.usc.wechat.mp.sdk.vo.push.event.LocationEventPush;
import org.usc.wechat.mp.sdk.vo.push.event.MassEndJobFinishEventPush;
import org.usc.wechat.mp.sdk.vo.push.event.NormalEventPush; | package org.usc.wechat.mp.sdk.vo;
/**
*
* @author Shunli
*/
public enum EventPushType {
SUBSCRIBE("subscribe", NormalEventPush.class),
UNSUBSCRIBE("unsubscribe", NormalEventPush.class),
CLICK("CLICK", NormalEventPush.class),
VIEW("VIEW", NormalEventPush.class),
SCAN("scan", NormalEventPush.class),
LOCATION("LOCATION", LocationEventPush.class),
MASSSENDJOBFINISH("MASSSENDJOBFINISH", MassEndJobFinishEventPush.class);
private String type; | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/EventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class EventPush extends Push {
// @XmlElement(name = "Event")
// private String event;
//
// public String getEvent() {
// return event;
// }
//
// public void setEvent(String event) {
// this.event = event;
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/LocationEventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class LocationEventPush extends EventPush {
// @XmlElement(name = "Latitude")
// private String latitude;
//
// @XmlElement(name = "Longitude")
// private String longitude;
//
// @XmlElement(name = "Precision")
// private String precision;
//
// public LocationEventPush() {
// }
//
// public String getLatitude() {
// return latitude;
// }
//
// public void setLatitude(String latitude) {
// this.latitude = latitude;
// }
//
// public String getLongitude() {
// return longitude;
// }
//
// public void setLongitude(String longitude) {
// this.longitude = longitude;
// }
//
// public String getPrecision() {
// return precision;
// }
//
// public void setPrecision(String precision) {
// this.precision = precision;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/MassEndJobFinishEventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MassEndJobFinishEventPush extends EventPush {
// @XmlElement(name = "MsgID")
// private String massMsgId;
//
// @XmlElement(name = "Status")
// private String status;
//
// @XmlElement(name = "TotalCount")
// private long totalCount;
//
// @XmlElement(name = "FilterCount")
// private long filterCount;
//
// @XmlElement(name = "SentCount")
// private long sentCount;
//
// @XmlElement(name = "ErrorCount")
// private long errorCount;
//
// public MassEndJobFinishEventPush() {
// }
//
// public String getMassMsgId() {
// return massMsgId;
// }
//
// public void setMassMsgId(String massMsgId) {
// this.massMsgId = massMsgId;
// }
//
// public String getStatus() {
// return status;
// }
//
// public void setStatus(String status) {
// this.status = status;
// }
//
// public long getTotalCount() {
// return totalCount;
// }
//
// public void setTotalCount(long totalCount) {
// this.totalCount = totalCount;
// }
//
// public long getFilterCount() {
// return filterCount;
// }
//
// public void setFilterCount(long filterCount) {
// this.filterCount = filterCount;
// }
//
// public long getSentCount() {
// return sentCount;
// }
//
// public void setSentCount(long sentCount) {
// this.sentCount = sentCount;
// }
//
// public long getErrorCount() {
// return errorCount;
// }
//
// public void setErrorCount(long errorCount) {
// this.errorCount = errorCount;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/event/NormalEventPush.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class NormalEventPush extends EventPush {
// @XmlElement(name = "EventKey")
// private String eventKey;
//
// @XmlElement(name = "Ticket")
// private String ticket;
//
// public NormalEventPush() {
// }
//
// public String getEventKey() {
// return eventKey;
// }
//
// public void setEventKey(String eventKey) {
// this.eventKey = eventKey;
// }
//
// public String getTicket() {
// return ticket;
// }
//
// public void setTicket(String ticket) {
// this.ticket = ticket;
// }
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/EventPushType.java
import org.usc.wechat.mp.sdk.vo.push.event.EventPush;
import org.usc.wechat.mp.sdk.vo.push.event.LocationEventPush;
import org.usc.wechat.mp.sdk.vo.push.event.MassEndJobFinishEventPush;
import org.usc.wechat.mp.sdk.vo.push.event.NormalEventPush;
package org.usc.wechat.mp.sdk.vo;
/**
*
* @author Shunli
*/
public enum EventPushType {
SUBSCRIBE("subscribe", NormalEventPush.class),
UNSUBSCRIBE("unsubscribe", NormalEventPush.class),
CLICK("CLICK", NormalEventPush.class),
VIEW("VIEW", NormalEventPush.class),
SCAN("scan", NormalEventPush.class),
LOCATION("LOCATION", LocationEventPush.class),
MASSSENDJOBFINISH("MASSSENDJOBFINISH", MassEndJobFinishEventPush.class);
private String type; | private Class<? extends EventPush> eventPushClass; |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ImageReplyBuilder.java
// public class ImageReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
// return new ImageReply(new MediaDetail(detail.getMediaId()));
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/MusicReplyBuilder.java
// public class MusicReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// MusicDetail musicDetail = new MusicDetail(
// detail.getTitle(),
// detail.getDescription(),
// detail.getMediaUrl(),
// detail.getUrl(),
// detail.getThumbMediaId());
//
// return new MusicReply(musicDetail);
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/NewsReplyBuilder.java
// public class NewsReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// int size = replyDetails.size();
// List<NewsDetail> articles = new ArrayList<NewsDetail>(size);
// for (ReplyDetail replyDetailVo : replyDetails) {
// articles.add(new NewsDetail(
// replyDetailVo.getTitle(),
// replyDetailVo.getDescription(),
// replyDetailVo.getMediaUrl(),
// replyDetailVo.getUrl()));
// }
//
// return new NewsReply(size, articles);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ReplyBuilder.java
// public interface ReplyBuilder {
// Reply buildReply(List<ReplyDetail> replyDetails);
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/TextReplyBuilder.java
// public class TextReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// String content = replyDetails.get(0).getDescription();
// if (StringUtils.isEmpty(content)) {
// return null;
// }
//
// return new TextReply(content);
//
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/VideoReplyBuilder.java
// public class VideoReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// VideoDetail videoDetail = new VideoDetail(detail.getMediaId());
// videoDetail.setTitle(detail.getTitle());
// videoDetail.setDescription(detail.getDescription());
//
// return new VideoReply(videoDetail);
// }
//
// }
| import java.util.List;
import org.usc.wechat.mp.sdk.factory.builder.ImageReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.MusicReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.NewsReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.ReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.TextReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VideoReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VoiceReplyBuilder;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply; | package org.usc.wechat.mp.sdk.factory;
/**
*
* @author Shunli
*/
public enum ReplyEnumFactory {
TEXT("text", new TextReplyBuilder()), | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ImageReplyBuilder.java
// public class ImageReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
// return new ImageReply(new MediaDetail(detail.getMediaId()));
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/MusicReplyBuilder.java
// public class MusicReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// MusicDetail musicDetail = new MusicDetail(
// detail.getTitle(),
// detail.getDescription(),
// detail.getMediaUrl(),
// detail.getUrl(),
// detail.getThumbMediaId());
//
// return new MusicReply(musicDetail);
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/NewsReplyBuilder.java
// public class NewsReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// int size = replyDetails.size();
// List<NewsDetail> articles = new ArrayList<NewsDetail>(size);
// for (ReplyDetail replyDetailVo : replyDetails) {
// articles.add(new NewsDetail(
// replyDetailVo.getTitle(),
// replyDetailVo.getDescription(),
// replyDetailVo.getMediaUrl(),
// replyDetailVo.getUrl()));
// }
//
// return new NewsReply(size, articles);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ReplyBuilder.java
// public interface ReplyBuilder {
// Reply buildReply(List<ReplyDetail> replyDetails);
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/TextReplyBuilder.java
// public class TextReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// String content = replyDetails.get(0).getDescription();
// if (StringUtils.isEmpty(content)) {
// return null;
// }
//
// return new TextReply(content);
//
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/VideoReplyBuilder.java
// public class VideoReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// VideoDetail videoDetail = new VideoDetail(detail.getMediaId());
// videoDetail.setTitle(detail.getTitle());
// videoDetail.setDescription(detail.getDescription());
//
// return new VideoReply(videoDetail);
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
import java.util.List;
import org.usc.wechat.mp.sdk.factory.builder.ImageReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.MusicReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.NewsReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.ReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.TextReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VideoReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VoiceReplyBuilder;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
package org.usc.wechat.mp.sdk.factory;
/**
*
* @author Shunli
*/
public enum ReplyEnumFactory {
TEXT("text", new TextReplyBuilder()), | NEWS("news", new NewsReplyBuilder()), |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ImageReplyBuilder.java
// public class ImageReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
// return new ImageReply(new MediaDetail(detail.getMediaId()));
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/MusicReplyBuilder.java
// public class MusicReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// MusicDetail musicDetail = new MusicDetail(
// detail.getTitle(),
// detail.getDescription(),
// detail.getMediaUrl(),
// detail.getUrl(),
// detail.getThumbMediaId());
//
// return new MusicReply(musicDetail);
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/NewsReplyBuilder.java
// public class NewsReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// int size = replyDetails.size();
// List<NewsDetail> articles = new ArrayList<NewsDetail>(size);
// for (ReplyDetail replyDetailVo : replyDetails) {
// articles.add(new NewsDetail(
// replyDetailVo.getTitle(),
// replyDetailVo.getDescription(),
// replyDetailVo.getMediaUrl(),
// replyDetailVo.getUrl()));
// }
//
// return new NewsReply(size, articles);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ReplyBuilder.java
// public interface ReplyBuilder {
// Reply buildReply(List<ReplyDetail> replyDetails);
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/TextReplyBuilder.java
// public class TextReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// String content = replyDetails.get(0).getDescription();
// if (StringUtils.isEmpty(content)) {
// return null;
// }
//
// return new TextReply(content);
//
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/VideoReplyBuilder.java
// public class VideoReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// VideoDetail videoDetail = new VideoDetail(detail.getMediaId());
// videoDetail.setTitle(detail.getTitle());
// videoDetail.setDescription(detail.getDescription());
//
// return new VideoReply(videoDetail);
// }
//
// }
| import java.util.List;
import org.usc.wechat.mp.sdk.factory.builder.ImageReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.MusicReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.NewsReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.ReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.TextReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VideoReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VoiceReplyBuilder;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply; | package org.usc.wechat.mp.sdk.factory;
/**
*
* @author Shunli
*/
public enum ReplyEnumFactory {
TEXT("text", new TextReplyBuilder()),
NEWS("news", new NewsReplyBuilder()), | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ImageReplyBuilder.java
// public class ImageReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
// return new ImageReply(new MediaDetail(detail.getMediaId()));
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/MusicReplyBuilder.java
// public class MusicReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// MusicDetail musicDetail = new MusicDetail(
// detail.getTitle(),
// detail.getDescription(),
// detail.getMediaUrl(),
// detail.getUrl(),
// detail.getThumbMediaId());
//
// return new MusicReply(musicDetail);
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/NewsReplyBuilder.java
// public class NewsReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// int size = replyDetails.size();
// List<NewsDetail> articles = new ArrayList<NewsDetail>(size);
// for (ReplyDetail replyDetailVo : replyDetails) {
// articles.add(new NewsDetail(
// replyDetailVo.getTitle(),
// replyDetailVo.getDescription(),
// replyDetailVo.getMediaUrl(),
// replyDetailVo.getUrl()));
// }
//
// return new NewsReply(size, articles);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ReplyBuilder.java
// public interface ReplyBuilder {
// Reply buildReply(List<ReplyDetail> replyDetails);
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/TextReplyBuilder.java
// public class TextReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// String content = replyDetails.get(0).getDescription();
// if (StringUtils.isEmpty(content)) {
// return null;
// }
//
// return new TextReply(content);
//
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/VideoReplyBuilder.java
// public class VideoReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// VideoDetail videoDetail = new VideoDetail(detail.getMediaId());
// videoDetail.setTitle(detail.getTitle());
// videoDetail.setDescription(detail.getDescription());
//
// return new VideoReply(videoDetail);
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
import java.util.List;
import org.usc.wechat.mp.sdk.factory.builder.ImageReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.MusicReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.NewsReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.ReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.TextReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VideoReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VoiceReplyBuilder;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
package org.usc.wechat.mp.sdk.factory;
/**
*
* @author Shunli
*/
public enum ReplyEnumFactory {
TEXT("text", new TextReplyBuilder()),
NEWS("news", new NewsReplyBuilder()), | MUSIC("music", new MusicReplyBuilder()), |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ImageReplyBuilder.java
// public class ImageReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
// return new ImageReply(new MediaDetail(detail.getMediaId()));
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/MusicReplyBuilder.java
// public class MusicReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// MusicDetail musicDetail = new MusicDetail(
// detail.getTitle(),
// detail.getDescription(),
// detail.getMediaUrl(),
// detail.getUrl(),
// detail.getThumbMediaId());
//
// return new MusicReply(musicDetail);
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/NewsReplyBuilder.java
// public class NewsReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// int size = replyDetails.size();
// List<NewsDetail> articles = new ArrayList<NewsDetail>(size);
// for (ReplyDetail replyDetailVo : replyDetails) {
// articles.add(new NewsDetail(
// replyDetailVo.getTitle(),
// replyDetailVo.getDescription(),
// replyDetailVo.getMediaUrl(),
// replyDetailVo.getUrl()));
// }
//
// return new NewsReply(size, articles);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ReplyBuilder.java
// public interface ReplyBuilder {
// Reply buildReply(List<ReplyDetail> replyDetails);
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/TextReplyBuilder.java
// public class TextReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// String content = replyDetails.get(0).getDescription();
// if (StringUtils.isEmpty(content)) {
// return null;
// }
//
// return new TextReply(content);
//
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/VideoReplyBuilder.java
// public class VideoReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// VideoDetail videoDetail = new VideoDetail(detail.getMediaId());
// videoDetail.setTitle(detail.getTitle());
// videoDetail.setDescription(detail.getDescription());
//
// return new VideoReply(videoDetail);
// }
//
// }
| import java.util.List;
import org.usc.wechat.mp.sdk.factory.builder.ImageReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.MusicReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.NewsReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.ReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.TextReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VideoReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VoiceReplyBuilder;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply; | package org.usc.wechat.mp.sdk.factory;
/**
*
* @author Shunli
*/
public enum ReplyEnumFactory {
TEXT("text", new TextReplyBuilder()),
NEWS("news", new NewsReplyBuilder()),
MUSIC("music", new MusicReplyBuilder()), | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ImageReplyBuilder.java
// public class ImageReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
// return new ImageReply(new MediaDetail(detail.getMediaId()));
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/MusicReplyBuilder.java
// public class MusicReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// MusicDetail musicDetail = new MusicDetail(
// detail.getTitle(),
// detail.getDescription(),
// detail.getMediaUrl(),
// detail.getUrl(),
// detail.getThumbMediaId());
//
// return new MusicReply(musicDetail);
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/NewsReplyBuilder.java
// public class NewsReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// int size = replyDetails.size();
// List<NewsDetail> articles = new ArrayList<NewsDetail>(size);
// for (ReplyDetail replyDetailVo : replyDetails) {
// articles.add(new NewsDetail(
// replyDetailVo.getTitle(),
// replyDetailVo.getDescription(),
// replyDetailVo.getMediaUrl(),
// replyDetailVo.getUrl()));
// }
//
// return new NewsReply(size, articles);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ReplyBuilder.java
// public interface ReplyBuilder {
// Reply buildReply(List<ReplyDetail> replyDetails);
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/TextReplyBuilder.java
// public class TextReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// String content = replyDetails.get(0).getDescription();
// if (StringUtils.isEmpty(content)) {
// return null;
// }
//
// return new TextReply(content);
//
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/VideoReplyBuilder.java
// public class VideoReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// VideoDetail videoDetail = new VideoDetail(detail.getMediaId());
// videoDetail.setTitle(detail.getTitle());
// videoDetail.setDescription(detail.getDescription());
//
// return new VideoReply(videoDetail);
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
import java.util.List;
import org.usc.wechat.mp.sdk.factory.builder.ImageReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.MusicReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.NewsReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.ReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.TextReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VideoReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VoiceReplyBuilder;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
package org.usc.wechat.mp.sdk.factory;
/**
*
* @author Shunli
*/
public enum ReplyEnumFactory {
TEXT("text", new TextReplyBuilder()),
NEWS("news", new NewsReplyBuilder()),
MUSIC("music", new MusicReplyBuilder()), | IMAGE("image", new ImageReplyBuilder()), |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ImageReplyBuilder.java
// public class ImageReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
// return new ImageReply(new MediaDetail(detail.getMediaId()));
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/MusicReplyBuilder.java
// public class MusicReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// MusicDetail musicDetail = new MusicDetail(
// detail.getTitle(),
// detail.getDescription(),
// detail.getMediaUrl(),
// detail.getUrl(),
// detail.getThumbMediaId());
//
// return new MusicReply(musicDetail);
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/NewsReplyBuilder.java
// public class NewsReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// int size = replyDetails.size();
// List<NewsDetail> articles = new ArrayList<NewsDetail>(size);
// for (ReplyDetail replyDetailVo : replyDetails) {
// articles.add(new NewsDetail(
// replyDetailVo.getTitle(),
// replyDetailVo.getDescription(),
// replyDetailVo.getMediaUrl(),
// replyDetailVo.getUrl()));
// }
//
// return new NewsReply(size, articles);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ReplyBuilder.java
// public interface ReplyBuilder {
// Reply buildReply(List<ReplyDetail> replyDetails);
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/TextReplyBuilder.java
// public class TextReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// String content = replyDetails.get(0).getDescription();
// if (StringUtils.isEmpty(content)) {
// return null;
// }
//
// return new TextReply(content);
//
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/VideoReplyBuilder.java
// public class VideoReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// VideoDetail videoDetail = new VideoDetail(detail.getMediaId());
// videoDetail.setTitle(detail.getTitle());
// videoDetail.setDescription(detail.getDescription());
//
// return new VideoReply(videoDetail);
// }
//
// }
| import java.util.List;
import org.usc.wechat.mp.sdk.factory.builder.ImageReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.MusicReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.NewsReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.ReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.TextReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VideoReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VoiceReplyBuilder;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply; | package org.usc.wechat.mp.sdk.factory;
/**
*
* @author Shunli
*/
public enum ReplyEnumFactory {
TEXT("text", new TextReplyBuilder()),
NEWS("news", new NewsReplyBuilder()),
MUSIC("music", new MusicReplyBuilder()),
IMAGE("image", new ImageReplyBuilder()),
VOICE("voice", new VoiceReplyBuilder()), | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ImageReplyBuilder.java
// public class ImageReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
// return new ImageReply(new MediaDetail(detail.getMediaId()));
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/MusicReplyBuilder.java
// public class MusicReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// MusicDetail musicDetail = new MusicDetail(
// detail.getTitle(),
// detail.getDescription(),
// detail.getMediaUrl(),
// detail.getUrl(),
// detail.getThumbMediaId());
//
// return new MusicReply(musicDetail);
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/NewsReplyBuilder.java
// public class NewsReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// int size = replyDetails.size();
// List<NewsDetail> articles = new ArrayList<NewsDetail>(size);
// for (ReplyDetail replyDetailVo : replyDetails) {
// articles.add(new NewsDetail(
// replyDetailVo.getTitle(),
// replyDetailVo.getDescription(),
// replyDetailVo.getMediaUrl(),
// replyDetailVo.getUrl()));
// }
//
// return new NewsReply(size, articles);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ReplyBuilder.java
// public interface ReplyBuilder {
// Reply buildReply(List<ReplyDetail> replyDetails);
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/TextReplyBuilder.java
// public class TextReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// String content = replyDetails.get(0).getDescription();
// if (StringUtils.isEmpty(content)) {
// return null;
// }
//
// return new TextReply(content);
//
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/VideoReplyBuilder.java
// public class VideoReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// VideoDetail videoDetail = new VideoDetail(detail.getMediaId());
// videoDetail.setTitle(detail.getTitle());
// videoDetail.setDescription(detail.getDescription());
//
// return new VideoReply(videoDetail);
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
import java.util.List;
import org.usc.wechat.mp.sdk.factory.builder.ImageReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.MusicReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.NewsReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.ReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.TextReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VideoReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VoiceReplyBuilder;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
package org.usc.wechat.mp.sdk.factory;
/**
*
* @author Shunli
*/
public enum ReplyEnumFactory {
TEXT("text", new TextReplyBuilder()),
NEWS("news", new NewsReplyBuilder()),
MUSIC("music", new MusicReplyBuilder()),
IMAGE("image", new ImageReplyBuilder()),
VOICE("voice", new VoiceReplyBuilder()), | VIDEO("video", new VideoReplyBuilder()); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ImageReplyBuilder.java
// public class ImageReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
// return new ImageReply(new MediaDetail(detail.getMediaId()));
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/MusicReplyBuilder.java
// public class MusicReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// MusicDetail musicDetail = new MusicDetail(
// detail.getTitle(),
// detail.getDescription(),
// detail.getMediaUrl(),
// detail.getUrl(),
// detail.getThumbMediaId());
//
// return new MusicReply(musicDetail);
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/NewsReplyBuilder.java
// public class NewsReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// int size = replyDetails.size();
// List<NewsDetail> articles = new ArrayList<NewsDetail>(size);
// for (ReplyDetail replyDetailVo : replyDetails) {
// articles.add(new NewsDetail(
// replyDetailVo.getTitle(),
// replyDetailVo.getDescription(),
// replyDetailVo.getMediaUrl(),
// replyDetailVo.getUrl()));
// }
//
// return new NewsReply(size, articles);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ReplyBuilder.java
// public interface ReplyBuilder {
// Reply buildReply(List<ReplyDetail> replyDetails);
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/TextReplyBuilder.java
// public class TextReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// String content = replyDetails.get(0).getDescription();
// if (StringUtils.isEmpty(content)) {
// return null;
// }
//
// return new TextReply(content);
//
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/VideoReplyBuilder.java
// public class VideoReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// VideoDetail videoDetail = new VideoDetail(detail.getMediaId());
// videoDetail.setTitle(detail.getTitle());
// videoDetail.setDescription(detail.getDescription());
//
// return new VideoReply(videoDetail);
// }
//
// }
| import java.util.List;
import org.usc.wechat.mp.sdk.factory.builder.ImageReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.MusicReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.NewsReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.ReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.TextReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VideoReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VoiceReplyBuilder;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply; | package org.usc.wechat.mp.sdk.factory;
/**
*
* @author Shunli
*/
public enum ReplyEnumFactory {
TEXT("text", new TextReplyBuilder()),
NEWS("news", new NewsReplyBuilder()),
MUSIC("music", new MusicReplyBuilder()),
IMAGE("image", new ImageReplyBuilder()),
VOICE("voice", new VoiceReplyBuilder()),
VIDEO("video", new VideoReplyBuilder());
private String replyType; | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ImageReplyBuilder.java
// public class ImageReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
// return new ImageReply(new MediaDetail(detail.getMediaId()));
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/MusicReplyBuilder.java
// public class MusicReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// MusicDetail musicDetail = new MusicDetail(
// detail.getTitle(),
// detail.getDescription(),
// detail.getMediaUrl(),
// detail.getUrl(),
// detail.getThumbMediaId());
//
// return new MusicReply(musicDetail);
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/NewsReplyBuilder.java
// public class NewsReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// int size = replyDetails.size();
// List<NewsDetail> articles = new ArrayList<NewsDetail>(size);
// for (ReplyDetail replyDetailVo : replyDetails) {
// articles.add(new NewsDetail(
// replyDetailVo.getTitle(),
// replyDetailVo.getDescription(),
// replyDetailVo.getMediaUrl(),
// replyDetailVo.getUrl()));
// }
//
// return new NewsReply(size, articles);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ReplyBuilder.java
// public interface ReplyBuilder {
// Reply buildReply(List<ReplyDetail> replyDetails);
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/TextReplyBuilder.java
// public class TextReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// String content = replyDetails.get(0).getDescription();
// if (StringUtils.isEmpty(content)) {
// return null;
// }
//
// return new TextReply(content);
//
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/VideoReplyBuilder.java
// public class VideoReplyBuilder implements ReplyBuilder {
// @Override
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// ReplyDetail detail = replyDetails.get(0);
//
// VideoDetail videoDetail = new VideoDetail(detail.getMediaId());
// videoDetail.setTitle(detail.getTitle());
// videoDetail.setDescription(detail.getDescription());
//
// return new VideoReply(videoDetail);
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
import java.util.List;
import org.usc.wechat.mp.sdk.factory.builder.ImageReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.MusicReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.NewsReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.ReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.TextReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VideoReplyBuilder;
import org.usc.wechat.mp.sdk.factory.builder.VoiceReplyBuilder;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
package org.usc.wechat.mp.sdk.factory;
/**
*
* @author Shunli
*/
public enum ReplyEnumFactory {
TEXT("text", new TextReplyBuilder()),
NEWS("news", new NewsReplyBuilder()),
MUSIC("music", new MusicReplyBuilder()),
IMAGE("image", new ImageReplyBuilder()),
VOICE("voice", new VoiceReplyBuilder()),
VIDEO("video", new VideoReplyBuilder());
private String replyType; | private ReplyBuilder replyBuilder; |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/VideoCustomMessage.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/detail/VideoCustomMessageDetail.java
// public class VideoCustomMessageDetail extends MediaCustomMessageDetail {
// @JSONField(name = "title")
// private String title;
//
// @JSONField(name = "description")
// private String description;
//
// protected VideoCustomMessageDetail() {
// }
//
// public VideoCustomMessageDetail(String mediaId) {
// super(mediaId);
// }
//
// public VideoCustomMessageDetail(String mediaId, String title, String description) {
// super(mediaId);
// this.title = title;
// this.description = description;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// }
| import org.usc.wechat.mp.sdk.vo.message.custom.detail.VideoCustomMessageDetail;
import com.alibaba.fastjson.annotation.JSONField; | package org.usc.wechat.mp.sdk.vo.message.custom;
/**
*
* @author Shunli
*/
public class VideoCustomMessage extends CustomMessage {
@JSONField(name = "video") | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/detail/VideoCustomMessageDetail.java
// public class VideoCustomMessageDetail extends MediaCustomMessageDetail {
// @JSONField(name = "title")
// private String title;
//
// @JSONField(name = "description")
// private String description;
//
// protected VideoCustomMessageDetail() {
// }
//
// public VideoCustomMessageDetail(String mediaId) {
// super(mediaId);
// }
//
// public VideoCustomMessageDetail(String mediaId, String title, String description) {
// super(mediaId);
// this.title = title;
// this.description = description;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/VideoCustomMessage.java
import org.usc.wechat.mp.sdk.vo.message.custom.detail.VideoCustomMessageDetail;
import com.alibaba.fastjson.annotation.JSONField;
package org.usc.wechat.mp.sdk.vo.message.custom;
/**
*
* @author Shunli
*/
public class VideoCustomMessage extends CustomMessage {
@JSONField(name = "video") | private VideoCustomMessageDetail videoDetail; |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/MusicCustomMessage.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/detail/MusicCustomMessageDetail.java
// public class MusicCustomMessageDetail extends AbstractToStringBuilder{
// @JSONField(name = "title")
// private String title;
//
// @JSONField(name = "description")
// private String description;
//
// @JSONField(name = "musicurl")
// private String musicUrl;
//
// @JSONField(name = "hqmusicurl")
// private String hqMusicUrl;
//
// @JSONField(name = "thumb_media_id")
// private String thumbMediaId;
//
// protected MusicCustomMessageDetail() {
// }
//
// public MusicCustomMessageDetail(String musicUrl, String hqMusicUrl, String thumbMediaId) {
// this.musicUrl = musicUrl;
// this.hqMusicUrl = hqMusicUrl;
// this.thumbMediaId = thumbMediaId;
// }
//
// public MusicCustomMessageDetail(String title, String description, String musicUrl, String hqMusicUrl, String thumbMediaId) {
// this.title = title;
// this.description = description;
// this.musicUrl = musicUrl;
// this.hqMusicUrl = hqMusicUrl;
// this.thumbMediaId = thumbMediaId;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getMusicUrl() {
// return musicUrl;
// }
//
// public void setMusicUrl(String musicUrl) {
// this.musicUrl = musicUrl;
// }
//
// public String getHqMusicUrl() {
// return hqMusicUrl;
// }
//
// public void setHqMusicUrl(String hqMusicUrl) {
// this.hqMusicUrl = hqMusicUrl;
// }
//
// public String getThumbMediaId() {
// return thumbMediaId;
// }
//
// public void setThumbMediaId(String thumbMediaId) {
// this.thumbMediaId = thumbMediaId;
// }
// }
| import org.usc.wechat.mp.sdk.vo.message.custom.detail.MusicCustomMessageDetail;
import com.alibaba.fastjson.annotation.JSONField; | package org.usc.wechat.mp.sdk.vo.message.custom;
/**
*
* @author Shunli
*/
public class MusicCustomMessage extends CustomMessage {
@JSONField(name = "music") | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/detail/MusicCustomMessageDetail.java
// public class MusicCustomMessageDetail extends AbstractToStringBuilder{
// @JSONField(name = "title")
// private String title;
//
// @JSONField(name = "description")
// private String description;
//
// @JSONField(name = "musicurl")
// private String musicUrl;
//
// @JSONField(name = "hqmusicurl")
// private String hqMusicUrl;
//
// @JSONField(name = "thumb_media_id")
// private String thumbMediaId;
//
// protected MusicCustomMessageDetail() {
// }
//
// public MusicCustomMessageDetail(String musicUrl, String hqMusicUrl, String thumbMediaId) {
// this.musicUrl = musicUrl;
// this.hqMusicUrl = hqMusicUrl;
// this.thumbMediaId = thumbMediaId;
// }
//
// public MusicCustomMessageDetail(String title, String description, String musicUrl, String hqMusicUrl, String thumbMediaId) {
// this.title = title;
// this.description = description;
// this.musicUrl = musicUrl;
// this.hqMusicUrl = hqMusicUrl;
// this.thumbMediaId = thumbMediaId;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getMusicUrl() {
// return musicUrl;
// }
//
// public void setMusicUrl(String musicUrl) {
// this.musicUrl = musicUrl;
// }
//
// public String getHqMusicUrl() {
// return hqMusicUrl;
// }
//
// public void setHqMusicUrl(String hqMusicUrl) {
// this.hqMusicUrl = hqMusicUrl;
// }
//
// public String getThumbMediaId() {
// return thumbMediaId;
// }
//
// public void setThumbMediaId(String thumbMediaId) {
// this.thumbMediaId = thumbMediaId;
// }
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/MusicCustomMessage.java
import org.usc.wechat.mp.sdk.vo.message.custom.detail.MusicCustomMessageDetail;
import com.alibaba.fastjson.annotation.JSONField;
package org.usc.wechat.mp.sdk.vo.message.custom;
/**
*
* @author Shunli
*/
public class MusicCustomMessage extends CustomMessage {
@JSONField(name = "music") | private MusicCustomMessageDetail musicDetail; |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ImageReplyBuilder.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/ImageReply.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class ImageReply extends Reply {
// @XmlElement(name = "Image")
// private MediaDetail imageDetail;
//
// {
// super.setMsgType(ReplyEnumFactory.IMAGE.getReplyType());
// }
//
// public ImageReply() {
// }
//
// public ImageReply(MediaDetail imageDetail) {
// this.imageDetail = imageDetail;
// }
//
// public MediaDetail getImageDetail() {
// return imageDetail;
// }
//
// public void setImageDetail(MediaDetail imageDetail) {
// this.imageDetail = imageDetail;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/MediaDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MediaDetail extends AbstractToStringBuilder {
// @XmlElement(name = "MediaId")
// private String mediaId;
//
// public MediaDetail() {
// }
//
// public MediaDetail(String mediaId) {
// this.mediaId = mediaId;
// }
//
// public String getMediaId() {
// return mediaId;
// }
//
// public void setMediaId(String mediaId) {
// this.mediaId = mediaId;
// }
//
// }
| import java.util.List;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.ImageReply;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.MediaDetail; | package org.usc.wechat.mp.sdk.factory.builder;
/**
*
* @author Shunli
*/
public class ImageReplyBuilder implements ReplyBuilder {
@Override
public Reply buildReply(List<ReplyDetail> replyDetails) {
ReplyDetail detail = replyDetails.get(0); | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/ImageReply.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class ImageReply extends Reply {
// @XmlElement(name = "Image")
// private MediaDetail imageDetail;
//
// {
// super.setMsgType(ReplyEnumFactory.IMAGE.getReplyType());
// }
//
// public ImageReply() {
// }
//
// public ImageReply(MediaDetail imageDetail) {
// this.imageDetail = imageDetail;
// }
//
// public MediaDetail getImageDetail() {
// return imageDetail;
// }
//
// public void setImageDetail(MediaDetail imageDetail) {
// this.imageDetail = imageDetail;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/MediaDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MediaDetail extends AbstractToStringBuilder {
// @XmlElement(name = "MediaId")
// private String mediaId;
//
// public MediaDetail() {
// }
//
// public MediaDetail(String mediaId) {
// this.mediaId = mediaId;
// }
//
// public String getMediaId() {
// return mediaId;
// }
//
// public void setMediaId(String mediaId) {
// this.mediaId = mediaId;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ImageReplyBuilder.java
import java.util.List;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.ImageReply;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.MediaDetail;
package org.usc.wechat.mp.sdk.factory.builder;
/**
*
* @author Shunli
*/
public class ImageReplyBuilder implements ReplyBuilder {
@Override
public Reply buildReply(List<ReplyDetail> replyDetails) {
ReplyDetail detail = replyDetails.get(0); | return new ImageReply(new MediaDetail(detail.getMediaId())); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ImageReplyBuilder.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/ImageReply.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class ImageReply extends Reply {
// @XmlElement(name = "Image")
// private MediaDetail imageDetail;
//
// {
// super.setMsgType(ReplyEnumFactory.IMAGE.getReplyType());
// }
//
// public ImageReply() {
// }
//
// public ImageReply(MediaDetail imageDetail) {
// this.imageDetail = imageDetail;
// }
//
// public MediaDetail getImageDetail() {
// return imageDetail;
// }
//
// public void setImageDetail(MediaDetail imageDetail) {
// this.imageDetail = imageDetail;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/MediaDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MediaDetail extends AbstractToStringBuilder {
// @XmlElement(name = "MediaId")
// private String mediaId;
//
// public MediaDetail() {
// }
//
// public MediaDetail(String mediaId) {
// this.mediaId = mediaId;
// }
//
// public String getMediaId() {
// return mediaId;
// }
//
// public void setMediaId(String mediaId) {
// this.mediaId = mediaId;
// }
//
// }
| import java.util.List;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.ImageReply;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.MediaDetail; | package org.usc.wechat.mp.sdk.factory.builder;
/**
*
* @author Shunli
*/
public class ImageReplyBuilder implements ReplyBuilder {
@Override
public Reply buildReply(List<ReplyDetail> replyDetails) {
ReplyDetail detail = replyDetails.get(0); | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/ImageReply.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class ImageReply extends Reply {
// @XmlElement(name = "Image")
// private MediaDetail imageDetail;
//
// {
// super.setMsgType(ReplyEnumFactory.IMAGE.getReplyType());
// }
//
// public ImageReply() {
// }
//
// public ImageReply(MediaDetail imageDetail) {
// this.imageDetail = imageDetail;
// }
//
// public MediaDetail getImageDetail() {
// return imageDetail;
// }
//
// public void setImageDetail(MediaDetail imageDetail) {
// this.imageDetail = imageDetail;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/MediaDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MediaDetail extends AbstractToStringBuilder {
// @XmlElement(name = "MediaId")
// private String mediaId;
//
// public MediaDetail() {
// }
//
// public MediaDetail(String mediaId) {
// this.mediaId = mediaId;
// }
//
// public String getMediaId() {
// return mediaId;
// }
//
// public void setMediaId(String mediaId) {
// this.mediaId = mediaId;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/ImageReplyBuilder.java
import java.util.List;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.ImageReply;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.MediaDetail;
package org.usc.wechat.mp.sdk.factory.builder;
/**
*
* @author Shunli
*/
public class ImageReplyBuilder implements ReplyBuilder {
@Override
public Reply buildReply(List<ReplyDetail> replyDetails) {
ReplyDetail detail = replyDetails.get(0); | return new ImageReply(new MediaDetail(detail.getMediaId())); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/test/java/org/usc/wechat/mp/sdk/util/platform/QRcodeUtilTest.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/util/JsonRtnUtil.java
// public class JsonRtnUtil {
// private static final String WECHAT_GLOBAL_MESSAGE_FILE_NAME = "wechate-global-message";
// private static final String WECHAT_JSON_RTN_SUCCESS_CODE = "0";
// private static ResourceBundle bundle;
//
// static {
// try {
// bundle = ResourceBundle.getBundle(WECHAT_GLOBAL_MESSAGE_FILE_NAME);
// } catch (Exception e) {
// }
// }
//
// /**
// * parse json text to specified class
// *
// * @param jsonRtn
// * @param jsonRtnClazz
// * @return
// */
// public static <T extends JsonRtn> T parseJsonRtn(String jsonRtn, Class<T> jsonRtnClazz) {
// T rtn = JSONObject.parseObject(jsonRtn, jsonRtnClazz);
// appendErrorHumanMsg(rtn);
// return rtn;
// }
//
// /**
// * append human message to JsonRtn class
// *
// * @param jsonRtn
// * @return
// */
// private static JsonRtn appendErrorHumanMsg(JsonRtn jsonRtn) {
// if (bundle == null || jsonRtn == null || StringUtils.isEmpty(jsonRtn.getErrCode())) {
// return null;
// }
//
// try {
// jsonRtn.setErrHumanMsg(bundle.getString(jsonRtn.getErrCode()));
// return jsonRtn;
// } catch (Exception e) {
// return null;
// }
// }
//
// /**
// * return request is success by JsonRtn object
// *
// * @param jsonRtn
// * @return
// */
// public static boolean isSuccess(JsonRtn jsonRtn) {
// if (jsonRtn == null) {
// return false;
// }
//
// String errCode = jsonRtn.getErrCode();
// if (StringUtils.isEmpty(errCode) || StringUtils.equals(WECHAT_JSON_RTN_SUCCESS_CODE, errCode)) {
// return true;
// }
//
// return false;
// }
//
// public static <T extends JsonRtn> T buildFailureJsonRtn(Class<T> jsonRtnClazz, String errMsg) {
// try {
// T jsonRtn = jsonRtnClazz.newInstance();
// jsonRtn.setErrCode("-1");
// jsonRtn.setErrMsg(errMsg);
//
// appendErrorHumanMsg(jsonRtn);
//
// return jsonRtn;
// } catch (Exception e) {
// return null;
// }
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/qrcode/QRcodeTicketJsonRtn.java
// public class QRcodeTicketJsonRtn extends JsonRtn {
// @JSONField(name = "ticket")
// private String ticket;
//
// @JSONField(name = "expire_seconds")
// private int expireSeconds = -1;
//
// public QRcodeTicketJsonRtn() {
// }
//
// public String getTicket() {
// return ticket;
// }
//
// public void setTicket(String ticket) {
// this.ticket = ticket;
// }
//
// public int getExpireSeconds() {
// return expireSeconds;
// }
//
// public void setExpireSeconds(int expireSeconds) {
// this.expireSeconds = expireSeconds;
// }
//
// }
| import org.usc.wechat.mp.sdk.util.JsonRtnUtil;
import org.usc.wechat.mp.sdk.vo.qrcode.QRcodeTicketJsonRtn; | package org.usc.wechat.mp.sdk.util.platform;
/**
*
* @author Shunli
*/
public class QRcodeUtilTest {
public static void main(String[] args) { | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/util/JsonRtnUtil.java
// public class JsonRtnUtil {
// private static final String WECHAT_GLOBAL_MESSAGE_FILE_NAME = "wechate-global-message";
// private static final String WECHAT_JSON_RTN_SUCCESS_CODE = "0";
// private static ResourceBundle bundle;
//
// static {
// try {
// bundle = ResourceBundle.getBundle(WECHAT_GLOBAL_MESSAGE_FILE_NAME);
// } catch (Exception e) {
// }
// }
//
// /**
// * parse json text to specified class
// *
// * @param jsonRtn
// * @param jsonRtnClazz
// * @return
// */
// public static <T extends JsonRtn> T parseJsonRtn(String jsonRtn, Class<T> jsonRtnClazz) {
// T rtn = JSONObject.parseObject(jsonRtn, jsonRtnClazz);
// appendErrorHumanMsg(rtn);
// return rtn;
// }
//
// /**
// * append human message to JsonRtn class
// *
// * @param jsonRtn
// * @return
// */
// private static JsonRtn appendErrorHumanMsg(JsonRtn jsonRtn) {
// if (bundle == null || jsonRtn == null || StringUtils.isEmpty(jsonRtn.getErrCode())) {
// return null;
// }
//
// try {
// jsonRtn.setErrHumanMsg(bundle.getString(jsonRtn.getErrCode()));
// return jsonRtn;
// } catch (Exception e) {
// return null;
// }
// }
//
// /**
// * return request is success by JsonRtn object
// *
// * @param jsonRtn
// * @return
// */
// public static boolean isSuccess(JsonRtn jsonRtn) {
// if (jsonRtn == null) {
// return false;
// }
//
// String errCode = jsonRtn.getErrCode();
// if (StringUtils.isEmpty(errCode) || StringUtils.equals(WECHAT_JSON_RTN_SUCCESS_CODE, errCode)) {
// return true;
// }
//
// return false;
// }
//
// public static <T extends JsonRtn> T buildFailureJsonRtn(Class<T> jsonRtnClazz, String errMsg) {
// try {
// T jsonRtn = jsonRtnClazz.newInstance();
// jsonRtn.setErrCode("-1");
// jsonRtn.setErrMsg(errMsg);
//
// appendErrorHumanMsg(jsonRtn);
//
// return jsonRtn;
// } catch (Exception e) {
// return null;
// }
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/qrcode/QRcodeTicketJsonRtn.java
// public class QRcodeTicketJsonRtn extends JsonRtn {
// @JSONField(name = "ticket")
// private String ticket;
//
// @JSONField(name = "expire_seconds")
// private int expireSeconds = -1;
//
// public QRcodeTicketJsonRtn() {
// }
//
// public String getTicket() {
// return ticket;
// }
//
// public void setTicket(String ticket) {
// this.ticket = ticket;
// }
//
// public int getExpireSeconds() {
// return expireSeconds;
// }
//
// public void setExpireSeconds(int expireSeconds) {
// this.expireSeconds = expireSeconds;
// }
//
// }
// Path: wechat-mp-sdk/src/test/java/org/usc/wechat/mp/sdk/util/platform/QRcodeUtilTest.java
import org.usc.wechat.mp.sdk.util.JsonRtnUtil;
import org.usc.wechat.mp.sdk.vo.qrcode.QRcodeTicketJsonRtn;
package org.usc.wechat.mp.sdk.util.platform;
/**
*
* @author Shunli
*/
public class QRcodeUtilTest {
public static void main(String[] args) { | QRcodeTicketJsonRtn jsonRtn = QRcodeUtil.createPermanentQRcode(Constants.LICENSE, 1); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/test/java/org/usc/wechat/mp/sdk/util/platform/QRcodeUtilTest.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/util/JsonRtnUtil.java
// public class JsonRtnUtil {
// private static final String WECHAT_GLOBAL_MESSAGE_FILE_NAME = "wechate-global-message";
// private static final String WECHAT_JSON_RTN_SUCCESS_CODE = "0";
// private static ResourceBundle bundle;
//
// static {
// try {
// bundle = ResourceBundle.getBundle(WECHAT_GLOBAL_MESSAGE_FILE_NAME);
// } catch (Exception e) {
// }
// }
//
// /**
// * parse json text to specified class
// *
// * @param jsonRtn
// * @param jsonRtnClazz
// * @return
// */
// public static <T extends JsonRtn> T parseJsonRtn(String jsonRtn, Class<T> jsonRtnClazz) {
// T rtn = JSONObject.parseObject(jsonRtn, jsonRtnClazz);
// appendErrorHumanMsg(rtn);
// return rtn;
// }
//
// /**
// * append human message to JsonRtn class
// *
// * @param jsonRtn
// * @return
// */
// private static JsonRtn appendErrorHumanMsg(JsonRtn jsonRtn) {
// if (bundle == null || jsonRtn == null || StringUtils.isEmpty(jsonRtn.getErrCode())) {
// return null;
// }
//
// try {
// jsonRtn.setErrHumanMsg(bundle.getString(jsonRtn.getErrCode()));
// return jsonRtn;
// } catch (Exception e) {
// return null;
// }
// }
//
// /**
// * return request is success by JsonRtn object
// *
// * @param jsonRtn
// * @return
// */
// public static boolean isSuccess(JsonRtn jsonRtn) {
// if (jsonRtn == null) {
// return false;
// }
//
// String errCode = jsonRtn.getErrCode();
// if (StringUtils.isEmpty(errCode) || StringUtils.equals(WECHAT_JSON_RTN_SUCCESS_CODE, errCode)) {
// return true;
// }
//
// return false;
// }
//
// public static <T extends JsonRtn> T buildFailureJsonRtn(Class<T> jsonRtnClazz, String errMsg) {
// try {
// T jsonRtn = jsonRtnClazz.newInstance();
// jsonRtn.setErrCode("-1");
// jsonRtn.setErrMsg(errMsg);
//
// appendErrorHumanMsg(jsonRtn);
//
// return jsonRtn;
// } catch (Exception e) {
// return null;
// }
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/qrcode/QRcodeTicketJsonRtn.java
// public class QRcodeTicketJsonRtn extends JsonRtn {
// @JSONField(name = "ticket")
// private String ticket;
//
// @JSONField(name = "expire_seconds")
// private int expireSeconds = -1;
//
// public QRcodeTicketJsonRtn() {
// }
//
// public String getTicket() {
// return ticket;
// }
//
// public void setTicket(String ticket) {
// this.ticket = ticket;
// }
//
// public int getExpireSeconds() {
// return expireSeconds;
// }
//
// public void setExpireSeconds(int expireSeconds) {
// this.expireSeconds = expireSeconds;
// }
//
// }
| import org.usc.wechat.mp.sdk.util.JsonRtnUtil;
import org.usc.wechat.mp.sdk.vo.qrcode.QRcodeTicketJsonRtn; | package org.usc.wechat.mp.sdk.util.platform;
/**
*
* @author Shunli
*/
public class QRcodeUtilTest {
public static void main(String[] args) {
QRcodeTicketJsonRtn jsonRtn = QRcodeUtil.createPermanentQRcode(Constants.LICENSE, 1);
handleTicket(jsonRtn);
jsonRtn = QRcodeUtil.createTemporaryQRcode(Constants.LICENSE, 2, 1800);
handleTicket(jsonRtn);
}
private static void handleTicket(QRcodeTicketJsonRtn jsonRtn) {
if (jsonRtn == null) {
System.out.println("null");
return;
}
| // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/util/JsonRtnUtil.java
// public class JsonRtnUtil {
// private static final String WECHAT_GLOBAL_MESSAGE_FILE_NAME = "wechate-global-message";
// private static final String WECHAT_JSON_RTN_SUCCESS_CODE = "0";
// private static ResourceBundle bundle;
//
// static {
// try {
// bundle = ResourceBundle.getBundle(WECHAT_GLOBAL_MESSAGE_FILE_NAME);
// } catch (Exception e) {
// }
// }
//
// /**
// * parse json text to specified class
// *
// * @param jsonRtn
// * @param jsonRtnClazz
// * @return
// */
// public static <T extends JsonRtn> T parseJsonRtn(String jsonRtn, Class<T> jsonRtnClazz) {
// T rtn = JSONObject.parseObject(jsonRtn, jsonRtnClazz);
// appendErrorHumanMsg(rtn);
// return rtn;
// }
//
// /**
// * append human message to JsonRtn class
// *
// * @param jsonRtn
// * @return
// */
// private static JsonRtn appendErrorHumanMsg(JsonRtn jsonRtn) {
// if (bundle == null || jsonRtn == null || StringUtils.isEmpty(jsonRtn.getErrCode())) {
// return null;
// }
//
// try {
// jsonRtn.setErrHumanMsg(bundle.getString(jsonRtn.getErrCode()));
// return jsonRtn;
// } catch (Exception e) {
// return null;
// }
// }
//
// /**
// * return request is success by JsonRtn object
// *
// * @param jsonRtn
// * @return
// */
// public static boolean isSuccess(JsonRtn jsonRtn) {
// if (jsonRtn == null) {
// return false;
// }
//
// String errCode = jsonRtn.getErrCode();
// if (StringUtils.isEmpty(errCode) || StringUtils.equals(WECHAT_JSON_RTN_SUCCESS_CODE, errCode)) {
// return true;
// }
//
// return false;
// }
//
// public static <T extends JsonRtn> T buildFailureJsonRtn(Class<T> jsonRtnClazz, String errMsg) {
// try {
// T jsonRtn = jsonRtnClazz.newInstance();
// jsonRtn.setErrCode("-1");
// jsonRtn.setErrMsg(errMsg);
//
// appendErrorHumanMsg(jsonRtn);
//
// return jsonRtn;
// } catch (Exception e) {
// return null;
// }
// }
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/qrcode/QRcodeTicketJsonRtn.java
// public class QRcodeTicketJsonRtn extends JsonRtn {
// @JSONField(name = "ticket")
// private String ticket;
//
// @JSONField(name = "expire_seconds")
// private int expireSeconds = -1;
//
// public QRcodeTicketJsonRtn() {
// }
//
// public String getTicket() {
// return ticket;
// }
//
// public void setTicket(String ticket) {
// this.ticket = ticket;
// }
//
// public int getExpireSeconds() {
// return expireSeconds;
// }
//
// public void setExpireSeconds(int expireSeconds) {
// this.expireSeconds = expireSeconds;
// }
//
// }
// Path: wechat-mp-sdk/src/test/java/org/usc/wechat/mp/sdk/util/platform/QRcodeUtilTest.java
import org.usc.wechat.mp.sdk.util.JsonRtnUtil;
import org.usc.wechat.mp.sdk.vo.qrcode.QRcodeTicketJsonRtn;
package org.usc.wechat.mp.sdk.util.platform;
/**
*
* @author Shunli
*/
public class QRcodeUtilTest {
public static void main(String[] args) {
QRcodeTicketJsonRtn jsonRtn = QRcodeUtil.createPermanentQRcode(Constants.LICENSE, 1);
handleTicket(jsonRtn);
jsonRtn = QRcodeUtil.createTemporaryQRcode(Constants.LICENSE, 2, 1800);
handleTicket(jsonRtn);
}
private static void handleTicket(QRcodeTicketJsonRtn jsonRtn) {
if (jsonRtn == null) {
System.out.println("null");
return;
}
| if (!JsonRtnUtil.isSuccess(jsonRtn)) { |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/util/ReplyUtil.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/Push.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class Push extends AbstractToStringBuilder{
// @XmlElement(name = "ToUserName")
// private String toUserName;
//
// @XmlElement(name = "FromUserName")
// private String fromUserName;
//
// @XmlElement(name = "CreateTime")
// private long createTime;
//
// @XmlElement(name = "MsgType")
// private String msgType;
//
// @XmlElement(name = "MsgId")
// private String msgId;
//
// public String getToUserName() {
// return toUserName;
// }
//
// public void setToUserName(String toUserName) {
// this.toUserName = toUserName;
// }
//
// public String getFromUserName() {
// return fromUserName;
// }
//
// public void setFromUserName(String fromUserName) {
// this.fromUserName = fromUserName;
// }
//
// public long getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(long createTime) {
// this.createTime = createTime;
// }
//
// public String getMsgType() {
// return msgType;
// }
//
// public void setMsgType(String msgType) {
// this.msgType = msgType;
// }
//
// public String getMsgId() {
// return msgId;
// }
//
// public void setMsgId(String msgId) {
// this.msgId = msgId;
// }
//
// }
| import java.util.Arrays;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.EnumUtils;
import org.apache.commons.lang3.StringUtils;
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.ReplyDetailWarpper;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.push.Push; | package org.usc.wechat.mp.sdk.util;
/**
*
* @author Shunli
*/
public class ReplyUtil {
public static Reply buildReply(Reply reply, Push push) {
try {
if (reply != null) {
// keep is new instance
Reply newReply = (Reply) BeanUtils.cloneBean(reply);
newReply.setCreateTime(getUnixTimeStamp());
newReply.setToUserName(push.getFromUserName());
newReply.setFromUserName(push.getToUserName());
return newReply;
}
} catch (Exception e) {
}
return null;
}
public static long getUnixTimeStamp() {
return System.currentTimeMillis() / 1000;
}
public static Reply parseReplyDetailWarpper(ReplyDetailWarpper replyDetailWarpper) {
if (replyDetailWarpper == null) {
return null;
}
String replyType = replyDetailWarpper.getReplyType(); | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/Push.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class Push extends AbstractToStringBuilder{
// @XmlElement(name = "ToUserName")
// private String toUserName;
//
// @XmlElement(name = "FromUserName")
// private String fromUserName;
//
// @XmlElement(name = "CreateTime")
// private long createTime;
//
// @XmlElement(name = "MsgType")
// private String msgType;
//
// @XmlElement(name = "MsgId")
// private String msgId;
//
// public String getToUserName() {
// return toUserName;
// }
//
// public void setToUserName(String toUserName) {
// this.toUserName = toUserName;
// }
//
// public String getFromUserName() {
// return fromUserName;
// }
//
// public void setFromUserName(String fromUserName) {
// this.fromUserName = fromUserName;
// }
//
// public long getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(long createTime) {
// this.createTime = createTime;
// }
//
// public String getMsgType() {
// return msgType;
// }
//
// public void setMsgType(String msgType) {
// this.msgType = msgType;
// }
//
// public String getMsgId() {
// return msgId;
// }
//
// public void setMsgId(String msgId) {
// this.msgId = msgId;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/util/ReplyUtil.java
import java.util.Arrays;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.EnumUtils;
import org.apache.commons.lang3.StringUtils;
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.ReplyDetailWarpper;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.push.Push;
package org.usc.wechat.mp.sdk.util;
/**
*
* @author Shunli
*/
public class ReplyUtil {
public static Reply buildReply(Reply reply, Push push) {
try {
if (reply != null) {
// keep is new instance
Reply newReply = (Reply) BeanUtils.cloneBean(reply);
newReply.setCreateTime(getUnixTimeStamp());
newReply.setToUserName(push.getFromUserName());
newReply.setFromUserName(push.getToUserName());
return newReply;
}
} catch (Exception e) {
}
return null;
}
public static long getUnixTimeStamp() {
return System.currentTimeMillis() / 1000;
}
public static Reply parseReplyDetailWarpper(ReplyDetailWarpper replyDetailWarpper) {
if (replyDetailWarpper == null) {
return null;
}
String replyType = replyDetailWarpper.getReplyType(); | ReplyEnumFactory replyEnumFactory = EnumUtils.getEnum(ReplyEnumFactory.class, StringUtils.upperCase(replyType)); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/MusicReply.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/MusicDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MusicDetail extends AbstractToStringBuilder {
// @XmlElement(name = "Title")
// private String title;
//
// @XmlElement(name = "Description")
// private String description;
//
// @XmlElement(name = "MusicUrl")
// private String musicUrl;
//
// @XmlElement(name = "HQMusicUrl")
// private String hqMusicUrl;
//
// @XmlElement(name = "ThumbMediaId")
// private String thumbMediaId;
//
// public MusicDetail() {
// }
//
// public MusicDetail(String thumbMediaId) {
// this.thumbMediaId = thumbMediaId;
// }
//
// public MusicDetail(String title, String description, String musicUrl, String hqMusicUrl, String thumbMediaId) {
// this.title = title;
// this.description = description;
// this.musicUrl = musicUrl;
// this.hqMusicUrl = hqMusicUrl;
// this.thumbMediaId = thumbMediaId;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getMusicUrl() {
// return musicUrl;
// }
//
// public void setMusicUrl(String musicUrl) {
// this.musicUrl = musicUrl;
// }
//
// public String getHqMusicUrl() {
// return hqMusicUrl;
// }
//
// public void setHqMusicUrl(String hqMusicUrl) {
// this.hqMusicUrl = hqMusicUrl;
// }
//
// public String getThumbMediaId() {
// return thumbMediaId;
// }
//
// public void setThumbMediaId(String thumbMediaId) {
// this.thumbMediaId = thumbMediaId;
// }
//
// }
| import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.MusicDetail; | package org.usc.wechat.mp.sdk.vo.message.reply;
/**
*
* @author Shunli
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class MusicReply extends Reply {
@XmlElement(name = "Music") | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/MusicDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MusicDetail extends AbstractToStringBuilder {
// @XmlElement(name = "Title")
// private String title;
//
// @XmlElement(name = "Description")
// private String description;
//
// @XmlElement(name = "MusicUrl")
// private String musicUrl;
//
// @XmlElement(name = "HQMusicUrl")
// private String hqMusicUrl;
//
// @XmlElement(name = "ThumbMediaId")
// private String thumbMediaId;
//
// public MusicDetail() {
// }
//
// public MusicDetail(String thumbMediaId) {
// this.thumbMediaId = thumbMediaId;
// }
//
// public MusicDetail(String title, String description, String musicUrl, String hqMusicUrl, String thumbMediaId) {
// this.title = title;
// this.description = description;
// this.musicUrl = musicUrl;
// this.hqMusicUrl = hqMusicUrl;
// this.thumbMediaId = thumbMediaId;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getMusicUrl() {
// return musicUrl;
// }
//
// public void setMusicUrl(String musicUrl) {
// this.musicUrl = musicUrl;
// }
//
// public String getHqMusicUrl() {
// return hqMusicUrl;
// }
//
// public void setHqMusicUrl(String hqMusicUrl) {
// this.hqMusicUrl = hqMusicUrl;
// }
//
// public String getThumbMediaId() {
// return thumbMediaId;
// }
//
// public void setThumbMediaId(String thumbMediaId) {
// this.thumbMediaId = thumbMediaId;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/MusicReply.java
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.MusicDetail;
package org.usc.wechat.mp.sdk.vo.message.reply;
/**
*
* @author Shunli
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class MusicReply extends Reply {
@XmlElement(name = "Music") | private MusicDetail musicDetail; |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/MusicReply.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/MusicDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MusicDetail extends AbstractToStringBuilder {
// @XmlElement(name = "Title")
// private String title;
//
// @XmlElement(name = "Description")
// private String description;
//
// @XmlElement(name = "MusicUrl")
// private String musicUrl;
//
// @XmlElement(name = "HQMusicUrl")
// private String hqMusicUrl;
//
// @XmlElement(name = "ThumbMediaId")
// private String thumbMediaId;
//
// public MusicDetail() {
// }
//
// public MusicDetail(String thumbMediaId) {
// this.thumbMediaId = thumbMediaId;
// }
//
// public MusicDetail(String title, String description, String musicUrl, String hqMusicUrl, String thumbMediaId) {
// this.title = title;
// this.description = description;
// this.musicUrl = musicUrl;
// this.hqMusicUrl = hqMusicUrl;
// this.thumbMediaId = thumbMediaId;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getMusicUrl() {
// return musicUrl;
// }
//
// public void setMusicUrl(String musicUrl) {
// this.musicUrl = musicUrl;
// }
//
// public String getHqMusicUrl() {
// return hqMusicUrl;
// }
//
// public void setHqMusicUrl(String hqMusicUrl) {
// this.hqMusicUrl = hqMusicUrl;
// }
//
// public String getThumbMediaId() {
// return thumbMediaId;
// }
//
// public void setThumbMediaId(String thumbMediaId) {
// this.thumbMediaId = thumbMediaId;
// }
//
// }
| import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.MusicDetail; | package org.usc.wechat.mp.sdk.vo.message.reply;
/**
*
* @author Shunli
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class MusicReply extends Reply {
@XmlElement(name = "Music")
private MusicDetail musicDetail;
{ | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/MusicDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MusicDetail extends AbstractToStringBuilder {
// @XmlElement(name = "Title")
// private String title;
//
// @XmlElement(name = "Description")
// private String description;
//
// @XmlElement(name = "MusicUrl")
// private String musicUrl;
//
// @XmlElement(name = "HQMusicUrl")
// private String hqMusicUrl;
//
// @XmlElement(name = "ThumbMediaId")
// private String thumbMediaId;
//
// public MusicDetail() {
// }
//
// public MusicDetail(String thumbMediaId) {
// this.thumbMediaId = thumbMediaId;
// }
//
// public MusicDetail(String title, String description, String musicUrl, String hqMusicUrl, String thumbMediaId) {
// this.title = title;
// this.description = description;
// this.musicUrl = musicUrl;
// this.hqMusicUrl = hqMusicUrl;
// this.thumbMediaId = thumbMediaId;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getMusicUrl() {
// return musicUrl;
// }
//
// public void setMusicUrl(String musicUrl) {
// this.musicUrl = musicUrl;
// }
//
// public String getHqMusicUrl() {
// return hqMusicUrl;
// }
//
// public void setHqMusicUrl(String hqMusicUrl) {
// this.hqMusicUrl = hqMusicUrl;
// }
//
// public String getThumbMediaId() {
// return thumbMediaId;
// }
//
// public void setThumbMediaId(String thumbMediaId) {
// this.thumbMediaId = thumbMediaId;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/MusicReply.java
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.MusicDetail;
package org.usc.wechat.mp.sdk.vo.message.reply;
/**
*
* @author Shunli
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class MusicReply extends Reply {
@XmlElement(name = "Music")
private MusicDetail musicDetail;
{ | super.setMsgType(ReplyEnumFactory.MUSIC.getReplyType()); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/NewsReplyBuilder.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/NewsReply.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class NewsReply extends Reply {
// @XmlElement(name = "ArticleCount")
// private int articleCount;
//
// @XmlElementWrapper(name = "Articles")
// @XmlElement(name = "item")
// private List<NewsDetail> articles;
//
// {
// super.setMsgType(ReplyEnumFactory.NEWS.getReplyType());
// }
//
// public NewsReply() {
// }
//
// public NewsReply(int articleCount, List<NewsDetail> articles) {
// this.articleCount = articleCount;
// this.articles = articles;
// }
//
// public int getArticleCount() {
// return articleCount;
// }
//
// public void setArticleCount(int articleCount) {
// this.articleCount = articleCount;
// }
//
// public List<NewsDetail> getArticles() {
// return articles;
// }
//
// public void setArticles(List<NewsDetail> articles) {
// this.articles = articles;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/NewsDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class NewsDetail extends AbstractToStringBuilder {
// @XmlElement(name = "Title")
// private String title;
//
// @XmlElement(name = "Description")
// private String description;
//
// @XmlElement(name = "PicUrl")
// private String picUrl;
//
// @XmlElement(name = "Url")
// private String url;
//
// public NewsDetail() {
// }
//
// public NewsDetail(String url) {
// this.url = url;
// }
//
// public NewsDetail(String title, String description, String picUrl, String url) {
// this.title = title;
// this.description = description;
// this.picUrl = picUrl;
// this.url = url;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getPicUrl() {
// return picUrl;
// }
//
// public void setPicUrl(String picUrl) {
// this.picUrl = picUrl;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.NewsReply;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.NewsDetail; | package org.usc.wechat.mp.sdk.factory.builder;
/**
*
* @author Shunli
*/
public class NewsReplyBuilder implements ReplyBuilder {
@Override
public Reply buildReply(List<ReplyDetail> replyDetails) {
int size = replyDetails.size(); | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/NewsReply.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class NewsReply extends Reply {
// @XmlElement(name = "ArticleCount")
// private int articleCount;
//
// @XmlElementWrapper(name = "Articles")
// @XmlElement(name = "item")
// private List<NewsDetail> articles;
//
// {
// super.setMsgType(ReplyEnumFactory.NEWS.getReplyType());
// }
//
// public NewsReply() {
// }
//
// public NewsReply(int articleCount, List<NewsDetail> articles) {
// this.articleCount = articleCount;
// this.articles = articles;
// }
//
// public int getArticleCount() {
// return articleCount;
// }
//
// public void setArticleCount(int articleCount) {
// this.articleCount = articleCount;
// }
//
// public List<NewsDetail> getArticles() {
// return articles;
// }
//
// public void setArticles(List<NewsDetail> articles) {
// this.articles = articles;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/NewsDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class NewsDetail extends AbstractToStringBuilder {
// @XmlElement(name = "Title")
// private String title;
//
// @XmlElement(name = "Description")
// private String description;
//
// @XmlElement(name = "PicUrl")
// private String picUrl;
//
// @XmlElement(name = "Url")
// private String url;
//
// public NewsDetail() {
// }
//
// public NewsDetail(String url) {
// this.url = url;
// }
//
// public NewsDetail(String title, String description, String picUrl, String url) {
// this.title = title;
// this.description = description;
// this.picUrl = picUrl;
// this.url = url;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getPicUrl() {
// return picUrl;
// }
//
// public void setPicUrl(String picUrl) {
// this.picUrl = picUrl;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/NewsReplyBuilder.java
import java.util.ArrayList;
import java.util.List;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.NewsReply;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.NewsDetail;
package org.usc.wechat.mp.sdk.factory.builder;
/**
*
* @author Shunli
*/
public class NewsReplyBuilder implements ReplyBuilder {
@Override
public Reply buildReply(List<ReplyDetail> replyDetails) {
int size = replyDetails.size(); | List<NewsDetail> articles = new ArrayList<NewsDetail>(size); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/NewsReplyBuilder.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/NewsReply.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class NewsReply extends Reply {
// @XmlElement(name = "ArticleCount")
// private int articleCount;
//
// @XmlElementWrapper(name = "Articles")
// @XmlElement(name = "item")
// private List<NewsDetail> articles;
//
// {
// super.setMsgType(ReplyEnumFactory.NEWS.getReplyType());
// }
//
// public NewsReply() {
// }
//
// public NewsReply(int articleCount, List<NewsDetail> articles) {
// this.articleCount = articleCount;
// this.articles = articles;
// }
//
// public int getArticleCount() {
// return articleCount;
// }
//
// public void setArticleCount(int articleCount) {
// this.articleCount = articleCount;
// }
//
// public List<NewsDetail> getArticles() {
// return articles;
// }
//
// public void setArticles(List<NewsDetail> articles) {
// this.articles = articles;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/NewsDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class NewsDetail extends AbstractToStringBuilder {
// @XmlElement(name = "Title")
// private String title;
//
// @XmlElement(name = "Description")
// private String description;
//
// @XmlElement(name = "PicUrl")
// private String picUrl;
//
// @XmlElement(name = "Url")
// private String url;
//
// public NewsDetail() {
// }
//
// public NewsDetail(String url) {
// this.url = url;
// }
//
// public NewsDetail(String title, String description, String picUrl, String url) {
// this.title = title;
// this.description = description;
// this.picUrl = picUrl;
// this.url = url;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getPicUrl() {
// return picUrl;
// }
//
// public void setPicUrl(String picUrl) {
// this.picUrl = picUrl;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.NewsReply;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.NewsDetail; | package org.usc.wechat.mp.sdk.factory.builder;
/**
*
* @author Shunli
*/
public class NewsReplyBuilder implements ReplyBuilder {
@Override
public Reply buildReply(List<ReplyDetail> replyDetails) {
int size = replyDetails.size();
List<NewsDetail> articles = new ArrayList<NewsDetail>(size);
for (ReplyDetail replyDetailVo : replyDetails) {
articles.add(new NewsDetail(
replyDetailVo.getTitle(),
replyDetailVo.getDescription(),
replyDetailVo.getMediaUrl(),
replyDetailVo.getUrl()));
}
| // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/NewsReply.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class NewsReply extends Reply {
// @XmlElement(name = "ArticleCount")
// private int articleCount;
//
// @XmlElementWrapper(name = "Articles")
// @XmlElement(name = "item")
// private List<NewsDetail> articles;
//
// {
// super.setMsgType(ReplyEnumFactory.NEWS.getReplyType());
// }
//
// public NewsReply() {
// }
//
// public NewsReply(int articleCount, List<NewsDetail> articles) {
// this.articleCount = articleCount;
// this.articles = articles;
// }
//
// public int getArticleCount() {
// return articleCount;
// }
//
// public void setArticleCount(int articleCount) {
// this.articleCount = articleCount;
// }
//
// public List<NewsDetail> getArticles() {
// return articles;
// }
//
// public void setArticles(List<NewsDetail> articles) {
// this.articles = articles;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/NewsDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class NewsDetail extends AbstractToStringBuilder {
// @XmlElement(name = "Title")
// private String title;
//
// @XmlElement(name = "Description")
// private String description;
//
// @XmlElement(name = "PicUrl")
// private String picUrl;
//
// @XmlElement(name = "Url")
// private String url;
//
// public NewsDetail() {
// }
//
// public NewsDetail(String url) {
// this.url = url;
// }
//
// public NewsDetail(String title, String description, String picUrl, String url) {
// this.title = title;
// this.description = description;
// this.picUrl = picUrl;
// this.url = url;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getPicUrl() {
// return picUrl;
// }
//
// public void setPicUrl(String picUrl) {
// this.picUrl = picUrl;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/NewsReplyBuilder.java
import java.util.ArrayList;
import java.util.List;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.NewsReply;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.NewsDetail;
package org.usc.wechat.mp.sdk.factory.builder;
/**
*
* @author Shunli
*/
public class NewsReplyBuilder implements ReplyBuilder {
@Override
public Reply buildReply(List<ReplyDetail> replyDetails) {
int size = replyDetails.size();
List<NewsDetail> articles = new ArrayList<NewsDetail>(size);
for (ReplyDetail replyDetailVo : replyDetails) {
articles.add(new NewsDetail(
replyDetailVo.getTitle(),
replyDetailVo.getDescription(),
replyDetailVo.getMediaUrl(),
replyDetailVo.getUrl()));
}
| return new NewsReply(size, articles); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/parser/LocationPushParser.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/Push.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class Push extends AbstractToStringBuilder{
// @XmlElement(name = "ToUserName")
// private String toUserName;
//
// @XmlElement(name = "FromUserName")
// private String fromUserName;
//
// @XmlElement(name = "CreateTime")
// private long createTime;
//
// @XmlElement(name = "MsgType")
// private String msgType;
//
// @XmlElement(name = "MsgId")
// private String msgId;
//
// public String getToUserName() {
// return toUserName;
// }
//
// public void setToUserName(String toUserName) {
// this.toUserName = toUserName;
// }
//
// public String getFromUserName() {
// return fromUserName;
// }
//
// public void setFromUserName(String fromUserName) {
// this.fromUserName = fromUserName;
// }
//
// public long getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(long createTime) {
// this.createTime = createTime;
// }
//
// public String getMsgType() {
// return msgType;
// }
//
// public void setMsgType(String msgType) {
// this.msgType = msgType;
// }
//
// public String getMsgId() {
// return msgId;
// }
//
// public void setMsgId(String msgId) {
// this.msgId = msgId;
// }
//
// }
| import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.push.Push; | package org.usc.wechat.mp.sdk.factory.parser;
/**
*
* @author Shunli
*/
public class LocationPushParser implements PushParser {
@Override | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/Push.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class Push extends AbstractToStringBuilder{
// @XmlElement(name = "ToUserName")
// private String toUserName;
//
// @XmlElement(name = "FromUserName")
// private String fromUserName;
//
// @XmlElement(name = "CreateTime")
// private long createTime;
//
// @XmlElement(name = "MsgType")
// private String msgType;
//
// @XmlElement(name = "MsgId")
// private String msgId;
//
// public String getToUserName() {
// return toUserName;
// }
//
// public void setToUserName(String toUserName) {
// this.toUserName = toUserName;
// }
//
// public String getFromUserName() {
// return fromUserName;
// }
//
// public void setFromUserName(String fromUserName) {
// this.fromUserName = fromUserName;
// }
//
// public long getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(long createTime) {
// this.createTime = createTime;
// }
//
// public String getMsgType() {
// return msgType;
// }
//
// public void setMsgType(String msgType) {
// this.msgType = msgType;
// }
//
// public String getMsgId() {
// return msgId;
// }
//
// public void setMsgId(String msgId) {
// this.msgId = msgId;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/parser/LocationPushParser.java
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.push.Push;
package org.usc.wechat.mp.sdk.factory.parser;
/**
*
* @author Shunli
*/
public class LocationPushParser implements PushParser {
@Override | public Reply parse(Push push) { |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/VideoReply.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
| import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.VideoDetail; | package org.usc.wechat.mp.sdk.vo.message.reply;
/**
*
* @author Shunli
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class VideoReply extends Reply {
@XmlElement(name = "Video")
private VideoDetail videoDetail;
{ | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/VideoReply.java
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.VideoDetail;
package org.usc.wechat.mp.sdk.vo.message.reply;
/**
*
* @author Shunli
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class VideoReply extends Reply {
@XmlElement(name = "Video")
private VideoDetail videoDetail;
{ | super.setMsgType(ReplyEnumFactory.VIDEO.getReplyType()); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/ArticleCustomMessage.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/detail/ArticlesCustomMessageDetail.java
// public class ArticlesCustomMessageDetail extends AbstractToStringBuilder {
// @JSONField(name = "articles")
// private List<ArticleCustomMessageDetail> articles;
//
// public ArticlesCustomMessageDetail(List<ArticleCustomMessageDetail> articles) {
// this.articles = articles;
// }
//
// public List<ArticleCustomMessageDetail> getArticles() {
// return articles;
// }
//
// public void setArticles(List<ArticleCustomMessageDetail> articles) {
// this.articles = articles;
// }
//
// }
| import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.message.custom.detail.ArticlesCustomMessageDetail;
import com.alibaba.fastjson.annotation.JSONField; | package org.usc.wechat.mp.sdk.vo.message.custom;
/**
*
* @author Shunli
*/
public class ArticleCustomMessage extends CustomMessage {
@JSONField(name = "news") | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/detail/ArticlesCustomMessageDetail.java
// public class ArticlesCustomMessageDetail extends AbstractToStringBuilder {
// @JSONField(name = "articles")
// private List<ArticleCustomMessageDetail> articles;
//
// public ArticlesCustomMessageDetail(List<ArticleCustomMessageDetail> articles) {
// this.articles = articles;
// }
//
// public List<ArticleCustomMessageDetail> getArticles() {
// return articles;
// }
//
// public void setArticles(List<ArticleCustomMessageDetail> articles) {
// this.articles = articles;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/ArticleCustomMessage.java
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.message.custom.detail.ArticlesCustomMessageDetail;
import com.alibaba.fastjson.annotation.JSONField;
package org.usc.wechat.mp.sdk.vo.message.custom;
/**
*
* @author Shunli
*/
public class ArticleCustomMessage extends CustomMessage {
@JSONField(name = "news") | private ArticlesCustomMessageDetail news; |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/ArticleCustomMessage.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/detail/ArticlesCustomMessageDetail.java
// public class ArticlesCustomMessageDetail extends AbstractToStringBuilder {
// @JSONField(name = "articles")
// private List<ArticleCustomMessageDetail> articles;
//
// public ArticlesCustomMessageDetail(List<ArticleCustomMessageDetail> articles) {
// this.articles = articles;
// }
//
// public List<ArticleCustomMessageDetail> getArticles() {
// return articles;
// }
//
// public void setArticles(List<ArticleCustomMessageDetail> articles) {
// this.articles = articles;
// }
//
// }
| import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.message.custom.detail.ArticlesCustomMessageDetail;
import com.alibaba.fastjson.annotation.JSONField; | package org.usc.wechat.mp.sdk.vo.message.custom;
/**
*
* @author Shunli
*/
public class ArticleCustomMessage extends CustomMessage {
@JSONField(name = "news")
private ArticlesCustomMessageDetail news;
{ | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/detail/ArticlesCustomMessageDetail.java
// public class ArticlesCustomMessageDetail extends AbstractToStringBuilder {
// @JSONField(name = "articles")
// private List<ArticleCustomMessageDetail> articles;
//
// public ArticlesCustomMessageDetail(List<ArticleCustomMessageDetail> articles) {
// this.articles = articles;
// }
//
// public List<ArticleCustomMessageDetail> getArticles() {
// return articles;
// }
//
// public void setArticles(List<ArticleCustomMessageDetail> articles) {
// this.articles = articles;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/ArticleCustomMessage.java
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.message.custom.detail.ArticlesCustomMessageDetail;
import com.alibaba.fastjson.annotation.JSONField;
package org.usc.wechat.mp.sdk.vo.message.custom;
/**
*
* @author Shunli
*/
public class ArticleCustomMessage extends CustomMessage {
@JSONField(name = "news")
private ArticlesCustomMessageDetail news;
{ | super.setMsgType(ReplyEnumFactory.NEWS.getReplyType()); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/parser/LinkPushParser.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/Push.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class Push extends AbstractToStringBuilder{
// @XmlElement(name = "ToUserName")
// private String toUserName;
//
// @XmlElement(name = "FromUserName")
// private String fromUserName;
//
// @XmlElement(name = "CreateTime")
// private long createTime;
//
// @XmlElement(name = "MsgType")
// private String msgType;
//
// @XmlElement(name = "MsgId")
// private String msgId;
//
// public String getToUserName() {
// return toUserName;
// }
//
// public void setToUserName(String toUserName) {
// this.toUserName = toUserName;
// }
//
// public String getFromUserName() {
// return fromUserName;
// }
//
// public void setFromUserName(String fromUserName) {
// this.fromUserName = fromUserName;
// }
//
// public long getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(long createTime) {
// this.createTime = createTime;
// }
//
// public String getMsgType() {
// return msgType;
// }
//
// public void setMsgType(String msgType) {
// this.msgType = msgType;
// }
//
// public String getMsgId() {
// return msgId;
// }
//
// public void setMsgId(String msgId) {
// this.msgId = msgId;
// }
//
// }
| import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.push.Push; | package org.usc.wechat.mp.sdk.factory.parser;
/**
*
* @author Shunli
*/
public class LinkPushParser implements PushParser {
@Override | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/Push.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class Push extends AbstractToStringBuilder{
// @XmlElement(name = "ToUserName")
// private String toUserName;
//
// @XmlElement(name = "FromUserName")
// private String fromUserName;
//
// @XmlElement(name = "CreateTime")
// private long createTime;
//
// @XmlElement(name = "MsgType")
// private String msgType;
//
// @XmlElement(name = "MsgId")
// private String msgId;
//
// public String getToUserName() {
// return toUserName;
// }
//
// public void setToUserName(String toUserName) {
// this.toUserName = toUserName;
// }
//
// public String getFromUserName() {
// return fromUserName;
// }
//
// public void setFromUserName(String fromUserName) {
// this.fromUserName = fromUserName;
// }
//
// public long getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(long createTime) {
// this.createTime = createTime;
// }
//
// public String getMsgType() {
// return msgType;
// }
//
// public void setMsgType(String msgType) {
// this.msgType = msgType;
// }
//
// public String getMsgId() {
// return msgId;
// }
//
// public void setMsgId(String msgId) {
// this.msgId = msgId;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/parser/LinkPushParser.java
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.push.Push;
package org.usc.wechat.mp.sdk.factory.parser;
/**
*
* @author Shunli
*/
public class LinkPushParser implements PushParser {
@Override | public Reply parse(Push push) { |
usc/wechat-mp-sdk | wechat-mp-sdk/src/test/java/org/usc/wechat/mp/sdk/util/platform/MenuUtilTest.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MenuInfo.java
// public abstract class MenuInfo extends AbstractToStringBuilder{
// @JSONField(name = "name")
// private String name;
//
// public MenuInfo() {
// }
//
// public MenuInfo(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MenuType.java
// public enum MenuType {
// CLICK("click"),
// VIEW("view") {
// @Override
// protected SingleMenuInfo buildSingleMenuInfo(SingleMenuInfo menuInfo, String menuUrlOrKey) {
// menuInfo.setUrl(menuUrlOrKey);
// return menuInfo;
// }
// },
// SCANCODE_PUSH("scancode_push"),
// SCANCODE_WAITMSG("scancode_waitmsg"),
// PIC_SYSPHOTO("pic_sysphoto"),
// PIC_PHOTO_OR_ALBUM("pic_photo_or_album"),
// PIC_WEIXIN("pic_weixin"),
// LOCATION_SELECT("location_select"), ;
//
// private String type;
//
// private MenuType(String type) {
// this.type = type;
// }
//
// protected SingleMenuInfo buildSingleMenuInfo(SingleMenuInfo menuInfo, String menuUrlOrKey) {
// menuInfo.setKey(menuUrlOrKey);
// return menuInfo;
// }
//
// public SingleMenuInfo buildSingleMenuInfo(String menuName, String menuUrlOrKey) {
// return buildSingleMenuInfo(new SingleMenuInfo(menuName, type), menuUrlOrKey);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MultiMenuInfo.java
// public class MultiMenuInfo extends MenuInfo {
// @JSONField(name = "sub_button")
// private List<SingleMenuInfo> subMenuInfos;
//
// public MultiMenuInfo() {
// }
//
// public MultiMenuInfo(String name, List<SingleMenuInfo> subMenuInfos) {
// super(name);
// this.subMenuInfos = subMenuInfos;
// }
//
// public List<SingleMenuInfo> getSubMenuInfos() {
// return subMenuInfos;
// }
//
// public void setSubMenuInfos(List<SingleMenuInfo> subMenuInfos) {
// this.subMenuInfos = subMenuInfos;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/SingleMenuInfo.java
// public class SingleMenuInfo extends MenuInfo {
// private String type;
// private String url;
// private String key;
//
// public SingleMenuInfo() {
// }
//
// public SingleMenuInfo(String name, String type) {
// super(name);
// this.type = type;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getKey() {
// return key;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// }
| import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import org.usc.wechat.mp.sdk.vo.menu.Menu;
import org.usc.wechat.mp.sdk.vo.menu.MenuInfo;
import org.usc.wechat.mp.sdk.vo.menu.MenuType;
import org.usc.wechat.mp.sdk.vo.menu.MultiMenuInfo;
import org.usc.wechat.mp.sdk.vo.menu.SingleMenuInfo; | package org.usc.wechat.mp.sdk.util.platform;
/**
*
* @author Shunli
*/
public class MenuUtilTest {
public static void main(String[] args) throws URISyntaxException { | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MenuInfo.java
// public abstract class MenuInfo extends AbstractToStringBuilder{
// @JSONField(name = "name")
// private String name;
//
// public MenuInfo() {
// }
//
// public MenuInfo(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MenuType.java
// public enum MenuType {
// CLICK("click"),
// VIEW("view") {
// @Override
// protected SingleMenuInfo buildSingleMenuInfo(SingleMenuInfo menuInfo, String menuUrlOrKey) {
// menuInfo.setUrl(menuUrlOrKey);
// return menuInfo;
// }
// },
// SCANCODE_PUSH("scancode_push"),
// SCANCODE_WAITMSG("scancode_waitmsg"),
// PIC_SYSPHOTO("pic_sysphoto"),
// PIC_PHOTO_OR_ALBUM("pic_photo_or_album"),
// PIC_WEIXIN("pic_weixin"),
// LOCATION_SELECT("location_select"), ;
//
// private String type;
//
// private MenuType(String type) {
// this.type = type;
// }
//
// protected SingleMenuInfo buildSingleMenuInfo(SingleMenuInfo menuInfo, String menuUrlOrKey) {
// menuInfo.setKey(menuUrlOrKey);
// return menuInfo;
// }
//
// public SingleMenuInfo buildSingleMenuInfo(String menuName, String menuUrlOrKey) {
// return buildSingleMenuInfo(new SingleMenuInfo(menuName, type), menuUrlOrKey);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MultiMenuInfo.java
// public class MultiMenuInfo extends MenuInfo {
// @JSONField(name = "sub_button")
// private List<SingleMenuInfo> subMenuInfos;
//
// public MultiMenuInfo() {
// }
//
// public MultiMenuInfo(String name, List<SingleMenuInfo> subMenuInfos) {
// super(name);
// this.subMenuInfos = subMenuInfos;
// }
//
// public List<SingleMenuInfo> getSubMenuInfos() {
// return subMenuInfos;
// }
//
// public void setSubMenuInfos(List<SingleMenuInfo> subMenuInfos) {
// this.subMenuInfos = subMenuInfos;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/SingleMenuInfo.java
// public class SingleMenuInfo extends MenuInfo {
// private String type;
// private String url;
// private String key;
//
// public SingleMenuInfo() {
// }
//
// public SingleMenuInfo(String name, String type) {
// super(name);
// this.type = type;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getKey() {
// return key;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// }
// Path: wechat-mp-sdk/src/test/java/org/usc/wechat/mp/sdk/util/platform/MenuUtilTest.java
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import org.usc.wechat.mp.sdk.vo.menu.Menu;
import org.usc.wechat.mp.sdk.vo.menu.MenuInfo;
import org.usc.wechat.mp.sdk.vo.menu.MenuType;
import org.usc.wechat.mp.sdk.vo.menu.MultiMenuInfo;
import org.usc.wechat.mp.sdk.vo.menu.SingleMenuInfo;
package org.usc.wechat.mp.sdk.util.platform;
/**
*
* @author Shunli
*/
public class MenuUtilTest {
public static void main(String[] args) throws URISyntaxException { | List<SingleMenuInfo> subMenuInfos = new ArrayList<SingleMenuInfo>(); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/test/java/org/usc/wechat/mp/sdk/util/platform/MenuUtilTest.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MenuInfo.java
// public abstract class MenuInfo extends AbstractToStringBuilder{
// @JSONField(name = "name")
// private String name;
//
// public MenuInfo() {
// }
//
// public MenuInfo(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MenuType.java
// public enum MenuType {
// CLICK("click"),
// VIEW("view") {
// @Override
// protected SingleMenuInfo buildSingleMenuInfo(SingleMenuInfo menuInfo, String menuUrlOrKey) {
// menuInfo.setUrl(menuUrlOrKey);
// return menuInfo;
// }
// },
// SCANCODE_PUSH("scancode_push"),
// SCANCODE_WAITMSG("scancode_waitmsg"),
// PIC_SYSPHOTO("pic_sysphoto"),
// PIC_PHOTO_OR_ALBUM("pic_photo_or_album"),
// PIC_WEIXIN("pic_weixin"),
// LOCATION_SELECT("location_select"), ;
//
// private String type;
//
// private MenuType(String type) {
// this.type = type;
// }
//
// protected SingleMenuInfo buildSingleMenuInfo(SingleMenuInfo menuInfo, String menuUrlOrKey) {
// menuInfo.setKey(menuUrlOrKey);
// return menuInfo;
// }
//
// public SingleMenuInfo buildSingleMenuInfo(String menuName, String menuUrlOrKey) {
// return buildSingleMenuInfo(new SingleMenuInfo(menuName, type), menuUrlOrKey);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MultiMenuInfo.java
// public class MultiMenuInfo extends MenuInfo {
// @JSONField(name = "sub_button")
// private List<SingleMenuInfo> subMenuInfos;
//
// public MultiMenuInfo() {
// }
//
// public MultiMenuInfo(String name, List<SingleMenuInfo> subMenuInfos) {
// super(name);
// this.subMenuInfos = subMenuInfos;
// }
//
// public List<SingleMenuInfo> getSubMenuInfos() {
// return subMenuInfos;
// }
//
// public void setSubMenuInfos(List<SingleMenuInfo> subMenuInfos) {
// this.subMenuInfos = subMenuInfos;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/SingleMenuInfo.java
// public class SingleMenuInfo extends MenuInfo {
// private String type;
// private String url;
// private String key;
//
// public SingleMenuInfo() {
// }
//
// public SingleMenuInfo(String name, String type) {
// super(name);
// this.type = type;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getKey() {
// return key;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// }
| import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import org.usc.wechat.mp.sdk.vo.menu.Menu;
import org.usc.wechat.mp.sdk.vo.menu.MenuInfo;
import org.usc.wechat.mp.sdk.vo.menu.MenuType;
import org.usc.wechat.mp.sdk.vo.menu.MultiMenuInfo;
import org.usc.wechat.mp.sdk.vo.menu.SingleMenuInfo; | package org.usc.wechat.mp.sdk.util.platform;
/**
*
* @author Shunli
*/
public class MenuUtilTest {
public static void main(String[] args) throws URISyntaxException {
List<SingleMenuInfo> subMenuInfos = new ArrayList<SingleMenuInfo>(); | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MenuInfo.java
// public abstract class MenuInfo extends AbstractToStringBuilder{
// @JSONField(name = "name")
// private String name;
//
// public MenuInfo() {
// }
//
// public MenuInfo(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MenuType.java
// public enum MenuType {
// CLICK("click"),
// VIEW("view") {
// @Override
// protected SingleMenuInfo buildSingleMenuInfo(SingleMenuInfo menuInfo, String menuUrlOrKey) {
// menuInfo.setUrl(menuUrlOrKey);
// return menuInfo;
// }
// },
// SCANCODE_PUSH("scancode_push"),
// SCANCODE_WAITMSG("scancode_waitmsg"),
// PIC_SYSPHOTO("pic_sysphoto"),
// PIC_PHOTO_OR_ALBUM("pic_photo_or_album"),
// PIC_WEIXIN("pic_weixin"),
// LOCATION_SELECT("location_select"), ;
//
// private String type;
//
// private MenuType(String type) {
// this.type = type;
// }
//
// protected SingleMenuInfo buildSingleMenuInfo(SingleMenuInfo menuInfo, String menuUrlOrKey) {
// menuInfo.setKey(menuUrlOrKey);
// return menuInfo;
// }
//
// public SingleMenuInfo buildSingleMenuInfo(String menuName, String menuUrlOrKey) {
// return buildSingleMenuInfo(new SingleMenuInfo(menuName, type), menuUrlOrKey);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MultiMenuInfo.java
// public class MultiMenuInfo extends MenuInfo {
// @JSONField(name = "sub_button")
// private List<SingleMenuInfo> subMenuInfos;
//
// public MultiMenuInfo() {
// }
//
// public MultiMenuInfo(String name, List<SingleMenuInfo> subMenuInfos) {
// super(name);
// this.subMenuInfos = subMenuInfos;
// }
//
// public List<SingleMenuInfo> getSubMenuInfos() {
// return subMenuInfos;
// }
//
// public void setSubMenuInfos(List<SingleMenuInfo> subMenuInfos) {
// this.subMenuInfos = subMenuInfos;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/SingleMenuInfo.java
// public class SingleMenuInfo extends MenuInfo {
// private String type;
// private String url;
// private String key;
//
// public SingleMenuInfo() {
// }
//
// public SingleMenuInfo(String name, String type) {
// super(name);
// this.type = type;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getKey() {
// return key;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// }
// Path: wechat-mp-sdk/src/test/java/org/usc/wechat/mp/sdk/util/platform/MenuUtilTest.java
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import org.usc.wechat.mp.sdk.vo.menu.Menu;
import org.usc.wechat.mp.sdk.vo.menu.MenuInfo;
import org.usc.wechat.mp.sdk.vo.menu.MenuType;
import org.usc.wechat.mp.sdk.vo.menu.MultiMenuInfo;
import org.usc.wechat.mp.sdk.vo.menu.SingleMenuInfo;
package org.usc.wechat.mp.sdk.util.platform;
/**
*
* @author Shunli
*/
public class MenuUtilTest {
public static void main(String[] args) throws URISyntaxException {
List<SingleMenuInfo> subMenuInfos = new ArrayList<SingleMenuInfo>(); | subMenuInfos.add(MenuType.VIEW.buildSingleMenuInfo("搜索", "http://www.soso.com/")); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/test/java/org/usc/wechat/mp/sdk/util/platform/MenuUtilTest.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MenuInfo.java
// public abstract class MenuInfo extends AbstractToStringBuilder{
// @JSONField(name = "name")
// private String name;
//
// public MenuInfo() {
// }
//
// public MenuInfo(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MenuType.java
// public enum MenuType {
// CLICK("click"),
// VIEW("view") {
// @Override
// protected SingleMenuInfo buildSingleMenuInfo(SingleMenuInfo menuInfo, String menuUrlOrKey) {
// menuInfo.setUrl(menuUrlOrKey);
// return menuInfo;
// }
// },
// SCANCODE_PUSH("scancode_push"),
// SCANCODE_WAITMSG("scancode_waitmsg"),
// PIC_SYSPHOTO("pic_sysphoto"),
// PIC_PHOTO_OR_ALBUM("pic_photo_or_album"),
// PIC_WEIXIN("pic_weixin"),
// LOCATION_SELECT("location_select"), ;
//
// private String type;
//
// private MenuType(String type) {
// this.type = type;
// }
//
// protected SingleMenuInfo buildSingleMenuInfo(SingleMenuInfo menuInfo, String menuUrlOrKey) {
// menuInfo.setKey(menuUrlOrKey);
// return menuInfo;
// }
//
// public SingleMenuInfo buildSingleMenuInfo(String menuName, String menuUrlOrKey) {
// return buildSingleMenuInfo(new SingleMenuInfo(menuName, type), menuUrlOrKey);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MultiMenuInfo.java
// public class MultiMenuInfo extends MenuInfo {
// @JSONField(name = "sub_button")
// private List<SingleMenuInfo> subMenuInfos;
//
// public MultiMenuInfo() {
// }
//
// public MultiMenuInfo(String name, List<SingleMenuInfo> subMenuInfos) {
// super(name);
// this.subMenuInfos = subMenuInfos;
// }
//
// public List<SingleMenuInfo> getSubMenuInfos() {
// return subMenuInfos;
// }
//
// public void setSubMenuInfos(List<SingleMenuInfo> subMenuInfos) {
// this.subMenuInfos = subMenuInfos;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/SingleMenuInfo.java
// public class SingleMenuInfo extends MenuInfo {
// private String type;
// private String url;
// private String key;
//
// public SingleMenuInfo() {
// }
//
// public SingleMenuInfo(String name, String type) {
// super(name);
// this.type = type;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getKey() {
// return key;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// }
| import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import org.usc.wechat.mp.sdk.vo.menu.Menu;
import org.usc.wechat.mp.sdk.vo.menu.MenuInfo;
import org.usc.wechat.mp.sdk.vo.menu.MenuType;
import org.usc.wechat.mp.sdk.vo.menu.MultiMenuInfo;
import org.usc.wechat.mp.sdk.vo.menu.SingleMenuInfo; | package org.usc.wechat.mp.sdk.util.platform;
/**
*
* @author Shunli
*/
public class MenuUtilTest {
public static void main(String[] args) throws URISyntaxException {
List<SingleMenuInfo> subMenuInfos = new ArrayList<SingleMenuInfo>();
subMenuInfos.add(MenuType.VIEW.buildSingleMenuInfo("搜索", "http://www.soso.com/"));
subMenuInfos.add(MenuType.VIEW.buildSingleMenuInfo("视频", "http://v.qq.com/"));
subMenuInfos.add(MenuType.CLICK.buildSingleMenuInfo("赞一下我们", "V1001_GOOD"));
| // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MenuInfo.java
// public abstract class MenuInfo extends AbstractToStringBuilder{
// @JSONField(name = "name")
// private String name;
//
// public MenuInfo() {
// }
//
// public MenuInfo(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MenuType.java
// public enum MenuType {
// CLICK("click"),
// VIEW("view") {
// @Override
// protected SingleMenuInfo buildSingleMenuInfo(SingleMenuInfo menuInfo, String menuUrlOrKey) {
// menuInfo.setUrl(menuUrlOrKey);
// return menuInfo;
// }
// },
// SCANCODE_PUSH("scancode_push"),
// SCANCODE_WAITMSG("scancode_waitmsg"),
// PIC_SYSPHOTO("pic_sysphoto"),
// PIC_PHOTO_OR_ALBUM("pic_photo_or_album"),
// PIC_WEIXIN("pic_weixin"),
// LOCATION_SELECT("location_select"), ;
//
// private String type;
//
// private MenuType(String type) {
// this.type = type;
// }
//
// protected SingleMenuInfo buildSingleMenuInfo(SingleMenuInfo menuInfo, String menuUrlOrKey) {
// menuInfo.setKey(menuUrlOrKey);
// return menuInfo;
// }
//
// public SingleMenuInfo buildSingleMenuInfo(String menuName, String menuUrlOrKey) {
// return buildSingleMenuInfo(new SingleMenuInfo(menuName, type), menuUrlOrKey);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MultiMenuInfo.java
// public class MultiMenuInfo extends MenuInfo {
// @JSONField(name = "sub_button")
// private List<SingleMenuInfo> subMenuInfos;
//
// public MultiMenuInfo() {
// }
//
// public MultiMenuInfo(String name, List<SingleMenuInfo> subMenuInfos) {
// super(name);
// this.subMenuInfos = subMenuInfos;
// }
//
// public List<SingleMenuInfo> getSubMenuInfos() {
// return subMenuInfos;
// }
//
// public void setSubMenuInfos(List<SingleMenuInfo> subMenuInfos) {
// this.subMenuInfos = subMenuInfos;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/SingleMenuInfo.java
// public class SingleMenuInfo extends MenuInfo {
// private String type;
// private String url;
// private String key;
//
// public SingleMenuInfo() {
// }
//
// public SingleMenuInfo(String name, String type) {
// super(name);
// this.type = type;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getKey() {
// return key;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// }
// Path: wechat-mp-sdk/src/test/java/org/usc/wechat/mp/sdk/util/platform/MenuUtilTest.java
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import org.usc.wechat.mp.sdk.vo.menu.Menu;
import org.usc.wechat.mp.sdk.vo.menu.MenuInfo;
import org.usc.wechat.mp.sdk.vo.menu.MenuType;
import org.usc.wechat.mp.sdk.vo.menu.MultiMenuInfo;
import org.usc.wechat.mp.sdk.vo.menu.SingleMenuInfo;
package org.usc.wechat.mp.sdk.util.platform;
/**
*
* @author Shunli
*/
public class MenuUtilTest {
public static void main(String[] args) throws URISyntaxException {
List<SingleMenuInfo> subMenuInfos = new ArrayList<SingleMenuInfo>();
subMenuInfos.add(MenuType.VIEW.buildSingleMenuInfo("搜索", "http://www.soso.com/"));
subMenuInfos.add(MenuType.VIEW.buildSingleMenuInfo("视频", "http://v.qq.com/"));
subMenuInfos.add(MenuType.CLICK.buildSingleMenuInfo("赞一下我们", "V1001_GOOD"));
| List<MenuInfo> menuInfos = new ArrayList<MenuInfo>(); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/test/java/org/usc/wechat/mp/sdk/util/platform/MenuUtilTest.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MenuInfo.java
// public abstract class MenuInfo extends AbstractToStringBuilder{
// @JSONField(name = "name")
// private String name;
//
// public MenuInfo() {
// }
//
// public MenuInfo(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MenuType.java
// public enum MenuType {
// CLICK("click"),
// VIEW("view") {
// @Override
// protected SingleMenuInfo buildSingleMenuInfo(SingleMenuInfo menuInfo, String menuUrlOrKey) {
// menuInfo.setUrl(menuUrlOrKey);
// return menuInfo;
// }
// },
// SCANCODE_PUSH("scancode_push"),
// SCANCODE_WAITMSG("scancode_waitmsg"),
// PIC_SYSPHOTO("pic_sysphoto"),
// PIC_PHOTO_OR_ALBUM("pic_photo_or_album"),
// PIC_WEIXIN("pic_weixin"),
// LOCATION_SELECT("location_select"), ;
//
// private String type;
//
// private MenuType(String type) {
// this.type = type;
// }
//
// protected SingleMenuInfo buildSingleMenuInfo(SingleMenuInfo menuInfo, String menuUrlOrKey) {
// menuInfo.setKey(menuUrlOrKey);
// return menuInfo;
// }
//
// public SingleMenuInfo buildSingleMenuInfo(String menuName, String menuUrlOrKey) {
// return buildSingleMenuInfo(new SingleMenuInfo(menuName, type), menuUrlOrKey);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MultiMenuInfo.java
// public class MultiMenuInfo extends MenuInfo {
// @JSONField(name = "sub_button")
// private List<SingleMenuInfo> subMenuInfos;
//
// public MultiMenuInfo() {
// }
//
// public MultiMenuInfo(String name, List<SingleMenuInfo> subMenuInfos) {
// super(name);
// this.subMenuInfos = subMenuInfos;
// }
//
// public List<SingleMenuInfo> getSubMenuInfos() {
// return subMenuInfos;
// }
//
// public void setSubMenuInfos(List<SingleMenuInfo> subMenuInfos) {
// this.subMenuInfos = subMenuInfos;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/SingleMenuInfo.java
// public class SingleMenuInfo extends MenuInfo {
// private String type;
// private String url;
// private String key;
//
// public SingleMenuInfo() {
// }
//
// public SingleMenuInfo(String name, String type) {
// super(name);
// this.type = type;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getKey() {
// return key;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// }
| import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import org.usc.wechat.mp.sdk.vo.menu.Menu;
import org.usc.wechat.mp.sdk.vo.menu.MenuInfo;
import org.usc.wechat.mp.sdk.vo.menu.MenuType;
import org.usc.wechat.mp.sdk.vo.menu.MultiMenuInfo;
import org.usc.wechat.mp.sdk.vo.menu.SingleMenuInfo; | package org.usc.wechat.mp.sdk.util.platform;
/**
*
* @author Shunli
*/
public class MenuUtilTest {
public static void main(String[] args) throws URISyntaxException {
List<SingleMenuInfo> subMenuInfos = new ArrayList<SingleMenuInfo>();
subMenuInfos.add(MenuType.VIEW.buildSingleMenuInfo("搜索", "http://www.soso.com/"));
subMenuInfos.add(MenuType.VIEW.buildSingleMenuInfo("视频", "http://v.qq.com/"));
subMenuInfos.add(MenuType.CLICK.buildSingleMenuInfo("赞一下我们", "V1001_GOOD"));
List<MenuInfo> menuInfos = new ArrayList<MenuInfo>();
menuInfos.add(MenuType.CLICK.buildSingleMenuInfo("今日歌曲", "V1001_TODAY_MUSIC"));
menuInfos.add(MenuType.CLICK.buildSingleMenuInfo("歌手简介", "V1001_TODAY_SINGER")); | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MenuInfo.java
// public abstract class MenuInfo extends AbstractToStringBuilder{
// @JSONField(name = "name")
// private String name;
//
// public MenuInfo() {
// }
//
// public MenuInfo(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MenuType.java
// public enum MenuType {
// CLICK("click"),
// VIEW("view") {
// @Override
// protected SingleMenuInfo buildSingleMenuInfo(SingleMenuInfo menuInfo, String menuUrlOrKey) {
// menuInfo.setUrl(menuUrlOrKey);
// return menuInfo;
// }
// },
// SCANCODE_PUSH("scancode_push"),
// SCANCODE_WAITMSG("scancode_waitmsg"),
// PIC_SYSPHOTO("pic_sysphoto"),
// PIC_PHOTO_OR_ALBUM("pic_photo_or_album"),
// PIC_WEIXIN("pic_weixin"),
// LOCATION_SELECT("location_select"), ;
//
// private String type;
//
// private MenuType(String type) {
// this.type = type;
// }
//
// protected SingleMenuInfo buildSingleMenuInfo(SingleMenuInfo menuInfo, String menuUrlOrKey) {
// menuInfo.setKey(menuUrlOrKey);
// return menuInfo;
// }
//
// public SingleMenuInfo buildSingleMenuInfo(String menuName, String menuUrlOrKey) {
// return buildSingleMenuInfo(new SingleMenuInfo(menuName, type), menuUrlOrKey);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/MultiMenuInfo.java
// public class MultiMenuInfo extends MenuInfo {
// @JSONField(name = "sub_button")
// private List<SingleMenuInfo> subMenuInfos;
//
// public MultiMenuInfo() {
// }
//
// public MultiMenuInfo(String name, List<SingleMenuInfo> subMenuInfos) {
// super(name);
// this.subMenuInfos = subMenuInfos;
// }
//
// public List<SingleMenuInfo> getSubMenuInfos() {
// return subMenuInfos;
// }
//
// public void setSubMenuInfos(List<SingleMenuInfo> subMenuInfos) {
// this.subMenuInfos = subMenuInfos;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/menu/SingleMenuInfo.java
// public class SingleMenuInfo extends MenuInfo {
// private String type;
// private String url;
// private String key;
//
// public SingleMenuInfo() {
// }
//
// public SingleMenuInfo(String name, String type) {
// super(name);
// this.type = type;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getKey() {
// return key;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// }
// Path: wechat-mp-sdk/src/test/java/org/usc/wechat/mp/sdk/util/platform/MenuUtilTest.java
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import org.usc.wechat.mp.sdk.vo.menu.Menu;
import org.usc.wechat.mp.sdk.vo.menu.MenuInfo;
import org.usc.wechat.mp.sdk.vo.menu.MenuType;
import org.usc.wechat.mp.sdk.vo.menu.MultiMenuInfo;
import org.usc.wechat.mp.sdk.vo.menu.SingleMenuInfo;
package org.usc.wechat.mp.sdk.util.platform;
/**
*
* @author Shunli
*/
public class MenuUtilTest {
public static void main(String[] args) throws URISyntaxException {
List<SingleMenuInfo> subMenuInfos = new ArrayList<SingleMenuInfo>();
subMenuInfos.add(MenuType.VIEW.buildSingleMenuInfo("搜索", "http://www.soso.com/"));
subMenuInfos.add(MenuType.VIEW.buildSingleMenuInfo("视频", "http://v.qq.com/"));
subMenuInfos.add(MenuType.CLICK.buildSingleMenuInfo("赞一下我们", "V1001_GOOD"));
List<MenuInfo> menuInfos = new ArrayList<MenuInfo>();
menuInfos.add(MenuType.CLICK.buildSingleMenuInfo("今日歌曲", "V1001_TODAY_MUSIC"));
menuInfos.add(MenuType.CLICK.buildSingleMenuInfo("歌手简介", "V1001_TODAY_SINGER")); | menuInfos.add(new MultiMenuInfo("菜单", subMenuInfos)); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/parser/VideoPushParser.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/Push.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class Push extends AbstractToStringBuilder{
// @XmlElement(name = "ToUserName")
// private String toUserName;
//
// @XmlElement(name = "FromUserName")
// private String fromUserName;
//
// @XmlElement(name = "CreateTime")
// private long createTime;
//
// @XmlElement(name = "MsgType")
// private String msgType;
//
// @XmlElement(name = "MsgId")
// private String msgId;
//
// public String getToUserName() {
// return toUserName;
// }
//
// public void setToUserName(String toUserName) {
// this.toUserName = toUserName;
// }
//
// public String getFromUserName() {
// return fromUserName;
// }
//
// public void setFromUserName(String fromUserName) {
// this.fromUserName = fromUserName;
// }
//
// public long getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(long createTime) {
// this.createTime = createTime;
// }
//
// public String getMsgType() {
// return msgType;
// }
//
// public void setMsgType(String msgType) {
// this.msgType = msgType;
// }
//
// public String getMsgId() {
// return msgId;
// }
//
// public void setMsgId(String msgId) {
// this.msgId = msgId;
// }
//
// }
| import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.push.Push; | package org.usc.wechat.mp.sdk.factory.parser;
/**
*
* @author Shunli
*/
public class VideoPushParser implements PushParser {
@Override | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/Push.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class Push extends AbstractToStringBuilder{
// @XmlElement(name = "ToUserName")
// private String toUserName;
//
// @XmlElement(name = "FromUserName")
// private String fromUserName;
//
// @XmlElement(name = "CreateTime")
// private long createTime;
//
// @XmlElement(name = "MsgType")
// private String msgType;
//
// @XmlElement(name = "MsgId")
// private String msgId;
//
// public String getToUserName() {
// return toUserName;
// }
//
// public void setToUserName(String toUserName) {
// this.toUserName = toUserName;
// }
//
// public String getFromUserName() {
// return fromUserName;
// }
//
// public void setFromUserName(String fromUserName) {
// this.fromUserName = fromUserName;
// }
//
// public long getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(long createTime) {
// this.createTime = createTime;
// }
//
// public String getMsgType() {
// return msgType;
// }
//
// public void setMsgType(String msgType) {
// this.msgType = msgType;
// }
//
// public String getMsgId() {
// return msgId;
// }
//
// public void setMsgId(String msgId) {
// this.msgId = msgId;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/parser/VideoPushParser.java
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.push.Push;
package org.usc.wechat.mp.sdk.factory.parser;
/**
*
* @author Shunli
*/
public class VideoPushParser implements PushParser {
@Override | public Reply parse(Push push) { |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/Push.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/AbstractToStringBuilder.java
// public abstract class AbstractToStringBuilder {
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
// }
// }
| import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.usc.wechat.mp.sdk.vo.AbstractToStringBuilder; | package org.usc.wechat.mp.sdk.vo.push;
/**
*
* @author Shunli
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD) | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/AbstractToStringBuilder.java
// public abstract class AbstractToStringBuilder {
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
// }
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/Push.java
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.usc.wechat.mp.sdk.vo.AbstractToStringBuilder;
package org.usc.wechat.mp.sdk.vo.push;
/**
*
* @author Shunli
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD) | public abstract class Push extends AbstractToStringBuilder{ |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/VoiceCustomMessage.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/detail/MediaCustomMessageDetail.java
// public class MediaCustomMessageDetail extends AbstractToStringBuilder {
// @JSONField(name = "media_id")
// private String mediaId;
//
// protected MediaCustomMessageDetail() {
// }
//
// public MediaCustomMessageDetail(String mediaId) {
// this.mediaId = mediaId;
// }
//
// public String getMediaId() {
// return mediaId;
// }
//
// public void setMediaId(String mediaId) {
// this.mediaId = mediaId;
// }
// }
| import org.usc.wechat.mp.sdk.vo.message.custom.detail.MediaCustomMessageDetail;
import com.alibaba.fastjson.annotation.JSONField; | package org.usc.wechat.mp.sdk.vo.message.custom;
/**
*
* @author Shunli
*/
public class VoiceCustomMessage extends CustomMessage {
@JSONField(name = "voice") | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/detail/MediaCustomMessageDetail.java
// public class MediaCustomMessageDetail extends AbstractToStringBuilder {
// @JSONField(name = "media_id")
// private String mediaId;
//
// protected MediaCustomMessageDetail() {
// }
//
// public MediaCustomMessageDetail(String mediaId) {
// this.mediaId = mediaId;
// }
//
// public String getMediaId() {
// return mediaId;
// }
//
// public void setMediaId(String mediaId) {
// this.mediaId = mediaId;
// }
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/VoiceCustomMessage.java
import org.usc.wechat.mp.sdk.vo.message.custom.detail.MediaCustomMessageDetail;
import com.alibaba.fastjson.annotation.JSONField;
package org.usc.wechat.mp.sdk.vo.message.custom;
/**
*
* @author Shunli
*/
public class VoiceCustomMessage extends CustomMessage {
@JSONField(name = "voice") | private MediaCustomMessageDetail voiceDetail; |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/NewsReply.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/NewsDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class NewsDetail extends AbstractToStringBuilder {
// @XmlElement(name = "Title")
// private String title;
//
// @XmlElement(name = "Description")
// private String description;
//
// @XmlElement(name = "PicUrl")
// private String picUrl;
//
// @XmlElement(name = "Url")
// private String url;
//
// public NewsDetail() {
// }
//
// public NewsDetail(String url) {
// this.url = url;
// }
//
// public NewsDetail(String title, String description, String picUrl, String url) {
// this.title = title;
// this.description = description;
// this.picUrl = picUrl;
// this.url = url;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getPicUrl() {
// return picUrl;
// }
//
// public void setPicUrl(String picUrl) {
// this.picUrl = picUrl;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// }
| import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.NewsDetail; | package org.usc.wechat.mp.sdk.vo.message.reply;
/**
*
* @author Shunli
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class NewsReply extends Reply {
@XmlElement(name = "ArticleCount")
private int articleCount;
@XmlElementWrapper(name = "Articles")
@XmlElement(name = "item") | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/NewsDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class NewsDetail extends AbstractToStringBuilder {
// @XmlElement(name = "Title")
// private String title;
//
// @XmlElement(name = "Description")
// private String description;
//
// @XmlElement(name = "PicUrl")
// private String picUrl;
//
// @XmlElement(name = "Url")
// private String url;
//
// public NewsDetail() {
// }
//
// public NewsDetail(String url) {
// this.url = url;
// }
//
// public NewsDetail(String title, String description, String picUrl, String url) {
// this.title = title;
// this.description = description;
// this.picUrl = picUrl;
// this.url = url;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getPicUrl() {
// return picUrl;
// }
//
// public void setPicUrl(String picUrl) {
// this.picUrl = picUrl;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/NewsReply.java
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.NewsDetail;
package org.usc.wechat.mp.sdk.vo.message.reply;
/**
*
* @author Shunli
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class NewsReply extends Reply {
@XmlElement(name = "ArticleCount")
private int articleCount;
@XmlElementWrapper(name = "Articles")
@XmlElement(name = "item") | private List<NewsDetail> articles; |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/NewsReply.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/NewsDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class NewsDetail extends AbstractToStringBuilder {
// @XmlElement(name = "Title")
// private String title;
//
// @XmlElement(name = "Description")
// private String description;
//
// @XmlElement(name = "PicUrl")
// private String picUrl;
//
// @XmlElement(name = "Url")
// private String url;
//
// public NewsDetail() {
// }
//
// public NewsDetail(String url) {
// this.url = url;
// }
//
// public NewsDetail(String title, String description, String picUrl, String url) {
// this.title = title;
// this.description = description;
// this.picUrl = picUrl;
// this.url = url;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getPicUrl() {
// return picUrl;
// }
//
// public void setPicUrl(String picUrl) {
// this.picUrl = picUrl;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// }
| import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.NewsDetail; | package org.usc.wechat.mp.sdk.vo.message.reply;
/**
*
* @author Shunli
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class NewsReply extends Reply {
@XmlElement(name = "ArticleCount")
private int articleCount;
@XmlElementWrapper(name = "Articles")
@XmlElement(name = "item")
private List<NewsDetail> articles;
{ | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
// TEXT("text", new TextReplyBuilder()),
// NEWS("news", new NewsReplyBuilder()),
// MUSIC("music", new MusicReplyBuilder()),
// IMAGE("image", new ImageReplyBuilder()),
// VOICE("voice", new VoiceReplyBuilder()),
// VIDEO("video", new VideoReplyBuilder());
//
// private String replyType;
// private ReplyBuilder replyBuilder;
//
// private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
// this.replyType = replyType;
// this.replyBuilder = replyBuilder;
// }
//
// public String getReplyType() {
// return replyType;
// }
//
// public Reply buildReply(List<ReplyDetail> replyDetails) {
// if (replyDetails == null || replyDetails.isEmpty()) {
// return null;
// }
//
// return replyBuilder.buildReply(replyDetails);
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/NewsDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class NewsDetail extends AbstractToStringBuilder {
// @XmlElement(name = "Title")
// private String title;
//
// @XmlElement(name = "Description")
// private String description;
//
// @XmlElement(name = "PicUrl")
// private String picUrl;
//
// @XmlElement(name = "Url")
// private String url;
//
// public NewsDetail() {
// }
//
// public NewsDetail(String url) {
// this.url = url;
// }
//
// public NewsDetail(String title, String description, String picUrl, String url) {
// this.title = title;
// this.description = description;
// this.picUrl = picUrl;
// this.url = url;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getPicUrl() {
// return picUrl;
// }
//
// public void setPicUrl(String picUrl) {
// this.picUrl = picUrl;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/NewsReply.java
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.NewsDetail;
package org.usc.wechat.mp.sdk.vo.message.reply;
/**
*
* @author Shunli
*/
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class NewsReply extends Reply {
@XmlElement(name = "ArticleCount")
private int articleCount;
@XmlElementWrapper(name = "Articles")
@XmlElement(name = "item")
private List<NewsDetail> articles;
{ | super.setMsgType(ReplyEnumFactory.NEWS.getReplyType()); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/MusicReplyBuilder.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/MusicReply.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MusicReply extends Reply {
// @XmlElement(name = "Music")
// private MusicDetail musicDetail;
//
// {
// super.setMsgType(ReplyEnumFactory.MUSIC.getReplyType());
// }
//
// public MusicReply() {
// }
//
// public MusicReply(MusicDetail musicDetail) {
// this.musicDetail = musicDetail;
// }
//
// public MusicDetail getMusicDetail() {
// return musicDetail;
// }
//
// public void setMusicDetail(MusicDetail musicDetail) {
// this.musicDetail = musicDetail;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/MusicDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MusicDetail extends AbstractToStringBuilder {
// @XmlElement(name = "Title")
// private String title;
//
// @XmlElement(name = "Description")
// private String description;
//
// @XmlElement(name = "MusicUrl")
// private String musicUrl;
//
// @XmlElement(name = "HQMusicUrl")
// private String hqMusicUrl;
//
// @XmlElement(name = "ThumbMediaId")
// private String thumbMediaId;
//
// public MusicDetail() {
// }
//
// public MusicDetail(String thumbMediaId) {
// this.thumbMediaId = thumbMediaId;
// }
//
// public MusicDetail(String title, String description, String musicUrl, String hqMusicUrl, String thumbMediaId) {
// this.title = title;
// this.description = description;
// this.musicUrl = musicUrl;
// this.hqMusicUrl = hqMusicUrl;
// this.thumbMediaId = thumbMediaId;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getMusicUrl() {
// return musicUrl;
// }
//
// public void setMusicUrl(String musicUrl) {
// this.musicUrl = musicUrl;
// }
//
// public String getHqMusicUrl() {
// return hqMusicUrl;
// }
//
// public void setHqMusicUrl(String hqMusicUrl) {
// this.hqMusicUrl = hqMusicUrl;
// }
//
// public String getThumbMediaId() {
// return thumbMediaId;
// }
//
// public void setThumbMediaId(String thumbMediaId) {
// this.thumbMediaId = thumbMediaId;
// }
//
// }
| import java.util.List;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.MusicReply;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.MusicDetail; | package org.usc.wechat.mp.sdk.factory.builder;
/**
*
* @author Shunli
*/
public class MusicReplyBuilder implements ReplyBuilder {
@Override
public Reply buildReply(List<ReplyDetail> replyDetails) {
ReplyDetail detail = replyDetails.get(0);
| // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/MusicReply.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MusicReply extends Reply {
// @XmlElement(name = "Music")
// private MusicDetail musicDetail;
//
// {
// super.setMsgType(ReplyEnumFactory.MUSIC.getReplyType());
// }
//
// public MusicReply() {
// }
//
// public MusicReply(MusicDetail musicDetail) {
// this.musicDetail = musicDetail;
// }
//
// public MusicDetail getMusicDetail() {
// return musicDetail;
// }
//
// public void setMusicDetail(MusicDetail musicDetail) {
// this.musicDetail = musicDetail;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/MusicDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MusicDetail extends AbstractToStringBuilder {
// @XmlElement(name = "Title")
// private String title;
//
// @XmlElement(name = "Description")
// private String description;
//
// @XmlElement(name = "MusicUrl")
// private String musicUrl;
//
// @XmlElement(name = "HQMusicUrl")
// private String hqMusicUrl;
//
// @XmlElement(name = "ThumbMediaId")
// private String thumbMediaId;
//
// public MusicDetail() {
// }
//
// public MusicDetail(String thumbMediaId) {
// this.thumbMediaId = thumbMediaId;
// }
//
// public MusicDetail(String title, String description, String musicUrl, String hqMusicUrl, String thumbMediaId) {
// this.title = title;
// this.description = description;
// this.musicUrl = musicUrl;
// this.hqMusicUrl = hqMusicUrl;
// this.thumbMediaId = thumbMediaId;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getMusicUrl() {
// return musicUrl;
// }
//
// public void setMusicUrl(String musicUrl) {
// this.musicUrl = musicUrl;
// }
//
// public String getHqMusicUrl() {
// return hqMusicUrl;
// }
//
// public void setHqMusicUrl(String hqMusicUrl) {
// this.hqMusicUrl = hqMusicUrl;
// }
//
// public String getThumbMediaId() {
// return thumbMediaId;
// }
//
// public void setThumbMediaId(String thumbMediaId) {
// this.thumbMediaId = thumbMediaId;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/MusicReplyBuilder.java
import java.util.List;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.MusicReply;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.MusicDetail;
package org.usc.wechat.mp.sdk.factory.builder;
/**
*
* @author Shunli
*/
public class MusicReplyBuilder implements ReplyBuilder {
@Override
public Reply buildReply(List<ReplyDetail> replyDetails) {
ReplyDetail detail = replyDetails.get(0);
| MusicDetail musicDetail = new MusicDetail( |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/MusicReplyBuilder.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/MusicReply.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MusicReply extends Reply {
// @XmlElement(name = "Music")
// private MusicDetail musicDetail;
//
// {
// super.setMsgType(ReplyEnumFactory.MUSIC.getReplyType());
// }
//
// public MusicReply() {
// }
//
// public MusicReply(MusicDetail musicDetail) {
// this.musicDetail = musicDetail;
// }
//
// public MusicDetail getMusicDetail() {
// return musicDetail;
// }
//
// public void setMusicDetail(MusicDetail musicDetail) {
// this.musicDetail = musicDetail;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/MusicDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MusicDetail extends AbstractToStringBuilder {
// @XmlElement(name = "Title")
// private String title;
//
// @XmlElement(name = "Description")
// private String description;
//
// @XmlElement(name = "MusicUrl")
// private String musicUrl;
//
// @XmlElement(name = "HQMusicUrl")
// private String hqMusicUrl;
//
// @XmlElement(name = "ThumbMediaId")
// private String thumbMediaId;
//
// public MusicDetail() {
// }
//
// public MusicDetail(String thumbMediaId) {
// this.thumbMediaId = thumbMediaId;
// }
//
// public MusicDetail(String title, String description, String musicUrl, String hqMusicUrl, String thumbMediaId) {
// this.title = title;
// this.description = description;
// this.musicUrl = musicUrl;
// this.hqMusicUrl = hqMusicUrl;
// this.thumbMediaId = thumbMediaId;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getMusicUrl() {
// return musicUrl;
// }
//
// public void setMusicUrl(String musicUrl) {
// this.musicUrl = musicUrl;
// }
//
// public String getHqMusicUrl() {
// return hqMusicUrl;
// }
//
// public void setHqMusicUrl(String hqMusicUrl) {
// this.hqMusicUrl = hqMusicUrl;
// }
//
// public String getThumbMediaId() {
// return thumbMediaId;
// }
//
// public void setThumbMediaId(String thumbMediaId) {
// this.thumbMediaId = thumbMediaId;
// }
//
// }
| import java.util.List;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.MusicReply;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.MusicDetail; | package org.usc.wechat.mp.sdk.factory.builder;
/**
*
* @author Shunli
*/
public class MusicReplyBuilder implements ReplyBuilder {
@Override
public Reply buildReply(List<ReplyDetail> replyDetails) {
ReplyDetail detail = replyDetails.get(0);
MusicDetail musicDetail = new MusicDetail(
detail.getTitle(),
detail.getDescription(),
detail.getMediaUrl(),
detail.getUrl(),
detail.getThumbMediaId());
| // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/MusicReply.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MusicReply extends Reply {
// @XmlElement(name = "Music")
// private MusicDetail musicDetail;
//
// {
// super.setMsgType(ReplyEnumFactory.MUSIC.getReplyType());
// }
//
// public MusicReply() {
// }
//
// public MusicReply(MusicDetail musicDetail) {
// this.musicDetail = musicDetail;
// }
//
// public MusicDetail getMusicDetail() {
// return musicDetail;
// }
//
// public void setMusicDetail(MusicDetail musicDetail) {
// this.musicDetail = musicDetail;
// }
//
// }
//
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/detail/MusicDetail.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class MusicDetail extends AbstractToStringBuilder {
// @XmlElement(name = "Title")
// private String title;
//
// @XmlElement(name = "Description")
// private String description;
//
// @XmlElement(name = "MusicUrl")
// private String musicUrl;
//
// @XmlElement(name = "HQMusicUrl")
// private String hqMusicUrl;
//
// @XmlElement(name = "ThumbMediaId")
// private String thumbMediaId;
//
// public MusicDetail() {
// }
//
// public MusicDetail(String thumbMediaId) {
// this.thumbMediaId = thumbMediaId;
// }
//
// public MusicDetail(String title, String description, String musicUrl, String hqMusicUrl, String thumbMediaId) {
// this.title = title;
// this.description = description;
// this.musicUrl = musicUrl;
// this.hqMusicUrl = hqMusicUrl;
// this.thumbMediaId = thumbMediaId;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getMusicUrl() {
// return musicUrl;
// }
//
// public void setMusicUrl(String musicUrl) {
// this.musicUrl = musicUrl;
// }
//
// public String getHqMusicUrl() {
// return hqMusicUrl;
// }
//
// public void setHqMusicUrl(String hqMusicUrl) {
// this.hqMusicUrl = hqMusicUrl;
// }
//
// public String getThumbMediaId() {
// return thumbMediaId;
// }
//
// public void setThumbMediaId(String thumbMediaId) {
// this.thumbMediaId = thumbMediaId;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/MusicReplyBuilder.java
import java.util.List;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.MusicReply;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.MusicDetail;
package org.usc.wechat.mp.sdk.factory.builder;
/**
*
* @author Shunli
*/
public class MusicReplyBuilder implements ReplyBuilder {
@Override
public Reply buildReply(List<ReplyDetail> replyDetails) {
ReplyDetail detail = replyDetails.get(0);
MusicDetail musicDetail = new MusicDetail(
detail.getTitle(),
detail.getDescription(),
detail.getMediaUrl(),
detail.getUrl(),
detail.getThumbMediaId());
| return new MusicReply(musicDetail); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/VideoReplyBuilder.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/VideoReply.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class VideoReply extends Reply {
// @XmlElement(name = "Video")
// private VideoDetail videoDetail;
//
// {
// super.setMsgType(ReplyEnumFactory.VIDEO.getReplyType());
// }
//
// public VideoReply() {
// }
//
// public VideoReply(VideoDetail videoDetail) {
// this.videoDetail = videoDetail;
// }
//
// public VideoDetail getVideoDetail() {
// return videoDetail;
// }
//
// public void setVideoDetail(VideoDetail videoDetail) {
// this.videoDetail = videoDetail;
// }
//
// }
| import java.util.List;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.message.reply.VideoReply;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.VideoDetail; | package org.usc.wechat.mp.sdk.factory.builder;
/**
*
* @author Shunli
*/
public class VideoReplyBuilder implements ReplyBuilder {
@Override
public Reply buildReply(List<ReplyDetail> replyDetails) {
ReplyDetail detail = replyDetails.get(0);
VideoDetail videoDetail = new VideoDetail(detail.getMediaId());
videoDetail.setTitle(detail.getTitle());
videoDetail.setDescription(detail.getDescription());
| // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/reply/VideoReply.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public class VideoReply extends Reply {
// @XmlElement(name = "Video")
// private VideoDetail videoDetail;
//
// {
// super.setMsgType(ReplyEnumFactory.VIDEO.getReplyType());
// }
//
// public VideoReply() {
// }
//
// public VideoReply(VideoDetail videoDetail) {
// this.videoDetail = videoDetail;
// }
//
// public VideoDetail getVideoDetail() {
// return videoDetail;
// }
//
// public void setVideoDetail(VideoDetail videoDetail) {
// this.videoDetail = videoDetail;
// }
//
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/builder/VideoReplyBuilder.java
import java.util.List;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.message.reply.VideoReply;
import org.usc.wechat.mp.sdk.vo.message.reply.detail.VideoDetail;
package org.usc.wechat.mp.sdk.factory.builder;
/**
*
* @author Shunli
*/
public class VideoReplyBuilder implements ReplyBuilder {
@Override
public Reply buildReply(List<ReplyDetail> replyDetails) {
ReplyDetail detail = replyDetails.get(0);
VideoDetail videoDetail = new VideoDetail(detail.getMediaId());
videoDetail.setTitle(detail.getTitle());
videoDetail.setDescription(detail.getDescription());
| return new VideoReply(videoDetail); |
usc/wechat-mp-sdk | wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/ImageCustomMessage.java | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/detail/MediaCustomMessageDetail.java
// public class MediaCustomMessageDetail extends AbstractToStringBuilder {
// @JSONField(name = "media_id")
// private String mediaId;
//
// protected MediaCustomMessageDetail() {
// }
//
// public MediaCustomMessageDetail(String mediaId) {
// this.mediaId = mediaId;
// }
//
// public String getMediaId() {
// return mediaId;
// }
//
// public void setMediaId(String mediaId) {
// this.mediaId = mediaId;
// }
// }
| import org.usc.wechat.mp.sdk.vo.message.custom.detail.MediaCustomMessageDetail;
import com.alibaba.fastjson.annotation.JSONField; | package org.usc.wechat.mp.sdk.vo.message.custom;
/**
*
* @author Shunli
*/
public class ImageCustomMessage extends CustomMessage {
@JSONField(name = "image") | // Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/detail/MediaCustomMessageDetail.java
// public class MediaCustomMessageDetail extends AbstractToStringBuilder {
// @JSONField(name = "media_id")
// private String mediaId;
//
// protected MediaCustomMessageDetail() {
// }
//
// public MediaCustomMessageDetail(String mediaId) {
// this.mediaId = mediaId;
// }
//
// public String getMediaId() {
// return mediaId;
// }
//
// public void setMediaId(String mediaId) {
// this.mediaId = mediaId;
// }
// }
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/message/custom/ImageCustomMessage.java
import org.usc.wechat.mp.sdk.vo.message.custom.detail.MediaCustomMessageDetail;
import com.alibaba.fastjson.annotation.JSONField;
package org.usc.wechat.mp.sdk.vo.message.custom;
/**
*
* @author Shunli
*/
public class ImageCustomMessage extends CustomMessage {
@JSONField(name = "image") | private MediaCustomMessageDetail imageDetail; |
valdasraps/esj | client/src/main/java/lt/emasina/esj/tcp/TcpFramer.java | // Path: client/src/main/java/lt/emasina/esj/model/ParseException.java
// public class ParseException extends Throwable {
//
// public ParseException(String message, Object... params) {
// super(String.format(message, params));
// }
//
// public ParseException(Exception ex) {
// super(ex);
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpConnection.java
// public static final int HEADER_SIZE = 4;
//
// Path: client/src/main/java/lt/emasina/esj/util/Bytes.java
// public class Bytes {
//
// /**
// * Appends two bytes array into one.
// *
// * @param a A byte[].
// * @param b A byte[].
// * @return A byte[].
// */
// public static byte[] append(byte[] a, byte[] b) {
// byte[] z = new byte[a.length + b.length];
// System.arraycopy(a, 0, z, 0, a.length);
// System.arraycopy(b, 0, z, a.length, b.length);
// return z;
// }
//
// /**
// * Returns a 8-byte array built from a long.
// *
// * @param n The number to convert.
// * @return A byte[].
// */
// public static byte[] toBytes(long n) {
// return toBytes(n, new byte[8]);
// }
//
// /**
// * Build a 8-byte array from a long. No check is performed on the array
// * length.
// *
// * @param n The number to convert.
// * @param b The array to fill.
// * @return A byte[].
// */
// public static byte[] toBytes(long n, byte[] b) {
// b[7] = (byte) (n);
// n >>>= 8;
// b[6] = (byte) (n);
// n >>>= 8;
// b[5] = (byte) (n);
// n >>>= 8;
// b[4] = (byte) (n);
// n >>>= 8;
// b[3] = (byte) (n);
// n >>>= 8;
// b[2] = (byte) (n);
// n >>>= 8;
// b[1] = (byte) (n);
// n >>>= 8;
// b[0] = (byte) (n);
//
// return b;
// }
//
// public static byte[] toBytes(UUID i) {
// return Bytes.append(Bytes.toBytes(i.getMostSignificantBits()), Bytes.toBytes(i.getLeastSignificantBits()));
// }
//
// //** Formatting and validation constants
// /**
// * Chars in a UUID String.
// */
// private static final int UUID_UNFORMATTED_LENGTH = 32;
//
// /**
// * Insertion points for dashes in the string format
// */
// private static final int FORMAT_POSITIONS[] = new int[]{8, 13, 18, 23};
//
// public static UUID fromBytes(byte[] b) {
// if (b.length != 16) {
// throw new IllegalArgumentException(String.format("Expected length 16, was %d", b.length));
// }
// StringBuilder sb = new StringBuilder(new String(Hex.encodeHex(b)));
// while (sb.length() != UUID_UNFORMATTED_LENGTH) {
// sb.insert(0, "0");
// }
// for (int fp : FORMAT_POSITIONS) {
// sb.insert(fp, '-');
// }
// return UUID.fromString(sb.toString());
// }
//
// public static int toInt(byte b) {
// return (int) b & 0xFF;
// }
//
// public static String toBinaryString(byte b) {
// return String.format("%8s", Integer.toBinaryString(toInt(b))).replace(' ', '0');
// }
//
// public static String debugString(byte[]
// ... bs) {
// StringBuilder sbA = new StringBuilder();
// StringBuilder sbL = new StringBuilder();
// for (byte[] b1 : bs) {
// StringBuilder sb = new StringBuilder();
// for (byte b : b1) {
// sb.append(String.format("%02X ", b));
// }
// sbA.append("[").append(sb.toString().trim()).append("]");
// sbL.append("[").append(b1.length).append("]");
// }
// return String.format("Bytes (sizes: %s): %s", sbL.toString(), sbA.toString());
// }
//
// }
| import lt.emasina.esj.model.ParseException;
import static lt.emasina.esj.tcp.TcpConnection.HEADER_SIZE;
import lt.emasina.esj.util.Bytes; | package lt.emasina.esj.tcp;
/**
* TcpFramer class
* @author Stasys
*/
public class TcpFramer {
public static byte[][] frame(byte [] data) {
int len = data.length;
return new byte [][] {
{ (byte) len, (byte)(len >> 8), (byte)(len >> 16), (byte)(len >> 24) },
data };
}
| // Path: client/src/main/java/lt/emasina/esj/model/ParseException.java
// public class ParseException extends Throwable {
//
// public ParseException(String message, Object... params) {
// super(String.format(message, params));
// }
//
// public ParseException(Exception ex) {
// super(ex);
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpConnection.java
// public static final int HEADER_SIZE = 4;
//
// Path: client/src/main/java/lt/emasina/esj/util/Bytes.java
// public class Bytes {
//
// /**
// * Appends two bytes array into one.
// *
// * @param a A byte[].
// * @param b A byte[].
// * @return A byte[].
// */
// public static byte[] append(byte[] a, byte[] b) {
// byte[] z = new byte[a.length + b.length];
// System.arraycopy(a, 0, z, 0, a.length);
// System.arraycopy(b, 0, z, a.length, b.length);
// return z;
// }
//
// /**
// * Returns a 8-byte array built from a long.
// *
// * @param n The number to convert.
// * @return A byte[].
// */
// public static byte[] toBytes(long n) {
// return toBytes(n, new byte[8]);
// }
//
// /**
// * Build a 8-byte array from a long. No check is performed on the array
// * length.
// *
// * @param n The number to convert.
// * @param b The array to fill.
// * @return A byte[].
// */
// public static byte[] toBytes(long n, byte[] b) {
// b[7] = (byte) (n);
// n >>>= 8;
// b[6] = (byte) (n);
// n >>>= 8;
// b[5] = (byte) (n);
// n >>>= 8;
// b[4] = (byte) (n);
// n >>>= 8;
// b[3] = (byte) (n);
// n >>>= 8;
// b[2] = (byte) (n);
// n >>>= 8;
// b[1] = (byte) (n);
// n >>>= 8;
// b[0] = (byte) (n);
//
// return b;
// }
//
// public static byte[] toBytes(UUID i) {
// return Bytes.append(Bytes.toBytes(i.getMostSignificantBits()), Bytes.toBytes(i.getLeastSignificantBits()));
// }
//
// //** Formatting and validation constants
// /**
// * Chars in a UUID String.
// */
// private static final int UUID_UNFORMATTED_LENGTH = 32;
//
// /**
// * Insertion points for dashes in the string format
// */
// private static final int FORMAT_POSITIONS[] = new int[]{8, 13, 18, 23};
//
// public static UUID fromBytes(byte[] b) {
// if (b.length != 16) {
// throw new IllegalArgumentException(String.format("Expected length 16, was %d", b.length));
// }
// StringBuilder sb = new StringBuilder(new String(Hex.encodeHex(b)));
// while (sb.length() != UUID_UNFORMATTED_LENGTH) {
// sb.insert(0, "0");
// }
// for (int fp : FORMAT_POSITIONS) {
// sb.insert(fp, '-');
// }
// return UUID.fromString(sb.toString());
// }
//
// public static int toInt(byte b) {
// return (int) b & 0xFF;
// }
//
// public static String toBinaryString(byte b) {
// return String.format("%8s", Integer.toBinaryString(toInt(b))).replace(' ', '0');
// }
//
// public static String debugString(byte[]
// ... bs) {
// StringBuilder sbA = new StringBuilder();
// StringBuilder sbL = new StringBuilder();
// for (byte[] b1 : bs) {
// StringBuilder sb = new StringBuilder();
// for (byte b : b1) {
// sb.append(String.format("%02X ", b));
// }
// sbA.append("[").append(sb.toString().trim()).append("]");
// sbL.append("[").append(b1.length).append("]");
// }
// return String.format("Bytes (sizes: %s): %s", sbL.toString(), sbA.toString());
// }
//
// }
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpFramer.java
import lt.emasina.esj.model.ParseException;
import static lt.emasina.esj.tcp.TcpConnection.HEADER_SIZE;
import lt.emasina.esj.util.Bytes;
package lt.emasina.esj.tcp;
/**
* TcpFramer class
* @author Stasys
*/
public class TcpFramer {
public static byte[][] frame(byte [] data) {
int len = data.length;
return new byte [][] {
{ (byte) len, (byte)(len >> 8), (byte)(len >> 16), (byte)(len >> 24) },
data };
}
| public static byte[] unframe(byte [] data) throws ParseException { |
valdasraps/esj | client/src/main/java/lt/emasina/esj/tcp/TcpFramer.java | // Path: client/src/main/java/lt/emasina/esj/model/ParseException.java
// public class ParseException extends Throwable {
//
// public ParseException(String message, Object... params) {
// super(String.format(message, params));
// }
//
// public ParseException(Exception ex) {
// super(ex);
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpConnection.java
// public static final int HEADER_SIZE = 4;
//
// Path: client/src/main/java/lt/emasina/esj/util/Bytes.java
// public class Bytes {
//
// /**
// * Appends two bytes array into one.
// *
// * @param a A byte[].
// * @param b A byte[].
// * @return A byte[].
// */
// public static byte[] append(byte[] a, byte[] b) {
// byte[] z = new byte[a.length + b.length];
// System.arraycopy(a, 0, z, 0, a.length);
// System.arraycopy(b, 0, z, a.length, b.length);
// return z;
// }
//
// /**
// * Returns a 8-byte array built from a long.
// *
// * @param n The number to convert.
// * @return A byte[].
// */
// public static byte[] toBytes(long n) {
// return toBytes(n, new byte[8]);
// }
//
// /**
// * Build a 8-byte array from a long. No check is performed on the array
// * length.
// *
// * @param n The number to convert.
// * @param b The array to fill.
// * @return A byte[].
// */
// public static byte[] toBytes(long n, byte[] b) {
// b[7] = (byte) (n);
// n >>>= 8;
// b[6] = (byte) (n);
// n >>>= 8;
// b[5] = (byte) (n);
// n >>>= 8;
// b[4] = (byte) (n);
// n >>>= 8;
// b[3] = (byte) (n);
// n >>>= 8;
// b[2] = (byte) (n);
// n >>>= 8;
// b[1] = (byte) (n);
// n >>>= 8;
// b[0] = (byte) (n);
//
// return b;
// }
//
// public static byte[] toBytes(UUID i) {
// return Bytes.append(Bytes.toBytes(i.getMostSignificantBits()), Bytes.toBytes(i.getLeastSignificantBits()));
// }
//
// //** Formatting and validation constants
// /**
// * Chars in a UUID String.
// */
// private static final int UUID_UNFORMATTED_LENGTH = 32;
//
// /**
// * Insertion points for dashes in the string format
// */
// private static final int FORMAT_POSITIONS[] = new int[]{8, 13, 18, 23};
//
// public static UUID fromBytes(byte[] b) {
// if (b.length != 16) {
// throw new IllegalArgumentException(String.format("Expected length 16, was %d", b.length));
// }
// StringBuilder sb = new StringBuilder(new String(Hex.encodeHex(b)));
// while (sb.length() != UUID_UNFORMATTED_LENGTH) {
// sb.insert(0, "0");
// }
// for (int fp : FORMAT_POSITIONS) {
// sb.insert(fp, '-');
// }
// return UUID.fromString(sb.toString());
// }
//
// public static int toInt(byte b) {
// return (int) b & 0xFF;
// }
//
// public static String toBinaryString(byte b) {
// return String.format("%8s", Integer.toBinaryString(toInt(b))).replace(' ', '0');
// }
//
// public static String debugString(byte[]
// ... bs) {
// StringBuilder sbA = new StringBuilder();
// StringBuilder sbL = new StringBuilder();
// for (byte[] b1 : bs) {
// StringBuilder sb = new StringBuilder();
// for (byte b : b1) {
// sb.append(String.format("%02X ", b));
// }
// sbA.append("[").append(sb.toString().trim()).append("]");
// sbL.append("[").append(b1.length).append("]");
// }
// return String.format("Bytes (sizes: %s): %s", sbL.toString(), sbA.toString());
// }
//
// }
| import lt.emasina.esj.model.ParseException;
import static lt.emasina.esj.tcp.TcpConnection.HEADER_SIZE;
import lt.emasina.esj.util.Bytes; | package lt.emasina.esj.tcp;
/**
* TcpFramer class
* @author Stasys
*/
public class TcpFramer {
public static byte[][] frame(byte [] data) {
int len = data.length;
return new byte [][] {
{ (byte) len, (byte)(len >> 8), (byte)(len >> 16), (byte)(len >> 24) },
data };
}
public static byte[] unframe(byte [] data) throws ParseException { | // Path: client/src/main/java/lt/emasina/esj/model/ParseException.java
// public class ParseException extends Throwable {
//
// public ParseException(String message, Object... params) {
// super(String.format(message, params));
// }
//
// public ParseException(Exception ex) {
// super(ex);
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpConnection.java
// public static final int HEADER_SIZE = 4;
//
// Path: client/src/main/java/lt/emasina/esj/util/Bytes.java
// public class Bytes {
//
// /**
// * Appends two bytes array into one.
// *
// * @param a A byte[].
// * @param b A byte[].
// * @return A byte[].
// */
// public static byte[] append(byte[] a, byte[] b) {
// byte[] z = new byte[a.length + b.length];
// System.arraycopy(a, 0, z, 0, a.length);
// System.arraycopy(b, 0, z, a.length, b.length);
// return z;
// }
//
// /**
// * Returns a 8-byte array built from a long.
// *
// * @param n The number to convert.
// * @return A byte[].
// */
// public static byte[] toBytes(long n) {
// return toBytes(n, new byte[8]);
// }
//
// /**
// * Build a 8-byte array from a long. No check is performed on the array
// * length.
// *
// * @param n The number to convert.
// * @param b The array to fill.
// * @return A byte[].
// */
// public static byte[] toBytes(long n, byte[] b) {
// b[7] = (byte) (n);
// n >>>= 8;
// b[6] = (byte) (n);
// n >>>= 8;
// b[5] = (byte) (n);
// n >>>= 8;
// b[4] = (byte) (n);
// n >>>= 8;
// b[3] = (byte) (n);
// n >>>= 8;
// b[2] = (byte) (n);
// n >>>= 8;
// b[1] = (byte) (n);
// n >>>= 8;
// b[0] = (byte) (n);
//
// return b;
// }
//
// public static byte[] toBytes(UUID i) {
// return Bytes.append(Bytes.toBytes(i.getMostSignificantBits()), Bytes.toBytes(i.getLeastSignificantBits()));
// }
//
// //** Formatting and validation constants
// /**
// * Chars in a UUID String.
// */
// private static final int UUID_UNFORMATTED_LENGTH = 32;
//
// /**
// * Insertion points for dashes in the string format
// */
// private static final int FORMAT_POSITIONS[] = new int[]{8, 13, 18, 23};
//
// public static UUID fromBytes(byte[] b) {
// if (b.length != 16) {
// throw new IllegalArgumentException(String.format("Expected length 16, was %d", b.length));
// }
// StringBuilder sb = new StringBuilder(new String(Hex.encodeHex(b)));
// while (sb.length() != UUID_UNFORMATTED_LENGTH) {
// sb.insert(0, "0");
// }
// for (int fp : FORMAT_POSITIONS) {
// sb.insert(fp, '-');
// }
// return UUID.fromString(sb.toString());
// }
//
// public static int toInt(byte b) {
// return (int) b & 0xFF;
// }
//
// public static String toBinaryString(byte b) {
// return String.format("%8s", Integer.toBinaryString(toInt(b))).replace(' ', '0');
// }
//
// public static String debugString(byte[]
// ... bs) {
// StringBuilder sbA = new StringBuilder();
// StringBuilder sbL = new StringBuilder();
// for (byte[] b1 : bs) {
// StringBuilder sb = new StringBuilder();
// for (byte b : b1) {
// sb.append(String.format("%02X ", b));
// }
// sbA.append("[").append(sb.toString().trim()).append("]");
// sbL.append("[").append(b1.length).append("]");
// }
// return String.format("Bytes (sizes: %s): %s", sbL.toString(), sbA.toString());
// }
//
// }
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpFramer.java
import lt.emasina.esj.model.ParseException;
import static lt.emasina.esj.tcp.TcpConnection.HEADER_SIZE;
import lt.emasina.esj.util.Bytes;
package lt.emasina.esj.tcp;
/**
* TcpFramer class
* @author Stasys
*/
public class TcpFramer {
public static byte[][] frame(byte [] data) {
int len = data.length;
return new byte [][] {
{ (byte) len, (byte)(len >> 8), (byte)(len >> 16), (byte)(len >> 24) },
data };
}
public static byte[] unframe(byte [] data) throws ParseException { | if (data.length < HEADER_SIZE) { |
valdasraps/esj | client/src/main/java/lt/emasina/esj/tcp/TcpFramer.java | // Path: client/src/main/java/lt/emasina/esj/model/ParseException.java
// public class ParseException extends Throwable {
//
// public ParseException(String message, Object... params) {
// super(String.format(message, params));
// }
//
// public ParseException(Exception ex) {
// super(ex);
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpConnection.java
// public static final int HEADER_SIZE = 4;
//
// Path: client/src/main/java/lt/emasina/esj/util/Bytes.java
// public class Bytes {
//
// /**
// * Appends two bytes array into one.
// *
// * @param a A byte[].
// * @param b A byte[].
// * @return A byte[].
// */
// public static byte[] append(byte[] a, byte[] b) {
// byte[] z = new byte[a.length + b.length];
// System.arraycopy(a, 0, z, 0, a.length);
// System.arraycopy(b, 0, z, a.length, b.length);
// return z;
// }
//
// /**
// * Returns a 8-byte array built from a long.
// *
// * @param n The number to convert.
// * @return A byte[].
// */
// public static byte[] toBytes(long n) {
// return toBytes(n, new byte[8]);
// }
//
// /**
// * Build a 8-byte array from a long. No check is performed on the array
// * length.
// *
// * @param n The number to convert.
// * @param b The array to fill.
// * @return A byte[].
// */
// public static byte[] toBytes(long n, byte[] b) {
// b[7] = (byte) (n);
// n >>>= 8;
// b[6] = (byte) (n);
// n >>>= 8;
// b[5] = (byte) (n);
// n >>>= 8;
// b[4] = (byte) (n);
// n >>>= 8;
// b[3] = (byte) (n);
// n >>>= 8;
// b[2] = (byte) (n);
// n >>>= 8;
// b[1] = (byte) (n);
// n >>>= 8;
// b[0] = (byte) (n);
//
// return b;
// }
//
// public static byte[] toBytes(UUID i) {
// return Bytes.append(Bytes.toBytes(i.getMostSignificantBits()), Bytes.toBytes(i.getLeastSignificantBits()));
// }
//
// //** Formatting and validation constants
// /**
// * Chars in a UUID String.
// */
// private static final int UUID_UNFORMATTED_LENGTH = 32;
//
// /**
// * Insertion points for dashes in the string format
// */
// private static final int FORMAT_POSITIONS[] = new int[]{8, 13, 18, 23};
//
// public static UUID fromBytes(byte[] b) {
// if (b.length != 16) {
// throw new IllegalArgumentException(String.format("Expected length 16, was %d", b.length));
// }
// StringBuilder sb = new StringBuilder(new String(Hex.encodeHex(b)));
// while (sb.length() != UUID_UNFORMATTED_LENGTH) {
// sb.insert(0, "0");
// }
// for (int fp : FORMAT_POSITIONS) {
// sb.insert(fp, '-');
// }
// return UUID.fromString(sb.toString());
// }
//
// public static int toInt(byte b) {
// return (int) b & 0xFF;
// }
//
// public static String toBinaryString(byte b) {
// return String.format("%8s", Integer.toBinaryString(toInt(b))).replace(' ', '0');
// }
//
// public static String debugString(byte[]
// ... bs) {
// StringBuilder sbA = new StringBuilder();
// StringBuilder sbL = new StringBuilder();
// for (byte[] b1 : bs) {
// StringBuilder sb = new StringBuilder();
// for (byte b : b1) {
// sb.append(String.format("%02X ", b));
// }
// sbA.append("[").append(sb.toString().trim()).append("]");
// sbL.append("[").append(b1.length).append("]");
// }
// return String.format("Bytes (sizes: %s): %s", sbL.toString(), sbA.toString());
// }
//
// }
| import lt.emasina.esj.model.ParseException;
import static lt.emasina.esj.tcp.TcpConnection.HEADER_SIZE;
import lt.emasina.esj.util.Bytes; | package lt.emasina.esj.tcp;
/**
* TcpFramer class
* @author Stasys
*/
public class TcpFramer {
public static byte[][] frame(byte [] data) {
int len = data.length;
return new byte [][] {
{ (byte) len, (byte)(len >> 8), (byte)(len >> 16), (byte)(len >> 24) },
data };
}
public static byte[] unframe(byte [] data) throws ParseException {
if (data.length < HEADER_SIZE) {
throw new ParseException("Data buffer (%d) smaller than header (%d)", data.length, HEADER_SIZE);
} | // Path: client/src/main/java/lt/emasina/esj/model/ParseException.java
// public class ParseException extends Throwable {
//
// public ParseException(String message, Object... params) {
// super(String.format(message, params));
// }
//
// public ParseException(Exception ex) {
// super(ex);
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpConnection.java
// public static final int HEADER_SIZE = 4;
//
// Path: client/src/main/java/lt/emasina/esj/util/Bytes.java
// public class Bytes {
//
// /**
// * Appends two bytes array into one.
// *
// * @param a A byte[].
// * @param b A byte[].
// * @return A byte[].
// */
// public static byte[] append(byte[] a, byte[] b) {
// byte[] z = new byte[a.length + b.length];
// System.arraycopy(a, 0, z, 0, a.length);
// System.arraycopy(b, 0, z, a.length, b.length);
// return z;
// }
//
// /**
// * Returns a 8-byte array built from a long.
// *
// * @param n The number to convert.
// * @return A byte[].
// */
// public static byte[] toBytes(long n) {
// return toBytes(n, new byte[8]);
// }
//
// /**
// * Build a 8-byte array from a long. No check is performed on the array
// * length.
// *
// * @param n The number to convert.
// * @param b The array to fill.
// * @return A byte[].
// */
// public static byte[] toBytes(long n, byte[] b) {
// b[7] = (byte) (n);
// n >>>= 8;
// b[6] = (byte) (n);
// n >>>= 8;
// b[5] = (byte) (n);
// n >>>= 8;
// b[4] = (byte) (n);
// n >>>= 8;
// b[3] = (byte) (n);
// n >>>= 8;
// b[2] = (byte) (n);
// n >>>= 8;
// b[1] = (byte) (n);
// n >>>= 8;
// b[0] = (byte) (n);
//
// return b;
// }
//
// public static byte[] toBytes(UUID i) {
// return Bytes.append(Bytes.toBytes(i.getMostSignificantBits()), Bytes.toBytes(i.getLeastSignificantBits()));
// }
//
// //** Formatting and validation constants
// /**
// * Chars in a UUID String.
// */
// private static final int UUID_UNFORMATTED_LENGTH = 32;
//
// /**
// * Insertion points for dashes in the string format
// */
// private static final int FORMAT_POSITIONS[] = new int[]{8, 13, 18, 23};
//
// public static UUID fromBytes(byte[] b) {
// if (b.length != 16) {
// throw new IllegalArgumentException(String.format("Expected length 16, was %d", b.length));
// }
// StringBuilder sb = new StringBuilder(new String(Hex.encodeHex(b)));
// while (sb.length() != UUID_UNFORMATTED_LENGTH) {
// sb.insert(0, "0");
// }
// for (int fp : FORMAT_POSITIONS) {
// sb.insert(fp, '-');
// }
// return UUID.fromString(sb.toString());
// }
//
// public static int toInt(byte b) {
// return (int) b & 0xFF;
// }
//
// public static String toBinaryString(byte b) {
// return String.format("%8s", Integer.toBinaryString(toInt(b))).replace(' ', '0');
// }
//
// public static String debugString(byte[]
// ... bs) {
// StringBuilder sbA = new StringBuilder();
// StringBuilder sbL = new StringBuilder();
// for (byte[] b1 : bs) {
// StringBuilder sb = new StringBuilder();
// for (byte b : b1) {
// sb.append(String.format("%02X ", b));
// }
// sbA.append("[").append(sb.toString().trim()).append("]");
// sbL.append("[").append(b1.length).append("]");
// }
// return String.format("Bytes (sizes: %s): %s", sbL.toString(), sbA.toString());
// }
//
// }
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpFramer.java
import lt.emasina.esj.model.ParseException;
import static lt.emasina.esj.tcp.TcpConnection.HEADER_SIZE;
import lt.emasina.esj.util.Bytes;
package lt.emasina.esj.tcp;
/**
* TcpFramer class
* @author Stasys
*/
public class TcpFramer {
public static byte[][] frame(byte [] data) {
int len = data.length;
return new byte [][] {
{ (byte) len, (byte)(len >> 8), (byte)(len >> 16), (byte)(len >> 24) },
data };
}
public static byte[] unframe(byte [] data) throws ParseException {
if (data.length < HEADER_SIZE) {
throw new ParseException("Data buffer (%d) smaller than header (%d)", data.length, HEADER_SIZE);
} | int rawlen = Bytes.toInt(data[0]) + Bytes.toInt(data[1]) + Bytes.toInt(data[2]) + Bytes.toInt(data[3]); |
valdasraps/esj | client/src/main/java/lt/emasina/esj/tcp/TcpCommand.java | // Path: client/src/main/java/lt/emasina/esj/util/Bytes.java
// public class Bytes {
//
// /**
// * Appends two bytes array into one.
// *
// * @param a A byte[].
// * @param b A byte[].
// * @return A byte[].
// */
// public static byte[] append(byte[] a, byte[] b) {
// byte[] z = new byte[a.length + b.length];
// System.arraycopy(a, 0, z, 0, a.length);
// System.arraycopy(b, 0, z, a.length, b.length);
// return z;
// }
//
// /**
// * Returns a 8-byte array built from a long.
// *
// * @param n The number to convert.
// * @return A byte[].
// */
// public static byte[] toBytes(long n) {
// return toBytes(n, new byte[8]);
// }
//
// /**
// * Build a 8-byte array from a long. No check is performed on the array
// * length.
// *
// * @param n The number to convert.
// * @param b The array to fill.
// * @return A byte[].
// */
// public static byte[] toBytes(long n, byte[] b) {
// b[7] = (byte) (n);
// n >>>= 8;
// b[6] = (byte) (n);
// n >>>= 8;
// b[5] = (byte) (n);
// n >>>= 8;
// b[4] = (byte) (n);
// n >>>= 8;
// b[3] = (byte) (n);
// n >>>= 8;
// b[2] = (byte) (n);
// n >>>= 8;
// b[1] = (byte) (n);
// n >>>= 8;
// b[0] = (byte) (n);
//
// return b;
// }
//
// public static byte[] toBytes(UUID i) {
// return Bytes.append(Bytes.toBytes(i.getMostSignificantBits()), Bytes.toBytes(i.getLeastSignificantBits()));
// }
//
// //** Formatting and validation constants
// /**
// * Chars in a UUID String.
// */
// private static final int UUID_UNFORMATTED_LENGTH = 32;
//
// /**
// * Insertion points for dashes in the string format
// */
// private static final int FORMAT_POSITIONS[] = new int[]{8, 13, 18, 23};
//
// public static UUID fromBytes(byte[] b) {
// if (b.length != 16) {
// throw new IllegalArgumentException(String.format("Expected length 16, was %d", b.length));
// }
// StringBuilder sb = new StringBuilder(new String(Hex.encodeHex(b)));
// while (sb.length() != UUID_UNFORMATTED_LENGTH) {
// sb.insert(0, "0");
// }
// for (int fp : FORMAT_POSITIONS) {
// sb.insert(fp, '-');
// }
// return UUID.fromString(sb.toString());
// }
//
// public static int toInt(byte b) {
// return (int) b & 0xFF;
// }
//
// public static String toBinaryString(byte b) {
// return String.format("%8s", Integer.toBinaryString(toInt(b))).replace(' ', '0');
// }
//
// public static String debugString(byte[]
// ... bs) {
// StringBuilder sbA = new StringBuilder();
// StringBuilder sbL = new StringBuilder();
// for (byte[] b1 : bs) {
// StringBuilder sb = new StringBuilder();
// for (byte b : b1) {
// sb.append(String.format("%02X ", b));
// }
// sbA.append("[").append(sb.toString().trim()).append("]");
// sbL.append("[").append(b1.length).append("]");
// }
// return String.format("Bytes (sizes: %s): %s", sbL.toString(), sbA.toString());
// }
//
// }
| import lt.emasina.esj.util.Bytes; | ReadStreamEventsBackwardCompleted(0xB5),
ReadAllEventsForward(0xB6),
ReadAllEventsForwardCompleted(0xB7),
ReadAllEventsBackward(0xB8),
ReadAllEventsBackwardCompleted(0xB9),
SubscribeToStream(0xC0),
SubscriptionConfirmation(0xC1),
StreamEventAppeared(0xC2),
UnsubscribeFromStream(0xC3),
SubscriptionDropped(0xC4),
ScavengeDatabase(0xD0),
ScavengeDatabaseCompleted(0xD1),
BadRequest(0xF0),
NotHandled(0xF1),
Authenticate(0xF2),
Authenticated(0xF3),
NotAuthenticated(0xF4);
private final byte mask;
private TcpCommand(int mask) {
this.mask = (byte) mask;
}
public static TcpCommand valueOf(byte mask) {
for (TcpCommand c : TcpCommand.values()) {
if (c.getMask() == mask) {
return c;
}
} | // Path: client/src/main/java/lt/emasina/esj/util/Bytes.java
// public class Bytes {
//
// /**
// * Appends two bytes array into one.
// *
// * @param a A byte[].
// * @param b A byte[].
// * @return A byte[].
// */
// public static byte[] append(byte[] a, byte[] b) {
// byte[] z = new byte[a.length + b.length];
// System.arraycopy(a, 0, z, 0, a.length);
// System.arraycopy(b, 0, z, a.length, b.length);
// return z;
// }
//
// /**
// * Returns a 8-byte array built from a long.
// *
// * @param n The number to convert.
// * @return A byte[].
// */
// public static byte[] toBytes(long n) {
// return toBytes(n, new byte[8]);
// }
//
// /**
// * Build a 8-byte array from a long. No check is performed on the array
// * length.
// *
// * @param n The number to convert.
// * @param b The array to fill.
// * @return A byte[].
// */
// public static byte[] toBytes(long n, byte[] b) {
// b[7] = (byte) (n);
// n >>>= 8;
// b[6] = (byte) (n);
// n >>>= 8;
// b[5] = (byte) (n);
// n >>>= 8;
// b[4] = (byte) (n);
// n >>>= 8;
// b[3] = (byte) (n);
// n >>>= 8;
// b[2] = (byte) (n);
// n >>>= 8;
// b[1] = (byte) (n);
// n >>>= 8;
// b[0] = (byte) (n);
//
// return b;
// }
//
// public static byte[] toBytes(UUID i) {
// return Bytes.append(Bytes.toBytes(i.getMostSignificantBits()), Bytes.toBytes(i.getLeastSignificantBits()));
// }
//
// //** Formatting and validation constants
// /**
// * Chars in a UUID String.
// */
// private static final int UUID_UNFORMATTED_LENGTH = 32;
//
// /**
// * Insertion points for dashes in the string format
// */
// private static final int FORMAT_POSITIONS[] = new int[]{8, 13, 18, 23};
//
// public static UUID fromBytes(byte[] b) {
// if (b.length != 16) {
// throw new IllegalArgumentException(String.format("Expected length 16, was %d", b.length));
// }
// StringBuilder sb = new StringBuilder(new String(Hex.encodeHex(b)));
// while (sb.length() != UUID_UNFORMATTED_LENGTH) {
// sb.insert(0, "0");
// }
// for (int fp : FORMAT_POSITIONS) {
// sb.insert(fp, '-');
// }
// return UUID.fromString(sb.toString());
// }
//
// public static int toInt(byte b) {
// return (int) b & 0xFF;
// }
//
// public static String toBinaryString(byte b) {
// return String.format("%8s", Integer.toBinaryString(toInt(b))).replace(' ', '0');
// }
//
// public static String debugString(byte[]
// ... bs) {
// StringBuilder sbA = new StringBuilder();
// StringBuilder sbL = new StringBuilder();
// for (byte[] b1 : bs) {
// StringBuilder sb = new StringBuilder();
// for (byte b : b1) {
// sb.append(String.format("%02X ", b));
// }
// sbA.append("[").append(sb.toString().trim()).append("]");
// sbL.append("[").append(b1.length).append("]");
// }
// return String.format("Bytes (sizes: %s): %s", sbL.toString(), sbA.toString());
// }
//
// }
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpCommand.java
import lt.emasina.esj.util.Bytes;
ReadStreamEventsBackwardCompleted(0xB5),
ReadAllEventsForward(0xB6),
ReadAllEventsForwardCompleted(0xB7),
ReadAllEventsBackward(0xB8),
ReadAllEventsBackwardCompleted(0xB9),
SubscribeToStream(0xC0),
SubscriptionConfirmation(0xC1),
StreamEventAppeared(0xC2),
UnsubscribeFromStream(0xC3),
SubscriptionDropped(0xC4),
ScavengeDatabase(0xD0),
ScavengeDatabaseCompleted(0xD1),
BadRequest(0xF0),
NotHandled(0xF1),
Authenticate(0xF2),
Authenticated(0xF3),
NotAuthenticated(0xF4);
private final byte mask;
private TcpCommand(int mask) {
this.mask = (byte) mask;
}
public static TcpCommand valueOf(byte mask) {
for (TcpCommand c : TcpCommand.values()) {
if (c.getMask() == mask) {
return c;
}
} | throw new IllegalArgumentException(String.format("Unknown mask: %d (%s)", Bytes.toInt(mask), Bytes.toBinaryString(mask))); |
valdasraps/esj | client/src/test/java/lt/emasina/esj/TestResponseReceiver.java | // Path: client/src/main/java/lt/emasina/esj/model/Message.java
// public abstract class Message {
//
// // General properties
// protected final TcpCommand command;
//
// protected UUID correlationId;
//
// // Request properties
// protected UserCredentials user;
//
// // Response properties
// protected String message;
//
// /**
// * Constructor with required arguments.
// *
// * @param command
// */
// public Message(TcpCommand command) {
// super();
// this.command = command;
// }
//
// public Message(TcpCommand command, UserCredentials user) {
// this.command = command;
// this.correlationId = UUID.randomUUID();
// this.user = user;
// }
//
// public GeneratedMessage getDto(Settings settings) {
// return null;
// }
//
// public void parse(byte[] data) throws ParseException {
//
// }
//
// public final TcpPackage getTcpPackage(Settings settings) {
// TcpFlag flag = (user == null ? TcpFlag.None : TcpFlag.Authenticated);
// GeneratedMessage dto = getDto(settings);
// return new TcpPackage(command, flag, correlationId, user, dto == null ? new byte[]{} : dto.toByteArray());
// }
//
// public final void parse(TcpPackage pckg) throws ParseException {
// parse(null, pckg);
// }
//
// public final void parse(Message request, TcpPackage pckg) throws ParseException {
//
// if (!command.equals(pckg.getCommand())) {
// throw new ParseException("Command does not match: expected %s got %s", command, pckg.getCommand());
// }
//
// if (request != null && !request.getCorrelationId().equals(pckg.getCorrelationId())) {
// throw new ParseException("Correlation ID does not match: expected %s got %s", request.getCorrelationId(), pckg.getCorrelationId());
// } else {
// this.correlationId = pckg.getCorrelationId();
// }
//
// this.user = pckg.getUser();
// parse(pckg.getData());
// }
//
// protected String toResultInfo() {
// return "Unimplemented!";
// }
//
// /**
// * @return the correlationId
// */
// public UUID getCorrelationId() {
// return correlationId;
// }
//
// /**
// * @param correlationId the correlationId to set
// */
// public void setCorrelationId(UUID correlationId) {
// this.correlationId = correlationId;
// }
//
// /**
// * @return the user
// */
// public UserCredentials getUser() {
// return user;
// }
//
// /**
// * @param user the user to set
// */
// public void setUser(UserCredentials user) {
// this.user = user;
// }
//
// /**
// * @return the message
// */
// public String getMessage() {
// return message;
// }
//
// /**
// * @param message the message to set
// */
// public void setMessage(String message) {
// this.message = message;
// }
//
// /**
// * @return the command
// */
// public TcpCommand getCommand() {
// return command;
// }
//
// }
| import lt.emasina.esj.model.Message; | package lt.emasina.esj;
/**
* Helper class to make threaded testing a little easier.
*/
public class TestResponseReceiver implements ResponseReceiver {
private volatile boolean resultAvailable = false;
private Exception ex;
| // Path: client/src/main/java/lt/emasina/esj/model/Message.java
// public abstract class Message {
//
// // General properties
// protected final TcpCommand command;
//
// protected UUID correlationId;
//
// // Request properties
// protected UserCredentials user;
//
// // Response properties
// protected String message;
//
// /**
// * Constructor with required arguments.
// *
// * @param command
// */
// public Message(TcpCommand command) {
// super();
// this.command = command;
// }
//
// public Message(TcpCommand command, UserCredentials user) {
// this.command = command;
// this.correlationId = UUID.randomUUID();
// this.user = user;
// }
//
// public GeneratedMessage getDto(Settings settings) {
// return null;
// }
//
// public void parse(byte[] data) throws ParseException {
//
// }
//
// public final TcpPackage getTcpPackage(Settings settings) {
// TcpFlag flag = (user == null ? TcpFlag.None : TcpFlag.Authenticated);
// GeneratedMessage dto = getDto(settings);
// return new TcpPackage(command, flag, correlationId, user, dto == null ? new byte[]{} : dto.toByteArray());
// }
//
// public final void parse(TcpPackage pckg) throws ParseException {
// parse(null, pckg);
// }
//
// public final void parse(Message request, TcpPackage pckg) throws ParseException {
//
// if (!command.equals(pckg.getCommand())) {
// throw new ParseException("Command does not match: expected %s got %s", command, pckg.getCommand());
// }
//
// if (request != null && !request.getCorrelationId().equals(pckg.getCorrelationId())) {
// throw new ParseException("Correlation ID does not match: expected %s got %s", request.getCorrelationId(), pckg.getCorrelationId());
// } else {
// this.correlationId = pckg.getCorrelationId();
// }
//
// this.user = pckg.getUser();
// parse(pckg.getData());
// }
//
// protected String toResultInfo() {
// return "Unimplemented!";
// }
//
// /**
// * @return the correlationId
// */
// public UUID getCorrelationId() {
// return correlationId;
// }
//
// /**
// * @param correlationId the correlationId to set
// */
// public void setCorrelationId(UUID correlationId) {
// this.correlationId = correlationId;
// }
//
// /**
// * @return the user
// */
// public UserCredentials getUser() {
// return user;
// }
//
// /**
// * @param user the user to set
// */
// public void setUser(UserCredentials user) {
// this.user = user;
// }
//
// /**
// * @return the message
// */
// public String getMessage() {
// return message;
// }
//
// /**
// * @param message the message to set
// */
// public void setMessage(String message) {
// this.message = message;
// }
//
// /**
// * @return the command
// */
// public TcpCommand getCommand() {
// return command;
// }
//
// }
// Path: client/src/test/java/lt/emasina/esj/TestResponseReceiver.java
import lt.emasina.esj.model.Message;
package lt.emasina.esj;
/**
* Helper class to make threaded testing a little easier.
*/
public class TestResponseReceiver implements ResponseReceiver {
private volatile boolean resultAvailable = false;
private Exception ex;
| private Message msg; |
valdasraps/esj | client/src/main/java/lt/emasina/esj/tcp/TcpSocketManager.java | // Path: client/src/main/java/lt/emasina/esj/model/RequestOperation.java
// public abstract class RequestOperation<F extends Message> extends ResponseOperation {
//
// private final TcpConnection connection;
// protected F request;
//
// public RequestOperation(TcpConnection connection, F request) {
// this.connection = connection;
// this.request = request;
// }
//
// //private final Semaphore processing = new Semaphore(0);
//
// public TcpPackage getRequestPackage() {
// return request.getTcpPackage(connection.getSettings());
// }
//
// public UUID getCorrelationId() {
// return request.getCorrelationId();
// }
//
// public void doneProcessing() {
// //processing.release();
// }
//
// public void send() {
// sendAsync();
// /*try {
// processing.acquire();
// } catch (InterruptedException ex) {
// log.warn("Processing was interrpupted", ex);
// }*/
// }
//
// public void sendAsync() {
// connection.send(this);
// }
//
// /**
// * @return the connection
// */
// public TcpConnection getConnection() {
// return connection;
// }
//
// /**
// * @return the request
// */
// public F getRequest() {
// return request;
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/model/ResponseOperation.java
// public abstract class ResponseOperation {
//
// public boolean hasSingleResponse = true;
//
// public abstract void setResponsePackage(TcpPackage pckg);
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/operation/HeartBeatResponseOperation.java
// public class HeartBeatResponseOperation extends RequestOperation<HeartBeatResponse> {
//
// public HeartBeatResponseOperation(TcpConnection connection, UUID correlationId) {
// super(connection, new HeartBeatResponse());
// this.getRequest().setCorrelationId(correlationId);
// }
//
// @Override
// public void setResponsePackage(TcpPackage pckg) {
//
// }
//
// }
| import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.Semaphore;
import lt.emasina.esj.model.RequestOperation;
import lt.emasina.esj.model.ResponseOperation;
import lt.emasina.esj.operation.HeartBeatResponseOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package lt.emasina.esj.tcp;
/**
* TcpProcessor
*
* @author Stasys
*/
public class TcpSocketManager implements Runnable {
private static final Logger log = LoggerFactory.getLogger(TcpSocketManager.class);
private final TcpConnection connection;
private final InetAddress host;
private final int port;
private Socket socket;
public final ExecutorService executor;
private Future<?> senderTask;
private Future<?> receiverTask;
private final Semaphore running = new Semaphore(0);
| // Path: client/src/main/java/lt/emasina/esj/model/RequestOperation.java
// public abstract class RequestOperation<F extends Message> extends ResponseOperation {
//
// private final TcpConnection connection;
// protected F request;
//
// public RequestOperation(TcpConnection connection, F request) {
// this.connection = connection;
// this.request = request;
// }
//
// //private final Semaphore processing = new Semaphore(0);
//
// public TcpPackage getRequestPackage() {
// return request.getTcpPackage(connection.getSettings());
// }
//
// public UUID getCorrelationId() {
// return request.getCorrelationId();
// }
//
// public void doneProcessing() {
// //processing.release();
// }
//
// public void send() {
// sendAsync();
// /*try {
// processing.acquire();
// } catch (InterruptedException ex) {
// log.warn("Processing was interrpupted", ex);
// }*/
// }
//
// public void sendAsync() {
// connection.send(this);
// }
//
// /**
// * @return the connection
// */
// public TcpConnection getConnection() {
// return connection;
// }
//
// /**
// * @return the request
// */
// public F getRequest() {
// return request;
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/model/ResponseOperation.java
// public abstract class ResponseOperation {
//
// public boolean hasSingleResponse = true;
//
// public abstract void setResponsePackage(TcpPackage pckg);
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/operation/HeartBeatResponseOperation.java
// public class HeartBeatResponseOperation extends RequestOperation<HeartBeatResponse> {
//
// public HeartBeatResponseOperation(TcpConnection connection, UUID correlationId) {
// super(connection, new HeartBeatResponse());
// this.getRequest().setCorrelationId(correlationId);
// }
//
// @Override
// public void setResponsePackage(TcpPackage pckg) {
//
// }
//
// }
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpSocketManager.java
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.Semaphore;
import lt.emasina.esj.model.RequestOperation;
import lt.emasina.esj.model.ResponseOperation;
import lt.emasina.esj.operation.HeartBeatResponseOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package lt.emasina.esj.tcp;
/**
* TcpProcessor
*
* @author Stasys
*/
public class TcpSocketManager implements Runnable {
private static final Logger log = LoggerFactory.getLogger(TcpSocketManager.class);
private final TcpConnection connection;
private final InetAddress host;
private final int port;
private Socket socket;
public final ExecutorService executor;
private Future<?> senderTask;
private Future<?> receiverTask;
private final Semaphore running = new Semaphore(0);
| private final BlockingQueue<RequestOperation> sending = new LinkedBlockingDeque<>(); |
valdasraps/esj | client/src/main/java/lt/emasina/esj/tcp/TcpSocketManager.java | // Path: client/src/main/java/lt/emasina/esj/model/RequestOperation.java
// public abstract class RequestOperation<F extends Message> extends ResponseOperation {
//
// private final TcpConnection connection;
// protected F request;
//
// public RequestOperation(TcpConnection connection, F request) {
// this.connection = connection;
// this.request = request;
// }
//
// //private final Semaphore processing = new Semaphore(0);
//
// public TcpPackage getRequestPackage() {
// return request.getTcpPackage(connection.getSettings());
// }
//
// public UUID getCorrelationId() {
// return request.getCorrelationId();
// }
//
// public void doneProcessing() {
// //processing.release();
// }
//
// public void send() {
// sendAsync();
// /*try {
// processing.acquire();
// } catch (InterruptedException ex) {
// log.warn("Processing was interrpupted", ex);
// }*/
// }
//
// public void sendAsync() {
// connection.send(this);
// }
//
// /**
// * @return the connection
// */
// public TcpConnection getConnection() {
// return connection;
// }
//
// /**
// * @return the request
// */
// public F getRequest() {
// return request;
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/model/ResponseOperation.java
// public abstract class ResponseOperation {
//
// public boolean hasSingleResponse = true;
//
// public abstract void setResponsePackage(TcpPackage pckg);
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/operation/HeartBeatResponseOperation.java
// public class HeartBeatResponseOperation extends RequestOperation<HeartBeatResponse> {
//
// public HeartBeatResponseOperation(TcpConnection connection, UUID correlationId) {
// super(connection, new HeartBeatResponse());
// this.getRequest().setCorrelationId(correlationId);
// }
//
// @Override
// public void setResponsePackage(TcpPackage pckg) {
//
// }
//
// }
| import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.Semaphore;
import lt.emasina.esj.model.RequestOperation;
import lt.emasina.esj.model.ResponseOperation;
import lt.emasina.esj.operation.HeartBeatResponseOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package lt.emasina.esj.tcp;
/**
* TcpProcessor
*
* @author Stasys
*/
public class TcpSocketManager implements Runnable {
private static final Logger log = LoggerFactory.getLogger(TcpSocketManager.class);
private final TcpConnection connection;
private final InetAddress host;
private final int port;
private Socket socket;
public final ExecutorService executor;
private Future<?> senderTask;
private Future<?> receiverTask;
private final Semaphore running = new Semaphore(0);
private final BlockingQueue<RequestOperation> sending = new LinkedBlockingDeque<>();
| // Path: client/src/main/java/lt/emasina/esj/model/RequestOperation.java
// public abstract class RequestOperation<F extends Message> extends ResponseOperation {
//
// private final TcpConnection connection;
// protected F request;
//
// public RequestOperation(TcpConnection connection, F request) {
// this.connection = connection;
// this.request = request;
// }
//
// //private final Semaphore processing = new Semaphore(0);
//
// public TcpPackage getRequestPackage() {
// return request.getTcpPackage(connection.getSettings());
// }
//
// public UUID getCorrelationId() {
// return request.getCorrelationId();
// }
//
// public void doneProcessing() {
// //processing.release();
// }
//
// public void send() {
// sendAsync();
// /*try {
// processing.acquire();
// } catch (InterruptedException ex) {
// log.warn("Processing was interrpupted", ex);
// }*/
// }
//
// public void sendAsync() {
// connection.send(this);
// }
//
// /**
// * @return the connection
// */
// public TcpConnection getConnection() {
// return connection;
// }
//
// /**
// * @return the request
// */
// public F getRequest() {
// return request;
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/model/ResponseOperation.java
// public abstract class ResponseOperation {
//
// public boolean hasSingleResponse = true;
//
// public abstract void setResponsePackage(TcpPackage pckg);
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/operation/HeartBeatResponseOperation.java
// public class HeartBeatResponseOperation extends RequestOperation<HeartBeatResponse> {
//
// public HeartBeatResponseOperation(TcpConnection connection, UUID correlationId) {
// super(connection, new HeartBeatResponse());
// this.getRequest().setCorrelationId(correlationId);
// }
//
// @Override
// public void setResponsePackage(TcpPackage pckg) {
//
// }
//
// }
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpSocketManager.java
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.Semaphore;
import lt.emasina.esj.model.RequestOperation;
import lt.emasina.esj.model.ResponseOperation;
import lt.emasina.esj.operation.HeartBeatResponseOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package lt.emasina.esj.tcp;
/**
* TcpProcessor
*
* @author Stasys
*/
public class TcpSocketManager implements Runnable {
private static final Logger log = LoggerFactory.getLogger(TcpSocketManager.class);
private final TcpConnection connection;
private final InetAddress host;
private final int port;
private Socket socket;
public final ExecutorService executor;
private Future<?> senderTask;
private Future<?> receiverTask;
private final Semaphore running = new Semaphore(0);
private final BlockingQueue<RequestOperation> sending = new LinkedBlockingDeque<>();
| private final Map<UUID, ResponseOperation> receiving = new ConcurrentHashMap<>(); |
valdasraps/esj | client/src/main/java/lt/emasina/esj/tcp/TcpSocketManager.java | // Path: client/src/main/java/lt/emasina/esj/model/RequestOperation.java
// public abstract class RequestOperation<F extends Message> extends ResponseOperation {
//
// private final TcpConnection connection;
// protected F request;
//
// public RequestOperation(TcpConnection connection, F request) {
// this.connection = connection;
// this.request = request;
// }
//
// //private final Semaphore processing = new Semaphore(0);
//
// public TcpPackage getRequestPackage() {
// return request.getTcpPackage(connection.getSettings());
// }
//
// public UUID getCorrelationId() {
// return request.getCorrelationId();
// }
//
// public void doneProcessing() {
// //processing.release();
// }
//
// public void send() {
// sendAsync();
// /*try {
// processing.acquire();
// } catch (InterruptedException ex) {
// log.warn("Processing was interrpupted", ex);
// }*/
// }
//
// public void sendAsync() {
// connection.send(this);
// }
//
// /**
// * @return the connection
// */
// public TcpConnection getConnection() {
// return connection;
// }
//
// /**
// * @return the request
// */
// public F getRequest() {
// return request;
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/model/ResponseOperation.java
// public abstract class ResponseOperation {
//
// public boolean hasSingleResponse = true;
//
// public abstract void setResponsePackage(TcpPackage pckg);
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/operation/HeartBeatResponseOperation.java
// public class HeartBeatResponseOperation extends RequestOperation<HeartBeatResponse> {
//
// public HeartBeatResponseOperation(TcpConnection connection, UUID correlationId) {
// super(connection, new HeartBeatResponse());
// this.getRequest().setCorrelationId(correlationId);
// }
//
// @Override
// public void setResponsePackage(TcpPackage pckg) {
//
// }
//
// }
| import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.Semaphore;
import lt.emasina.esj.model.RequestOperation;
import lt.emasina.esj.model.ResponseOperation;
import lt.emasina.esj.operation.HeartBeatResponseOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package lt.emasina.esj.tcp;
/**
* TcpProcessor
*
* @author Stasys
*/
public class TcpSocketManager implements Runnable {
private static final Logger log = LoggerFactory.getLogger(TcpSocketManager.class);
private final TcpConnection connection;
private final InetAddress host;
private final int port;
private Socket socket;
public final ExecutorService executor;
private Future<?> senderTask;
private Future<?> receiverTask;
private final Semaphore running = new Semaphore(0);
private final BlockingQueue<RequestOperation> sending = new LinkedBlockingDeque<>();
private final Map<UUID, ResponseOperation> receiving = new ConcurrentHashMap<>();
/**
* Constructor with mandatory fields.
*
* @param connection
* @param host
* @param port
* @param executor
*/
public TcpSocketManager(TcpConnection connection, InetAddress host, int port, ExecutorService executor) {
super();
this.connection = connection;
this.host = host;
this.port = port;
this.executor = executor;
}
public void scheduleSend(RequestOperation op) {
this.sending.add(op);
}
public void respondHeartBeat(UUID correlationId) { | // Path: client/src/main/java/lt/emasina/esj/model/RequestOperation.java
// public abstract class RequestOperation<F extends Message> extends ResponseOperation {
//
// private final TcpConnection connection;
// protected F request;
//
// public RequestOperation(TcpConnection connection, F request) {
// this.connection = connection;
// this.request = request;
// }
//
// //private final Semaphore processing = new Semaphore(0);
//
// public TcpPackage getRequestPackage() {
// return request.getTcpPackage(connection.getSettings());
// }
//
// public UUID getCorrelationId() {
// return request.getCorrelationId();
// }
//
// public void doneProcessing() {
// //processing.release();
// }
//
// public void send() {
// sendAsync();
// /*try {
// processing.acquire();
// } catch (InterruptedException ex) {
// log.warn("Processing was interrpupted", ex);
// }*/
// }
//
// public void sendAsync() {
// connection.send(this);
// }
//
// /**
// * @return the connection
// */
// public TcpConnection getConnection() {
// return connection;
// }
//
// /**
// * @return the request
// */
// public F getRequest() {
// return request;
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/model/ResponseOperation.java
// public abstract class ResponseOperation {
//
// public boolean hasSingleResponse = true;
//
// public abstract void setResponsePackage(TcpPackage pckg);
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/operation/HeartBeatResponseOperation.java
// public class HeartBeatResponseOperation extends RequestOperation<HeartBeatResponse> {
//
// public HeartBeatResponseOperation(TcpConnection connection, UUID correlationId) {
// super(connection, new HeartBeatResponse());
// this.getRequest().setCorrelationId(correlationId);
// }
//
// @Override
// public void setResponsePackage(TcpPackage pckg) {
//
// }
//
// }
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpSocketManager.java
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.Semaphore;
import lt.emasina.esj.model.RequestOperation;
import lt.emasina.esj.model.ResponseOperation;
import lt.emasina.esj.operation.HeartBeatResponseOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package lt.emasina.esj.tcp;
/**
* TcpProcessor
*
* @author Stasys
*/
public class TcpSocketManager implements Runnable {
private static final Logger log = LoggerFactory.getLogger(TcpSocketManager.class);
private final TcpConnection connection;
private final InetAddress host;
private final int port;
private Socket socket;
public final ExecutorService executor;
private Future<?> senderTask;
private Future<?> receiverTask;
private final Semaphore running = new Semaphore(0);
private final BlockingQueue<RequestOperation> sending = new LinkedBlockingDeque<>();
private final Map<UUID, ResponseOperation> receiving = new ConcurrentHashMap<>();
/**
* Constructor with mandatory fields.
*
* @param connection
* @param host
* @param port
* @param executor
*/
public TcpSocketManager(TcpConnection connection, InetAddress host, int port, ExecutorService executor) {
super();
this.connection = connection;
this.host = host;
this.port = port;
this.executor = executor;
}
public void scheduleSend(RequestOperation op) {
this.sending.add(op);
}
public void respondHeartBeat(UUID correlationId) { | this.sending.add(new HeartBeatResponseOperation(connection, correlationId)); |
valdasraps/esj | client/src/main/java/lt/emasina/esj/tcp/TcpReceiver.java | // Path: client/src/main/java/lt/emasina/esj/tcp/TcpConnection.java
// public static final int HEADER_SIZE = 4;
//
// Path: client/src/main/java/lt/emasina/esj/model/ParseException.java
// public class ParseException extends Throwable {
//
// public ParseException(String message, Object... params) {
// super(String.format(message, params));
// }
//
// public ParseException(Exception ex) {
// super(ex);
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/model/ResponseOperation.java
// public abstract class ResponseOperation {
//
// public boolean hasSingleResponse = true;
//
// public abstract void setResponsePackage(TcpPackage pckg);
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/util/Bytes.java
// public class Bytes {
//
// /**
// * Appends two bytes array into one.
// *
// * @param a A byte[].
// * @param b A byte[].
// * @return A byte[].
// */
// public static byte[] append(byte[] a, byte[] b) {
// byte[] z = new byte[a.length + b.length];
// System.arraycopy(a, 0, z, 0, a.length);
// System.arraycopy(b, 0, z, a.length, b.length);
// return z;
// }
//
// /**
// * Returns a 8-byte array built from a long.
// *
// * @param n The number to convert.
// * @return A byte[].
// */
// public static byte[] toBytes(long n) {
// return toBytes(n, new byte[8]);
// }
//
// /**
// * Build a 8-byte array from a long. No check is performed on the array
// * length.
// *
// * @param n The number to convert.
// * @param b The array to fill.
// * @return A byte[].
// */
// public static byte[] toBytes(long n, byte[] b) {
// b[7] = (byte) (n);
// n >>>= 8;
// b[6] = (byte) (n);
// n >>>= 8;
// b[5] = (byte) (n);
// n >>>= 8;
// b[4] = (byte) (n);
// n >>>= 8;
// b[3] = (byte) (n);
// n >>>= 8;
// b[2] = (byte) (n);
// n >>>= 8;
// b[1] = (byte) (n);
// n >>>= 8;
// b[0] = (byte) (n);
//
// return b;
// }
//
// public static byte[] toBytes(UUID i) {
// return Bytes.append(Bytes.toBytes(i.getMostSignificantBits()), Bytes.toBytes(i.getLeastSignificantBits()));
// }
//
// //** Formatting and validation constants
// /**
// * Chars in a UUID String.
// */
// private static final int UUID_UNFORMATTED_LENGTH = 32;
//
// /**
// * Insertion points for dashes in the string format
// */
// private static final int FORMAT_POSITIONS[] = new int[]{8, 13, 18, 23};
//
// public static UUID fromBytes(byte[] b) {
// if (b.length != 16) {
// throw new IllegalArgumentException(String.format("Expected length 16, was %d", b.length));
// }
// StringBuilder sb = new StringBuilder(new String(Hex.encodeHex(b)));
// while (sb.length() != UUID_UNFORMATTED_LENGTH) {
// sb.insert(0, "0");
// }
// for (int fp : FORMAT_POSITIONS) {
// sb.insert(fp, '-');
// }
// return UUID.fromString(sb.toString());
// }
//
// public static int toInt(byte b) {
// return (int) b & 0xFF;
// }
//
// public static String toBinaryString(byte b) {
// return String.format("%8s", Integer.toBinaryString(toInt(b))).replace(' ', '0');
// }
//
// public static String debugString(byte[]
// ... bs) {
// StringBuilder sbA = new StringBuilder();
// StringBuilder sbL = new StringBuilder();
// for (byte[] b1 : bs) {
// StringBuilder sb = new StringBuilder();
// for (byte b : b1) {
// sb.append(String.format("%02X ", b));
// }
// sbA.append("[").append(sb.toString().trim()).append("]");
// sbL.append("[").append(b1.length).append("]");
// }
// return String.format("Bytes (sizes: %s): %s", sbL.toString(), sbA.toString());
// }
//
// }
| import static lt.emasina.esj.tcp.TcpConnection.HEADER_SIZE;
import java.io.IOException;
import java.io.InputStream;
import lt.emasina.esj.model.ParseException;
import lt.emasina.esj.model.ResponseOperation;
import lt.emasina.esj.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package lt.emasina.esj.tcp;
/**
* TcpReceiver class
* @author Stasys
*/
public class TcpReceiver implements Runnable {
private static final Logger log = LoggerFactory.getLogger(TcpReceiver.class);
private final InputStream in;
private final TcpSocketManager manager;
/**
* Constructor with mandatory data.
*
* @param in
* @param manager
*/
public TcpReceiver(InputStream in, TcpSocketManager manager) {
super();
this.in = in;
this.manager = manager;
}
@Override
public void run() {
try {
// Wait for the manager to lock itself
while (!manager.getRunning().hasQueuedThreads()) Thread.sleep(10);
while (manager.getRunning().hasQueuedThreads()) {
// Receive header | // Path: client/src/main/java/lt/emasina/esj/tcp/TcpConnection.java
// public static final int HEADER_SIZE = 4;
//
// Path: client/src/main/java/lt/emasina/esj/model/ParseException.java
// public class ParseException extends Throwable {
//
// public ParseException(String message, Object... params) {
// super(String.format(message, params));
// }
//
// public ParseException(Exception ex) {
// super(ex);
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/model/ResponseOperation.java
// public abstract class ResponseOperation {
//
// public boolean hasSingleResponse = true;
//
// public abstract void setResponsePackage(TcpPackage pckg);
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/util/Bytes.java
// public class Bytes {
//
// /**
// * Appends two bytes array into one.
// *
// * @param a A byte[].
// * @param b A byte[].
// * @return A byte[].
// */
// public static byte[] append(byte[] a, byte[] b) {
// byte[] z = new byte[a.length + b.length];
// System.arraycopy(a, 0, z, 0, a.length);
// System.arraycopy(b, 0, z, a.length, b.length);
// return z;
// }
//
// /**
// * Returns a 8-byte array built from a long.
// *
// * @param n The number to convert.
// * @return A byte[].
// */
// public static byte[] toBytes(long n) {
// return toBytes(n, new byte[8]);
// }
//
// /**
// * Build a 8-byte array from a long. No check is performed on the array
// * length.
// *
// * @param n The number to convert.
// * @param b The array to fill.
// * @return A byte[].
// */
// public static byte[] toBytes(long n, byte[] b) {
// b[7] = (byte) (n);
// n >>>= 8;
// b[6] = (byte) (n);
// n >>>= 8;
// b[5] = (byte) (n);
// n >>>= 8;
// b[4] = (byte) (n);
// n >>>= 8;
// b[3] = (byte) (n);
// n >>>= 8;
// b[2] = (byte) (n);
// n >>>= 8;
// b[1] = (byte) (n);
// n >>>= 8;
// b[0] = (byte) (n);
//
// return b;
// }
//
// public static byte[] toBytes(UUID i) {
// return Bytes.append(Bytes.toBytes(i.getMostSignificantBits()), Bytes.toBytes(i.getLeastSignificantBits()));
// }
//
// //** Formatting and validation constants
// /**
// * Chars in a UUID String.
// */
// private static final int UUID_UNFORMATTED_LENGTH = 32;
//
// /**
// * Insertion points for dashes in the string format
// */
// private static final int FORMAT_POSITIONS[] = new int[]{8, 13, 18, 23};
//
// public static UUID fromBytes(byte[] b) {
// if (b.length != 16) {
// throw new IllegalArgumentException(String.format("Expected length 16, was %d", b.length));
// }
// StringBuilder sb = new StringBuilder(new String(Hex.encodeHex(b)));
// while (sb.length() != UUID_UNFORMATTED_LENGTH) {
// sb.insert(0, "0");
// }
// for (int fp : FORMAT_POSITIONS) {
// sb.insert(fp, '-');
// }
// return UUID.fromString(sb.toString());
// }
//
// public static int toInt(byte b) {
// return (int) b & 0xFF;
// }
//
// public static String toBinaryString(byte b) {
// return String.format("%8s", Integer.toBinaryString(toInt(b))).replace(' ', '0');
// }
//
// public static String debugString(byte[]
// ... bs) {
// StringBuilder sbA = new StringBuilder();
// StringBuilder sbL = new StringBuilder();
// for (byte[] b1 : bs) {
// StringBuilder sb = new StringBuilder();
// for (byte b : b1) {
// sb.append(String.format("%02X ", b));
// }
// sbA.append("[").append(sb.toString().trim()).append("]");
// sbL.append("[").append(b1.length).append("]");
// }
// return String.format("Bytes (sizes: %s): %s", sbL.toString(), sbA.toString());
// }
//
// }
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpReceiver.java
import static lt.emasina.esj.tcp.TcpConnection.HEADER_SIZE;
import java.io.IOException;
import java.io.InputStream;
import lt.emasina.esj.model.ParseException;
import lt.emasina.esj.model.ResponseOperation;
import lt.emasina.esj.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package lt.emasina.esj.tcp;
/**
* TcpReceiver class
* @author Stasys
*/
public class TcpReceiver implements Runnable {
private static final Logger log = LoggerFactory.getLogger(TcpReceiver.class);
private final InputStream in;
private final TcpSocketManager manager;
/**
* Constructor with mandatory data.
*
* @param in
* @param manager
*/
public TcpReceiver(InputStream in, TcpSocketManager manager) {
super();
this.in = in;
this.manager = manager;
}
@Override
public void run() {
try {
// Wait for the manager to lock itself
while (!manager.getRunning().hasQueuedThreads()) Thread.sleep(10);
while (manager.getRunning().hasQueuedThreads()) {
// Receive header | byte[] header = new byte[HEADER_SIZE]; |
valdasraps/esj | client/src/main/java/lt/emasina/esj/tcp/TcpReceiver.java | // Path: client/src/main/java/lt/emasina/esj/tcp/TcpConnection.java
// public static final int HEADER_SIZE = 4;
//
// Path: client/src/main/java/lt/emasina/esj/model/ParseException.java
// public class ParseException extends Throwable {
//
// public ParseException(String message, Object... params) {
// super(String.format(message, params));
// }
//
// public ParseException(Exception ex) {
// super(ex);
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/model/ResponseOperation.java
// public abstract class ResponseOperation {
//
// public boolean hasSingleResponse = true;
//
// public abstract void setResponsePackage(TcpPackage pckg);
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/util/Bytes.java
// public class Bytes {
//
// /**
// * Appends two bytes array into one.
// *
// * @param a A byte[].
// * @param b A byte[].
// * @return A byte[].
// */
// public static byte[] append(byte[] a, byte[] b) {
// byte[] z = new byte[a.length + b.length];
// System.arraycopy(a, 0, z, 0, a.length);
// System.arraycopy(b, 0, z, a.length, b.length);
// return z;
// }
//
// /**
// * Returns a 8-byte array built from a long.
// *
// * @param n The number to convert.
// * @return A byte[].
// */
// public static byte[] toBytes(long n) {
// return toBytes(n, new byte[8]);
// }
//
// /**
// * Build a 8-byte array from a long. No check is performed on the array
// * length.
// *
// * @param n The number to convert.
// * @param b The array to fill.
// * @return A byte[].
// */
// public static byte[] toBytes(long n, byte[] b) {
// b[7] = (byte) (n);
// n >>>= 8;
// b[6] = (byte) (n);
// n >>>= 8;
// b[5] = (byte) (n);
// n >>>= 8;
// b[4] = (byte) (n);
// n >>>= 8;
// b[3] = (byte) (n);
// n >>>= 8;
// b[2] = (byte) (n);
// n >>>= 8;
// b[1] = (byte) (n);
// n >>>= 8;
// b[0] = (byte) (n);
//
// return b;
// }
//
// public static byte[] toBytes(UUID i) {
// return Bytes.append(Bytes.toBytes(i.getMostSignificantBits()), Bytes.toBytes(i.getLeastSignificantBits()));
// }
//
// //** Formatting and validation constants
// /**
// * Chars in a UUID String.
// */
// private static final int UUID_UNFORMATTED_LENGTH = 32;
//
// /**
// * Insertion points for dashes in the string format
// */
// private static final int FORMAT_POSITIONS[] = new int[]{8, 13, 18, 23};
//
// public static UUID fromBytes(byte[] b) {
// if (b.length != 16) {
// throw new IllegalArgumentException(String.format("Expected length 16, was %d", b.length));
// }
// StringBuilder sb = new StringBuilder(new String(Hex.encodeHex(b)));
// while (sb.length() != UUID_UNFORMATTED_LENGTH) {
// sb.insert(0, "0");
// }
// for (int fp : FORMAT_POSITIONS) {
// sb.insert(fp, '-');
// }
// return UUID.fromString(sb.toString());
// }
//
// public static int toInt(byte b) {
// return (int) b & 0xFF;
// }
//
// public static String toBinaryString(byte b) {
// return String.format("%8s", Integer.toBinaryString(toInt(b))).replace(' ', '0');
// }
//
// public static String debugString(byte[]
// ... bs) {
// StringBuilder sbA = new StringBuilder();
// StringBuilder sbL = new StringBuilder();
// for (byte[] b1 : bs) {
// StringBuilder sb = new StringBuilder();
// for (byte b : b1) {
// sb.append(String.format("%02X ", b));
// }
// sbA.append("[").append(sb.toString().trim()).append("]");
// sbL.append("[").append(b1.length).append("]");
// }
// return String.format("Bytes (sizes: %s): %s", sbL.toString(), sbA.toString());
// }
//
// }
| import static lt.emasina.esj.tcp.TcpConnection.HEADER_SIZE;
import java.io.IOException;
import java.io.InputStream;
import lt.emasina.esj.model.ParseException;
import lt.emasina.esj.model.ResponseOperation;
import lt.emasina.esj.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package lt.emasina.esj.tcp;
/**
* TcpReceiver class
* @author Stasys
*/
public class TcpReceiver implements Runnable {
private static final Logger log = LoggerFactory.getLogger(TcpReceiver.class);
private final InputStream in;
private final TcpSocketManager manager;
/**
* Constructor with mandatory data.
*
* @param in
* @param manager
*/
public TcpReceiver(InputStream in, TcpSocketManager manager) {
super();
this.in = in;
this.manager = manager;
}
@Override
public void run() {
try {
// Wait for the manager to lock itself
while (!manager.getRunning().hasQueuedThreads()) Thread.sleep(10);
while (manager.getRunning().hasQueuedThreads()) {
// Receive header
byte[] header = new byte[HEADER_SIZE];
int headerLen = in.read(header, 0, HEADER_SIZE);
if (HEADER_SIZE != headerLen) {
throw new IOException(String.format("Wrong header size received: expected %d, got %d", HEADER_SIZE, headerLen));
}
| // Path: client/src/main/java/lt/emasina/esj/tcp/TcpConnection.java
// public static final int HEADER_SIZE = 4;
//
// Path: client/src/main/java/lt/emasina/esj/model/ParseException.java
// public class ParseException extends Throwable {
//
// public ParseException(String message, Object... params) {
// super(String.format(message, params));
// }
//
// public ParseException(Exception ex) {
// super(ex);
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/model/ResponseOperation.java
// public abstract class ResponseOperation {
//
// public boolean hasSingleResponse = true;
//
// public abstract void setResponsePackage(TcpPackage pckg);
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/util/Bytes.java
// public class Bytes {
//
// /**
// * Appends two bytes array into one.
// *
// * @param a A byte[].
// * @param b A byte[].
// * @return A byte[].
// */
// public static byte[] append(byte[] a, byte[] b) {
// byte[] z = new byte[a.length + b.length];
// System.arraycopy(a, 0, z, 0, a.length);
// System.arraycopy(b, 0, z, a.length, b.length);
// return z;
// }
//
// /**
// * Returns a 8-byte array built from a long.
// *
// * @param n The number to convert.
// * @return A byte[].
// */
// public static byte[] toBytes(long n) {
// return toBytes(n, new byte[8]);
// }
//
// /**
// * Build a 8-byte array from a long. No check is performed on the array
// * length.
// *
// * @param n The number to convert.
// * @param b The array to fill.
// * @return A byte[].
// */
// public static byte[] toBytes(long n, byte[] b) {
// b[7] = (byte) (n);
// n >>>= 8;
// b[6] = (byte) (n);
// n >>>= 8;
// b[5] = (byte) (n);
// n >>>= 8;
// b[4] = (byte) (n);
// n >>>= 8;
// b[3] = (byte) (n);
// n >>>= 8;
// b[2] = (byte) (n);
// n >>>= 8;
// b[1] = (byte) (n);
// n >>>= 8;
// b[0] = (byte) (n);
//
// return b;
// }
//
// public static byte[] toBytes(UUID i) {
// return Bytes.append(Bytes.toBytes(i.getMostSignificantBits()), Bytes.toBytes(i.getLeastSignificantBits()));
// }
//
// //** Formatting and validation constants
// /**
// * Chars in a UUID String.
// */
// private static final int UUID_UNFORMATTED_LENGTH = 32;
//
// /**
// * Insertion points for dashes in the string format
// */
// private static final int FORMAT_POSITIONS[] = new int[]{8, 13, 18, 23};
//
// public static UUID fromBytes(byte[] b) {
// if (b.length != 16) {
// throw new IllegalArgumentException(String.format("Expected length 16, was %d", b.length));
// }
// StringBuilder sb = new StringBuilder(new String(Hex.encodeHex(b)));
// while (sb.length() != UUID_UNFORMATTED_LENGTH) {
// sb.insert(0, "0");
// }
// for (int fp : FORMAT_POSITIONS) {
// sb.insert(fp, '-');
// }
// return UUID.fromString(sb.toString());
// }
//
// public static int toInt(byte b) {
// return (int) b & 0xFF;
// }
//
// public static String toBinaryString(byte b) {
// return String.format("%8s", Integer.toBinaryString(toInt(b))).replace(' ', '0');
// }
//
// public static String debugString(byte[]
// ... bs) {
// StringBuilder sbA = new StringBuilder();
// StringBuilder sbL = new StringBuilder();
// for (byte[] b1 : bs) {
// StringBuilder sb = new StringBuilder();
// for (byte b : b1) {
// sb.append(String.format("%02X ", b));
// }
// sbA.append("[").append(sb.toString().trim()).append("]");
// sbL.append("[").append(b1.length).append("]");
// }
// return String.format("Bytes (sizes: %s): %s", sbL.toString(), sbA.toString());
// }
//
// }
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpReceiver.java
import static lt.emasina.esj.tcp.TcpConnection.HEADER_SIZE;
import java.io.IOException;
import java.io.InputStream;
import lt.emasina.esj.model.ParseException;
import lt.emasina.esj.model.ResponseOperation;
import lt.emasina.esj.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package lt.emasina.esj.tcp;
/**
* TcpReceiver class
* @author Stasys
*/
public class TcpReceiver implements Runnable {
private static final Logger log = LoggerFactory.getLogger(TcpReceiver.class);
private final InputStream in;
private final TcpSocketManager manager;
/**
* Constructor with mandatory data.
*
* @param in
* @param manager
*/
public TcpReceiver(InputStream in, TcpSocketManager manager) {
super();
this.in = in;
this.manager = manager;
}
@Override
public void run() {
try {
// Wait for the manager to lock itself
while (!manager.getRunning().hasQueuedThreads()) Thread.sleep(10);
while (manager.getRunning().hasQueuedThreads()) {
// Receive header
byte[] header = new byte[HEADER_SIZE];
int headerLen = in.read(header, 0, HEADER_SIZE);
if (HEADER_SIZE != headerLen) {
throw new IOException(String.format("Wrong header size received: expected %d, got %d", HEADER_SIZE, headerLen));
}
| int expectLen = Bytes.toInt(header[0]) + Bytes.toInt(header[1]) + Bytes.toInt(header[2]) + Bytes.toInt(header[3]); |
valdasraps/esj | client/src/main/java/lt/emasina/esj/tcp/TcpReceiver.java | // Path: client/src/main/java/lt/emasina/esj/tcp/TcpConnection.java
// public static final int HEADER_SIZE = 4;
//
// Path: client/src/main/java/lt/emasina/esj/model/ParseException.java
// public class ParseException extends Throwable {
//
// public ParseException(String message, Object... params) {
// super(String.format(message, params));
// }
//
// public ParseException(Exception ex) {
// super(ex);
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/model/ResponseOperation.java
// public abstract class ResponseOperation {
//
// public boolean hasSingleResponse = true;
//
// public abstract void setResponsePackage(TcpPackage pckg);
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/util/Bytes.java
// public class Bytes {
//
// /**
// * Appends two bytes array into one.
// *
// * @param a A byte[].
// * @param b A byte[].
// * @return A byte[].
// */
// public static byte[] append(byte[] a, byte[] b) {
// byte[] z = new byte[a.length + b.length];
// System.arraycopy(a, 0, z, 0, a.length);
// System.arraycopy(b, 0, z, a.length, b.length);
// return z;
// }
//
// /**
// * Returns a 8-byte array built from a long.
// *
// * @param n The number to convert.
// * @return A byte[].
// */
// public static byte[] toBytes(long n) {
// return toBytes(n, new byte[8]);
// }
//
// /**
// * Build a 8-byte array from a long. No check is performed on the array
// * length.
// *
// * @param n The number to convert.
// * @param b The array to fill.
// * @return A byte[].
// */
// public static byte[] toBytes(long n, byte[] b) {
// b[7] = (byte) (n);
// n >>>= 8;
// b[6] = (byte) (n);
// n >>>= 8;
// b[5] = (byte) (n);
// n >>>= 8;
// b[4] = (byte) (n);
// n >>>= 8;
// b[3] = (byte) (n);
// n >>>= 8;
// b[2] = (byte) (n);
// n >>>= 8;
// b[1] = (byte) (n);
// n >>>= 8;
// b[0] = (byte) (n);
//
// return b;
// }
//
// public static byte[] toBytes(UUID i) {
// return Bytes.append(Bytes.toBytes(i.getMostSignificantBits()), Bytes.toBytes(i.getLeastSignificantBits()));
// }
//
// //** Formatting and validation constants
// /**
// * Chars in a UUID String.
// */
// private static final int UUID_UNFORMATTED_LENGTH = 32;
//
// /**
// * Insertion points for dashes in the string format
// */
// private static final int FORMAT_POSITIONS[] = new int[]{8, 13, 18, 23};
//
// public static UUID fromBytes(byte[] b) {
// if (b.length != 16) {
// throw new IllegalArgumentException(String.format("Expected length 16, was %d", b.length));
// }
// StringBuilder sb = new StringBuilder(new String(Hex.encodeHex(b)));
// while (sb.length() != UUID_UNFORMATTED_LENGTH) {
// sb.insert(0, "0");
// }
// for (int fp : FORMAT_POSITIONS) {
// sb.insert(fp, '-');
// }
// return UUID.fromString(sb.toString());
// }
//
// public static int toInt(byte b) {
// return (int) b & 0xFF;
// }
//
// public static String toBinaryString(byte b) {
// return String.format("%8s", Integer.toBinaryString(toInt(b))).replace(' ', '0');
// }
//
// public static String debugString(byte[]
// ... bs) {
// StringBuilder sbA = new StringBuilder();
// StringBuilder sbL = new StringBuilder();
// for (byte[] b1 : bs) {
// StringBuilder sb = new StringBuilder();
// for (byte b : b1) {
// sb.append(String.format("%02X ", b));
// }
// sbA.append("[").append(sb.toString().trim()).append("]");
// sbL.append("[").append(b1.length).append("]");
// }
// return String.format("Bytes (sizes: %s): %s", sbL.toString(), sbA.toString());
// }
//
// }
| import static lt.emasina.esj.tcp.TcpConnection.HEADER_SIZE;
import java.io.IOException;
import java.io.InputStream;
import lt.emasina.esj.model.ParseException;
import lt.emasina.esj.model.ResponseOperation;
import lt.emasina.esj.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | TcpCommand cmd = pckg.getCommand();
if (cmd.equals(TcpCommand.SubscriptionDropped)){
manager.getReceiving().remove(pckg.getCorrelationId());
}
}
}
if (log.isDebugEnabled()) {
log.debug("Remaining operations: {}", manager.getReceiving().size());
}
if (op == null) {
switch (pckg.getCommand()) {
case HeartbeatRequestCommand:
manager.respondHeartBeat(pckg.getCorrelationId());
break;
case CreateChunk:
// Silently ignore this (don't know what to do...)
break;
default:
throw new IOException(String.format("Have not found operation to return data to: %s, operation %s",
pckg.getCorrelationId(),
pckg.getCommand()));
}
} else {
op.setResponsePackage(pckg);
}
}
} catch (InterruptedException ex) {
// Ignore | // Path: client/src/main/java/lt/emasina/esj/tcp/TcpConnection.java
// public static final int HEADER_SIZE = 4;
//
// Path: client/src/main/java/lt/emasina/esj/model/ParseException.java
// public class ParseException extends Throwable {
//
// public ParseException(String message, Object... params) {
// super(String.format(message, params));
// }
//
// public ParseException(Exception ex) {
// super(ex);
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/model/ResponseOperation.java
// public abstract class ResponseOperation {
//
// public boolean hasSingleResponse = true;
//
// public abstract void setResponsePackage(TcpPackage pckg);
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/util/Bytes.java
// public class Bytes {
//
// /**
// * Appends two bytes array into one.
// *
// * @param a A byte[].
// * @param b A byte[].
// * @return A byte[].
// */
// public static byte[] append(byte[] a, byte[] b) {
// byte[] z = new byte[a.length + b.length];
// System.arraycopy(a, 0, z, 0, a.length);
// System.arraycopy(b, 0, z, a.length, b.length);
// return z;
// }
//
// /**
// * Returns a 8-byte array built from a long.
// *
// * @param n The number to convert.
// * @return A byte[].
// */
// public static byte[] toBytes(long n) {
// return toBytes(n, new byte[8]);
// }
//
// /**
// * Build a 8-byte array from a long. No check is performed on the array
// * length.
// *
// * @param n The number to convert.
// * @param b The array to fill.
// * @return A byte[].
// */
// public static byte[] toBytes(long n, byte[] b) {
// b[7] = (byte) (n);
// n >>>= 8;
// b[6] = (byte) (n);
// n >>>= 8;
// b[5] = (byte) (n);
// n >>>= 8;
// b[4] = (byte) (n);
// n >>>= 8;
// b[3] = (byte) (n);
// n >>>= 8;
// b[2] = (byte) (n);
// n >>>= 8;
// b[1] = (byte) (n);
// n >>>= 8;
// b[0] = (byte) (n);
//
// return b;
// }
//
// public static byte[] toBytes(UUID i) {
// return Bytes.append(Bytes.toBytes(i.getMostSignificantBits()), Bytes.toBytes(i.getLeastSignificantBits()));
// }
//
// //** Formatting and validation constants
// /**
// * Chars in a UUID String.
// */
// private static final int UUID_UNFORMATTED_LENGTH = 32;
//
// /**
// * Insertion points for dashes in the string format
// */
// private static final int FORMAT_POSITIONS[] = new int[]{8, 13, 18, 23};
//
// public static UUID fromBytes(byte[] b) {
// if (b.length != 16) {
// throw new IllegalArgumentException(String.format("Expected length 16, was %d", b.length));
// }
// StringBuilder sb = new StringBuilder(new String(Hex.encodeHex(b)));
// while (sb.length() != UUID_UNFORMATTED_LENGTH) {
// sb.insert(0, "0");
// }
// for (int fp : FORMAT_POSITIONS) {
// sb.insert(fp, '-');
// }
// return UUID.fromString(sb.toString());
// }
//
// public static int toInt(byte b) {
// return (int) b & 0xFF;
// }
//
// public static String toBinaryString(byte b) {
// return String.format("%8s", Integer.toBinaryString(toInt(b))).replace(' ', '0');
// }
//
// public static String debugString(byte[]
// ... bs) {
// StringBuilder sbA = new StringBuilder();
// StringBuilder sbL = new StringBuilder();
// for (byte[] b1 : bs) {
// StringBuilder sb = new StringBuilder();
// for (byte b : b1) {
// sb.append(String.format("%02X ", b));
// }
// sbA.append("[").append(sb.toString().trim()).append("]");
// sbL.append("[").append(b1.length).append("]");
// }
// return String.format("Bytes (sizes: %s): %s", sbL.toString(), sbA.toString());
// }
//
// }
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpReceiver.java
import static lt.emasina.esj.tcp.TcpConnection.HEADER_SIZE;
import java.io.IOException;
import java.io.InputStream;
import lt.emasina.esj.model.ParseException;
import lt.emasina.esj.model.ResponseOperation;
import lt.emasina.esj.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
TcpCommand cmd = pckg.getCommand();
if (cmd.equals(TcpCommand.SubscriptionDropped)){
manager.getReceiving().remove(pckg.getCorrelationId());
}
}
}
if (log.isDebugEnabled()) {
log.debug("Remaining operations: {}", manager.getReceiving().size());
}
if (op == null) {
switch (pckg.getCommand()) {
case HeartbeatRequestCommand:
manager.respondHeartBeat(pckg.getCorrelationId());
break;
case CreateChunk:
// Silently ignore this (don't know what to do...)
break;
default:
throw new IOException(String.format("Have not found operation to return data to: %s, operation %s",
pckg.getCorrelationId(),
pckg.getCommand()));
}
} else {
op.setResponsePackage(pckg);
}
}
} catch (InterruptedException ex) {
// Ignore | } catch (IOException | ParseException ex) { |
valdasraps/esj | client/src/main/java/lt/emasina/esj/tcp/TcpConnection.java | // Path: client/src/main/java/lt/emasina/esj/Settings.java
// public class Settings {
//
// private boolean requireMaster = false;
//
// /**
// * @return the requireMaster
// */
// public boolean isRequireMaster() {
// return requireMaster;
// }
//
// /**
// * @param requireMaster the requireMaster to set
// */
// public void setRequireMaster(boolean requireMaster) {
// this.requireMaster = requireMaster;
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/model/RequestOperation.java
// public abstract class RequestOperation<F extends Message> extends ResponseOperation {
//
// private final TcpConnection connection;
// protected F request;
//
// public RequestOperation(TcpConnection connection, F request) {
// this.connection = connection;
// this.request = request;
// }
//
// //private final Semaphore processing = new Semaphore(0);
//
// public TcpPackage getRequestPackage() {
// return request.getTcpPackage(connection.getSettings());
// }
//
// public UUID getCorrelationId() {
// return request.getCorrelationId();
// }
//
// public void doneProcessing() {
// //processing.release();
// }
//
// public void send() {
// sendAsync();
// /*try {
// processing.acquire();
// } catch (InterruptedException ex) {
// log.warn("Processing was interrpupted", ex);
// }*/
// }
//
// public void sendAsync() {
// connection.send(this);
// }
//
// /**
// * @return the connection
// */
// public TcpConnection getConnection() {
// return connection;
// }
//
// /**
// * @return the request
// */
// public F getRequest() {
// return request;
// }
//
// }
| import java.io.IOException;
import java.net.InetAddress;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.Semaphore;
import lt.emasina.esj.Settings;
import lt.emasina.esj.model.RequestOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package lt.emasina.esj.tcp;
public class TcpConnection implements AutoCloseable {
private static final Logger log = LoggerFactory.getLogger(TcpConnection.class);
public static final int HEADER_SIZE = 4;
| // Path: client/src/main/java/lt/emasina/esj/Settings.java
// public class Settings {
//
// private boolean requireMaster = false;
//
// /**
// * @return the requireMaster
// */
// public boolean isRequireMaster() {
// return requireMaster;
// }
//
// /**
// * @param requireMaster the requireMaster to set
// */
// public void setRequireMaster(boolean requireMaster) {
// this.requireMaster = requireMaster;
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/model/RequestOperation.java
// public abstract class RequestOperation<F extends Message> extends ResponseOperation {
//
// private final TcpConnection connection;
// protected F request;
//
// public RequestOperation(TcpConnection connection, F request) {
// this.connection = connection;
// this.request = request;
// }
//
// //private final Semaphore processing = new Semaphore(0);
//
// public TcpPackage getRequestPackage() {
// return request.getTcpPackage(connection.getSettings());
// }
//
// public UUID getCorrelationId() {
// return request.getCorrelationId();
// }
//
// public void doneProcessing() {
// //processing.release();
// }
//
// public void send() {
// sendAsync();
// /*try {
// processing.acquire();
// } catch (InterruptedException ex) {
// log.warn("Processing was interrpupted", ex);
// }*/
// }
//
// public void sendAsync() {
// connection.send(this);
// }
//
// /**
// * @return the connection
// */
// public TcpConnection getConnection() {
// return connection;
// }
//
// /**
// * @return the request
// */
// public F getRequest() {
// return request;
// }
//
// }
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpConnection.java
import java.io.IOException;
import java.net.InetAddress;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.Semaphore;
import lt.emasina.esj.Settings;
import lt.emasina.esj.model.RequestOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package lt.emasina.esj.tcp;
public class TcpConnection implements AutoCloseable {
private static final Logger log = LoggerFactory.getLogger(TcpConnection.class);
public static final int HEADER_SIZE = 4;
| private final Settings settings; |
valdasraps/esj | client/src/main/java/lt/emasina/esj/tcp/TcpConnection.java | // Path: client/src/main/java/lt/emasina/esj/Settings.java
// public class Settings {
//
// private boolean requireMaster = false;
//
// /**
// * @return the requireMaster
// */
// public boolean isRequireMaster() {
// return requireMaster;
// }
//
// /**
// * @param requireMaster the requireMaster to set
// */
// public void setRequireMaster(boolean requireMaster) {
// this.requireMaster = requireMaster;
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/model/RequestOperation.java
// public abstract class RequestOperation<F extends Message> extends ResponseOperation {
//
// private final TcpConnection connection;
// protected F request;
//
// public RequestOperation(TcpConnection connection, F request) {
// this.connection = connection;
// this.request = request;
// }
//
// //private final Semaphore processing = new Semaphore(0);
//
// public TcpPackage getRequestPackage() {
// return request.getTcpPackage(connection.getSettings());
// }
//
// public UUID getCorrelationId() {
// return request.getCorrelationId();
// }
//
// public void doneProcessing() {
// //processing.release();
// }
//
// public void send() {
// sendAsync();
// /*try {
// processing.acquire();
// } catch (InterruptedException ex) {
// log.warn("Processing was interrpupted", ex);
// }*/
// }
//
// public void sendAsync() {
// connection.send(this);
// }
//
// /**
// * @return the connection
// */
// public TcpConnection getConnection() {
// return connection;
// }
//
// /**
// * @return the request
// */
// public F getRequest() {
// return request;
// }
//
// }
| import java.io.IOException;
import java.net.InetAddress;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.Semaphore;
import lt.emasina.esj.Settings;
import lt.emasina.esj.model.RequestOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package lt.emasina.esj.tcp;
public class TcpConnection implements AutoCloseable {
private static final Logger log = LoggerFactory.getLogger(TcpConnection.class);
public static final int HEADER_SIZE = 4;
private final Settings settings;
private final TcpSocketManager manager;
private final Future<?> managerTask;
/**
* Establish the connection to EventStore TCP socket
* and launch writer/reader threads.
*
* @param host server hostname
* @param port server TCP port
* @param settings additional connection settings
* @param executor executor service
* @throws IOException
*/
public TcpConnection(InetAddress host, int port, Settings settings, ExecutorService executor) throws IOException {
this.settings = settings;
this.manager = new TcpSocketManager(this, host, port, executor);
this.managerTask = executor.submit(manager);
}
| // Path: client/src/main/java/lt/emasina/esj/Settings.java
// public class Settings {
//
// private boolean requireMaster = false;
//
// /**
// * @return the requireMaster
// */
// public boolean isRequireMaster() {
// return requireMaster;
// }
//
// /**
// * @param requireMaster the requireMaster to set
// */
// public void setRequireMaster(boolean requireMaster) {
// this.requireMaster = requireMaster;
// }
//
// }
//
// Path: client/src/main/java/lt/emasina/esj/model/RequestOperation.java
// public abstract class RequestOperation<F extends Message> extends ResponseOperation {
//
// private final TcpConnection connection;
// protected F request;
//
// public RequestOperation(TcpConnection connection, F request) {
// this.connection = connection;
// this.request = request;
// }
//
// //private final Semaphore processing = new Semaphore(0);
//
// public TcpPackage getRequestPackage() {
// return request.getTcpPackage(connection.getSettings());
// }
//
// public UUID getCorrelationId() {
// return request.getCorrelationId();
// }
//
// public void doneProcessing() {
// //processing.release();
// }
//
// public void send() {
// sendAsync();
// /*try {
// processing.acquire();
// } catch (InterruptedException ex) {
// log.warn("Processing was interrpupted", ex);
// }*/
// }
//
// public void sendAsync() {
// connection.send(this);
// }
//
// /**
// * @return the connection
// */
// public TcpConnection getConnection() {
// return connection;
// }
//
// /**
// * @return the request
// */
// public F getRequest() {
// return request;
// }
//
// }
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpConnection.java
import java.io.IOException;
import java.net.InetAddress;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.Semaphore;
import lt.emasina.esj.Settings;
import lt.emasina.esj.model.RequestOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package lt.emasina.esj.tcp;
public class TcpConnection implements AutoCloseable {
private static final Logger log = LoggerFactory.getLogger(TcpConnection.class);
public static final int HEADER_SIZE = 4;
private final Settings settings;
private final TcpSocketManager manager;
private final Future<?> managerTask;
/**
* Establish the connection to EventStore TCP socket
* and launch writer/reader threads.
*
* @param host server hostname
* @param port server TCP port
* @param settings additional connection settings
* @param executor executor service
* @throws IOException
*/
public TcpConnection(InetAddress host, int port, Settings settings, ExecutorService executor) throws IOException {
this.settings = settings;
this.manager = new TcpSocketManager(this, host, port, executor);
this.managerTask = executor.submit(manager);
}
| public void send(RequestOperation op) { |
valdasraps/esj | client/src/main/java/lt/emasina/esj/model/ResponseOperation.java | // Path: client/src/main/java/lt/emasina/esj/tcp/TcpPackage.java
// public class TcpPackage {
//
// private static final Charset UTF8_CHARSET = Charset.forName("UTF-8");
// private static final int COMMAND_OFFSET = 0;
// private static final int FLAGS_OFFSET = COMMAND_OFFSET + 1;
// private static final int CORRELATION_OFFSET = FLAGS_OFFSET + 1;
// private static final int AUTH_OFFSET = CORRELATION_OFFSET + 16;
// private static final int MANDATORY_SIZE = AUTH_OFFSET;
//
// private static final int UUID_SIZE = 16;
//
// private final TcpCommand command;
// private final TcpFlag flag;
// private final UUID correlationId;
// private final UserCredentials user;
// private final byte[] data;
//
// /**
// * Constructor with mandatory data.
// *
// * @param command
// * @param flag
// * @param correlationId
// * @param user
// * @param data
// */
// public TcpPackage(TcpCommand command, TcpFlag flag, UUID correlationId,
// UserCredentials user, byte[] data) {
// super();
// this.command = command;
// this.flag = flag;
// this.correlationId = correlationId;
// this.user = user;
// this.data = data;
// }
//
// public byte[] AsByteArray() {
// if (flag.equals(TcpFlag.Authenticated) && user != null) {
// int loginLen = user.getLogin().getBytes(UTF8_CHARSET).length;
// int passLen = user.getPassword().getBytes(UTF8_CHARSET).length;
// if (loginLen > 255) throw new IllegalArgumentException(String.format("Login serialized length should be less than 256 bytes (but is {0}).", loginLen));
// if (passLen > 255) throw new IllegalArgumentException(String.format("Password serialized length should be less than 256 bytes (but is {0}).", passLen));
//
// byte[] res = new byte[MANDATORY_SIZE + 2 + loginLen + passLen + data.length];
// res[COMMAND_OFFSET] = command.getMask();
// res[FLAGS_OFFSET] = flag.getMask();
// System.arraycopy(Bytes.toBytes(correlationId), 0, res, CORRELATION_OFFSET, UUID_SIZE);
//
// res[AUTH_OFFSET] = (byte) loginLen;
// System.arraycopy(user.getLogin().getBytes(UTF8_CHARSET), 0, res, AUTH_OFFSET + 1, loginLen);
// res[AUTH_OFFSET + 1 + loginLen] = (byte) passLen;
// System.arraycopy(user.getPassword().getBytes(UTF8_CHARSET), 0, res, AUTH_OFFSET + 1 + loginLen + 1, passLen);
//
// System.arraycopy(data, 0, res, res.length - data.length, data.length);
// return res;
// } else {
// byte[] res = new byte[MANDATORY_SIZE + data.length];
// res[COMMAND_OFFSET] = command.getMask();
// res[FLAGS_OFFSET] = flag.getMask();
// System.arraycopy(Bytes.toBytes(correlationId), 0, res, CORRELATION_OFFSET, UUID_SIZE);
// System.arraycopy(data, 0, res, res.length - data.length, data.length);
// return res;
// }
// }
//
// public static TcpPackage fromBytes(byte[] data) throws ParseException {
// if (data.length < MANDATORY_SIZE) {
// throw new ParseException("ArraySegment too short, length: {0}", data.length);
// }
//
// TcpCommand command = TcpCommand.valueOf(data[COMMAND_OFFSET]);
// TcpFlag flag = TcpFlag.valueOf(data[FLAGS_OFFSET]);
//
// byte[] uuidBytes = new byte[UUID_SIZE];
// System.arraycopy(data, CORRELATION_OFFSET, uuidBytes, 0, UUID_SIZE);
// UUID correlationId = Bytes.fromBytes(uuidBytes);
//
// UserCredentials user = null;
//
// int headerSize = MANDATORY_SIZE;
// if (flag.equals(TcpFlag.Authenticated)) {
//
// int loginLen = (int) data[AUTH_OFFSET];
// if (AUTH_OFFSET + 1 + loginLen + 1 >= data.length) {
// throw new ParseException("Login length is too big, it doesn't fit into TcpPackage.");
// }
// String login = new String(data, AUTH_OFFSET + 1, loginLen);
// int passLen = (int) data[AUTH_OFFSET + 1 + loginLen];
// if (AUTH_OFFSET + 1 + loginLen + 1 + passLen > data.length) {
// throw new ParseException("Password length is too big, it doesn't fit into TcpPackage.");
// }
// String pass = new String(data, AUTH_OFFSET + 1 + loginLen + 1, passLen);
// headerSize += 1 + loginLen + 1 + passLen;
//
// user = new UserCredentials(login, pass);
//
// }
//
// byte [] dtoBytes = new byte[data.length - headerSize];
// System.arraycopy(data, headerSize, dtoBytes, 0, data.length - headerSize);
// return new TcpPackage(command, flag, correlationId, user, dtoBytes);
// }
//
// /**
// * @return the command
// */
// public TcpCommand getCommand() {
// return command;
// }
//
// /**
// * @return the flag
// */
// public TcpFlag getFlag() {
// return flag;
// }
//
// /**
// * @return the correlationId
// */
// public UUID getCorrelationId() {
// return correlationId;
// }
//
// /**
// * @return the user
// */
// public UserCredentials getUser() {
// return user;
// }
//
// /**
// * @return the data
// */
// public byte[] getData() {
// return data;
// }
//
// }
| import lt.emasina.esj.tcp.TcpPackage; | package lt.emasina.esj.model;
/**
* Interface ResponseOperation
*
* @author Stasys
*/
public abstract class ResponseOperation {
public boolean hasSingleResponse = true;
| // Path: client/src/main/java/lt/emasina/esj/tcp/TcpPackage.java
// public class TcpPackage {
//
// private static final Charset UTF8_CHARSET = Charset.forName("UTF-8");
// private static final int COMMAND_OFFSET = 0;
// private static final int FLAGS_OFFSET = COMMAND_OFFSET + 1;
// private static final int CORRELATION_OFFSET = FLAGS_OFFSET + 1;
// private static final int AUTH_OFFSET = CORRELATION_OFFSET + 16;
// private static final int MANDATORY_SIZE = AUTH_OFFSET;
//
// private static final int UUID_SIZE = 16;
//
// private final TcpCommand command;
// private final TcpFlag flag;
// private final UUID correlationId;
// private final UserCredentials user;
// private final byte[] data;
//
// /**
// * Constructor with mandatory data.
// *
// * @param command
// * @param flag
// * @param correlationId
// * @param user
// * @param data
// */
// public TcpPackage(TcpCommand command, TcpFlag flag, UUID correlationId,
// UserCredentials user, byte[] data) {
// super();
// this.command = command;
// this.flag = flag;
// this.correlationId = correlationId;
// this.user = user;
// this.data = data;
// }
//
// public byte[] AsByteArray() {
// if (flag.equals(TcpFlag.Authenticated) && user != null) {
// int loginLen = user.getLogin().getBytes(UTF8_CHARSET).length;
// int passLen = user.getPassword().getBytes(UTF8_CHARSET).length;
// if (loginLen > 255) throw new IllegalArgumentException(String.format("Login serialized length should be less than 256 bytes (but is {0}).", loginLen));
// if (passLen > 255) throw new IllegalArgumentException(String.format("Password serialized length should be less than 256 bytes (but is {0}).", passLen));
//
// byte[] res = new byte[MANDATORY_SIZE + 2 + loginLen + passLen + data.length];
// res[COMMAND_OFFSET] = command.getMask();
// res[FLAGS_OFFSET] = flag.getMask();
// System.arraycopy(Bytes.toBytes(correlationId), 0, res, CORRELATION_OFFSET, UUID_SIZE);
//
// res[AUTH_OFFSET] = (byte) loginLen;
// System.arraycopy(user.getLogin().getBytes(UTF8_CHARSET), 0, res, AUTH_OFFSET + 1, loginLen);
// res[AUTH_OFFSET + 1 + loginLen] = (byte) passLen;
// System.arraycopy(user.getPassword().getBytes(UTF8_CHARSET), 0, res, AUTH_OFFSET + 1 + loginLen + 1, passLen);
//
// System.arraycopy(data, 0, res, res.length - data.length, data.length);
// return res;
// } else {
// byte[] res = new byte[MANDATORY_SIZE + data.length];
// res[COMMAND_OFFSET] = command.getMask();
// res[FLAGS_OFFSET] = flag.getMask();
// System.arraycopy(Bytes.toBytes(correlationId), 0, res, CORRELATION_OFFSET, UUID_SIZE);
// System.arraycopy(data, 0, res, res.length - data.length, data.length);
// return res;
// }
// }
//
// public static TcpPackage fromBytes(byte[] data) throws ParseException {
// if (data.length < MANDATORY_SIZE) {
// throw new ParseException("ArraySegment too short, length: {0}", data.length);
// }
//
// TcpCommand command = TcpCommand.valueOf(data[COMMAND_OFFSET]);
// TcpFlag flag = TcpFlag.valueOf(data[FLAGS_OFFSET]);
//
// byte[] uuidBytes = new byte[UUID_SIZE];
// System.arraycopy(data, CORRELATION_OFFSET, uuidBytes, 0, UUID_SIZE);
// UUID correlationId = Bytes.fromBytes(uuidBytes);
//
// UserCredentials user = null;
//
// int headerSize = MANDATORY_SIZE;
// if (flag.equals(TcpFlag.Authenticated)) {
//
// int loginLen = (int) data[AUTH_OFFSET];
// if (AUTH_OFFSET + 1 + loginLen + 1 >= data.length) {
// throw new ParseException("Login length is too big, it doesn't fit into TcpPackage.");
// }
// String login = new String(data, AUTH_OFFSET + 1, loginLen);
// int passLen = (int) data[AUTH_OFFSET + 1 + loginLen];
// if (AUTH_OFFSET + 1 + loginLen + 1 + passLen > data.length) {
// throw new ParseException("Password length is too big, it doesn't fit into TcpPackage.");
// }
// String pass = new String(data, AUTH_OFFSET + 1 + loginLen + 1, passLen);
// headerSize += 1 + loginLen + 1 + passLen;
//
// user = new UserCredentials(login, pass);
//
// }
//
// byte [] dtoBytes = new byte[data.length - headerSize];
// System.arraycopy(data, headerSize, dtoBytes, 0, data.length - headerSize);
// return new TcpPackage(command, flag, correlationId, user, dtoBytes);
// }
//
// /**
// * @return the command
// */
// public TcpCommand getCommand() {
// return command;
// }
//
// /**
// * @return the flag
// */
// public TcpFlag getFlag() {
// return flag;
// }
//
// /**
// * @return the correlationId
// */
// public UUID getCorrelationId() {
// return correlationId;
// }
//
// /**
// * @return the user
// */
// public UserCredentials getUser() {
// return user;
// }
//
// /**
// * @return the data
// */
// public byte[] getData() {
// return data;
// }
//
// }
// Path: client/src/main/java/lt/emasina/esj/model/ResponseOperation.java
import lt.emasina.esj.tcp.TcpPackage;
package lt.emasina.esj.model;
/**
* Interface ResponseOperation
*
* @author Stasys
*/
public abstract class ResponseOperation {
public boolean hasSingleResponse = true;
| public abstract void setResponsePackage(TcpPackage pckg); |
valdasraps/esj | client/src/main/java/lt/emasina/esj/tcp/TcpFlag.java | // Path: client/src/main/java/lt/emasina/esj/util/Bytes.java
// public class Bytes {
//
// /**
// * Appends two bytes array into one.
// *
// * @param a A byte[].
// * @param b A byte[].
// * @return A byte[].
// */
// public static byte[] append(byte[] a, byte[] b) {
// byte[] z = new byte[a.length + b.length];
// System.arraycopy(a, 0, z, 0, a.length);
// System.arraycopy(b, 0, z, a.length, b.length);
// return z;
// }
//
// /**
// * Returns a 8-byte array built from a long.
// *
// * @param n The number to convert.
// * @return A byte[].
// */
// public static byte[] toBytes(long n) {
// return toBytes(n, new byte[8]);
// }
//
// /**
// * Build a 8-byte array from a long. No check is performed on the array
// * length.
// *
// * @param n The number to convert.
// * @param b The array to fill.
// * @return A byte[].
// */
// public static byte[] toBytes(long n, byte[] b) {
// b[7] = (byte) (n);
// n >>>= 8;
// b[6] = (byte) (n);
// n >>>= 8;
// b[5] = (byte) (n);
// n >>>= 8;
// b[4] = (byte) (n);
// n >>>= 8;
// b[3] = (byte) (n);
// n >>>= 8;
// b[2] = (byte) (n);
// n >>>= 8;
// b[1] = (byte) (n);
// n >>>= 8;
// b[0] = (byte) (n);
//
// return b;
// }
//
// public static byte[] toBytes(UUID i) {
// return Bytes.append(Bytes.toBytes(i.getMostSignificantBits()), Bytes.toBytes(i.getLeastSignificantBits()));
// }
//
// //** Formatting and validation constants
// /**
// * Chars in a UUID String.
// */
// private static final int UUID_UNFORMATTED_LENGTH = 32;
//
// /**
// * Insertion points for dashes in the string format
// */
// private static final int FORMAT_POSITIONS[] = new int[]{8, 13, 18, 23};
//
// public static UUID fromBytes(byte[] b) {
// if (b.length != 16) {
// throw new IllegalArgumentException(String.format("Expected length 16, was %d", b.length));
// }
// StringBuilder sb = new StringBuilder(new String(Hex.encodeHex(b)));
// while (sb.length() != UUID_UNFORMATTED_LENGTH) {
// sb.insert(0, "0");
// }
// for (int fp : FORMAT_POSITIONS) {
// sb.insert(fp, '-');
// }
// return UUID.fromString(sb.toString());
// }
//
// public static int toInt(byte b) {
// return (int) b & 0xFF;
// }
//
// public static String toBinaryString(byte b) {
// return String.format("%8s", Integer.toBinaryString(toInt(b))).replace(' ', '0');
// }
//
// public static String debugString(byte[]
// ... bs) {
// StringBuilder sbA = new StringBuilder();
// StringBuilder sbL = new StringBuilder();
// for (byte[] b1 : bs) {
// StringBuilder sb = new StringBuilder();
// for (byte b : b1) {
// sb.append(String.format("%02X ", b));
// }
// sbA.append("[").append(sb.toString().trim()).append("]");
// sbL.append("[").append(b1.length).append("]");
// }
// return String.format("Bytes (sizes: %s): %s", sbL.toString(), sbA.toString());
// }
//
// }
| import lt.emasina.esj.util.Bytes; | package lt.emasina.esj.tcp;
/**
* TcpFlag
* @author Stasys
*/
public enum TcpFlag {
None(0x00),
Authenticated(0x01);
private final byte mask;
private TcpFlag(int mask) {
this.mask = (byte) mask;
}
public static TcpFlag valueOf(byte mask) {
for (TcpFlag f: TcpFlag.values()) {
if (f.getMask() == mask) {
return f;
}
} | // Path: client/src/main/java/lt/emasina/esj/util/Bytes.java
// public class Bytes {
//
// /**
// * Appends two bytes array into one.
// *
// * @param a A byte[].
// * @param b A byte[].
// * @return A byte[].
// */
// public static byte[] append(byte[] a, byte[] b) {
// byte[] z = new byte[a.length + b.length];
// System.arraycopy(a, 0, z, 0, a.length);
// System.arraycopy(b, 0, z, a.length, b.length);
// return z;
// }
//
// /**
// * Returns a 8-byte array built from a long.
// *
// * @param n The number to convert.
// * @return A byte[].
// */
// public static byte[] toBytes(long n) {
// return toBytes(n, new byte[8]);
// }
//
// /**
// * Build a 8-byte array from a long. No check is performed on the array
// * length.
// *
// * @param n The number to convert.
// * @param b The array to fill.
// * @return A byte[].
// */
// public static byte[] toBytes(long n, byte[] b) {
// b[7] = (byte) (n);
// n >>>= 8;
// b[6] = (byte) (n);
// n >>>= 8;
// b[5] = (byte) (n);
// n >>>= 8;
// b[4] = (byte) (n);
// n >>>= 8;
// b[3] = (byte) (n);
// n >>>= 8;
// b[2] = (byte) (n);
// n >>>= 8;
// b[1] = (byte) (n);
// n >>>= 8;
// b[0] = (byte) (n);
//
// return b;
// }
//
// public static byte[] toBytes(UUID i) {
// return Bytes.append(Bytes.toBytes(i.getMostSignificantBits()), Bytes.toBytes(i.getLeastSignificantBits()));
// }
//
// //** Formatting and validation constants
// /**
// * Chars in a UUID String.
// */
// private static final int UUID_UNFORMATTED_LENGTH = 32;
//
// /**
// * Insertion points for dashes in the string format
// */
// private static final int FORMAT_POSITIONS[] = new int[]{8, 13, 18, 23};
//
// public static UUID fromBytes(byte[] b) {
// if (b.length != 16) {
// throw new IllegalArgumentException(String.format("Expected length 16, was %d", b.length));
// }
// StringBuilder sb = new StringBuilder(new String(Hex.encodeHex(b)));
// while (sb.length() != UUID_UNFORMATTED_LENGTH) {
// sb.insert(0, "0");
// }
// for (int fp : FORMAT_POSITIONS) {
// sb.insert(fp, '-');
// }
// return UUID.fromString(sb.toString());
// }
//
// public static int toInt(byte b) {
// return (int) b & 0xFF;
// }
//
// public static String toBinaryString(byte b) {
// return String.format("%8s", Integer.toBinaryString(toInt(b))).replace(' ', '0');
// }
//
// public static String debugString(byte[]
// ... bs) {
// StringBuilder sbA = new StringBuilder();
// StringBuilder sbL = new StringBuilder();
// for (byte[] b1 : bs) {
// StringBuilder sb = new StringBuilder();
// for (byte b : b1) {
// sb.append(String.format("%02X ", b));
// }
// sbA.append("[").append(sb.toString().trim()).append("]");
// sbL.append("[").append(b1.length).append("]");
// }
// return String.format("Bytes (sizes: %s): %s", sbL.toString(), sbA.toString());
// }
//
// }
// Path: client/src/main/java/lt/emasina/esj/tcp/TcpFlag.java
import lt.emasina.esj.util.Bytes;
package lt.emasina.esj.tcp;
/**
* TcpFlag
* @author Stasys
*/
public enum TcpFlag {
None(0x00),
Authenticated(0x01);
private final byte mask;
private TcpFlag(int mask) {
this.mask = (byte) mask;
}
public static TcpFlag valueOf(byte mask) {
for (TcpFlag f: TcpFlag.values()) {
if (f.getMask() == mask) {
return f;
}
} | throw new IllegalArgumentException(String.format("Unknown mask: %d (%s)", Bytes.toInt(mask), Bytes.toBinaryString(mask))); |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/injection/module/ApplicationModule.java | // Path: app/src/main/java/com/yunq/gankio/util/HttpUtils.java
// public class HttpUtils {
// /**
// * 生成离线缓存
// */
// public static Interceptor getCacheInterceptor(final Context context) {
// return new Interceptor() {
// @Override
// public Response intercept(Interceptor.Chain chain) throws IOException {
// Request request = chain.request();
//
// // String tag = request.url().queryParameter("TAG");
// //
// // HttpUrl.Builder urlBuilder = request.url().newBuilder()
// // .removeAllQueryParameters("TAG");
// //
// // request = request.newBuilder()
// // .url(urlBuilder.build())
// // .tag(tag)
// // .build();
//
// if (!NetworkUtil.isNetworkConnected(context)) {
// request = request.newBuilder()
// .cacheControl(CacheControl.FORCE_CACHE)
// .build();
// }
// // Log.e("response", request.httpUrl().toString());
// Response response = chain.proceed(request);
// if (NetworkUtil.isNetworkConnected(context)) {
// // Log.e("response", "connected");
// int maxAge = 60 * 60;
// response.newBuilder()
// .removeHeader("Pragma")
// .header("Cache-Control", "public, max-age=" + maxAge)
// .build();
// } else {
// // Log.e("response", "not connected");
// int maxStale = 60 * 60 * 24 * 28;
// response.newBuilder()
// .removeHeader("Pragma")
// .header("Cache-Control", "public, only-if-cached, max-stale=" + maxStale)
// .build();
// }
// // Log.e("response", "response");
// return response;
//
//
// }
// };
// }
// }
| import android.app.Application;
import com.yunq.gankio.util.HttpUtils;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import okhttp3.Cache;
import okhttp3.OkHttpClient; | package com.yunq.gankio.injection.module;
/**
* Created by admin on 16/1/25.
*/
@Module
public class ApplicationModule {
protected final Application mApplication;
public ApplicationModule(Application application) {
mApplication = application;
}
@Provides
Application provideApplication() {
return mApplication;
}
// @Provides
// // @ApplicationContext
// Context provideContext() {
// return mApplication;
// }
@Provides
@Singleton
OkHttpClient provideOkHttpClient() {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.cache(new Cache(mApplication.getCacheDir(), 10 * 1024 * 1024)); | // Path: app/src/main/java/com/yunq/gankio/util/HttpUtils.java
// public class HttpUtils {
// /**
// * 生成离线缓存
// */
// public static Interceptor getCacheInterceptor(final Context context) {
// return new Interceptor() {
// @Override
// public Response intercept(Interceptor.Chain chain) throws IOException {
// Request request = chain.request();
//
// // String tag = request.url().queryParameter("TAG");
// //
// // HttpUrl.Builder urlBuilder = request.url().newBuilder()
// // .removeAllQueryParameters("TAG");
// //
// // request = request.newBuilder()
// // .url(urlBuilder.build())
// // .tag(tag)
// // .build();
//
// if (!NetworkUtil.isNetworkConnected(context)) {
// request = request.newBuilder()
// .cacheControl(CacheControl.FORCE_CACHE)
// .build();
// }
// // Log.e("response", request.httpUrl().toString());
// Response response = chain.proceed(request);
// if (NetworkUtil.isNetworkConnected(context)) {
// // Log.e("response", "connected");
// int maxAge = 60 * 60;
// response.newBuilder()
// .removeHeader("Pragma")
// .header("Cache-Control", "public, max-age=" + maxAge)
// .build();
// } else {
// // Log.e("response", "not connected");
// int maxStale = 60 * 60 * 24 * 28;
// response.newBuilder()
// .removeHeader("Pragma")
// .header("Cache-Control", "public, only-if-cached, max-stale=" + maxStale)
// .build();
// }
// // Log.e("response", "response");
// return response;
//
//
// }
// };
// }
// }
// Path: app/src/main/java/com/yunq/gankio/injection/module/ApplicationModule.java
import android.app.Application;
import com.yunq.gankio.util.HttpUtils;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import okhttp3.Cache;
import okhttp3.OkHttpClient;
package com.yunq.gankio.injection.module;
/**
* Created by admin on 16/1/25.
*/
@Module
public class ApplicationModule {
protected final Application mApplication;
public ApplicationModule(Application application) {
mApplication = application;
}
@Provides
Application provideApplication() {
return mApplication;
}
// @Provides
// // @ApplicationContext
// Context provideContext() {
// return mApplication;
// }
@Provides
@Singleton
OkHttpClient provideOkHttpClient() {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.cache(new Cache(mApplication.getCacheDir(), 10 * 1024 * 1024)); | builder.addInterceptor(HttpUtils.getCacheInterceptor(mApplication)); |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/ui/BaseActivity.java | // Path: app/src/main/java/com/yunq/gankio/GankApp.java
// public class GankApp extends Application {
//
// private RefWatcher refWatcher;
//
// ApplicationComponent mApplicationComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
// refWatcher = LeakCanary.install(this);
//
// if (BuildConfig.DEBUG) {
// //警告在主线程中执行耗时操作
// StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
// StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
//
// Timber.plant(new Timber.DebugTree());
// }
//
// }
//
// public static GankApp get(Context context) {
// return (GankApp) context.getApplicationContext();
// }
//
// public static RefWatcher getRefWatcher(Context context) {
// return ((GankApp) context.getApplicationContext()).refWatcher;
// }
//
// public ApplicationComponent getComponent() {
// if (mApplicationComponent == null) {
// mApplicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
// return mApplicationComponent;
// }
//
//
// }
| import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import com.yunq.gankio.GankApp;
import com.yunq.gankio.R;
import butterknife.Bind;
import butterknife.ButterKnife; | initInjection();
initToolBar();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(getMenuRes(), menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
break;
}
return super.onOptionsItemSelected(item);
}
public void setTitle(String tilte, boolean showHome) {
setTitle(tilte);
getSupportActionBar().setDisplayHomeAsUpEnabled(showHome);
getSupportActionBar().setDisplayShowHomeEnabled(showHome);
}
@Override
protected void onDestroy() {
super.onDestroy();
ButterKnife.unbind(this); | // Path: app/src/main/java/com/yunq/gankio/GankApp.java
// public class GankApp extends Application {
//
// private RefWatcher refWatcher;
//
// ApplicationComponent mApplicationComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
// refWatcher = LeakCanary.install(this);
//
// if (BuildConfig.DEBUG) {
// //警告在主线程中执行耗时操作
// StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
// StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
//
// Timber.plant(new Timber.DebugTree());
// }
//
// }
//
// public static GankApp get(Context context) {
// return (GankApp) context.getApplicationContext();
// }
//
// public static RefWatcher getRefWatcher(Context context) {
// return ((GankApp) context.getApplicationContext()).refWatcher;
// }
//
// public ApplicationComponent getComponent() {
// if (mApplicationComponent == null) {
// mApplicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
// return mApplicationComponent;
// }
//
//
// }
// Path: app/src/main/java/com/yunq/gankio/ui/BaseActivity.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import com.yunq.gankio.GankApp;
import com.yunq.gankio.R;
import butterknife.Bind;
import butterknife.ButterKnife;
initInjection();
initToolBar();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(getMenuRes(), menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
break;
}
return super.onOptionsItemSelected(item);
}
public void setTitle(String tilte, boolean showHome) {
setTitle(tilte);
getSupportActionBar().setDisplayHomeAsUpEnabled(showHome);
getSupportActionBar().setDisplayShowHomeEnabled(showHome);
}
@Override
protected void onDestroy() {
super.onDestroy();
ButterKnife.unbind(this); | GankApp.getRefWatcher(this).watch(this); |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/injection/component/ApplicationComponent.java | // Path: app/src/main/java/com/yunq/gankio/data/DataManager.java
// @Singleton
// public class DataManager {
// private final OkHttpClient mClient;
//
// private final MeiziService mMeiziService;
//
// @Inject
// public DataManager(OkHttpClient client) {
// mClient = client;
// mMeiziService = MeiziService.Creator.newGudongService(client);
// }
//
//
// public void cancelRequest() {
// mClient.dispatcher().cancelAll();
// }
//
// /**
// * MainActivity中获取所有Girls
// */
// public Observable<List<Girl>> getGirls(int pageSize, int currentPage) {
// return Observable.zip(mMeiziService.getPrettyGirlData(pageSize, currentPage),
// mMeiziService.get休息视频Data(pageSize, currentPage),
// new Func2<PrettyGirlData, 休息视频Data, PrettyGirlData>() {
// @Override
// public PrettyGirlData call(PrettyGirlData prettyGirlData, 休息视频Data 休息视频Data) {
// return DataUtils.createGirlInfoWith休息视频(prettyGirlData, 休息视频Data);
// }
// })
// .map(new Func1<PrettyGirlData, List<Girl>>() {
// @Override
// public List<Girl> call(PrettyGirlData girlData) {
// return girlData.results;
// }
// })
// .flatMap(new Func1<List<Girl>, Observable<Girl>>() {
// @Override
// public Observable<Girl> call(List<Girl> girls) {
// return Observable.from(girls);
// }
// })
// .toSortedList(new Func2<Girl, Girl, Integer>() {
// @Override
// public Integer call(Girl girl, Girl girl2) {
// return girl2.publishedAt.compareTo(girl.publishedAt);
// }
// });
// }
//
// /**
// * GankDetailActivity
// */
// public Observable<List<Gank>> getGankData(Date date) {
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(date);
// int year = calendar.get(Calendar.YEAR);
// int month = calendar.get(Calendar.MONTH) + 1;
// int day = calendar.get(Calendar.DAY_OF_MONTH);
//
// return mMeiziService.getGankData(year, month, day)
// .map(new Func1<GankData, GankData.Result>() {
// @Override
// public GankData.Result call(GankData gankData) {
// return gankData.results;
// }
// })
// .map(new Func1<GankData.Result, List<Gank>>() {
// @Override
// public List<Gank> call(GankData.Result result) {
// return DataUtils.addAllResults(result);
// }
// });
// }
//
// }
//
// Path: app/src/main/java/com/yunq/gankio/injection/module/ApplicationModule.java
// @Module
// public class ApplicationModule {
// protected final Application mApplication;
//
// public ApplicationModule(Application application) {
// mApplication = application;
// }
//
// @Provides
// Application provideApplication() {
// return mApplication;
// }
//
// // @Provides
// // // @ApplicationContext
// // Context provideContext() {
// // return mApplication;
// // }
//
// @Provides
// @Singleton
// OkHttpClient provideOkHttpClient() {
// OkHttpClient.Builder builder = new OkHttpClient.Builder();
// builder.cache(new Cache(mApplication.getCacheDir(), 10 * 1024 * 1024));
// builder.addInterceptor(HttpUtils.getCacheInterceptor(mApplication));
// return builder.build();
// }
//
//
// }
| import android.app.Application;
import com.yunq.gankio.data.DataManager;
import com.yunq.gankio.injection.module.ApplicationModule;
import javax.inject.Singleton;
import dagger.Component;
import okhttp3.OkHttpClient; | package com.yunq.gankio.injection.component;
/**
* Created by admin on 16/1/25.
*/
@Singleton
@Component(modules = ApplicationModule.class)
public interface ApplicationComponent {
//@ApplicationContext
// Context context();
Application application();
OkHttpClient okHttpClient();
| // Path: app/src/main/java/com/yunq/gankio/data/DataManager.java
// @Singleton
// public class DataManager {
// private final OkHttpClient mClient;
//
// private final MeiziService mMeiziService;
//
// @Inject
// public DataManager(OkHttpClient client) {
// mClient = client;
// mMeiziService = MeiziService.Creator.newGudongService(client);
// }
//
//
// public void cancelRequest() {
// mClient.dispatcher().cancelAll();
// }
//
// /**
// * MainActivity中获取所有Girls
// */
// public Observable<List<Girl>> getGirls(int pageSize, int currentPage) {
// return Observable.zip(mMeiziService.getPrettyGirlData(pageSize, currentPage),
// mMeiziService.get休息视频Data(pageSize, currentPage),
// new Func2<PrettyGirlData, 休息视频Data, PrettyGirlData>() {
// @Override
// public PrettyGirlData call(PrettyGirlData prettyGirlData, 休息视频Data 休息视频Data) {
// return DataUtils.createGirlInfoWith休息视频(prettyGirlData, 休息视频Data);
// }
// })
// .map(new Func1<PrettyGirlData, List<Girl>>() {
// @Override
// public List<Girl> call(PrettyGirlData girlData) {
// return girlData.results;
// }
// })
// .flatMap(new Func1<List<Girl>, Observable<Girl>>() {
// @Override
// public Observable<Girl> call(List<Girl> girls) {
// return Observable.from(girls);
// }
// })
// .toSortedList(new Func2<Girl, Girl, Integer>() {
// @Override
// public Integer call(Girl girl, Girl girl2) {
// return girl2.publishedAt.compareTo(girl.publishedAt);
// }
// });
// }
//
// /**
// * GankDetailActivity
// */
// public Observable<List<Gank>> getGankData(Date date) {
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(date);
// int year = calendar.get(Calendar.YEAR);
// int month = calendar.get(Calendar.MONTH) + 1;
// int day = calendar.get(Calendar.DAY_OF_MONTH);
//
// return mMeiziService.getGankData(year, month, day)
// .map(new Func1<GankData, GankData.Result>() {
// @Override
// public GankData.Result call(GankData gankData) {
// return gankData.results;
// }
// })
// .map(new Func1<GankData.Result, List<Gank>>() {
// @Override
// public List<Gank> call(GankData.Result result) {
// return DataUtils.addAllResults(result);
// }
// });
// }
//
// }
//
// Path: app/src/main/java/com/yunq/gankio/injection/module/ApplicationModule.java
// @Module
// public class ApplicationModule {
// protected final Application mApplication;
//
// public ApplicationModule(Application application) {
// mApplication = application;
// }
//
// @Provides
// Application provideApplication() {
// return mApplication;
// }
//
// // @Provides
// // // @ApplicationContext
// // Context provideContext() {
// // return mApplication;
// // }
//
// @Provides
// @Singleton
// OkHttpClient provideOkHttpClient() {
// OkHttpClient.Builder builder = new OkHttpClient.Builder();
// builder.cache(new Cache(mApplication.getCacheDir(), 10 * 1024 * 1024));
// builder.addInterceptor(HttpUtils.getCacheInterceptor(mApplication));
// return builder.build();
// }
//
//
// }
// Path: app/src/main/java/com/yunq/gankio/injection/component/ApplicationComponent.java
import android.app.Application;
import com.yunq.gankio.data.DataManager;
import com.yunq.gankio.injection.module.ApplicationModule;
import javax.inject.Singleton;
import dagger.Component;
import okhttp3.OkHttpClient;
package com.yunq.gankio.injection.component;
/**
* Created by admin on 16/1/25.
*/
@Singleton
@Component(modules = ApplicationModule.class)
public interface ApplicationComponent {
//@ApplicationContext
// Context context();
Application application();
OkHttpClient okHttpClient();
| DataManager dataManager(); |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/core/MeiziService.java | // Path: app/src/main/java/com/yunq/gankio/data/parse/GankData.java
// public class GankData extends BaseData{
//
// public List<String> category;
// public Result results;
//
// public class Result {
// @SerializedName("Android")
// public List<Gank> androidList;
// @SerializedName("休息视频")
// public List<Gank> 休息视频List;
// @SerializedName("iOS")
// public List<Gank> iOSList;
// @SerializedName("福利")
// public List<Gank> 妹纸List;
// @SerializedName("拓展资源")
// public List<Gank> 拓展资源List;
// @SerializedName("瞎推荐")
// public List<Gank> 瞎推荐List;
// @SerializedName("App")
// public List<Gank> appList;
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/parse/PrettyGirlData.java
// public class PrettyGirlData extends BaseData {
//
// public List<Girl> results;
// }
| import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yunq.gankio.data.parse.GankData;
import com.yunq.gankio.data.parse.PrettyGirlData;
import com.yunq.gankio.data.parse.休息视频Data;
import okhttp3.OkHttpClient;
import retrofit2.GsonConverterFactory;
import retrofit2.Retrofit;
import retrofit2.RxJavaCallAdapterFactory;
import retrofit2.http.GET;
import retrofit2.http.Path;
import rx.Observable; | package com.yunq.gankio.core;
/**
* Created by admin on 16/1/25.
*/
public interface MeiziService {
/**
* 数据主机地址
*/
String HOST = "http://gank.avosapps.com/api/";
@GET("data/福利/{pageSize}/{page}") | // Path: app/src/main/java/com/yunq/gankio/data/parse/GankData.java
// public class GankData extends BaseData{
//
// public List<String> category;
// public Result results;
//
// public class Result {
// @SerializedName("Android")
// public List<Gank> androidList;
// @SerializedName("休息视频")
// public List<Gank> 休息视频List;
// @SerializedName("iOS")
// public List<Gank> iOSList;
// @SerializedName("福利")
// public List<Gank> 妹纸List;
// @SerializedName("拓展资源")
// public List<Gank> 拓展资源List;
// @SerializedName("瞎推荐")
// public List<Gank> 瞎推荐List;
// @SerializedName("App")
// public List<Gank> appList;
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/parse/PrettyGirlData.java
// public class PrettyGirlData extends BaseData {
//
// public List<Girl> results;
// }
// Path: app/src/main/java/com/yunq/gankio/core/MeiziService.java
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yunq.gankio.data.parse.GankData;
import com.yunq.gankio.data.parse.PrettyGirlData;
import com.yunq.gankio.data.parse.休息视频Data;
import okhttp3.OkHttpClient;
import retrofit2.GsonConverterFactory;
import retrofit2.Retrofit;
import retrofit2.RxJavaCallAdapterFactory;
import retrofit2.http.GET;
import retrofit2.http.Path;
import rx.Observable;
package com.yunq.gankio.core;
/**
* Created by admin on 16/1/25.
*/
public interface MeiziService {
/**
* 数据主机地址
*/
String HOST = "http://gank.avosapps.com/api/";
@GET("data/福利/{pageSize}/{page}") | Observable<PrettyGirlData> getPrettyGirlData(@Path("pageSize") int pageSize, @Path("page") int page); |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/core/MeiziService.java | // Path: app/src/main/java/com/yunq/gankio/data/parse/GankData.java
// public class GankData extends BaseData{
//
// public List<String> category;
// public Result results;
//
// public class Result {
// @SerializedName("Android")
// public List<Gank> androidList;
// @SerializedName("休息视频")
// public List<Gank> 休息视频List;
// @SerializedName("iOS")
// public List<Gank> iOSList;
// @SerializedName("福利")
// public List<Gank> 妹纸List;
// @SerializedName("拓展资源")
// public List<Gank> 拓展资源List;
// @SerializedName("瞎推荐")
// public List<Gank> 瞎推荐List;
// @SerializedName("App")
// public List<Gank> appList;
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/parse/PrettyGirlData.java
// public class PrettyGirlData extends BaseData {
//
// public List<Girl> results;
// }
| import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yunq.gankio.data.parse.GankData;
import com.yunq.gankio.data.parse.PrettyGirlData;
import com.yunq.gankio.data.parse.休息视频Data;
import okhttp3.OkHttpClient;
import retrofit2.GsonConverterFactory;
import retrofit2.Retrofit;
import retrofit2.RxJavaCallAdapterFactory;
import retrofit2.http.GET;
import retrofit2.http.Path;
import rx.Observable; | package com.yunq.gankio.core;
/**
* Created by admin on 16/1/25.
*/
public interface MeiziService {
/**
* 数据主机地址
*/
String HOST = "http://gank.avosapps.com/api/";
@GET("data/福利/{pageSize}/{page}")
Observable<PrettyGirlData> getPrettyGirlData(@Path("pageSize") int pageSize, @Path("page") int page);
@GET("data/休息视频/{pageSize}/{page}")
Observable<休息视频Data> get休息视频Data(@Path("pageSize") int pageSize, @Path("page") int page);
@GET("day/{year}/{month}/{day}") | // Path: app/src/main/java/com/yunq/gankio/data/parse/GankData.java
// public class GankData extends BaseData{
//
// public List<String> category;
// public Result results;
//
// public class Result {
// @SerializedName("Android")
// public List<Gank> androidList;
// @SerializedName("休息视频")
// public List<Gank> 休息视频List;
// @SerializedName("iOS")
// public List<Gank> iOSList;
// @SerializedName("福利")
// public List<Gank> 妹纸List;
// @SerializedName("拓展资源")
// public List<Gank> 拓展资源List;
// @SerializedName("瞎推荐")
// public List<Gank> 瞎推荐List;
// @SerializedName("App")
// public List<Gank> appList;
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/parse/PrettyGirlData.java
// public class PrettyGirlData extends BaseData {
//
// public List<Girl> results;
// }
// Path: app/src/main/java/com/yunq/gankio/core/MeiziService.java
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yunq.gankio.data.parse.GankData;
import com.yunq.gankio.data.parse.PrettyGirlData;
import com.yunq.gankio.data.parse.休息视频Data;
import okhttp3.OkHttpClient;
import retrofit2.GsonConverterFactory;
import retrofit2.Retrofit;
import retrofit2.RxJavaCallAdapterFactory;
import retrofit2.http.GET;
import retrofit2.http.Path;
import rx.Observable;
package com.yunq.gankio.core;
/**
* Created by admin on 16/1/25.
*/
public interface MeiziService {
/**
* 数据主机地址
*/
String HOST = "http://gank.avosapps.com/api/";
@GET("data/福利/{pageSize}/{page}")
Observable<PrettyGirlData> getPrettyGirlData(@Path("pageSize") int pageSize, @Path("page") int page);
@GET("data/休息视频/{pageSize}/{page}")
Observable<休息视频Data> get休息视频Data(@Path("pageSize") int pageSize, @Path("page") int page);
@GET("day/{year}/{month}/{day}") | Observable<GankData> getGankData(@Path("year") int year, @Path("month") int month, @Path("day") int day); |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/util/DialogUtils.java | // Path: app/src/main/java/com/yunq/gankio/ui/fragment/CustomWebViewDialog.java
// public class CustomWebViewDialog extends DialogFragment implements ICustomDialog {
//
// public static final String EXTRA_DIALOG_TITLE = "DIALOG_TITLE";
// public static final String EXTRA_HTML_FILE_NAME = "HTML_FILE_NAME";
// public static final String EXTRA_ACCENT_COLOR = "ACCENT_COLOR";
//
// @Inject
// CustomDialogPresenter mPresenter;
// @Inject
// Context mContext;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// initInjection();
// }
//
// private void initInjection() {
// DaggerFragmentComponent.builder()
// .fragmentModule(new FragmentModule(this))
// .applicationComponent(GankApp.get(this.getActivity()).getComponent())
// .build()
// .inject(this);
// }
//
// @NonNull
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState) {
// final View customView;
// try {
// customView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_webview, null);
// } catch (InflateException e) {
// throw new IllegalStateException("This device does not support Web Views.");
// }
//
// return mPresenter.makeDialog(this, customView);
//
//
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// GankApp.getRefWatcher(mContext).watch(this);
// mPresenter.detachView();
// }
// }
| import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import com.yunq.gankio.ui.fragment.CustomWebViewDialog; | package com.yunq.gankio.util;
/**
* Created by admin on 16/1/5.
*/
public class DialogUtils {
public static void showCustomDialog(Context context, FragmentManager fragmentManager, String dialogTitle, String htmlFileName, String tag) {
int accentColor = AndroidUtils.getAccentColor(context);
// CustomDialogPresenter.create(dialogTitle, htmlFileName, accentColor)
// .show(fragmentManager, tag); | // Path: app/src/main/java/com/yunq/gankio/ui/fragment/CustomWebViewDialog.java
// public class CustomWebViewDialog extends DialogFragment implements ICustomDialog {
//
// public static final String EXTRA_DIALOG_TITLE = "DIALOG_TITLE";
// public static final String EXTRA_HTML_FILE_NAME = "HTML_FILE_NAME";
// public static final String EXTRA_ACCENT_COLOR = "ACCENT_COLOR";
//
// @Inject
// CustomDialogPresenter mPresenter;
// @Inject
// Context mContext;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// initInjection();
// }
//
// private void initInjection() {
// DaggerFragmentComponent.builder()
// .fragmentModule(new FragmentModule(this))
// .applicationComponent(GankApp.get(this.getActivity()).getComponent())
// .build()
// .inject(this);
// }
//
// @NonNull
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState) {
// final View customView;
// try {
// customView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_webview, null);
// } catch (InflateException e) {
// throw new IllegalStateException("This device does not support Web Views.");
// }
//
// return mPresenter.makeDialog(this, customView);
//
//
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// GankApp.getRefWatcher(mContext).watch(this);
// mPresenter.detachView();
// }
// }
// Path: app/src/main/java/com/yunq/gankio/util/DialogUtils.java
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import com.yunq.gankio.ui.fragment.CustomWebViewDialog;
package com.yunq.gankio.util;
/**
* Created by admin on 16/1/5.
*/
public class DialogUtils {
public static void showCustomDialog(Context context, FragmentManager fragmentManager, String dialogTitle, String htmlFileName, String tag) {
int accentColor = AndroidUtils.getAccentColor(context);
// CustomDialogPresenter.create(dialogTitle, htmlFileName, accentColor)
// .show(fragmentManager, tag); | CustomWebViewDialog dialog = new CustomWebViewDialog(); |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/data/DataUtils.java | // Path: app/src/main/java/com/yunq/gankio/data/parse/GankData.java
// public class GankData extends BaseData{
//
// public List<String> category;
// public Result results;
//
// public class Result {
// @SerializedName("Android")
// public List<Gank> androidList;
// @SerializedName("休息视频")
// public List<Gank> 休息视频List;
// @SerializedName("iOS")
// public List<Gank> iOSList;
// @SerializedName("福利")
// public List<Gank> 妹纸List;
// @SerializedName("拓展资源")
// public List<Gank> 拓展资源List;
// @SerializedName("瞎推荐")
// public List<Gank> 瞎推荐List;
// @SerializedName("App")
// public List<Gank> appList;
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/parse/PrettyGirlData.java
// public class PrettyGirlData extends BaseData {
//
// public List<Girl> results;
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/entity/Gank.java
// @Table("ganks")
// public class Gank extends Soul {
//
// @Column("used")
// public boolean used;
// @Column("type")
// public String type;
// @Column("url")
// public String url;
// @Column("who")
// public String who;
// @Column("desc")
// public String desc;
// @Column("updatedAt")
// public Date updatedAt;
// @Column("createdAt")
// public Date createdAt;
// @Column("publishedAt")
// public Date publishedAt;
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/entity/Girl.java
// public class Girl extends Soul {
//
// @Column("used")
// public boolean used;
// @Column("type")
// public String type;
// @Column("url")
// public String url;
// @Column("who")
// public String who;
// @Column("desc")
// public String desc;
// @Column("createdAt")
// public Date createdAt;
// @Column("publishedAt")
// public Date publishedAt;
// @Column("updatedAt")
// public Date updatedAt;
//
// }
| import com.yunq.gankio.data.parse.GankData;
import com.yunq.gankio.data.parse.PrettyGirlData;
import com.yunq.gankio.data.entity.Gank;
import com.yunq.gankio.data.entity.Girl;
import com.yunq.gankio.data.parse.休息视频Data;
import java.util.ArrayList;
import java.util.List; | package com.yunq.gankio.data;
/**
* Created by admin on 16/1/25.
*/
public class DataUtils {
//MainActivity相关
public static PrettyGirlData createGirlInfoWith休息视频(PrettyGirlData girlData, 休息视频Data data) {
int restSize = data.results.size();
for (int i = 0; i < girlData.results.size(); i++) {
if (i <= restSize - 1) { | // Path: app/src/main/java/com/yunq/gankio/data/parse/GankData.java
// public class GankData extends BaseData{
//
// public List<String> category;
// public Result results;
//
// public class Result {
// @SerializedName("Android")
// public List<Gank> androidList;
// @SerializedName("休息视频")
// public List<Gank> 休息视频List;
// @SerializedName("iOS")
// public List<Gank> iOSList;
// @SerializedName("福利")
// public List<Gank> 妹纸List;
// @SerializedName("拓展资源")
// public List<Gank> 拓展资源List;
// @SerializedName("瞎推荐")
// public List<Gank> 瞎推荐List;
// @SerializedName("App")
// public List<Gank> appList;
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/parse/PrettyGirlData.java
// public class PrettyGirlData extends BaseData {
//
// public List<Girl> results;
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/entity/Gank.java
// @Table("ganks")
// public class Gank extends Soul {
//
// @Column("used")
// public boolean used;
// @Column("type")
// public String type;
// @Column("url")
// public String url;
// @Column("who")
// public String who;
// @Column("desc")
// public String desc;
// @Column("updatedAt")
// public Date updatedAt;
// @Column("createdAt")
// public Date createdAt;
// @Column("publishedAt")
// public Date publishedAt;
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/entity/Girl.java
// public class Girl extends Soul {
//
// @Column("used")
// public boolean used;
// @Column("type")
// public String type;
// @Column("url")
// public String url;
// @Column("who")
// public String who;
// @Column("desc")
// public String desc;
// @Column("createdAt")
// public Date createdAt;
// @Column("publishedAt")
// public Date publishedAt;
// @Column("updatedAt")
// public Date updatedAt;
//
// }
// Path: app/src/main/java/com/yunq/gankio/data/DataUtils.java
import com.yunq.gankio.data.parse.GankData;
import com.yunq.gankio.data.parse.PrettyGirlData;
import com.yunq.gankio.data.entity.Gank;
import com.yunq.gankio.data.entity.Girl;
import com.yunq.gankio.data.parse.休息视频Data;
import java.util.ArrayList;
import java.util.List;
package com.yunq.gankio.data;
/**
* Created by admin on 16/1/25.
*/
public class DataUtils {
//MainActivity相关
public static PrettyGirlData createGirlInfoWith休息视频(PrettyGirlData girlData, 休息视频Data data) {
int restSize = data.results.size();
for (int i = 0; i < girlData.results.size(); i++) {
if (i <= restSize - 1) { | Girl girl = girlData.results.get(i); |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/data/DataUtils.java | // Path: app/src/main/java/com/yunq/gankio/data/parse/GankData.java
// public class GankData extends BaseData{
//
// public List<String> category;
// public Result results;
//
// public class Result {
// @SerializedName("Android")
// public List<Gank> androidList;
// @SerializedName("休息视频")
// public List<Gank> 休息视频List;
// @SerializedName("iOS")
// public List<Gank> iOSList;
// @SerializedName("福利")
// public List<Gank> 妹纸List;
// @SerializedName("拓展资源")
// public List<Gank> 拓展资源List;
// @SerializedName("瞎推荐")
// public List<Gank> 瞎推荐List;
// @SerializedName("App")
// public List<Gank> appList;
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/parse/PrettyGirlData.java
// public class PrettyGirlData extends BaseData {
//
// public List<Girl> results;
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/entity/Gank.java
// @Table("ganks")
// public class Gank extends Soul {
//
// @Column("used")
// public boolean used;
// @Column("type")
// public String type;
// @Column("url")
// public String url;
// @Column("who")
// public String who;
// @Column("desc")
// public String desc;
// @Column("updatedAt")
// public Date updatedAt;
// @Column("createdAt")
// public Date createdAt;
// @Column("publishedAt")
// public Date publishedAt;
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/entity/Girl.java
// public class Girl extends Soul {
//
// @Column("used")
// public boolean used;
// @Column("type")
// public String type;
// @Column("url")
// public String url;
// @Column("who")
// public String who;
// @Column("desc")
// public String desc;
// @Column("createdAt")
// public Date createdAt;
// @Column("publishedAt")
// public Date publishedAt;
// @Column("updatedAt")
// public Date updatedAt;
//
// }
| import com.yunq.gankio.data.parse.GankData;
import com.yunq.gankio.data.parse.PrettyGirlData;
import com.yunq.gankio.data.entity.Gank;
import com.yunq.gankio.data.entity.Girl;
import com.yunq.gankio.data.parse.休息视频Data;
import java.util.ArrayList;
import java.util.List; | package com.yunq.gankio.data;
/**
* Created by admin on 16/1/25.
*/
public class DataUtils {
//MainActivity相关
public static PrettyGirlData createGirlInfoWith休息视频(PrettyGirlData girlData, 休息视频Data data) {
int restSize = data.results.size();
for (int i = 0; i < girlData.results.size(); i++) {
if (i <= restSize - 1) {
Girl girl = girlData.results.get(i);
girl.desc += " " + data.results.get(i).desc;
} else {
break;
}
}
return girlData;
}
//GirlDetailActivity相关 | // Path: app/src/main/java/com/yunq/gankio/data/parse/GankData.java
// public class GankData extends BaseData{
//
// public List<String> category;
// public Result results;
//
// public class Result {
// @SerializedName("Android")
// public List<Gank> androidList;
// @SerializedName("休息视频")
// public List<Gank> 休息视频List;
// @SerializedName("iOS")
// public List<Gank> iOSList;
// @SerializedName("福利")
// public List<Gank> 妹纸List;
// @SerializedName("拓展资源")
// public List<Gank> 拓展资源List;
// @SerializedName("瞎推荐")
// public List<Gank> 瞎推荐List;
// @SerializedName("App")
// public List<Gank> appList;
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/parse/PrettyGirlData.java
// public class PrettyGirlData extends BaseData {
//
// public List<Girl> results;
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/entity/Gank.java
// @Table("ganks")
// public class Gank extends Soul {
//
// @Column("used")
// public boolean used;
// @Column("type")
// public String type;
// @Column("url")
// public String url;
// @Column("who")
// public String who;
// @Column("desc")
// public String desc;
// @Column("updatedAt")
// public Date updatedAt;
// @Column("createdAt")
// public Date createdAt;
// @Column("publishedAt")
// public Date publishedAt;
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/entity/Girl.java
// public class Girl extends Soul {
//
// @Column("used")
// public boolean used;
// @Column("type")
// public String type;
// @Column("url")
// public String url;
// @Column("who")
// public String who;
// @Column("desc")
// public String desc;
// @Column("createdAt")
// public Date createdAt;
// @Column("publishedAt")
// public Date publishedAt;
// @Column("updatedAt")
// public Date updatedAt;
//
// }
// Path: app/src/main/java/com/yunq/gankio/data/DataUtils.java
import com.yunq.gankio.data.parse.GankData;
import com.yunq.gankio.data.parse.PrettyGirlData;
import com.yunq.gankio.data.entity.Gank;
import com.yunq.gankio.data.entity.Girl;
import com.yunq.gankio.data.parse.休息视频Data;
import java.util.ArrayList;
import java.util.List;
package com.yunq.gankio.data;
/**
* Created by admin on 16/1/25.
*/
public class DataUtils {
//MainActivity相关
public static PrettyGirlData createGirlInfoWith休息视频(PrettyGirlData girlData, 休息视频Data data) {
int restSize = data.results.size();
for (int i = 0; i < girlData.results.size(); i++) {
if (i <= restSize - 1) {
Girl girl = girlData.results.get(i);
girl.desc += " " + data.results.get(i).desc;
} else {
break;
}
}
return girlData;
}
//GirlDetailActivity相关 | public static List<Gank> addAllResults(GankData.Result results) { |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/data/DataUtils.java | // Path: app/src/main/java/com/yunq/gankio/data/parse/GankData.java
// public class GankData extends BaseData{
//
// public List<String> category;
// public Result results;
//
// public class Result {
// @SerializedName("Android")
// public List<Gank> androidList;
// @SerializedName("休息视频")
// public List<Gank> 休息视频List;
// @SerializedName("iOS")
// public List<Gank> iOSList;
// @SerializedName("福利")
// public List<Gank> 妹纸List;
// @SerializedName("拓展资源")
// public List<Gank> 拓展资源List;
// @SerializedName("瞎推荐")
// public List<Gank> 瞎推荐List;
// @SerializedName("App")
// public List<Gank> appList;
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/parse/PrettyGirlData.java
// public class PrettyGirlData extends BaseData {
//
// public List<Girl> results;
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/entity/Gank.java
// @Table("ganks")
// public class Gank extends Soul {
//
// @Column("used")
// public boolean used;
// @Column("type")
// public String type;
// @Column("url")
// public String url;
// @Column("who")
// public String who;
// @Column("desc")
// public String desc;
// @Column("updatedAt")
// public Date updatedAt;
// @Column("createdAt")
// public Date createdAt;
// @Column("publishedAt")
// public Date publishedAt;
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/entity/Girl.java
// public class Girl extends Soul {
//
// @Column("used")
// public boolean used;
// @Column("type")
// public String type;
// @Column("url")
// public String url;
// @Column("who")
// public String who;
// @Column("desc")
// public String desc;
// @Column("createdAt")
// public Date createdAt;
// @Column("publishedAt")
// public Date publishedAt;
// @Column("updatedAt")
// public Date updatedAt;
//
// }
| import com.yunq.gankio.data.parse.GankData;
import com.yunq.gankio.data.parse.PrettyGirlData;
import com.yunq.gankio.data.entity.Gank;
import com.yunq.gankio.data.entity.Girl;
import com.yunq.gankio.data.parse.休息视频Data;
import java.util.ArrayList;
import java.util.List; | package com.yunq.gankio.data;
/**
* Created by admin on 16/1/25.
*/
public class DataUtils {
//MainActivity相关
public static PrettyGirlData createGirlInfoWith休息视频(PrettyGirlData girlData, 休息视频Data data) {
int restSize = data.results.size();
for (int i = 0; i < girlData.results.size(); i++) {
if (i <= restSize - 1) {
Girl girl = girlData.results.get(i);
girl.desc += " " + data.results.get(i).desc;
} else {
break;
}
}
return girlData;
}
//GirlDetailActivity相关 | // Path: app/src/main/java/com/yunq/gankio/data/parse/GankData.java
// public class GankData extends BaseData{
//
// public List<String> category;
// public Result results;
//
// public class Result {
// @SerializedName("Android")
// public List<Gank> androidList;
// @SerializedName("休息视频")
// public List<Gank> 休息视频List;
// @SerializedName("iOS")
// public List<Gank> iOSList;
// @SerializedName("福利")
// public List<Gank> 妹纸List;
// @SerializedName("拓展资源")
// public List<Gank> 拓展资源List;
// @SerializedName("瞎推荐")
// public List<Gank> 瞎推荐List;
// @SerializedName("App")
// public List<Gank> appList;
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/parse/PrettyGirlData.java
// public class PrettyGirlData extends BaseData {
//
// public List<Girl> results;
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/entity/Gank.java
// @Table("ganks")
// public class Gank extends Soul {
//
// @Column("used")
// public boolean used;
// @Column("type")
// public String type;
// @Column("url")
// public String url;
// @Column("who")
// public String who;
// @Column("desc")
// public String desc;
// @Column("updatedAt")
// public Date updatedAt;
// @Column("createdAt")
// public Date createdAt;
// @Column("publishedAt")
// public Date publishedAt;
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/entity/Girl.java
// public class Girl extends Soul {
//
// @Column("used")
// public boolean used;
// @Column("type")
// public String type;
// @Column("url")
// public String url;
// @Column("who")
// public String who;
// @Column("desc")
// public String desc;
// @Column("createdAt")
// public Date createdAt;
// @Column("publishedAt")
// public Date publishedAt;
// @Column("updatedAt")
// public Date updatedAt;
//
// }
// Path: app/src/main/java/com/yunq/gankio/data/DataUtils.java
import com.yunq.gankio.data.parse.GankData;
import com.yunq.gankio.data.parse.PrettyGirlData;
import com.yunq.gankio.data.entity.Gank;
import com.yunq.gankio.data.entity.Girl;
import com.yunq.gankio.data.parse.休息视频Data;
import java.util.ArrayList;
import java.util.List;
package com.yunq.gankio.data;
/**
* Created by admin on 16/1/25.
*/
public class DataUtils {
//MainActivity相关
public static PrettyGirlData createGirlInfoWith休息视频(PrettyGirlData girlData, 休息视频Data data) {
int restSize = data.results.size();
for (int i = 0; i < girlData.results.size(); i++) {
if (i <= restSize - 1) {
Girl girl = girlData.results.get(i);
girl.desc += " " + data.results.get(i).desc;
} else {
break;
}
}
return girlData;
}
//GirlDetailActivity相关 | public static List<Gank> addAllResults(GankData.Result results) { |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/injection/component/FragmentComponent.java | // Path: app/src/main/java/com/yunq/gankio/injection/module/FragmentModule.java
// @Module
// public class FragmentModule {
// private final Fragment mFragment;
//
// public FragmentModule(Fragment fragment) {
// mFragment = fragment;
// }
//
// @Provides
// @com.yunq.gankio.injection.Fragment
// Context provideContext() {
// return mFragment.getActivity();
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/ui/fragment/CustomWebViewDialog.java
// public class CustomWebViewDialog extends DialogFragment implements ICustomDialog {
//
// public static final String EXTRA_DIALOG_TITLE = "DIALOG_TITLE";
// public static final String EXTRA_HTML_FILE_NAME = "HTML_FILE_NAME";
// public static final String EXTRA_ACCENT_COLOR = "ACCENT_COLOR";
//
// @Inject
// CustomDialogPresenter mPresenter;
// @Inject
// Context mContext;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// initInjection();
// }
//
// private void initInjection() {
// DaggerFragmentComponent.builder()
// .fragmentModule(new FragmentModule(this))
// .applicationComponent(GankApp.get(this.getActivity()).getComponent())
// .build()
// .inject(this);
// }
//
// @NonNull
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState) {
// final View customView;
// try {
// customView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_webview, null);
// } catch (InflateException e) {
// throw new IllegalStateException("This device does not support Web Views.");
// }
//
// return mPresenter.makeDialog(this, customView);
//
//
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// GankApp.getRefWatcher(mContext).watch(this);
// mPresenter.detachView();
// }
// }
| import android.content.Context;
import com.yunq.gankio.injection.Fragment;
import com.yunq.gankio.injection.module.FragmentModule;
import com.yunq.gankio.ui.fragment.CustomWebViewDialog;
import dagger.Component; | package com.yunq.gankio.injection.component;
/**
* Created by admin on 16/1/25.
*/
@Fragment
@Component(dependencies = ApplicationComponent.class, modules = FragmentModule.class)
public interface FragmentComponent { | // Path: app/src/main/java/com/yunq/gankio/injection/module/FragmentModule.java
// @Module
// public class FragmentModule {
// private final Fragment mFragment;
//
// public FragmentModule(Fragment fragment) {
// mFragment = fragment;
// }
//
// @Provides
// @com.yunq.gankio.injection.Fragment
// Context provideContext() {
// return mFragment.getActivity();
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/ui/fragment/CustomWebViewDialog.java
// public class CustomWebViewDialog extends DialogFragment implements ICustomDialog {
//
// public static final String EXTRA_DIALOG_TITLE = "DIALOG_TITLE";
// public static final String EXTRA_HTML_FILE_NAME = "HTML_FILE_NAME";
// public static final String EXTRA_ACCENT_COLOR = "ACCENT_COLOR";
//
// @Inject
// CustomDialogPresenter mPresenter;
// @Inject
// Context mContext;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// initInjection();
// }
//
// private void initInjection() {
// DaggerFragmentComponent.builder()
// .fragmentModule(new FragmentModule(this))
// .applicationComponent(GankApp.get(this.getActivity()).getComponent())
// .build()
// .inject(this);
// }
//
// @NonNull
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState) {
// final View customView;
// try {
// customView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_webview, null);
// } catch (InflateException e) {
// throw new IllegalStateException("This device does not support Web Views.");
// }
//
// return mPresenter.makeDialog(this, customView);
//
//
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// GankApp.getRefWatcher(mContext).watch(this);
// mPresenter.detachView();
// }
// }
// Path: app/src/main/java/com/yunq/gankio/injection/component/FragmentComponent.java
import android.content.Context;
import com.yunq.gankio.injection.Fragment;
import com.yunq.gankio.injection.module.FragmentModule;
import com.yunq.gankio.ui.fragment.CustomWebViewDialog;
import dagger.Component;
package com.yunq.gankio.injection.component;
/**
* Created by admin on 16/1/25.
*/
@Fragment
@Component(dependencies = ApplicationComponent.class, modules = FragmentModule.class)
public interface FragmentComponent { | void inject(CustomWebViewDialog dialog); |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/presenter/CustomDialogPresenter.java | // Path: app/src/main/java/com/yunq/gankio/presenter/view/ICustomDialog.java
// public interface ICustomDialog extends IBaseView {
// }
//
// Path: app/src/main/java/com/yunq/gankio/ui/fragment/CustomWebViewDialog.java
// public class CustomWebViewDialog extends DialogFragment implements ICustomDialog {
//
// public static final String EXTRA_DIALOG_TITLE = "DIALOG_TITLE";
// public static final String EXTRA_HTML_FILE_NAME = "HTML_FILE_NAME";
// public static final String EXTRA_ACCENT_COLOR = "ACCENT_COLOR";
//
// @Inject
// CustomDialogPresenter mPresenter;
// @Inject
// Context mContext;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// initInjection();
// }
//
// private void initInjection() {
// DaggerFragmentComponent.builder()
// .fragmentModule(new FragmentModule(this))
// .applicationComponent(GankApp.get(this.getActivity()).getComponent())
// .build()
// .inject(this);
// }
//
// @NonNull
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState) {
// final View customView;
// try {
// customView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_webview, null);
// } catch (InflateException e) {
// throw new IllegalStateException("This device does not support Web Views.");
// }
//
// return mPresenter.makeDialog(this, customView);
//
//
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// GankApp.getRefWatcher(mContext).watch(this);
// mPresenter.detachView();
// }
// }
| import android.content.Context;
import android.graphics.Color;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.webkit.WebView;
import com.yunq.gankio.R;
import com.yunq.gankio.presenter.view.ICustomDialog;
import com.yunq.gankio.ui.fragment.CustomWebViewDialog;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import javax.inject.Inject; | package com.yunq.gankio.presenter;
/**
* Created by admin on 16/1/6.
*/
public class CustomDialogPresenter extends BasePresenter<ICustomDialog> {
private static final String KEY_UTF_8 = "UTF-8";
private Context mContext;
@Inject
public CustomDialogPresenter(Context context) {
mContext = context;
}
public AlertDialog makeDialog(Fragment fragment, View customView) {
| // Path: app/src/main/java/com/yunq/gankio/presenter/view/ICustomDialog.java
// public interface ICustomDialog extends IBaseView {
// }
//
// Path: app/src/main/java/com/yunq/gankio/ui/fragment/CustomWebViewDialog.java
// public class CustomWebViewDialog extends DialogFragment implements ICustomDialog {
//
// public static final String EXTRA_DIALOG_TITLE = "DIALOG_TITLE";
// public static final String EXTRA_HTML_FILE_NAME = "HTML_FILE_NAME";
// public static final String EXTRA_ACCENT_COLOR = "ACCENT_COLOR";
//
// @Inject
// CustomDialogPresenter mPresenter;
// @Inject
// Context mContext;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// initInjection();
// }
//
// private void initInjection() {
// DaggerFragmentComponent.builder()
// .fragmentModule(new FragmentModule(this))
// .applicationComponent(GankApp.get(this.getActivity()).getComponent())
// .build()
// .inject(this);
// }
//
// @NonNull
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState) {
// final View customView;
// try {
// customView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_webview, null);
// } catch (InflateException e) {
// throw new IllegalStateException("This device does not support Web Views.");
// }
//
// return mPresenter.makeDialog(this, customView);
//
//
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// GankApp.getRefWatcher(mContext).watch(this);
// mPresenter.detachView();
// }
// }
// Path: app/src/main/java/com/yunq/gankio/presenter/CustomDialogPresenter.java
import android.content.Context;
import android.graphics.Color;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.webkit.WebView;
import com.yunq.gankio.R;
import com.yunq.gankio.presenter.view.ICustomDialog;
import com.yunq.gankio.ui.fragment.CustomWebViewDialog;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import javax.inject.Inject;
package com.yunq.gankio.presenter;
/**
* Created by admin on 16/1/6.
*/
public class CustomDialogPresenter extends BasePresenter<ICustomDialog> {
private static final String KEY_UTF_8 = "UTF-8";
private Context mContext;
@Inject
public CustomDialogPresenter(Context context) {
mContext = context;
}
public AlertDialog makeDialog(Fragment fragment, View customView) {
| String dialogTitle = fragment.getArguments().getString(CustomWebViewDialog.EXTRA_DIALOG_TITLE); |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/presenter/GankDetailPresenter.java | // Path: app/src/main/java/com/yunq/gankio/data/DataManager.java
// @Singleton
// public class DataManager {
// private final OkHttpClient mClient;
//
// private final MeiziService mMeiziService;
//
// @Inject
// public DataManager(OkHttpClient client) {
// mClient = client;
// mMeiziService = MeiziService.Creator.newGudongService(client);
// }
//
//
// public void cancelRequest() {
// mClient.dispatcher().cancelAll();
// }
//
// /**
// * MainActivity中获取所有Girls
// */
// public Observable<List<Girl>> getGirls(int pageSize, int currentPage) {
// return Observable.zip(mMeiziService.getPrettyGirlData(pageSize, currentPage),
// mMeiziService.get休息视频Data(pageSize, currentPage),
// new Func2<PrettyGirlData, 休息视频Data, PrettyGirlData>() {
// @Override
// public PrettyGirlData call(PrettyGirlData prettyGirlData, 休息视频Data 休息视频Data) {
// return DataUtils.createGirlInfoWith休息视频(prettyGirlData, 休息视频Data);
// }
// })
// .map(new Func1<PrettyGirlData, List<Girl>>() {
// @Override
// public List<Girl> call(PrettyGirlData girlData) {
// return girlData.results;
// }
// })
// .flatMap(new Func1<List<Girl>, Observable<Girl>>() {
// @Override
// public Observable<Girl> call(List<Girl> girls) {
// return Observable.from(girls);
// }
// })
// .toSortedList(new Func2<Girl, Girl, Integer>() {
// @Override
// public Integer call(Girl girl, Girl girl2) {
// return girl2.publishedAt.compareTo(girl.publishedAt);
// }
// });
// }
//
// /**
// * GankDetailActivity
// */
// public Observable<List<Gank>> getGankData(Date date) {
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(date);
// int year = calendar.get(Calendar.YEAR);
// int month = calendar.get(Calendar.MONTH) + 1;
// int day = calendar.get(Calendar.DAY_OF_MONTH);
//
// return mMeiziService.getGankData(year, month, day)
// .map(new Func1<GankData, GankData.Result>() {
// @Override
// public GankData.Result call(GankData gankData) {
// return gankData.results;
// }
// })
// .map(new Func1<GankData.Result, List<Gank>>() {
// @Override
// public List<Gank> call(GankData.Result result) {
// return DataUtils.addAllResults(result);
// }
// });
// }
//
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/entity/Gank.java
// @Table("ganks")
// public class Gank extends Soul {
//
// @Column("used")
// public boolean used;
// @Column("type")
// public String type;
// @Column("url")
// public String url;
// @Column("who")
// public String who;
// @Column("desc")
// public String desc;
// @Column("updatedAt")
// public Date updatedAt;
// @Column("createdAt")
// public Date createdAt;
// @Column("publishedAt")
// public Date publishedAt;
// }
//
// Path: app/src/main/java/com/yunq/gankio/presenter/view/IGankDetailView.java
// public interface IGankDetailView<T extends Soul> extends ISwipeRefreshView {
//
// void fillData(List<T> data);
// }
| import com.yunq.gankio.data.DataManager;
import com.yunq.gankio.data.entity.Gank;
import com.yunq.gankio.presenter.view.IGankDetailView;
import java.util.Date;
import java.util.List;
import javax.inject.Inject;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers; | package com.yunq.gankio.presenter;
/**
* Created by admin on 16/1/6.
*/
public class GankDetailPresenter extends BasePresenter<IGankDetailView> {
private final DataManager mDataManager;
@Inject
public GankDetailPresenter(DataManager dataManager) {
mDataManager = dataManager;
}
public void getData(Date date) {
addSubscription(mDataManager.getGankData(date)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io()) | // Path: app/src/main/java/com/yunq/gankio/data/DataManager.java
// @Singleton
// public class DataManager {
// private final OkHttpClient mClient;
//
// private final MeiziService mMeiziService;
//
// @Inject
// public DataManager(OkHttpClient client) {
// mClient = client;
// mMeiziService = MeiziService.Creator.newGudongService(client);
// }
//
//
// public void cancelRequest() {
// mClient.dispatcher().cancelAll();
// }
//
// /**
// * MainActivity中获取所有Girls
// */
// public Observable<List<Girl>> getGirls(int pageSize, int currentPage) {
// return Observable.zip(mMeiziService.getPrettyGirlData(pageSize, currentPage),
// mMeiziService.get休息视频Data(pageSize, currentPage),
// new Func2<PrettyGirlData, 休息视频Data, PrettyGirlData>() {
// @Override
// public PrettyGirlData call(PrettyGirlData prettyGirlData, 休息视频Data 休息视频Data) {
// return DataUtils.createGirlInfoWith休息视频(prettyGirlData, 休息视频Data);
// }
// })
// .map(new Func1<PrettyGirlData, List<Girl>>() {
// @Override
// public List<Girl> call(PrettyGirlData girlData) {
// return girlData.results;
// }
// })
// .flatMap(new Func1<List<Girl>, Observable<Girl>>() {
// @Override
// public Observable<Girl> call(List<Girl> girls) {
// return Observable.from(girls);
// }
// })
// .toSortedList(new Func2<Girl, Girl, Integer>() {
// @Override
// public Integer call(Girl girl, Girl girl2) {
// return girl2.publishedAt.compareTo(girl.publishedAt);
// }
// });
// }
//
// /**
// * GankDetailActivity
// */
// public Observable<List<Gank>> getGankData(Date date) {
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(date);
// int year = calendar.get(Calendar.YEAR);
// int month = calendar.get(Calendar.MONTH) + 1;
// int day = calendar.get(Calendar.DAY_OF_MONTH);
//
// return mMeiziService.getGankData(year, month, day)
// .map(new Func1<GankData, GankData.Result>() {
// @Override
// public GankData.Result call(GankData gankData) {
// return gankData.results;
// }
// })
// .map(new Func1<GankData.Result, List<Gank>>() {
// @Override
// public List<Gank> call(GankData.Result result) {
// return DataUtils.addAllResults(result);
// }
// });
// }
//
// }
//
// Path: app/src/main/java/com/yunq/gankio/data/entity/Gank.java
// @Table("ganks")
// public class Gank extends Soul {
//
// @Column("used")
// public boolean used;
// @Column("type")
// public String type;
// @Column("url")
// public String url;
// @Column("who")
// public String who;
// @Column("desc")
// public String desc;
// @Column("updatedAt")
// public Date updatedAt;
// @Column("createdAt")
// public Date createdAt;
// @Column("publishedAt")
// public Date publishedAt;
// }
//
// Path: app/src/main/java/com/yunq/gankio/presenter/view/IGankDetailView.java
// public interface IGankDetailView<T extends Soul> extends ISwipeRefreshView {
//
// void fillData(List<T> data);
// }
// Path: app/src/main/java/com/yunq/gankio/presenter/GankDetailPresenter.java
import com.yunq.gankio.data.DataManager;
import com.yunq.gankio.data.entity.Gank;
import com.yunq.gankio.presenter.view.IGankDetailView;
import java.util.Date;
import java.util.List;
import javax.inject.Inject;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
package com.yunq.gankio.presenter;
/**
* Created by admin on 16/1/6.
*/
public class GankDetailPresenter extends BasePresenter<IGankDetailView> {
private final DataManager mDataManager;
@Inject
public GankDetailPresenter(DataManager dataManager) {
mDataManager = dataManager;
}
public void getData(Date date) {
addSubscription(mDataManager.getGankData(date)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io()) | .subscribe(new Subscriber<List<Gank>>() { |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/injection/component/WebActivityComponent.java | // Path: app/src/main/java/com/yunq/gankio/injection/module/ActivityModule.java
// @Module
// public class ActivityModule {
//
// private android.app.Activity mActivity;
//
// public ActivityModule(android.app.Activity activity) {
// mActivity = activity;
// }
//
// @Provides
// android.app.Activity provideActivity() {
// return mActivity;
// }
//
// // @Provides
// // //@ActivityContext
// // Context provideContext() {
// // return mActivity;
// // }
// }
//
// Path: app/src/main/java/com/yunq/gankio/ui/activity/WebActivity.java
// public class WebActivity extends BaseSwipeRefreshActivity implements IWebView {
//
// private static final String TAG = WebActivity.class.getSimpleName();
//
// private static final String EXTRA_URL = "URL";
// private static final String EXTRA_TITLE = "TITLE";
//
// public static void gotoWebActivity(Context context, String url, String title) {
// Intent intent = new Intent(context, WebActivity.class);
// intent.putExtra(EXTRA_URL, url);
// intent.putExtra(EXTRA_TITLE, title);
// context.startActivity(intent);
// }
//
// @Bind(R.id.wb_content)
// WebView mWebView;
//
// @Inject
// WebPresenter mPresenter;
//
// @Override
// protected int getLayout() {
// return R.layout.activity_web;
// }
//
// @Override
// protected int getMenuRes() {
// return R.menu.menu_web;
// }
//
// @Override
// protected void initInjection() {
// DaggerWebActivityComponent.builder()
// .activityModule(new ActivityModule(this))
// .applicationComponent(GankApp.get(this).getComponent())
// .build()
// .inject(this);
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// initInjection();
// mPresenter.attachView(this);
// String url = getIntent().getStringExtra(EXTRA_URL);
// String title = getIntent().getStringExtra(EXTRA_TITLE);
//
// if (!TextUtils.isEmpty(title)) {
// setTitle(title, true);
// }
//
// mPresenter.setUpWebView(mWebView);
// mPresenter.loadUrl(mWebView, url);
// }
//
// @Override
// protected void onRefreshStarted() {
// refresh();
// }
//
// private void refresh() {
// mWebView.reload();
// }
//
// @Override
// public void showEmptyView() {
//
// }
//
// @Override
// public void showErrorView(Throwable throwable) {
// throwable.printStackTrace();
// }
//
// @Override
// public void showCancelRequest() {
//
// }
//
//
// @Override
// public void showLoadErrorMessage(String message) {
// Snackbar.make(mWebView, message, Snackbar.LENGTH_SHORT).show();
// }
//
// @Override
// protected void onDestroy() {
// super.onDestroy();
// if (mWebView != null) {
// mWebView.destroy();
// }
// mPresenter.detachView();
// }
//
// @Override
// protected void onPause() {
// if (mWebView != null) {
// mWebView.onPause();
// }
// super.onPause();
// }
//
// @Override
// public boolean onKeyDown(int keyCode, KeyEvent event) {
// if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
// mWebView.goBack();
// return true;
// }
// return super.onKeyDown(keyCode, event);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// int id = item.getItemId();
//
// switch (id) {
// case R.id.action_copy_url:
// String copyDone = getString(R.string.toast_copy_done);
// AndroidUtils.copyToClipBoard(this, mWebView.getUrl(), copyDone);
// return true;
// case R.id.action_open_url:
// Intent intent = new Intent();
// intent.setAction(Intent.ACTION_VIEW);
// Uri uri = Uri.parse(mWebView.getUrl());
// intent.setData(uri);
// if (intent.resolveActivity(getPackageManager()) != null) {
// startActivity(intent);
// } else {
// Toast.makeText(WebActivity.this, R.string.toast_open_fail, Toast.LENGTH_SHORT).show();
// }
// return true;
// }
// return super.onOptionsItemSelected(item);
// }
//
//
// @Override
// public void onBackPressed() {
// if (isRefreshing()) {
// hideRefresh();
// return;
// }
// super.onBackPressed();
// }
//
// }
| import com.yunq.gankio.injection.Activity;
import com.yunq.gankio.injection.module.ActivityModule;
import com.yunq.gankio.ui.activity.WebActivity;
import dagger.Component; | package com.yunq.gankio.injection.component;
/**
* Created by admin on 16/1/25.
*/
@Activity
@Component(dependencies = ApplicationComponent.class, modules = ActivityModule.class)
public interface WebActivityComponent extends ActivityComponent { | // Path: app/src/main/java/com/yunq/gankio/injection/module/ActivityModule.java
// @Module
// public class ActivityModule {
//
// private android.app.Activity mActivity;
//
// public ActivityModule(android.app.Activity activity) {
// mActivity = activity;
// }
//
// @Provides
// android.app.Activity provideActivity() {
// return mActivity;
// }
//
// // @Provides
// // //@ActivityContext
// // Context provideContext() {
// // return mActivity;
// // }
// }
//
// Path: app/src/main/java/com/yunq/gankio/ui/activity/WebActivity.java
// public class WebActivity extends BaseSwipeRefreshActivity implements IWebView {
//
// private static final String TAG = WebActivity.class.getSimpleName();
//
// private static final String EXTRA_URL = "URL";
// private static final String EXTRA_TITLE = "TITLE";
//
// public static void gotoWebActivity(Context context, String url, String title) {
// Intent intent = new Intent(context, WebActivity.class);
// intent.putExtra(EXTRA_URL, url);
// intent.putExtra(EXTRA_TITLE, title);
// context.startActivity(intent);
// }
//
// @Bind(R.id.wb_content)
// WebView mWebView;
//
// @Inject
// WebPresenter mPresenter;
//
// @Override
// protected int getLayout() {
// return R.layout.activity_web;
// }
//
// @Override
// protected int getMenuRes() {
// return R.menu.menu_web;
// }
//
// @Override
// protected void initInjection() {
// DaggerWebActivityComponent.builder()
// .activityModule(new ActivityModule(this))
// .applicationComponent(GankApp.get(this).getComponent())
// .build()
// .inject(this);
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// initInjection();
// mPresenter.attachView(this);
// String url = getIntent().getStringExtra(EXTRA_URL);
// String title = getIntent().getStringExtra(EXTRA_TITLE);
//
// if (!TextUtils.isEmpty(title)) {
// setTitle(title, true);
// }
//
// mPresenter.setUpWebView(mWebView);
// mPresenter.loadUrl(mWebView, url);
// }
//
// @Override
// protected void onRefreshStarted() {
// refresh();
// }
//
// private void refresh() {
// mWebView.reload();
// }
//
// @Override
// public void showEmptyView() {
//
// }
//
// @Override
// public void showErrorView(Throwable throwable) {
// throwable.printStackTrace();
// }
//
// @Override
// public void showCancelRequest() {
//
// }
//
//
// @Override
// public void showLoadErrorMessage(String message) {
// Snackbar.make(mWebView, message, Snackbar.LENGTH_SHORT).show();
// }
//
// @Override
// protected void onDestroy() {
// super.onDestroy();
// if (mWebView != null) {
// mWebView.destroy();
// }
// mPresenter.detachView();
// }
//
// @Override
// protected void onPause() {
// if (mWebView != null) {
// mWebView.onPause();
// }
// super.onPause();
// }
//
// @Override
// public boolean onKeyDown(int keyCode, KeyEvent event) {
// if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
// mWebView.goBack();
// return true;
// }
// return super.onKeyDown(keyCode, event);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// int id = item.getItemId();
//
// switch (id) {
// case R.id.action_copy_url:
// String copyDone = getString(R.string.toast_copy_done);
// AndroidUtils.copyToClipBoard(this, mWebView.getUrl(), copyDone);
// return true;
// case R.id.action_open_url:
// Intent intent = new Intent();
// intent.setAction(Intent.ACTION_VIEW);
// Uri uri = Uri.parse(mWebView.getUrl());
// intent.setData(uri);
// if (intent.resolveActivity(getPackageManager()) != null) {
// startActivity(intent);
// } else {
// Toast.makeText(WebActivity.this, R.string.toast_open_fail, Toast.LENGTH_SHORT).show();
// }
// return true;
// }
// return super.onOptionsItemSelected(item);
// }
//
//
// @Override
// public void onBackPressed() {
// if (isRefreshing()) {
// hideRefresh();
// return;
// }
// super.onBackPressed();
// }
//
// }
// Path: app/src/main/java/com/yunq/gankio/injection/component/WebActivityComponent.java
import com.yunq.gankio.injection.Activity;
import com.yunq.gankio.injection.module.ActivityModule;
import com.yunq.gankio.ui.activity.WebActivity;
import dagger.Component;
package com.yunq.gankio.injection.component;
/**
* Created by admin on 16/1/25.
*/
@Activity
@Component(dependencies = ApplicationComponent.class, modules = ActivityModule.class)
public interface WebActivityComponent extends ActivityComponent { | void inject(WebActivity activity); |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/ui/adapter/MainListAdapter.java | // Path: app/src/main/java/com/yunq/gankio/data/entity/Girl.java
// public class Girl extends Soul {
//
// @Column("used")
// public boolean used;
// @Column("type")
// public String type;
// @Column("url")
// public String url;
// @Column("who")
// public String who;
// @Column("desc")
// public String desc;
// @Column("createdAt")
// public Date createdAt;
// @Column("publishedAt")
// public Date publishedAt;
// @Column("updatedAt")
// public Date updatedAt;
//
// }
//
// Path: app/src/main/java/com/yunq/gankio/ui/widget/RatioImageView.java
// public class RatioImageView extends ImageView {
//
// private int originalWidth;
//
// private int originalHeight;
//
// public RatioImageView(Context context) {
// super(context);
// }
//
// public RatioImageView(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// public RatioImageView(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// public void setOriginalSize(int originalWidth, int originalHeight) {
// this.originalWidth = originalWidth;
// this.originalHeight = originalHeight;
// }
//
// @Override
// protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// if (originalHeight > 0 && originalWidth > 0) {
// float radio = (float) originalWidth / (float) originalHeight;
//
// int width = MeasureSpec.getSize(widthMeasureSpec);
// int height = MeasureSpec.getSize(heightMeasureSpec);
//
// if (width > 0) {
// height = (int) ((float) width / radio);
// }
//
// setMeasuredDimension(width, height);
// } else {
// super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// }
//
// }
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import com.yunq.gankio.R;
import com.yunq.gankio.data.entity.Girl;
import com.yunq.gankio.ui.widget.RatioImageView;
import java.util.ArrayList;
import java.util.List;
import butterknife.Bind;
import butterknife.ButterKnife; | Picasso.with(mContext).load(entity.url).into(holder.mIvIndexPhoto);
holder.mTvIndexIntro.setText(entity.desc);
if (mIClickItem != null) {
holder.mIvIndexPhoto.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mIClickItem.onClickPhoto(position, holder.mIvIndexPhoto);
}
});
holder.mTvIndexIntro.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mIClickItem.onClickDesc(position, holder.mTvIndexIntro);
}
});
}
}
@Override
public int getItemCount() {
return mListData.size();
}
public Girl getGirl(int position) {
return mListData.get(position);
}
public static class ViewHolder extends RecyclerView.ViewHolder {
@Bind(R.id.iv_index_photo) | // Path: app/src/main/java/com/yunq/gankio/data/entity/Girl.java
// public class Girl extends Soul {
//
// @Column("used")
// public boolean used;
// @Column("type")
// public String type;
// @Column("url")
// public String url;
// @Column("who")
// public String who;
// @Column("desc")
// public String desc;
// @Column("createdAt")
// public Date createdAt;
// @Column("publishedAt")
// public Date publishedAt;
// @Column("updatedAt")
// public Date updatedAt;
//
// }
//
// Path: app/src/main/java/com/yunq/gankio/ui/widget/RatioImageView.java
// public class RatioImageView extends ImageView {
//
// private int originalWidth;
//
// private int originalHeight;
//
// public RatioImageView(Context context) {
// super(context);
// }
//
// public RatioImageView(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// public RatioImageView(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// public void setOriginalSize(int originalWidth, int originalHeight) {
// this.originalWidth = originalWidth;
// this.originalHeight = originalHeight;
// }
//
// @Override
// protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// if (originalHeight > 0 && originalWidth > 0) {
// float radio = (float) originalWidth / (float) originalHeight;
//
// int width = MeasureSpec.getSize(widthMeasureSpec);
// int height = MeasureSpec.getSize(heightMeasureSpec);
//
// if (width > 0) {
// height = (int) ((float) width / radio);
// }
//
// setMeasuredDimension(width, height);
// } else {
// super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// }
//
// }
// }
// Path: app/src/main/java/com/yunq/gankio/ui/adapter/MainListAdapter.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import com.yunq.gankio.R;
import com.yunq.gankio.data.entity.Girl;
import com.yunq.gankio.ui.widget.RatioImageView;
import java.util.ArrayList;
import java.util.List;
import butterknife.Bind;
import butterknife.ButterKnife;
Picasso.with(mContext).load(entity.url).into(holder.mIvIndexPhoto);
holder.mTvIndexIntro.setText(entity.desc);
if (mIClickItem != null) {
holder.mIvIndexPhoto.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mIClickItem.onClickPhoto(position, holder.mIvIndexPhoto);
}
});
holder.mTvIndexIntro.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mIClickItem.onClickDesc(position, holder.mTvIndexIntro);
}
});
}
}
@Override
public int getItemCount() {
return mListData.size();
}
public Girl getGirl(int position) {
return mListData.get(position);
}
public static class ViewHolder extends RecyclerView.ViewHolder {
@Bind(R.id.iv_index_photo) | RatioImageView mIvIndexPhoto; |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/injection/component/GirlFaceActivityComponent.java | // Path: app/src/main/java/com/yunq/gankio/injection/module/ActivityModule.java
// @Module
// public class ActivityModule {
//
// private android.app.Activity mActivity;
//
// public ActivityModule(android.app.Activity activity) {
// mActivity = activity;
// }
//
// @Provides
// android.app.Activity provideActivity() {
// return mActivity;
// }
//
// // @Provides
// // //@ActivityContext
// // Context provideContext() {
// // return mActivity;
// // }
// }
//
// Path: app/src/main/java/com/yunq/gankio/ui/activity/GirlFaceActivity.java
// public class GirlFaceActivity extends BaseActivity implements IGirlFaceView {
//
// private static final String EXTRA_BUNDLE_URL = "BUNDLE_URL";
// private static final String EXTRA_BUNDLE_TITLE = "BUNDLE_TITLE";
//
// @Bind(R.id.iv_girl_detail)
// ImageView mIvGrilDetail;
//
// PhotoViewAttacher mAttacher;
//
// @Inject
// GirlFacePresenter mPresenter;
//
// public static void gotoWatchGirlDetail(Context context, String url, String title) {
// Intent intent = new Intent(context, GirlFaceActivity.class);
// intent.putExtra(EXTRA_BUNDLE_URL, url);
// intent.putExtra(EXTRA_BUNDLE_TITLE, title);
// context.startActivity(intent);
// }
//
//
// @Override
// protected int getLayout() {
// return R.layout.activity_girl_face;
// }
//
// @Override
// protected int getMenuRes() {
// return R.menu.menu_girl_detail;
// }
//
//
// @Override
// protected void initInjection() {
// DaggerGirlFaceActivityComponent.builder()
// .activityModule(new ActivityModule(this))
// .applicationComponent(GankApp.get(this).getComponent())
// .build()
// .inject(this);
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// initInjection();
// mPresenter.attachView(this);
// mAttacher = new PhotoViewAttacher(mIvGrilDetail);
//
// String title = getIntent().getStringExtra(EXTRA_BUNDLE_TITLE);
// setTitle(title, true);
//
// String url = getIntent().getStringExtra(EXTRA_BUNDLE_URL);
// mPresenter.loadGirl(url, mIvGrilDetail);
// }
//
// @Override
// public void saveSuccess(String message) {
// ToastUtils.showShort(this, message);
// }
//
// @Override
// public void showFailInfo(String error) {
// ToastUtils.showShort(this, error);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// int id = item.getItemId();
// if (id == R.id.action_save) {
// mPresenter.saveFace(getIntent().getStringExtra(EXTRA_BUNDLE_URL));
// return true;
// }
// return super.onOptionsItemSelected(item);
// }
//
//
// @Override
// protected void onDestroy() {
// super.onDestroy();
// Picasso.with(this).cancelRequest(mIvGrilDetail);
// mPresenter.detachView();
// }
//
//
// }
| import com.yunq.gankio.injection.Activity;
import com.yunq.gankio.injection.module.ActivityModule;
import com.yunq.gankio.ui.activity.GirlFaceActivity;
import dagger.Component; | package com.yunq.gankio.injection.component;
/**
* Created by admin on 16/1/25.
*/
@Activity
@Component(dependencies = ApplicationComponent.class, modules = ActivityModule.class)
public interface GirlFaceActivityComponent extends ActivityComponent{ | // Path: app/src/main/java/com/yunq/gankio/injection/module/ActivityModule.java
// @Module
// public class ActivityModule {
//
// private android.app.Activity mActivity;
//
// public ActivityModule(android.app.Activity activity) {
// mActivity = activity;
// }
//
// @Provides
// android.app.Activity provideActivity() {
// return mActivity;
// }
//
// // @Provides
// // //@ActivityContext
// // Context provideContext() {
// // return mActivity;
// // }
// }
//
// Path: app/src/main/java/com/yunq/gankio/ui/activity/GirlFaceActivity.java
// public class GirlFaceActivity extends BaseActivity implements IGirlFaceView {
//
// private static final String EXTRA_BUNDLE_URL = "BUNDLE_URL";
// private static final String EXTRA_BUNDLE_TITLE = "BUNDLE_TITLE";
//
// @Bind(R.id.iv_girl_detail)
// ImageView mIvGrilDetail;
//
// PhotoViewAttacher mAttacher;
//
// @Inject
// GirlFacePresenter mPresenter;
//
// public static void gotoWatchGirlDetail(Context context, String url, String title) {
// Intent intent = new Intent(context, GirlFaceActivity.class);
// intent.putExtra(EXTRA_BUNDLE_URL, url);
// intent.putExtra(EXTRA_BUNDLE_TITLE, title);
// context.startActivity(intent);
// }
//
//
// @Override
// protected int getLayout() {
// return R.layout.activity_girl_face;
// }
//
// @Override
// protected int getMenuRes() {
// return R.menu.menu_girl_detail;
// }
//
//
// @Override
// protected void initInjection() {
// DaggerGirlFaceActivityComponent.builder()
// .activityModule(new ActivityModule(this))
// .applicationComponent(GankApp.get(this).getComponent())
// .build()
// .inject(this);
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// initInjection();
// mPresenter.attachView(this);
// mAttacher = new PhotoViewAttacher(mIvGrilDetail);
//
// String title = getIntent().getStringExtra(EXTRA_BUNDLE_TITLE);
// setTitle(title, true);
//
// String url = getIntent().getStringExtra(EXTRA_BUNDLE_URL);
// mPresenter.loadGirl(url, mIvGrilDetail);
// }
//
// @Override
// public void saveSuccess(String message) {
// ToastUtils.showShort(this, message);
// }
//
// @Override
// public void showFailInfo(String error) {
// ToastUtils.showShort(this, error);
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// int id = item.getItemId();
// if (id == R.id.action_save) {
// mPresenter.saveFace(getIntent().getStringExtra(EXTRA_BUNDLE_URL));
// return true;
// }
// return super.onOptionsItemSelected(item);
// }
//
//
// @Override
// protected void onDestroy() {
// super.onDestroy();
// Picasso.with(this).cancelRequest(mIvGrilDetail);
// mPresenter.detachView();
// }
//
//
// }
// Path: app/src/main/java/com/yunq/gankio/injection/component/GirlFaceActivityComponent.java
import com.yunq.gankio.injection.Activity;
import com.yunq.gankio.injection.module.ActivityModule;
import com.yunq.gankio.ui.activity.GirlFaceActivity;
import dagger.Component;
package com.yunq.gankio.injection.component;
/**
* Created by admin on 16/1/25.
*/
@Activity
@Component(dependencies = ApplicationComponent.class, modules = ActivityModule.class)
public interface GirlFaceActivityComponent extends ActivityComponent{ | void inject(GirlFaceActivity activity); |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/GankApp.java | // Path: app/src/main/java/com/yunq/gankio/injection/component/ApplicationComponent.java
// @Singleton
// @Component(modules = ApplicationModule.class)
// public interface ApplicationComponent {
// //@ApplicationContext
// // Context context();
//
// Application application();
//
// OkHttpClient okHttpClient();
//
// DataManager dataManager();
//
//
// }
//
// Path: app/src/main/java/com/yunq/gankio/injection/module/ApplicationModule.java
// @Module
// public class ApplicationModule {
// protected final Application mApplication;
//
// public ApplicationModule(Application application) {
// mApplication = application;
// }
//
// @Provides
// Application provideApplication() {
// return mApplication;
// }
//
// // @Provides
// // // @ApplicationContext
// // Context provideContext() {
// // return mApplication;
// // }
//
// @Provides
// @Singleton
// OkHttpClient provideOkHttpClient() {
// OkHttpClient.Builder builder = new OkHttpClient.Builder();
// builder.cache(new Cache(mApplication.getCacheDir(), 10 * 1024 * 1024));
// builder.addInterceptor(HttpUtils.getCacheInterceptor(mApplication));
// return builder.build();
// }
//
//
// }
| import android.app.Application;
import android.content.Context;
import android.os.StrictMode;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;
import com.yunq.gankio.injection.component.ApplicationComponent;
import com.yunq.gankio.injection.component.DaggerApplicationComponent;
import com.yunq.gankio.injection.module.ApplicationModule;
import timber.log.Timber; | package com.yunq.gankio;
/**
* Created by admin on 16/1/5.
*/
public class GankApp extends Application {
private RefWatcher refWatcher;
| // Path: app/src/main/java/com/yunq/gankio/injection/component/ApplicationComponent.java
// @Singleton
// @Component(modules = ApplicationModule.class)
// public interface ApplicationComponent {
// //@ApplicationContext
// // Context context();
//
// Application application();
//
// OkHttpClient okHttpClient();
//
// DataManager dataManager();
//
//
// }
//
// Path: app/src/main/java/com/yunq/gankio/injection/module/ApplicationModule.java
// @Module
// public class ApplicationModule {
// protected final Application mApplication;
//
// public ApplicationModule(Application application) {
// mApplication = application;
// }
//
// @Provides
// Application provideApplication() {
// return mApplication;
// }
//
// // @Provides
// // // @ApplicationContext
// // Context provideContext() {
// // return mApplication;
// // }
//
// @Provides
// @Singleton
// OkHttpClient provideOkHttpClient() {
// OkHttpClient.Builder builder = new OkHttpClient.Builder();
// builder.cache(new Cache(mApplication.getCacheDir(), 10 * 1024 * 1024));
// builder.addInterceptor(HttpUtils.getCacheInterceptor(mApplication));
// return builder.build();
// }
//
//
// }
// Path: app/src/main/java/com/yunq/gankio/GankApp.java
import android.app.Application;
import android.content.Context;
import android.os.StrictMode;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;
import com.yunq.gankio.injection.component.ApplicationComponent;
import com.yunq.gankio.injection.component.DaggerApplicationComponent;
import com.yunq.gankio.injection.module.ApplicationModule;
import timber.log.Timber;
package com.yunq.gankio;
/**
* Created by admin on 16/1/5.
*/
public class GankApp extends Application {
private RefWatcher refWatcher;
| ApplicationComponent mApplicationComponent; |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/GankApp.java | // Path: app/src/main/java/com/yunq/gankio/injection/component/ApplicationComponent.java
// @Singleton
// @Component(modules = ApplicationModule.class)
// public interface ApplicationComponent {
// //@ApplicationContext
// // Context context();
//
// Application application();
//
// OkHttpClient okHttpClient();
//
// DataManager dataManager();
//
//
// }
//
// Path: app/src/main/java/com/yunq/gankio/injection/module/ApplicationModule.java
// @Module
// public class ApplicationModule {
// protected final Application mApplication;
//
// public ApplicationModule(Application application) {
// mApplication = application;
// }
//
// @Provides
// Application provideApplication() {
// return mApplication;
// }
//
// // @Provides
// // // @ApplicationContext
// // Context provideContext() {
// // return mApplication;
// // }
//
// @Provides
// @Singleton
// OkHttpClient provideOkHttpClient() {
// OkHttpClient.Builder builder = new OkHttpClient.Builder();
// builder.cache(new Cache(mApplication.getCacheDir(), 10 * 1024 * 1024));
// builder.addInterceptor(HttpUtils.getCacheInterceptor(mApplication));
// return builder.build();
// }
//
//
// }
| import android.app.Application;
import android.content.Context;
import android.os.StrictMode;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;
import com.yunq.gankio.injection.component.ApplicationComponent;
import com.yunq.gankio.injection.component.DaggerApplicationComponent;
import com.yunq.gankio.injection.module.ApplicationModule;
import timber.log.Timber; | package com.yunq.gankio;
/**
* Created by admin on 16/1/5.
*/
public class GankApp extends Application {
private RefWatcher refWatcher;
ApplicationComponent mApplicationComponent;
@Override
public void onCreate() {
super.onCreate();
refWatcher = LeakCanary.install(this);
if (BuildConfig.DEBUG) {
//警告在主线程中执行耗时操作
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
Timber.plant(new Timber.DebugTree());
}
}
public static GankApp get(Context context) {
return (GankApp) context.getApplicationContext();
}
public static RefWatcher getRefWatcher(Context context) {
return ((GankApp) context.getApplicationContext()).refWatcher;
}
public ApplicationComponent getComponent() {
if (mApplicationComponent == null) {
mApplicationComponent = DaggerApplicationComponent.builder() | // Path: app/src/main/java/com/yunq/gankio/injection/component/ApplicationComponent.java
// @Singleton
// @Component(modules = ApplicationModule.class)
// public interface ApplicationComponent {
// //@ApplicationContext
// // Context context();
//
// Application application();
//
// OkHttpClient okHttpClient();
//
// DataManager dataManager();
//
//
// }
//
// Path: app/src/main/java/com/yunq/gankio/injection/module/ApplicationModule.java
// @Module
// public class ApplicationModule {
// protected final Application mApplication;
//
// public ApplicationModule(Application application) {
// mApplication = application;
// }
//
// @Provides
// Application provideApplication() {
// return mApplication;
// }
//
// // @Provides
// // // @ApplicationContext
// // Context provideContext() {
// // return mApplication;
// // }
//
// @Provides
// @Singleton
// OkHttpClient provideOkHttpClient() {
// OkHttpClient.Builder builder = new OkHttpClient.Builder();
// builder.cache(new Cache(mApplication.getCacheDir(), 10 * 1024 * 1024));
// builder.addInterceptor(HttpUtils.getCacheInterceptor(mApplication));
// return builder.build();
// }
//
//
// }
// Path: app/src/main/java/com/yunq/gankio/GankApp.java
import android.app.Application;
import android.content.Context;
import android.os.StrictMode;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;
import com.yunq.gankio.injection.component.ApplicationComponent;
import com.yunq.gankio.injection.component.DaggerApplicationComponent;
import com.yunq.gankio.injection.module.ApplicationModule;
import timber.log.Timber;
package com.yunq.gankio;
/**
* Created by admin on 16/1/5.
*/
public class GankApp extends Application {
private RefWatcher refWatcher;
ApplicationComponent mApplicationComponent;
@Override
public void onCreate() {
super.onCreate();
refWatcher = LeakCanary.install(this);
if (BuildConfig.DEBUG) {
//警告在主线程中执行耗时操作
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
Timber.plant(new Timber.DebugTree());
}
}
public static GankApp get(Context context) {
return (GankApp) context.getApplicationContext();
}
public static RefWatcher getRefWatcher(Context context) {
return ((GankApp) context.getApplicationContext()).refWatcher;
}
public ApplicationComponent getComponent() {
if (mApplicationComponent == null) {
mApplicationComponent = DaggerApplicationComponent.builder() | .applicationModule(new ApplicationModule(this)) |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/ui/fragment/CustomWebViewDialog.java | // Path: app/src/main/java/com/yunq/gankio/GankApp.java
// public class GankApp extends Application {
//
// private RefWatcher refWatcher;
//
// ApplicationComponent mApplicationComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
// refWatcher = LeakCanary.install(this);
//
// if (BuildConfig.DEBUG) {
// //警告在主线程中执行耗时操作
// StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
// StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
//
// Timber.plant(new Timber.DebugTree());
// }
//
// }
//
// public static GankApp get(Context context) {
// return (GankApp) context.getApplicationContext();
// }
//
// public static RefWatcher getRefWatcher(Context context) {
// return ((GankApp) context.getApplicationContext()).refWatcher;
// }
//
// public ApplicationComponent getComponent() {
// if (mApplicationComponent == null) {
// mApplicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
// return mApplicationComponent;
// }
//
//
// }
//
// Path: app/src/main/java/com/yunq/gankio/injection/module/FragmentModule.java
// @Module
// public class FragmentModule {
// private final Fragment mFragment;
//
// public FragmentModule(Fragment fragment) {
// mFragment = fragment;
// }
//
// @Provides
// @com.yunq.gankio.injection.Fragment
// Context provideContext() {
// return mFragment.getActivity();
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/presenter/CustomDialogPresenter.java
// public class CustomDialogPresenter extends BasePresenter<ICustomDialog> {
//
//
// private static final String KEY_UTF_8 = "UTF-8";
//
// private Context mContext;
//
// @Inject
// public CustomDialogPresenter(Context context) {
// mContext = context;
// }
//
// public AlertDialog makeDialog(Fragment fragment, View customView) {
//
// String dialogTitle = fragment.getArguments().getString(CustomWebViewDialog.EXTRA_DIALOG_TITLE);
// String htmlFileName = fragment.getArguments().getString(CustomWebViewDialog.EXTRA_HTML_FILE_NAME);
// int accentColor = fragment.getArguments().getInt(CustomWebViewDialog.EXTRA_ACCENT_COLOR);
//
// final WebView webView = (WebView) customView.findViewById(R.id.webView);
// webView.getSettings().setDefaultTextEncodingName(KEY_UTF_8);
// loadData(webView, htmlFileName, accentColor);
//
// AlertDialog dialog = new AlertDialog.Builder(mContext)
// .setTitle(dialogTitle)
// .setView(customView)
// .setPositiveButton(android.R.string.ok, null)
// .show();
// return dialog;
// }
//
// private void loadData(WebView webView, String htmlFileName, int accentColor) {
// try {
// StringBuilder buf = new StringBuilder();
// InputStream json = mContext.getAssets().open(htmlFileName);
// BufferedReader in = new BufferedReader(new InputStreamReader(json, KEY_UTF_8));
// String str;
// while ((str = in.readLine()) != null)
// buf.append(str);
// in.close();
//
// String formatLodString = buf.toString()
// .replace("{style-placeholder}", "body { background-color: #ffffff; color: #000; }")
// .replace("{link-color}", colorToHex(shiftColor(accentColor, true)))
// .replace("{link-color-active}", colorToHex(accentColor));
// webView.loadDataWithBaseURL(null, formatLodString, "text/html", KEY_UTF_8, null);
// } catch (Throwable e) {
// webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", KEY_UTF_8);
// }
// }
//
// private String colorToHex(int color) {
// return Integer.toHexString(color).substring(2);
// }
//
// private int shiftColor(int color, boolean up) {
// float[] hsv = new float[3];
// Color.colorToHSV(color, hsv);
// hsv[2] *= (up ? 1.1f : 0.9f); // value component
// return Color.HSVToColor(hsv);
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/presenter/view/ICustomDialog.java
// public interface ICustomDialog extends IBaseView {
// }
| import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.view.InflateException;
import android.view.LayoutInflater;
import android.view.View;
import com.yunq.gankio.GankApp;
import com.yunq.gankio.R;
import com.yunq.gankio.injection.component.DaggerFragmentComponent;
import com.yunq.gankio.injection.module.FragmentModule;
import com.yunq.gankio.presenter.CustomDialogPresenter;
import com.yunq.gankio.presenter.view.ICustomDialog;
import javax.inject.Inject; | package com.yunq.gankio.ui.fragment;
/**
* A simple {@link Fragment} subclass.
*/
public class CustomWebViewDialog extends DialogFragment implements ICustomDialog {
public static final String EXTRA_DIALOG_TITLE = "DIALOG_TITLE";
public static final String EXTRA_HTML_FILE_NAME = "HTML_FILE_NAME";
public static final String EXTRA_ACCENT_COLOR = "ACCENT_COLOR";
@Inject | // Path: app/src/main/java/com/yunq/gankio/GankApp.java
// public class GankApp extends Application {
//
// private RefWatcher refWatcher;
//
// ApplicationComponent mApplicationComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
// refWatcher = LeakCanary.install(this);
//
// if (BuildConfig.DEBUG) {
// //警告在主线程中执行耗时操作
// StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
// StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
//
// Timber.plant(new Timber.DebugTree());
// }
//
// }
//
// public static GankApp get(Context context) {
// return (GankApp) context.getApplicationContext();
// }
//
// public static RefWatcher getRefWatcher(Context context) {
// return ((GankApp) context.getApplicationContext()).refWatcher;
// }
//
// public ApplicationComponent getComponent() {
// if (mApplicationComponent == null) {
// mApplicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
// return mApplicationComponent;
// }
//
//
// }
//
// Path: app/src/main/java/com/yunq/gankio/injection/module/FragmentModule.java
// @Module
// public class FragmentModule {
// private final Fragment mFragment;
//
// public FragmentModule(Fragment fragment) {
// mFragment = fragment;
// }
//
// @Provides
// @com.yunq.gankio.injection.Fragment
// Context provideContext() {
// return mFragment.getActivity();
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/presenter/CustomDialogPresenter.java
// public class CustomDialogPresenter extends BasePresenter<ICustomDialog> {
//
//
// private static final String KEY_UTF_8 = "UTF-8";
//
// private Context mContext;
//
// @Inject
// public CustomDialogPresenter(Context context) {
// mContext = context;
// }
//
// public AlertDialog makeDialog(Fragment fragment, View customView) {
//
// String dialogTitle = fragment.getArguments().getString(CustomWebViewDialog.EXTRA_DIALOG_TITLE);
// String htmlFileName = fragment.getArguments().getString(CustomWebViewDialog.EXTRA_HTML_FILE_NAME);
// int accentColor = fragment.getArguments().getInt(CustomWebViewDialog.EXTRA_ACCENT_COLOR);
//
// final WebView webView = (WebView) customView.findViewById(R.id.webView);
// webView.getSettings().setDefaultTextEncodingName(KEY_UTF_8);
// loadData(webView, htmlFileName, accentColor);
//
// AlertDialog dialog = new AlertDialog.Builder(mContext)
// .setTitle(dialogTitle)
// .setView(customView)
// .setPositiveButton(android.R.string.ok, null)
// .show();
// return dialog;
// }
//
// private void loadData(WebView webView, String htmlFileName, int accentColor) {
// try {
// StringBuilder buf = new StringBuilder();
// InputStream json = mContext.getAssets().open(htmlFileName);
// BufferedReader in = new BufferedReader(new InputStreamReader(json, KEY_UTF_8));
// String str;
// while ((str = in.readLine()) != null)
// buf.append(str);
// in.close();
//
// String formatLodString = buf.toString()
// .replace("{style-placeholder}", "body { background-color: #ffffff; color: #000; }")
// .replace("{link-color}", colorToHex(shiftColor(accentColor, true)))
// .replace("{link-color-active}", colorToHex(accentColor));
// webView.loadDataWithBaseURL(null, formatLodString, "text/html", KEY_UTF_8, null);
// } catch (Throwable e) {
// webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", KEY_UTF_8);
// }
// }
//
// private String colorToHex(int color) {
// return Integer.toHexString(color).substring(2);
// }
//
// private int shiftColor(int color, boolean up) {
// float[] hsv = new float[3];
// Color.colorToHSV(color, hsv);
// hsv[2] *= (up ? 1.1f : 0.9f); // value component
// return Color.HSVToColor(hsv);
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/presenter/view/ICustomDialog.java
// public interface ICustomDialog extends IBaseView {
// }
// Path: app/src/main/java/com/yunq/gankio/ui/fragment/CustomWebViewDialog.java
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.view.InflateException;
import android.view.LayoutInflater;
import android.view.View;
import com.yunq.gankio.GankApp;
import com.yunq.gankio.R;
import com.yunq.gankio.injection.component.DaggerFragmentComponent;
import com.yunq.gankio.injection.module.FragmentModule;
import com.yunq.gankio.presenter.CustomDialogPresenter;
import com.yunq.gankio.presenter.view.ICustomDialog;
import javax.inject.Inject;
package com.yunq.gankio.ui.fragment;
/**
* A simple {@link Fragment} subclass.
*/
public class CustomWebViewDialog extends DialogFragment implements ICustomDialog {
public static final String EXTRA_DIALOG_TITLE = "DIALOG_TITLE";
public static final String EXTRA_HTML_FILE_NAME = "HTML_FILE_NAME";
public static final String EXTRA_ACCENT_COLOR = "ACCENT_COLOR";
@Inject | CustomDialogPresenter mPresenter; |
xuyunqiang/MeiziAPP | app/src/main/java/com/yunq/gankio/ui/fragment/CustomWebViewDialog.java | // Path: app/src/main/java/com/yunq/gankio/GankApp.java
// public class GankApp extends Application {
//
// private RefWatcher refWatcher;
//
// ApplicationComponent mApplicationComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
// refWatcher = LeakCanary.install(this);
//
// if (BuildConfig.DEBUG) {
// //警告在主线程中执行耗时操作
// StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
// StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
//
// Timber.plant(new Timber.DebugTree());
// }
//
// }
//
// public static GankApp get(Context context) {
// return (GankApp) context.getApplicationContext();
// }
//
// public static RefWatcher getRefWatcher(Context context) {
// return ((GankApp) context.getApplicationContext()).refWatcher;
// }
//
// public ApplicationComponent getComponent() {
// if (mApplicationComponent == null) {
// mApplicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
// return mApplicationComponent;
// }
//
//
// }
//
// Path: app/src/main/java/com/yunq/gankio/injection/module/FragmentModule.java
// @Module
// public class FragmentModule {
// private final Fragment mFragment;
//
// public FragmentModule(Fragment fragment) {
// mFragment = fragment;
// }
//
// @Provides
// @com.yunq.gankio.injection.Fragment
// Context provideContext() {
// return mFragment.getActivity();
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/presenter/CustomDialogPresenter.java
// public class CustomDialogPresenter extends BasePresenter<ICustomDialog> {
//
//
// private static final String KEY_UTF_8 = "UTF-8";
//
// private Context mContext;
//
// @Inject
// public CustomDialogPresenter(Context context) {
// mContext = context;
// }
//
// public AlertDialog makeDialog(Fragment fragment, View customView) {
//
// String dialogTitle = fragment.getArguments().getString(CustomWebViewDialog.EXTRA_DIALOG_TITLE);
// String htmlFileName = fragment.getArguments().getString(CustomWebViewDialog.EXTRA_HTML_FILE_NAME);
// int accentColor = fragment.getArguments().getInt(CustomWebViewDialog.EXTRA_ACCENT_COLOR);
//
// final WebView webView = (WebView) customView.findViewById(R.id.webView);
// webView.getSettings().setDefaultTextEncodingName(KEY_UTF_8);
// loadData(webView, htmlFileName, accentColor);
//
// AlertDialog dialog = new AlertDialog.Builder(mContext)
// .setTitle(dialogTitle)
// .setView(customView)
// .setPositiveButton(android.R.string.ok, null)
// .show();
// return dialog;
// }
//
// private void loadData(WebView webView, String htmlFileName, int accentColor) {
// try {
// StringBuilder buf = new StringBuilder();
// InputStream json = mContext.getAssets().open(htmlFileName);
// BufferedReader in = new BufferedReader(new InputStreamReader(json, KEY_UTF_8));
// String str;
// while ((str = in.readLine()) != null)
// buf.append(str);
// in.close();
//
// String formatLodString = buf.toString()
// .replace("{style-placeholder}", "body { background-color: #ffffff; color: #000; }")
// .replace("{link-color}", colorToHex(shiftColor(accentColor, true)))
// .replace("{link-color-active}", colorToHex(accentColor));
// webView.loadDataWithBaseURL(null, formatLodString, "text/html", KEY_UTF_8, null);
// } catch (Throwable e) {
// webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", KEY_UTF_8);
// }
// }
//
// private String colorToHex(int color) {
// return Integer.toHexString(color).substring(2);
// }
//
// private int shiftColor(int color, boolean up) {
// float[] hsv = new float[3];
// Color.colorToHSV(color, hsv);
// hsv[2] *= (up ? 1.1f : 0.9f); // value component
// return Color.HSVToColor(hsv);
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/presenter/view/ICustomDialog.java
// public interface ICustomDialog extends IBaseView {
// }
| import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.view.InflateException;
import android.view.LayoutInflater;
import android.view.View;
import com.yunq.gankio.GankApp;
import com.yunq.gankio.R;
import com.yunq.gankio.injection.component.DaggerFragmentComponent;
import com.yunq.gankio.injection.module.FragmentModule;
import com.yunq.gankio.presenter.CustomDialogPresenter;
import com.yunq.gankio.presenter.view.ICustomDialog;
import javax.inject.Inject; | package com.yunq.gankio.ui.fragment;
/**
* A simple {@link Fragment} subclass.
*/
public class CustomWebViewDialog extends DialogFragment implements ICustomDialog {
public static final String EXTRA_DIALOG_TITLE = "DIALOG_TITLE";
public static final String EXTRA_HTML_FILE_NAME = "HTML_FILE_NAME";
public static final String EXTRA_ACCENT_COLOR = "ACCENT_COLOR";
@Inject
CustomDialogPresenter mPresenter;
@Inject
Context mContext;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initInjection();
}
private void initInjection() {
DaggerFragmentComponent.builder() | // Path: app/src/main/java/com/yunq/gankio/GankApp.java
// public class GankApp extends Application {
//
// private RefWatcher refWatcher;
//
// ApplicationComponent mApplicationComponent;
//
// @Override
// public void onCreate() {
// super.onCreate();
// refWatcher = LeakCanary.install(this);
//
// if (BuildConfig.DEBUG) {
// //警告在主线程中执行耗时操作
// StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
// StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
//
// Timber.plant(new Timber.DebugTree());
// }
//
// }
//
// public static GankApp get(Context context) {
// return (GankApp) context.getApplicationContext();
// }
//
// public static RefWatcher getRefWatcher(Context context) {
// return ((GankApp) context.getApplicationContext()).refWatcher;
// }
//
// public ApplicationComponent getComponent() {
// if (mApplicationComponent == null) {
// mApplicationComponent = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
// }
// return mApplicationComponent;
// }
//
//
// }
//
// Path: app/src/main/java/com/yunq/gankio/injection/module/FragmentModule.java
// @Module
// public class FragmentModule {
// private final Fragment mFragment;
//
// public FragmentModule(Fragment fragment) {
// mFragment = fragment;
// }
//
// @Provides
// @com.yunq.gankio.injection.Fragment
// Context provideContext() {
// return mFragment.getActivity();
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/presenter/CustomDialogPresenter.java
// public class CustomDialogPresenter extends BasePresenter<ICustomDialog> {
//
//
// private static final String KEY_UTF_8 = "UTF-8";
//
// private Context mContext;
//
// @Inject
// public CustomDialogPresenter(Context context) {
// mContext = context;
// }
//
// public AlertDialog makeDialog(Fragment fragment, View customView) {
//
// String dialogTitle = fragment.getArguments().getString(CustomWebViewDialog.EXTRA_DIALOG_TITLE);
// String htmlFileName = fragment.getArguments().getString(CustomWebViewDialog.EXTRA_HTML_FILE_NAME);
// int accentColor = fragment.getArguments().getInt(CustomWebViewDialog.EXTRA_ACCENT_COLOR);
//
// final WebView webView = (WebView) customView.findViewById(R.id.webView);
// webView.getSettings().setDefaultTextEncodingName(KEY_UTF_8);
// loadData(webView, htmlFileName, accentColor);
//
// AlertDialog dialog = new AlertDialog.Builder(mContext)
// .setTitle(dialogTitle)
// .setView(customView)
// .setPositiveButton(android.R.string.ok, null)
// .show();
// return dialog;
// }
//
// private void loadData(WebView webView, String htmlFileName, int accentColor) {
// try {
// StringBuilder buf = new StringBuilder();
// InputStream json = mContext.getAssets().open(htmlFileName);
// BufferedReader in = new BufferedReader(new InputStreamReader(json, KEY_UTF_8));
// String str;
// while ((str = in.readLine()) != null)
// buf.append(str);
// in.close();
//
// String formatLodString = buf.toString()
// .replace("{style-placeholder}", "body { background-color: #ffffff; color: #000; }")
// .replace("{link-color}", colorToHex(shiftColor(accentColor, true)))
// .replace("{link-color-active}", colorToHex(accentColor));
// webView.loadDataWithBaseURL(null, formatLodString, "text/html", KEY_UTF_8, null);
// } catch (Throwable e) {
// webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", KEY_UTF_8);
// }
// }
//
// private String colorToHex(int color) {
// return Integer.toHexString(color).substring(2);
// }
//
// private int shiftColor(int color, boolean up) {
// float[] hsv = new float[3];
// Color.colorToHSV(color, hsv);
// hsv[2] *= (up ? 1.1f : 0.9f); // value component
// return Color.HSVToColor(hsv);
// }
// }
//
// Path: app/src/main/java/com/yunq/gankio/presenter/view/ICustomDialog.java
// public interface ICustomDialog extends IBaseView {
// }
// Path: app/src/main/java/com/yunq/gankio/ui/fragment/CustomWebViewDialog.java
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.view.InflateException;
import android.view.LayoutInflater;
import android.view.View;
import com.yunq.gankio.GankApp;
import com.yunq.gankio.R;
import com.yunq.gankio.injection.component.DaggerFragmentComponent;
import com.yunq.gankio.injection.module.FragmentModule;
import com.yunq.gankio.presenter.CustomDialogPresenter;
import com.yunq.gankio.presenter.view.ICustomDialog;
import javax.inject.Inject;
package com.yunq.gankio.ui.fragment;
/**
* A simple {@link Fragment} subclass.
*/
public class CustomWebViewDialog extends DialogFragment implements ICustomDialog {
public static final String EXTRA_DIALOG_TITLE = "DIALOG_TITLE";
public static final String EXTRA_HTML_FILE_NAME = "HTML_FILE_NAME";
public static final String EXTRA_ACCENT_COLOR = "ACCENT_COLOR";
@Inject
CustomDialogPresenter mPresenter;
@Inject
Context mContext;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initInjection();
}
private void initInjection() {
DaggerFragmentComponent.builder() | .fragmentModule(new FragmentModule(this)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.