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 |
|---|---|---|---|---|---|---|
jacobhyphenated/PokerServer | src/main/java/com/hyphenated/card/eval/HandRank.java | // Path: src/main/java/com/hyphenated/card/HandType.java
// public enum HandType {
// BAD,
// HIGH_CARD,
// PAIR,
// TWO_PAIR,
// THREE_OF_A_KIND,
// STRAIGHT,
// FLUSH,
// FULL_HOUSE,
// FOUR_OF_A_KIND,
// STRAIGHT_FLUSH;
// }
| import java.io.Serializable;
import com.hyphenated.card.HandType;
| /*
The MIT License (MIT)
Copyright (c) 2013 Jacob Kanipe-Illig
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package com.hyphenated.card.eval;
/**
* Representation of the poker hand strength.
*/
public class HandRank implements Comparable<HandRank>, Serializable {
private static final long serialVersionUID = 6897360347770643227L;
private final int rankValue;
public HandRank(int rankValue) {
super();
this.rankValue = rankValue;
}
/**
* Compares the strength of the hand (the values of the ranks).
*
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public final int compareTo(HandRank rank) {
return rankValue < rank.rankValue ? -1
: (rankValue == rank.rankValue ? 0 : 1);
}
@Override
public final int hashCode() {
return rankValue;
}
@Override
public final boolean equals(Object obj) {
return (obj instanceof HandRank)
&& (rankValue == ((HandRank) obj).rankValue);
}
public final int getValue() {
return rankValue;
}
/**
* The type of hand as represented by {@link HandType}
* @return {@link HandType}
*/
| // Path: src/main/java/com/hyphenated/card/HandType.java
// public enum HandType {
// BAD,
// HIGH_CARD,
// PAIR,
// TWO_PAIR,
// THREE_OF_A_KIND,
// STRAIGHT,
// FLUSH,
// FULL_HOUSE,
// FOUR_OF_A_KIND,
// STRAIGHT_FLUSH;
// }
// Path: src/main/java/com/hyphenated/card/eval/HandRank.java
import java.io.Serializable;
import com.hyphenated.card.HandType;
/*
The MIT License (MIT)
Copyright (c) 2013 Jacob Kanipe-Illig
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package com.hyphenated.card.eval;
/**
* Representation of the poker hand strength.
*/
public class HandRank implements Comparable<HandRank>, Serializable {
private static final long serialVersionUID = 6897360347770643227L;
private final int rankValue;
public HandRank(int rankValue) {
super();
this.rankValue = rankValue;
}
/**
* Compares the strength of the hand (the values of the ranks).
*
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public final int compareTo(HandRank rank) {
return rankValue < rank.rankValue ? -1
: (rankValue == rank.rankValue ? 0 : 1);
}
@Override
public final int hashCode() {
return rankValue;
}
@Override
public final boolean equals(Object obj) {
return (obj instanceof HandRank)
&& (rankValue == ((HandRank) obj).rankValue);
}
public final int getValue() {
return rankValue;
}
/**
* The type of hand as represented by {@link HandType}
* @return {@link HandType}
*/
| public HandType getHandType(){
|
vivlabs/log6j | src/java/com/spinn3r/log5j/LogUtils.java | // Path: src/java/com/spinn3r/tracepoint/Tracepoint.java
// public class Tracepoint {
//
// StringBuffer buff = new StringBuffer();
//
// public Tracepoint( Object... args ) {
//
// init( Thread.currentThread().getStackTrace(), null, args );
//
// }
//
// public Tracepoint( Throwable t , Object... args ) {
//
// init( t.getStackTrace(), t, args );
// }
//
// private void init( StackTraceElement[] frames, Throwable throwable, Object... args ) {
//
// int offset = 2;
//
// if ( throwable != null ) {
// offset = 0;
// }
//
// for( int i = offset; i < frames.length; ++i ) {
//
// StackTraceElement frame = frames[i];
//
// buff.append( "\t" );
// buff.append( frame.toString() );
// buff.append( "\n" );
//
// }
//
// String stacktrace = buff.toString();
//
// buff = new StringBuffer();
//
// String tp = Hex.encode( MD5.encode( stacktrace ) );
//
// buff.append( String.format( "Exception tracepoint: %s", tp ) );
//
// if ( args.length != 0 )
// buff.append( " (" );
//
// for( int i = 0; i < args.length; i=i + 2 ) {
//
// if ( i != 0 )
// buff.append( ", " );
//
// buff.append( String.format( "%s = %s", args[i], args[i + 1] ) );
// }
//
// if ( args.length != 0 )
// buff.append( ")" );
//
// buff.append( "\n" );
//
// if ( throwable != null ) {
//
// if ( throwable.getMessage() != null ) {
// buff.append( String.format( "%s:%s\n", throwable.getClass().getName(), throwable.getMessage() ) );
// } else {
// buff.append( String.format( "%s\n", throwable.getClass().getName() ) );
// }
//
// }
//
// buff.append( stacktrace );
//
// }
//
// public String toString() {
// return buff.toString();
// }
//
// }
| import java.io.ByteArrayOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.charset.Charset;
import java.util.Date;
import com.spinn3r.tracepoint.Tracepoint; | /*
* Copyright 2010 "Tailrank, Inc (Spinn3r)"
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.spinn3r.log5j;
public class LogUtils {
private static final Charset UTF8 = Charset.forName("UTF-8");
public static String toString(LogEvent logEvent) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(
new OutputStreamWriter(baos, UTF8));
writer.append(logEvent.level().name());
writer.append(" [");
writer.append(new Date(logEvent.time()).toString());
writer.append("]: ");
writer.append(logEvent.threadName());
writer.append(" > ");
writer.append(logEvent.logName());
writer.append(" - ");
writer.append(logEvent.message());
if (logEvent.throwable() != null) {
writer.append('\n');
| // Path: src/java/com/spinn3r/tracepoint/Tracepoint.java
// public class Tracepoint {
//
// StringBuffer buff = new StringBuffer();
//
// public Tracepoint( Object... args ) {
//
// init( Thread.currentThread().getStackTrace(), null, args );
//
// }
//
// public Tracepoint( Throwable t , Object... args ) {
//
// init( t.getStackTrace(), t, args );
// }
//
// private void init( StackTraceElement[] frames, Throwable throwable, Object... args ) {
//
// int offset = 2;
//
// if ( throwable != null ) {
// offset = 0;
// }
//
// for( int i = offset; i < frames.length; ++i ) {
//
// StackTraceElement frame = frames[i];
//
// buff.append( "\t" );
// buff.append( frame.toString() );
// buff.append( "\n" );
//
// }
//
// String stacktrace = buff.toString();
//
// buff = new StringBuffer();
//
// String tp = Hex.encode( MD5.encode( stacktrace ) );
//
// buff.append( String.format( "Exception tracepoint: %s", tp ) );
//
// if ( args.length != 0 )
// buff.append( " (" );
//
// for( int i = 0; i < args.length; i=i + 2 ) {
//
// if ( i != 0 )
// buff.append( ", " );
//
// buff.append( String.format( "%s = %s", args[i], args[i + 1] ) );
// }
//
// if ( args.length != 0 )
// buff.append( ")" );
//
// buff.append( "\n" );
//
// if ( throwable != null ) {
//
// if ( throwable.getMessage() != null ) {
// buff.append( String.format( "%s:%s\n", throwable.getClass().getName(), throwable.getMessage() ) );
// } else {
// buff.append( String.format( "%s\n", throwable.getClass().getName() ) );
// }
//
// }
//
// buff.append( stacktrace );
//
// }
//
// public String toString() {
// return buff.toString();
// }
//
// }
// Path: src/java/com/spinn3r/log5j/LogUtils.java
import java.io.ByteArrayOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.charset.Charset;
import java.util.Date;
import com.spinn3r.tracepoint.Tracepoint;
/*
* Copyright 2010 "Tailrank, Inc (Spinn3r)"
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.spinn3r.log5j;
public class LogUtils {
private static final Charset UTF8 = Charset.forName("UTF-8");
public static String toString(LogEvent logEvent) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(
new OutputStreamWriter(baos, UTF8));
writer.append(logEvent.level().name());
writer.append(" [");
writer.append(new Date(logEvent.time()).toString());
writer.append("]: ");
writer.append(logEvent.threadName());
writer.append(" > ");
writer.append(logEvent.logName());
writer.append(" - ");
writer.append(logEvent.message());
if (logEvent.throwable() != null) {
writer.append('\n');
| Tracepoint tp = new Tracepoint( logEvent.throwable() ); |
vivlabs/log6j | tst/java/com/spinn3r/log5j/formatter/MessageFormatterFactoryTest.java | // Path: src/java/com/spinn3r/log5j/Log.java
// public interface Log {
// boolean enabled(LogLevel level);
//
// void t(String formatMessage, Object... formatParams);
//
// void t(Throwable t, String formatMessage, Object... formatParams);
//
// void d(String formatMessage, Object... formatParams);
//
// void d(Throwable t, String formatMessage, Object... formatParams);
//
// void i(String formatMessage, Object... formatParams);
//
// void i(Throwable t, String formatMessage, Object... formatParams);
//
// void w(String formatMessage, Object... formatParams);
//
// void w(Throwable t, String formatMessage, Object... formatParams);
//
// void e(String formatMessage, Object... formatParams);
//
// void e(Throwable t, String formatMessage, Object... formatParams);
//
// void f(String formatMessage, Object... formatParams);
//
// void f(Throwable t, String formatMessage, Object... formatParams);
// }
//
// Path: src/java/com/spinn3r/log5j/LogFactory.java
// public class LogFactory {
// public static Log getLog(Class clazz) {
// return getLog(clazz, true);
// }
//
// public static Log getLog(Class clazz, boolean async) {
// return getLog(clazz.getName(), async);
// }
//
// public static Log getLog() {
// return getLog(getCallerClassName(), true);
// }
//
// public static Log getLog(boolean async) {
// return getLog(getCallerClassName(), async);
// }
//
// public static Log getLog(String name) {
// return getLog(name, true);
// }
//
// public static Log getLog(String name, boolean async) {
// return new LogImpl(name, async, LogManager.createInternalLogger(name));
// }
//
//
// private static String getCallerClassName() {
// return new Exception().getStackTrace()[2].getClassName();
// }
//
// }
| import com.spinn3r.log5j.Log;
import com.spinn3r.log5j.LogFactory;
import org.junit.Test;
import static org.junit.Assert.assertEquals; | package com.spinn3r.log5j.formatter;
/**
* User: Denis Tarima
* Date: Jun 4, 2010
*/
public class MessageFormatterFactoryTest {
static String __lastFormat;
static Object[] __lastArgs;
public static class TstMessageFormatterFactory implements MessageFormatterFactory {
public MessageFormatter create() {
return new MessageFormatter() {
public String format(String format, Object... args) {
__lastFormat = format;
__lastArgs = args;
return format;
}
};
}
}
public static void main(String[] args) throws Exception {
// customFormatter
System.setProperty("log5j.formatter.factory",
TstMessageFormatterFactory.class.getName());
| // Path: src/java/com/spinn3r/log5j/Log.java
// public interface Log {
// boolean enabled(LogLevel level);
//
// void t(String formatMessage, Object... formatParams);
//
// void t(Throwable t, String formatMessage, Object... formatParams);
//
// void d(String formatMessage, Object... formatParams);
//
// void d(Throwable t, String formatMessage, Object... formatParams);
//
// void i(String formatMessage, Object... formatParams);
//
// void i(Throwable t, String formatMessage, Object... formatParams);
//
// void w(String formatMessage, Object... formatParams);
//
// void w(Throwable t, String formatMessage, Object... formatParams);
//
// void e(String formatMessage, Object... formatParams);
//
// void e(Throwable t, String formatMessage, Object... formatParams);
//
// void f(String formatMessage, Object... formatParams);
//
// void f(Throwable t, String formatMessage, Object... formatParams);
// }
//
// Path: src/java/com/spinn3r/log5j/LogFactory.java
// public class LogFactory {
// public static Log getLog(Class clazz) {
// return getLog(clazz, true);
// }
//
// public static Log getLog(Class clazz, boolean async) {
// return getLog(clazz.getName(), async);
// }
//
// public static Log getLog() {
// return getLog(getCallerClassName(), true);
// }
//
// public static Log getLog(boolean async) {
// return getLog(getCallerClassName(), async);
// }
//
// public static Log getLog(String name) {
// return getLog(name, true);
// }
//
// public static Log getLog(String name, boolean async) {
// return new LogImpl(name, async, LogManager.createInternalLogger(name));
// }
//
//
// private static String getCallerClassName() {
// return new Exception().getStackTrace()[2].getClassName();
// }
//
// }
// Path: tst/java/com/spinn3r/log5j/formatter/MessageFormatterFactoryTest.java
import com.spinn3r.log5j.Log;
import com.spinn3r.log5j.LogFactory;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
package com.spinn3r.log5j.formatter;
/**
* User: Denis Tarima
* Date: Jun 4, 2010
*/
public class MessageFormatterFactoryTest {
static String __lastFormat;
static Object[] __lastArgs;
public static class TstMessageFormatterFactory implements MessageFormatterFactory {
public MessageFormatter create() {
return new MessageFormatter() {
public String format(String format, Object... args) {
__lastFormat = format;
__lastArgs = args;
return format;
}
};
}
}
public static void main(String[] args) throws Exception {
// customFormatter
System.setProperty("log5j.formatter.factory",
TstMessageFormatterFactory.class.getName());
| Log log = LogFactory.getLog(false); |
vivlabs/log6j | tst/java/com/spinn3r/log5j/formatter/MessageFormatterFactoryTest.java | // Path: src/java/com/spinn3r/log5j/Log.java
// public interface Log {
// boolean enabled(LogLevel level);
//
// void t(String formatMessage, Object... formatParams);
//
// void t(Throwable t, String formatMessage, Object... formatParams);
//
// void d(String formatMessage, Object... formatParams);
//
// void d(Throwable t, String formatMessage, Object... formatParams);
//
// void i(String formatMessage, Object... formatParams);
//
// void i(Throwable t, String formatMessage, Object... formatParams);
//
// void w(String formatMessage, Object... formatParams);
//
// void w(Throwable t, String formatMessage, Object... formatParams);
//
// void e(String formatMessage, Object... formatParams);
//
// void e(Throwable t, String formatMessage, Object... formatParams);
//
// void f(String formatMessage, Object... formatParams);
//
// void f(Throwable t, String formatMessage, Object... formatParams);
// }
//
// Path: src/java/com/spinn3r/log5j/LogFactory.java
// public class LogFactory {
// public static Log getLog(Class clazz) {
// return getLog(clazz, true);
// }
//
// public static Log getLog(Class clazz, boolean async) {
// return getLog(clazz.getName(), async);
// }
//
// public static Log getLog() {
// return getLog(getCallerClassName(), true);
// }
//
// public static Log getLog(boolean async) {
// return getLog(getCallerClassName(), async);
// }
//
// public static Log getLog(String name) {
// return getLog(name, true);
// }
//
// public static Log getLog(String name, boolean async) {
// return new LogImpl(name, async, LogManager.createInternalLogger(name));
// }
//
//
// private static String getCallerClassName() {
// return new Exception().getStackTrace()[2].getClassName();
// }
//
// }
| import com.spinn3r.log5j.Log;
import com.spinn3r.log5j.LogFactory;
import org.junit.Test;
import static org.junit.Assert.assertEquals; | package com.spinn3r.log5j.formatter;
/**
* User: Denis Tarima
* Date: Jun 4, 2010
*/
public class MessageFormatterFactoryTest {
static String __lastFormat;
static Object[] __lastArgs;
public static class TstMessageFormatterFactory implements MessageFormatterFactory {
public MessageFormatter create() {
return new MessageFormatter() {
public String format(String format, Object... args) {
__lastFormat = format;
__lastArgs = args;
return format;
}
};
}
}
public static void main(String[] args) throws Exception {
// customFormatter
System.setProperty("log5j.formatter.factory",
TstMessageFormatterFactory.class.getName());
| // Path: src/java/com/spinn3r/log5j/Log.java
// public interface Log {
// boolean enabled(LogLevel level);
//
// void t(String formatMessage, Object... formatParams);
//
// void t(Throwable t, String formatMessage, Object... formatParams);
//
// void d(String formatMessage, Object... formatParams);
//
// void d(Throwable t, String formatMessage, Object... formatParams);
//
// void i(String formatMessage, Object... formatParams);
//
// void i(Throwable t, String formatMessage, Object... formatParams);
//
// void w(String formatMessage, Object... formatParams);
//
// void w(Throwable t, String formatMessage, Object... formatParams);
//
// void e(String formatMessage, Object... formatParams);
//
// void e(Throwable t, String formatMessage, Object... formatParams);
//
// void f(String formatMessage, Object... formatParams);
//
// void f(Throwable t, String formatMessage, Object... formatParams);
// }
//
// Path: src/java/com/spinn3r/log5j/LogFactory.java
// public class LogFactory {
// public static Log getLog(Class clazz) {
// return getLog(clazz, true);
// }
//
// public static Log getLog(Class clazz, boolean async) {
// return getLog(clazz.getName(), async);
// }
//
// public static Log getLog() {
// return getLog(getCallerClassName(), true);
// }
//
// public static Log getLog(boolean async) {
// return getLog(getCallerClassName(), async);
// }
//
// public static Log getLog(String name) {
// return getLog(name, true);
// }
//
// public static Log getLog(String name, boolean async) {
// return new LogImpl(name, async, LogManager.createInternalLogger(name));
// }
//
//
// private static String getCallerClassName() {
// return new Exception().getStackTrace()[2].getClassName();
// }
//
// }
// Path: tst/java/com/spinn3r/log5j/formatter/MessageFormatterFactoryTest.java
import com.spinn3r.log5j.Log;
import com.spinn3r.log5j.LogFactory;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
package com.spinn3r.log5j.formatter;
/**
* User: Denis Tarima
* Date: Jun 4, 2010
*/
public class MessageFormatterFactoryTest {
static String __lastFormat;
static Object[] __lastArgs;
public static class TstMessageFormatterFactory implements MessageFormatterFactory {
public MessageFormatter create() {
return new MessageFormatter() {
public String format(String format, Object... args) {
__lastFormat = format;
__lastArgs = args;
return format;
}
};
}
}
public static void main(String[] args) throws Exception {
// customFormatter
System.setProperty("log5j.formatter.factory",
TstMessageFormatterFactory.class.getName());
| Log log = LogFactory.getLog(false); |
vivlabs/log6j | src/java/com/spinn3r/log5j/LogManager.java | // Path: src/java/com/spinn3r/log5j/factories/StdoutInternalLoggerFactory.java
// public class StdoutInternalLoggerFactory implements InternalLoggerFactory {
// private static final InternalLogger LOGGER = new InternalLogger() {
// public boolean isEnabled(LogLevel level) {
// return true;
// }
//
// public void log(LogEvent logEvent) {
// System.out.println(LogUtils.toString(logEvent));
// }
// };
//
// public InternalLogger create(String logName) {
// return LOGGER;
// }
//
// public void shutdown() {
// // do nothing
// }
// }
//
// Path: src/java/com/spinn3r/log5j/formatter/DefaultMessageFormatterFactory.java
// public class DefaultMessageFormatterFactory implements MessageFormatterFactory {
//
// private static final String __prefix = "log5j.formatter.default.";
//
// private final Locale _locale;
//
// public DefaultMessageFormatterFactory() {
// String language = System.getProperty(__prefix + "language", null);
// String country = System.getProperty(__prefix + "country", null);
// String variant = System.getProperty(__prefix + "variant", null);
//
// if (variant != null) {
// _locale = new Locale(language, country, variant);
// } else if (country != null) {
// _locale = new Locale(language, country);
// } else if (language != null) {
// _locale = new Locale(language);
// } else {
// _locale = Locale.getDefault();
// }
// }
//
// public MessageFormatter create() {
// return new DefaultMessageFormatter(_locale);
// }
// }
//
// Path: src/java/com/spinn3r/log5j/formatter/MessageFormatterFactory.java
// public interface MessageFormatterFactory {
// MessageFormatter create();
// }
| import com.spinn3r.log5j.factories.StdoutInternalLoggerFactory;
import com.spinn3r.log5j.formatter.DefaultMessageFormatterFactory;
import com.spinn3r.log5j.formatter.MessageFormatterFactory; | /*
* Copyright 2010 "Tailrank, Inc (Spinn3r)"
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.spinn3r.log5j;
public class LogManager {
private static final AsyncLogger __asyncLogger = new AsyncLogger();
private static InternalLoggerFactory __internalLoggerFactory;
| // Path: src/java/com/spinn3r/log5j/factories/StdoutInternalLoggerFactory.java
// public class StdoutInternalLoggerFactory implements InternalLoggerFactory {
// private static final InternalLogger LOGGER = new InternalLogger() {
// public boolean isEnabled(LogLevel level) {
// return true;
// }
//
// public void log(LogEvent logEvent) {
// System.out.println(LogUtils.toString(logEvent));
// }
// };
//
// public InternalLogger create(String logName) {
// return LOGGER;
// }
//
// public void shutdown() {
// // do nothing
// }
// }
//
// Path: src/java/com/spinn3r/log5j/formatter/DefaultMessageFormatterFactory.java
// public class DefaultMessageFormatterFactory implements MessageFormatterFactory {
//
// private static final String __prefix = "log5j.formatter.default.";
//
// private final Locale _locale;
//
// public DefaultMessageFormatterFactory() {
// String language = System.getProperty(__prefix + "language", null);
// String country = System.getProperty(__prefix + "country", null);
// String variant = System.getProperty(__prefix + "variant", null);
//
// if (variant != null) {
// _locale = new Locale(language, country, variant);
// } else if (country != null) {
// _locale = new Locale(language, country);
// } else if (language != null) {
// _locale = new Locale(language);
// } else {
// _locale = Locale.getDefault();
// }
// }
//
// public MessageFormatter create() {
// return new DefaultMessageFormatter(_locale);
// }
// }
//
// Path: src/java/com/spinn3r/log5j/formatter/MessageFormatterFactory.java
// public interface MessageFormatterFactory {
// MessageFormatter create();
// }
// Path: src/java/com/spinn3r/log5j/LogManager.java
import com.spinn3r.log5j.factories.StdoutInternalLoggerFactory;
import com.spinn3r.log5j.formatter.DefaultMessageFormatterFactory;
import com.spinn3r.log5j.formatter.MessageFormatterFactory;
/*
* Copyright 2010 "Tailrank, Inc (Spinn3r)"
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.spinn3r.log5j;
public class LogManager {
private static final AsyncLogger __asyncLogger = new AsyncLogger();
private static InternalLoggerFactory __internalLoggerFactory;
| static MessageFormatterFactory __messageFormatterFactory; |
vivlabs/log6j | src/java/com/spinn3r/log5j/LogManager.java | // Path: src/java/com/spinn3r/log5j/factories/StdoutInternalLoggerFactory.java
// public class StdoutInternalLoggerFactory implements InternalLoggerFactory {
// private static final InternalLogger LOGGER = new InternalLogger() {
// public boolean isEnabled(LogLevel level) {
// return true;
// }
//
// public void log(LogEvent logEvent) {
// System.out.println(LogUtils.toString(logEvent));
// }
// };
//
// public InternalLogger create(String logName) {
// return LOGGER;
// }
//
// public void shutdown() {
// // do nothing
// }
// }
//
// Path: src/java/com/spinn3r/log5j/formatter/DefaultMessageFormatterFactory.java
// public class DefaultMessageFormatterFactory implements MessageFormatterFactory {
//
// private static final String __prefix = "log5j.formatter.default.";
//
// private final Locale _locale;
//
// public DefaultMessageFormatterFactory() {
// String language = System.getProperty(__prefix + "language", null);
// String country = System.getProperty(__prefix + "country", null);
// String variant = System.getProperty(__prefix + "variant", null);
//
// if (variant != null) {
// _locale = new Locale(language, country, variant);
// } else if (country != null) {
// _locale = new Locale(language, country);
// } else if (language != null) {
// _locale = new Locale(language);
// } else {
// _locale = Locale.getDefault();
// }
// }
//
// public MessageFormatter create() {
// return new DefaultMessageFormatter(_locale);
// }
// }
//
// Path: src/java/com/spinn3r/log5j/formatter/MessageFormatterFactory.java
// public interface MessageFormatterFactory {
// MessageFormatter create();
// }
| import com.spinn3r.log5j.factories.StdoutInternalLoggerFactory;
import com.spinn3r.log5j.formatter.DefaultMessageFormatterFactory;
import com.spinn3r.log5j.formatter.MessageFormatterFactory; | /*
* Copyright 2010 "Tailrank, Inc (Spinn3r)"
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.spinn3r.log5j;
public class LogManager {
private static final AsyncLogger __asyncLogger = new AsyncLogger();
private static InternalLoggerFactory __internalLoggerFactory;
static MessageFormatterFactory __messageFormatterFactory;
private static volatile boolean _disableShutdownHook = false;
private static volatile boolean _shuttingDown = false;
static {
try {
Class<?> clazz = Class.forName(Settings.get().getFactoryClass());
__internalLoggerFactory = (InternalLoggerFactory) clazz.newInstance();
} catch (Throwable e) {
System.err.println("Cannot initialize internal logger factory:");
e.printStackTrace(); | // Path: src/java/com/spinn3r/log5j/factories/StdoutInternalLoggerFactory.java
// public class StdoutInternalLoggerFactory implements InternalLoggerFactory {
// private static final InternalLogger LOGGER = new InternalLogger() {
// public boolean isEnabled(LogLevel level) {
// return true;
// }
//
// public void log(LogEvent logEvent) {
// System.out.println(LogUtils.toString(logEvent));
// }
// };
//
// public InternalLogger create(String logName) {
// return LOGGER;
// }
//
// public void shutdown() {
// // do nothing
// }
// }
//
// Path: src/java/com/spinn3r/log5j/formatter/DefaultMessageFormatterFactory.java
// public class DefaultMessageFormatterFactory implements MessageFormatterFactory {
//
// private static final String __prefix = "log5j.formatter.default.";
//
// private final Locale _locale;
//
// public DefaultMessageFormatterFactory() {
// String language = System.getProperty(__prefix + "language", null);
// String country = System.getProperty(__prefix + "country", null);
// String variant = System.getProperty(__prefix + "variant", null);
//
// if (variant != null) {
// _locale = new Locale(language, country, variant);
// } else if (country != null) {
// _locale = new Locale(language, country);
// } else if (language != null) {
// _locale = new Locale(language);
// } else {
// _locale = Locale.getDefault();
// }
// }
//
// public MessageFormatter create() {
// return new DefaultMessageFormatter(_locale);
// }
// }
//
// Path: src/java/com/spinn3r/log5j/formatter/MessageFormatterFactory.java
// public interface MessageFormatterFactory {
// MessageFormatter create();
// }
// Path: src/java/com/spinn3r/log5j/LogManager.java
import com.spinn3r.log5j.factories.StdoutInternalLoggerFactory;
import com.spinn3r.log5j.formatter.DefaultMessageFormatterFactory;
import com.spinn3r.log5j.formatter.MessageFormatterFactory;
/*
* Copyright 2010 "Tailrank, Inc (Spinn3r)"
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.spinn3r.log5j;
public class LogManager {
private static final AsyncLogger __asyncLogger = new AsyncLogger();
private static InternalLoggerFactory __internalLoggerFactory;
static MessageFormatterFactory __messageFormatterFactory;
private static volatile boolean _disableShutdownHook = false;
private static volatile boolean _shuttingDown = false;
static {
try {
Class<?> clazz = Class.forName(Settings.get().getFactoryClass());
__internalLoggerFactory = (InternalLoggerFactory) clazz.newInstance();
} catch (Throwable e) {
System.err.println("Cannot initialize internal logger factory:");
e.printStackTrace(); | __internalLoggerFactory = new StdoutInternalLoggerFactory(); |
vivlabs/log6j | src/java/com/spinn3r/log5j/LogManager.java | // Path: src/java/com/spinn3r/log5j/factories/StdoutInternalLoggerFactory.java
// public class StdoutInternalLoggerFactory implements InternalLoggerFactory {
// private static final InternalLogger LOGGER = new InternalLogger() {
// public boolean isEnabled(LogLevel level) {
// return true;
// }
//
// public void log(LogEvent logEvent) {
// System.out.println(LogUtils.toString(logEvent));
// }
// };
//
// public InternalLogger create(String logName) {
// return LOGGER;
// }
//
// public void shutdown() {
// // do nothing
// }
// }
//
// Path: src/java/com/spinn3r/log5j/formatter/DefaultMessageFormatterFactory.java
// public class DefaultMessageFormatterFactory implements MessageFormatterFactory {
//
// private static final String __prefix = "log5j.formatter.default.";
//
// private final Locale _locale;
//
// public DefaultMessageFormatterFactory() {
// String language = System.getProperty(__prefix + "language", null);
// String country = System.getProperty(__prefix + "country", null);
// String variant = System.getProperty(__prefix + "variant", null);
//
// if (variant != null) {
// _locale = new Locale(language, country, variant);
// } else if (country != null) {
// _locale = new Locale(language, country);
// } else if (language != null) {
// _locale = new Locale(language);
// } else {
// _locale = Locale.getDefault();
// }
// }
//
// public MessageFormatter create() {
// return new DefaultMessageFormatter(_locale);
// }
// }
//
// Path: src/java/com/spinn3r/log5j/formatter/MessageFormatterFactory.java
// public interface MessageFormatterFactory {
// MessageFormatter create();
// }
| import com.spinn3r.log5j.factories.StdoutInternalLoggerFactory;
import com.spinn3r.log5j.formatter.DefaultMessageFormatterFactory;
import com.spinn3r.log5j.formatter.MessageFormatterFactory; | /*
* Copyright 2010 "Tailrank, Inc (Spinn3r)"
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.spinn3r.log5j;
public class LogManager {
private static final AsyncLogger __asyncLogger = new AsyncLogger();
private static InternalLoggerFactory __internalLoggerFactory;
static MessageFormatterFactory __messageFormatterFactory;
private static volatile boolean _disableShutdownHook = false;
private static volatile boolean _shuttingDown = false;
static {
try {
Class<?> clazz = Class.forName(Settings.get().getFactoryClass());
__internalLoggerFactory = (InternalLoggerFactory) clazz.newInstance();
} catch (Throwable e) {
System.err.println("Cannot initialize internal logger factory:");
e.printStackTrace();
__internalLoggerFactory = new StdoutInternalLoggerFactory();
}
try {
Class<?> clazz = Class.forName(Settings.get().getFormatterFactoryClass());
__messageFormatterFactory = (MessageFormatterFactory) clazz.newInstance();
} catch (Throwable e) {
System.err.println("Cannot initialize message formatter factory:");
e.printStackTrace(); | // Path: src/java/com/spinn3r/log5j/factories/StdoutInternalLoggerFactory.java
// public class StdoutInternalLoggerFactory implements InternalLoggerFactory {
// private static final InternalLogger LOGGER = new InternalLogger() {
// public boolean isEnabled(LogLevel level) {
// return true;
// }
//
// public void log(LogEvent logEvent) {
// System.out.println(LogUtils.toString(logEvent));
// }
// };
//
// public InternalLogger create(String logName) {
// return LOGGER;
// }
//
// public void shutdown() {
// // do nothing
// }
// }
//
// Path: src/java/com/spinn3r/log5j/formatter/DefaultMessageFormatterFactory.java
// public class DefaultMessageFormatterFactory implements MessageFormatterFactory {
//
// private static final String __prefix = "log5j.formatter.default.";
//
// private final Locale _locale;
//
// public DefaultMessageFormatterFactory() {
// String language = System.getProperty(__prefix + "language", null);
// String country = System.getProperty(__prefix + "country", null);
// String variant = System.getProperty(__prefix + "variant", null);
//
// if (variant != null) {
// _locale = new Locale(language, country, variant);
// } else if (country != null) {
// _locale = new Locale(language, country);
// } else if (language != null) {
// _locale = new Locale(language);
// } else {
// _locale = Locale.getDefault();
// }
// }
//
// public MessageFormatter create() {
// return new DefaultMessageFormatter(_locale);
// }
// }
//
// Path: src/java/com/spinn3r/log5j/formatter/MessageFormatterFactory.java
// public interface MessageFormatterFactory {
// MessageFormatter create();
// }
// Path: src/java/com/spinn3r/log5j/LogManager.java
import com.spinn3r.log5j.factories.StdoutInternalLoggerFactory;
import com.spinn3r.log5j.formatter.DefaultMessageFormatterFactory;
import com.spinn3r.log5j.formatter.MessageFormatterFactory;
/*
* Copyright 2010 "Tailrank, Inc (Spinn3r)"
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.spinn3r.log5j;
public class LogManager {
private static final AsyncLogger __asyncLogger = new AsyncLogger();
private static InternalLoggerFactory __internalLoggerFactory;
static MessageFormatterFactory __messageFormatterFactory;
private static volatile boolean _disableShutdownHook = false;
private static volatile boolean _shuttingDown = false;
static {
try {
Class<?> clazz = Class.forName(Settings.get().getFactoryClass());
__internalLoggerFactory = (InternalLoggerFactory) clazz.newInstance();
} catch (Throwable e) {
System.err.println("Cannot initialize internal logger factory:");
e.printStackTrace();
__internalLoggerFactory = new StdoutInternalLoggerFactory();
}
try {
Class<?> clazz = Class.forName(Settings.get().getFormatterFactoryClass());
__messageFormatterFactory = (MessageFormatterFactory) clazz.newInstance();
} catch (Throwable e) {
System.err.println("Cannot initialize message formatter factory:");
e.printStackTrace(); | __messageFormatterFactory = new DefaultMessageFormatterFactory(); |
vivlabs/log6j | src/java/com/spinn3r/log5j/StandardLogger.java | // Path: src/java/com/spinn3r/log5j/factories/StdoutInternalLoggerFactory.java
// public class StdoutInternalLoggerFactory implements InternalLoggerFactory {
// private static final InternalLogger LOGGER = new InternalLogger() {
// public boolean isEnabled(LogLevel level) {
// return true;
// }
//
// public void log(LogEvent logEvent) {
// System.out.println(LogUtils.toString(logEvent));
// }
// };
//
// public InternalLogger create(String logName) {
// return LOGGER;
// }
//
// public void shutdown() {
// // do nothing
// }
// }
| import com.spinn3r.log5j.factories.StdoutInternalLoggerFactory; | /*
* Copyright 2010 "Tailrank, Inc (Spinn3r)"
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.spinn3r.log5j;
public class StandardLogger extends AbstractLoggable {
public StandardLogger(Loggable logger) {
this(logger.getName());
}
public StandardLogger(String logName) { | // Path: src/java/com/spinn3r/log5j/factories/StdoutInternalLoggerFactory.java
// public class StdoutInternalLoggerFactory implements InternalLoggerFactory {
// private static final InternalLogger LOGGER = new InternalLogger() {
// public boolean isEnabled(LogLevel level) {
// return true;
// }
//
// public void log(LogEvent logEvent) {
// System.out.println(LogUtils.toString(logEvent));
// }
// };
//
// public InternalLogger create(String logName) {
// return LOGGER;
// }
//
// public void shutdown() {
// // do nothing
// }
// }
// Path: src/java/com/spinn3r/log5j/StandardLogger.java
import com.spinn3r.log5j.factories.StdoutInternalLoggerFactory;
/*
* Copyright 2010 "Tailrank, Inc (Spinn3r)"
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.spinn3r.log5j;
public class StandardLogger extends AbstractLoggable {
public StandardLogger(Loggable logger) {
this(logger.getName());
}
public StandardLogger(String logName) { | super(logName, true, new StdoutInternalLoggerFactory().create(logName)); |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/server/servlet/matcher/QueryStringMatcher.java | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
| import com.thoughtworks.webstub.config.HttpConfiguration;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import static java.net.URLDecoder.decode;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import static org.apache.commons.lang.StringUtils.isBlank; | package com.thoughtworks.webstub.server.servlet.matcher;
public class QueryStringMatcher extends RequestPartMatcher {
public QueryStringMatcher(HttpServletRequest request) {
super(request, SC_BAD_REQUEST);
}
@Override | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/matcher/QueryStringMatcher.java
import com.thoughtworks.webstub.config.HttpConfiguration;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import static java.net.URLDecoder.decode;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import static org.apache.commons.lang.StringUtils.isBlank;
package com.thoughtworks.webstub.server.servlet.matcher;
public class QueryStringMatcher extends RequestPartMatcher {
public QueryStringMatcher(HttpServletRequest request) {
super(request, SC_BAD_REQUEST);
}
@Override | public boolean matches(HttpConfiguration configuration) throws IOException { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/dsl/builders/EntityEnclosingRequestBuilder.java | // Path: src/main/java/com/thoughtworks/webstub/config/ConfigurationProvider.java
// public abstract class ConfigurationProvider {
// private ConfigurationListener listener;
//
// protected ConfigurationProvider(ConfigurationListener listener) {
// this.listener = listener;
// }
//
// public void configurationCreated(HttpConfiguration configuration) {
// listener.configurationCreated(configuration);
// }
//
// protected void configurationCleared() {
// listener.configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Request.java
// public class Request {
// private String uri;
// private String method;
// private String content;
// private Collection<Header> headers = new ArrayList<>();
//
// public Request(String method, String uri) {
// this.method = method;
// this.uri = uri;
// }
//
// public Request(String method, String uri, String content) {
// this(method, uri);
// this.content = content;
// }
//
// public Request(String method, String uri, String content, Collection<Header> headers) {
// this(method, uri, content);
// this.headers = headers;
// }
//
// public String content() {
// return content;
// }
//
// public String uri() {
// return uri;
// }
//
// public String method() {
// return method;
// }
//
// public Collection<Header> headers() {
// return headers;
// }
//
// @Override
// public boolean equals(Object o) {
// if (! (o instanceof Request)) return false;
//
// Request that = (Request) o;
// return new EqualsBuilder()
// .append(method, that.method)
// .append(uri, that.uri)
// .append(content, that.content)
// .append(headers, that.headers)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = uri.hashCode();
// result = 31 * result + method.hashCode();
// result = 31 * result + (content != null ? content.hashCode() : 0);
// result = 31 * result + (headers != null ? headers.hashCode() : 0);
// return result;
// }
// }
| import com.thoughtworks.webstub.config.ConfigurationProvider;
import com.thoughtworks.webstub.config.Request; | package com.thoughtworks.webstub.dsl.builders;
public class EntityEnclosingRequestBuilder extends RequestBuilder<EntityEnclosingRequestBuilder> {
private String content;
| // Path: src/main/java/com/thoughtworks/webstub/config/ConfigurationProvider.java
// public abstract class ConfigurationProvider {
// private ConfigurationListener listener;
//
// protected ConfigurationProvider(ConfigurationListener listener) {
// this.listener = listener;
// }
//
// public void configurationCreated(HttpConfiguration configuration) {
// listener.configurationCreated(configuration);
// }
//
// protected void configurationCleared() {
// listener.configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Request.java
// public class Request {
// private String uri;
// private String method;
// private String content;
// private Collection<Header> headers = new ArrayList<>();
//
// public Request(String method, String uri) {
// this.method = method;
// this.uri = uri;
// }
//
// public Request(String method, String uri, String content) {
// this(method, uri);
// this.content = content;
// }
//
// public Request(String method, String uri, String content, Collection<Header> headers) {
// this(method, uri, content);
// this.headers = headers;
// }
//
// public String content() {
// return content;
// }
//
// public String uri() {
// return uri;
// }
//
// public String method() {
// return method;
// }
//
// public Collection<Header> headers() {
// return headers;
// }
//
// @Override
// public boolean equals(Object o) {
// if (! (o instanceof Request)) return false;
//
// Request that = (Request) o;
// return new EqualsBuilder()
// .append(method, that.method)
// .append(uri, that.uri)
// .append(content, that.content)
// .append(headers, that.headers)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = uri.hashCode();
// result = 31 * result + method.hashCode();
// result = 31 * result + (content != null ? content.hashCode() : 0);
// result = 31 * result + (headers != null ? headers.hashCode() : 0);
// return result;
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/dsl/builders/EntityEnclosingRequestBuilder.java
import com.thoughtworks.webstub.config.ConfigurationProvider;
import com.thoughtworks.webstub.config.Request;
package com.thoughtworks.webstub.dsl.builders;
public class EntityEnclosingRequestBuilder extends RequestBuilder<EntityEnclosingRequestBuilder> {
private String content;
| public EntityEnclosingRequestBuilder(ConfigurationProvider configurationProvider) { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/dsl/builders/EntityEnclosingRequestBuilder.java | // Path: src/main/java/com/thoughtworks/webstub/config/ConfigurationProvider.java
// public abstract class ConfigurationProvider {
// private ConfigurationListener listener;
//
// protected ConfigurationProvider(ConfigurationListener listener) {
// this.listener = listener;
// }
//
// public void configurationCreated(HttpConfiguration configuration) {
// listener.configurationCreated(configuration);
// }
//
// protected void configurationCleared() {
// listener.configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Request.java
// public class Request {
// private String uri;
// private String method;
// private String content;
// private Collection<Header> headers = new ArrayList<>();
//
// public Request(String method, String uri) {
// this.method = method;
// this.uri = uri;
// }
//
// public Request(String method, String uri, String content) {
// this(method, uri);
// this.content = content;
// }
//
// public Request(String method, String uri, String content, Collection<Header> headers) {
// this(method, uri, content);
// this.headers = headers;
// }
//
// public String content() {
// return content;
// }
//
// public String uri() {
// return uri;
// }
//
// public String method() {
// return method;
// }
//
// public Collection<Header> headers() {
// return headers;
// }
//
// @Override
// public boolean equals(Object o) {
// if (! (o instanceof Request)) return false;
//
// Request that = (Request) o;
// return new EqualsBuilder()
// .append(method, that.method)
// .append(uri, that.uri)
// .append(content, that.content)
// .append(headers, that.headers)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = uri.hashCode();
// result = 31 * result + method.hashCode();
// result = 31 * result + (content != null ? content.hashCode() : 0);
// result = 31 * result + (headers != null ? headers.hashCode() : 0);
// return result;
// }
// }
| import com.thoughtworks.webstub.config.ConfigurationProvider;
import com.thoughtworks.webstub.config.Request; | package com.thoughtworks.webstub.dsl.builders;
public class EntityEnclosingRequestBuilder extends RequestBuilder<EntityEnclosingRequestBuilder> {
private String content;
public EntityEnclosingRequestBuilder(ConfigurationProvider configurationProvider) {
super(configurationProvider);
}
public EntityEnclosingRequestBuilder withContent(String content) {
return withContent(new StringContentBuilder(content));
}
public EntityEnclosingRequestBuilder withContent(ContentBuilder contentBuilder) {
this.content = contentBuilder.build();
return this;
}
@Override | // Path: src/main/java/com/thoughtworks/webstub/config/ConfigurationProvider.java
// public abstract class ConfigurationProvider {
// private ConfigurationListener listener;
//
// protected ConfigurationProvider(ConfigurationListener listener) {
// this.listener = listener;
// }
//
// public void configurationCreated(HttpConfiguration configuration) {
// listener.configurationCreated(configuration);
// }
//
// protected void configurationCleared() {
// listener.configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Request.java
// public class Request {
// private String uri;
// private String method;
// private String content;
// private Collection<Header> headers = new ArrayList<>();
//
// public Request(String method, String uri) {
// this.method = method;
// this.uri = uri;
// }
//
// public Request(String method, String uri, String content) {
// this(method, uri);
// this.content = content;
// }
//
// public Request(String method, String uri, String content, Collection<Header> headers) {
// this(method, uri, content);
// this.headers = headers;
// }
//
// public String content() {
// return content;
// }
//
// public String uri() {
// return uri;
// }
//
// public String method() {
// return method;
// }
//
// public Collection<Header> headers() {
// return headers;
// }
//
// @Override
// public boolean equals(Object o) {
// if (! (o instanceof Request)) return false;
//
// Request that = (Request) o;
// return new EqualsBuilder()
// .append(method, that.method)
// .append(uri, that.uri)
// .append(content, that.content)
// .append(headers, that.headers)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = uri.hashCode();
// result = 31 * result + method.hashCode();
// result = 31 * result + (content != null ? content.hashCode() : 0);
// result = 31 * result + (headers != null ? headers.hashCode() : 0);
// return result;
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/dsl/builders/EntityEnclosingRequestBuilder.java
import com.thoughtworks.webstub.config.ConfigurationProvider;
import com.thoughtworks.webstub.config.Request;
package com.thoughtworks.webstub.dsl.builders;
public class EntityEnclosingRequestBuilder extends RequestBuilder<EntityEnclosingRequestBuilder> {
private String content;
public EntityEnclosingRequestBuilder(ConfigurationProvider configurationProvider) {
super(configurationProvider);
}
public EntityEnclosingRequestBuilder withContent(String content) {
return withContent(new StringContentBuilder(content));
}
public EntityEnclosingRequestBuilder withContent(ContentBuilder contentBuilder) {
this.content = contentBuilder.build();
return this;
}
@Override | protected Request build() { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/server/servlet/matcher/RequestPartMatcher.java | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
| import com.thoughtworks.webstub.config.HttpConfiguration;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException; | package com.thoughtworks.webstub.server.servlet.matcher;
public abstract class RequestPartMatcher {
protected HttpServletRequest request;
private int failedResponseCode;
protected RequestPartMatcher(HttpServletRequest request, int failedResponseCode) {
this.request = request;
this.failedResponseCode = failedResponseCode;
}
public int failedResponseCode() {
return failedResponseCode;
}
| // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/matcher/RequestPartMatcher.java
import com.thoughtworks.webstub.config.HttpConfiguration;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
package com.thoughtworks.webstub.server.servlet.matcher;
public abstract class RequestPartMatcher {
protected HttpServletRequest request;
private int failedResponseCode;
protected RequestPartMatcher(HttpServletRequest request, int failedResponseCode) {
this.request = request;
this.failedResponseCode = failedResponseCode;
}
public int failedResponseCode() {
return failedResponseCode;
}
| public abstract boolean matches(HttpConfiguration configuration) throws IOException; |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/dsl/builders/ResponseBuilder.java | // Path: src/main/java/com/thoughtworks/webstub/config/Response.java
// public class Response {
// private int status;
// private String content;
// private Collection<Header> headers;
//
// public Response(int status, String content, Collection<Header> headers) {
// this.status = status;
// this.content = content;
// this.headers = headers;
// }
//
// public int status() {
// return status;
// }
//
// public String content() {
// return content;
// }
//
// public Collection<Header> headers() {
// return headers;
// }
//
// @Override
// public boolean equals(Object o) {
// if (! (o instanceof Response)) return false;
//
// Response that = (Response) o;
// return new EqualsBuilder()
// .append(status, that.status)
// .append(content, that.content).isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = status;
// result = 31 * result + (content != null ? content.hashCode() : 0);
// return result;
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
| import com.thoughtworks.webstub.config.Response;
import com.thoughtworks.webstub.config.Header;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map; | package com.thoughtworks.webstub.dsl.builders;
public class ResponseBuilder {
public static ResponseBuilder response(int status) {
return new ResponseBuilder(status);
}
private int status;
private String content; | // Path: src/main/java/com/thoughtworks/webstub/config/Response.java
// public class Response {
// private int status;
// private String content;
// private Collection<Header> headers;
//
// public Response(int status, String content, Collection<Header> headers) {
// this.status = status;
// this.content = content;
// this.headers = headers;
// }
//
// public int status() {
// return status;
// }
//
// public String content() {
// return content;
// }
//
// public Collection<Header> headers() {
// return headers;
// }
//
// @Override
// public boolean equals(Object o) {
// if (! (o instanceof Response)) return false;
//
// Response that = (Response) o;
// return new EqualsBuilder()
// .append(status, that.status)
// .append(content, that.content).isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = status;
// result = 31 * result + (content != null ? content.hashCode() : 0);
// return result;
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/dsl/builders/ResponseBuilder.java
import com.thoughtworks.webstub.config.Response;
import com.thoughtworks.webstub.config.Header;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
package com.thoughtworks.webstub.dsl.builders;
public class ResponseBuilder {
public static ResponseBuilder response(int status) {
return new ResponseBuilder(status);
}
private int status;
private String content; | private Collection<Header> headers = new ArrayList<Header>(); |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/dsl/builders/ResponseBuilder.java | // Path: src/main/java/com/thoughtworks/webstub/config/Response.java
// public class Response {
// private int status;
// private String content;
// private Collection<Header> headers;
//
// public Response(int status, String content, Collection<Header> headers) {
// this.status = status;
// this.content = content;
// this.headers = headers;
// }
//
// public int status() {
// return status;
// }
//
// public String content() {
// return content;
// }
//
// public Collection<Header> headers() {
// return headers;
// }
//
// @Override
// public boolean equals(Object o) {
// if (! (o instanceof Response)) return false;
//
// Response that = (Response) o;
// return new EqualsBuilder()
// .append(status, that.status)
// .append(content, that.content).isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = status;
// result = 31 * result + (content != null ? content.hashCode() : 0);
// return result;
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
| import com.thoughtworks.webstub.config.Response;
import com.thoughtworks.webstub.config.Header;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map; | package com.thoughtworks.webstub.dsl.builders;
public class ResponseBuilder {
public static ResponseBuilder response(int status) {
return new ResponseBuilder(status);
}
private int status;
private String content;
private Collection<Header> headers = new ArrayList<Header>();
private ResponseBuilder(int status) {
this.status = status;
}
public ResponseBuilder withContent(String content) {
return withContent(new StringContentBuilder(content));
}
public ResponseBuilder withContent(ContentBuilder contentBuilder) {
this.content = contentBuilder.build();
return this;
}
public ResponseBuilder withHeader(String name, String value) {
headers.add(new Header(name, value));
return this;
}
public ResponseBuilder withHeaders(Map<String, String> headersMap) {
headers.clear();
for (Map.Entry<String, String> entry : headersMap.entrySet()) {
headers.add(new Header(entry.getKey(), entry.getValue()));
}
return this;
}
| // Path: src/main/java/com/thoughtworks/webstub/config/Response.java
// public class Response {
// private int status;
// private String content;
// private Collection<Header> headers;
//
// public Response(int status, String content, Collection<Header> headers) {
// this.status = status;
// this.content = content;
// this.headers = headers;
// }
//
// public int status() {
// return status;
// }
//
// public String content() {
// return content;
// }
//
// public Collection<Header> headers() {
// return headers;
// }
//
// @Override
// public boolean equals(Object o) {
// if (! (o instanceof Response)) return false;
//
// Response that = (Response) o;
// return new EqualsBuilder()
// .append(status, that.status)
// .append(content, that.content).isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = status;
// result = 31 * result + (content != null ? content.hashCode() : 0);
// return result;
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/dsl/builders/ResponseBuilder.java
import com.thoughtworks.webstub.config.Response;
import com.thoughtworks.webstub.config.Header;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
package com.thoughtworks.webstub.dsl.builders;
public class ResponseBuilder {
public static ResponseBuilder response(int status) {
return new ResponseBuilder(status);
}
private int status;
private String content;
private Collection<Header> headers = new ArrayList<Header>();
private ResponseBuilder(int status) {
this.status = status;
}
public ResponseBuilder withContent(String content) {
return withContent(new StringContentBuilder(content));
}
public ResponseBuilder withContent(ContentBuilder contentBuilder) {
this.content = contentBuilder.build();
return this;
}
public ResponseBuilder withHeader(String name, String value) {
headers.add(new Header(name, value));
return this;
}
public ResponseBuilder withHeaders(Map<String, String> headersMap) {
headers.clear();
for (Map.Entry<String, String> entry : headersMap.entrySet()) {
headers.add(new Header(entry.getKey(), entry.getValue()));
}
return this;
}
| public Response build() { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/server/servlet/ConfigurableServlet.java | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ContentCreator.java
// public class ContentCreator extends ResponsePartCreator {
// public ContentCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// String content = responseContent();
// if (content != null)
// response.getWriter().print(content);
// }
//
// private String responseContent() {
// return configuration.response().content();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/HeadersCreator.java
// public class HeadersCreator extends ResponsePartCreator {
// public HeadersCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) {
// for (Header header : configuration.response().headers()) {
// response.setHeader(header.name(), header.value());
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ResponsePartCreator.java
// public abstract class ResponsePartCreator {
// protected HttpConfiguration configuration;
//
// protected ResponsePartCreator(HttpConfiguration configuration) {
// this.configuration = configuration;
// }
//
// public abstract void createFor(HttpServletResponse response) throws IOException;
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/StatusCreator.java
// public class StatusCreator extends ResponsePartCreator {
// public StatusCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// response.setStatus(configuration.response().status());
// }
// }
| import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.server.servlet.creator.ContentCreator;
import com.thoughtworks.webstub.server.servlet.creator.HeadersCreator;
import com.thoughtworks.webstub.server.servlet.creator.ResponsePartCreator;
import com.thoughtworks.webstub.server.servlet.creator.StatusCreator;
import com.thoughtworks.webstub.server.servlet.matcher.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import static java.util.Arrays.asList; | }
@Override
protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
@Override
protected void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
@Override
protected void doTrace(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
protected void doPatch(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
private void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
Configurations filtered = configurations
.filterBy(new MethodMatcher(request))
.filterBy(new UriMatcher(request))
.filterBy(new QueryStringMatcher(request))
.filterBy(new HeadersMatcher(request))
.filterBy(new ContentMatcher(request));
| // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ContentCreator.java
// public class ContentCreator extends ResponsePartCreator {
// public ContentCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// String content = responseContent();
// if (content != null)
// response.getWriter().print(content);
// }
//
// private String responseContent() {
// return configuration.response().content();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/HeadersCreator.java
// public class HeadersCreator extends ResponsePartCreator {
// public HeadersCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) {
// for (Header header : configuration.response().headers()) {
// response.setHeader(header.name(), header.value());
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ResponsePartCreator.java
// public abstract class ResponsePartCreator {
// protected HttpConfiguration configuration;
//
// protected ResponsePartCreator(HttpConfiguration configuration) {
// this.configuration = configuration;
// }
//
// public abstract void createFor(HttpServletResponse response) throws IOException;
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/StatusCreator.java
// public class StatusCreator extends ResponsePartCreator {
// public StatusCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// response.setStatus(configuration.response().status());
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/ConfigurableServlet.java
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.server.servlet.creator.ContentCreator;
import com.thoughtworks.webstub.server.servlet.creator.HeadersCreator;
import com.thoughtworks.webstub.server.servlet.creator.ResponsePartCreator;
import com.thoughtworks.webstub.server.servlet.creator.StatusCreator;
import com.thoughtworks.webstub.server.servlet.matcher.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import static java.util.Arrays.asList;
}
@Override
protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
@Override
protected void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
@Override
protected void doTrace(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
protected void doPatch(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
private void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
Configurations filtered = configurations
.filterBy(new MethodMatcher(request))
.filterBy(new UriMatcher(request))
.filterBy(new QueryStringMatcher(request))
.filterBy(new HeadersMatcher(request))
.filterBy(new ContentMatcher(request));
| for (ResponsePartCreator creator : responseCreators(filtered.last())) { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/server/servlet/ConfigurableServlet.java | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ContentCreator.java
// public class ContentCreator extends ResponsePartCreator {
// public ContentCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// String content = responseContent();
// if (content != null)
// response.getWriter().print(content);
// }
//
// private String responseContent() {
// return configuration.response().content();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/HeadersCreator.java
// public class HeadersCreator extends ResponsePartCreator {
// public HeadersCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) {
// for (Header header : configuration.response().headers()) {
// response.setHeader(header.name(), header.value());
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ResponsePartCreator.java
// public abstract class ResponsePartCreator {
// protected HttpConfiguration configuration;
//
// protected ResponsePartCreator(HttpConfiguration configuration) {
// this.configuration = configuration;
// }
//
// public abstract void createFor(HttpServletResponse response) throws IOException;
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/StatusCreator.java
// public class StatusCreator extends ResponsePartCreator {
// public StatusCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// response.setStatus(configuration.response().status());
// }
// }
| import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.server.servlet.creator.ContentCreator;
import com.thoughtworks.webstub.server.servlet.creator.HeadersCreator;
import com.thoughtworks.webstub.server.servlet.creator.ResponsePartCreator;
import com.thoughtworks.webstub.server.servlet.creator.StatusCreator;
import com.thoughtworks.webstub.server.servlet.matcher.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import static java.util.Arrays.asList; | protected void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
@Override
protected void doTrace(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
protected void doPatch(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
private void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
Configurations filtered = configurations
.filterBy(new MethodMatcher(request))
.filterBy(new UriMatcher(request))
.filterBy(new QueryStringMatcher(request))
.filterBy(new HeadersMatcher(request))
.filterBy(new ContentMatcher(request));
for (ResponsePartCreator creator : responseCreators(filtered.last())) {
creator.createFor(response);
}
} catch (MissingMatchingConfigurationException e) {
response.setStatus(e.getFailedMatcher().failedResponseCode());
}
}
| // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ContentCreator.java
// public class ContentCreator extends ResponsePartCreator {
// public ContentCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// String content = responseContent();
// if (content != null)
// response.getWriter().print(content);
// }
//
// private String responseContent() {
// return configuration.response().content();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/HeadersCreator.java
// public class HeadersCreator extends ResponsePartCreator {
// public HeadersCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) {
// for (Header header : configuration.response().headers()) {
// response.setHeader(header.name(), header.value());
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ResponsePartCreator.java
// public abstract class ResponsePartCreator {
// protected HttpConfiguration configuration;
//
// protected ResponsePartCreator(HttpConfiguration configuration) {
// this.configuration = configuration;
// }
//
// public abstract void createFor(HttpServletResponse response) throws IOException;
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/StatusCreator.java
// public class StatusCreator extends ResponsePartCreator {
// public StatusCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// response.setStatus(configuration.response().status());
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/ConfigurableServlet.java
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.server.servlet.creator.ContentCreator;
import com.thoughtworks.webstub.server.servlet.creator.HeadersCreator;
import com.thoughtworks.webstub.server.servlet.creator.ResponsePartCreator;
import com.thoughtworks.webstub.server.servlet.creator.StatusCreator;
import com.thoughtworks.webstub.server.servlet.matcher.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import static java.util.Arrays.asList;
protected void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
@Override
protected void doTrace(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
protected void doPatch(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
private void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
Configurations filtered = configurations
.filterBy(new MethodMatcher(request))
.filterBy(new UriMatcher(request))
.filterBy(new QueryStringMatcher(request))
.filterBy(new HeadersMatcher(request))
.filterBy(new ContentMatcher(request));
for (ResponsePartCreator creator : responseCreators(filtered.last())) {
creator.createFor(response);
}
} catch (MissingMatchingConfigurationException e) {
response.setStatus(e.getFailedMatcher().failedResponseCode());
}
}
| private List<ResponsePartCreator> responseCreators(HttpConfiguration configuration) { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/server/servlet/ConfigurableServlet.java | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ContentCreator.java
// public class ContentCreator extends ResponsePartCreator {
// public ContentCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// String content = responseContent();
// if (content != null)
// response.getWriter().print(content);
// }
//
// private String responseContent() {
// return configuration.response().content();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/HeadersCreator.java
// public class HeadersCreator extends ResponsePartCreator {
// public HeadersCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) {
// for (Header header : configuration.response().headers()) {
// response.setHeader(header.name(), header.value());
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ResponsePartCreator.java
// public abstract class ResponsePartCreator {
// protected HttpConfiguration configuration;
//
// protected ResponsePartCreator(HttpConfiguration configuration) {
// this.configuration = configuration;
// }
//
// public abstract void createFor(HttpServletResponse response) throws IOException;
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/StatusCreator.java
// public class StatusCreator extends ResponsePartCreator {
// public StatusCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// response.setStatus(configuration.response().status());
// }
// }
| import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.server.servlet.creator.ContentCreator;
import com.thoughtworks.webstub.server.servlet.creator.HeadersCreator;
import com.thoughtworks.webstub.server.servlet.creator.ResponsePartCreator;
import com.thoughtworks.webstub.server.servlet.creator.StatusCreator;
import com.thoughtworks.webstub.server.servlet.matcher.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import static java.util.Arrays.asList; | }
@Override
protected void doTrace(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
protected void doPatch(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
private void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
Configurations filtered = configurations
.filterBy(new MethodMatcher(request))
.filterBy(new UriMatcher(request))
.filterBy(new QueryStringMatcher(request))
.filterBy(new HeadersMatcher(request))
.filterBy(new ContentMatcher(request));
for (ResponsePartCreator creator : responseCreators(filtered.last())) {
creator.createFor(response);
}
} catch (MissingMatchingConfigurationException e) {
response.setStatus(e.getFailedMatcher().failedResponseCode());
}
}
private List<ResponsePartCreator> responseCreators(HttpConfiguration configuration) {
return asList( | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ContentCreator.java
// public class ContentCreator extends ResponsePartCreator {
// public ContentCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// String content = responseContent();
// if (content != null)
// response.getWriter().print(content);
// }
//
// private String responseContent() {
// return configuration.response().content();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/HeadersCreator.java
// public class HeadersCreator extends ResponsePartCreator {
// public HeadersCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) {
// for (Header header : configuration.response().headers()) {
// response.setHeader(header.name(), header.value());
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ResponsePartCreator.java
// public abstract class ResponsePartCreator {
// protected HttpConfiguration configuration;
//
// protected ResponsePartCreator(HttpConfiguration configuration) {
// this.configuration = configuration;
// }
//
// public abstract void createFor(HttpServletResponse response) throws IOException;
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/StatusCreator.java
// public class StatusCreator extends ResponsePartCreator {
// public StatusCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// response.setStatus(configuration.response().status());
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/ConfigurableServlet.java
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.server.servlet.creator.ContentCreator;
import com.thoughtworks.webstub.server.servlet.creator.HeadersCreator;
import com.thoughtworks.webstub.server.servlet.creator.ResponsePartCreator;
import com.thoughtworks.webstub.server.servlet.creator.StatusCreator;
import com.thoughtworks.webstub.server.servlet.matcher.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import static java.util.Arrays.asList;
}
@Override
protected void doTrace(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
protected void doPatch(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
private void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
Configurations filtered = configurations
.filterBy(new MethodMatcher(request))
.filterBy(new UriMatcher(request))
.filterBy(new QueryStringMatcher(request))
.filterBy(new HeadersMatcher(request))
.filterBy(new ContentMatcher(request));
for (ResponsePartCreator creator : responseCreators(filtered.last())) {
creator.createFor(response);
}
} catch (MissingMatchingConfigurationException e) {
response.setStatus(e.getFailedMatcher().failedResponseCode());
}
}
private List<ResponsePartCreator> responseCreators(HttpConfiguration configuration) {
return asList( | new HeadersCreator(configuration), |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/server/servlet/ConfigurableServlet.java | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ContentCreator.java
// public class ContentCreator extends ResponsePartCreator {
// public ContentCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// String content = responseContent();
// if (content != null)
// response.getWriter().print(content);
// }
//
// private String responseContent() {
// return configuration.response().content();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/HeadersCreator.java
// public class HeadersCreator extends ResponsePartCreator {
// public HeadersCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) {
// for (Header header : configuration.response().headers()) {
// response.setHeader(header.name(), header.value());
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ResponsePartCreator.java
// public abstract class ResponsePartCreator {
// protected HttpConfiguration configuration;
//
// protected ResponsePartCreator(HttpConfiguration configuration) {
// this.configuration = configuration;
// }
//
// public abstract void createFor(HttpServletResponse response) throws IOException;
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/StatusCreator.java
// public class StatusCreator extends ResponsePartCreator {
// public StatusCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// response.setStatus(configuration.response().status());
// }
// }
| import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.server.servlet.creator.ContentCreator;
import com.thoughtworks.webstub.server.servlet.creator.HeadersCreator;
import com.thoughtworks.webstub.server.servlet.creator.ResponsePartCreator;
import com.thoughtworks.webstub.server.servlet.creator.StatusCreator;
import com.thoughtworks.webstub.server.servlet.matcher.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import static java.util.Arrays.asList; |
@Override
protected void doTrace(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
protected void doPatch(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
private void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
Configurations filtered = configurations
.filterBy(new MethodMatcher(request))
.filterBy(new UriMatcher(request))
.filterBy(new QueryStringMatcher(request))
.filterBy(new HeadersMatcher(request))
.filterBy(new ContentMatcher(request));
for (ResponsePartCreator creator : responseCreators(filtered.last())) {
creator.createFor(response);
}
} catch (MissingMatchingConfigurationException e) {
response.setStatus(e.getFailedMatcher().failedResponseCode());
}
}
private List<ResponsePartCreator> responseCreators(HttpConfiguration configuration) {
return asList(
new HeadersCreator(configuration), | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ContentCreator.java
// public class ContentCreator extends ResponsePartCreator {
// public ContentCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// String content = responseContent();
// if (content != null)
// response.getWriter().print(content);
// }
//
// private String responseContent() {
// return configuration.response().content();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/HeadersCreator.java
// public class HeadersCreator extends ResponsePartCreator {
// public HeadersCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) {
// for (Header header : configuration.response().headers()) {
// response.setHeader(header.name(), header.value());
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ResponsePartCreator.java
// public abstract class ResponsePartCreator {
// protected HttpConfiguration configuration;
//
// protected ResponsePartCreator(HttpConfiguration configuration) {
// this.configuration = configuration;
// }
//
// public abstract void createFor(HttpServletResponse response) throws IOException;
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/StatusCreator.java
// public class StatusCreator extends ResponsePartCreator {
// public StatusCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// response.setStatus(configuration.response().status());
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/ConfigurableServlet.java
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.server.servlet.creator.ContentCreator;
import com.thoughtworks.webstub.server.servlet.creator.HeadersCreator;
import com.thoughtworks.webstub.server.servlet.creator.ResponsePartCreator;
import com.thoughtworks.webstub.server.servlet.creator.StatusCreator;
import com.thoughtworks.webstub.server.servlet.matcher.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import static java.util.Arrays.asList;
@Override
protected void doTrace(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
protected void doPatch(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
private void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
Configurations filtered = configurations
.filterBy(new MethodMatcher(request))
.filterBy(new UriMatcher(request))
.filterBy(new QueryStringMatcher(request))
.filterBy(new HeadersMatcher(request))
.filterBy(new ContentMatcher(request));
for (ResponsePartCreator creator : responseCreators(filtered.last())) {
creator.createFor(response);
}
} catch (MissingMatchingConfigurationException e) {
response.setStatus(e.getFailedMatcher().failedResponseCode());
}
}
private List<ResponsePartCreator> responseCreators(HttpConfiguration configuration) {
return asList(
new HeadersCreator(configuration), | new ContentCreator(configuration), |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/server/servlet/ConfigurableServlet.java | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ContentCreator.java
// public class ContentCreator extends ResponsePartCreator {
// public ContentCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// String content = responseContent();
// if (content != null)
// response.getWriter().print(content);
// }
//
// private String responseContent() {
// return configuration.response().content();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/HeadersCreator.java
// public class HeadersCreator extends ResponsePartCreator {
// public HeadersCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) {
// for (Header header : configuration.response().headers()) {
// response.setHeader(header.name(), header.value());
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ResponsePartCreator.java
// public abstract class ResponsePartCreator {
// protected HttpConfiguration configuration;
//
// protected ResponsePartCreator(HttpConfiguration configuration) {
// this.configuration = configuration;
// }
//
// public abstract void createFor(HttpServletResponse response) throws IOException;
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/StatusCreator.java
// public class StatusCreator extends ResponsePartCreator {
// public StatusCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// response.setStatus(configuration.response().status());
// }
// }
| import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.server.servlet.creator.ContentCreator;
import com.thoughtworks.webstub.server.servlet.creator.HeadersCreator;
import com.thoughtworks.webstub.server.servlet.creator.ResponsePartCreator;
import com.thoughtworks.webstub.server.servlet.creator.StatusCreator;
import com.thoughtworks.webstub.server.servlet.matcher.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import static java.util.Arrays.asList; | @Override
protected void doTrace(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
protected void doPatch(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
private void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
Configurations filtered = configurations
.filterBy(new MethodMatcher(request))
.filterBy(new UriMatcher(request))
.filterBy(new QueryStringMatcher(request))
.filterBy(new HeadersMatcher(request))
.filterBy(new ContentMatcher(request));
for (ResponsePartCreator creator : responseCreators(filtered.last())) {
creator.createFor(response);
}
} catch (MissingMatchingConfigurationException e) {
response.setStatus(e.getFailedMatcher().failedResponseCode());
}
}
private List<ResponsePartCreator> responseCreators(HttpConfiguration configuration) {
return asList(
new HeadersCreator(configuration),
new ContentCreator(configuration), | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ContentCreator.java
// public class ContentCreator extends ResponsePartCreator {
// public ContentCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// String content = responseContent();
// if (content != null)
// response.getWriter().print(content);
// }
//
// private String responseContent() {
// return configuration.response().content();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/HeadersCreator.java
// public class HeadersCreator extends ResponsePartCreator {
// public HeadersCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) {
// for (Header header : configuration.response().headers()) {
// response.setHeader(header.name(), header.value());
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/ResponsePartCreator.java
// public abstract class ResponsePartCreator {
// protected HttpConfiguration configuration;
//
// protected ResponsePartCreator(HttpConfiguration configuration) {
// this.configuration = configuration;
// }
//
// public abstract void createFor(HttpServletResponse response) throws IOException;
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/StatusCreator.java
// public class StatusCreator extends ResponsePartCreator {
// public StatusCreator(HttpConfiguration configuration) {
// super(configuration);
// }
//
// @Override
// public void createFor(HttpServletResponse response) throws IOException {
// response.setStatus(configuration.response().status());
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/ConfigurableServlet.java
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.server.servlet.creator.ContentCreator;
import com.thoughtworks.webstub.server.servlet.creator.HeadersCreator;
import com.thoughtworks.webstub.server.servlet.creator.ResponsePartCreator;
import com.thoughtworks.webstub.server.servlet.creator.StatusCreator;
import com.thoughtworks.webstub.server.servlet.matcher.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import static java.util.Arrays.asList;
@Override
protected void doTrace(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
protected void doPatch(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
handle(req, resp);
}
private void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
Configurations filtered = configurations
.filterBy(new MethodMatcher(request))
.filterBy(new UriMatcher(request))
.filterBy(new QueryStringMatcher(request))
.filterBy(new HeadersMatcher(request))
.filterBy(new ContentMatcher(request));
for (ResponsePartCreator creator : responseCreators(filtered.last())) {
creator.createFor(response);
}
} catch (MissingMatchingConfigurationException e) {
response.setStatus(e.getFailedMatcher().failedResponseCode());
}
}
private List<ResponsePartCreator> responseCreators(HttpConfiguration configuration) {
return asList(
new HeadersCreator(configuration),
new ContentCreator(configuration), | new StatusCreator(configuration) |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/server/servlet/matcher/ContentMatcher.java | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
| import com.thoughtworks.webstub.config.HttpConfiguration;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import static org.apache.commons.io.IOUtils.readLines;
import static org.apache.commons.lang.StringUtils.isBlank;
import static org.apache.commons.lang.StringUtils.join; | package com.thoughtworks.webstub.server.servlet.matcher;
public class ContentMatcher extends RequestPartMatcher {
public ContentMatcher(HttpServletRequest request) {
super(request, SC_BAD_REQUEST);
}
@Override | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/matcher/ContentMatcher.java
import com.thoughtworks.webstub.config.HttpConfiguration;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import static org.apache.commons.io.IOUtils.readLines;
import static org.apache.commons.lang.StringUtils.isBlank;
import static org.apache.commons.lang.StringUtils.join;
package com.thoughtworks.webstub.server.servlet.matcher;
public class ContentMatcher extends RequestPartMatcher {
public ContentMatcher(HttpServletRequest request) {
super(request, SC_BAD_REQUEST);
}
@Override | public boolean matches(HttpConfiguration configuration) throws IOException { |
tusharm/WebStub | src/test/java/com/thoughtworks/webstub/WebConsoleTest.java | // Path: src/main/java/com/thoughtworks/webstub/StubServer.java
// public static StubServer newServer(int port) {
// return new StubServer(new JettyHttpServer(port));
// }
| import static com.thoughtworks.webstub.StubServer.newServer; | package com.thoughtworks.webstub;
public class WebConsoleTest {
public static void main(String[] args) { | // Path: src/main/java/com/thoughtworks/webstub/StubServer.java
// public static StubServer newServer(int port) {
// return new StubServer(new JettyHttpServer(port));
// }
// Path: src/test/java/com/thoughtworks/webstub/WebConsoleTest.java
import static com.thoughtworks.webstub.StubServer.newServer;
package com.thoughtworks.webstub;
public class WebConsoleTest {
public static void main(String[] args) { | newServer(9000).withWebConsole().start(); |
tusharm/WebStub | src/test/java/com/thoughtworks/webstub/utils/Response.java | // Path: src/main/java/com/thoughtworks/webstub/utils/CollectionUtils.java
// public static <S, T> Collection<T> map(Collection<S> inputs, Mapper<S, T> mapper) {
// List<T> outputs = new ArrayList<T>();
// for (S input : inputs) {
// outputs.add(mapper.map(input));
// }
//
// return outputs;
// }
| import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import static com.thoughtworks.webstub.utils.CollectionUtils.map;
import static java.util.Arrays.asList; | package com.thoughtworks.webstub.utils;
public class Response {
private HttpResponse response;
private String cachedContent;
public Response(HttpResponse response) {
this.response = response;
}
public Integer status() {
return response.getStatusLine().getStatusCode();
}
public Collection<String> header(String name) { | // Path: src/main/java/com/thoughtworks/webstub/utils/CollectionUtils.java
// public static <S, T> Collection<T> map(Collection<S> inputs, Mapper<S, T> mapper) {
// List<T> outputs = new ArrayList<T>();
// for (S input : inputs) {
// outputs.add(mapper.map(input));
// }
//
// return outputs;
// }
// Path: src/test/java/com/thoughtworks/webstub/utils/Response.java
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import static com.thoughtworks.webstub.utils.CollectionUtils.map;
import static java.util.Arrays.asList;
package com.thoughtworks.webstub.utils;
public class Response {
private HttpResponse response;
private String cachedContent;
public Response(HttpResponse response) {
this.response = response;
}
public Integer status() {
return response.getStatusLine().getStatusCode();
}
public Collection<String> header(String name) { | return map(asList(response.getHeaders(name)), new Mapper<Header, String>() { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/StubServer.java | // Path: src/main/java/com/thoughtworks/webstub/server/context/WebConsoleContext.java
// public class WebConsoleContext extends ContextHandler {
//
// public WebConsoleContext(HttpServer httpServer, String webAppRootDir) {
// ResourceHandler handler = new ResourceHandler();
// handler.setBaseResource(Resource.newClassPathResource(webAppRootDir));
// handler.setDirectoriesListed(true);
// handler.setWelcomeFiles(new String[] { "index.html" });
//
// this.setHandler(handler);
// this.setContextPath("/");
//
// httpServer.addContext(this);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/dsl/StubDsl.java
// public class StubDsl extends ConfigurationProvider {
//
// public StubDsl(ConfigurationListener listener) {
// super(listener);
// }
//
// public RequestBuilder get(String uri) {
// return new RequestBuilder(this).withMethod("GET").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder post(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("POST").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder put(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PUT").withUri(uri);
// }
//
// public RequestBuilder delete(String uri) {
// return new RequestBuilder(this).withMethod("DELETE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder options(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("OPTIONS").withUri(uri);
// }
//
// public RequestBuilder head(String uri) {
// return new RequestBuilder(this).withMethod("HEAD").withUri(uri);
// }
//
// public RequestBuilder trace(String uri) {
// return new RequestBuilder(this).withMethod("TRACE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder patch(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PATCH").withUri(uri);
// }
//
// public void reset() {
// configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/HttpServer.java
// public interface HttpServer {
// void start();
// void stop();
// void addContext(ContextHandler contextHandler);
// int port();
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/JettyHttpServer.java
// public class JettyHttpServer implements HttpServer {
//
// private Server server;
// private ContextHandlerCollection handlerCollection;
//
// public JettyHttpServer(int port) {
// server = new Server(port);
//
// handlerCollection = new ContextHandlerCollection();
// server.setHandler(handlerCollection);
// }
//
// public JettyHttpServer() {
// // random port
// this(0);
// }
//
// @Override
// public void addContext(ContextHandler contextHandler) {
// handlerCollection.addHandler(contextHandler);
// start(contextHandler);
// }
//
// @Override
// public int port() {
// Connector[] connectors = server.getConnectors();
// for (Connector connector : connectors) {
// if (connector instanceof ServerConnector)
// return ((ServerConnector) connector).getLocalPort();
// }
//
// throw new IllegalStateException("Couldn't find a server connector; this is absurd!");
// }
//
// @Override
// public void start() {
// try {
// server.start();
// } catch (Exception e) {
// throw new RuntimeException("Unable to start server", e);
// }
// }
//
// @Override
// public void stop() {
// try {
// server.stop();
// } catch (Exception e) {
// throw new RuntimeException("Unable to stop server", e);
// }
// }
//
// private void start(ContextHandler contextHandler) {
// try {
// contextHandler.start();
// } catch (Exception e) {
// throw new RuntimeException("Error starting context: " + contextHandler.getDisplayName(), e);
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/context/ConfigurableContext.java
// public class ConfigurableContext implements ConfigurationListener {
// private Configurations configurations;
//
// public ConfigurableContext(HttpServer server, String contextRoot) {
// assertNotBlank(contextRoot);
//
// ServletContextHandler context = new ServletContextHandler(sanitized(contextRoot));
// context.addServlet("/__status__", new StatusServlet(200));
//
// configurations = new Configurations();
// context.addServlet("/", new ConfigurableServlet(configurations));
//
// server.addContext(context);
// }
//
// @Override
// public void configurationCreated(HttpConfiguration configuration) {
// configurations.add(configuration);
// }
//
// @Override
// public void configurationCleared() {
// configurations.reset();
// }
//
// private void assertNotBlank(String contextRoot) {
// if (isBlank(contextRoot))
// throw new IllegalArgumentException("Invalid context root");
// }
//
// private String sanitized(String contextRoot) {
// return contextRoot.startsWith("/") ? contextRoot : ("/" + contextRoot);
// }
// }
| import com.thoughtworks.webstub.server.context.WebConsoleContext;
import com.thoughtworks.webstub.dsl.StubDsl;
import com.thoughtworks.webstub.server.HttpServer;
import com.thoughtworks.webstub.server.JettyHttpServer;
import com.thoughtworks.webstub.server.context.ConfigurableContext; | package com.thoughtworks.webstub;
public class StubServer {
public static StubServer newServer(int port) { | // Path: src/main/java/com/thoughtworks/webstub/server/context/WebConsoleContext.java
// public class WebConsoleContext extends ContextHandler {
//
// public WebConsoleContext(HttpServer httpServer, String webAppRootDir) {
// ResourceHandler handler = new ResourceHandler();
// handler.setBaseResource(Resource.newClassPathResource(webAppRootDir));
// handler.setDirectoriesListed(true);
// handler.setWelcomeFiles(new String[] { "index.html" });
//
// this.setHandler(handler);
// this.setContextPath("/");
//
// httpServer.addContext(this);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/dsl/StubDsl.java
// public class StubDsl extends ConfigurationProvider {
//
// public StubDsl(ConfigurationListener listener) {
// super(listener);
// }
//
// public RequestBuilder get(String uri) {
// return new RequestBuilder(this).withMethod("GET").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder post(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("POST").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder put(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PUT").withUri(uri);
// }
//
// public RequestBuilder delete(String uri) {
// return new RequestBuilder(this).withMethod("DELETE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder options(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("OPTIONS").withUri(uri);
// }
//
// public RequestBuilder head(String uri) {
// return new RequestBuilder(this).withMethod("HEAD").withUri(uri);
// }
//
// public RequestBuilder trace(String uri) {
// return new RequestBuilder(this).withMethod("TRACE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder patch(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PATCH").withUri(uri);
// }
//
// public void reset() {
// configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/HttpServer.java
// public interface HttpServer {
// void start();
// void stop();
// void addContext(ContextHandler contextHandler);
// int port();
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/JettyHttpServer.java
// public class JettyHttpServer implements HttpServer {
//
// private Server server;
// private ContextHandlerCollection handlerCollection;
//
// public JettyHttpServer(int port) {
// server = new Server(port);
//
// handlerCollection = new ContextHandlerCollection();
// server.setHandler(handlerCollection);
// }
//
// public JettyHttpServer() {
// // random port
// this(0);
// }
//
// @Override
// public void addContext(ContextHandler contextHandler) {
// handlerCollection.addHandler(contextHandler);
// start(contextHandler);
// }
//
// @Override
// public int port() {
// Connector[] connectors = server.getConnectors();
// for (Connector connector : connectors) {
// if (connector instanceof ServerConnector)
// return ((ServerConnector) connector).getLocalPort();
// }
//
// throw new IllegalStateException("Couldn't find a server connector; this is absurd!");
// }
//
// @Override
// public void start() {
// try {
// server.start();
// } catch (Exception e) {
// throw new RuntimeException("Unable to start server", e);
// }
// }
//
// @Override
// public void stop() {
// try {
// server.stop();
// } catch (Exception e) {
// throw new RuntimeException("Unable to stop server", e);
// }
// }
//
// private void start(ContextHandler contextHandler) {
// try {
// contextHandler.start();
// } catch (Exception e) {
// throw new RuntimeException("Error starting context: " + contextHandler.getDisplayName(), e);
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/context/ConfigurableContext.java
// public class ConfigurableContext implements ConfigurationListener {
// private Configurations configurations;
//
// public ConfigurableContext(HttpServer server, String contextRoot) {
// assertNotBlank(contextRoot);
//
// ServletContextHandler context = new ServletContextHandler(sanitized(contextRoot));
// context.addServlet("/__status__", new StatusServlet(200));
//
// configurations = new Configurations();
// context.addServlet("/", new ConfigurableServlet(configurations));
//
// server.addContext(context);
// }
//
// @Override
// public void configurationCreated(HttpConfiguration configuration) {
// configurations.add(configuration);
// }
//
// @Override
// public void configurationCleared() {
// configurations.reset();
// }
//
// private void assertNotBlank(String contextRoot) {
// if (isBlank(contextRoot))
// throw new IllegalArgumentException("Invalid context root");
// }
//
// private String sanitized(String contextRoot) {
// return contextRoot.startsWith("/") ? contextRoot : ("/" + contextRoot);
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/StubServer.java
import com.thoughtworks.webstub.server.context.WebConsoleContext;
import com.thoughtworks.webstub.dsl.StubDsl;
import com.thoughtworks.webstub.server.HttpServer;
import com.thoughtworks.webstub.server.JettyHttpServer;
import com.thoughtworks.webstub.server.context.ConfigurableContext;
package com.thoughtworks.webstub;
public class StubServer {
public static StubServer newServer(int port) { | return new StubServer(new JettyHttpServer(port)); |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/StubServer.java | // Path: src/main/java/com/thoughtworks/webstub/server/context/WebConsoleContext.java
// public class WebConsoleContext extends ContextHandler {
//
// public WebConsoleContext(HttpServer httpServer, String webAppRootDir) {
// ResourceHandler handler = new ResourceHandler();
// handler.setBaseResource(Resource.newClassPathResource(webAppRootDir));
// handler.setDirectoriesListed(true);
// handler.setWelcomeFiles(new String[] { "index.html" });
//
// this.setHandler(handler);
// this.setContextPath("/");
//
// httpServer.addContext(this);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/dsl/StubDsl.java
// public class StubDsl extends ConfigurationProvider {
//
// public StubDsl(ConfigurationListener listener) {
// super(listener);
// }
//
// public RequestBuilder get(String uri) {
// return new RequestBuilder(this).withMethod("GET").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder post(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("POST").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder put(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PUT").withUri(uri);
// }
//
// public RequestBuilder delete(String uri) {
// return new RequestBuilder(this).withMethod("DELETE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder options(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("OPTIONS").withUri(uri);
// }
//
// public RequestBuilder head(String uri) {
// return new RequestBuilder(this).withMethod("HEAD").withUri(uri);
// }
//
// public RequestBuilder trace(String uri) {
// return new RequestBuilder(this).withMethod("TRACE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder patch(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PATCH").withUri(uri);
// }
//
// public void reset() {
// configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/HttpServer.java
// public interface HttpServer {
// void start();
// void stop();
// void addContext(ContextHandler contextHandler);
// int port();
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/JettyHttpServer.java
// public class JettyHttpServer implements HttpServer {
//
// private Server server;
// private ContextHandlerCollection handlerCollection;
//
// public JettyHttpServer(int port) {
// server = new Server(port);
//
// handlerCollection = new ContextHandlerCollection();
// server.setHandler(handlerCollection);
// }
//
// public JettyHttpServer() {
// // random port
// this(0);
// }
//
// @Override
// public void addContext(ContextHandler contextHandler) {
// handlerCollection.addHandler(contextHandler);
// start(contextHandler);
// }
//
// @Override
// public int port() {
// Connector[] connectors = server.getConnectors();
// for (Connector connector : connectors) {
// if (connector instanceof ServerConnector)
// return ((ServerConnector) connector).getLocalPort();
// }
//
// throw new IllegalStateException("Couldn't find a server connector; this is absurd!");
// }
//
// @Override
// public void start() {
// try {
// server.start();
// } catch (Exception e) {
// throw new RuntimeException("Unable to start server", e);
// }
// }
//
// @Override
// public void stop() {
// try {
// server.stop();
// } catch (Exception e) {
// throw new RuntimeException("Unable to stop server", e);
// }
// }
//
// private void start(ContextHandler contextHandler) {
// try {
// contextHandler.start();
// } catch (Exception e) {
// throw new RuntimeException("Error starting context: " + contextHandler.getDisplayName(), e);
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/context/ConfigurableContext.java
// public class ConfigurableContext implements ConfigurationListener {
// private Configurations configurations;
//
// public ConfigurableContext(HttpServer server, String contextRoot) {
// assertNotBlank(contextRoot);
//
// ServletContextHandler context = new ServletContextHandler(sanitized(contextRoot));
// context.addServlet("/__status__", new StatusServlet(200));
//
// configurations = new Configurations();
// context.addServlet("/", new ConfigurableServlet(configurations));
//
// server.addContext(context);
// }
//
// @Override
// public void configurationCreated(HttpConfiguration configuration) {
// configurations.add(configuration);
// }
//
// @Override
// public void configurationCleared() {
// configurations.reset();
// }
//
// private void assertNotBlank(String contextRoot) {
// if (isBlank(contextRoot))
// throw new IllegalArgumentException("Invalid context root");
// }
//
// private String sanitized(String contextRoot) {
// return contextRoot.startsWith("/") ? contextRoot : ("/" + contextRoot);
// }
// }
| import com.thoughtworks.webstub.server.context.WebConsoleContext;
import com.thoughtworks.webstub.dsl.StubDsl;
import com.thoughtworks.webstub.server.HttpServer;
import com.thoughtworks.webstub.server.JettyHttpServer;
import com.thoughtworks.webstub.server.context.ConfigurableContext; | package com.thoughtworks.webstub;
public class StubServer {
public static StubServer newServer(int port) {
return new StubServer(new JettyHttpServer(port));
}
public static StubServer newServer() {
return new StubServer(new JettyHttpServer());
}
| // Path: src/main/java/com/thoughtworks/webstub/server/context/WebConsoleContext.java
// public class WebConsoleContext extends ContextHandler {
//
// public WebConsoleContext(HttpServer httpServer, String webAppRootDir) {
// ResourceHandler handler = new ResourceHandler();
// handler.setBaseResource(Resource.newClassPathResource(webAppRootDir));
// handler.setDirectoriesListed(true);
// handler.setWelcomeFiles(new String[] { "index.html" });
//
// this.setHandler(handler);
// this.setContextPath("/");
//
// httpServer.addContext(this);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/dsl/StubDsl.java
// public class StubDsl extends ConfigurationProvider {
//
// public StubDsl(ConfigurationListener listener) {
// super(listener);
// }
//
// public RequestBuilder get(String uri) {
// return new RequestBuilder(this).withMethod("GET").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder post(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("POST").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder put(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PUT").withUri(uri);
// }
//
// public RequestBuilder delete(String uri) {
// return new RequestBuilder(this).withMethod("DELETE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder options(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("OPTIONS").withUri(uri);
// }
//
// public RequestBuilder head(String uri) {
// return new RequestBuilder(this).withMethod("HEAD").withUri(uri);
// }
//
// public RequestBuilder trace(String uri) {
// return new RequestBuilder(this).withMethod("TRACE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder patch(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PATCH").withUri(uri);
// }
//
// public void reset() {
// configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/HttpServer.java
// public interface HttpServer {
// void start();
// void stop();
// void addContext(ContextHandler contextHandler);
// int port();
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/JettyHttpServer.java
// public class JettyHttpServer implements HttpServer {
//
// private Server server;
// private ContextHandlerCollection handlerCollection;
//
// public JettyHttpServer(int port) {
// server = new Server(port);
//
// handlerCollection = new ContextHandlerCollection();
// server.setHandler(handlerCollection);
// }
//
// public JettyHttpServer() {
// // random port
// this(0);
// }
//
// @Override
// public void addContext(ContextHandler contextHandler) {
// handlerCollection.addHandler(contextHandler);
// start(contextHandler);
// }
//
// @Override
// public int port() {
// Connector[] connectors = server.getConnectors();
// for (Connector connector : connectors) {
// if (connector instanceof ServerConnector)
// return ((ServerConnector) connector).getLocalPort();
// }
//
// throw new IllegalStateException("Couldn't find a server connector; this is absurd!");
// }
//
// @Override
// public void start() {
// try {
// server.start();
// } catch (Exception e) {
// throw new RuntimeException("Unable to start server", e);
// }
// }
//
// @Override
// public void stop() {
// try {
// server.stop();
// } catch (Exception e) {
// throw new RuntimeException("Unable to stop server", e);
// }
// }
//
// private void start(ContextHandler contextHandler) {
// try {
// contextHandler.start();
// } catch (Exception e) {
// throw new RuntimeException("Error starting context: " + contextHandler.getDisplayName(), e);
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/context/ConfigurableContext.java
// public class ConfigurableContext implements ConfigurationListener {
// private Configurations configurations;
//
// public ConfigurableContext(HttpServer server, String contextRoot) {
// assertNotBlank(contextRoot);
//
// ServletContextHandler context = new ServletContextHandler(sanitized(contextRoot));
// context.addServlet("/__status__", new StatusServlet(200));
//
// configurations = new Configurations();
// context.addServlet("/", new ConfigurableServlet(configurations));
//
// server.addContext(context);
// }
//
// @Override
// public void configurationCreated(HttpConfiguration configuration) {
// configurations.add(configuration);
// }
//
// @Override
// public void configurationCleared() {
// configurations.reset();
// }
//
// private void assertNotBlank(String contextRoot) {
// if (isBlank(contextRoot))
// throw new IllegalArgumentException("Invalid context root");
// }
//
// private String sanitized(String contextRoot) {
// return contextRoot.startsWith("/") ? contextRoot : ("/" + contextRoot);
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/StubServer.java
import com.thoughtworks.webstub.server.context.WebConsoleContext;
import com.thoughtworks.webstub.dsl.StubDsl;
import com.thoughtworks.webstub.server.HttpServer;
import com.thoughtworks.webstub.server.JettyHttpServer;
import com.thoughtworks.webstub.server.context.ConfigurableContext;
package com.thoughtworks.webstub;
public class StubServer {
public static StubServer newServer(int port) {
return new StubServer(new JettyHttpServer(port));
}
public static StubServer newServer() {
return new StubServer(new JettyHttpServer());
}
| private HttpServer httpServer; |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/StubServer.java | // Path: src/main/java/com/thoughtworks/webstub/server/context/WebConsoleContext.java
// public class WebConsoleContext extends ContextHandler {
//
// public WebConsoleContext(HttpServer httpServer, String webAppRootDir) {
// ResourceHandler handler = new ResourceHandler();
// handler.setBaseResource(Resource.newClassPathResource(webAppRootDir));
// handler.setDirectoriesListed(true);
// handler.setWelcomeFiles(new String[] { "index.html" });
//
// this.setHandler(handler);
// this.setContextPath("/");
//
// httpServer.addContext(this);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/dsl/StubDsl.java
// public class StubDsl extends ConfigurationProvider {
//
// public StubDsl(ConfigurationListener listener) {
// super(listener);
// }
//
// public RequestBuilder get(String uri) {
// return new RequestBuilder(this).withMethod("GET").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder post(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("POST").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder put(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PUT").withUri(uri);
// }
//
// public RequestBuilder delete(String uri) {
// return new RequestBuilder(this).withMethod("DELETE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder options(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("OPTIONS").withUri(uri);
// }
//
// public RequestBuilder head(String uri) {
// return new RequestBuilder(this).withMethod("HEAD").withUri(uri);
// }
//
// public RequestBuilder trace(String uri) {
// return new RequestBuilder(this).withMethod("TRACE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder patch(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PATCH").withUri(uri);
// }
//
// public void reset() {
// configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/HttpServer.java
// public interface HttpServer {
// void start();
// void stop();
// void addContext(ContextHandler contextHandler);
// int port();
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/JettyHttpServer.java
// public class JettyHttpServer implements HttpServer {
//
// private Server server;
// private ContextHandlerCollection handlerCollection;
//
// public JettyHttpServer(int port) {
// server = new Server(port);
//
// handlerCollection = new ContextHandlerCollection();
// server.setHandler(handlerCollection);
// }
//
// public JettyHttpServer() {
// // random port
// this(0);
// }
//
// @Override
// public void addContext(ContextHandler contextHandler) {
// handlerCollection.addHandler(contextHandler);
// start(contextHandler);
// }
//
// @Override
// public int port() {
// Connector[] connectors = server.getConnectors();
// for (Connector connector : connectors) {
// if (connector instanceof ServerConnector)
// return ((ServerConnector) connector).getLocalPort();
// }
//
// throw new IllegalStateException("Couldn't find a server connector; this is absurd!");
// }
//
// @Override
// public void start() {
// try {
// server.start();
// } catch (Exception e) {
// throw new RuntimeException("Unable to start server", e);
// }
// }
//
// @Override
// public void stop() {
// try {
// server.stop();
// } catch (Exception e) {
// throw new RuntimeException("Unable to stop server", e);
// }
// }
//
// private void start(ContextHandler contextHandler) {
// try {
// contextHandler.start();
// } catch (Exception e) {
// throw new RuntimeException("Error starting context: " + contextHandler.getDisplayName(), e);
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/context/ConfigurableContext.java
// public class ConfigurableContext implements ConfigurationListener {
// private Configurations configurations;
//
// public ConfigurableContext(HttpServer server, String contextRoot) {
// assertNotBlank(contextRoot);
//
// ServletContextHandler context = new ServletContextHandler(sanitized(contextRoot));
// context.addServlet("/__status__", new StatusServlet(200));
//
// configurations = new Configurations();
// context.addServlet("/", new ConfigurableServlet(configurations));
//
// server.addContext(context);
// }
//
// @Override
// public void configurationCreated(HttpConfiguration configuration) {
// configurations.add(configuration);
// }
//
// @Override
// public void configurationCleared() {
// configurations.reset();
// }
//
// private void assertNotBlank(String contextRoot) {
// if (isBlank(contextRoot))
// throw new IllegalArgumentException("Invalid context root");
// }
//
// private String sanitized(String contextRoot) {
// return contextRoot.startsWith("/") ? contextRoot : ("/" + contextRoot);
// }
// }
| import com.thoughtworks.webstub.server.context.WebConsoleContext;
import com.thoughtworks.webstub.dsl.StubDsl;
import com.thoughtworks.webstub.server.HttpServer;
import com.thoughtworks.webstub.server.JettyHttpServer;
import com.thoughtworks.webstub.server.context.ConfigurableContext; | package com.thoughtworks.webstub;
public class StubServer {
public static StubServer newServer(int port) {
return new StubServer(new JettyHttpServer(port));
}
public static StubServer newServer() {
return new StubServer(new JettyHttpServer());
}
private HttpServer httpServer;
private StubServer(HttpServer httpServer) {
this.httpServer = httpServer;
}
public StubServer withWebConsole() { | // Path: src/main/java/com/thoughtworks/webstub/server/context/WebConsoleContext.java
// public class WebConsoleContext extends ContextHandler {
//
// public WebConsoleContext(HttpServer httpServer, String webAppRootDir) {
// ResourceHandler handler = new ResourceHandler();
// handler.setBaseResource(Resource.newClassPathResource(webAppRootDir));
// handler.setDirectoriesListed(true);
// handler.setWelcomeFiles(new String[] { "index.html" });
//
// this.setHandler(handler);
// this.setContextPath("/");
//
// httpServer.addContext(this);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/dsl/StubDsl.java
// public class StubDsl extends ConfigurationProvider {
//
// public StubDsl(ConfigurationListener listener) {
// super(listener);
// }
//
// public RequestBuilder get(String uri) {
// return new RequestBuilder(this).withMethod("GET").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder post(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("POST").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder put(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PUT").withUri(uri);
// }
//
// public RequestBuilder delete(String uri) {
// return new RequestBuilder(this).withMethod("DELETE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder options(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("OPTIONS").withUri(uri);
// }
//
// public RequestBuilder head(String uri) {
// return new RequestBuilder(this).withMethod("HEAD").withUri(uri);
// }
//
// public RequestBuilder trace(String uri) {
// return new RequestBuilder(this).withMethod("TRACE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder patch(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PATCH").withUri(uri);
// }
//
// public void reset() {
// configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/HttpServer.java
// public interface HttpServer {
// void start();
// void stop();
// void addContext(ContextHandler contextHandler);
// int port();
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/JettyHttpServer.java
// public class JettyHttpServer implements HttpServer {
//
// private Server server;
// private ContextHandlerCollection handlerCollection;
//
// public JettyHttpServer(int port) {
// server = new Server(port);
//
// handlerCollection = new ContextHandlerCollection();
// server.setHandler(handlerCollection);
// }
//
// public JettyHttpServer() {
// // random port
// this(0);
// }
//
// @Override
// public void addContext(ContextHandler contextHandler) {
// handlerCollection.addHandler(contextHandler);
// start(contextHandler);
// }
//
// @Override
// public int port() {
// Connector[] connectors = server.getConnectors();
// for (Connector connector : connectors) {
// if (connector instanceof ServerConnector)
// return ((ServerConnector) connector).getLocalPort();
// }
//
// throw new IllegalStateException("Couldn't find a server connector; this is absurd!");
// }
//
// @Override
// public void start() {
// try {
// server.start();
// } catch (Exception e) {
// throw new RuntimeException("Unable to start server", e);
// }
// }
//
// @Override
// public void stop() {
// try {
// server.stop();
// } catch (Exception e) {
// throw new RuntimeException("Unable to stop server", e);
// }
// }
//
// private void start(ContextHandler contextHandler) {
// try {
// contextHandler.start();
// } catch (Exception e) {
// throw new RuntimeException("Error starting context: " + contextHandler.getDisplayName(), e);
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/context/ConfigurableContext.java
// public class ConfigurableContext implements ConfigurationListener {
// private Configurations configurations;
//
// public ConfigurableContext(HttpServer server, String contextRoot) {
// assertNotBlank(contextRoot);
//
// ServletContextHandler context = new ServletContextHandler(sanitized(contextRoot));
// context.addServlet("/__status__", new StatusServlet(200));
//
// configurations = new Configurations();
// context.addServlet("/", new ConfigurableServlet(configurations));
//
// server.addContext(context);
// }
//
// @Override
// public void configurationCreated(HttpConfiguration configuration) {
// configurations.add(configuration);
// }
//
// @Override
// public void configurationCleared() {
// configurations.reset();
// }
//
// private void assertNotBlank(String contextRoot) {
// if (isBlank(contextRoot))
// throw new IllegalArgumentException("Invalid context root");
// }
//
// private String sanitized(String contextRoot) {
// return contextRoot.startsWith("/") ? contextRoot : ("/" + contextRoot);
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/StubServer.java
import com.thoughtworks.webstub.server.context.WebConsoleContext;
import com.thoughtworks.webstub.dsl.StubDsl;
import com.thoughtworks.webstub.server.HttpServer;
import com.thoughtworks.webstub.server.JettyHttpServer;
import com.thoughtworks.webstub.server.context.ConfigurableContext;
package com.thoughtworks.webstub;
public class StubServer {
public static StubServer newServer(int port) {
return new StubServer(new JettyHttpServer(port));
}
public static StubServer newServer() {
return new StubServer(new JettyHttpServer());
}
private HttpServer httpServer;
private StubServer(HttpServer httpServer) {
this.httpServer = httpServer;
}
public StubServer withWebConsole() { | new WebConsoleContext(httpServer, "webconsole"); |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/StubServer.java | // Path: src/main/java/com/thoughtworks/webstub/server/context/WebConsoleContext.java
// public class WebConsoleContext extends ContextHandler {
//
// public WebConsoleContext(HttpServer httpServer, String webAppRootDir) {
// ResourceHandler handler = new ResourceHandler();
// handler.setBaseResource(Resource.newClassPathResource(webAppRootDir));
// handler.setDirectoriesListed(true);
// handler.setWelcomeFiles(new String[] { "index.html" });
//
// this.setHandler(handler);
// this.setContextPath("/");
//
// httpServer.addContext(this);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/dsl/StubDsl.java
// public class StubDsl extends ConfigurationProvider {
//
// public StubDsl(ConfigurationListener listener) {
// super(listener);
// }
//
// public RequestBuilder get(String uri) {
// return new RequestBuilder(this).withMethod("GET").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder post(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("POST").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder put(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PUT").withUri(uri);
// }
//
// public RequestBuilder delete(String uri) {
// return new RequestBuilder(this).withMethod("DELETE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder options(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("OPTIONS").withUri(uri);
// }
//
// public RequestBuilder head(String uri) {
// return new RequestBuilder(this).withMethod("HEAD").withUri(uri);
// }
//
// public RequestBuilder trace(String uri) {
// return new RequestBuilder(this).withMethod("TRACE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder patch(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PATCH").withUri(uri);
// }
//
// public void reset() {
// configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/HttpServer.java
// public interface HttpServer {
// void start();
// void stop();
// void addContext(ContextHandler contextHandler);
// int port();
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/JettyHttpServer.java
// public class JettyHttpServer implements HttpServer {
//
// private Server server;
// private ContextHandlerCollection handlerCollection;
//
// public JettyHttpServer(int port) {
// server = new Server(port);
//
// handlerCollection = new ContextHandlerCollection();
// server.setHandler(handlerCollection);
// }
//
// public JettyHttpServer() {
// // random port
// this(0);
// }
//
// @Override
// public void addContext(ContextHandler contextHandler) {
// handlerCollection.addHandler(contextHandler);
// start(contextHandler);
// }
//
// @Override
// public int port() {
// Connector[] connectors = server.getConnectors();
// for (Connector connector : connectors) {
// if (connector instanceof ServerConnector)
// return ((ServerConnector) connector).getLocalPort();
// }
//
// throw new IllegalStateException("Couldn't find a server connector; this is absurd!");
// }
//
// @Override
// public void start() {
// try {
// server.start();
// } catch (Exception e) {
// throw new RuntimeException("Unable to start server", e);
// }
// }
//
// @Override
// public void stop() {
// try {
// server.stop();
// } catch (Exception e) {
// throw new RuntimeException("Unable to stop server", e);
// }
// }
//
// private void start(ContextHandler contextHandler) {
// try {
// contextHandler.start();
// } catch (Exception e) {
// throw new RuntimeException("Error starting context: " + contextHandler.getDisplayName(), e);
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/context/ConfigurableContext.java
// public class ConfigurableContext implements ConfigurationListener {
// private Configurations configurations;
//
// public ConfigurableContext(HttpServer server, String contextRoot) {
// assertNotBlank(contextRoot);
//
// ServletContextHandler context = new ServletContextHandler(sanitized(contextRoot));
// context.addServlet("/__status__", new StatusServlet(200));
//
// configurations = new Configurations();
// context.addServlet("/", new ConfigurableServlet(configurations));
//
// server.addContext(context);
// }
//
// @Override
// public void configurationCreated(HttpConfiguration configuration) {
// configurations.add(configuration);
// }
//
// @Override
// public void configurationCleared() {
// configurations.reset();
// }
//
// private void assertNotBlank(String contextRoot) {
// if (isBlank(contextRoot))
// throw new IllegalArgumentException("Invalid context root");
// }
//
// private String sanitized(String contextRoot) {
// return contextRoot.startsWith("/") ? contextRoot : ("/" + contextRoot);
// }
// }
| import com.thoughtworks.webstub.server.context.WebConsoleContext;
import com.thoughtworks.webstub.dsl.StubDsl;
import com.thoughtworks.webstub.server.HttpServer;
import com.thoughtworks.webstub.server.JettyHttpServer;
import com.thoughtworks.webstub.server.context.ConfigurableContext; | package com.thoughtworks.webstub;
public class StubServer {
public static StubServer newServer(int port) {
return new StubServer(new JettyHttpServer(port));
}
public static StubServer newServer() {
return new StubServer(new JettyHttpServer());
}
private HttpServer httpServer;
private StubServer(HttpServer httpServer) {
this.httpServer = httpServer;
}
public StubServer withWebConsole() {
new WebConsoleContext(httpServer, "webconsole");
return this;
}
| // Path: src/main/java/com/thoughtworks/webstub/server/context/WebConsoleContext.java
// public class WebConsoleContext extends ContextHandler {
//
// public WebConsoleContext(HttpServer httpServer, String webAppRootDir) {
// ResourceHandler handler = new ResourceHandler();
// handler.setBaseResource(Resource.newClassPathResource(webAppRootDir));
// handler.setDirectoriesListed(true);
// handler.setWelcomeFiles(new String[] { "index.html" });
//
// this.setHandler(handler);
// this.setContextPath("/");
//
// httpServer.addContext(this);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/dsl/StubDsl.java
// public class StubDsl extends ConfigurationProvider {
//
// public StubDsl(ConfigurationListener listener) {
// super(listener);
// }
//
// public RequestBuilder get(String uri) {
// return new RequestBuilder(this).withMethod("GET").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder post(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("POST").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder put(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PUT").withUri(uri);
// }
//
// public RequestBuilder delete(String uri) {
// return new RequestBuilder(this).withMethod("DELETE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder options(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("OPTIONS").withUri(uri);
// }
//
// public RequestBuilder head(String uri) {
// return new RequestBuilder(this).withMethod("HEAD").withUri(uri);
// }
//
// public RequestBuilder trace(String uri) {
// return new RequestBuilder(this).withMethod("TRACE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder patch(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PATCH").withUri(uri);
// }
//
// public void reset() {
// configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/HttpServer.java
// public interface HttpServer {
// void start();
// void stop();
// void addContext(ContextHandler contextHandler);
// int port();
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/JettyHttpServer.java
// public class JettyHttpServer implements HttpServer {
//
// private Server server;
// private ContextHandlerCollection handlerCollection;
//
// public JettyHttpServer(int port) {
// server = new Server(port);
//
// handlerCollection = new ContextHandlerCollection();
// server.setHandler(handlerCollection);
// }
//
// public JettyHttpServer() {
// // random port
// this(0);
// }
//
// @Override
// public void addContext(ContextHandler contextHandler) {
// handlerCollection.addHandler(contextHandler);
// start(contextHandler);
// }
//
// @Override
// public int port() {
// Connector[] connectors = server.getConnectors();
// for (Connector connector : connectors) {
// if (connector instanceof ServerConnector)
// return ((ServerConnector) connector).getLocalPort();
// }
//
// throw new IllegalStateException("Couldn't find a server connector; this is absurd!");
// }
//
// @Override
// public void start() {
// try {
// server.start();
// } catch (Exception e) {
// throw new RuntimeException("Unable to start server", e);
// }
// }
//
// @Override
// public void stop() {
// try {
// server.stop();
// } catch (Exception e) {
// throw new RuntimeException("Unable to stop server", e);
// }
// }
//
// private void start(ContextHandler contextHandler) {
// try {
// contextHandler.start();
// } catch (Exception e) {
// throw new RuntimeException("Error starting context: " + contextHandler.getDisplayName(), e);
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/context/ConfigurableContext.java
// public class ConfigurableContext implements ConfigurationListener {
// private Configurations configurations;
//
// public ConfigurableContext(HttpServer server, String contextRoot) {
// assertNotBlank(contextRoot);
//
// ServletContextHandler context = new ServletContextHandler(sanitized(contextRoot));
// context.addServlet("/__status__", new StatusServlet(200));
//
// configurations = new Configurations();
// context.addServlet("/", new ConfigurableServlet(configurations));
//
// server.addContext(context);
// }
//
// @Override
// public void configurationCreated(HttpConfiguration configuration) {
// configurations.add(configuration);
// }
//
// @Override
// public void configurationCleared() {
// configurations.reset();
// }
//
// private void assertNotBlank(String contextRoot) {
// if (isBlank(contextRoot))
// throw new IllegalArgumentException("Invalid context root");
// }
//
// private String sanitized(String contextRoot) {
// return contextRoot.startsWith("/") ? contextRoot : ("/" + contextRoot);
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/StubServer.java
import com.thoughtworks.webstub.server.context.WebConsoleContext;
import com.thoughtworks.webstub.dsl.StubDsl;
import com.thoughtworks.webstub.server.HttpServer;
import com.thoughtworks.webstub.server.JettyHttpServer;
import com.thoughtworks.webstub.server.context.ConfigurableContext;
package com.thoughtworks.webstub;
public class StubServer {
public static StubServer newServer(int port) {
return new StubServer(new JettyHttpServer(port));
}
public static StubServer newServer() {
return new StubServer(new JettyHttpServer());
}
private HttpServer httpServer;
private StubServer(HttpServer httpServer) {
this.httpServer = httpServer;
}
public StubServer withWebConsole() {
new WebConsoleContext(httpServer, "webconsole");
return this;
}
| public StubDsl stub(String contextRoot) { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/StubServer.java | // Path: src/main/java/com/thoughtworks/webstub/server/context/WebConsoleContext.java
// public class WebConsoleContext extends ContextHandler {
//
// public WebConsoleContext(HttpServer httpServer, String webAppRootDir) {
// ResourceHandler handler = new ResourceHandler();
// handler.setBaseResource(Resource.newClassPathResource(webAppRootDir));
// handler.setDirectoriesListed(true);
// handler.setWelcomeFiles(new String[] { "index.html" });
//
// this.setHandler(handler);
// this.setContextPath("/");
//
// httpServer.addContext(this);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/dsl/StubDsl.java
// public class StubDsl extends ConfigurationProvider {
//
// public StubDsl(ConfigurationListener listener) {
// super(listener);
// }
//
// public RequestBuilder get(String uri) {
// return new RequestBuilder(this).withMethod("GET").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder post(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("POST").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder put(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PUT").withUri(uri);
// }
//
// public RequestBuilder delete(String uri) {
// return new RequestBuilder(this).withMethod("DELETE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder options(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("OPTIONS").withUri(uri);
// }
//
// public RequestBuilder head(String uri) {
// return new RequestBuilder(this).withMethod("HEAD").withUri(uri);
// }
//
// public RequestBuilder trace(String uri) {
// return new RequestBuilder(this).withMethod("TRACE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder patch(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PATCH").withUri(uri);
// }
//
// public void reset() {
// configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/HttpServer.java
// public interface HttpServer {
// void start();
// void stop();
// void addContext(ContextHandler contextHandler);
// int port();
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/JettyHttpServer.java
// public class JettyHttpServer implements HttpServer {
//
// private Server server;
// private ContextHandlerCollection handlerCollection;
//
// public JettyHttpServer(int port) {
// server = new Server(port);
//
// handlerCollection = new ContextHandlerCollection();
// server.setHandler(handlerCollection);
// }
//
// public JettyHttpServer() {
// // random port
// this(0);
// }
//
// @Override
// public void addContext(ContextHandler contextHandler) {
// handlerCollection.addHandler(contextHandler);
// start(contextHandler);
// }
//
// @Override
// public int port() {
// Connector[] connectors = server.getConnectors();
// for (Connector connector : connectors) {
// if (connector instanceof ServerConnector)
// return ((ServerConnector) connector).getLocalPort();
// }
//
// throw new IllegalStateException("Couldn't find a server connector; this is absurd!");
// }
//
// @Override
// public void start() {
// try {
// server.start();
// } catch (Exception e) {
// throw new RuntimeException("Unable to start server", e);
// }
// }
//
// @Override
// public void stop() {
// try {
// server.stop();
// } catch (Exception e) {
// throw new RuntimeException("Unable to stop server", e);
// }
// }
//
// private void start(ContextHandler contextHandler) {
// try {
// contextHandler.start();
// } catch (Exception e) {
// throw new RuntimeException("Error starting context: " + contextHandler.getDisplayName(), e);
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/context/ConfigurableContext.java
// public class ConfigurableContext implements ConfigurationListener {
// private Configurations configurations;
//
// public ConfigurableContext(HttpServer server, String contextRoot) {
// assertNotBlank(contextRoot);
//
// ServletContextHandler context = new ServletContextHandler(sanitized(contextRoot));
// context.addServlet("/__status__", new StatusServlet(200));
//
// configurations = new Configurations();
// context.addServlet("/", new ConfigurableServlet(configurations));
//
// server.addContext(context);
// }
//
// @Override
// public void configurationCreated(HttpConfiguration configuration) {
// configurations.add(configuration);
// }
//
// @Override
// public void configurationCleared() {
// configurations.reset();
// }
//
// private void assertNotBlank(String contextRoot) {
// if (isBlank(contextRoot))
// throw new IllegalArgumentException("Invalid context root");
// }
//
// private String sanitized(String contextRoot) {
// return contextRoot.startsWith("/") ? contextRoot : ("/" + contextRoot);
// }
// }
| import com.thoughtworks.webstub.server.context.WebConsoleContext;
import com.thoughtworks.webstub.dsl.StubDsl;
import com.thoughtworks.webstub.server.HttpServer;
import com.thoughtworks.webstub.server.JettyHttpServer;
import com.thoughtworks.webstub.server.context.ConfigurableContext; | package com.thoughtworks.webstub;
public class StubServer {
public static StubServer newServer(int port) {
return new StubServer(new JettyHttpServer(port));
}
public static StubServer newServer() {
return new StubServer(new JettyHttpServer());
}
private HttpServer httpServer;
private StubServer(HttpServer httpServer) {
this.httpServer = httpServer;
}
public StubServer withWebConsole() {
new WebConsoleContext(httpServer, "webconsole");
return this;
}
public StubDsl stub(String contextRoot) {
if (contextRoot.equals("/"))
throw new IllegalArgumentException("The root context cannot be stubbed since is reserved for internal use.");
| // Path: src/main/java/com/thoughtworks/webstub/server/context/WebConsoleContext.java
// public class WebConsoleContext extends ContextHandler {
//
// public WebConsoleContext(HttpServer httpServer, String webAppRootDir) {
// ResourceHandler handler = new ResourceHandler();
// handler.setBaseResource(Resource.newClassPathResource(webAppRootDir));
// handler.setDirectoriesListed(true);
// handler.setWelcomeFiles(new String[] { "index.html" });
//
// this.setHandler(handler);
// this.setContextPath("/");
//
// httpServer.addContext(this);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/dsl/StubDsl.java
// public class StubDsl extends ConfigurationProvider {
//
// public StubDsl(ConfigurationListener listener) {
// super(listener);
// }
//
// public RequestBuilder get(String uri) {
// return new RequestBuilder(this).withMethod("GET").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder post(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("POST").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder put(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PUT").withUri(uri);
// }
//
// public RequestBuilder delete(String uri) {
// return new RequestBuilder(this).withMethod("DELETE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder options(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("OPTIONS").withUri(uri);
// }
//
// public RequestBuilder head(String uri) {
// return new RequestBuilder(this).withMethod("HEAD").withUri(uri);
// }
//
// public RequestBuilder trace(String uri) {
// return new RequestBuilder(this).withMethod("TRACE").withUri(uri);
// }
//
// public EntityEnclosingRequestBuilder patch(String uri) {
// return new EntityEnclosingRequestBuilder(this).withMethod("PATCH").withUri(uri);
// }
//
// public void reset() {
// configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/HttpServer.java
// public interface HttpServer {
// void start();
// void stop();
// void addContext(ContextHandler contextHandler);
// int port();
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/JettyHttpServer.java
// public class JettyHttpServer implements HttpServer {
//
// private Server server;
// private ContextHandlerCollection handlerCollection;
//
// public JettyHttpServer(int port) {
// server = new Server(port);
//
// handlerCollection = new ContextHandlerCollection();
// server.setHandler(handlerCollection);
// }
//
// public JettyHttpServer() {
// // random port
// this(0);
// }
//
// @Override
// public void addContext(ContextHandler contextHandler) {
// handlerCollection.addHandler(contextHandler);
// start(contextHandler);
// }
//
// @Override
// public int port() {
// Connector[] connectors = server.getConnectors();
// for (Connector connector : connectors) {
// if (connector instanceof ServerConnector)
// return ((ServerConnector) connector).getLocalPort();
// }
//
// throw new IllegalStateException("Couldn't find a server connector; this is absurd!");
// }
//
// @Override
// public void start() {
// try {
// server.start();
// } catch (Exception e) {
// throw new RuntimeException("Unable to start server", e);
// }
// }
//
// @Override
// public void stop() {
// try {
// server.stop();
// } catch (Exception e) {
// throw new RuntimeException("Unable to stop server", e);
// }
// }
//
// private void start(ContextHandler contextHandler) {
// try {
// contextHandler.start();
// } catch (Exception e) {
// throw new RuntimeException("Error starting context: " + contextHandler.getDisplayName(), e);
// }
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/context/ConfigurableContext.java
// public class ConfigurableContext implements ConfigurationListener {
// private Configurations configurations;
//
// public ConfigurableContext(HttpServer server, String contextRoot) {
// assertNotBlank(contextRoot);
//
// ServletContextHandler context = new ServletContextHandler(sanitized(contextRoot));
// context.addServlet("/__status__", new StatusServlet(200));
//
// configurations = new Configurations();
// context.addServlet("/", new ConfigurableServlet(configurations));
//
// server.addContext(context);
// }
//
// @Override
// public void configurationCreated(HttpConfiguration configuration) {
// configurations.add(configuration);
// }
//
// @Override
// public void configurationCleared() {
// configurations.reset();
// }
//
// private void assertNotBlank(String contextRoot) {
// if (isBlank(contextRoot))
// throw new IllegalArgumentException("Invalid context root");
// }
//
// private String sanitized(String contextRoot) {
// return contextRoot.startsWith("/") ? contextRoot : ("/" + contextRoot);
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/StubServer.java
import com.thoughtworks.webstub.server.context.WebConsoleContext;
import com.thoughtworks.webstub.dsl.StubDsl;
import com.thoughtworks.webstub.server.HttpServer;
import com.thoughtworks.webstub.server.JettyHttpServer;
import com.thoughtworks.webstub.server.context.ConfigurableContext;
package com.thoughtworks.webstub;
public class StubServer {
public static StubServer newServer(int port) {
return new StubServer(new JettyHttpServer(port));
}
public static StubServer newServer() {
return new StubServer(new JettyHttpServer());
}
private HttpServer httpServer;
private StubServer(HttpServer httpServer) {
this.httpServer = httpServer;
}
public StubServer withWebConsole() {
new WebConsoleContext(httpServer, "webconsole");
return this;
}
public StubDsl stub(String contextRoot) {
if (contextRoot.equals("/"))
throw new IllegalArgumentException("The root context cannot be stubbed since is reserved for internal use.");
| return new StubDsl(new ConfigurableContext(httpServer, contextRoot)); |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/server/servlet/matcher/MethodMatcher.java | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
| import com.thoughtworks.webstub.config.HttpConfiguration;
import javax.servlet.http.HttpServletRequest;
import static javax.servlet.http.HttpServletResponse.SC_NOT_IMPLEMENTED; | package com.thoughtworks.webstub.server.servlet.matcher;
public class MethodMatcher extends RequestPartMatcher {
public MethodMatcher(HttpServletRequest request) {
super(request, SC_NOT_IMPLEMENTED);
}
@Override | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/matcher/MethodMatcher.java
import com.thoughtworks.webstub.config.HttpConfiguration;
import javax.servlet.http.HttpServletRequest;
import static javax.servlet.http.HttpServletResponse.SC_NOT_IMPLEMENTED;
package com.thoughtworks.webstub.server.servlet.matcher;
public class MethodMatcher extends RequestPartMatcher {
public MethodMatcher(HttpServletRequest request) {
super(request, SC_NOT_IMPLEMENTED);
}
@Override | public boolean matches(HttpConfiguration configuration) { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/server/servlet/creator/HeadersCreator.java | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
| import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.config.Header;
import javax.servlet.http.HttpServletResponse; | package com.thoughtworks.webstub.server.servlet.creator;
public class HeadersCreator extends ResponsePartCreator {
public HeadersCreator(HttpConfiguration configuration) {
super(configuration);
}
@Override
public void createFor(HttpServletResponse response) { | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/creator/HeadersCreator.java
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.config.Header;
import javax.servlet.http.HttpServletResponse;
package com.thoughtworks.webstub.server.servlet.creator;
public class HeadersCreator extends ResponsePartCreator {
public HeadersCreator(HttpConfiguration configuration) {
super(configuration);
}
@Override
public void createFor(HttpServletResponse response) { | for (Header header : configuration.response().headers()) { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/dsl/StubDsl.java | // Path: src/main/java/com/thoughtworks/webstub/dsl/builders/EntityEnclosingRequestBuilder.java
// public class EntityEnclosingRequestBuilder extends RequestBuilder<EntityEnclosingRequestBuilder> {
// private String content;
//
// public EntityEnclosingRequestBuilder(ConfigurationProvider configurationProvider) {
// super(configurationProvider);
// }
//
// public EntityEnclosingRequestBuilder withContent(String content) {
// return withContent(new StringContentBuilder(content));
// }
//
// public EntityEnclosingRequestBuilder withContent(ContentBuilder contentBuilder) {
// this.content = contentBuilder.build();
// return this;
// }
//
// @Override
// protected Request build() {
// return new Request(method, uri, content, headers);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/dsl/builders/RequestBuilder.java
// public class RequestBuilder<T extends RequestBuilder<T>> {
// private ConfigurationProvider configurationProvider;
// protected String uri;
// protected String method;
// protected Collection<Header> headers = new ArrayList<Header>();
//
// public RequestBuilder(ConfigurationProvider configurationProvider) {
// this.configurationProvider = configurationProvider;
// }
//
// public T withMethod(String method) {
// this.method = method;
// return (T) this;
// }
//
// public T withUri(String uri) {
// this.uri = uri;
// return (T) this;
// }
//
// public T withHeader(String name, String value) {
// headers.add(new Header(name, value));
// return (T) this;
// }
//
// public T withHeaders(Map<String, String> headersMap) {
// headers.clear();
// for (Map.Entry<String, String> entry : headersMap.entrySet()) {
// headers.add(new Header(entry.getKey(), entry.getValue()));
// }
// return (T) this;
// }
//
// protected Request build() {
// return new Request(method, uri, null, headers);
// }
//
// public final void returns(ResponseBuilder responseBuilder) {
// configurationProvider.configurationCreated(new HttpConfiguration(this.build(), responseBuilder.build()));
// }
// }
| import com.thoughtworks.webstub.config.*;
import com.thoughtworks.webstub.dsl.builders.EntityEnclosingRequestBuilder;
import com.thoughtworks.webstub.dsl.builders.RequestBuilder; | package com.thoughtworks.webstub.dsl;
public class StubDsl extends ConfigurationProvider {
public StubDsl(ConfigurationListener listener) {
super(listener);
}
| // Path: src/main/java/com/thoughtworks/webstub/dsl/builders/EntityEnclosingRequestBuilder.java
// public class EntityEnclosingRequestBuilder extends RequestBuilder<EntityEnclosingRequestBuilder> {
// private String content;
//
// public EntityEnclosingRequestBuilder(ConfigurationProvider configurationProvider) {
// super(configurationProvider);
// }
//
// public EntityEnclosingRequestBuilder withContent(String content) {
// return withContent(new StringContentBuilder(content));
// }
//
// public EntityEnclosingRequestBuilder withContent(ContentBuilder contentBuilder) {
// this.content = contentBuilder.build();
// return this;
// }
//
// @Override
// protected Request build() {
// return new Request(method, uri, content, headers);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/dsl/builders/RequestBuilder.java
// public class RequestBuilder<T extends RequestBuilder<T>> {
// private ConfigurationProvider configurationProvider;
// protected String uri;
// protected String method;
// protected Collection<Header> headers = new ArrayList<Header>();
//
// public RequestBuilder(ConfigurationProvider configurationProvider) {
// this.configurationProvider = configurationProvider;
// }
//
// public T withMethod(String method) {
// this.method = method;
// return (T) this;
// }
//
// public T withUri(String uri) {
// this.uri = uri;
// return (T) this;
// }
//
// public T withHeader(String name, String value) {
// headers.add(new Header(name, value));
// return (T) this;
// }
//
// public T withHeaders(Map<String, String> headersMap) {
// headers.clear();
// for (Map.Entry<String, String> entry : headersMap.entrySet()) {
// headers.add(new Header(entry.getKey(), entry.getValue()));
// }
// return (T) this;
// }
//
// protected Request build() {
// return new Request(method, uri, null, headers);
// }
//
// public final void returns(ResponseBuilder responseBuilder) {
// configurationProvider.configurationCreated(new HttpConfiguration(this.build(), responseBuilder.build()));
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/dsl/StubDsl.java
import com.thoughtworks.webstub.config.*;
import com.thoughtworks.webstub.dsl.builders.EntityEnclosingRequestBuilder;
import com.thoughtworks.webstub.dsl.builders.RequestBuilder;
package com.thoughtworks.webstub.dsl;
public class StubDsl extends ConfigurationProvider {
public StubDsl(ConfigurationListener listener) {
super(listener);
}
| public RequestBuilder get(String uri) { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/dsl/StubDsl.java | // Path: src/main/java/com/thoughtworks/webstub/dsl/builders/EntityEnclosingRequestBuilder.java
// public class EntityEnclosingRequestBuilder extends RequestBuilder<EntityEnclosingRequestBuilder> {
// private String content;
//
// public EntityEnclosingRequestBuilder(ConfigurationProvider configurationProvider) {
// super(configurationProvider);
// }
//
// public EntityEnclosingRequestBuilder withContent(String content) {
// return withContent(new StringContentBuilder(content));
// }
//
// public EntityEnclosingRequestBuilder withContent(ContentBuilder contentBuilder) {
// this.content = contentBuilder.build();
// return this;
// }
//
// @Override
// protected Request build() {
// return new Request(method, uri, content, headers);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/dsl/builders/RequestBuilder.java
// public class RequestBuilder<T extends RequestBuilder<T>> {
// private ConfigurationProvider configurationProvider;
// protected String uri;
// protected String method;
// protected Collection<Header> headers = new ArrayList<Header>();
//
// public RequestBuilder(ConfigurationProvider configurationProvider) {
// this.configurationProvider = configurationProvider;
// }
//
// public T withMethod(String method) {
// this.method = method;
// return (T) this;
// }
//
// public T withUri(String uri) {
// this.uri = uri;
// return (T) this;
// }
//
// public T withHeader(String name, String value) {
// headers.add(new Header(name, value));
// return (T) this;
// }
//
// public T withHeaders(Map<String, String> headersMap) {
// headers.clear();
// for (Map.Entry<String, String> entry : headersMap.entrySet()) {
// headers.add(new Header(entry.getKey(), entry.getValue()));
// }
// return (T) this;
// }
//
// protected Request build() {
// return new Request(method, uri, null, headers);
// }
//
// public final void returns(ResponseBuilder responseBuilder) {
// configurationProvider.configurationCreated(new HttpConfiguration(this.build(), responseBuilder.build()));
// }
// }
| import com.thoughtworks.webstub.config.*;
import com.thoughtworks.webstub.dsl.builders.EntityEnclosingRequestBuilder;
import com.thoughtworks.webstub.dsl.builders.RequestBuilder; | package com.thoughtworks.webstub.dsl;
public class StubDsl extends ConfigurationProvider {
public StubDsl(ConfigurationListener listener) {
super(listener);
}
public RequestBuilder get(String uri) {
return new RequestBuilder(this).withMethod("GET").withUri(uri);
}
| // Path: src/main/java/com/thoughtworks/webstub/dsl/builders/EntityEnclosingRequestBuilder.java
// public class EntityEnclosingRequestBuilder extends RequestBuilder<EntityEnclosingRequestBuilder> {
// private String content;
//
// public EntityEnclosingRequestBuilder(ConfigurationProvider configurationProvider) {
// super(configurationProvider);
// }
//
// public EntityEnclosingRequestBuilder withContent(String content) {
// return withContent(new StringContentBuilder(content));
// }
//
// public EntityEnclosingRequestBuilder withContent(ContentBuilder contentBuilder) {
// this.content = contentBuilder.build();
// return this;
// }
//
// @Override
// protected Request build() {
// return new Request(method, uri, content, headers);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/dsl/builders/RequestBuilder.java
// public class RequestBuilder<T extends RequestBuilder<T>> {
// private ConfigurationProvider configurationProvider;
// protected String uri;
// protected String method;
// protected Collection<Header> headers = new ArrayList<Header>();
//
// public RequestBuilder(ConfigurationProvider configurationProvider) {
// this.configurationProvider = configurationProvider;
// }
//
// public T withMethod(String method) {
// this.method = method;
// return (T) this;
// }
//
// public T withUri(String uri) {
// this.uri = uri;
// return (T) this;
// }
//
// public T withHeader(String name, String value) {
// headers.add(new Header(name, value));
// return (T) this;
// }
//
// public T withHeaders(Map<String, String> headersMap) {
// headers.clear();
// for (Map.Entry<String, String> entry : headersMap.entrySet()) {
// headers.add(new Header(entry.getKey(), entry.getValue()));
// }
// return (T) this;
// }
//
// protected Request build() {
// return new Request(method, uri, null, headers);
// }
//
// public final void returns(ResponseBuilder responseBuilder) {
// configurationProvider.configurationCreated(new HttpConfiguration(this.build(), responseBuilder.build()));
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/dsl/StubDsl.java
import com.thoughtworks.webstub.config.*;
import com.thoughtworks.webstub.dsl.builders.EntityEnclosingRequestBuilder;
import com.thoughtworks.webstub.dsl.builders.RequestBuilder;
package com.thoughtworks.webstub.dsl;
public class StubDsl extends ConfigurationProvider {
public StubDsl(ConfigurationListener listener) {
super(listener);
}
public RequestBuilder get(String uri) {
return new RequestBuilder(this).withMethod("GET").withUri(uri);
}
| public EntityEnclosingRequestBuilder post(String uri) { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/dsl/builders/RequestBuilder.java | // Path: src/main/java/com/thoughtworks/webstub/config/ConfigurationProvider.java
// public abstract class ConfigurationProvider {
// private ConfigurationListener listener;
//
// protected ConfigurationProvider(ConfigurationListener listener) {
// this.listener = listener;
// }
//
// public void configurationCreated(HttpConfiguration configuration) {
// listener.configurationCreated(configuration);
// }
//
// protected void configurationCleared() {
// listener.configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Request.java
// public class Request {
// private String uri;
// private String method;
// private String content;
// private Collection<Header> headers = new ArrayList<>();
//
// public Request(String method, String uri) {
// this.method = method;
// this.uri = uri;
// }
//
// public Request(String method, String uri, String content) {
// this(method, uri);
// this.content = content;
// }
//
// public Request(String method, String uri, String content, Collection<Header> headers) {
// this(method, uri, content);
// this.headers = headers;
// }
//
// public String content() {
// return content;
// }
//
// public String uri() {
// return uri;
// }
//
// public String method() {
// return method;
// }
//
// public Collection<Header> headers() {
// return headers;
// }
//
// @Override
// public boolean equals(Object o) {
// if (! (o instanceof Request)) return false;
//
// Request that = (Request) o;
// return new EqualsBuilder()
// .append(method, that.method)
// .append(uri, that.uri)
// .append(content, that.content)
// .append(headers, that.headers)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = uri.hashCode();
// result = 31 * result + method.hashCode();
// result = 31 * result + (content != null ? content.hashCode() : 0);
// result = 31 * result + (headers != null ? headers.hashCode() : 0);
// return result;
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
| import com.thoughtworks.webstub.config.ConfigurationProvider;
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.config.Request;
import com.thoughtworks.webstub.config.Header;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map; | package com.thoughtworks.webstub.dsl.builders;
public class RequestBuilder<T extends RequestBuilder<T>> {
private ConfigurationProvider configurationProvider;
protected String uri;
protected String method; | // Path: src/main/java/com/thoughtworks/webstub/config/ConfigurationProvider.java
// public abstract class ConfigurationProvider {
// private ConfigurationListener listener;
//
// protected ConfigurationProvider(ConfigurationListener listener) {
// this.listener = listener;
// }
//
// public void configurationCreated(HttpConfiguration configuration) {
// listener.configurationCreated(configuration);
// }
//
// protected void configurationCleared() {
// listener.configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Request.java
// public class Request {
// private String uri;
// private String method;
// private String content;
// private Collection<Header> headers = new ArrayList<>();
//
// public Request(String method, String uri) {
// this.method = method;
// this.uri = uri;
// }
//
// public Request(String method, String uri, String content) {
// this(method, uri);
// this.content = content;
// }
//
// public Request(String method, String uri, String content, Collection<Header> headers) {
// this(method, uri, content);
// this.headers = headers;
// }
//
// public String content() {
// return content;
// }
//
// public String uri() {
// return uri;
// }
//
// public String method() {
// return method;
// }
//
// public Collection<Header> headers() {
// return headers;
// }
//
// @Override
// public boolean equals(Object o) {
// if (! (o instanceof Request)) return false;
//
// Request that = (Request) o;
// return new EqualsBuilder()
// .append(method, that.method)
// .append(uri, that.uri)
// .append(content, that.content)
// .append(headers, that.headers)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = uri.hashCode();
// result = 31 * result + method.hashCode();
// result = 31 * result + (content != null ? content.hashCode() : 0);
// result = 31 * result + (headers != null ? headers.hashCode() : 0);
// return result;
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/dsl/builders/RequestBuilder.java
import com.thoughtworks.webstub.config.ConfigurationProvider;
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.config.Request;
import com.thoughtworks.webstub.config.Header;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
package com.thoughtworks.webstub.dsl.builders;
public class RequestBuilder<T extends RequestBuilder<T>> {
private ConfigurationProvider configurationProvider;
protected String uri;
protected String method; | protected Collection<Header> headers = new ArrayList<Header>(); |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/dsl/builders/RequestBuilder.java | // Path: src/main/java/com/thoughtworks/webstub/config/ConfigurationProvider.java
// public abstract class ConfigurationProvider {
// private ConfigurationListener listener;
//
// protected ConfigurationProvider(ConfigurationListener listener) {
// this.listener = listener;
// }
//
// public void configurationCreated(HttpConfiguration configuration) {
// listener.configurationCreated(configuration);
// }
//
// protected void configurationCleared() {
// listener.configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Request.java
// public class Request {
// private String uri;
// private String method;
// private String content;
// private Collection<Header> headers = new ArrayList<>();
//
// public Request(String method, String uri) {
// this.method = method;
// this.uri = uri;
// }
//
// public Request(String method, String uri, String content) {
// this(method, uri);
// this.content = content;
// }
//
// public Request(String method, String uri, String content, Collection<Header> headers) {
// this(method, uri, content);
// this.headers = headers;
// }
//
// public String content() {
// return content;
// }
//
// public String uri() {
// return uri;
// }
//
// public String method() {
// return method;
// }
//
// public Collection<Header> headers() {
// return headers;
// }
//
// @Override
// public boolean equals(Object o) {
// if (! (o instanceof Request)) return false;
//
// Request that = (Request) o;
// return new EqualsBuilder()
// .append(method, that.method)
// .append(uri, that.uri)
// .append(content, that.content)
// .append(headers, that.headers)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = uri.hashCode();
// result = 31 * result + method.hashCode();
// result = 31 * result + (content != null ? content.hashCode() : 0);
// result = 31 * result + (headers != null ? headers.hashCode() : 0);
// return result;
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
| import com.thoughtworks.webstub.config.ConfigurationProvider;
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.config.Request;
import com.thoughtworks.webstub.config.Header;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map; | package com.thoughtworks.webstub.dsl.builders;
public class RequestBuilder<T extends RequestBuilder<T>> {
private ConfigurationProvider configurationProvider;
protected String uri;
protected String method;
protected Collection<Header> headers = new ArrayList<Header>();
public RequestBuilder(ConfigurationProvider configurationProvider) {
this.configurationProvider = configurationProvider;
}
public T withMethod(String method) {
this.method = method;
return (T) this;
}
public T withUri(String uri) {
this.uri = uri;
return (T) this;
}
public T withHeader(String name, String value) {
headers.add(new Header(name, value));
return (T) this;
}
public T withHeaders(Map<String, String> headersMap) {
headers.clear();
for (Map.Entry<String, String> entry : headersMap.entrySet()) {
headers.add(new Header(entry.getKey(), entry.getValue()));
}
return (T) this;
}
| // Path: src/main/java/com/thoughtworks/webstub/config/ConfigurationProvider.java
// public abstract class ConfigurationProvider {
// private ConfigurationListener listener;
//
// protected ConfigurationProvider(ConfigurationListener listener) {
// this.listener = listener;
// }
//
// public void configurationCreated(HttpConfiguration configuration) {
// listener.configurationCreated(configuration);
// }
//
// protected void configurationCleared() {
// listener.configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Request.java
// public class Request {
// private String uri;
// private String method;
// private String content;
// private Collection<Header> headers = new ArrayList<>();
//
// public Request(String method, String uri) {
// this.method = method;
// this.uri = uri;
// }
//
// public Request(String method, String uri, String content) {
// this(method, uri);
// this.content = content;
// }
//
// public Request(String method, String uri, String content, Collection<Header> headers) {
// this(method, uri, content);
// this.headers = headers;
// }
//
// public String content() {
// return content;
// }
//
// public String uri() {
// return uri;
// }
//
// public String method() {
// return method;
// }
//
// public Collection<Header> headers() {
// return headers;
// }
//
// @Override
// public boolean equals(Object o) {
// if (! (o instanceof Request)) return false;
//
// Request that = (Request) o;
// return new EqualsBuilder()
// .append(method, that.method)
// .append(uri, that.uri)
// .append(content, that.content)
// .append(headers, that.headers)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = uri.hashCode();
// result = 31 * result + method.hashCode();
// result = 31 * result + (content != null ? content.hashCode() : 0);
// result = 31 * result + (headers != null ? headers.hashCode() : 0);
// return result;
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/dsl/builders/RequestBuilder.java
import com.thoughtworks.webstub.config.ConfigurationProvider;
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.config.Request;
import com.thoughtworks.webstub.config.Header;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
package com.thoughtworks.webstub.dsl.builders;
public class RequestBuilder<T extends RequestBuilder<T>> {
private ConfigurationProvider configurationProvider;
protected String uri;
protected String method;
protected Collection<Header> headers = new ArrayList<Header>();
public RequestBuilder(ConfigurationProvider configurationProvider) {
this.configurationProvider = configurationProvider;
}
public T withMethod(String method) {
this.method = method;
return (T) this;
}
public T withUri(String uri) {
this.uri = uri;
return (T) this;
}
public T withHeader(String name, String value) {
headers.add(new Header(name, value));
return (T) this;
}
public T withHeaders(Map<String, String> headersMap) {
headers.clear();
for (Map.Entry<String, String> entry : headersMap.entrySet()) {
headers.add(new Header(entry.getKey(), entry.getValue()));
}
return (T) this;
}
| protected Request build() { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/dsl/builders/RequestBuilder.java | // Path: src/main/java/com/thoughtworks/webstub/config/ConfigurationProvider.java
// public abstract class ConfigurationProvider {
// private ConfigurationListener listener;
//
// protected ConfigurationProvider(ConfigurationListener listener) {
// this.listener = listener;
// }
//
// public void configurationCreated(HttpConfiguration configuration) {
// listener.configurationCreated(configuration);
// }
//
// protected void configurationCleared() {
// listener.configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Request.java
// public class Request {
// private String uri;
// private String method;
// private String content;
// private Collection<Header> headers = new ArrayList<>();
//
// public Request(String method, String uri) {
// this.method = method;
// this.uri = uri;
// }
//
// public Request(String method, String uri, String content) {
// this(method, uri);
// this.content = content;
// }
//
// public Request(String method, String uri, String content, Collection<Header> headers) {
// this(method, uri, content);
// this.headers = headers;
// }
//
// public String content() {
// return content;
// }
//
// public String uri() {
// return uri;
// }
//
// public String method() {
// return method;
// }
//
// public Collection<Header> headers() {
// return headers;
// }
//
// @Override
// public boolean equals(Object o) {
// if (! (o instanceof Request)) return false;
//
// Request that = (Request) o;
// return new EqualsBuilder()
// .append(method, that.method)
// .append(uri, that.uri)
// .append(content, that.content)
// .append(headers, that.headers)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = uri.hashCode();
// result = 31 * result + method.hashCode();
// result = 31 * result + (content != null ? content.hashCode() : 0);
// result = 31 * result + (headers != null ? headers.hashCode() : 0);
// return result;
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
| import com.thoughtworks.webstub.config.ConfigurationProvider;
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.config.Request;
import com.thoughtworks.webstub.config.Header;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map; | }
public T withMethod(String method) {
this.method = method;
return (T) this;
}
public T withUri(String uri) {
this.uri = uri;
return (T) this;
}
public T withHeader(String name, String value) {
headers.add(new Header(name, value));
return (T) this;
}
public T withHeaders(Map<String, String> headersMap) {
headers.clear();
for (Map.Entry<String, String> entry : headersMap.entrySet()) {
headers.add(new Header(entry.getKey(), entry.getValue()));
}
return (T) this;
}
protected Request build() {
return new Request(method, uri, null, headers);
}
public final void returns(ResponseBuilder responseBuilder) { | // Path: src/main/java/com/thoughtworks/webstub/config/ConfigurationProvider.java
// public abstract class ConfigurationProvider {
// private ConfigurationListener listener;
//
// protected ConfigurationProvider(ConfigurationListener listener) {
// this.listener = listener;
// }
//
// public void configurationCreated(HttpConfiguration configuration) {
// listener.configurationCreated(configuration);
// }
//
// protected void configurationCleared() {
// listener.configurationCleared();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Request.java
// public class Request {
// private String uri;
// private String method;
// private String content;
// private Collection<Header> headers = new ArrayList<>();
//
// public Request(String method, String uri) {
// this.method = method;
// this.uri = uri;
// }
//
// public Request(String method, String uri, String content) {
// this(method, uri);
// this.content = content;
// }
//
// public Request(String method, String uri, String content, Collection<Header> headers) {
// this(method, uri, content);
// this.headers = headers;
// }
//
// public String content() {
// return content;
// }
//
// public String uri() {
// return uri;
// }
//
// public String method() {
// return method;
// }
//
// public Collection<Header> headers() {
// return headers;
// }
//
// @Override
// public boolean equals(Object o) {
// if (! (o instanceof Request)) return false;
//
// Request that = (Request) o;
// return new EqualsBuilder()
// .append(method, that.method)
// .append(uri, that.uri)
// .append(content, that.content)
// .append(headers, that.headers)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = uri.hashCode();
// result = 31 * result + method.hashCode();
// result = 31 * result + (content != null ? content.hashCode() : 0);
// result = 31 * result + (headers != null ? headers.hashCode() : 0);
// return result;
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/dsl/builders/RequestBuilder.java
import com.thoughtworks.webstub.config.ConfigurationProvider;
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.config.Request;
import com.thoughtworks.webstub.config.Header;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
}
public T withMethod(String method) {
this.method = method;
return (T) this;
}
public T withUri(String uri) {
this.uri = uri;
return (T) this;
}
public T withHeader(String name, String value) {
headers.add(new Header(name, value));
return (T) this;
}
public T withHeaders(Map<String, String> headersMap) {
headers.clear();
for (Map.Entry<String, String> entry : headersMap.entrySet()) {
headers.add(new Header(entry.getKey(), entry.getValue()));
}
return (T) this;
}
protected Request build() {
return new Request(method, uri, null, headers);
}
public final void returns(ResponseBuilder responseBuilder) { | configurationProvider.configurationCreated(new HttpConfiguration(this.build(), responseBuilder.build())); |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/server/servlet/matcher/HeadersMatcher.java | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/Predicate.java
// public abstract class Predicate<T> implements org.apache.commons.collections.Predicate {
// public abstract boolean satisfies(T t);
//
// @Override
// public final boolean evaluate(Object o) {
// return satisfies((T) o);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/CollectionUtils.java
// public static <T> boolean exists(Collection<T> collection, com.thoughtworks.webstub.utils.Predicate<T> predicate) {
// for (T t : collection) {
// if (predicate.satisfies(t))
// return true;
// }
//
// return false;
// }
| import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.config.Header;
import com.thoughtworks.webstub.utils.Predicate;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Collection;
import static com.thoughtworks.webstub.utils.CollectionUtils.exists;
import static javax.servlet.http.HttpServletResponse.SC_PRECONDITION_FAILED; | package com.thoughtworks.webstub.server.servlet.matcher;
public class HeadersMatcher extends RequestPartMatcher {
public HeadersMatcher(HttpServletRequest request) {
super(request, SC_PRECONDITION_FAILED);
}
@Override | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/Predicate.java
// public abstract class Predicate<T> implements org.apache.commons.collections.Predicate {
// public abstract boolean satisfies(T t);
//
// @Override
// public final boolean evaluate(Object o) {
// return satisfies((T) o);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/CollectionUtils.java
// public static <T> boolean exists(Collection<T> collection, com.thoughtworks.webstub.utils.Predicate<T> predicate) {
// for (T t : collection) {
// if (predicate.satisfies(t))
// return true;
// }
//
// return false;
// }
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/matcher/HeadersMatcher.java
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.config.Header;
import com.thoughtworks.webstub.utils.Predicate;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Collection;
import static com.thoughtworks.webstub.utils.CollectionUtils.exists;
import static javax.servlet.http.HttpServletResponse.SC_PRECONDITION_FAILED;
package com.thoughtworks.webstub.server.servlet.matcher;
public class HeadersMatcher extends RequestPartMatcher {
public HeadersMatcher(HttpServletRequest request) {
super(request, SC_PRECONDITION_FAILED);
}
@Override | public boolean matches(HttpConfiguration configuration) throws IOException { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/server/servlet/matcher/HeadersMatcher.java | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/Predicate.java
// public abstract class Predicate<T> implements org.apache.commons.collections.Predicate {
// public abstract boolean satisfies(T t);
//
// @Override
// public final boolean evaluate(Object o) {
// return satisfies((T) o);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/CollectionUtils.java
// public static <T> boolean exists(Collection<T> collection, com.thoughtworks.webstub.utils.Predicate<T> predicate) {
// for (T t : collection) {
// if (predicate.satisfies(t))
// return true;
// }
//
// return false;
// }
| import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.config.Header;
import com.thoughtworks.webstub.utils.Predicate;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Collection;
import static com.thoughtworks.webstub.utils.CollectionUtils.exists;
import static javax.servlet.http.HttpServletResponse.SC_PRECONDITION_FAILED; | package com.thoughtworks.webstub.server.servlet.matcher;
public class HeadersMatcher extends RequestPartMatcher {
public HeadersMatcher(HttpServletRequest request) {
super(request, SC_PRECONDITION_FAILED);
}
@Override
public boolean matches(HttpConfiguration configuration) throws IOException { | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/Predicate.java
// public abstract class Predicate<T> implements org.apache.commons.collections.Predicate {
// public abstract boolean satisfies(T t);
//
// @Override
// public final boolean evaluate(Object o) {
// return satisfies((T) o);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/CollectionUtils.java
// public static <T> boolean exists(Collection<T> collection, com.thoughtworks.webstub.utils.Predicate<T> predicate) {
// for (T t : collection) {
// if (predicate.satisfies(t))
// return true;
// }
//
// return false;
// }
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/matcher/HeadersMatcher.java
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.config.Header;
import com.thoughtworks.webstub.utils.Predicate;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Collection;
import static com.thoughtworks.webstub.utils.CollectionUtils.exists;
import static javax.servlet.http.HttpServletResponse.SC_PRECONDITION_FAILED;
package com.thoughtworks.webstub.server.servlet.matcher;
public class HeadersMatcher extends RequestPartMatcher {
public HeadersMatcher(HttpServletRequest request) {
super(request, SC_PRECONDITION_FAILED);
}
@Override
public boolean matches(HttpConfiguration configuration) throws IOException { | return !exists(getHeaders(configuration), new Predicate<Header>() { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/server/servlet/matcher/HeadersMatcher.java | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/Predicate.java
// public abstract class Predicate<T> implements org.apache.commons.collections.Predicate {
// public abstract boolean satisfies(T t);
//
// @Override
// public final boolean evaluate(Object o) {
// return satisfies((T) o);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/CollectionUtils.java
// public static <T> boolean exists(Collection<T> collection, com.thoughtworks.webstub.utils.Predicate<T> predicate) {
// for (T t : collection) {
// if (predicate.satisfies(t))
// return true;
// }
//
// return false;
// }
| import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.config.Header;
import com.thoughtworks.webstub.utils.Predicate;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Collection;
import static com.thoughtworks.webstub.utils.CollectionUtils.exists;
import static javax.servlet.http.HttpServletResponse.SC_PRECONDITION_FAILED; | package com.thoughtworks.webstub.server.servlet.matcher;
public class HeadersMatcher extends RequestPartMatcher {
public HeadersMatcher(HttpServletRequest request) {
super(request, SC_PRECONDITION_FAILED);
}
@Override
public boolean matches(HttpConfiguration configuration) throws IOException { | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/Predicate.java
// public abstract class Predicate<T> implements org.apache.commons.collections.Predicate {
// public abstract boolean satisfies(T t);
//
// @Override
// public final boolean evaluate(Object o) {
// return satisfies((T) o);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/CollectionUtils.java
// public static <T> boolean exists(Collection<T> collection, com.thoughtworks.webstub.utils.Predicate<T> predicate) {
// for (T t : collection) {
// if (predicate.satisfies(t))
// return true;
// }
//
// return false;
// }
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/matcher/HeadersMatcher.java
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.config.Header;
import com.thoughtworks.webstub.utils.Predicate;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Collection;
import static com.thoughtworks.webstub.utils.CollectionUtils.exists;
import static javax.servlet.http.HttpServletResponse.SC_PRECONDITION_FAILED;
package com.thoughtworks.webstub.server.servlet.matcher;
public class HeadersMatcher extends RequestPartMatcher {
public HeadersMatcher(HttpServletRequest request) {
super(request, SC_PRECONDITION_FAILED);
}
@Override
public boolean matches(HttpConfiguration configuration) throws IOException { | return !exists(getHeaders(configuration), new Predicate<Header>() { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/server/servlet/matcher/HeadersMatcher.java | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/Predicate.java
// public abstract class Predicate<T> implements org.apache.commons.collections.Predicate {
// public abstract boolean satisfies(T t);
//
// @Override
// public final boolean evaluate(Object o) {
// return satisfies((T) o);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/CollectionUtils.java
// public static <T> boolean exists(Collection<T> collection, com.thoughtworks.webstub.utils.Predicate<T> predicate) {
// for (T t : collection) {
// if (predicate.satisfies(t))
// return true;
// }
//
// return false;
// }
| import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.config.Header;
import com.thoughtworks.webstub.utils.Predicate;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Collection;
import static com.thoughtworks.webstub.utils.CollectionUtils.exists;
import static javax.servlet.http.HttpServletResponse.SC_PRECONDITION_FAILED; | package com.thoughtworks.webstub.server.servlet.matcher;
public class HeadersMatcher extends RequestPartMatcher {
public HeadersMatcher(HttpServletRequest request) {
super(request, SC_PRECONDITION_FAILED);
}
@Override
public boolean matches(HttpConfiguration configuration) throws IOException { | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/config/Header.java
// public class Header {
// private final String name;
// private final String value;
//
// public Header(String name, String value) {
// this.name = name;
// this.value = value;
// }
//
// public String name() {
// return name;
// }
//
// public String value() {
// return value;
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/Predicate.java
// public abstract class Predicate<T> implements org.apache.commons.collections.Predicate {
// public abstract boolean satisfies(T t);
//
// @Override
// public final boolean evaluate(Object o) {
// return satisfies((T) o);
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/CollectionUtils.java
// public static <T> boolean exists(Collection<T> collection, com.thoughtworks.webstub.utils.Predicate<T> predicate) {
// for (T t : collection) {
// if (predicate.satisfies(t))
// return true;
// }
//
// return false;
// }
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/matcher/HeadersMatcher.java
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.config.Header;
import com.thoughtworks.webstub.utils.Predicate;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Collection;
import static com.thoughtworks.webstub.utils.CollectionUtils.exists;
import static javax.servlet.http.HttpServletResponse.SC_PRECONDITION_FAILED;
package com.thoughtworks.webstub.server.servlet.matcher;
public class HeadersMatcher extends RequestPartMatcher {
public HeadersMatcher(HttpServletRequest request) {
super(request, SC_PRECONDITION_FAILED);
}
@Override
public boolean matches(HttpConfiguration configuration) throws IOException { | return !exists(getHeaders(configuration), new Predicate<Header>() { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/server/servlet/Configurations.java | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/matcher/RequestPartMatcher.java
// public abstract class RequestPartMatcher {
// protected HttpServletRequest request;
// private int failedResponseCode;
//
// protected RequestPartMatcher(HttpServletRequest request, int failedResponseCode) {
// this.request = request;
// this.failedResponseCode = failedResponseCode;
// }
//
// public int failedResponseCode() {
// return failedResponseCode;
// }
//
// public abstract boolean matches(HttpConfiguration configuration) throws IOException;
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/Predicate.java
// public abstract class Predicate<T> implements org.apache.commons.collections.Predicate {
// public abstract boolean satisfies(T t);
//
// @Override
// public final boolean evaluate(Object o) {
// return satisfies((T) o);
// }
// }
| import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.server.servlet.matcher.RequestPartMatcher;
import com.thoughtworks.webstub.utils.Predicate;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static org.apache.commons.collections.CollectionUtils.select; | package com.thoughtworks.webstub.server.servlet;
public class Configurations {
private final List<HttpConfiguration> configurations;
public Configurations() {
this(new ArrayList<HttpConfiguration>());
}
public Configurations(List<HttpConfiguration> configurations) {
this.configurations = new ArrayList<>(configurations);
}
public void add(HttpConfiguration configuration) {
configurations.add(configuration);
}
public void reset() {
configurations.clear();
}
public List<HttpConfiguration> all() {
return Collections.unmodifiableList(configurations);
}
| // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/matcher/RequestPartMatcher.java
// public abstract class RequestPartMatcher {
// protected HttpServletRequest request;
// private int failedResponseCode;
//
// protected RequestPartMatcher(HttpServletRequest request, int failedResponseCode) {
// this.request = request;
// this.failedResponseCode = failedResponseCode;
// }
//
// public int failedResponseCode() {
// return failedResponseCode;
// }
//
// public abstract boolean matches(HttpConfiguration configuration) throws IOException;
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/Predicate.java
// public abstract class Predicate<T> implements org.apache.commons.collections.Predicate {
// public abstract boolean satisfies(T t);
//
// @Override
// public final boolean evaluate(Object o) {
// return satisfies((T) o);
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/Configurations.java
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.server.servlet.matcher.RequestPartMatcher;
import com.thoughtworks.webstub.utils.Predicate;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static org.apache.commons.collections.CollectionUtils.select;
package com.thoughtworks.webstub.server.servlet;
public class Configurations {
private final List<HttpConfiguration> configurations;
public Configurations() {
this(new ArrayList<HttpConfiguration>());
}
public Configurations(List<HttpConfiguration> configurations) {
this.configurations = new ArrayList<>(configurations);
}
public void add(HttpConfiguration configuration) {
configurations.add(configuration);
}
public void reset() {
configurations.clear();
}
public List<HttpConfiguration> all() {
return Collections.unmodifiableList(configurations);
}
| public Configurations filterBy(final RequestPartMatcher matcher) throws MissingMatchingConfigurationException { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/server/servlet/Configurations.java | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/matcher/RequestPartMatcher.java
// public abstract class RequestPartMatcher {
// protected HttpServletRequest request;
// private int failedResponseCode;
//
// protected RequestPartMatcher(HttpServletRequest request, int failedResponseCode) {
// this.request = request;
// this.failedResponseCode = failedResponseCode;
// }
//
// public int failedResponseCode() {
// return failedResponseCode;
// }
//
// public abstract boolean matches(HttpConfiguration configuration) throws IOException;
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/Predicate.java
// public abstract class Predicate<T> implements org.apache.commons.collections.Predicate {
// public abstract boolean satisfies(T t);
//
// @Override
// public final boolean evaluate(Object o) {
// return satisfies((T) o);
// }
// }
| import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.server.servlet.matcher.RequestPartMatcher;
import com.thoughtworks.webstub.utils.Predicate;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static org.apache.commons.collections.CollectionUtils.select; | package com.thoughtworks.webstub.server.servlet;
public class Configurations {
private final List<HttpConfiguration> configurations;
public Configurations() {
this(new ArrayList<HttpConfiguration>());
}
public Configurations(List<HttpConfiguration> configurations) {
this.configurations = new ArrayList<>(configurations);
}
public void add(HttpConfiguration configuration) {
configurations.add(configuration);
}
public void reset() {
configurations.clear();
}
public List<HttpConfiguration> all() {
return Collections.unmodifiableList(configurations);
}
public Configurations filterBy(final RequestPartMatcher matcher) throws MissingMatchingConfigurationException { | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
//
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/matcher/RequestPartMatcher.java
// public abstract class RequestPartMatcher {
// protected HttpServletRequest request;
// private int failedResponseCode;
//
// protected RequestPartMatcher(HttpServletRequest request, int failedResponseCode) {
// this.request = request;
// this.failedResponseCode = failedResponseCode;
// }
//
// public int failedResponseCode() {
// return failedResponseCode;
// }
//
// public abstract boolean matches(HttpConfiguration configuration) throws IOException;
// }
//
// Path: src/main/java/com/thoughtworks/webstub/utils/Predicate.java
// public abstract class Predicate<T> implements org.apache.commons.collections.Predicate {
// public abstract boolean satisfies(T t);
//
// @Override
// public final boolean evaluate(Object o) {
// return satisfies((T) o);
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/Configurations.java
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.server.servlet.matcher.RequestPartMatcher;
import com.thoughtworks.webstub.utils.Predicate;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static org.apache.commons.collections.CollectionUtils.select;
package com.thoughtworks.webstub.server.servlet;
public class Configurations {
private final List<HttpConfiguration> configurations;
public Configurations() {
this(new ArrayList<HttpConfiguration>());
}
public Configurations(List<HttpConfiguration> configurations) {
this.configurations = new ArrayList<>(configurations);
}
public void add(HttpConfiguration configuration) {
configurations.add(configuration);
}
public void reset() {
configurations.clear();
}
public List<HttpConfiguration> all() {
return Collections.unmodifiableList(configurations);
}
public Configurations filterBy(final RequestPartMatcher matcher) throws MissingMatchingConfigurationException { | List<HttpConfiguration> filtered = (List<HttpConfiguration>) select(configurations, new Predicate<HttpConfiguration>() { |
tusharm/WebStub | src/main/java/com/thoughtworks/webstub/server/servlet/matcher/UriMatcher.java | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
| import com.thoughtworks.webstub.config.HttpConfiguration;
import org.apache.oro.text.GlobCompiler;
import org.apache.oro.text.regex.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND; | package com.thoughtworks.webstub.server.servlet.matcher;
public class UriMatcher extends RequestPartMatcher {
public UriMatcher(HttpServletRequest request) {
super(request, SC_NOT_FOUND);
}
@Override | // Path: src/main/java/com/thoughtworks/webstub/config/HttpConfiguration.java
// public class HttpConfiguration {
// private Request request;
// private Response response;
//
// public HttpConfiguration(Request request, Response response) {
// this.request = request;
// this.response = response;
// }
//
// public Request request() {
// return request;
// }
//
// public Response response() {
// return response;
// }
//
// @Override
// public boolean equals(Object o) {
// if (!(o instanceof HttpConfiguration)) return false;
//
// HttpConfiguration that = (HttpConfiguration) o;
// return new EqualsBuilder()
// .append(request, that.request)
// .append(response, that.response)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// int result = request.hashCode();
// result = 31 * result + response.hashCode();
// return result;
// }
//
// @Override
//
// public String toString() {
// return new ToStringBuilder(this)
// .append("method", request.method())
// .append("uri", request.uri())
// .append("request content", request.content())
// .append("response status", response.status())
// .append("response content", response.content())
// .toString();
// }
// }
// Path: src/main/java/com/thoughtworks/webstub/server/servlet/matcher/UriMatcher.java
import com.thoughtworks.webstub.config.HttpConfiguration;
import org.apache.oro.text.GlobCompiler;
import org.apache.oro.text.regex.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
package com.thoughtworks.webstub.server.servlet.matcher;
public class UriMatcher extends RequestPartMatcher {
public UriMatcher(HttpServletRequest request) {
super(request, SC_NOT_FOUND);
}
@Override | public boolean matches(HttpConfiguration configuration) throws IOException { |
ArcadiaPlugins/Arcadia-Spigot | src/main/java/me/redraskal/arcadia/api/music/defaults/MusicalMinecartsMusic.java | // Path: src/main/java/me/redraskal/arcadia/api/music/MusicCallback.java
// public abstract class MusicCallback {
//
// public abstract void onFinish();
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicNote.java
// public class MusicNote {
//
// private final Sound sound;
// private final float volume;
// private final float pitch;
//
// public MusicNote(Sound sound, float volume, float pitch) {
// this.sound = sound;
// this.volume = volume;
// this.pitch = pitch;
// }
//
// public MusicNote(Sound sound) {
// this(sound, 1f, 1f);
// }
//
// public MusicNote(Sound sound, float volume) {
// this(sound, volume, 1f);
// }
//
// public Sound getSound() {
// return this.sound;
// }
//
// public float getVolume() {
// return this.volume;
// }
//
// public float getPitch() {
// return this.pitch;
// }
//
// public void play(Player... players) {
// for(Player player : players) {
// player.getWorld().playSound(player.getLocation(), sound, volume, pitch);
// }
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicPlayer.java
// public class MusicPlayer extends BukkitRunnable {
//
// private final MusicSequence musicSequence;
// private final Player[] players;
// private int ticks = 0;
// private MusicCallback musicCallback;
//
// public MusicPlayer(MusicSequence musicSequence, Player... players) {
// this.musicSequence = musicSequence;
// this.players = players;
// Arcadia arcadia = Arcadia.getPlugin(Arcadia.class);
// if(arcadia == null || !arcadia.isEnabled()) return;
// this.runTaskTimer(Arcadia.getPlugin(Arcadia.class), 0, 1L);
// }
//
// @Override
// public void run() {
// if(musicSequence.getLastTick() < ticks) {
// this.cancel();
// if(musicCallback != null) musicCallback.onFinish();
// return;
// }
// for(MusicNote musicNote : musicSequence.getSounds(ticks)) {
// musicNote.play(players);
// }
// ticks++;
// }
//
// public void setCallback(MusicCallback musicCallback) {
// this.musicCallback = musicCallback;
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicSequence.java
// public class MusicSequence {
//
// private Map<Integer, List<MusicNote>> sounds = new HashMap<>();
//
// public MusicNote[] getSounds(int ticks) {
// if(sounds.containsKey(ticks)) return sounds.get(ticks).toArray(new MusicNote[sounds.get(ticks).size()]);
// return new MusicNote[]{};
// }
//
// public void addSound(MusicNote note, int ticks) {
// List<MusicNote> temp = new ArrayList<>();
// if(sounds.containsKey(ticks)) temp.addAll(sounds.get(ticks));
// temp.add(note);
// sounds.put(ticks, temp);
// }
//
// public int getLastTick() {
// if(sounds.isEmpty()) return 0;
// return sounds.entrySet().stream()
// .max((entry1, entry2) -> entry1.getKey() > entry2.getKey() ? 1 : -1)
// .get().getKey();
// }
//
// public MusicPlayer play(Player... players) {
// return new MusicPlayer(this, players);
// }
//
// public MusicPlayer play() {
// return this.play(Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]));
// }
// }
| import me.redraskal.arcadia.api.music.MusicCallback;
import me.redraskal.arcadia.api.music.MusicNote;
import me.redraskal.arcadia.api.music.MusicPlayer;
import me.redraskal.arcadia.api.music.MusicSequence;
import org.bukkit.Sound;
import java.util.ArrayList;
import java.util.List; | package me.redraskal.arcadia.api.music.defaults;
public class MusicalMinecartsMusic {
private static List<MusicPlayer> musicPlaying = new ArrayList<>();
public static void stopMusic() {
musicPlaying.forEach(musicPlayer -> {
musicPlayer.cancel();
});
musicPlaying.clear();
}
public MusicalMinecartsMusic() { | // Path: src/main/java/me/redraskal/arcadia/api/music/MusicCallback.java
// public abstract class MusicCallback {
//
// public abstract void onFinish();
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicNote.java
// public class MusicNote {
//
// private final Sound sound;
// private final float volume;
// private final float pitch;
//
// public MusicNote(Sound sound, float volume, float pitch) {
// this.sound = sound;
// this.volume = volume;
// this.pitch = pitch;
// }
//
// public MusicNote(Sound sound) {
// this(sound, 1f, 1f);
// }
//
// public MusicNote(Sound sound, float volume) {
// this(sound, volume, 1f);
// }
//
// public Sound getSound() {
// return this.sound;
// }
//
// public float getVolume() {
// return this.volume;
// }
//
// public float getPitch() {
// return this.pitch;
// }
//
// public void play(Player... players) {
// for(Player player : players) {
// player.getWorld().playSound(player.getLocation(), sound, volume, pitch);
// }
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicPlayer.java
// public class MusicPlayer extends BukkitRunnable {
//
// private final MusicSequence musicSequence;
// private final Player[] players;
// private int ticks = 0;
// private MusicCallback musicCallback;
//
// public MusicPlayer(MusicSequence musicSequence, Player... players) {
// this.musicSequence = musicSequence;
// this.players = players;
// Arcadia arcadia = Arcadia.getPlugin(Arcadia.class);
// if(arcadia == null || !arcadia.isEnabled()) return;
// this.runTaskTimer(Arcadia.getPlugin(Arcadia.class), 0, 1L);
// }
//
// @Override
// public void run() {
// if(musicSequence.getLastTick() < ticks) {
// this.cancel();
// if(musicCallback != null) musicCallback.onFinish();
// return;
// }
// for(MusicNote musicNote : musicSequence.getSounds(ticks)) {
// musicNote.play(players);
// }
// ticks++;
// }
//
// public void setCallback(MusicCallback musicCallback) {
// this.musicCallback = musicCallback;
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicSequence.java
// public class MusicSequence {
//
// private Map<Integer, List<MusicNote>> sounds = new HashMap<>();
//
// public MusicNote[] getSounds(int ticks) {
// if(sounds.containsKey(ticks)) return sounds.get(ticks).toArray(new MusicNote[sounds.get(ticks).size()]);
// return new MusicNote[]{};
// }
//
// public void addSound(MusicNote note, int ticks) {
// List<MusicNote> temp = new ArrayList<>();
// if(sounds.containsKey(ticks)) temp.addAll(sounds.get(ticks));
// temp.add(note);
// sounds.put(ticks, temp);
// }
//
// public int getLastTick() {
// if(sounds.isEmpty()) return 0;
// return sounds.entrySet().stream()
// .max((entry1, entry2) -> entry1.getKey() > entry2.getKey() ? 1 : -1)
// .get().getKey();
// }
//
// public MusicPlayer play(Player... players) {
// return new MusicPlayer(this, players);
// }
//
// public MusicPlayer play() {
// return this.play(Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]));
// }
// }
// Path: src/main/java/me/redraskal/arcadia/api/music/defaults/MusicalMinecartsMusic.java
import me.redraskal.arcadia.api.music.MusicCallback;
import me.redraskal.arcadia.api.music.MusicNote;
import me.redraskal.arcadia.api.music.MusicPlayer;
import me.redraskal.arcadia.api.music.MusicSequence;
import org.bukkit.Sound;
import java.util.ArrayList;
import java.util.List;
package me.redraskal.arcadia.api.music.defaults;
public class MusicalMinecartsMusic {
private static List<MusicPlayer> musicPlaying = new ArrayList<>();
public static void stopMusic() {
musicPlaying.forEach(musicPlayer -> {
musicPlayer.cancel();
});
musicPlaying.clear();
}
public MusicalMinecartsMusic() { | MusicSequence musicSequence = new MusicSequence(); |
ArcadiaPlugins/Arcadia-Spigot | src/main/java/me/redraskal/arcadia/api/music/defaults/MusicalMinecartsMusic.java | // Path: src/main/java/me/redraskal/arcadia/api/music/MusicCallback.java
// public abstract class MusicCallback {
//
// public abstract void onFinish();
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicNote.java
// public class MusicNote {
//
// private final Sound sound;
// private final float volume;
// private final float pitch;
//
// public MusicNote(Sound sound, float volume, float pitch) {
// this.sound = sound;
// this.volume = volume;
// this.pitch = pitch;
// }
//
// public MusicNote(Sound sound) {
// this(sound, 1f, 1f);
// }
//
// public MusicNote(Sound sound, float volume) {
// this(sound, volume, 1f);
// }
//
// public Sound getSound() {
// return this.sound;
// }
//
// public float getVolume() {
// return this.volume;
// }
//
// public float getPitch() {
// return this.pitch;
// }
//
// public void play(Player... players) {
// for(Player player : players) {
// player.getWorld().playSound(player.getLocation(), sound, volume, pitch);
// }
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicPlayer.java
// public class MusicPlayer extends BukkitRunnable {
//
// private final MusicSequence musicSequence;
// private final Player[] players;
// private int ticks = 0;
// private MusicCallback musicCallback;
//
// public MusicPlayer(MusicSequence musicSequence, Player... players) {
// this.musicSequence = musicSequence;
// this.players = players;
// Arcadia arcadia = Arcadia.getPlugin(Arcadia.class);
// if(arcadia == null || !arcadia.isEnabled()) return;
// this.runTaskTimer(Arcadia.getPlugin(Arcadia.class), 0, 1L);
// }
//
// @Override
// public void run() {
// if(musicSequence.getLastTick() < ticks) {
// this.cancel();
// if(musicCallback != null) musicCallback.onFinish();
// return;
// }
// for(MusicNote musicNote : musicSequence.getSounds(ticks)) {
// musicNote.play(players);
// }
// ticks++;
// }
//
// public void setCallback(MusicCallback musicCallback) {
// this.musicCallback = musicCallback;
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicSequence.java
// public class MusicSequence {
//
// private Map<Integer, List<MusicNote>> sounds = new HashMap<>();
//
// public MusicNote[] getSounds(int ticks) {
// if(sounds.containsKey(ticks)) return sounds.get(ticks).toArray(new MusicNote[sounds.get(ticks).size()]);
// return new MusicNote[]{};
// }
//
// public void addSound(MusicNote note, int ticks) {
// List<MusicNote> temp = new ArrayList<>();
// if(sounds.containsKey(ticks)) temp.addAll(sounds.get(ticks));
// temp.add(note);
// sounds.put(ticks, temp);
// }
//
// public int getLastTick() {
// if(sounds.isEmpty()) return 0;
// return sounds.entrySet().stream()
// .max((entry1, entry2) -> entry1.getKey() > entry2.getKey() ? 1 : -1)
// .get().getKey();
// }
//
// public MusicPlayer play(Player... players) {
// return new MusicPlayer(this, players);
// }
//
// public MusicPlayer play() {
// return this.play(Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]));
// }
// }
| import me.redraskal.arcadia.api.music.MusicCallback;
import me.redraskal.arcadia.api.music.MusicNote;
import me.redraskal.arcadia.api.music.MusicPlayer;
import me.redraskal.arcadia.api.music.MusicSequence;
import org.bukkit.Sound;
import java.util.ArrayList;
import java.util.List; | package me.redraskal.arcadia.api.music.defaults;
public class MusicalMinecartsMusic {
private static List<MusicPlayer> musicPlaying = new ArrayList<>();
public static void stopMusic() {
musicPlaying.forEach(musicPlayer -> {
musicPlayer.cancel();
});
musicPlaying.clear();
}
public MusicalMinecartsMusic() {
MusicSequence musicSequence = new MusicSequence();
float add = 0f;
int ticks = 0;
for(int i=0; i<8; i++) { | // Path: src/main/java/me/redraskal/arcadia/api/music/MusicCallback.java
// public abstract class MusicCallback {
//
// public abstract void onFinish();
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicNote.java
// public class MusicNote {
//
// private final Sound sound;
// private final float volume;
// private final float pitch;
//
// public MusicNote(Sound sound, float volume, float pitch) {
// this.sound = sound;
// this.volume = volume;
// this.pitch = pitch;
// }
//
// public MusicNote(Sound sound) {
// this(sound, 1f, 1f);
// }
//
// public MusicNote(Sound sound, float volume) {
// this(sound, volume, 1f);
// }
//
// public Sound getSound() {
// return this.sound;
// }
//
// public float getVolume() {
// return this.volume;
// }
//
// public float getPitch() {
// return this.pitch;
// }
//
// public void play(Player... players) {
// for(Player player : players) {
// player.getWorld().playSound(player.getLocation(), sound, volume, pitch);
// }
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicPlayer.java
// public class MusicPlayer extends BukkitRunnable {
//
// private final MusicSequence musicSequence;
// private final Player[] players;
// private int ticks = 0;
// private MusicCallback musicCallback;
//
// public MusicPlayer(MusicSequence musicSequence, Player... players) {
// this.musicSequence = musicSequence;
// this.players = players;
// Arcadia arcadia = Arcadia.getPlugin(Arcadia.class);
// if(arcadia == null || !arcadia.isEnabled()) return;
// this.runTaskTimer(Arcadia.getPlugin(Arcadia.class), 0, 1L);
// }
//
// @Override
// public void run() {
// if(musicSequence.getLastTick() < ticks) {
// this.cancel();
// if(musicCallback != null) musicCallback.onFinish();
// return;
// }
// for(MusicNote musicNote : musicSequence.getSounds(ticks)) {
// musicNote.play(players);
// }
// ticks++;
// }
//
// public void setCallback(MusicCallback musicCallback) {
// this.musicCallback = musicCallback;
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicSequence.java
// public class MusicSequence {
//
// private Map<Integer, List<MusicNote>> sounds = new HashMap<>();
//
// public MusicNote[] getSounds(int ticks) {
// if(sounds.containsKey(ticks)) return sounds.get(ticks).toArray(new MusicNote[sounds.get(ticks).size()]);
// return new MusicNote[]{};
// }
//
// public void addSound(MusicNote note, int ticks) {
// List<MusicNote> temp = new ArrayList<>();
// if(sounds.containsKey(ticks)) temp.addAll(sounds.get(ticks));
// temp.add(note);
// sounds.put(ticks, temp);
// }
//
// public int getLastTick() {
// if(sounds.isEmpty()) return 0;
// return sounds.entrySet().stream()
// .max((entry1, entry2) -> entry1.getKey() > entry2.getKey() ? 1 : -1)
// .get().getKey();
// }
//
// public MusicPlayer play(Player... players) {
// return new MusicPlayer(this, players);
// }
//
// public MusicPlayer play() {
// return this.play(Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]));
// }
// }
// Path: src/main/java/me/redraskal/arcadia/api/music/defaults/MusicalMinecartsMusic.java
import me.redraskal.arcadia.api.music.MusicCallback;
import me.redraskal.arcadia.api.music.MusicNote;
import me.redraskal.arcadia.api.music.MusicPlayer;
import me.redraskal.arcadia.api.music.MusicSequence;
import org.bukkit.Sound;
import java.util.ArrayList;
import java.util.List;
package me.redraskal.arcadia.api.music.defaults;
public class MusicalMinecartsMusic {
private static List<MusicPlayer> musicPlaying = new ArrayList<>();
public static void stopMusic() {
musicPlaying.forEach(musicPlayer -> {
musicPlayer.cancel();
});
musicPlaying.clear();
}
public MusicalMinecartsMusic() {
MusicSequence musicSequence = new MusicSequence();
float add = 0f;
int ticks = 0;
for(int i=0; i<8; i++) { | musicSequence.addSound(new MusicNote(Sound.BLOCK_NOTE_HARP, 1.2f, 0.5f+add), ticks); |
ArcadiaPlugins/Arcadia-Spigot | src/main/java/me/redraskal/arcadia/api/music/defaults/MusicalMinecartsMusic.java | // Path: src/main/java/me/redraskal/arcadia/api/music/MusicCallback.java
// public abstract class MusicCallback {
//
// public abstract void onFinish();
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicNote.java
// public class MusicNote {
//
// private final Sound sound;
// private final float volume;
// private final float pitch;
//
// public MusicNote(Sound sound, float volume, float pitch) {
// this.sound = sound;
// this.volume = volume;
// this.pitch = pitch;
// }
//
// public MusicNote(Sound sound) {
// this(sound, 1f, 1f);
// }
//
// public MusicNote(Sound sound, float volume) {
// this(sound, volume, 1f);
// }
//
// public Sound getSound() {
// return this.sound;
// }
//
// public float getVolume() {
// return this.volume;
// }
//
// public float getPitch() {
// return this.pitch;
// }
//
// public void play(Player... players) {
// for(Player player : players) {
// player.getWorld().playSound(player.getLocation(), sound, volume, pitch);
// }
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicPlayer.java
// public class MusicPlayer extends BukkitRunnable {
//
// private final MusicSequence musicSequence;
// private final Player[] players;
// private int ticks = 0;
// private MusicCallback musicCallback;
//
// public MusicPlayer(MusicSequence musicSequence, Player... players) {
// this.musicSequence = musicSequence;
// this.players = players;
// Arcadia arcadia = Arcadia.getPlugin(Arcadia.class);
// if(arcadia == null || !arcadia.isEnabled()) return;
// this.runTaskTimer(Arcadia.getPlugin(Arcadia.class), 0, 1L);
// }
//
// @Override
// public void run() {
// if(musicSequence.getLastTick() < ticks) {
// this.cancel();
// if(musicCallback != null) musicCallback.onFinish();
// return;
// }
// for(MusicNote musicNote : musicSequence.getSounds(ticks)) {
// musicNote.play(players);
// }
// ticks++;
// }
//
// public void setCallback(MusicCallback musicCallback) {
// this.musicCallback = musicCallback;
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicSequence.java
// public class MusicSequence {
//
// private Map<Integer, List<MusicNote>> sounds = new HashMap<>();
//
// public MusicNote[] getSounds(int ticks) {
// if(sounds.containsKey(ticks)) return sounds.get(ticks).toArray(new MusicNote[sounds.get(ticks).size()]);
// return new MusicNote[]{};
// }
//
// public void addSound(MusicNote note, int ticks) {
// List<MusicNote> temp = new ArrayList<>();
// if(sounds.containsKey(ticks)) temp.addAll(sounds.get(ticks));
// temp.add(note);
// sounds.put(ticks, temp);
// }
//
// public int getLastTick() {
// if(sounds.isEmpty()) return 0;
// return sounds.entrySet().stream()
// .max((entry1, entry2) -> entry1.getKey() > entry2.getKey() ? 1 : -1)
// .get().getKey();
// }
//
// public MusicPlayer play(Player... players) {
// return new MusicPlayer(this, players);
// }
//
// public MusicPlayer play() {
// return this.play(Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]));
// }
// }
| import me.redraskal.arcadia.api.music.MusicCallback;
import me.redraskal.arcadia.api.music.MusicNote;
import me.redraskal.arcadia.api.music.MusicPlayer;
import me.redraskal.arcadia.api.music.MusicSequence;
import org.bukkit.Sound;
import java.util.ArrayList;
import java.util.List; | package me.redraskal.arcadia.api.music.defaults;
public class MusicalMinecartsMusic {
private static List<MusicPlayer> musicPlaying = new ArrayList<>();
public static void stopMusic() {
musicPlaying.forEach(musicPlayer -> {
musicPlayer.cancel();
});
musicPlaying.clear();
}
public MusicalMinecartsMusic() {
MusicSequence musicSequence = new MusicSequence();
float add = 0f;
int ticks = 0;
for(int i=0; i<8; i++) {
musicSequence.addSound(new MusicNote(Sound.BLOCK_NOTE_HARP, 1.2f, 0.5f+add), ticks);
musicSequence.addSound(new MusicNote(Sound.BLOCK_NOTE_FLUTE, 1.5f, 0.7f+add), ticks);
ticks+=10;
musicSequence.addSound(new MusicNote(Sound.BLOCK_NOTE_GUITAR, 1.5f, 0.5f), ticks-5);
add+=0.11111115;
}
MusicPlayer musicPlayer = musicSequence.play();
musicPlaying.add(musicPlayer); | // Path: src/main/java/me/redraskal/arcadia/api/music/MusicCallback.java
// public abstract class MusicCallback {
//
// public abstract void onFinish();
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicNote.java
// public class MusicNote {
//
// private final Sound sound;
// private final float volume;
// private final float pitch;
//
// public MusicNote(Sound sound, float volume, float pitch) {
// this.sound = sound;
// this.volume = volume;
// this.pitch = pitch;
// }
//
// public MusicNote(Sound sound) {
// this(sound, 1f, 1f);
// }
//
// public MusicNote(Sound sound, float volume) {
// this(sound, volume, 1f);
// }
//
// public Sound getSound() {
// return this.sound;
// }
//
// public float getVolume() {
// return this.volume;
// }
//
// public float getPitch() {
// return this.pitch;
// }
//
// public void play(Player... players) {
// for(Player player : players) {
// player.getWorld().playSound(player.getLocation(), sound, volume, pitch);
// }
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicPlayer.java
// public class MusicPlayer extends BukkitRunnable {
//
// private final MusicSequence musicSequence;
// private final Player[] players;
// private int ticks = 0;
// private MusicCallback musicCallback;
//
// public MusicPlayer(MusicSequence musicSequence, Player... players) {
// this.musicSequence = musicSequence;
// this.players = players;
// Arcadia arcadia = Arcadia.getPlugin(Arcadia.class);
// if(arcadia == null || !arcadia.isEnabled()) return;
// this.runTaskTimer(Arcadia.getPlugin(Arcadia.class), 0, 1L);
// }
//
// @Override
// public void run() {
// if(musicSequence.getLastTick() < ticks) {
// this.cancel();
// if(musicCallback != null) musicCallback.onFinish();
// return;
// }
// for(MusicNote musicNote : musicSequence.getSounds(ticks)) {
// musicNote.play(players);
// }
// ticks++;
// }
//
// public void setCallback(MusicCallback musicCallback) {
// this.musicCallback = musicCallback;
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicSequence.java
// public class MusicSequence {
//
// private Map<Integer, List<MusicNote>> sounds = new HashMap<>();
//
// public MusicNote[] getSounds(int ticks) {
// if(sounds.containsKey(ticks)) return sounds.get(ticks).toArray(new MusicNote[sounds.get(ticks).size()]);
// return new MusicNote[]{};
// }
//
// public void addSound(MusicNote note, int ticks) {
// List<MusicNote> temp = new ArrayList<>();
// if(sounds.containsKey(ticks)) temp.addAll(sounds.get(ticks));
// temp.add(note);
// sounds.put(ticks, temp);
// }
//
// public int getLastTick() {
// if(sounds.isEmpty()) return 0;
// return sounds.entrySet().stream()
// .max((entry1, entry2) -> entry1.getKey() > entry2.getKey() ? 1 : -1)
// .get().getKey();
// }
//
// public MusicPlayer play(Player... players) {
// return new MusicPlayer(this, players);
// }
//
// public MusicPlayer play() {
// return this.play(Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]));
// }
// }
// Path: src/main/java/me/redraskal/arcadia/api/music/defaults/MusicalMinecartsMusic.java
import me.redraskal.arcadia.api.music.MusicCallback;
import me.redraskal.arcadia.api.music.MusicNote;
import me.redraskal.arcadia.api.music.MusicPlayer;
import me.redraskal.arcadia.api.music.MusicSequence;
import org.bukkit.Sound;
import java.util.ArrayList;
import java.util.List;
package me.redraskal.arcadia.api.music.defaults;
public class MusicalMinecartsMusic {
private static List<MusicPlayer> musicPlaying = new ArrayList<>();
public static void stopMusic() {
musicPlaying.forEach(musicPlayer -> {
musicPlayer.cancel();
});
musicPlaying.clear();
}
public MusicalMinecartsMusic() {
MusicSequence musicSequence = new MusicSequence();
float add = 0f;
int ticks = 0;
for(int i=0; i<8; i++) {
musicSequence.addSound(new MusicNote(Sound.BLOCK_NOTE_HARP, 1.2f, 0.5f+add), ticks);
musicSequence.addSound(new MusicNote(Sound.BLOCK_NOTE_FLUTE, 1.5f, 0.7f+add), ticks);
ticks+=10;
musicSequence.addSound(new MusicNote(Sound.BLOCK_NOTE_GUITAR, 1.5f, 0.5f), ticks-5);
add+=0.11111115;
}
MusicPlayer musicPlayer = musicSequence.play();
musicPlaying.add(musicPlayer); | musicPlayer.setCallback(new MusicCallback() { |
ArcadiaPlugins/Arcadia-Spigot | src/main/java/me/redraskal/arcadia/api/music/defaults/EndGameMusic.java | // Path: src/main/java/me/redraskal/arcadia/api/music/MusicNote.java
// public class MusicNote {
//
// private final Sound sound;
// private final float volume;
// private final float pitch;
//
// public MusicNote(Sound sound, float volume, float pitch) {
// this.sound = sound;
// this.volume = volume;
// this.pitch = pitch;
// }
//
// public MusicNote(Sound sound) {
// this(sound, 1f, 1f);
// }
//
// public MusicNote(Sound sound, float volume) {
// this(sound, volume, 1f);
// }
//
// public Sound getSound() {
// return this.sound;
// }
//
// public float getVolume() {
// return this.volume;
// }
//
// public float getPitch() {
// return this.pitch;
// }
//
// public void play(Player... players) {
// for(Player player : players) {
// player.getWorld().playSound(player.getLocation(), sound, volume, pitch);
// }
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicSequence.java
// public class MusicSequence {
//
// private Map<Integer, List<MusicNote>> sounds = new HashMap<>();
//
// public MusicNote[] getSounds(int ticks) {
// if(sounds.containsKey(ticks)) return sounds.get(ticks).toArray(new MusicNote[sounds.get(ticks).size()]);
// return new MusicNote[]{};
// }
//
// public void addSound(MusicNote note, int ticks) {
// List<MusicNote> temp = new ArrayList<>();
// if(sounds.containsKey(ticks)) temp.addAll(sounds.get(ticks));
// temp.add(note);
// sounds.put(ticks, temp);
// }
//
// public int getLastTick() {
// if(sounds.isEmpty()) return 0;
// return sounds.entrySet().stream()
// .max((entry1, entry2) -> entry1.getKey() > entry2.getKey() ? 1 : -1)
// .get().getKey();
// }
//
// public MusicPlayer play(Player... players) {
// return new MusicPlayer(this, players);
// }
//
// public MusicPlayer play() {
// return this.play(Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]));
// }
// }
| import me.redraskal.arcadia.api.music.MusicNote;
import me.redraskal.arcadia.api.music.MusicSequence;
import org.bukkit.Sound; | package me.redraskal.arcadia.api.music.defaults;
public class EndGameMusic {
public EndGameMusic() { | // Path: src/main/java/me/redraskal/arcadia/api/music/MusicNote.java
// public class MusicNote {
//
// private final Sound sound;
// private final float volume;
// private final float pitch;
//
// public MusicNote(Sound sound, float volume, float pitch) {
// this.sound = sound;
// this.volume = volume;
// this.pitch = pitch;
// }
//
// public MusicNote(Sound sound) {
// this(sound, 1f, 1f);
// }
//
// public MusicNote(Sound sound, float volume) {
// this(sound, volume, 1f);
// }
//
// public Sound getSound() {
// return this.sound;
// }
//
// public float getVolume() {
// return this.volume;
// }
//
// public float getPitch() {
// return this.pitch;
// }
//
// public void play(Player... players) {
// for(Player player : players) {
// player.getWorld().playSound(player.getLocation(), sound, volume, pitch);
// }
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicSequence.java
// public class MusicSequence {
//
// private Map<Integer, List<MusicNote>> sounds = new HashMap<>();
//
// public MusicNote[] getSounds(int ticks) {
// if(sounds.containsKey(ticks)) return sounds.get(ticks).toArray(new MusicNote[sounds.get(ticks).size()]);
// return new MusicNote[]{};
// }
//
// public void addSound(MusicNote note, int ticks) {
// List<MusicNote> temp = new ArrayList<>();
// if(sounds.containsKey(ticks)) temp.addAll(sounds.get(ticks));
// temp.add(note);
// sounds.put(ticks, temp);
// }
//
// public int getLastTick() {
// if(sounds.isEmpty()) return 0;
// return sounds.entrySet().stream()
// .max((entry1, entry2) -> entry1.getKey() > entry2.getKey() ? 1 : -1)
// .get().getKey();
// }
//
// public MusicPlayer play(Player... players) {
// return new MusicPlayer(this, players);
// }
//
// public MusicPlayer play() {
// return this.play(Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]));
// }
// }
// Path: src/main/java/me/redraskal/arcadia/api/music/defaults/EndGameMusic.java
import me.redraskal.arcadia.api.music.MusicNote;
import me.redraskal.arcadia.api.music.MusicSequence;
import org.bukkit.Sound;
package me.redraskal.arcadia.api.music.defaults;
public class EndGameMusic {
public EndGameMusic() { | MusicSequence musicSequence = new MusicSequence(); |
ArcadiaPlugins/Arcadia-Spigot | src/main/java/me/redraskal/arcadia/api/music/defaults/EndGameMusic.java | // Path: src/main/java/me/redraskal/arcadia/api/music/MusicNote.java
// public class MusicNote {
//
// private final Sound sound;
// private final float volume;
// private final float pitch;
//
// public MusicNote(Sound sound, float volume, float pitch) {
// this.sound = sound;
// this.volume = volume;
// this.pitch = pitch;
// }
//
// public MusicNote(Sound sound) {
// this(sound, 1f, 1f);
// }
//
// public MusicNote(Sound sound, float volume) {
// this(sound, volume, 1f);
// }
//
// public Sound getSound() {
// return this.sound;
// }
//
// public float getVolume() {
// return this.volume;
// }
//
// public float getPitch() {
// return this.pitch;
// }
//
// public void play(Player... players) {
// for(Player player : players) {
// player.getWorld().playSound(player.getLocation(), sound, volume, pitch);
// }
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicSequence.java
// public class MusicSequence {
//
// private Map<Integer, List<MusicNote>> sounds = new HashMap<>();
//
// public MusicNote[] getSounds(int ticks) {
// if(sounds.containsKey(ticks)) return sounds.get(ticks).toArray(new MusicNote[sounds.get(ticks).size()]);
// return new MusicNote[]{};
// }
//
// public void addSound(MusicNote note, int ticks) {
// List<MusicNote> temp = new ArrayList<>();
// if(sounds.containsKey(ticks)) temp.addAll(sounds.get(ticks));
// temp.add(note);
// sounds.put(ticks, temp);
// }
//
// public int getLastTick() {
// if(sounds.isEmpty()) return 0;
// return sounds.entrySet().stream()
// .max((entry1, entry2) -> entry1.getKey() > entry2.getKey() ? 1 : -1)
// .get().getKey();
// }
//
// public MusicPlayer play(Player... players) {
// return new MusicPlayer(this, players);
// }
//
// public MusicPlayer play() {
// return this.play(Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]));
// }
// }
| import me.redraskal.arcadia.api.music.MusicNote;
import me.redraskal.arcadia.api.music.MusicSequence;
import org.bukkit.Sound; | package me.redraskal.arcadia.api.music.defaults;
public class EndGameMusic {
public EndGameMusic() {
MusicSequence musicSequence = new MusicSequence();
float add = 0f;
int ticks = 0;
for(int i=0; i<15; i++) { | // Path: src/main/java/me/redraskal/arcadia/api/music/MusicNote.java
// public class MusicNote {
//
// private final Sound sound;
// private final float volume;
// private final float pitch;
//
// public MusicNote(Sound sound, float volume, float pitch) {
// this.sound = sound;
// this.volume = volume;
// this.pitch = pitch;
// }
//
// public MusicNote(Sound sound) {
// this(sound, 1f, 1f);
// }
//
// public MusicNote(Sound sound, float volume) {
// this(sound, volume, 1f);
// }
//
// public Sound getSound() {
// return this.sound;
// }
//
// public float getVolume() {
// return this.volume;
// }
//
// public float getPitch() {
// return this.pitch;
// }
//
// public void play(Player... players) {
// for(Player player : players) {
// player.getWorld().playSound(player.getLocation(), sound, volume, pitch);
// }
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/music/MusicSequence.java
// public class MusicSequence {
//
// private Map<Integer, List<MusicNote>> sounds = new HashMap<>();
//
// public MusicNote[] getSounds(int ticks) {
// if(sounds.containsKey(ticks)) return sounds.get(ticks).toArray(new MusicNote[sounds.get(ticks).size()]);
// return new MusicNote[]{};
// }
//
// public void addSound(MusicNote note, int ticks) {
// List<MusicNote> temp = new ArrayList<>();
// if(sounds.containsKey(ticks)) temp.addAll(sounds.get(ticks));
// temp.add(note);
// sounds.put(ticks, temp);
// }
//
// public int getLastTick() {
// if(sounds.isEmpty()) return 0;
// return sounds.entrySet().stream()
// .max((entry1, entry2) -> entry1.getKey() > entry2.getKey() ? 1 : -1)
// .get().getKey();
// }
//
// public MusicPlayer play(Player... players) {
// return new MusicPlayer(this, players);
// }
//
// public MusicPlayer play() {
// return this.play(Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]));
// }
// }
// Path: src/main/java/me/redraskal/arcadia/api/music/defaults/EndGameMusic.java
import me.redraskal.arcadia.api.music.MusicNote;
import me.redraskal.arcadia.api.music.MusicSequence;
import org.bukkit.Sound;
package me.redraskal.arcadia.api.music.defaults;
public class EndGameMusic {
public EndGameMusic() {
MusicSequence musicSequence = new MusicSequence();
float add = 0f;
int ticks = 0;
for(int i=0; i<15; i++) { | musicSequence.addSound(new MusicNote(Sound.BLOCK_NOTE_HARP, 1.5f, 0.24444445f+add), ticks); |
ArcadiaPlugins/Arcadia-Spigot | src/main/java/me/redraskal/arcadia/api/game/event/GameStateUpdateEvent.java | // Path: src/main/java/me/redraskal/arcadia/api/game/GameState.java
// public enum GameState {
//
// STARTING(0),
// INGAME(1),
// FINISHED(2);
//
// private final int id;
//
// private GameState(int id) {
// this.id = id;
// }
//
// public int getID() {
// return this.id;
// }
// }
| import me.redraskal.arcadia.api.game.GameState;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; | package me.redraskal.arcadia.api.game.event;
public class GameStateUpdateEvent extends Event {
private static HandlerList handlers = new HandlerList();
| // Path: src/main/java/me/redraskal/arcadia/api/game/GameState.java
// public enum GameState {
//
// STARTING(0),
// INGAME(1),
// FINISHED(2);
//
// private final int id;
//
// private GameState(int id) {
// this.id = id;
// }
//
// public int getID() {
// return this.id;
// }
// }
// Path: src/main/java/me/redraskal/arcadia/api/game/event/GameStateUpdateEvent.java
import me.redraskal.arcadia.api.game.GameState;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
package me.redraskal.arcadia.api.game.event;
public class GameStateUpdateEvent extends Event {
private static HandlerList handlers = new HandlerList();
| private final GameState gameState; |
ArcadiaPlugins/Arcadia-Spigot | src/main/java/me/redraskal/arcadia/api/scoreboard/defaults/PlayersLeftSidebar.java | // Path: src/main/java/me/redraskal/arcadia/api/game/event/PlayerAliveStatusEvent.java
// public class PlayerAliveStatusEvent extends Event {
//
// private static HandlerList handlers = new HandlerList();
//
// private final Player player;
// private final boolean alive;
// private final boolean spectating;
//
// public PlayerAliveStatusEvent(Player player, boolean alive, boolean spectating) {
// this.player = player;
// this.alive = alive;
// this.spectating = spectating;
// }
//
// public Player getPlayer() {
// return this.player;
// }
//
// public boolean isAlive() {
// return this.alive;
// }
//
// public boolean isSpectating() {
// return this.spectating;
// }
//
// @Override
// public HandlerList getHandlers() {
// return handlers;
// }
//
// public static HandlerList getHandlerList() {
// return handlers;
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/scoreboard/Sidebar.java
// public abstract class Sidebar implements Listener {
//
// private final Scoreboard scoreboard;
// private final Objective sidebar;
// private final ArcadiaAPI api;
//
// /**
// * A fun scoreboard system for Arcadia.
// */
// public Sidebar() {
// this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
// this.sidebar = scoreboard.registerNewObjective("sidebar", "dummy");
// this.api = Arcadia.getPlugin(Arcadia.class).getAPI();
// sidebar.setDisplaySlot(DisplaySlot.SIDEBAR);
// this.updateDisplayName(0, 10);
// for(Player player : Bukkit.getOnlinePlayers()) player.setScoreboard(scoreboard);
// this.onCreation();
// api.getPlugin().getServer().getPluginManager().registerEvents(this, api.getPlugin());
// }
//
// public abstract void onCreation();
//
// /**
// * Returns the sidebar.
// * @return
// */
// public Objective getSidebar() {
// return this.sidebar;
// }
//
// /**
// * Returns the ArcadiaAPI.
// * @return
// */
// public ArcadiaAPI getAPI() {
// return this.api;
// }
//
// /**
// * Updates the scoreboard display name.
// * (Called every second & or on certain events)
// */
// public void updateDisplayName(int minutes, int seconds) {
// final String currentRotation = "" + (api.getGameManager().getRotation().getCurrentID()+1);
// final String rotationSize = "" + api.getGameManager().getRotation().getSize();
// final String currentTime = Utils.formatTime(minutes, seconds);
// switch(api.getGameManager().getGameState()) {
// case STARTING: this.sidebar.setDisplayName(" " + api.getTranslationManager()
// .fetchTranslation("ui.scoreboard.title-starting").build(currentRotation, rotationSize, currentTime) + " "); break;
// case INGAME: this.sidebar.setDisplayName(" " + api.getTranslationManager()
// .fetchTranslation("ui.scoreboard.title-ingame").build(currentRotation, rotationSize, currentTime) + " "); break;
// case FINISHED: this.sidebar.setDisplayName(" " + api.getTranslationManager()
// .fetchTranslation("ui.scoreboard.title-finished").build(currentRotation, rotationSize, currentTime) + " "); break;
// }
// }
// }
| import me.redraskal.arcadia.api.game.event.PlayerAliveStatusEvent;
import me.redraskal.arcadia.api.scoreboard.Sidebar;
import org.bukkit.event.EventHandler; | package me.redraskal.arcadia.api.scoreboard.defaults;
public class PlayersLeftSidebar extends Sidebar {
@Override
public void onCreation() {
this.update();
}
/**
* Updates the Players Left string.
*/
public void update() {
this.getSidebar().getScore(this.getAPI().getTranslationManager()
.fetchTranslation("ui.scoreboard.players-left").build()).setScore(
this.getAPI().getGameManager().getPlayersAlive());
}
@EventHandler | // Path: src/main/java/me/redraskal/arcadia/api/game/event/PlayerAliveStatusEvent.java
// public class PlayerAliveStatusEvent extends Event {
//
// private static HandlerList handlers = new HandlerList();
//
// private final Player player;
// private final boolean alive;
// private final boolean spectating;
//
// public PlayerAliveStatusEvent(Player player, boolean alive, boolean spectating) {
// this.player = player;
// this.alive = alive;
// this.spectating = spectating;
// }
//
// public Player getPlayer() {
// return this.player;
// }
//
// public boolean isAlive() {
// return this.alive;
// }
//
// public boolean isSpectating() {
// return this.spectating;
// }
//
// @Override
// public HandlerList getHandlers() {
// return handlers;
// }
//
// public static HandlerList getHandlerList() {
// return handlers;
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/scoreboard/Sidebar.java
// public abstract class Sidebar implements Listener {
//
// private final Scoreboard scoreboard;
// private final Objective sidebar;
// private final ArcadiaAPI api;
//
// /**
// * A fun scoreboard system for Arcadia.
// */
// public Sidebar() {
// this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
// this.sidebar = scoreboard.registerNewObjective("sidebar", "dummy");
// this.api = Arcadia.getPlugin(Arcadia.class).getAPI();
// sidebar.setDisplaySlot(DisplaySlot.SIDEBAR);
// this.updateDisplayName(0, 10);
// for(Player player : Bukkit.getOnlinePlayers()) player.setScoreboard(scoreboard);
// this.onCreation();
// api.getPlugin().getServer().getPluginManager().registerEvents(this, api.getPlugin());
// }
//
// public abstract void onCreation();
//
// /**
// * Returns the sidebar.
// * @return
// */
// public Objective getSidebar() {
// return this.sidebar;
// }
//
// /**
// * Returns the ArcadiaAPI.
// * @return
// */
// public ArcadiaAPI getAPI() {
// return this.api;
// }
//
// /**
// * Updates the scoreboard display name.
// * (Called every second & or on certain events)
// */
// public void updateDisplayName(int minutes, int seconds) {
// final String currentRotation = "" + (api.getGameManager().getRotation().getCurrentID()+1);
// final String rotationSize = "" + api.getGameManager().getRotation().getSize();
// final String currentTime = Utils.formatTime(minutes, seconds);
// switch(api.getGameManager().getGameState()) {
// case STARTING: this.sidebar.setDisplayName(" " + api.getTranslationManager()
// .fetchTranslation("ui.scoreboard.title-starting").build(currentRotation, rotationSize, currentTime) + " "); break;
// case INGAME: this.sidebar.setDisplayName(" " + api.getTranslationManager()
// .fetchTranslation("ui.scoreboard.title-ingame").build(currentRotation, rotationSize, currentTime) + " "); break;
// case FINISHED: this.sidebar.setDisplayName(" " + api.getTranslationManager()
// .fetchTranslation("ui.scoreboard.title-finished").build(currentRotation, rotationSize, currentTime) + " "); break;
// }
// }
// }
// Path: src/main/java/me/redraskal/arcadia/api/scoreboard/defaults/PlayersLeftSidebar.java
import me.redraskal.arcadia.api.game.event.PlayerAliveStatusEvent;
import me.redraskal.arcadia.api.scoreboard.Sidebar;
import org.bukkit.event.EventHandler;
package me.redraskal.arcadia.api.scoreboard.defaults;
public class PlayersLeftSidebar extends Sidebar {
@Override
public void onCreation() {
this.update();
}
/**
* Updates the Players Left string.
*/
public void update() {
this.getSidebar().getScore(this.getAPI().getTranslationManager()
.fetchTranslation("ui.scoreboard.players-left").build()).setScore(
this.getAPI().getGameManager().getPlayersAlive());
}
@EventHandler | public void onPlayerStatus(PlayerAliveStatusEvent event) { |
ArcadiaPlugins/Arcadia-Spigot | src/main/java/me/redraskal/arcadia/support/UltraCosmeticsSupport.java | // Path: src/main/java/me/redraskal/arcadia/api/game/event/GameLoadEvent.java
// public class GameLoadEvent extends Event {
//
// private static HandlerList handlers = new HandlerList();
//
// @Override
// public HandlerList getHandlers() {
// return handlers;
// }
//
// public static HandlerList getHandlerList() {
// return handlers;
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/game/event/PlayerAliveStatusEvent.java
// public class PlayerAliveStatusEvent extends Event {
//
// private static HandlerList handlers = new HandlerList();
//
// private final Player player;
// private final boolean alive;
// private final boolean spectating;
//
// public PlayerAliveStatusEvent(Player player, boolean alive, boolean spectating) {
// this.player = player;
// this.alive = alive;
// this.spectating = spectating;
// }
//
// public Player getPlayer() {
// return this.player;
// }
//
// public boolean isAlive() {
// return this.alive;
// }
//
// public boolean isSpectating() {
// return this.spectating;
// }
//
// @Override
// public HandlerList getHandlers() {
// return handlers;
// }
//
// public static HandlerList getHandlerList() {
// return handlers;
// }
// }
| import be.isach.ultracosmetics.UltraCosmetics;
import be.isach.ultracosmetics.cosmetics.emotes.Emote;
import be.isach.ultracosmetics.cosmetics.gadgets.Gadget;
import be.isach.ultracosmetics.cosmetics.hats.Hat;
import be.isach.ultracosmetics.cosmetics.particleeffects.ParticleEffect;
import be.isach.ultracosmetics.cosmetics.suits.ArmorSlot;
import be.isach.ultracosmetics.cosmetics.suits.Suit;
import be.isach.ultracosmetics.player.UltraPlayer;
import me.redraskal.arcadia.api.game.event.GameLoadEvent;
import me.redraskal.arcadia.api.game.event.PlayerAliveStatusEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.HashMap;
import java.util.Map; | package me.redraskal.arcadia.support;
public class UltraCosmeticsSupport implements Listener {
private final UltraCosmetics plugin = UltraCosmetics.getPlugin(UltraCosmetics.class);
@EventHandler | // Path: src/main/java/me/redraskal/arcadia/api/game/event/GameLoadEvent.java
// public class GameLoadEvent extends Event {
//
// private static HandlerList handlers = new HandlerList();
//
// @Override
// public HandlerList getHandlers() {
// return handlers;
// }
//
// public static HandlerList getHandlerList() {
// return handlers;
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/game/event/PlayerAliveStatusEvent.java
// public class PlayerAliveStatusEvent extends Event {
//
// private static HandlerList handlers = new HandlerList();
//
// private final Player player;
// private final boolean alive;
// private final boolean spectating;
//
// public PlayerAliveStatusEvent(Player player, boolean alive, boolean spectating) {
// this.player = player;
// this.alive = alive;
// this.spectating = spectating;
// }
//
// public Player getPlayer() {
// return this.player;
// }
//
// public boolean isAlive() {
// return this.alive;
// }
//
// public boolean isSpectating() {
// return this.spectating;
// }
//
// @Override
// public HandlerList getHandlers() {
// return handlers;
// }
//
// public static HandlerList getHandlerList() {
// return handlers;
// }
// }
// Path: src/main/java/me/redraskal/arcadia/support/UltraCosmeticsSupport.java
import be.isach.ultracosmetics.UltraCosmetics;
import be.isach.ultracosmetics.cosmetics.emotes.Emote;
import be.isach.ultracosmetics.cosmetics.gadgets.Gadget;
import be.isach.ultracosmetics.cosmetics.hats.Hat;
import be.isach.ultracosmetics.cosmetics.particleeffects.ParticleEffect;
import be.isach.ultracosmetics.cosmetics.suits.ArmorSlot;
import be.isach.ultracosmetics.cosmetics.suits.Suit;
import be.isach.ultracosmetics.player.UltraPlayer;
import me.redraskal.arcadia.api.game.event.GameLoadEvent;
import me.redraskal.arcadia.api.game.event.PlayerAliveStatusEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.HashMap;
import java.util.Map;
package me.redraskal.arcadia.support;
public class UltraCosmeticsSupport implements Listener {
private final UltraCosmetics plugin = UltraCosmetics.getPlugin(UltraCosmetics.class);
@EventHandler | public void onAliveStatusChange(PlayerAliveStatusEvent event) { |
ArcadiaPlugins/Arcadia-Spigot | src/main/java/me/redraskal/arcadia/support/UltraCosmeticsSupport.java | // Path: src/main/java/me/redraskal/arcadia/api/game/event/GameLoadEvent.java
// public class GameLoadEvent extends Event {
//
// private static HandlerList handlers = new HandlerList();
//
// @Override
// public HandlerList getHandlers() {
// return handlers;
// }
//
// public static HandlerList getHandlerList() {
// return handlers;
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/game/event/PlayerAliveStatusEvent.java
// public class PlayerAliveStatusEvent extends Event {
//
// private static HandlerList handlers = new HandlerList();
//
// private final Player player;
// private final boolean alive;
// private final boolean spectating;
//
// public PlayerAliveStatusEvent(Player player, boolean alive, boolean spectating) {
// this.player = player;
// this.alive = alive;
// this.spectating = spectating;
// }
//
// public Player getPlayer() {
// return this.player;
// }
//
// public boolean isAlive() {
// return this.alive;
// }
//
// public boolean isSpectating() {
// return this.spectating;
// }
//
// @Override
// public HandlerList getHandlers() {
// return handlers;
// }
//
// public static HandlerList getHandlerList() {
// return handlers;
// }
// }
| import be.isach.ultracosmetics.UltraCosmetics;
import be.isach.ultracosmetics.cosmetics.emotes.Emote;
import be.isach.ultracosmetics.cosmetics.gadgets.Gadget;
import be.isach.ultracosmetics.cosmetics.hats.Hat;
import be.isach.ultracosmetics.cosmetics.particleeffects.ParticleEffect;
import be.isach.ultracosmetics.cosmetics.suits.ArmorSlot;
import be.isach.ultracosmetics.cosmetics.suits.Suit;
import be.isach.ultracosmetics.player.UltraPlayer;
import me.redraskal.arcadia.api.game.event.GameLoadEvent;
import me.redraskal.arcadia.api.game.event.PlayerAliveStatusEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.HashMap;
import java.util.Map; | package me.redraskal.arcadia.support;
public class UltraCosmeticsSupport implements Listener {
private final UltraCosmetics plugin = UltraCosmetics.getPlugin(UltraCosmetics.class);
@EventHandler
public void onAliveStatusChange(PlayerAliveStatusEvent event) {
this.resetPlayer(this.plugin.getPlayerManager().getUltraPlayer(event.getPlayer()));
}
@EventHandler | // Path: src/main/java/me/redraskal/arcadia/api/game/event/GameLoadEvent.java
// public class GameLoadEvent extends Event {
//
// private static HandlerList handlers = new HandlerList();
//
// @Override
// public HandlerList getHandlers() {
// return handlers;
// }
//
// public static HandlerList getHandlerList() {
// return handlers;
// }
// }
//
// Path: src/main/java/me/redraskal/arcadia/api/game/event/PlayerAliveStatusEvent.java
// public class PlayerAliveStatusEvent extends Event {
//
// private static HandlerList handlers = new HandlerList();
//
// private final Player player;
// private final boolean alive;
// private final boolean spectating;
//
// public PlayerAliveStatusEvent(Player player, boolean alive, boolean spectating) {
// this.player = player;
// this.alive = alive;
// this.spectating = spectating;
// }
//
// public Player getPlayer() {
// return this.player;
// }
//
// public boolean isAlive() {
// return this.alive;
// }
//
// public boolean isSpectating() {
// return this.spectating;
// }
//
// @Override
// public HandlerList getHandlers() {
// return handlers;
// }
//
// public static HandlerList getHandlerList() {
// return handlers;
// }
// }
// Path: src/main/java/me/redraskal/arcadia/support/UltraCosmeticsSupport.java
import be.isach.ultracosmetics.UltraCosmetics;
import be.isach.ultracosmetics.cosmetics.emotes.Emote;
import be.isach.ultracosmetics.cosmetics.gadgets.Gadget;
import be.isach.ultracosmetics.cosmetics.hats.Hat;
import be.isach.ultracosmetics.cosmetics.particleeffects.ParticleEffect;
import be.isach.ultracosmetics.cosmetics.suits.ArmorSlot;
import be.isach.ultracosmetics.cosmetics.suits.Suit;
import be.isach.ultracosmetics.player.UltraPlayer;
import me.redraskal.arcadia.api.game.event.GameLoadEvent;
import me.redraskal.arcadia.api.game.event.PlayerAliveStatusEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.HashMap;
import java.util.Map;
package me.redraskal.arcadia.support;
public class UltraCosmeticsSupport implements Listener {
private final UltraCosmetics plugin = UltraCosmetics.getPlugin(UltraCosmetics.class);
@EventHandler
public void onAliveStatusChange(PlayerAliveStatusEvent event) {
this.resetPlayer(this.plugin.getPlayerManager().getUltraPlayer(event.getPlayer()));
}
@EventHandler | public void onGameLoad(GameLoadEvent event) { |
iobeam/iobeam-client-java | src/main/java/com/iobeam/api/RestException.java | // Path: src/main/java/com/iobeam/api/client/RestError.java
// public class RestError {
//
// private final int error;
// private final String message;
// private final String details;
//
// // Some useful errors. NOTE: must match Sleipnir REST errors.
// public static final int RESOURCE_NOT_CREATED = 31;
// public static final int RESOURCE_NOT_FOUND = 32;
// public static final int RESOURCE_ALREADY_EXISTS = 33;
//
// public RestError(final int error,
// final String message,
// final String details) {
// this.error = error;
// this.message = message;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public String getDetails() {
// return details;
// }
//
// public static RestError fromJson(final JSONObject json) {
// return new RestError(json.getInt("code"),
// json.getString("message"),
// json.optString("detailed_message", ""));
// }
// }
//
// Path: src/main/java/com/iobeam/api/http/StatusCode.java
// public enum StatusCode {
//
// OK(200),
// CREATED(201),
// ACCEPTED(202),
// NO_CONTENT(204),
//
// MOVED_PERMANENTLY(301),
// FOUND(302),
// SEE_OTHER(303),
// NOT_MODIFIED(304),
//
// BAD_REQUEST(400),
// UNAUTHORIZED(401),
// FORBIDDEN(403),
// NOT_FOUND(404),
// METHOD_NOT_ALLOWED(405),
// NOT_ACCEPTABLE(406),
// REQUEST_TIMEOUT(408),
// CONFLICT(409),
// LENGTH_REQUIRED(411),
// PRECONDITION_FAILED(412),
// REQUEST_ENTITY_TOO_LARGE(413),
// TOO_MANY_REQUESTS(429),
//
// INTERNAL_SERVER_ERROR(500),
// NOT_IMPLEMENTED(501),
// BAD_GATEWAY(502),
// SERVICE_UNAVAILABLE(503),
// HTTP_VERSION_NOT_SUPPORTED(504);
//
// private static final EnumMap<StatusCode, String> descriptions =
// new EnumMap<StatusCode, String>(StatusCode.class);
//
// private static final Map<Integer, StatusCode> reverseLookup =
// new HashMap<Integer, StatusCode>();
//
// static {
// for (final StatusCode status : StatusCode.values()) {
// descriptions.put(status, status.name().toLowerCase().replace('_', ' '));
// reverseLookup.put(status.getCode(), status);
// }
// }
//
// private final int status;
//
// private StatusCode(final int status) {
// this.status = status;
// }
//
// public int getCode() {
// return status;
// }
//
// public String getDescription() {
// return descriptions.get(this);
// }
//
// public static StatusCode fromValue(final int statusCode) {
// return reverseLookup.get(statusCode);
// }
// }
| import com.iobeam.api.client.RestError;
import com.iobeam.api.http.StatusCode; | package com.iobeam.api;
/**
* Exception representing a JSON error returned by the RESTful API.
*/
public class RestException extends ApiException {
private final StatusCode statusCode;
private final int error;
private final String details;
public RestException(final StatusCode statusCode,
final int error,
final String message) {
super(message);
this.statusCode = statusCode;
this.error = error;
this.details = "";
}
public RestException(final StatusCode statusCode, | // Path: src/main/java/com/iobeam/api/client/RestError.java
// public class RestError {
//
// private final int error;
// private final String message;
// private final String details;
//
// // Some useful errors. NOTE: must match Sleipnir REST errors.
// public static final int RESOURCE_NOT_CREATED = 31;
// public static final int RESOURCE_NOT_FOUND = 32;
// public static final int RESOURCE_ALREADY_EXISTS = 33;
//
// public RestError(final int error,
// final String message,
// final String details) {
// this.error = error;
// this.message = message;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public String getDetails() {
// return details;
// }
//
// public static RestError fromJson(final JSONObject json) {
// return new RestError(json.getInt("code"),
// json.getString("message"),
// json.optString("detailed_message", ""));
// }
// }
//
// Path: src/main/java/com/iobeam/api/http/StatusCode.java
// public enum StatusCode {
//
// OK(200),
// CREATED(201),
// ACCEPTED(202),
// NO_CONTENT(204),
//
// MOVED_PERMANENTLY(301),
// FOUND(302),
// SEE_OTHER(303),
// NOT_MODIFIED(304),
//
// BAD_REQUEST(400),
// UNAUTHORIZED(401),
// FORBIDDEN(403),
// NOT_FOUND(404),
// METHOD_NOT_ALLOWED(405),
// NOT_ACCEPTABLE(406),
// REQUEST_TIMEOUT(408),
// CONFLICT(409),
// LENGTH_REQUIRED(411),
// PRECONDITION_FAILED(412),
// REQUEST_ENTITY_TOO_LARGE(413),
// TOO_MANY_REQUESTS(429),
//
// INTERNAL_SERVER_ERROR(500),
// NOT_IMPLEMENTED(501),
// BAD_GATEWAY(502),
// SERVICE_UNAVAILABLE(503),
// HTTP_VERSION_NOT_SUPPORTED(504);
//
// private static final EnumMap<StatusCode, String> descriptions =
// new EnumMap<StatusCode, String>(StatusCode.class);
//
// private static final Map<Integer, StatusCode> reverseLookup =
// new HashMap<Integer, StatusCode>();
//
// static {
// for (final StatusCode status : StatusCode.values()) {
// descriptions.put(status, status.name().toLowerCase().replace('_', ' '));
// reverseLookup.put(status.getCode(), status);
// }
// }
//
// private final int status;
//
// private StatusCode(final int status) {
// this.status = status;
// }
//
// public int getCode() {
// return status;
// }
//
// public String getDescription() {
// return descriptions.get(this);
// }
//
// public static StatusCode fromValue(final int statusCode) {
// return reverseLookup.get(statusCode);
// }
// }
// Path: src/main/java/com/iobeam/api/RestException.java
import com.iobeam.api.client.RestError;
import com.iobeam.api.http.StatusCode;
package com.iobeam.api;
/**
* Exception representing a JSON error returned by the RESTful API.
*/
public class RestException extends ApiException {
private final StatusCode statusCode;
private final int error;
private final String details;
public RestException(final StatusCode statusCode,
final int error,
final String message) {
super(message);
this.statusCode = statusCode;
this.error = error;
this.details = "";
}
public RestException(final StatusCode statusCode, | final RestError error) { |
iobeam/iobeam-client-java | src/test/java/com/iobeam/api/auth/BasicTokenTests.java | // Path: src/main/java/com/iobeam/api/resource/util/Util.java
// public class Util {
//
// public static final SimpleDateFormat DATE_FORMAT =
// new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
//
// public static Date parseToDate(String dateStr) throws ParseException {
// Date created;
// try {
// created = Util.DATE_FORMAT.parse(dateStr);
// } catch (ParseException e) {
// try {
// final SimpleDateFormat ISO_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ");
// String newDateStr = dateStr.replace("Z", "+00:00");
// newDateStr = newDateStr.substring(0, 19) + newDateStr.substring(19).replace(":", "");
// created = ISO_FORMAT.parse(newDateStr);
// } catch (Exception e2) {
// throw e;
// }
// }
// return created;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.iobeam.api.resource.util.Util;
import org.json.JSONObject;
import org.junit.Test; | " \"admin\": true\n" +
"}";
private final String PROJECT_TOKEN_NEW = "{\n" +
" \"token\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImtpZCI6MTMzNX0=.eyJ1aWQiOjIsInBpZCI6NiwiZXhwIjoxNDcyNDA1MTMxLCJwbXMiOjd9.KhMKWinW0p_kPL2qNBTSrJjVutK1R26MkWukQSepU_0=\",\n" +
" \"expires\": \"" + TEST_DATE_STRING_8601 + "\",\n" +
" \"created\": \"" + TEST_DATE_STRING_8601 + "\",\n" +
" \"user_id\": 0,\n" +
" \"project_id\": 6,\n" +
" \"read\": true,\n" +
" \"write\": true,\n" +
" \"admin\": true\n" +
"}";
private final String PROJECT_TOKEN_NEW_2 = "{\n" +
" \"token\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImtpZCI6MTMzNX0=.eyJ1aWQiOjIsInBpZCI6NiwiZXhwIjoxNDcyNDA1MTMxLCJwbXMiOjd9.KhMKWinW0p_kPL2qNBTSrJjVutK1R26MkWukQSepU_0=\",\n" +
" \"expires\": \"" + TEST_DATE_STRING_8601_2 + "\",\n" +
" \"created\": \"" + TEST_DATE_STRING_8601_2 + "\",\n" +
" \"user_id\": 0,\n" +
" \"project_id\": 6,\n" +
" \"read\": true,\n" +
" \"write\": true,\n" +
" \"admin\": true\n" +
"}";
@Test
public void testProjectTokenFromJson() throws Exception {
ProjectBearerAuthToken t =
ProjectBearerAuthToken.fromJson(new JSONObject(PROJECT_TOKEN_NEW));
assertNotNull(t); | // Path: src/main/java/com/iobeam/api/resource/util/Util.java
// public class Util {
//
// public static final SimpleDateFormat DATE_FORMAT =
// new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
//
// public static Date parseToDate(String dateStr) throws ParseException {
// Date created;
// try {
// created = Util.DATE_FORMAT.parse(dateStr);
// } catch (ParseException e) {
// try {
// final SimpleDateFormat ISO_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ");
// String newDateStr = dateStr.replace("Z", "+00:00");
// newDateStr = newDateStr.substring(0, 19) + newDateStr.substring(19).replace(":", "");
// created = ISO_FORMAT.parse(newDateStr);
// } catch (Exception e2) {
// throw e;
// }
// }
// return created;
// }
// }
// Path: src/test/java/com/iobeam/api/auth/BasicTokenTests.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.iobeam.api.resource.util.Util;
import org.json.JSONObject;
import org.junit.Test;
" \"admin\": true\n" +
"}";
private final String PROJECT_TOKEN_NEW = "{\n" +
" \"token\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImtpZCI6MTMzNX0=.eyJ1aWQiOjIsInBpZCI6NiwiZXhwIjoxNDcyNDA1MTMxLCJwbXMiOjd9.KhMKWinW0p_kPL2qNBTSrJjVutK1R26MkWukQSepU_0=\",\n" +
" \"expires\": \"" + TEST_DATE_STRING_8601 + "\",\n" +
" \"created\": \"" + TEST_DATE_STRING_8601 + "\",\n" +
" \"user_id\": 0,\n" +
" \"project_id\": 6,\n" +
" \"read\": true,\n" +
" \"write\": true,\n" +
" \"admin\": true\n" +
"}";
private final String PROJECT_TOKEN_NEW_2 = "{\n" +
" \"token\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImtpZCI6MTMzNX0=.eyJ1aWQiOjIsInBpZCI6NiwiZXhwIjoxNDcyNDA1MTMxLCJwbXMiOjd9.KhMKWinW0p_kPL2qNBTSrJjVutK1R26MkWukQSepU_0=\",\n" +
" \"expires\": \"" + TEST_DATE_STRING_8601_2 + "\",\n" +
" \"created\": \"" + TEST_DATE_STRING_8601_2 + "\",\n" +
" \"user_id\": 0,\n" +
" \"project_id\": 6,\n" +
" \"read\": true,\n" +
" \"write\": true,\n" +
" \"admin\": true\n" +
"}";
@Test
public void testProjectTokenFromJson() throws Exception {
ProjectBearerAuthToken t =
ProjectBearerAuthToken.fromJson(new JSONObject(PROJECT_TOKEN_NEW));
assertNotNull(t); | assertEquals(Util.parseToDate(TEST_DATE_STRING_8601), t.getExpires()); |
iobeam/iobeam-client-java | src/main/java/com/iobeam/api/auth/UserBearerAuthToken.java | // Path: src/main/java/com/iobeam/api/resource/util/Util.java
// public class Util {
//
// public static final SimpleDateFormat DATE_FORMAT =
// new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
//
// public static Date parseToDate(String dateStr) throws ParseException {
// Date created;
// try {
// created = Util.DATE_FORMAT.parse(dateStr);
// } catch (ParseException e) {
// try {
// final SimpleDateFormat ISO_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ");
// String newDateStr = dateStr.replace("Z", "+00:00");
// newDateStr = newDateStr.substring(0, 19) + newDateStr.substring(19).replace(":", "");
// created = ISO_FORMAT.parse(newDateStr);
// } catch (Exception e2) {
// throw e;
// }
// }
// return created;
// }
// }
| import com.iobeam.api.resource.util.Util;
import org.json.JSONObject;
import java.text.ParseException;
import java.util.Date; | super(token);
this.userId = userId;
this.expires = expires.getTime();
}
@Override
public String getType() {
return "Bearer";
}
@Override
public boolean isValid() {
return !hasExpired();
}
public long getUserId() {
return userId;
}
public Date getExpires() {
return new Date(expires);
}
public boolean hasExpired() {
return System.currentTimeMillis() > expires;
}
public static UserBearerAuthToken fromJson(final JSONObject json) throws ParseException {
return new UserBearerAuthToken(json.getLong("user_id"),
json.getString("token"), | // Path: src/main/java/com/iobeam/api/resource/util/Util.java
// public class Util {
//
// public static final SimpleDateFormat DATE_FORMAT =
// new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
//
// public static Date parseToDate(String dateStr) throws ParseException {
// Date created;
// try {
// created = Util.DATE_FORMAT.parse(dateStr);
// } catch (ParseException e) {
// try {
// final SimpleDateFormat ISO_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ");
// String newDateStr = dateStr.replace("Z", "+00:00");
// newDateStr = newDateStr.substring(0, 19) + newDateStr.substring(19).replace(":", "");
// created = ISO_FORMAT.parse(newDateStr);
// } catch (Exception e2) {
// throw e;
// }
// }
// return created;
// }
// }
// Path: src/main/java/com/iobeam/api/auth/UserBearerAuthToken.java
import com.iobeam.api.resource.util.Util;
import org.json.JSONObject;
import java.text.ParseException;
import java.util.Date;
super(token);
this.userId = userId;
this.expires = expires.getTime();
}
@Override
public String getType() {
return "Bearer";
}
@Override
public boolean isValid() {
return !hasExpired();
}
public long getUserId() {
return userId;
}
public Date getExpires() {
return new Date(expires);
}
public boolean hasExpired() {
return System.currentTimeMillis() > expires;
}
public static UserBearerAuthToken fromJson(final JSONObject json) throws ParseException {
return new UserBearerAuthToken(json.getLong("user_id"),
json.getString("token"), | Util.parseToDate(json.getString("expires"))); |
iobeam/iobeam-client-java | src/main/java/com/iobeam/api/client/SendCallback.java | // Path: src/main/java/com/iobeam/api/resource/ImportBatch.java
// public class ImportBatch implements Serializable {
//
// private final long projectId;
// private final String deviceId;
// private final DataStore data;
// private final boolean legacy;
//
// public ImportBatch(long projectId, String deviceId, DataStore data) {
// this(projectId, deviceId, data, false);
// }
//
//
// private ImportBatch(long projectId, String deviceId, DataStore data, boolean legacy) {
// this.projectId = projectId;
// this.deviceId = deviceId;
// this.data = data;
// this.legacy = legacy;
// }
//
// public static ImportBatch createLegacy(long projectId, String deviceId, DataStore data) {
// return new ImportBatch(projectId, deviceId, data, true);
// }
//
// public long getProjectId() {
// return this.projectId;
// }
//
// public String getDeviceId() {
// return this.deviceId;
// }
//
// public DataStore getData() {
// return this.data;
// }
//
// public boolean isFromLegacy() {
// return this.legacy;
// }
//
// public JSONObject serialize() {
// JSONObject ret = new JSONObject();
// ret.put("project_id", this.projectId);
// ret.put("device_id", this.deviceId);
// ret.put("sources", this.data.toJson());
//
// return ret;
// }
//
// @Deprecated
// public JSONObject serialize(Map<String, Object> out) {
// out.put("project_id", this.projectId);
// out.put("device_id", this.deviceId);
// out.put("sources", this.data.toJson());
//
// return serialize();
// }
//
// public JSONObject toJson() {
// return serialize();
// }
//
// public JSONObject toJson(Map<String, Object> out) {
// return serialize(out);
// }
//
// @Override
// public String toString() {
// return "ImportBatch{" +
// "projectId=" + this.projectId + ", " +
// "deviceId=" + this.deviceId + ", " +
// "legacy=" + this.legacy + ", " +
// "data=" + this.data +
// "}";
// }
// }
| import com.iobeam.api.resource.ImportBatch; | package com.iobeam.api.client;
/**
* Callback for when data sending is called asynchronously.
*/
public abstract class SendCallback {
final RestCallback<Void> innerCallback = new RestCallback<Void>() {
@Override
public void completed(Void result, RestRequest req) { | // Path: src/main/java/com/iobeam/api/resource/ImportBatch.java
// public class ImportBatch implements Serializable {
//
// private final long projectId;
// private final String deviceId;
// private final DataStore data;
// private final boolean legacy;
//
// public ImportBatch(long projectId, String deviceId, DataStore data) {
// this(projectId, deviceId, data, false);
// }
//
//
// private ImportBatch(long projectId, String deviceId, DataStore data, boolean legacy) {
// this.projectId = projectId;
// this.deviceId = deviceId;
// this.data = data;
// this.legacy = legacy;
// }
//
// public static ImportBatch createLegacy(long projectId, String deviceId, DataStore data) {
// return new ImportBatch(projectId, deviceId, data, true);
// }
//
// public long getProjectId() {
// return this.projectId;
// }
//
// public String getDeviceId() {
// return this.deviceId;
// }
//
// public DataStore getData() {
// return this.data;
// }
//
// public boolean isFromLegacy() {
// return this.legacy;
// }
//
// public JSONObject serialize() {
// JSONObject ret = new JSONObject();
// ret.put("project_id", this.projectId);
// ret.put("device_id", this.deviceId);
// ret.put("sources", this.data.toJson());
//
// return ret;
// }
//
// @Deprecated
// public JSONObject serialize(Map<String, Object> out) {
// out.put("project_id", this.projectId);
// out.put("device_id", this.deviceId);
// out.put("sources", this.data.toJson());
//
// return serialize();
// }
//
// public JSONObject toJson() {
// return serialize();
// }
//
// public JSONObject toJson(Map<String, Object> out) {
// return serialize(out);
// }
//
// @Override
// public String toString() {
// return "ImportBatch{" +
// "projectId=" + this.projectId + ", " +
// "deviceId=" + this.deviceId + ", " +
// "legacy=" + this.legacy + ", " +
// "data=" + this.data +
// "}";
// }
// }
// Path: src/main/java/com/iobeam/api/client/SendCallback.java
import com.iobeam.api.resource.ImportBatch;
package com.iobeam.api.client;
/**
* Callback for when data sending is called asynchronously.
*/
public abstract class SendCallback {
final RestCallback<Void> innerCallback = new RestCallback<Void>() {
@Override
public void completed(Void result, RestRequest req) { | onSuccess((ImportBatch) req.getBuilder().getContent()); |
iobeam/iobeam-client-java | src/main/java/com/iobeam/api/client/RegisterCallback.java | // Path: src/main/java/com/iobeam/api/resource/Device.java
// public class Device implements Serializable {
//
// /**
// * A wrapper class around a String that uniquely identifies the device.
// */
// @Deprecated
// public static final class Id implements Serializable {
//
// private final String id;
//
// public Id(String id) {
// this.id = id;
// }
//
// public String getId() {
// return id;
// }
//
// public static Device.Id fromJson(final JSONObject json)
// throws ParseException {
// return new Device.Id(json.getString("device_id"));
// }
//
// @Override
// public String toString() {
// return id;
// }
// }
//
// public static final class Spec {
//
// private final String id;
// private final String name;
// private final String type;
//
// public Spec() {
// this(null, null, null);
// }
//
// public Spec(String id) {
// this(id, null, null);
// }
//
// public Spec(String id, String name) {
// this(id, name, null);
// }
//
// public Spec(String id, String name, String type) {
// this.id = id;
// this.name = name;
// this.type = type;
// }
// }
//
// private final long projectId;
// private final Spec spec;
// private final Date created;
//
// // TODO(robatticus) Remove in 0.6.0
// @Deprecated
// public Device(String id,
// long projectId,
// String name,
// String type,
// Date created) {
// this(projectId, new Device.Spec(id, name, type), created);
// }
//
// // TODO(robatticus) Remove in 0.6.0
// @Deprecated
// public Device(Id id,
// long projectId,
// String name,
// String type,
// Date created) {
// this(projectId, new Device.Spec(id.getId(), name, type), created);
// }
//
// public Device(long projectId, Device.Spec spec, Date created) {
// this.projectId = projectId;
// this.spec = spec;
// this.created = created;
// }
//
// public Device(long projectId, Device.Spec spec) {
// this(projectId, spec, null);
// }
//
// public Device(Device d) {
// this(d.projectId, d.spec, d.created);
// }
//
// @JsonProperty("device_id")
// public String getId() {
// return spec.id;
// }
//
// @JsonProperty("project_id")
// public long getProjectId() {
// return projectId;
// }
//
// @JsonProperty("device_name")
// public String getName() {
// return spec.name;
// }
//
// @JsonProperty("device_type")
// public String getType() {
// return spec.type;
// }
//
// public Date getCreated() {
// return created;
// }
//
// public static Device fromJson(final JSONObject json) throws ParseException {
//
// final long projectId = json.getLong("project_id");
// final Date created = Util.parseToDate(json.getString("created"));
// final Builder builder = new Builder(projectId).
// setId(json.getString("device_id")).
// setName(json.optString("device_name", null)).
// setType(json.optString("device_type", null)).
// setCreated(created);
//
// return builder.build();
// }
//
// @Override
// public String toString() {
// return "Device{" +
// "id='" + spec.id + "'" +
// ", projectId=" + projectId +
// ", name='" + spec.name + "'" +
// ", type='" + spec.type + "'" +
// ", created=" + (created != null ? Util.DATE_FORMAT.format(created) : null) +
// '}';
// }
//
// public static class Builder {
//
// private final long projectId;
// private String deviceId;
// private String deviceName;
// private String deviceType;
// public Date created;
//
// public Builder(final long projectId) {
// this.projectId = projectId;
// }
//
// @Deprecated
// public Builder setId(final String id) {
// return this.id(id);
// }
//
// public Builder id(final String id) {
// this.deviceId = id;
// return this;
// }
//
// @Deprecated
// public Builder setName(final String name) {
// return this.name(name);
// }
//
// public Builder name(final String name) {
// this.deviceName = name;
// return this;
// }
//
// @Deprecated
// public Builder setType(final String type) {
// return this.type(type);
// }
//
// public Builder type(final String type) {
// this.deviceType = type;
// return this;
// }
//
// @Deprecated
// public Builder setCreated(final Date created) {
// return this.created(created);
// }
//
// public Builder created(final Date created) {
// this.created = created;
// return this;
// }
//
// public Device build() {
// return new Device(projectId, new Spec(deviceId, deviceName, deviceType), created);
// }
// }
// }
| import com.iobeam.api.resource.Device; | package com.iobeam.api.client;
/**
* Callback for registering a device asynchronously.
*/
public abstract class RegisterCallback {
static RegisterCallback getEmptyCallback() {
return new RegisterCallback() {
@Override
public void onSuccess(String deviceId) {
}
@Override
public void onFailure(Throwable exc, RestRequest req) {
exc.printStackTrace();
}
};
}
| // Path: src/main/java/com/iobeam/api/resource/Device.java
// public class Device implements Serializable {
//
// /**
// * A wrapper class around a String that uniquely identifies the device.
// */
// @Deprecated
// public static final class Id implements Serializable {
//
// private final String id;
//
// public Id(String id) {
// this.id = id;
// }
//
// public String getId() {
// return id;
// }
//
// public static Device.Id fromJson(final JSONObject json)
// throws ParseException {
// return new Device.Id(json.getString("device_id"));
// }
//
// @Override
// public String toString() {
// return id;
// }
// }
//
// public static final class Spec {
//
// private final String id;
// private final String name;
// private final String type;
//
// public Spec() {
// this(null, null, null);
// }
//
// public Spec(String id) {
// this(id, null, null);
// }
//
// public Spec(String id, String name) {
// this(id, name, null);
// }
//
// public Spec(String id, String name, String type) {
// this.id = id;
// this.name = name;
// this.type = type;
// }
// }
//
// private final long projectId;
// private final Spec spec;
// private final Date created;
//
// // TODO(robatticus) Remove in 0.6.0
// @Deprecated
// public Device(String id,
// long projectId,
// String name,
// String type,
// Date created) {
// this(projectId, new Device.Spec(id, name, type), created);
// }
//
// // TODO(robatticus) Remove in 0.6.0
// @Deprecated
// public Device(Id id,
// long projectId,
// String name,
// String type,
// Date created) {
// this(projectId, new Device.Spec(id.getId(), name, type), created);
// }
//
// public Device(long projectId, Device.Spec spec, Date created) {
// this.projectId = projectId;
// this.spec = spec;
// this.created = created;
// }
//
// public Device(long projectId, Device.Spec spec) {
// this(projectId, spec, null);
// }
//
// public Device(Device d) {
// this(d.projectId, d.spec, d.created);
// }
//
// @JsonProperty("device_id")
// public String getId() {
// return spec.id;
// }
//
// @JsonProperty("project_id")
// public long getProjectId() {
// return projectId;
// }
//
// @JsonProperty("device_name")
// public String getName() {
// return spec.name;
// }
//
// @JsonProperty("device_type")
// public String getType() {
// return spec.type;
// }
//
// public Date getCreated() {
// return created;
// }
//
// public static Device fromJson(final JSONObject json) throws ParseException {
//
// final long projectId = json.getLong("project_id");
// final Date created = Util.parseToDate(json.getString("created"));
// final Builder builder = new Builder(projectId).
// setId(json.getString("device_id")).
// setName(json.optString("device_name", null)).
// setType(json.optString("device_type", null)).
// setCreated(created);
//
// return builder.build();
// }
//
// @Override
// public String toString() {
// return "Device{" +
// "id='" + spec.id + "'" +
// ", projectId=" + projectId +
// ", name='" + spec.name + "'" +
// ", type='" + spec.type + "'" +
// ", created=" + (created != null ? Util.DATE_FORMAT.format(created) : null) +
// '}';
// }
//
// public static class Builder {
//
// private final long projectId;
// private String deviceId;
// private String deviceName;
// private String deviceType;
// public Date created;
//
// public Builder(final long projectId) {
// this.projectId = projectId;
// }
//
// @Deprecated
// public Builder setId(final String id) {
// return this.id(id);
// }
//
// public Builder id(final String id) {
// this.deviceId = id;
// return this;
// }
//
// @Deprecated
// public Builder setName(final String name) {
// return this.name(name);
// }
//
// public Builder name(final String name) {
// this.deviceName = name;
// return this;
// }
//
// @Deprecated
// public Builder setType(final String type) {
// return this.type(type);
// }
//
// public Builder type(final String type) {
// this.deviceType = type;
// return this;
// }
//
// @Deprecated
// public Builder setCreated(final Date created) {
// return this.created(created);
// }
//
// public Builder created(final Date created) {
// this.created = created;
// return this;
// }
//
// public Device build() {
// return new Device(projectId, new Spec(deviceId, deviceName, deviceType), created);
// }
// }
// }
// Path: src/main/java/com/iobeam/api/client/RegisterCallback.java
import com.iobeam.api.resource.Device;
package com.iobeam.api.client;
/**
* Callback for registering a device asynchronously.
*/
public abstract class RegisterCallback {
static RegisterCallback getEmptyCallback() {
return new RegisterCallback() {
@Override
public void onSuccess(String deviceId) {
}
@Override
public void onFailure(Throwable exc, RestRequest req) {
exc.printStackTrace();
}
};
}
| RestCallback<Device> getInnerCallback(final Iobeam iobeam) { |
iobeam/iobeam-client-java | src/main/java/com/iobeam/api/resource/Device.java | // Path: src/main/java/com/iobeam/api/resource/util/Util.java
// public class Util {
//
// public static final SimpleDateFormat DATE_FORMAT =
// new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
//
// public static Date parseToDate(String dateStr) throws ParseException {
// Date created;
// try {
// created = Util.DATE_FORMAT.parse(dateStr);
// } catch (ParseException e) {
// try {
// final SimpleDateFormat ISO_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ");
// String newDateStr = dateStr.replace("Z", "+00:00");
// newDateStr = newDateStr.substring(0, 19) + newDateStr.substring(19).replace(":", "");
// created = ISO_FORMAT.parse(newDateStr);
// } catch (Exception e2) {
// throw e;
// }
// }
// return created;
// }
// }
| import com.iobeam.api.resource.annotations.JsonProperty;
import com.iobeam.api.resource.util.Util;
import org.json.JSONObject;
import java.io.Serializable;
import java.text.ParseException;
import java.util.Date; | this(d.projectId, d.spec, d.created);
}
@JsonProperty("device_id")
public String getId() {
return spec.id;
}
@JsonProperty("project_id")
public long getProjectId() {
return projectId;
}
@JsonProperty("device_name")
public String getName() {
return spec.name;
}
@JsonProperty("device_type")
public String getType() {
return spec.type;
}
public Date getCreated() {
return created;
}
public static Device fromJson(final JSONObject json) throws ParseException {
final long projectId = json.getLong("project_id"); | // Path: src/main/java/com/iobeam/api/resource/util/Util.java
// public class Util {
//
// public static final SimpleDateFormat DATE_FORMAT =
// new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
//
// public static Date parseToDate(String dateStr) throws ParseException {
// Date created;
// try {
// created = Util.DATE_FORMAT.parse(dateStr);
// } catch (ParseException e) {
// try {
// final SimpleDateFormat ISO_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ");
// String newDateStr = dateStr.replace("Z", "+00:00");
// newDateStr = newDateStr.substring(0, 19) + newDateStr.substring(19).replace(":", "");
// created = ISO_FORMAT.parse(newDateStr);
// } catch (Exception e2) {
// throw e;
// }
// }
// return created;
// }
// }
// Path: src/main/java/com/iobeam/api/resource/Device.java
import com.iobeam.api.resource.annotations.JsonProperty;
import com.iobeam.api.resource.util.Util;
import org.json.JSONObject;
import java.io.Serializable;
import java.text.ParseException;
import java.util.Date;
this(d.projectId, d.spec, d.created);
}
@JsonProperty("device_id")
public String getId() {
return spec.id;
}
@JsonProperty("project_id")
public long getProjectId() {
return projectId;
}
@JsonProperty("device_name")
public String getName() {
return spec.name;
}
@JsonProperty("device_type")
public String getType() {
return spec.type;
}
public Date getCreated() {
return created;
}
public static Device fromJson(final JSONObject json) throws ParseException {
final long projectId = json.getLong("project_id"); | final Date created = Util.parseToDate(json.getString("created")); |
iobeam/iobeam-client-java | src/test/java/com/iobeam/api/resource/DeviceTest.java | // Path: src/main/java/com/iobeam/api/resource/util/Util.java
// public class Util {
//
// public static final SimpleDateFormat DATE_FORMAT =
// new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
//
// public static Date parseToDate(String dateStr) throws ParseException {
// Date created;
// try {
// created = Util.DATE_FORMAT.parse(dateStr);
// } catch (ParseException e) {
// try {
// final SimpleDateFormat ISO_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ");
// String newDateStr = dateStr.replace("Z", "+00:00");
// newDateStr = newDateStr.substring(0, 19) + newDateStr.substring(19).replace(":", "");
// created = ISO_FORMAT.parse(newDateStr);
// } catch (Exception e2) {
// throw e;
// }
// }
// return created;
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import com.iobeam.api.resource.util.Util;
import org.json.JSONObject;
import org.junit.Test;
import java.util.Date; | package com.iobeam.api.resource;
public class DeviceTest {
private static final String DEVICE_ID = "test1234only5678";
private static final String DEVICE_NAME = "java_test_ex";
private static final String DEVICE_TYPE = "java_test";
private static final String TEST_DATE_STRING = "2015-03-01 20:55:21 -0400";
private static final String TEST_DATE_STRING_8601 = "2015-03-01T20:55:21-04:00";
private static final String jsonOldDevice = "{\n"
+ " \"device_id\": \"" + DEVICE_ID + "\",\n"
+ " \"project_id\": 1000,\n"
+ " \"device_name\": \"" + DEVICE_NAME + "\",\n"
+ " \"device_type\": \"java_test\",\n"
+ " \"created\": \"" + TEST_DATE_STRING + "\"\n"
+ "}";
private static final String jsonDevice = "{\n"
+ " \"device_id\": \"" + DEVICE_ID + "\",\n"
+ " \"project_id\": 1000,\n"
+ " \"device_name\": \"" + DEVICE_NAME + "\",\n"
+ " \"device_type\": \"java_test\",\n"
+ " \"created\": \"" + TEST_DATE_STRING_8601 + "\"\n"
+ "}";
@Test
public void testFromJson() throws Exception {
Device d = Device.fromJson(new JSONObject(jsonDevice));
assertNotNull(d);
assertEquals(DEVICE_ID, d.getId());
assertEquals(1000, d.getProjectId());
assertEquals(DEVICE_NAME, d.getName());
assertEquals(DEVICE_TYPE, d.getType());
| // Path: src/main/java/com/iobeam/api/resource/util/Util.java
// public class Util {
//
// public static final SimpleDateFormat DATE_FORMAT =
// new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
//
// public static Date parseToDate(String dateStr) throws ParseException {
// Date created;
// try {
// created = Util.DATE_FORMAT.parse(dateStr);
// } catch (ParseException e) {
// try {
// final SimpleDateFormat ISO_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ");
// String newDateStr = dateStr.replace("Z", "+00:00");
// newDateStr = newDateStr.substring(0, 19) + newDateStr.substring(19).replace(":", "");
// created = ISO_FORMAT.parse(newDateStr);
// } catch (Exception e2) {
// throw e;
// }
// }
// return created;
// }
// }
// Path: src/test/java/com/iobeam/api/resource/DeviceTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import com.iobeam.api.resource.util.Util;
import org.json.JSONObject;
import org.junit.Test;
import java.util.Date;
package com.iobeam.api.resource;
public class DeviceTest {
private static final String DEVICE_ID = "test1234only5678";
private static final String DEVICE_NAME = "java_test_ex";
private static final String DEVICE_TYPE = "java_test";
private static final String TEST_DATE_STRING = "2015-03-01 20:55:21 -0400";
private static final String TEST_DATE_STRING_8601 = "2015-03-01T20:55:21-04:00";
private static final String jsonOldDevice = "{\n"
+ " \"device_id\": \"" + DEVICE_ID + "\",\n"
+ " \"project_id\": 1000,\n"
+ " \"device_name\": \"" + DEVICE_NAME + "\",\n"
+ " \"device_type\": \"java_test\",\n"
+ " \"created\": \"" + TEST_DATE_STRING + "\"\n"
+ "}";
private static final String jsonDevice = "{\n"
+ " \"device_id\": \"" + DEVICE_ID + "\",\n"
+ " \"project_id\": 1000,\n"
+ " \"device_name\": \"" + DEVICE_NAME + "\",\n"
+ " \"device_type\": \"java_test\",\n"
+ " \"created\": \"" + TEST_DATE_STRING_8601 + "\"\n"
+ "}";
@Test
public void testFromJson() throws Exception {
Device d = Device.fromJson(new JSONObject(jsonDevice));
assertNotNull(d);
assertEquals(DEVICE_ID, d.getId());
assertEquals(1000, d.getProjectId());
assertEquals(DEVICE_NAME, d.getName());
assertEquals(DEVICE_TYPE, d.getType());
| Date expected = Util.parseToDate(TEST_DATE_STRING_8601); |
iobeam/iobeam-client-java | src/main/java/com/iobeam/api/auth/AuthException.java | // Path: src/main/java/com/iobeam/api/RestException.java
// public class RestException extends ApiException {
//
// private final StatusCode statusCode;
// private final int error;
// private final String details;
//
// public RestException(final StatusCode statusCode,
// final int error,
// final String message) {
// super(message);
// this.statusCode = statusCode;
// this.error = error;
// this.details = "";
// }
//
// public RestException(final StatusCode statusCode,
// final RestError error) {
// super(error.getMessage());
// this.statusCode = statusCode;
// this.error = error.getError();
// this.details = error.getDetails();
// }
//
// public StatusCode getStatusCode() {
// return statusCode;
// }
//
// public int getError() {
// return error;
// }
//
// public String getDetails() {
// return details;
// }
// }
//
// Path: src/main/java/com/iobeam/api/client/RestError.java
// public class RestError {
//
// private final int error;
// private final String message;
// private final String details;
//
// // Some useful errors. NOTE: must match Sleipnir REST errors.
// public static final int RESOURCE_NOT_CREATED = 31;
// public static final int RESOURCE_NOT_FOUND = 32;
// public static final int RESOURCE_ALREADY_EXISTS = 33;
//
// public RestError(final int error,
// final String message,
// final String details) {
// this.error = error;
// this.message = message;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public String getDetails() {
// return details;
// }
//
// public static RestError fromJson(final JSONObject json) {
// return new RestError(json.getInt("code"),
// json.getString("message"),
// json.optString("detailed_message", ""));
// }
// }
//
// Path: src/main/java/com/iobeam/api/http/StatusCode.java
// public enum StatusCode {
//
// OK(200),
// CREATED(201),
// ACCEPTED(202),
// NO_CONTENT(204),
//
// MOVED_PERMANENTLY(301),
// FOUND(302),
// SEE_OTHER(303),
// NOT_MODIFIED(304),
//
// BAD_REQUEST(400),
// UNAUTHORIZED(401),
// FORBIDDEN(403),
// NOT_FOUND(404),
// METHOD_NOT_ALLOWED(405),
// NOT_ACCEPTABLE(406),
// REQUEST_TIMEOUT(408),
// CONFLICT(409),
// LENGTH_REQUIRED(411),
// PRECONDITION_FAILED(412),
// REQUEST_ENTITY_TOO_LARGE(413),
// TOO_MANY_REQUESTS(429),
//
// INTERNAL_SERVER_ERROR(500),
// NOT_IMPLEMENTED(501),
// BAD_GATEWAY(502),
// SERVICE_UNAVAILABLE(503),
// HTTP_VERSION_NOT_SUPPORTED(504);
//
// private static final EnumMap<StatusCode, String> descriptions =
// new EnumMap<StatusCode, String>(StatusCode.class);
//
// private static final Map<Integer, StatusCode> reverseLookup =
// new HashMap<Integer, StatusCode>();
//
// static {
// for (final StatusCode status : StatusCode.values()) {
// descriptions.put(status, status.name().toLowerCase().replace('_', ' '));
// reverseLookup.put(status.getCode(), status);
// }
// }
//
// private final int status;
//
// private StatusCode(final int status) {
// this.status = status;
// }
//
// public int getCode() {
// return status;
// }
//
// public String getDescription() {
// return descriptions.get(this);
// }
//
// public static StatusCode fromValue(final int statusCode) {
// return reverseLookup.get(statusCode);
// }
// }
| import com.iobeam.api.RestException;
import com.iobeam.api.client.RestError;
import com.iobeam.api.http.StatusCode; | package com.iobeam.api.auth;
/**
* A specific RestException for authentication failures.
*/
public class AuthException extends RestException {
public AuthException(final int error, final String message) { | // Path: src/main/java/com/iobeam/api/RestException.java
// public class RestException extends ApiException {
//
// private final StatusCode statusCode;
// private final int error;
// private final String details;
//
// public RestException(final StatusCode statusCode,
// final int error,
// final String message) {
// super(message);
// this.statusCode = statusCode;
// this.error = error;
// this.details = "";
// }
//
// public RestException(final StatusCode statusCode,
// final RestError error) {
// super(error.getMessage());
// this.statusCode = statusCode;
// this.error = error.getError();
// this.details = error.getDetails();
// }
//
// public StatusCode getStatusCode() {
// return statusCode;
// }
//
// public int getError() {
// return error;
// }
//
// public String getDetails() {
// return details;
// }
// }
//
// Path: src/main/java/com/iobeam/api/client/RestError.java
// public class RestError {
//
// private final int error;
// private final String message;
// private final String details;
//
// // Some useful errors. NOTE: must match Sleipnir REST errors.
// public static final int RESOURCE_NOT_CREATED = 31;
// public static final int RESOURCE_NOT_FOUND = 32;
// public static final int RESOURCE_ALREADY_EXISTS = 33;
//
// public RestError(final int error,
// final String message,
// final String details) {
// this.error = error;
// this.message = message;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public String getDetails() {
// return details;
// }
//
// public static RestError fromJson(final JSONObject json) {
// return new RestError(json.getInt("code"),
// json.getString("message"),
// json.optString("detailed_message", ""));
// }
// }
//
// Path: src/main/java/com/iobeam/api/http/StatusCode.java
// public enum StatusCode {
//
// OK(200),
// CREATED(201),
// ACCEPTED(202),
// NO_CONTENT(204),
//
// MOVED_PERMANENTLY(301),
// FOUND(302),
// SEE_OTHER(303),
// NOT_MODIFIED(304),
//
// BAD_REQUEST(400),
// UNAUTHORIZED(401),
// FORBIDDEN(403),
// NOT_FOUND(404),
// METHOD_NOT_ALLOWED(405),
// NOT_ACCEPTABLE(406),
// REQUEST_TIMEOUT(408),
// CONFLICT(409),
// LENGTH_REQUIRED(411),
// PRECONDITION_FAILED(412),
// REQUEST_ENTITY_TOO_LARGE(413),
// TOO_MANY_REQUESTS(429),
//
// INTERNAL_SERVER_ERROR(500),
// NOT_IMPLEMENTED(501),
// BAD_GATEWAY(502),
// SERVICE_UNAVAILABLE(503),
// HTTP_VERSION_NOT_SUPPORTED(504);
//
// private static final EnumMap<StatusCode, String> descriptions =
// new EnumMap<StatusCode, String>(StatusCode.class);
//
// private static final Map<Integer, StatusCode> reverseLookup =
// new HashMap<Integer, StatusCode>();
//
// static {
// for (final StatusCode status : StatusCode.values()) {
// descriptions.put(status, status.name().toLowerCase().replace('_', ' '));
// reverseLookup.put(status.getCode(), status);
// }
// }
//
// private final int status;
//
// private StatusCode(final int status) {
// this.status = status;
// }
//
// public int getCode() {
// return status;
// }
//
// public String getDescription() {
// return descriptions.get(this);
// }
//
// public static StatusCode fromValue(final int statusCode) {
// return reverseLookup.get(statusCode);
// }
// }
// Path: src/main/java/com/iobeam/api/auth/AuthException.java
import com.iobeam.api.RestException;
import com.iobeam.api.client.RestError;
import com.iobeam.api.http.StatusCode;
package com.iobeam.api.auth;
/**
* A specific RestException for authentication failures.
*/
public class AuthException extends RestException {
public AuthException(final int error, final String message) { | super(StatusCode.UNAUTHORIZED, error, message); |
iobeam/iobeam-client-java | src/main/java/com/iobeam/api/auth/AuthException.java | // Path: src/main/java/com/iobeam/api/RestException.java
// public class RestException extends ApiException {
//
// private final StatusCode statusCode;
// private final int error;
// private final String details;
//
// public RestException(final StatusCode statusCode,
// final int error,
// final String message) {
// super(message);
// this.statusCode = statusCode;
// this.error = error;
// this.details = "";
// }
//
// public RestException(final StatusCode statusCode,
// final RestError error) {
// super(error.getMessage());
// this.statusCode = statusCode;
// this.error = error.getError();
// this.details = error.getDetails();
// }
//
// public StatusCode getStatusCode() {
// return statusCode;
// }
//
// public int getError() {
// return error;
// }
//
// public String getDetails() {
// return details;
// }
// }
//
// Path: src/main/java/com/iobeam/api/client/RestError.java
// public class RestError {
//
// private final int error;
// private final String message;
// private final String details;
//
// // Some useful errors. NOTE: must match Sleipnir REST errors.
// public static final int RESOURCE_NOT_CREATED = 31;
// public static final int RESOURCE_NOT_FOUND = 32;
// public static final int RESOURCE_ALREADY_EXISTS = 33;
//
// public RestError(final int error,
// final String message,
// final String details) {
// this.error = error;
// this.message = message;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public String getDetails() {
// return details;
// }
//
// public static RestError fromJson(final JSONObject json) {
// return new RestError(json.getInt("code"),
// json.getString("message"),
// json.optString("detailed_message", ""));
// }
// }
//
// Path: src/main/java/com/iobeam/api/http/StatusCode.java
// public enum StatusCode {
//
// OK(200),
// CREATED(201),
// ACCEPTED(202),
// NO_CONTENT(204),
//
// MOVED_PERMANENTLY(301),
// FOUND(302),
// SEE_OTHER(303),
// NOT_MODIFIED(304),
//
// BAD_REQUEST(400),
// UNAUTHORIZED(401),
// FORBIDDEN(403),
// NOT_FOUND(404),
// METHOD_NOT_ALLOWED(405),
// NOT_ACCEPTABLE(406),
// REQUEST_TIMEOUT(408),
// CONFLICT(409),
// LENGTH_REQUIRED(411),
// PRECONDITION_FAILED(412),
// REQUEST_ENTITY_TOO_LARGE(413),
// TOO_MANY_REQUESTS(429),
//
// INTERNAL_SERVER_ERROR(500),
// NOT_IMPLEMENTED(501),
// BAD_GATEWAY(502),
// SERVICE_UNAVAILABLE(503),
// HTTP_VERSION_NOT_SUPPORTED(504);
//
// private static final EnumMap<StatusCode, String> descriptions =
// new EnumMap<StatusCode, String>(StatusCode.class);
//
// private static final Map<Integer, StatusCode> reverseLookup =
// new HashMap<Integer, StatusCode>();
//
// static {
// for (final StatusCode status : StatusCode.values()) {
// descriptions.put(status, status.name().toLowerCase().replace('_', ' '));
// reverseLookup.put(status.getCode(), status);
// }
// }
//
// private final int status;
//
// private StatusCode(final int status) {
// this.status = status;
// }
//
// public int getCode() {
// return status;
// }
//
// public String getDescription() {
// return descriptions.get(this);
// }
//
// public static StatusCode fromValue(final int statusCode) {
// return reverseLookup.get(statusCode);
// }
// }
| import com.iobeam.api.RestException;
import com.iobeam.api.client.RestError;
import com.iobeam.api.http.StatusCode; | package com.iobeam.api.auth;
/**
* A specific RestException for authentication failures.
*/
public class AuthException extends RestException {
public AuthException(final int error, final String message) {
super(StatusCode.UNAUTHORIZED, error, message);
}
| // Path: src/main/java/com/iobeam/api/RestException.java
// public class RestException extends ApiException {
//
// private final StatusCode statusCode;
// private final int error;
// private final String details;
//
// public RestException(final StatusCode statusCode,
// final int error,
// final String message) {
// super(message);
// this.statusCode = statusCode;
// this.error = error;
// this.details = "";
// }
//
// public RestException(final StatusCode statusCode,
// final RestError error) {
// super(error.getMessage());
// this.statusCode = statusCode;
// this.error = error.getError();
// this.details = error.getDetails();
// }
//
// public StatusCode getStatusCode() {
// return statusCode;
// }
//
// public int getError() {
// return error;
// }
//
// public String getDetails() {
// return details;
// }
// }
//
// Path: src/main/java/com/iobeam/api/client/RestError.java
// public class RestError {
//
// private final int error;
// private final String message;
// private final String details;
//
// // Some useful errors. NOTE: must match Sleipnir REST errors.
// public static final int RESOURCE_NOT_CREATED = 31;
// public static final int RESOURCE_NOT_FOUND = 32;
// public static final int RESOURCE_ALREADY_EXISTS = 33;
//
// public RestError(final int error,
// final String message,
// final String details) {
// this.error = error;
// this.message = message;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public String getDetails() {
// return details;
// }
//
// public static RestError fromJson(final JSONObject json) {
// return new RestError(json.getInt("code"),
// json.getString("message"),
// json.optString("detailed_message", ""));
// }
// }
//
// Path: src/main/java/com/iobeam/api/http/StatusCode.java
// public enum StatusCode {
//
// OK(200),
// CREATED(201),
// ACCEPTED(202),
// NO_CONTENT(204),
//
// MOVED_PERMANENTLY(301),
// FOUND(302),
// SEE_OTHER(303),
// NOT_MODIFIED(304),
//
// BAD_REQUEST(400),
// UNAUTHORIZED(401),
// FORBIDDEN(403),
// NOT_FOUND(404),
// METHOD_NOT_ALLOWED(405),
// NOT_ACCEPTABLE(406),
// REQUEST_TIMEOUT(408),
// CONFLICT(409),
// LENGTH_REQUIRED(411),
// PRECONDITION_FAILED(412),
// REQUEST_ENTITY_TOO_LARGE(413),
// TOO_MANY_REQUESTS(429),
//
// INTERNAL_SERVER_ERROR(500),
// NOT_IMPLEMENTED(501),
// BAD_GATEWAY(502),
// SERVICE_UNAVAILABLE(503),
// HTTP_VERSION_NOT_SUPPORTED(504);
//
// private static final EnumMap<StatusCode, String> descriptions =
// new EnumMap<StatusCode, String>(StatusCode.class);
//
// private static final Map<Integer, StatusCode> reverseLookup =
// new HashMap<Integer, StatusCode>();
//
// static {
// for (final StatusCode status : StatusCode.values()) {
// descriptions.put(status, status.name().toLowerCase().replace('_', ' '));
// reverseLookup.put(status.getCode(), status);
// }
// }
//
// private final int status;
//
// private StatusCode(final int status) {
// this.status = status;
// }
//
// public int getCode() {
// return status;
// }
//
// public String getDescription() {
// return descriptions.get(this);
// }
//
// public static StatusCode fromValue(final int statusCode) {
// return reverseLookup.get(statusCode);
// }
// }
// Path: src/main/java/com/iobeam/api/auth/AuthException.java
import com.iobeam.api.RestException;
import com.iobeam.api.client.RestError;
import com.iobeam.api.http.StatusCode;
package com.iobeam.api.auth;
/**
* A specific RestException for authentication failures.
*/
public class AuthException extends RestException {
public AuthException(final int error, final String message) {
super(StatusCode.UNAUTHORIZED, error, message);
}
| public AuthException(final RestError error) { |
iobeam/iobeam-client-java | src/main/java/com/iobeam/api/auth/AuthHandler.java | // Path: src/main/java/com/iobeam/api/ApiException.java
// public class ApiException extends Exception {
//
// public ApiException(final String message) {
// super(message);
// }
// }
| import com.iobeam.api.ApiException;
import java.io.IOException;
import java.util.concurrent.Callable; | package com.iobeam.api.auth;
/**
* Handler interface for refreshing auth tokens.
*/
public interface AuthHandler extends Callable<AuthToken> {
public void setForceRefresh(boolean force);
| // Path: src/main/java/com/iobeam/api/ApiException.java
// public class ApiException extends Exception {
//
// public ApiException(final String message) {
// super(message);
// }
// }
// Path: src/main/java/com/iobeam/api/auth/AuthHandler.java
import com.iobeam.api.ApiException;
import java.io.IOException;
import java.util.concurrent.Callable;
package com.iobeam.api.auth;
/**
* Handler interface for refreshing auth tokens.
*/
public interface AuthHandler extends Callable<AuthToken> {
public void setForceRefresh(boolean force);
| public AuthToken refreshToken() throws IOException, ApiException; |
iobeam/iobeam-client-java | src/main/java/com/iobeam/api/resource/ResourceMapper.java | // Path: src/main/java/com/iobeam/api/auth/ProjectBearerAuthToken.java
// public class ProjectBearerAuthToken extends AuthToken {
//
// private final long projectId;
// private final long expires;
//
// public ProjectBearerAuthToken(final long projectId,
// final String token,
// final Date expires) {
// super(token);
// this.projectId = projectId;
// this.expires = expires.getTime();
// }
//
// @Override
// public String getType() {
// return "Bearer";
// }
//
// @Override
// public boolean isValid() {
// return !hasExpired();
// }
//
// public long getProjectId() {
// return projectId;
// }
//
// public Date getExpires() {
// return new Date(expires);
// }
//
// public boolean hasExpired() {
// return System.currentTimeMillis() > expires;
// }
//
// public static ProjectBearerAuthToken fromJson(final JSONObject json) throws ParseException {
// return new ProjectBearerAuthToken(json.getLong("project_id"),
// json.getString("token"),
// Util.parseToDate(json.getString("expires")));
// }
//
// @Override
// public String toString() {
// return "ProjectBearerAuthToken{" +
// "projectId=" + projectId +
// ", expires=" + expires +
// '}';
// }
// }
//
// Path: src/main/java/com/iobeam/api/auth/UserBearerAuthToken.java
// public class UserBearerAuthToken extends AuthToken {
//
// private final long userId;
// private final long expires;
//
// public UserBearerAuthToken(final long userId,
// final String token,
// final Date expires) {
// super(token);
// this.userId = userId;
// this.expires = expires.getTime();
// }
//
// @Override
// public String getType() {
// return "Bearer";
// }
//
// @Override
// public boolean isValid() {
// return !hasExpired();
// }
//
// public long getUserId() {
// return userId;
// }
//
// public Date getExpires() {
// return new Date(expires);
// }
//
// public boolean hasExpired() {
// return System.currentTimeMillis() > expires;
// }
//
// public static UserBearerAuthToken fromJson(final JSONObject json) throws ParseException {
// return new UserBearerAuthToken(json.getLong("user_id"),
// json.getString("token"),
// Util.parseToDate(json.getString("expires")));
// }
//
// @Override
// public String toString() {
// return "UserBearerAuthToken{" +
// "userId=" + userId +
// ", expires=" + expires +
// '}';
// }
// }
//
// Path: src/main/java/com/iobeam/api/client/RestError.java
// public class RestError {
//
// private final int error;
// private final String message;
// private final String details;
//
// // Some useful errors. NOTE: must match Sleipnir REST errors.
// public static final int RESOURCE_NOT_CREATED = 31;
// public static final int RESOURCE_NOT_FOUND = 32;
// public static final int RESOURCE_ALREADY_EXISTS = 33;
//
// public RestError(final int error,
// final String message,
// final String details) {
// this.error = error;
// this.message = message;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public String getDetails() {
// return details;
// }
//
// public static RestError fromJson(final JSONObject json) {
// return new RestError(json.getInt("code"),
// json.getString("message"),
// json.optString("detailed_message", ""));
// }
// }
//
// Path: src/main/java/com/iobeam/api/resource/util/Util.java
// public class Util {
//
// public static final SimpleDateFormat DATE_FORMAT =
// new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
//
// public static Date parseToDate(String dateStr) throws ParseException {
// Date created;
// try {
// created = Util.DATE_FORMAT.parse(dateStr);
// } catch (ParseException e) {
// try {
// final SimpleDateFormat ISO_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ");
// String newDateStr = dateStr.replace("Z", "+00:00");
// newDateStr = newDateStr.substring(0, 19) + newDateStr.substring(19).replace(":", "");
// created = ISO_FORMAT.parse(newDateStr);
// } catch (Exception e2) {
// throw e;
// }
// }
// return created;
// }
// }
| import com.iobeam.api.auth.ProjectBearerAuthToken;
import com.iobeam.api.auth.UserBearerAuthToken;
import com.iobeam.api.client.RestError;
import com.iobeam.api.resource.annotations.JsonIgnore;
import com.iobeam.api.resource.annotations.JsonProperty;
import com.iobeam.api.resource.util.Util;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.text.ParseException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map; | package com.iobeam.api.resource;
/**
* Maps resources to JSON and vice versa.
*/
public class ResourceMapper {
@SuppressWarnings("unchecked")
public <T> T fromJson(final JSONObject json,
final Class<T> resourceClass) throws ResourceException {
try {
if (resourceClass.equals(Device.class)) {
return (T) Device.fromJson(json);
} else if (resourceClass.equals(Device.Id.class)) {
return (T) Device.Id.fromJson(json);
} else if (resourceClass.equals(DeviceList.class)) {
return (T) DeviceList.fromJson(json); | // Path: src/main/java/com/iobeam/api/auth/ProjectBearerAuthToken.java
// public class ProjectBearerAuthToken extends AuthToken {
//
// private final long projectId;
// private final long expires;
//
// public ProjectBearerAuthToken(final long projectId,
// final String token,
// final Date expires) {
// super(token);
// this.projectId = projectId;
// this.expires = expires.getTime();
// }
//
// @Override
// public String getType() {
// return "Bearer";
// }
//
// @Override
// public boolean isValid() {
// return !hasExpired();
// }
//
// public long getProjectId() {
// return projectId;
// }
//
// public Date getExpires() {
// return new Date(expires);
// }
//
// public boolean hasExpired() {
// return System.currentTimeMillis() > expires;
// }
//
// public static ProjectBearerAuthToken fromJson(final JSONObject json) throws ParseException {
// return new ProjectBearerAuthToken(json.getLong("project_id"),
// json.getString("token"),
// Util.parseToDate(json.getString("expires")));
// }
//
// @Override
// public String toString() {
// return "ProjectBearerAuthToken{" +
// "projectId=" + projectId +
// ", expires=" + expires +
// '}';
// }
// }
//
// Path: src/main/java/com/iobeam/api/auth/UserBearerAuthToken.java
// public class UserBearerAuthToken extends AuthToken {
//
// private final long userId;
// private final long expires;
//
// public UserBearerAuthToken(final long userId,
// final String token,
// final Date expires) {
// super(token);
// this.userId = userId;
// this.expires = expires.getTime();
// }
//
// @Override
// public String getType() {
// return "Bearer";
// }
//
// @Override
// public boolean isValid() {
// return !hasExpired();
// }
//
// public long getUserId() {
// return userId;
// }
//
// public Date getExpires() {
// return new Date(expires);
// }
//
// public boolean hasExpired() {
// return System.currentTimeMillis() > expires;
// }
//
// public static UserBearerAuthToken fromJson(final JSONObject json) throws ParseException {
// return new UserBearerAuthToken(json.getLong("user_id"),
// json.getString("token"),
// Util.parseToDate(json.getString("expires")));
// }
//
// @Override
// public String toString() {
// return "UserBearerAuthToken{" +
// "userId=" + userId +
// ", expires=" + expires +
// '}';
// }
// }
//
// Path: src/main/java/com/iobeam/api/client/RestError.java
// public class RestError {
//
// private final int error;
// private final String message;
// private final String details;
//
// // Some useful errors. NOTE: must match Sleipnir REST errors.
// public static final int RESOURCE_NOT_CREATED = 31;
// public static final int RESOURCE_NOT_FOUND = 32;
// public static final int RESOURCE_ALREADY_EXISTS = 33;
//
// public RestError(final int error,
// final String message,
// final String details) {
// this.error = error;
// this.message = message;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public String getDetails() {
// return details;
// }
//
// public static RestError fromJson(final JSONObject json) {
// return new RestError(json.getInt("code"),
// json.getString("message"),
// json.optString("detailed_message", ""));
// }
// }
//
// Path: src/main/java/com/iobeam/api/resource/util/Util.java
// public class Util {
//
// public static final SimpleDateFormat DATE_FORMAT =
// new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
//
// public static Date parseToDate(String dateStr) throws ParseException {
// Date created;
// try {
// created = Util.DATE_FORMAT.parse(dateStr);
// } catch (ParseException e) {
// try {
// final SimpleDateFormat ISO_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ");
// String newDateStr = dateStr.replace("Z", "+00:00");
// newDateStr = newDateStr.substring(0, 19) + newDateStr.substring(19).replace(":", "");
// created = ISO_FORMAT.parse(newDateStr);
// } catch (Exception e2) {
// throw e;
// }
// }
// return created;
// }
// }
// Path: src/main/java/com/iobeam/api/resource/ResourceMapper.java
import com.iobeam.api.auth.ProjectBearerAuthToken;
import com.iobeam.api.auth.UserBearerAuthToken;
import com.iobeam.api.client.RestError;
import com.iobeam.api.resource.annotations.JsonIgnore;
import com.iobeam.api.resource.annotations.JsonProperty;
import com.iobeam.api.resource.util.Util;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.text.ParseException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
package com.iobeam.api.resource;
/**
* Maps resources to JSON and vice versa.
*/
public class ResourceMapper {
@SuppressWarnings("unchecked")
public <T> T fromJson(final JSONObject json,
final Class<T> resourceClass) throws ResourceException {
try {
if (resourceClass.equals(Device.class)) {
return (T) Device.fromJson(json);
} else if (resourceClass.equals(Device.Id.class)) {
return (T) Device.Id.fromJson(json);
} else if (resourceClass.equals(DeviceList.class)) {
return (T) DeviceList.fromJson(json); | } else if (resourceClass.equals(ProjectBearerAuthToken.class)) { |
iobeam/iobeam-client-java | src/main/java/com/iobeam/api/resource/ResourceMapper.java | // Path: src/main/java/com/iobeam/api/auth/ProjectBearerAuthToken.java
// public class ProjectBearerAuthToken extends AuthToken {
//
// private final long projectId;
// private final long expires;
//
// public ProjectBearerAuthToken(final long projectId,
// final String token,
// final Date expires) {
// super(token);
// this.projectId = projectId;
// this.expires = expires.getTime();
// }
//
// @Override
// public String getType() {
// return "Bearer";
// }
//
// @Override
// public boolean isValid() {
// return !hasExpired();
// }
//
// public long getProjectId() {
// return projectId;
// }
//
// public Date getExpires() {
// return new Date(expires);
// }
//
// public boolean hasExpired() {
// return System.currentTimeMillis() > expires;
// }
//
// public static ProjectBearerAuthToken fromJson(final JSONObject json) throws ParseException {
// return new ProjectBearerAuthToken(json.getLong("project_id"),
// json.getString("token"),
// Util.parseToDate(json.getString("expires")));
// }
//
// @Override
// public String toString() {
// return "ProjectBearerAuthToken{" +
// "projectId=" + projectId +
// ", expires=" + expires +
// '}';
// }
// }
//
// Path: src/main/java/com/iobeam/api/auth/UserBearerAuthToken.java
// public class UserBearerAuthToken extends AuthToken {
//
// private final long userId;
// private final long expires;
//
// public UserBearerAuthToken(final long userId,
// final String token,
// final Date expires) {
// super(token);
// this.userId = userId;
// this.expires = expires.getTime();
// }
//
// @Override
// public String getType() {
// return "Bearer";
// }
//
// @Override
// public boolean isValid() {
// return !hasExpired();
// }
//
// public long getUserId() {
// return userId;
// }
//
// public Date getExpires() {
// return new Date(expires);
// }
//
// public boolean hasExpired() {
// return System.currentTimeMillis() > expires;
// }
//
// public static UserBearerAuthToken fromJson(final JSONObject json) throws ParseException {
// return new UserBearerAuthToken(json.getLong("user_id"),
// json.getString("token"),
// Util.parseToDate(json.getString("expires")));
// }
//
// @Override
// public String toString() {
// return "UserBearerAuthToken{" +
// "userId=" + userId +
// ", expires=" + expires +
// '}';
// }
// }
//
// Path: src/main/java/com/iobeam/api/client/RestError.java
// public class RestError {
//
// private final int error;
// private final String message;
// private final String details;
//
// // Some useful errors. NOTE: must match Sleipnir REST errors.
// public static final int RESOURCE_NOT_CREATED = 31;
// public static final int RESOURCE_NOT_FOUND = 32;
// public static final int RESOURCE_ALREADY_EXISTS = 33;
//
// public RestError(final int error,
// final String message,
// final String details) {
// this.error = error;
// this.message = message;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public String getDetails() {
// return details;
// }
//
// public static RestError fromJson(final JSONObject json) {
// return new RestError(json.getInt("code"),
// json.getString("message"),
// json.optString("detailed_message", ""));
// }
// }
//
// Path: src/main/java/com/iobeam/api/resource/util/Util.java
// public class Util {
//
// public static final SimpleDateFormat DATE_FORMAT =
// new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
//
// public static Date parseToDate(String dateStr) throws ParseException {
// Date created;
// try {
// created = Util.DATE_FORMAT.parse(dateStr);
// } catch (ParseException e) {
// try {
// final SimpleDateFormat ISO_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ");
// String newDateStr = dateStr.replace("Z", "+00:00");
// newDateStr = newDateStr.substring(0, 19) + newDateStr.substring(19).replace(":", "");
// created = ISO_FORMAT.parse(newDateStr);
// } catch (Exception e2) {
// throw e;
// }
// }
// return created;
// }
// }
| import com.iobeam.api.auth.ProjectBearerAuthToken;
import com.iobeam.api.auth.UserBearerAuthToken;
import com.iobeam.api.client.RestError;
import com.iobeam.api.resource.annotations.JsonIgnore;
import com.iobeam.api.resource.annotations.JsonProperty;
import com.iobeam.api.resource.util.Util;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.text.ParseException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map; | package com.iobeam.api.resource;
/**
* Maps resources to JSON and vice versa.
*/
public class ResourceMapper {
@SuppressWarnings("unchecked")
public <T> T fromJson(final JSONObject json,
final Class<T> resourceClass) throws ResourceException {
try {
if (resourceClass.equals(Device.class)) {
return (T) Device.fromJson(json);
} else if (resourceClass.equals(Device.Id.class)) {
return (T) Device.Id.fromJson(json);
} else if (resourceClass.equals(DeviceList.class)) {
return (T) DeviceList.fromJson(json);
} else if (resourceClass.equals(ProjectBearerAuthToken.class)) {
return (T) ProjectBearerAuthToken.fromJson(json); | // Path: src/main/java/com/iobeam/api/auth/ProjectBearerAuthToken.java
// public class ProjectBearerAuthToken extends AuthToken {
//
// private final long projectId;
// private final long expires;
//
// public ProjectBearerAuthToken(final long projectId,
// final String token,
// final Date expires) {
// super(token);
// this.projectId = projectId;
// this.expires = expires.getTime();
// }
//
// @Override
// public String getType() {
// return "Bearer";
// }
//
// @Override
// public boolean isValid() {
// return !hasExpired();
// }
//
// public long getProjectId() {
// return projectId;
// }
//
// public Date getExpires() {
// return new Date(expires);
// }
//
// public boolean hasExpired() {
// return System.currentTimeMillis() > expires;
// }
//
// public static ProjectBearerAuthToken fromJson(final JSONObject json) throws ParseException {
// return new ProjectBearerAuthToken(json.getLong("project_id"),
// json.getString("token"),
// Util.parseToDate(json.getString("expires")));
// }
//
// @Override
// public String toString() {
// return "ProjectBearerAuthToken{" +
// "projectId=" + projectId +
// ", expires=" + expires +
// '}';
// }
// }
//
// Path: src/main/java/com/iobeam/api/auth/UserBearerAuthToken.java
// public class UserBearerAuthToken extends AuthToken {
//
// private final long userId;
// private final long expires;
//
// public UserBearerAuthToken(final long userId,
// final String token,
// final Date expires) {
// super(token);
// this.userId = userId;
// this.expires = expires.getTime();
// }
//
// @Override
// public String getType() {
// return "Bearer";
// }
//
// @Override
// public boolean isValid() {
// return !hasExpired();
// }
//
// public long getUserId() {
// return userId;
// }
//
// public Date getExpires() {
// return new Date(expires);
// }
//
// public boolean hasExpired() {
// return System.currentTimeMillis() > expires;
// }
//
// public static UserBearerAuthToken fromJson(final JSONObject json) throws ParseException {
// return new UserBearerAuthToken(json.getLong("user_id"),
// json.getString("token"),
// Util.parseToDate(json.getString("expires")));
// }
//
// @Override
// public String toString() {
// return "UserBearerAuthToken{" +
// "userId=" + userId +
// ", expires=" + expires +
// '}';
// }
// }
//
// Path: src/main/java/com/iobeam/api/client/RestError.java
// public class RestError {
//
// private final int error;
// private final String message;
// private final String details;
//
// // Some useful errors. NOTE: must match Sleipnir REST errors.
// public static final int RESOURCE_NOT_CREATED = 31;
// public static final int RESOURCE_NOT_FOUND = 32;
// public static final int RESOURCE_ALREADY_EXISTS = 33;
//
// public RestError(final int error,
// final String message,
// final String details) {
// this.error = error;
// this.message = message;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getMessage() {
// return message;
// }
//
// public String getDetails() {
// return details;
// }
//
// public static RestError fromJson(final JSONObject json) {
// return new RestError(json.getInt("code"),
// json.getString("message"),
// json.optString("detailed_message", ""));
// }
// }
//
// Path: src/main/java/com/iobeam/api/resource/util/Util.java
// public class Util {
//
// public static final SimpleDateFormat DATE_FORMAT =
// new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
//
// public static Date parseToDate(String dateStr) throws ParseException {
// Date created;
// try {
// created = Util.DATE_FORMAT.parse(dateStr);
// } catch (ParseException e) {
// try {
// final SimpleDateFormat ISO_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ");
// String newDateStr = dateStr.replace("Z", "+00:00");
// newDateStr = newDateStr.substring(0, 19) + newDateStr.substring(19).replace(":", "");
// created = ISO_FORMAT.parse(newDateStr);
// } catch (Exception e2) {
// throw e;
// }
// }
// return created;
// }
// }
// Path: src/main/java/com/iobeam/api/resource/ResourceMapper.java
import com.iobeam.api.auth.ProjectBearerAuthToken;
import com.iobeam.api.auth.UserBearerAuthToken;
import com.iobeam.api.client.RestError;
import com.iobeam.api.resource.annotations.JsonIgnore;
import com.iobeam.api.resource.annotations.JsonProperty;
import com.iobeam.api.resource.util.Util;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.text.ParseException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
package com.iobeam.api.resource;
/**
* Maps resources to JSON and vice versa.
*/
public class ResourceMapper {
@SuppressWarnings("unchecked")
public <T> T fromJson(final JSONObject json,
final Class<T> resourceClass) throws ResourceException {
try {
if (resourceClass.equals(Device.class)) {
return (T) Device.fromJson(json);
} else if (resourceClass.equals(Device.Id.class)) {
return (T) Device.Id.fromJson(json);
} else if (resourceClass.equals(DeviceList.class)) {
return (T) DeviceList.fromJson(json);
} else if (resourceClass.equals(ProjectBearerAuthToken.class)) {
return (T) ProjectBearerAuthToken.fromJson(json); | } else if (resourceClass.equals(UserBearerAuthToken.class)) { |
iobeam/iobeam-client-java | src/main/java/com/iobeam/api/auth/AbstractAuthHandler.java | // Path: src/main/java/com/iobeam/api/ApiException.java
// public class ApiException extends Exception {
//
// public ApiException(final String message) {
// super(message);
// }
// }
| import com.iobeam.api.ApiException;
import java.io.IOException;
import java.util.logging.Logger; | final AuthToken token = AuthUtils.readToken(authTokenFilePath);
if (token.isValid()) {
logger.info("read valid auth token from file '" + authTokenFilePath + "'");
}
return token;
} catch (Exception e) {
// Ignore
}
return null;
}
protected void writeToken(final AuthToken token) {
if (authTokenFilePath == null) {
return;
}
try {
AuthUtils.writeToken(token, authTokenFilePath);
logger.info("wrote auth token to file '" + authTokenFilePath + "'");
} catch (IOException e) {
// Ignore
}
}
@Override
public void setForceRefresh(final boolean forceRefresh) {
this.forceRefresh = forceRefresh;
}
| // Path: src/main/java/com/iobeam/api/ApiException.java
// public class ApiException extends Exception {
//
// public ApiException(final String message) {
// super(message);
// }
// }
// Path: src/main/java/com/iobeam/api/auth/AbstractAuthHandler.java
import com.iobeam.api.ApiException;
import java.io.IOException;
import java.util.logging.Logger;
final AuthToken token = AuthUtils.readToken(authTokenFilePath);
if (token.isValid()) {
logger.info("read valid auth token from file '" + authTokenFilePath + "'");
}
return token;
} catch (Exception e) {
// Ignore
}
return null;
}
protected void writeToken(final AuthToken token) {
if (authTokenFilePath == null) {
return;
}
try {
AuthUtils.writeToken(token, authTokenFilePath);
logger.info("wrote auth token to file '" + authTokenFilePath + "'");
} catch (IOException e) {
// Ignore
}
}
@Override
public void setForceRefresh(final boolean forceRefresh) {
this.forceRefresh = forceRefresh;
}
| public abstract AuthToken refreshToken() throws IOException, ApiException; |
iobeam/iobeam-client-java | src/main/java/com/iobeam/api/auth/ProjectBearerAuthToken.java | // Path: src/main/java/com/iobeam/api/resource/util/Util.java
// public class Util {
//
// public static final SimpleDateFormat DATE_FORMAT =
// new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
//
// public static Date parseToDate(String dateStr) throws ParseException {
// Date created;
// try {
// created = Util.DATE_FORMAT.parse(dateStr);
// } catch (ParseException e) {
// try {
// final SimpleDateFormat ISO_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ");
// String newDateStr = dateStr.replace("Z", "+00:00");
// newDateStr = newDateStr.substring(0, 19) + newDateStr.substring(19).replace(":", "");
// created = ISO_FORMAT.parse(newDateStr);
// } catch (Exception e2) {
// throw e;
// }
// }
// return created;
// }
// }
| import com.iobeam.api.resource.util.Util;
import org.json.JSONObject;
import java.text.ParseException;
import java.util.Date; | super(token);
this.projectId = projectId;
this.expires = expires.getTime();
}
@Override
public String getType() {
return "Bearer";
}
@Override
public boolean isValid() {
return !hasExpired();
}
public long getProjectId() {
return projectId;
}
public Date getExpires() {
return new Date(expires);
}
public boolean hasExpired() {
return System.currentTimeMillis() > expires;
}
public static ProjectBearerAuthToken fromJson(final JSONObject json) throws ParseException {
return new ProjectBearerAuthToken(json.getLong("project_id"),
json.getString("token"), | // Path: src/main/java/com/iobeam/api/resource/util/Util.java
// public class Util {
//
// public static final SimpleDateFormat DATE_FORMAT =
// new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
//
// public static Date parseToDate(String dateStr) throws ParseException {
// Date created;
// try {
// created = Util.DATE_FORMAT.parse(dateStr);
// } catch (ParseException e) {
// try {
// final SimpleDateFormat ISO_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ");
// String newDateStr = dateStr.replace("Z", "+00:00");
// newDateStr = newDateStr.substring(0, 19) + newDateStr.substring(19).replace(":", "");
// created = ISO_FORMAT.parse(newDateStr);
// } catch (Exception e2) {
// throw e;
// }
// }
// return created;
// }
// }
// Path: src/main/java/com/iobeam/api/auth/ProjectBearerAuthToken.java
import com.iobeam.api.resource.util.Util;
import org.json.JSONObject;
import java.text.ParseException;
import java.util.Date;
super(token);
this.projectId = projectId;
this.expires = expires.getTime();
}
@Override
public String getType() {
return "Bearer";
}
@Override
public boolean isValid() {
return !hasExpired();
}
public long getProjectId() {
return projectId;
}
public Date getExpires() {
return new Date(expires);
}
public boolean hasExpired() {
return System.currentTimeMillis() > expires;
}
public static ProjectBearerAuthToken fromJson(final JSONObject json) throws ParseException {
return new ProjectBearerAuthToken(json.getLong("project_id"),
json.getString("token"), | Util.parseToDate(json.getString("expires"))); |
WebcamStudio/webcamstudio | src/webcamstudio/mixers/PrePlayer.java | // Path: src/webcamstudio/WebcamStudio.java
// public static int audioFreq = 22050;
| import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import static java.util.concurrent.Executors.newCachedThreadPool;
import javax.sound.sampled.AudioFormat;
import static javax.sound.sampled.AudioSystem.getSourceDataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import static webcamstudio.WebcamStudio.audioFreq;
import webcamstudio.components.PreViewer;
import static webcamstudio.util.Tools.sleep; | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package webcamstudio.mixers;
/**
*
* @author patrick (modified by karl)
*/
public class PrePlayer implements Runnable {
private static PrePlayer preInstance = null;
public static PrePlayer getPreInstance(PreViewer viewer) {
if (preInstance == null) {
preInstance = new PrePlayer(viewer);
}
return preInstance;
}
boolean stopMe = false;
public boolean stopMePub = stopMe;
private SourceDataLine source;
private ExecutorService executor = null;
private final ArrayList<byte[]> buffer = new ArrayList<>();
private FrameBuffer frames = null;
private PreViewer preViewer = null; | // Path: src/webcamstudio/WebcamStudio.java
// public static int audioFreq = 22050;
// Path: src/webcamstudio/mixers/PrePlayer.java
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import static java.util.concurrent.Executors.newCachedThreadPool;
import javax.sound.sampled.AudioFormat;
import static javax.sound.sampled.AudioSystem.getSourceDataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import static webcamstudio.WebcamStudio.audioFreq;
import webcamstudio.components.PreViewer;
import static webcamstudio.util.Tools.sleep;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package webcamstudio.mixers;
/**
*
* @author patrick (modified by karl)
*/
public class PrePlayer implements Runnable {
private static PrePlayer preInstance = null;
public static PrePlayer getPreInstance(PreViewer viewer) {
if (preInstance == null) {
preInstance = new PrePlayer(viewer);
}
return preInstance;
}
boolean stopMe = false;
public boolean stopMePub = stopMe;
private SourceDataLine source;
private ExecutorService executor = null;
private final ArrayList<byte[]> buffer = new ArrayList<>();
private FrameBuffer frames = null;
private PreViewer preViewer = null; | private final int aFreq = audioFreq; |
WebcamStudio/webcamstudio | src/webcamstudio/mixers/AudioBuffer.java | // Path: src/webcamstudio/WebcamStudio.java
// public static int audioFreq = 22050;
| import static java.lang.System.arraycopy;
import java.util.ArrayList;
import static webcamstudio.WebcamStudio.audioFreq;
import static webcamstudio.mixers.MasterMixer.BUFFER_SIZE;
import static webcamstudio.util.Tools.sleep; | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package webcamstudio.mixers;
/**
*
* @author patrick
*/
public class AudioBuffer {
private final ArrayList<byte[]> buffer = new ArrayList<>();
private int bufferSize = BUFFER_SIZE;
private boolean abort = false; | // Path: src/webcamstudio/WebcamStudio.java
// public static int audioFreq = 22050;
// Path: src/webcamstudio/mixers/AudioBuffer.java
import static java.lang.System.arraycopy;
import java.util.ArrayList;
import static webcamstudio.WebcamStudio.audioFreq;
import static webcamstudio.mixers.MasterMixer.BUFFER_SIZE;
import static webcamstudio.util.Tools.sleep;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package webcamstudio.mixers;
/**
*
* @author patrick
*/
public class AudioBuffer {
private final ArrayList<byte[]> buffer = new ArrayList<>();
private int bufferSize = BUFFER_SIZE;
private boolean abort = false; | private int aFreq = audioFreq; |
WebcamStudio/webcamstudio | src/webcamstudio/mixers/Frame.java | // Path: src/webcamstudio/WebcamStudio.java
// public static int audioFreq = 22050;
| import java.awt.Color;
import java.awt.Graphics2D;
import static java.awt.RenderingHints.KEY_ANTIALIASING;
import static java.awt.RenderingHints.KEY_COLOR_RENDERING;
import static java.awt.RenderingHints.KEY_DITHERING;
import static java.awt.RenderingHints.KEY_FRACTIONALMETRICS;
import static java.awt.RenderingHints.KEY_INTERPOLATION;
import static java.awt.RenderingHints.KEY_RENDERING;
import static java.awt.RenderingHints.KEY_TEXT_ANTIALIASING;
import static java.awt.RenderingHints.VALUE_ANTIALIAS_OFF;
import static java.awt.RenderingHints.VALUE_COLOR_RENDER_SPEED;
import static java.awt.RenderingHints.VALUE_DITHER_DISABLE;
import static java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_OFF;
import static java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR;
import static java.awt.RenderingHints.VALUE_RENDER_SPEED;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_OFF;
import java.awt.image.BufferedImage;
import static java.awt.image.BufferedImage.TYPE_INT_ARGB;
import static webcamstudio.WebcamStudio.audioFreq; | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package webcamstudio.mixers;
/**
*
* @author patrick
*/
public class Frame {
private BufferedImage image;
private int x = 0;
private int y = 0;
private int w = 320;
private int h = 240;
private int opacity = 100;
private float audioVolume=1;
private byte[] audioData;
private int zOrder = 0;
private String uuid = null;
private long frameNb = 0; | // Path: src/webcamstudio/WebcamStudio.java
// public static int audioFreq = 22050;
// Path: src/webcamstudio/mixers/Frame.java
import java.awt.Color;
import java.awt.Graphics2D;
import static java.awt.RenderingHints.KEY_ANTIALIASING;
import static java.awt.RenderingHints.KEY_COLOR_RENDERING;
import static java.awt.RenderingHints.KEY_DITHERING;
import static java.awt.RenderingHints.KEY_FRACTIONALMETRICS;
import static java.awt.RenderingHints.KEY_INTERPOLATION;
import static java.awt.RenderingHints.KEY_RENDERING;
import static java.awt.RenderingHints.KEY_TEXT_ANTIALIASING;
import static java.awt.RenderingHints.VALUE_ANTIALIAS_OFF;
import static java.awt.RenderingHints.VALUE_COLOR_RENDER_SPEED;
import static java.awt.RenderingHints.VALUE_DITHER_DISABLE;
import static java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_OFF;
import static java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR;
import static java.awt.RenderingHints.VALUE_RENDER_SPEED;
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_OFF;
import java.awt.image.BufferedImage;
import static java.awt.image.BufferedImage.TYPE_INT_ARGB;
import static webcamstudio.WebcamStudio.audioFreq;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package webcamstudio.mixers;
/**
*
* @author patrick
*/
public class Frame {
private BufferedImage image;
private int x = 0;
private int y = 0;
private int w = 320;
private int h = 240;
private int opacity = 100;
private float audioVolume=1;
private byte[] audioData;
private int zOrder = 0;
private String uuid = null;
private long frameNb = 0; | private int aFreq = audioFreq; |
WebcamStudio/webcamstudio | src/webcamstudio/mixers/SystemPlayer.java | // Path: src/webcamstudio/WebcamStudio.java
// public static int audioFreq = 22050;
//
// Path: src/webcamstudio/components/Viewer.java
// public class Viewer extends javax.swing.JPanel {
// GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
// GraphicsDevice device = env.getDefaultScreenDevice();
// GraphicsConfiguration config = device.getDefaultConfiguration();
// private BufferedImage img = config.createCompatibleImage(320, 240, BufferedImage.TYPE_INT_ARGB);
// private int audioLeft = 0;
// private int audioRight=0;
//
// /** Creates new form Viewer */
// public Viewer() {
// initComponents();
// }
//
// public void setImage(BufferedImage image) {
//
// img=image;
//
// }
//
// public void setAudioLevel(int l, int r){
// audioLeft = l;
// audioRight = r;
// }
// @Override
// public void paintComponent(Graphics g) {
// Graphics2D graph = (Graphics2D) g;
//
// graph.setRenderingHint(java.awt.RenderingHints.KEY_INTERPOLATION,
// java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_RENDERING,
// java.awt.RenderingHints.VALUE_RENDER_SPEED);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING,
// java.awt.RenderingHints.VALUE_ANTIALIAS_OFF);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING,
// java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_FRACTIONALMETRICS,
// java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_COLOR_RENDERING,
// java.awt.RenderingHints.VALUE_COLOR_RENDER_SPEED);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_DITHERING,
// java.awt.RenderingHints.VALUE_DITHER_DISABLE);
//
// int w = this.getWidth();
// int h = this.getHeight();
// graph.setBackground(Color.BLACK);
// graph.clearRect(0, 0, w, h);
// if (img != null) {
// int imgWidth = h * img.getWidth() / img.getHeight();
// int border = (w - imgWidth) / 2;
// graph.drawImage(img, border, 0, imgWidth, h, null);
// } else {
// graph.setColor(Color.WHITE);
// graph.drawString("No Image",10,10);
// }
// if (audioLeft > 0 || audioRight > 0){
// graph.setColor(Color.green);
// graph.fillRect(0, h - audioLeft * h / 128, 10, audioLeft * h / 128);
// graph.fillRect(w-10, h - audioRight * h / 128, 10, audioRight * h / 128);
// }
// }
//
// /** This method is called from within the constructor to
// * initialize the form.
// * WARNING: Do NOT modify this code. The content of this method is
// * always regenerated by the Form Editor.
// */
// @SuppressWarnings("unchecked")
// // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
// private void initComponents() {
//
// setPreferredSize(new java.awt.Dimension(30, 29));
//
// javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
// this.setLayout(layout);
// layout.setHorizontalGroup(
// layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
// .addGap(0, 41, Short.MAX_VALUE)
// );
// layout.setVerticalGroup(
// layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
// .addGap(0, 39, Short.MAX_VALUE)
// );
// }// </editor-fold>//GEN-END:initComponents
// // Variables declaration - do not modify//GEN-BEGIN:variables
// // End of variables declaration//GEN-END:variables
// }
| import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import static java.util.concurrent.Executors.newCachedThreadPool;
import javax.sound.sampled.AudioFormat;
import static javax.sound.sampled.AudioSystem.getSourceDataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import static webcamstudio.WebcamStudio.audioFreq;
import webcamstudio.components.Viewer;
import static webcamstudio.util.Tools.sleep; | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package webcamstudio.mixers;
/**
*
* @author patrick (modified by karl)
*/
public class SystemPlayer implements Runnable {
private static SystemPlayer instance = null;
| // Path: src/webcamstudio/WebcamStudio.java
// public static int audioFreq = 22050;
//
// Path: src/webcamstudio/components/Viewer.java
// public class Viewer extends javax.swing.JPanel {
// GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
// GraphicsDevice device = env.getDefaultScreenDevice();
// GraphicsConfiguration config = device.getDefaultConfiguration();
// private BufferedImage img = config.createCompatibleImage(320, 240, BufferedImage.TYPE_INT_ARGB);
// private int audioLeft = 0;
// private int audioRight=0;
//
// /** Creates new form Viewer */
// public Viewer() {
// initComponents();
// }
//
// public void setImage(BufferedImage image) {
//
// img=image;
//
// }
//
// public void setAudioLevel(int l, int r){
// audioLeft = l;
// audioRight = r;
// }
// @Override
// public void paintComponent(Graphics g) {
// Graphics2D graph = (Graphics2D) g;
//
// graph.setRenderingHint(java.awt.RenderingHints.KEY_INTERPOLATION,
// java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_RENDERING,
// java.awt.RenderingHints.VALUE_RENDER_SPEED);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING,
// java.awt.RenderingHints.VALUE_ANTIALIAS_OFF);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING,
// java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_FRACTIONALMETRICS,
// java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_COLOR_RENDERING,
// java.awt.RenderingHints.VALUE_COLOR_RENDER_SPEED);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_DITHERING,
// java.awt.RenderingHints.VALUE_DITHER_DISABLE);
//
// int w = this.getWidth();
// int h = this.getHeight();
// graph.setBackground(Color.BLACK);
// graph.clearRect(0, 0, w, h);
// if (img != null) {
// int imgWidth = h * img.getWidth() / img.getHeight();
// int border = (w - imgWidth) / 2;
// graph.drawImage(img, border, 0, imgWidth, h, null);
// } else {
// graph.setColor(Color.WHITE);
// graph.drawString("No Image",10,10);
// }
// if (audioLeft > 0 || audioRight > 0){
// graph.setColor(Color.green);
// graph.fillRect(0, h - audioLeft * h / 128, 10, audioLeft * h / 128);
// graph.fillRect(w-10, h - audioRight * h / 128, 10, audioRight * h / 128);
// }
// }
//
// /** This method is called from within the constructor to
// * initialize the form.
// * WARNING: Do NOT modify this code. The content of this method is
// * always regenerated by the Form Editor.
// */
// @SuppressWarnings("unchecked")
// // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
// private void initComponents() {
//
// setPreferredSize(new java.awt.Dimension(30, 29));
//
// javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
// this.setLayout(layout);
// layout.setHorizontalGroup(
// layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
// .addGap(0, 41, Short.MAX_VALUE)
// );
// layout.setVerticalGroup(
// layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
// .addGap(0, 39, Short.MAX_VALUE)
// );
// }// </editor-fold>//GEN-END:initComponents
// // Variables declaration - do not modify//GEN-BEGIN:variables
// // End of variables declaration//GEN-END:variables
// }
// Path: src/webcamstudio/mixers/SystemPlayer.java
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import static java.util.concurrent.Executors.newCachedThreadPool;
import javax.sound.sampled.AudioFormat;
import static javax.sound.sampled.AudioSystem.getSourceDataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import static webcamstudio.WebcamStudio.audioFreq;
import webcamstudio.components.Viewer;
import static webcamstudio.util.Tools.sleep;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package webcamstudio.mixers;
/**
*
* @author patrick (modified by karl)
*/
public class SystemPlayer implements Runnable {
private static SystemPlayer instance = null;
| public static SystemPlayer getInstance(Viewer viewer) { |
WebcamStudio/webcamstudio | src/webcamstudio/mixers/SystemPlayer.java | // Path: src/webcamstudio/WebcamStudio.java
// public static int audioFreq = 22050;
//
// Path: src/webcamstudio/components/Viewer.java
// public class Viewer extends javax.swing.JPanel {
// GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
// GraphicsDevice device = env.getDefaultScreenDevice();
// GraphicsConfiguration config = device.getDefaultConfiguration();
// private BufferedImage img = config.createCompatibleImage(320, 240, BufferedImage.TYPE_INT_ARGB);
// private int audioLeft = 0;
// private int audioRight=0;
//
// /** Creates new form Viewer */
// public Viewer() {
// initComponents();
// }
//
// public void setImage(BufferedImage image) {
//
// img=image;
//
// }
//
// public void setAudioLevel(int l, int r){
// audioLeft = l;
// audioRight = r;
// }
// @Override
// public void paintComponent(Graphics g) {
// Graphics2D graph = (Graphics2D) g;
//
// graph.setRenderingHint(java.awt.RenderingHints.KEY_INTERPOLATION,
// java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_RENDERING,
// java.awt.RenderingHints.VALUE_RENDER_SPEED);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING,
// java.awt.RenderingHints.VALUE_ANTIALIAS_OFF);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING,
// java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_FRACTIONALMETRICS,
// java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_COLOR_RENDERING,
// java.awt.RenderingHints.VALUE_COLOR_RENDER_SPEED);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_DITHERING,
// java.awt.RenderingHints.VALUE_DITHER_DISABLE);
//
// int w = this.getWidth();
// int h = this.getHeight();
// graph.setBackground(Color.BLACK);
// graph.clearRect(0, 0, w, h);
// if (img != null) {
// int imgWidth = h * img.getWidth() / img.getHeight();
// int border = (w - imgWidth) / 2;
// graph.drawImage(img, border, 0, imgWidth, h, null);
// } else {
// graph.setColor(Color.WHITE);
// graph.drawString("No Image",10,10);
// }
// if (audioLeft > 0 || audioRight > 0){
// graph.setColor(Color.green);
// graph.fillRect(0, h - audioLeft * h / 128, 10, audioLeft * h / 128);
// graph.fillRect(w-10, h - audioRight * h / 128, 10, audioRight * h / 128);
// }
// }
//
// /** This method is called from within the constructor to
// * initialize the form.
// * WARNING: Do NOT modify this code. The content of this method is
// * always regenerated by the Form Editor.
// */
// @SuppressWarnings("unchecked")
// // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
// private void initComponents() {
//
// setPreferredSize(new java.awt.Dimension(30, 29));
//
// javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
// this.setLayout(layout);
// layout.setHorizontalGroup(
// layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
// .addGap(0, 41, Short.MAX_VALUE)
// );
// layout.setVerticalGroup(
// layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
// .addGap(0, 39, Short.MAX_VALUE)
// );
// }// </editor-fold>//GEN-END:initComponents
// // Variables declaration - do not modify//GEN-BEGIN:variables
// // End of variables declaration//GEN-END:variables
// }
| import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import static java.util.concurrent.Executors.newCachedThreadPool;
import javax.sound.sampled.AudioFormat;
import static javax.sound.sampled.AudioSystem.getSourceDataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import static webcamstudio.WebcamStudio.audioFreq;
import webcamstudio.components.Viewer;
import static webcamstudio.util.Tools.sleep; | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package webcamstudio.mixers;
/**
*
* @author patrick (modified by karl)
*/
public class SystemPlayer implements Runnable {
private static SystemPlayer instance = null;
public static SystemPlayer getInstance(Viewer viewer) {
if (instance == null) {
instance = new SystemPlayer(viewer);
}
return instance;
}
boolean stopMe = false;
public boolean stopMePub = stopMe;
private SourceDataLine source;
private ExecutorService executor = null;
private final ArrayList<byte[]> buffer = new ArrayList<>();
private FrameBuffer frames = null;
private Viewer viewer = null; | // Path: src/webcamstudio/WebcamStudio.java
// public static int audioFreq = 22050;
//
// Path: src/webcamstudio/components/Viewer.java
// public class Viewer extends javax.swing.JPanel {
// GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
// GraphicsDevice device = env.getDefaultScreenDevice();
// GraphicsConfiguration config = device.getDefaultConfiguration();
// private BufferedImage img = config.createCompatibleImage(320, 240, BufferedImage.TYPE_INT_ARGB);
// private int audioLeft = 0;
// private int audioRight=0;
//
// /** Creates new form Viewer */
// public Viewer() {
// initComponents();
// }
//
// public void setImage(BufferedImage image) {
//
// img=image;
//
// }
//
// public void setAudioLevel(int l, int r){
// audioLeft = l;
// audioRight = r;
// }
// @Override
// public void paintComponent(Graphics g) {
// Graphics2D graph = (Graphics2D) g;
//
// graph.setRenderingHint(java.awt.RenderingHints.KEY_INTERPOLATION,
// java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_RENDERING,
// java.awt.RenderingHints.VALUE_RENDER_SPEED);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING,
// java.awt.RenderingHints.VALUE_ANTIALIAS_OFF);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING,
// java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_FRACTIONALMETRICS,
// java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_COLOR_RENDERING,
// java.awt.RenderingHints.VALUE_COLOR_RENDER_SPEED);
// graph.setRenderingHint(java.awt.RenderingHints.KEY_DITHERING,
// java.awt.RenderingHints.VALUE_DITHER_DISABLE);
//
// int w = this.getWidth();
// int h = this.getHeight();
// graph.setBackground(Color.BLACK);
// graph.clearRect(0, 0, w, h);
// if (img != null) {
// int imgWidth = h * img.getWidth() / img.getHeight();
// int border = (w - imgWidth) / 2;
// graph.drawImage(img, border, 0, imgWidth, h, null);
// } else {
// graph.setColor(Color.WHITE);
// graph.drawString("No Image",10,10);
// }
// if (audioLeft > 0 || audioRight > 0){
// graph.setColor(Color.green);
// graph.fillRect(0, h - audioLeft * h / 128, 10, audioLeft * h / 128);
// graph.fillRect(w-10, h - audioRight * h / 128, 10, audioRight * h / 128);
// }
// }
//
// /** This method is called from within the constructor to
// * initialize the form.
// * WARNING: Do NOT modify this code. The content of this method is
// * always regenerated by the Form Editor.
// */
// @SuppressWarnings("unchecked")
// // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
// private void initComponents() {
//
// setPreferredSize(new java.awt.Dimension(30, 29));
//
// javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
// this.setLayout(layout);
// layout.setHorizontalGroup(
// layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
// .addGap(0, 41, Short.MAX_VALUE)
// );
// layout.setVerticalGroup(
// layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
// .addGap(0, 39, Short.MAX_VALUE)
// );
// }// </editor-fold>//GEN-END:initComponents
// // Variables declaration - do not modify//GEN-BEGIN:variables
// // End of variables declaration//GEN-END:variables
// }
// Path: src/webcamstudio/mixers/SystemPlayer.java
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import static java.util.concurrent.Executors.newCachedThreadPool;
import javax.sound.sampled.AudioFormat;
import static javax.sound.sampled.AudioSystem.getSourceDataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import static webcamstudio.WebcamStudio.audioFreq;
import webcamstudio.components.Viewer;
import static webcamstudio.util.Tools.sleep;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package webcamstudio.mixers;
/**
*
* @author patrick (modified by karl)
*/
public class SystemPlayer implements Runnable {
private static SystemPlayer instance = null;
public static SystemPlayer getInstance(Viewer viewer) {
if (instance == null) {
instance = new SystemPlayer(viewer);
}
return instance;
}
boolean stopMe = false;
public boolean stopMePub = stopMe;
private SourceDataLine source;
private ExecutorService executor = null;
private final ArrayList<byte[]> buffer = new ArrayList<>();
private FrameBuffer frames = null;
private Viewer viewer = null; | private final int aFreq = audioFreq; |
wizzardo/jrtorrent | src/main/java/com/wizzardo/jrt/db/generated/TorrentInfoTable.java | // Path: src/main/java/com/wizzardo/jrt/TorrentInfo.java
// public enum Status {
// SEEDING, FINISHED, DOWNLOADING, STOPPED, PAUSED, CHECKING, UNKNOWN;
//
// public static Status valueOf(boolean complete, boolean isOpen, boolean isHashChecking, boolean state) {
// if (complete && isOpen && !isHashChecking && state) {
// return SEEDING;
// } else if (complete && !isOpen && !isHashChecking && !state) {
// return FINISHED;
// } else if (!complete && isOpen && !isHashChecking && state) {
// return DOWNLOADING;
// } else if (!complete && !isOpen && !isHashChecking && state) {
// // stopped in the middle
// return STOPPED;
// } else if (!complete && !isOpen && !isHashChecking && !state) {
// // i dont know stopped
// return STOPPED;
// } else if (!complete && isOpen && !isHashChecking && !state) {
// return PAUSED;
// } else if (complete && isOpen && !isHashChecking && !state) {
// // seeding pause
// return PAUSED;
// } else if (complete && !isOpen && !isHashChecking && state) {
// return FINISHED;
// } else if (isHashChecking) {
// return CHECKING;
// }
//
// return UNKNOWN;
// }
// }
| import com.wizzardo.tools.sql.query.*;
import java.util.Arrays;
import java.util.List;
import java.util.Collections;
import com.wizzardo.jrt.TorrentInfo.Status; | package com.wizzardo.jrt.db.generated;
public class TorrentInfoTable extends Table {
private TorrentInfoTable(String name, String alias) {
super(name, alias);
}
public TorrentInfoTable as(String alias) {
return new TorrentInfoTable(name, alias);
}
public final static TorrentInfoTable INSTANCE = new TorrentInfoTable("torrent_info", null);
public final Field.LongField ID = new Field.LongField(this, "id");
public final Field.TimestampField DATE_CREATED = new Field.TimestampField(this, "date_created");
public final Field.TimestampField DATE_UPDATED = new Field.TimestampField(this, "date_updated");
public final Field.StringField NAME = new Field.StringField(this, "name");
public final Field.StringField HASH = new Field.StringField(this, "hash");
public final Field.LongField SIZE = new Field.LongField(this, "size");
public final Field.LongField DOWNLOADED = new Field.LongField(this, "downloaded");
public final Field.LongField UPLOADED = new Field.LongField(this, "uploaded"); | // Path: src/main/java/com/wizzardo/jrt/TorrentInfo.java
// public enum Status {
// SEEDING, FINISHED, DOWNLOADING, STOPPED, PAUSED, CHECKING, UNKNOWN;
//
// public static Status valueOf(boolean complete, boolean isOpen, boolean isHashChecking, boolean state) {
// if (complete && isOpen && !isHashChecking && state) {
// return SEEDING;
// } else if (complete && !isOpen && !isHashChecking && !state) {
// return FINISHED;
// } else if (!complete && isOpen && !isHashChecking && state) {
// return DOWNLOADING;
// } else if (!complete && !isOpen && !isHashChecking && state) {
// // stopped in the middle
// return STOPPED;
// } else if (!complete && !isOpen && !isHashChecking && !state) {
// // i dont know stopped
// return STOPPED;
// } else if (!complete && isOpen && !isHashChecking && !state) {
// return PAUSED;
// } else if (complete && isOpen && !isHashChecking && !state) {
// // seeding pause
// return PAUSED;
// } else if (complete && !isOpen && !isHashChecking && state) {
// return FINISHED;
// } else if (isHashChecking) {
// return CHECKING;
// }
//
// return UNKNOWN;
// }
// }
// Path: src/main/java/com/wizzardo/jrt/db/generated/TorrentInfoTable.java
import com.wizzardo.tools.sql.query.*;
import java.util.Arrays;
import java.util.List;
import java.util.Collections;
import com.wizzardo.jrt.TorrentInfo.Status;
package com.wizzardo.jrt.db.generated;
public class TorrentInfoTable extends Table {
private TorrentInfoTable(String name, String alias) {
super(name, alias);
}
public TorrentInfoTable as(String alias) {
return new TorrentInfoTable(name, alias);
}
public final static TorrentInfoTable INSTANCE = new TorrentInfoTable("torrent_info", null);
public final Field.LongField ID = new Field.LongField(this, "id");
public final Field.TimestampField DATE_CREATED = new Field.TimestampField(this, "date_created");
public final Field.TimestampField DATE_UPDATED = new Field.TimestampField(this, "date_updated");
public final Field.StringField NAME = new Field.StringField(this, "name");
public final Field.StringField HASH = new Field.StringField(this, "hash");
public final Field.LongField SIZE = new Field.LongField(this, "size");
public final Field.LongField DOWNLOADED = new Field.LongField(this, "downloaded");
public final Field.LongField UPLOADED = new Field.LongField(this, "uploaded"); | public final Field.EnumField<Status> STATUS = new Field.EnumField<Status>(this, "status"); |
wizzardo/jrtorrent | src/main/java/com/wizzardo/jrt/bt/PrioritizedSequentialPieceSelector.java | // Path: src/main/java/com/wizzardo/jrt/FilePriority.java
// public enum FilePriority {
// OFF(0), NORMAL(1), HIGH(2);
//
// final String s;
// public final int value;
//
// FilePriority(int value) {
// this.s = String.valueOf(value);
// this.value = value;
// }
//
// public static FilePriority byInt(int i) {
// if (i == 0)
// return OFF;
// if (i == 1)
// return NORMAL;
// if (i == 2)
// return HIGH;
//
// throw new IllegalArgumentException("Argument is not in a valid range (0-2)");
// }
//
// public static FilePriority byString(String s) {
// if ("0".equals(s))
// return OFF;
// if ("1".equals(s))
// return NORMAL;
// if ("2".equals(s))
// return HIGH;
//
// throw new IllegalArgumentException("Argument is not in a valid range (0-2)");
// }
// }
| import bt.data.*;
import bt.metainfo.Torrent;
import bt.metainfo.TorrentFile;
import bt.torrent.PieceStatistics;
import bt.torrent.selector.BaseStreamSelector;
import com.wizzardo.jrt.FilePriority;
import java.util.*;
import java.util.stream.Collectors; | package com.wizzardo.jrt.bt;
public class PrioritizedSequentialPieceSelector extends BaseStreamSelector {
final Storage storage;
volatile List<TorrentFileWithPieces> filesWithPieces;
public PrioritizedSequentialPieceSelector(Storage storage) {
this.storage = storage;
}
protected PrimitiveIterator.OfInt createIterator(final PieceStatistics pieceStatistics) {
List<TorrentFileWithPieces> files = this.filesWithPieces;
return new PrimitiveIterator.OfInt() {
int piece = 0;
int fileIndex = 0;
int pieceIndex = 0;
public int nextInt() {
return piece;
}
public boolean hasNext() {
while (true) {
TorrentFileWithPieces f;
do {
if (fileIndex >= files.size())
return false;
f = files.get(fileIndex);
if (pieceIndex >= f.pieces.length) {
pieceIndex = 0;
fileIndex++;
} else {
break;
}
} while (true); | // Path: src/main/java/com/wizzardo/jrt/FilePriority.java
// public enum FilePriority {
// OFF(0), NORMAL(1), HIGH(2);
//
// final String s;
// public final int value;
//
// FilePriority(int value) {
// this.s = String.valueOf(value);
// this.value = value;
// }
//
// public static FilePriority byInt(int i) {
// if (i == 0)
// return OFF;
// if (i == 1)
// return NORMAL;
// if (i == 2)
// return HIGH;
//
// throw new IllegalArgumentException("Argument is not in a valid range (0-2)");
// }
//
// public static FilePriority byString(String s) {
// if ("0".equals(s))
// return OFF;
// if ("1".equals(s))
// return NORMAL;
// if ("2".equals(s))
// return HIGH;
//
// throw new IllegalArgumentException("Argument is not in a valid range (0-2)");
// }
// }
// Path: src/main/java/com/wizzardo/jrt/bt/PrioritizedSequentialPieceSelector.java
import bt.data.*;
import bt.metainfo.Torrent;
import bt.metainfo.TorrentFile;
import bt.torrent.PieceStatistics;
import bt.torrent.selector.BaseStreamSelector;
import com.wizzardo.jrt.FilePriority;
import java.util.*;
import java.util.stream.Collectors;
package com.wizzardo.jrt.bt;
public class PrioritizedSequentialPieceSelector extends BaseStreamSelector {
final Storage storage;
volatile List<TorrentFileWithPieces> filesWithPieces;
public PrioritizedSequentialPieceSelector(Storage storage) {
this.storage = storage;
}
protected PrimitiveIterator.OfInt createIterator(final PieceStatistics pieceStatistics) {
List<TorrentFileWithPieces> files = this.filesWithPieces;
return new PrimitiveIterator.OfInt() {
int piece = 0;
int fileIndex = 0;
int pieceIndex = 0;
public int nextInt() {
return piece;
}
public boolean hasNext() {
while (true) {
TorrentFileWithPieces f;
do {
if (fileIndex >= files.size())
return false;
f = files.get(fileIndex);
if (pieceIndex >= f.pieces.length) {
pieceIndex = 0;
fileIndex++;
} else {
break;
}
} while (true); | if (f.priority == FilePriority.OFF) |
wizzardo/jrtorrent | src/main/java/com/wizzardo/jrt/db/model/TorrentEntryPriority.java | // Path: src/main/java/com/wizzardo/jrt/FilePriority.java
// public enum FilePriority {
// OFF(0), NORMAL(1), HIGH(2);
//
// final String s;
// public final int value;
//
// FilePriority(int value) {
// this.s = String.valueOf(value);
// this.value = value;
// }
//
// public static FilePriority byInt(int i) {
// if (i == 0)
// return OFF;
// if (i == 1)
// return NORMAL;
// if (i == 2)
// return HIGH;
//
// throw new IllegalArgumentException("Argument is not in a valid range (0-2)");
// }
//
// public static FilePriority byString(String s) {
// if ("0".equals(s))
// return OFF;
// if ("1".equals(s))
// return NORMAL;
// if ("2".equals(s))
// return HIGH;
//
// throw new IllegalArgumentException("Argument is not in a valid range (0-2)");
// }
// }
| import com.wizzardo.jrt.FilePriority;
import java.sql.Timestamp; | package com.wizzardo.jrt.db.model;
public class TorrentEntryPriority {
public long id;
public Timestamp dateCreated;
public Timestamp dateUpdated;
public long torrentInfoId;
public String path; | // Path: src/main/java/com/wizzardo/jrt/FilePriority.java
// public enum FilePriority {
// OFF(0), NORMAL(1), HIGH(2);
//
// final String s;
// public final int value;
//
// FilePriority(int value) {
// this.s = String.valueOf(value);
// this.value = value;
// }
//
// public static FilePriority byInt(int i) {
// if (i == 0)
// return OFF;
// if (i == 1)
// return NORMAL;
// if (i == 2)
// return HIGH;
//
// throw new IllegalArgumentException("Argument is not in a valid range (0-2)");
// }
//
// public static FilePriority byString(String s) {
// if ("0".equals(s))
// return OFF;
// if ("1".equals(s))
// return NORMAL;
// if ("2".equals(s))
// return HIGH;
//
// throw new IllegalArgumentException("Argument is not in a valid range (0-2)");
// }
// }
// Path: src/main/java/com/wizzardo/jrt/db/model/TorrentEntryPriority.java
import com.wizzardo.jrt.FilePriority;
import java.sql.Timestamp;
package com.wizzardo.jrt.db.model;
public class TorrentEntryPriority {
public long id;
public Timestamp dateCreated;
public Timestamp dateUpdated;
public long torrentInfoId;
public String path; | public FilePriority priority; |
wizzardo/jrtorrent | src/main/java/com/wizzardo/jrt/db/generated/TorrentEntryPriorityTable.java | // Path: src/main/java/com/wizzardo/jrt/FilePriority.java
// public enum FilePriority {
// OFF(0), NORMAL(1), HIGH(2);
//
// final String s;
// public final int value;
//
// FilePriority(int value) {
// this.s = String.valueOf(value);
// this.value = value;
// }
//
// public static FilePriority byInt(int i) {
// if (i == 0)
// return OFF;
// if (i == 1)
// return NORMAL;
// if (i == 2)
// return HIGH;
//
// throw new IllegalArgumentException("Argument is not in a valid range (0-2)");
// }
//
// public static FilePriority byString(String s) {
// if ("0".equals(s))
// return OFF;
// if ("1".equals(s))
// return NORMAL;
// if ("2".equals(s))
// return HIGH;
//
// throw new IllegalArgumentException("Argument is not in a valid range (0-2)");
// }
// }
| import com.wizzardo.tools.sql.query.*;
import java.util.Arrays;
import java.util.List;
import java.util.Collections;
import com.wizzardo.jrt.FilePriority; | package com.wizzardo.jrt.db.generated;
public class TorrentEntryPriorityTable extends Table {
private TorrentEntryPriorityTable(String name, String alias) {
super(name, alias);
}
public TorrentEntryPriorityTable as(String alias) {
return new TorrentEntryPriorityTable(name, alias);
}
public final static TorrentEntryPriorityTable INSTANCE = new TorrentEntryPriorityTable("torrent_entry_priority", null);
public final Field.LongField ID = new Field.LongField(this, "id");
public final Field.TimestampField DATE_CREATED = new Field.TimestampField(this, "date_created");
public final Field.TimestampField DATE_UPDATED = new Field.TimestampField(this, "date_updated");
public final Field.LongField TORRENT_INFO_ID = new Field.LongField(this, "torrent_info_id");
public final Field.StringField PATH = new Field.StringField(this, "path"); | // Path: src/main/java/com/wizzardo/jrt/FilePriority.java
// public enum FilePriority {
// OFF(0), NORMAL(1), HIGH(2);
//
// final String s;
// public final int value;
//
// FilePriority(int value) {
// this.s = String.valueOf(value);
// this.value = value;
// }
//
// public static FilePriority byInt(int i) {
// if (i == 0)
// return OFF;
// if (i == 1)
// return NORMAL;
// if (i == 2)
// return HIGH;
//
// throw new IllegalArgumentException("Argument is not in a valid range (0-2)");
// }
//
// public static FilePriority byString(String s) {
// if ("0".equals(s))
// return OFF;
// if ("1".equals(s))
// return NORMAL;
// if ("2".equals(s))
// return HIGH;
//
// throw new IllegalArgumentException("Argument is not in a valid range (0-2)");
// }
// }
// Path: src/main/java/com/wizzardo/jrt/db/generated/TorrentEntryPriorityTable.java
import com.wizzardo.tools.sql.query.*;
import java.util.Arrays;
import java.util.List;
import java.util.Collections;
import com.wizzardo.jrt.FilePriority;
package com.wizzardo.jrt.db.generated;
public class TorrentEntryPriorityTable extends Table {
private TorrentEntryPriorityTable(String name, String alias) {
super(name, alias);
}
public TorrentEntryPriorityTable as(String alias) {
return new TorrentEntryPriorityTable(name, alias);
}
public final static TorrentEntryPriorityTable INSTANCE = new TorrentEntryPriorityTable("torrent_entry_priority", null);
public final Field.LongField ID = new Field.LongField(this, "id");
public final Field.TimestampField DATE_CREATED = new Field.TimestampField(this, "date_created");
public final Field.TimestampField DATE_UPDATED = new Field.TimestampField(this, "date_updated");
public final Field.LongField TORRENT_INFO_ID = new Field.LongField(this, "torrent_info_id");
public final Field.StringField PATH = new Field.StringField(this, "path"); | public final Field.EnumField<FilePriority> PRIORITY = new Field.EnumField<FilePriority>(this, "priority"); |
tgobbens/fluffybalance | core/src/com/balanceball/system/PhysicsSystem.java | // Path: core/src/com/balanceball/component/GravityComponent.java
// public class GravityComponent implements Component {
// public Vector2 normalisedGravity = new Vector2();
// }
//
// Path: core/src/com/balanceball/enity/GravityEntity.java
// public class GravityEntity extends Entity {
//
// public GravityEntity() {
// addComponent(new GravityComponent());
// }
// }
//
// Path: core/src/com/balanceball/component/PhysicsComponent.java
// public class PhysicsComponent implements Component {
// public Body body;
// }
//
// Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
| import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Box2D;
import com.badlogic.gdx.physics.box2d.Contact;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.Manifold;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.GravityComponent;
import com.balanceball.enity.GravityEntity;
import com.balanceball.component.PhysicsComponent;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.sec.Entity;
import com.sec.System; | package com.balanceball.system;
/**
* Created by tijs on 14/07/2017.
*/
public class PhysicsSystem extends System {
public interface BallPointContactListener {
void onPointContact(int type);
}
public final static int BODY_USER_DATA_TYPE_BALL = 0;
public final static int BODY_USER_DATA_TYPE_POINT_LEFT = 1;
public final static int BODY_USER_DATA_TYPE_POINT_RIGHT = 2;
public final static int BODY_USER_DATA_TYPE_OTHER = 3;
public static class BodyUserDate {
public BodyUserDate(int type) {
this.type = type;
}
int type = BODY_USER_DATA_TYPE_OTHER;
}
private final float BASE_GRAVITY = 150.f;
private float mAccumulator = 0.f;
private World mWorld;
private boolean mIsPaused = false;
private BallPointContactListener mBallPointContactListener = null;
public PhysicsSystem(BallPointContactListener ballPointContactListener) { | // Path: core/src/com/balanceball/component/GravityComponent.java
// public class GravityComponent implements Component {
// public Vector2 normalisedGravity = new Vector2();
// }
//
// Path: core/src/com/balanceball/enity/GravityEntity.java
// public class GravityEntity extends Entity {
//
// public GravityEntity() {
// addComponent(new GravityComponent());
// }
// }
//
// Path: core/src/com/balanceball/component/PhysicsComponent.java
// public class PhysicsComponent implements Component {
// public Body body;
// }
//
// Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
// Path: core/src/com/balanceball/system/PhysicsSystem.java
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Box2D;
import com.badlogic.gdx.physics.box2d.Contact;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.Manifold;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.GravityComponent;
import com.balanceball.enity.GravityEntity;
import com.balanceball.component.PhysicsComponent;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.sec.Entity;
import com.sec.System;
package com.balanceball.system;
/**
* Created by tijs on 14/07/2017.
*/
public class PhysicsSystem extends System {
public interface BallPointContactListener {
void onPointContact(int type);
}
public final static int BODY_USER_DATA_TYPE_BALL = 0;
public final static int BODY_USER_DATA_TYPE_POINT_LEFT = 1;
public final static int BODY_USER_DATA_TYPE_POINT_RIGHT = 2;
public final static int BODY_USER_DATA_TYPE_OTHER = 3;
public static class BodyUserDate {
public BodyUserDate(int type) {
this.type = type;
}
int type = BODY_USER_DATA_TYPE_OTHER;
}
private final float BASE_GRAVITY = 150.f;
private float mAccumulator = 0.f;
private World mWorld;
private boolean mIsPaused = false;
private BallPointContactListener mBallPointContactListener = null;
public PhysicsSystem(BallPointContactListener ballPointContactListener) { | addComponentType(PhysicsComponent.class); |
tgobbens/fluffybalance | core/src/com/balanceball/system/PhysicsSystem.java | // Path: core/src/com/balanceball/component/GravityComponent.java
// public class GravityComponent implements Component {
// public Vector2 normalisedGravity = new Vector2();
// }
//
// Path: core/src/com/balanceball/enity/GravityEntity.java
// public class GravityEntity extends Entity {
//
// public GravityEntity() {
// addComponent(new GravityComponent());
// }
// }
//
// Path: core/src/com/balanceball/component/PhysicsComponent.java
// public class PhysicsComponent implements Component {
// public Body body;
// }
//
// Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
| import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Box2D;
import com.badlogic.gdx.physics.box2d.Contact;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.Manifold;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.GravityComponent;
import com.balanceball.enity.GravityEntity;
import com.balanceball.component.PhysicsComponent;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.sec.Entity;
import com.sec.System; | if ((userDateA.type == BODY_USER_DATA_TYPE_POINT_LEFT && userDateB.type == BODY_USER_DATA_TYPE_BALL) ||
(userDateA.type == BODY_USER_DATA_TYPE_BALL && userDateB.type == BODY_USER_DATA_TYPE_POINT_LEFT)) {
// touched left ball
mBallPointContactListener.onPointContact(BODY_USER_DATA_TYPE_POINT_LEFT);
} else if ((userDateA.type == BODY_USER_DATA_TYPE_POINT_RIGHT && userDateB.type == BODY_USER_DATA_TYPE_BALL) ||
(userDateA.type == BODY_USER_DATA_TYPE_BALL && userDateB.type == BODY_USER_DATA_TYPE_POINT_RIGHT)) {
// touched right ball
mBallPointContactListener.onPointContact(BODY_USER_DATA_TYPE_POINT_RIGHT);
}
}
}
@Override
public void endContact(Contact contact) {
}
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
}
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
}
});
}
| // Path: core/src/com/balanceball/component/GravityComponent.java
// public class GravityComponent implements Component {
// public Vector2 normalisedGravity = new Vector2();
// }
//
// Path: core/src/com/balanceball/enity/GravityEntity.java
// public class GravityEntity extends Entity {
//
// public GravityEntity() {
// addComponent(new GravityComponent());
// }
// }
//
// Path: core/src/com/balanceball/component/PhysicsComponent.java
// public class PhysicsComponent implements Component {
// public Body body;
// }
//
// Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
// Path: core/src/com/balanceball/system/PhysicsSystem.java
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Box2D;
import com.badlogic.gdx.physics.box2d.Contact;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.Manifold;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.GravityComponent;
import com.balanceball.enity.GravityEntity;
import com.balanceball.component.PhysicsComponent;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.sec.Entity;
import com.sec.System;
if ((userDateA.type == BODY_USER_DATA_TYPE_POINT_LEFT && userDateB.type == BODY_USER_DATA_TYPE_BALL) ||
(userDateA.type == BODY_USER_DATA_TYPE_BALL && userDateB.type == BODY_USER_DATA_TYPE_POINT_LEFT)) {
// touched left ball
mBallPointContactListener.onPointContact(BODY_USER_DATA_TYPE_POINT_LEFT);
} else if ((userDateA.type == BODY_USER_DATA_TYPE_POINT_RIGHT && userDateB.type == BODY_USER_DATA_TYPE_BALL) ||
(userDateA.type == BODY_USER_DATA_TYPE_BALL && userDateB.type == BODY_USER_DATA_TYPE_POINT_RIGHT)) {
// touched right ball
mBallPointContactListener.onPointContact(BODY_USER_DATA_TYPE_POINT_RIGHT);
}
}
}
@Override
public void endContact(Contact contact) {
}
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
}
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
}
});
}
| public void updateFromEntities(Array<Entity> entities) { |
tgobbens/fluffybalance | core/src/com/balanceball/system/PhysicsSystem.java | // Path: core/src/com/balanceball/component/GravityComponent.java
// public class GravityComponent implements Component {
// public Vector2 normalisedGravity = new Vector2();
// }
//
// Path: core/src/com/balanceball/enity/GravityEntity.java
// public class GravityEntity extends Entity {
//
// public GravityEntity() {
// addComponent(new GravityComponent());
// }
// }
//
// Path: core/src/com/balanceball/component/PhysicsComponent.java
// public class PhysicsComponent implements Component {
// public Body body;
// }
//
// Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
| import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Box2D;
import com.badlogic.gdx.physics.box2d.Contact;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.Manifold;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.GravityComponent;
import com.balanceball.enity.GravityEntity;
import com.balanceball.component.PhysicsComponent;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.sec.Entity;
import com.sec.System; | (userDateA.type == BODY_USER_DATA_TYPE_BALL && userDateB.type == BODY_USER_DATA_TYPE_POINT_RIGHT)) {
// touched right ball
mBallPointContactListener.onPointContact(BODY_USER_DATA_TYPE_POINT_RIGHT);
}
}
}
@Override
public void endContact(Contact contact) {
}
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
}
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
}
});
}
public void updateFromEntities(Array<Entity> entities) {
// if the game is not running don't update the physics
if (mIsPaused) {
return;
}
| // Path: core/src/com/balanceball/component/GravityComponent.java
// public class GravityComponent implements Component {
// public Vector2 normalisedGravity = new Vector2();
// }
//
// Path: core/src/com/balanceball/enity/GravityEntity.java
// public class GravityEntity extends Entity {
//
// public GravityEntity() {
// addComponent(new GravityComponent());
// }
// }
//
// Path: core/src/com/balanceball/component/PhysicsComponent.java
// public class PhysicsComponent implements Component {
// public Body body;
// }
//
// Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
// Path: core/src/com/balanceball/system/PhysicsSystem.java
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Box2D;
import com.badlogic.gdx.physics.box2d.Contact;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.Manifold;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.GravityComponent;
import com.balanceball.enity.GravityEntity;
import com.balanceball.component.PhysicsComponent;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.sec.Entity;
import com.sec.System;
(userDateA.type == BODY_USER_DATA_TYPE_BALL && userDateB.type == BODY_USER_DATA_TYPE_POINT_RIGHT)) {
// touched right ball
mBallPointContactListener.onPointContact(BODY_USER_DATA_TYPE_POINT_RIGHT);
}
}
}
@Override
public void endContact(Contact contact) {
}
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
}
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
}
});
}
public void updateFromEntities(Array<Entity> entities) {
// if the game is not running don't update the physics
if (mIsPaused) {
return;
}
| GravityComponent gravityComponent = mEngine.getComponentFromFirstEntity( |
tgobbens/fluffybalance | core/src/com/balanceball/system/PhysicsSystem.java | // Path: core/src/com/balanceball/component/GravityComponent.java
// public class GravityComponent implements Component {
// public Vector2 normalisedGravity = new Vector2();
// }
//
// Path: core/src/com/balanceball/enity/GravityEntity.java
// public class GravityEntity extends Entity {
//
// public GravityEntity() {
// addComponent(new GravityComponent());
// }
// }
//
// Path: core/src/com/balanceball/component/PhysicsComponent.java
// public class PhysicsComponent implements Component {
// public Body body;
// }
//
// Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
| import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Box2D;
import com.badlogic.gdx.physics.box2d.Contact;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.Manifold;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.GravityComponent;
import com.balanceball.enity.GravityEntity;
import com.balanceball.component.PhysicsComponent;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.sec.Entity;
import com.sec.System; | // touched right ball
mBallPointContactListener.onPointContact(BODY_USER_DATA_TYPE_POINT_RIGHT);
}
}
}
@Override
public void endContact(Contact contact) {
}
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
}
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
}
});
}
public void updateFromEntities(Array<Entity> entities) {
// if the game is not running don't update the physics
if (mIsPaused) {
return;
}
GravityComponent gravityComponent = mEngine.getComponentFromFirstEntity( | // Path: core/src/com/balanceball/component/GravityComponent.java
// public class GravityComponent implements Component {
// public Vector2 normalisedGravity = new Vector2();
// }
//
// Path: core/src/com/balanceball/enity/GravityEntity.java
// public class GravityEntity extends Entity {
//
// public GravityEntity() {
// addComponent(new GravityComponent());
// }
// }
//
// Path: core/src/com/balanceball/component/PhysicsComponent.java
// public class PhysicsComponent implements Component {
// public Body body;
// }
//
// Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
// Path: core/src/com/balanceball/system/PhysicsSystem.java
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Box2D;
import com.badlogic.gdx.physics.box2d.Contact;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.Manifold;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.GravityComponent;
import com.balanceball.enity.GravityEntity;
import com.balanceball.component.PhysicsComponent;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.sec.Entity;
import com.sec.System;
// touched right ball
mBallPointContactListener.onPointContact(BODY_USER_DATA_TYPE_POINT_RIGHT);
}
}
}
@Override
public void endContact(Contact contact) {
}
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
}
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
}
});
}
public void updateFromEntities(Array<Entity> entities) {
// if the game is not running don't update the physics
if (mIsPaused) {
return;
}
GravityComponent gravityComponent = mEngine.getComponentFromFirstEntity( | GravityEntity.class, GravityComponent.class); |
tgobbens/fluffybalance | core/src/com/balanceball/system/PhysicsSystem.java | // Path: core/src/com/balanceball/component/GravityComponent.java
// public class GravityComponent implements Component {
// public Vector2 normalisedGravity = new Vector2();
// }
//
// Path: core/src/com/balanceball/enity/GravityEntity.java
// public class GravityEntity extends Entity {
//
// public GravityEntity() {
// addComponent(new GravityComponent());
// }
// }
//
// Path: core/src/com/balanceball/component/PhysicsComponent.java
// public class PhysicsComponent implements Component {
// public Body body;
// }
//
// Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
| import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Box2D;
import com.badlogic.gdx.physics.box2d.Contact;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.Manifold;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.GravityComponent;
import com.balanceball.enity.GravityEntity;
import com.balanceball.component.PhysicsComponent;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.sec.Entity;
import com.sec.System; | }
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
}
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
}
});
}
public void updateFromEntities(Array<Entity> entities) {
// if the game is not running don't update the physics
if (mIsPaused) {
return;
}
GravityComponent gravityComponent = mEngine.getComponentFromFirstEntity(
GravityEntity.class, GravityComponent.class);
if (gravityComponent != null) {
Vector2 gravity = new Vector2(gravityComponent.normalisedGravity);
mWorld.setGravity(gravity.scl(BASE_GRAVITY));
}
// update object position
for (Entity entity : entities) {
PhysicsComponent physicsComp = entity.getComponentByType(PhysicsComponent.class); | // Path: core/src/com/balanceball/component/GravityComponent.java
// public class GravityComponent implements Component {
// public Vector2 normalisedGravity = new Vector2();
// }
//
// Path: core/src/com/balanceball/enity/GravityEntity.java
// public class GravityEntity extends Entity {
//
// public GravityEntity() {
// addComponent(new GravityComponent());
// }
// }
//
// Path: core/src/com/balanceball/component/PhysicsComponent.java
// public class PhysicsComponent implements Component {
// public Body body;
// }
//
// Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
// Path: core/src/com/balanceball/system/PhysicsSystem.java
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Box2D;
import com.badlogic.gdx.physics.box2d.Contact;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.Manifold;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.GravityComponent;
import com.balanceball.enity.GravityEntity;
import com.balanceball.component.PhysicsComponent;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.sec.Entity;
import com.sec.System;
}
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
}
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
}
});
}
public void updateFromEntities(Array<Entity> entities) {
// if the game is not running don't update the physics
if (mIsPaused) {
return;
}
GravityComponent gravityComponent = mEngine.getComponentFromFirstEntity(
GravityEntity.class, GravityComponent.class);
if (gravityComponent != null) {
Vector2 gravity = new Vector2(gravityComponent.normalisedGravity);
mWorld.setGravity(gravity.scl(BASE_GRAVITY));
}
// update object position
for (Entity entity : entities) {
PhysicsComponent physicsComp = entity.getComponentByType(PhysicsComponent.class); | PositionComponent positionComp = entity.getComponentByType(PositionComponent.class); |
tgobbens/fluffybalance | core/src/com/balanceball/system/PhysicsSystem.java | // Path: core/src/com/balanceball/component/GravityComponent.java
// public class GravityComponent implements Component {
// public Vector2 normalisedGravity = new Vector2();
// }
//
// Path: core/src/com/balanceball/enity/GravityEntity.java
// public class GravityEntity extends Entity {
//
// public GravityEntity() {
// addComponent(new GravityComponent());
// }
// }
//
// Path: core/src/com/balanceball/component/PhysicsComponent.java
// public class PhysicsComponent implements Component {
// public Body body;
// }
//
// Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
| import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Box2D;
import com.badlogic.gdx.physics.box2d.Contact;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.Manifold;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.GravityComponent;
import com.balanceball.enity.GravityEntity;
import com.balanceball.component.PhysicsComponent;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.sec.Entity;
import com.sec.System; |
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
}
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
}
});
}
public void updateFromEntities(Array<Entity> entities) {
// if the game is not running don't update the physics
if (mIsPaused) {
return;
}
GravityComponent gravityComponent = mEngine.getComponentFromFirstEntity(
GravityEntity.class, GravityComponent.class);
if (gravityComponent != null) {
Vector2 gravity = new Vector2(gravityComponent.normalisedGravity);
mWorld.setGravity(gravity.scl(BASE_GRAVITY));
}
// update object position
for (Entity entity : entities) {
PhysicsComponent physicsComp = entity.getComponentByType(PhysicsComponent.class);
PositionComponent positionComp = entity.getComponentByType(PositionComponent.class); | // Path: core/src/com/balanceball/component/GravityComponent.java
// public class GravityComponent implements Component {
// public Vector2 normalisedGravity = new Vector2();
// }
//
// Path: core/src/com/balanceball/enity/GravityEntity.java
// public class GravityEntity extends Entity {
//
// public GravityEntity() {
// addComponent(new GravityComponent());
// }
// }
//
// Path: core/src/com/balanceball/component/PhysicsComponent.java
// public class PhysicsComponent implements Component {
// public Body body;
// }
//
// Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
// Path: core/src/com/balanceball/system/PhysicsSystem.java
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Box2D;
import com.badlogic.gdx.physics.box2d.Contact;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.Manifold;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.GravityComponent;
import com.balanceball.enity.GravityEntity;
import com.balanceball.component.PhysicsComponent;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.sec.Entity;
import com.sec.System;
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
}
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
}
});
}
public void updateFromEntities(Array<Entity> entities) {
// if the game is not running don't update the physics
if (mIsPaused) {
return;
}
GravityComponent gravityComponent = mEngine.getComponentFromFirstEntity(
GravityEntity.class, GravityComponent.class);
if (gravityComponent != null) {
Vector2 gravity = new Vector2(gravityComponent.normalisedGravity);
mWorld.setGravity(gravity.scl(BASE_GRAVITY));
}
// update object position
for (Entity entity : entities) {
PhysicsComponent physicsComp = entity.getComponentByType(PhysicsComponent.class);
PositionComponent positionComp = entity.getComponentByType(PositionComponent.class); | RotationComponent rotationComp = entity.getComponentByType(RotationComponent.class); |
tgobbens/fluffybalance | core/src/com/balanceball/enity/GravityEntity.java | // Path: core/src/com/balanceball/component/GravityComponent.java
// public class GravityComponent implements Component {
// public Vector2 normalisedGravity = new Vector2();
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
| import com.balanceball.component.GravityComponent;
import com.sec.Entity; | package com.balanceball.enity;
/**
* Created by tijs on 16/07/2017.
*/
public class GravityEntity extends Entity {
public GravityEntity() { | // Path: core/src/com/balanceball/component/GravityComponent.java
// public class GravityComponent implements Component {
// public Vector2 normalisedGravity = new Vector2();
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
// Path: core/src/com/balanceball/enity/GravityEntity.java
import com.balanceball.component.GravityComponent;
import com.sec.Entity;
package com.balanceball.enity;
/**
* Created by tijs on 16/07/2017.
*/
public class GravityEntity extends Entity {
public GravityEntity() { | addComponent(new GravityComponent()); |
tgobbens/fluffybalance | core/src/com/balanceball/enity/RollInputEntity.java | // Path: core/src/com/balanceball/component/GravityComponent.java
// public class GravityComponent implements Component {
// public Vector2 normalisedGravity = new Vector2();
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
| import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.FloatArray;
import com.balanceball.component.GravityComponent;
import com.sec.Entity; | package com.balanceball.enity;
/**
* Created by tijs on 15/07/2017.
*/
public class RollInputEntity extends Entity {
// SMOOTH THE INPUT SAMPLING, HIGHER VALUE LESS RESPONSIVE GAME SO HARDER
private static final int INPUT_SAMPLE_SIZE = 50;
private FloatArray mInputRollList;
private float mInputRollAverage;
private int mInsertIndex;
public RollInputEntity() {
mInputRollList = new FloatArray(INPUT_SAMPLE_SIZE);
mInputRollAverage = 0.f;
mInsertIndex = 0;
}
public void update() {
// prevent user from manipulating input to much
addValue(MathUtils.clamp(Gdx.input.getRoll(), -25.f, 25.f));
// normalised normalisedGravity
Vector2 gravity = new Vector2(0, -1).rotate(mInputRollAverage).nor();
// find the gravity entity | // Path: core/src/com/balanceball/component/GravityComponent.java
// public class GravityComponent implements Component {
// public Vector2 normalisedGravity = new Vector2();
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
// Path: core/src/com/balanceball/enity/RollInputEntity.java
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.FloatArray;
import com.balanceball.component.GravityComponent;
import com.sec.Entity;
package com.balanceball.enity;
/**
* Created by tijs on 15/07/2017.
*/
public class RollInputEntity extends Entity {
// SMOOTH THE INPUT SAMPLING, HIGHER VALUE LESS RESPONSIVE GAME SO HARDER
private static final int INPUT_SAMPLE_SIZE = 50;
private FloatArray mInputRollList;
private float mInputRollAverage;
private int mInsertIndex;
public RollInputEntity() {
mInputRollList = new FloatArray(INPUT_SAMPLE_SIZE);
mInputRollAverage = 0.f;
mInsertIndex = 0;
}
public void update() {
// prevent user from manipulating input to much
addValue(MathUtils.clamp(Gdx.input.getRoll(), -25.f, 25.f));
// normalised normalisedGravity
Vector2 gravity = new Vector2(0, -1).rotate(mInputRollAverage).nor();
// find the gravity entity | GravityComponent gravityComponent = mEngine.getComponentFromFirstEntity( |
tgobbens/fluffybalance | core/src/com/balanceball/system/GuiRendererSystem.java | // Path: core/src/com/balanceball/component/GuiComponent.java
// public class GuiComponent implements Component {
// public Stage stage = null;
// }
//
// Path: core/src/com/balanceball/component/VisibleComponent.java
// public class VisibleComponent implements Component {
// public boolean visible = true;
// }
//
// Path: core/src/com/sec/Component.java
// public interface Component {
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
| import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.GuiComponent;
import com.balanceball.component.VisibleComponent;
import com.sec.Component;
import com.sec.Entity;
import com.sec.System; | package com.balanceball.system;
/**
* Created by tijs on 18/07/2017.
*/
public class GuiRendererSystem extends System {
private Class<? extends Entity> mActiveGui;
@Override
public void resume() { | // Path: core/src/com/balanceball/component/GuiComponent.java
// public class GuiComponent implements Component {
// public Stage stage = null;
// }
//
// Path: core/src/com/balanceball/component/VisibleComponent.java
// public class VisibleComponent implements Component {
// public boolean visible = true;
// }
//
// Path: core/src/com/sec/Component.java
// public interface Component {
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
// Path: core/src/com/balanceball/system/GuiRendererSystem.java
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.GuiComponent;
import com.balanceball.component.VisibleComponent;
import com.sec.Component;
import com.sec.Entity;
import com.sec.System;
package com.balanceball.system;
/**
* Created by tijs on 18/07/2017.
*/
public class GuiRendererSystem extends System {
private Class<? extends Entity> mActiveGui;
@Override
public void resume() { | Array<Entity> entities = mEngine.getAllEntitiesWithComponentOfType(GuiComponent.class); |
tgobbens/fluffybalance | core/src/com/balanceball/system/GuiRendererSystem.java | // Path: core/src/com/balanceball/component/GuiComponent.java
// public class GuiComponent implements Component {
// public Stage stage = null;
// }
//
// Path: core/src/com/balanceball/component/VisibleComponent.java
// public class VisibleComponent implements Component {
// public boolean visible = true;
// }
//
// Path: core/src/com/sec/Component.java
// public interface Component {
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
| import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.GuiComponent;
import com.balanceball.component.VisibleComponent;
import com.sec.Component;
import com.sec.Entity;
import com.sec.System; | entity.becomePaused();
}
}
public GuiRendererSystem() {
addComponentType(GuiComponent.class);
}
public void activateGui(Class<? extends Entity> guiEntityClass) {
if (mActiveGui != null) {
Entity activeGui = mEngine.getFirstEntityOfType(mActiveGui);
activeGui.becomePaused();
}
mActiveGui = guiEntityClass;
if (mActiveGui != null) {
Entity toBecomeActiveEntity = mEngine.getFirstEntityOfType(mActiveGui);
toBecomeActiveEntity.becomeActive();
GuiComponent guiComponent = toBecomeActiveEntity.getComponentByType(GuiComponent.class);
if (guiComponent != null) {
Gdx.input.setInputProcessor(guiComponent.stage);
}
}
}
@Override
public void updateFromEntities(Array<Entity> entities) {
for (Entity entity : entities) { | // Path: core/src/com/balanceball/component/GuiComponent.java
// public class GuiComponent implements Component {
// public Stage stage = null;
// }
//
// Path: core/src/com/balanceball/component/VisibleComponent.java
// public class VisibleComponent implements Component {
// public boolean visible = true;
// }
//
// Path: core/src/com/sec/Component.java
// public interface Component {
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
// Path: core/src/com/balanceball/system/GuiRendererSystem.java
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.GuiComponent;
import com.balanceball.component.VisibleComponent;
import com.sec.Component;
import com.sec.Entity;
import com.sec.System;
entity.becomePaused();
}
}
public GuiRendererSystem() {
addComponentType(GuiComponent.class);
}
public void activateGui(Class<? extends Entity> guiEntityClass) {
if (mActiveGui != null) {
Entity activeGui = mEngine.getFirstEntityOfType(mActiveGui);
activeGui.becomePaused();
}
mActiveGui = guiEntityClass;
if (mActiveGui != null) {
Entity toBecomeActiveEntity = mEngine.getFirstEntityOfType(mActiveGui);
toBecomeActiveEntity.becomeActive();
GuiComponent guiComponent = toBecomeActiveEntity.getComponentByType(GuiComponent.class);
if (guiComponent != null) {
Gdx.input.setInputProcessor(guiComponent.stage);
}
}
}
@Override
public void updateFromEntities(Array<Entity> entities) {
for (Entity entity : entities) { | VisibleComponent visibleComponent = entity.getComponentByType(VisibleComponent.class); |
tgobbens/fluffybalance | core/src/com/balanceball/system/SpriteRenderSystem.java | // Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/balanceball/component/SizeComponent.java
// public class SizeComponent implements Component {
// public float width = 1.f;
// public float height = 1.f;
// }
//
// Path: core/src/com/balanceball/component/TextureComponent.java
// public class TextureComponent implements Component {
// public TextureRegion textureRegion;
// }
//
// Path: core/src/com/balanceball/component/VisibleComponent.java
// public class VisibleComponent implements Component {
// public boolean visible = true;
// }
//
// Path: core/src/com/balanceball/component/ZIndexComponent.java
// public class ZIndexComponent implements Component {
// public int index = 0;
// }
//
// Path: core/src/com/balanceball/enity/CameraEntity.java
// public class CameraEntity extends Entity {
// private Camera mCamera;
//
// public CameraEntity() {
// addComponent(new PositionComponent());
// }
//
// @Override
// public void create() {
// GameWorldEntity gameWorldEntity = mEngine.getFirstEntityOfType(GameWorldEntity.class);
// if (gameWorldEntity == null) {
// // cannot create a camera without a game world
// return;
// }
//
// mCamera = new OrthographicCamera(gameWorldEntity.getWorldWidth(), gameWorldEntity.getWorldHeight());
// mCamera.position.set(mCamera.viewportWidth / 2f, mCamera.viewportHeight / 2f, 0.f);
//
// PositionComponent positionComponent = getComponentByType(PositionComponent.class);
// positionComponent.position.set(mCamera.viewportWidth / 2f, mCamera.viewportHeight / 2f);
// }
//
// public Camera getCamera() {
// return mCamera;
// }
//
// public void update() {
// mCamera.position.set(getComponentByType(PositionComponent.class).position, 0.f);
// mCamera.update();
// }
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
| import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.balanceball.component.SizeComponent;
import com.balanceball.component.TextureComponent;
import com.balanceball.component.VisibleComponent;
import com.balanceball.component.ZIndexComponent;
import com.balanceball.enity.CameraEntity;
import com.sec.Entity;
import com.sec.System;
import java.util.Comparator; | package com.balanceball.system;
/**
* Created by tijs on 11/07/2017.
*/
public class SpriteRenderSystem extends System {
private SpriteBatch mSpriteBatch; | // Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/balanceball/component/SizeComponent.java
// public class SizeComponent implements Component {
// public float width = 1.f;
// public float height = 1.f;
// }
//
// Path: core/src/com/balanceball/component/TextureComponent.java
// public class TextureComponent implements Component {
// public TextureRegion textureRegion;
// }
//
// Path: core/src/com/balanceball/component/VisibleComponent.java
// public class VisibleComponent implements Component {
// public boolean visible = true;
// }
//
// Path: core/src/com/balanceball/component/ZIndexComponent.java
// public class ZIndexComponent implements Component {
// public int index = 0;
// }
//
// Path: core/src/com/balanceball/enity/CameraEntity.java
// public class CameraEntity extends Entity {
// private Camera mCamera;
//
// public CameraEntity() {
// addComponent(new PositionComponent());
// }
//
// @Override
// public void create() {
// GameWorldEntity gameWorldEntity = mEngine.getFirstEntityOfType(GameWorldEntity.class);
// if (gameWorldEntity == null) {
// // cannot create a camera without a game world
// return;
// }
//
// mCamera = new OrthographicCamera(gameWorldEntity.getWorldWidth(), gameWorldEntity.getWorldHeight());
// mCamera.position.set(mCamera.viewportWidth / 2f, mCamera.viewportHeight / 2f, 0.f);
//
// PositionComponent positionComponent = getComponentByType(PositionComponent.class);
// positionComponent.position.set(mCamera.viewportWidth / 2f, mCamera.viewportHeight / 2f);
// }
//
// public Camera getCamera() {
// return mCamera;
// }
//
// public void update() {
// mCamera.position.set(getComponentByType(PositionComponent.class).position, 0.f);
// mCamera.update();
// }
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
// Path: core/src/com/balanceball/system/SpriteRenderSystem.java
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.balanceball.component.SizeComponent;
import com.balanceball.component.TextureComponent;
import com.balanceball.component.VisibleComponent;
import com.balanceball.component.ZIndexComponent;
import com.balanceball.enity.CameraEntity;
import com.sec.Entity;
import com.sec.System;
import java.util.Comparator;
package com.balanceball.system;
/**
* Created by tijs on 11/07/2017.
*/
public class SpriteRenderSystem extends System {
private SpriteBatch mSpriteBatch; | private Array<Entity> mZOrderedEntities; |
tgobbens/fluffybalance | core/src/com/balanceball/system/SpriteRenderSystem.java | // Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/balanceball/component/SizeComponent.java
// public class SizeComponent implements Component {
// public float width = 1.f;
// public float height = 1.f;
// }
//
// Path: core/src/com/balanceball/component/TextureComponent.java
// public class TextureComponent implements Component {
// public TextureRegion textureRegion;
// }
//
// Path: core/src/com/balanceball/component/VisibleComponent.java
// public class VisibleComponent implements Component {
// public boolean visible = true;
// }
//
// Path: core/src/com/balanceball/component/ZIndexComponent.java
// public class ZIndexComponent implements Component {
// public int index = 0;
// }
//
// Path: core/src/com/balanceball/enity/CameraEntity.java
// public class CameraEntity extends Entity {
// private Camera mCamera;
//
// public CameraEntity() {
// addComponent(new PositionComponent());
// }
//
// @Override
// public void create() {
// GameWorldEntity gameWorldEntity = mEngine.getFirstEntityOfType(GameWorldEntity.class);
// if (gameWorldEntity == null) {
// // cannot create a camera without a game world
// return;
// }
//
// mCamera = new OrthographicCamera(gameWorldEntity.getWorldWidth(), gameWorldEntity.getWorldHeight());
// mCamera.position.set(mCamera.viewportWidth / 2f, mCamera.viewportHeight / 2f, 0.f);
//
// PositionComponent positionComponent = getComponentByType(PositionComponent.class);
// positionComponent.position.set(mCamera.viewportWidth / 2f, mCamera.viewportHeight / 2f);
// }
//
// public Camera getCamera() {
// return mCamera;
// }
//
// public void update() {
// mCamera.position.set(getComponentByType(PositionComponent.class).position, 0.f);
// mCamera.update();
// }
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
| import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.balanceball.component.SizeComponent;
import com.balanceball.component.TextureComponent;
import com.balanceball.component.VisibleComponent;
import com.balanceball.component.ZIndexComponent;
import com.balanceball.enity.CameraEntity;
import com.sec.Entity;
import com.sec.System;
import java.util.Comparator; | package com.balanceball.system;
/**
* Created by tijs on 11/07/2017.
*/
public class SpriteRenderSystem extends System {
private SpriteBatch mSpriteBatch;
private Array<Entity> mZOrderedEntities;
public SpriteRenderSystem() { | // Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/balanceball/component/SizeComponent.java
// public class SizeComponent implements Component {
// public float width = 1.f;
// public float height = 1.f;
// }
//
// Path: core/src/com/balanceball/component/TextureComponent.java
// public class TextureComponent implements Component {
// public TextureRegion textureRegion;
// }
//
// Path: core/src/com/balanceball/component/VisibleComponent.java
// public class VisibleComponent implements Component {
// public boolean visible = true;
// }
//
// Path: core/src/com/balanceball/component/ZIndexComponent.java
// public class ZIndexComponent implements Component {
// public int index = 0;
// }
//
// Path: core/src/com/balanceball/enity/CameraEntity.java
// public class CameraEntity extends Entity {
// private Camera mCamera;
//
// public CameraEntity() {
// addComponent(new PositionComponent());
// }
//
// @Override
// public void create() {
// GameWorldEntity gameWorldEntity = mEngine.getFirstEntityOfType(GameWorldEntity.class);
// if (gameWorldEntity == null) {
// // cannot create a camera without a game world
// return;
// }
//
// mCamera = new OrthographicCamera(gameWorldEntity.getWorldWidth(), gameWorldEntity.getWorldHeight());
// mCamera.position.set(mCamera.viewportWidth / 2f, mCamera.viewportHeight / 2f, 0.f);
//
// PositionComponent positionComponent = getComponentByType(PositionComponent.class);
// positionComponent.position.set(mCamera.viewportWidth / 2f, mCamera.viewportHeight / 2f);
// }
//
// public Camera getCamera() {
// return mCamera;
// }
//
// public void update() {
// mCamera.position.set(getComponentByType(PositionComponent.class).position, 0.f);
// mCamera.update();
// }
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
// Path: core/src/com/balanceball/system/SpriteRenderSystem.java
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.balanceball.component.SizeComponent;
import com.balanceball.component.TextureComponent;
import com.balanceball.component.VisibleComponent;
import com.balanceball.component.ZIndexComponent;
import com.balanceball.enity.CameraEntity;
import com.sec.Entity;
import com.sec.System;
import java.util.Comparator;
package com.balanceball.system;
/**
* Created by tijs on 11/07/2017.
*/
public class SpriteRenderSystem extends System {
private SpriteBatch mSpriteBatch;
private Array<Entity> mZOrderedEntities;
public SpriteRenderSystem() { | addComponentType(TextureComponent.class); |
tgobbens/fluffybalance | core/src/com/balanceball/system/SpriteRenderSystem.java | // Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/balanceball/component/SizeComponent.java
// public class SizeComponent implements Component {
// public float width = 1.f;
// public float height = 1.f;
// }
//
// Path: core/src/com/balanceball/component/TextureComponent.java
// public class TextureComponent implements Component {
// public TextureRegion textureRegion;
// }
//
// Path: core/src/com/balanceball/component/VisibleComponent.java
// public class VisibleComponent implements Component {
// public boolean visible = true;
// }
//
// Path: core/src/com/balanceball/component/ZIndexComponent.java
// public class ZIndexComponent implements Component {
// public int index = 0;
// }
//
// Path: core/src/com/balanceball/enity/CameraEntity.java
// public class CameraEntity extends Entity {
// private Camera mCamera;
//
// public CameraEntity() {
// addComponent(new PositionComponent());
// }
//
// @Override
// public void create() {
// GameWorldEntity gameWorldEntity = mEngine.getFirstEntityOfType(GameWorldEntity.class);
// if (gameWorldEntity == null) {
// // cannot create a camera without a game world
// return;
// }
//
// mCamera = new OrthographicCamera(gameWorldEntity.getWorldWidth(), gameWorldEntity.getWorldHeight());
// mCamera.position.set(mCamera.viewportWidth / 2f, mCamera.viewportHeight / 2f, 0.f);
//
// PositionComponent positionComponent = getComponentByType(PositionComponent.class);
// positionComponent.position.set(mCamera.viewportWidth / 2f, mCamera.viewportHeight / 2f);
// }
//
// public Camera getCamera() {
// return mCamera;
// }
//
// public void update() {
// mCamera.position.set(getComponentByType(PositionComponent.class).position, 0.f);
// mCamera.update();
// }
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
| import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.balanceball.component.SizeComponent;
import com.balanceball.component.TextureComponent;
import com.balanceball.component.VisibleComponent;
import com.balanceball.component.ZIndexComponent;
import com.balanceball.enity.CameraEntity;
import com.sec.Entity;
import com.sec.System;
import java.util.Comparator; | package com.balanceball.system;
/**
* Created by tijs on 11/07/2017.
*/
public class SpriteRenderSystem extends System {
private SpriteBatch mSpriteBatch;
private Array<Entity> mZOrderedEntities;
public SpriteRenderSystem() {
addComponentType(TextureComponent.class); | // Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/balanceball/component/SizeComponent.java
// public class SizeComponent implements Component {
// public float width = 1.f;
// public float height = 1.f;
// }
//
// Path: core/src/com/balanceball/component/TextureComponent.java
// public class TextureComponent implements Component {
// public TextureRegion textureRegion;
// }
//
// Path: core/src/com/balanceball/component/VisibleComponent.java
// public class VisibleComponent implements Component {
// public boolean visible = true;
// }
//
// Path: core/src/com/balanceball/component/ZIndexComponent.java
// public class ZIndexComponent implements Component {
// public int index = 0;
// }
//
// Path: core/src/com/balanceball/enity/CameraEntity.java
// public class CameraEntity extends Entity {
// private Camera mCamera;
//
// public CameraEntity() {
// addComponent(new PositionComponent());
// }
//
// @Override
// public void create() {
// GameWorldEntity gameWorldEntity = mEngine.getFirstEntityOfType(GameWorldEntity.class);
// if (gameWorldEntity == null) {
// // cannot create a camera without a game world
// return;
// }
//
// mCamera = new OrthographicCamera(gameWorldEntity.getWorldWidth(), gameWorldEntity.getWorldHeight());
// mCamera.position.set(mCamera.viewportWidth / 2f, mCamera.viewportHeight / 2f, 0.f);
//
// PositionComponent positionComponent = getComponentByType(PositionComponent.class);
// positionComponent.position.set(mCamera.viewportWidth / 2f, mCamera.viewportHeight / 2f);
// }
//
// public Camera getCamera() {
// return mCamera;
// }
//
// public void update() {
// mCamera.position.set(getComponentByType(PositionComponent.class).position, 0.f);
// mCamera.update();
// }
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
// Path: core/src/com/balanceball/system/SpriteRenderSystem.java
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.balanceball.component.SizeComponent;
import com.balanceball.component.TextureComponent;
import com.balanceball.component.VisibleComponent;
import com.balanceball.component.ZIndexComponent;
import com.balanceball.enity.CameraEntity;
import com.sec.Entity;
import com.sec.System;
import java.util.Comparator;
package com.balanceball.system;
/**
* Created by tijs on 11/07/2017.
*/
public class SpriteRenderSystem extends System {
private SpriteBatch mSpriteBatch;
private Array<Entity> mZOrderedEntities;
public SpriteRenderSystem() {
addComponentType(TextureComponent.class); | addComponentType(PositionComponent.class); |
tgobbens/fluffybalance | core/src/com/balanceball/system/SpriteRenderSystem.java | // Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/balanceball/component/SizeComponent.java
// public class SizeComponent implements Component {
// public float width = 1.f;
// public float height = 1.f;
// }
//
// Path: core/src/com/balanceball/component/TextureComponent.java
// public class TextureComponent implements Component {
// public TextureRegion textureRegion;
// }
//
// Path: core/src/com/balanceball/component/VisibleComponent.java
// public class VisibleComponent implements Component {
// public boolean visible = true;
// }
//
// Path: core/src/com/balanceball/component/ZIndexComponent.java
// public class ZIndexComponent implements Component {
// public int index = 0;
// }
//
// Path: core/src/com/balanceball/enity/CameraEntity.java
// public class CameraEntity extends Entity {
// private Camera mCamera;
//
// public CameraEntity() {
// addComponent(new PositionComponent());
// }
//
// @Override
// public void create() {
// GameWorldEntity gameWorldEntity = mEngine.getFirstEntityOfType(GameWorldEntity.class);
// if (gameWorldEntity == null) {
// // cannot create a camera without a game world
// return;
// }
//
// mCamera = new OrthographicCamera(gameWorldEntity.getWorldWidth(), gameWorldEntity.getWorldHeight());
// mCamera.position.set(mCamera.viewportWidth / 2f, mCamera.viewportHeight / 2f, 0.f);
//
// PositionComponent positionComponent = getComponentByType(PositionComponent.class);
// positionComponent.position.set(mCamera.viewportWidth / 2f, mCamera.viewportHeight / 2f);
// }
//
// public Camera getCamera() {
// return mCamera;
// }
//
// public void update() {
// mCamera.position.set(getComponentByType(PositionComponent.class).position, 0.f);
// mCamera.update();
// }
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
| import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.balanceball.component.SizeComponent;
import com.balanceball.component.TextureComponent;
import com.balanceball.component.VisibleComponent;
import com.balanceball.component.ZIndexComponent;
import com.balanceball.enity.CameraEntity;
import com.sec.Entity;
import com.sec.System;
import java.util.Comparator; | package com.balanceball.system;
/**
* Created by tijs on 11/07/2017.
*/
public class SpriteRenderSystem extends System {
private SpriteBatch mSpriteBatch;
private Array<Entity> mZOrderedEntities;
public SpriteRenderSystem() {
addComponentType(TextureComponent.class);
addComponentType(PositionComponent.class); | // Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/balanceball/component/SizeComponent.java
// public class SizeComponent implements Component {
// public float width = 1.f;
// public float height = 1.f;
// }
//
// Path: core/src/com/balanceball/component/TextureComponent.java
// public class TextureComponent implements Component {
// public TextureRegion textureRegion;
// }
//
// Path: core/src/com/balanceball/component/VisibleComponent.java
// public class VisibleComponent implements Component {
// public boolean visible = true;
// }
//
// Path: core/src/com/balanceball/component/ZIndexComponent.java
// public class ZIndexComponent implements Component {
// public int index = 0;
// }
//
// Path: core/src/com/balanceball/enity/CameraEntity.java
// public class CameraEntity extends Entity {
// private Camera mCamera;
//
// public CameraEntity() {
// addComponent(new PositionComponent());
// }
//
// @Override
// public void create() {
// GameWorldEntity gameWorldEntity = mEngine.getFirstEntityOfType(GameWorldEntity.class);
// if (gameWorldEntity == null) {
// // cannot create a camera without a game world
// return;
// }
//
// mCamera = new OrthographicCamera(gameWorldEntity.getWorldWidth(), gameWorldEntity.getWorldHeight());
// mCamera.position.set(mCamera.viewportWidth / 2f, mCamera.viewportHeight / 2f, 0.f);
//
// PositionComponent positionComponent = getComponentByType(PositionComponent.class);
// positionComponent.position.set(mCamera.viewportWidth / 2f, mCamera.viewportHeight / 2f);
// }
//
// public Camera getCamera() {
// return mCamera;
// }
//
// public void update() {
// mCamera.position.set(getComponentByType(PositionComponent.class).position, 0.f);
// mCamera.update();
// }
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
//
// Path: core/src/com/sec/System.java
// public abstract class System implements SystemInterface, GameLifecycleListener {
//
// protected Engine mEngine = null;
//
// // register all type it want to listen for
// private Array<Class<? extends Component>> mComponentsType;
//
// protected System() {
// mComponentsType = new Array<Class<? extends Component>>();
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// protected final void addComponentType(Class<? extends Component> componentType) {
// mComponentsType.add(componentType);
// }
//
// Array<Class<? extends Component>> getComponentsType() {
// return mComponentsType;
// }
//
// @Override
// public void create() {
//
// }
//
// @Override
// public void resume() {
//
// }
//
// @Override
// public void update() {
//
// }
//
// @Override
// public void pause() {
//
// }
//
// @Override
// public void dispose() {
//
// }
// }
// Path: core/src/com/balanceball/system/SpriteRenderSystem.java
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.Array;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.balanceball.component.SizeComponent;
import com.balanceball.component.TextureComponent;
import com.balanceball.component.VisibleComponent;
import com.balanceball.component.ZIndexComponent;
import com.balanceball.enity.CameraEntity;
import com.sec.Entity;
import com.sec.System;
import java.util.Comparator;
package com.balanceball.system;
/**
* Created by tijs on 11/07/2017.
*/
public class SpriteRenderSystem extends System {
private SpriteBatch mSpriteBatch;
private Array<Entity> mZOrderedEntities;
public SpriteRenderSystem() {
addComponentType(TextureComponent.class);
addComponentType(PositionComponent.class); | addComponentType(SizeComponent.class); |
tgobbens/fluffybalance | core/src/com/balanceball/enity/IngameGuiEntity.java | // Path: core/src/com/balanceball/component/GuiComponent.java
// public class GuiComponent implements Component {
// public Stage stage = null;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
| import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import com.balanceball.component.GuiComponent;
import com.sec.Entity; | package com.balanceball.enity;
/**
* Created by tijs on 18/07/2017.
*/
public class IngameGuiEntity extends Entity {
private static final Color COLOR_FONT = new Color(0xffffffff);
private BitmapFont mFont;
private Label mScoreLabel;
public IngameGuiEntity(BitmapFont font) {
mFont = font;
| // Path: core/src/com/balanceball/component/GuiComponent.java
// public class GuiComponent implements Component {
// public Stage stage = null;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
// Path: core/src/com/balanceball/enity/IngameGuiEntity.java
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import com.balanceball.component.GuiComponent;
import com.sec.Entity;
package com.balanceball.enity;
/**
* Created by tijs on 18/07/2017.
*/
public class IngameGuiEntity extends Entity {
private static final Color COLOR_FONT = new Color(0xffffffff);
private BitmapFont mFont;
private Label mScoreLabel;
public IngameGuiEntity(BitmapFont font) {
mFont = font;
| addComponent(new GuiComponent()); |
tgobbens/fluffybalance | core/src/com/balanceball/enity/CameraEntity.java | // Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
| import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.balanceball.component.PositionComponent;
import com.sec.Entity; | package com.balanceball.enity;
/**
* Created by tijs on 16/07/2017.
*/
public class CameraEntity extends Entity {
private Camera mCamera;
public CameraEntity() { | // Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
// Path: core/src/com/balanceball/enity/CameraEntity.java
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.balanceball.component.PositionComponent;
import com.sec.Entity;
package com.balanceball.enity;
/**
* Created by tijs on 16/07/2017.
*/
public class CameraEntity extends Entity {
private Camera mCamera;
public CameraEntity() { | addComponent(new PositionComponent()); |
tgobbens/fluffybalance | core/src/com/balanceball/enity/SpriteEntity.java | // Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/balanceball/component/SizeComponent.java
// public class SizeComponent implements Component {
// public float width = 1.f;
// public float height = 1.f;
// }
//
// Path: core/src/com/balanceball/component/TextureComponent.java
// public class TextureComponent implements Component {
// public TextureRegion textureRegion;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
| import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.balanceball.component.SizeComponent;
import com.balanceball.component.TextureComponent;
import com.sec.Entity; | package com.balanceball.enity;
/**
* Created by tijs on 16/07/2017.
*/
public class SpriteEntity extends Entity {
private String mTexturePath;
public SpriteEntity(String texturePath, Vector2 position, float width) {
init(texturePath, position, width, -1.f, 0.f);
}
public SpriteEntity(String texturePath, Vector2 position, float width, float height) {
init(texturePath, position, width, height, 0.f);
}
public SpriteEntity(String texturePath, Vector2 position, float width, float height, float rotationDegree) {
init(texturePath, position, width, height, rotationDegree);
}
protected void init(String texturePath, Vector2 position, float width, float height, float rotationDegree) {
mTexturePath = texturePath;
| // Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/balanceball/component/SizeComponent.java
// public class SizeComponent implements Component {
// public float width = 1.f;
// public float height = 1.f;
// }
//
// Path: core/src/com/balanceball/component/TextureComponent.java
// public class TextureComponent implements Component {
// public TextureRegion textureRegion;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
// Path: core/src/com/balanceball/enity/SpriteEntity.java
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.balanceball.component.SizeComponent;
import com.balanceball.component.TextureComponent;
import com.sec.Entity;
package com.balanceball.enity;
/**
* Created by tijs on 16/07/2017.
*/
public class SpriteEntity extends Entity {
private String mTexturePath;
public SpriteEntity(String texturePath, Vector2 position, float width) {
init(texturePath, position, width, -1.f, 0.f);
}
public SpriteEntity(String texturePath, Vector2 position, float width, float height) {
init(texturePath, position, width, height, 0.f);
}
public SpriteEntity(String texturePath, Vector2 position, float width, float height, float rotationDegree) {
init(texturePath, position, width, height, rotationDegree);
}
protected void init(String texturePath, Vector2 position, float width, float height, float rotationDegree) {
mTexturePath = texturePath;
| PositionComponent positionComponent = new PositionComponent(); |
tgobbens/fluffybalance | core/src/com/balanceball/enity/SpriteEntity.java | // Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/balanceball/component/SizeComponent.java
// public class SizeComponent implements Component {
// public float width = 1.f;
// public float height = 1.f;
// }
//
// Path: core/src/com/balanceball/component/TextureComponent.java
// public class TextureComponent implements Component {
// public TextureRegion textureRegion;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
| import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.balanceball.component.SizeComponent;
import com.balanceball.component.TextureComponent;
import com.sec.Entity; | package com.balanceball.enity;
/**
* Created by tijs on 16/07/2017.
*/
public class SpriteEntity extends Entity {
private String mTexturePath;
public SpriteEntity(String texturePath, Vector2 position, float width) {
init(texturePath, position, width, -1.f, 0.f);
}
public SpriteEntity(String texturePath, Vector2 position, float width, float height) {
init(texturePath, position, width, height, 0.f);
}
public SpriteEntity(String texturePath, Vector2 position, float width, float height, float rotationDegree) {
init(texturePath, position, width, height, rotationDegree);
}
protected void init(String texturePath, Vector2 position, float width, float height, float rotationDegree) {
mTexturePath = texturePath;
PositionComponent positionComponent = new PositionComponent();
positionComponent.position = new Vector2(position);
addComponent(positionComponent);
| // Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/balanceball/component/SizeComponent.java
// public class SizeComponent implements Component {
// public float width = 1.f;
// public float height = 1.f;
// }
//
// Path: core/src/com/balanceball/component/TextureComponent.java
// public class TextureComponent implements Component {
// public TextureRegion textureRegion;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
// Path: core/src/com/balanceball/enity/SpriteEntity.java
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.balanceball.component.SizeComponent;
import com.balanceball.component.TextureComponent;
import com.sec.Entity;
package com.balanceball.enity;
/**
* Created by tijs on 16/07/2017.
*/
public class SpriteEntity extends Entity {
private String mTexturePath;
public SpriteEntity(String texturePath, Vector2 position, float width) {
init(texturePath, position, width, -1.f, 0.f);
}
public SpriteEntity(String texturePath, Vector2 position, float width, float height) {
init(texturePath, position, width, height, 0.f);
}
public SpriteEntity(String texturePath, Vector2 position, float width, float height, float rotationDegree) {
init(texturePath, position, width, height, rotationDegree);
}
protected void init(String texturePath, Vector2 position, float width, float height, float rotationDegree) {
mTexturePath = texturePath;
PositionComponent positionComponent = new PositionComponent();
positionComponent.position = new Vector2(position);
addComponent(positionComponent);
| SizeComponent sizeComponent = new SizeComponent(); |
tgobbens/fluffybalance | core/src/com/balanceball/enity/SpriteEntity.java | // Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/balanceball/component/SizeComponent.java
// public class SizeComponent implements Component {
// public float width = 1.f;
// public float height = 1.f;
// }
//
// Path: core/src/com/balanceball/component/TextureComponent.java
// public class TextureComponent implements Component {
// public TextureRegion textureRegion;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
| import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.balanceball.component.SizeComponent;
import com.balanceball.component.TextureComponent;
import com.sec.Entity; | package com.balanceball.enity;
/**
* Created by tijs on 16/07/2017.
*/
public class SpriteEntity extends Entity {
private String mTexturePath;
public SpriteEntity(String texturePath, Vector2 position, float width) {
init(texturePath, position, width, -1.f, 0.f);
}
public SpriteEntity(String texturePath, Vector2 position, float width, float height) {
init(texturePath, position, width, height, 0.f);
}
public SpriteEntity(String texturePath, Vector2 position, float width, float height, float rotationDegree) {
init(texturePath, position, width, height, rotationDegree);
}
protected void init(String texturePath, Vector2 position, float width, float height, float rotationDegree) {
mTexturePath = texturePath;
PositionComponent positionComponent = new PositionComponent();
positionComponent.position = new Vector2(position);
addComponent(positionComponent);
SizeComponent sizeComponent = new SizeComponent();
sizeComponent.width = width;
sizeComponent.height = height;
addComponent(sizeComponent);
| // Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/balanceball/component/SizeComponent.java
// public class SizeComponent implements Component {
// public float width = 1.f;
// public float height = 1.f;
// }
//
// Path: core/src/com/balanceball/component/TextureComponent.java
// public class TextureComponent implements Component {
// public TextureRegion textureRegion;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
// Path: core/src/com/balanceball/enity/SpriteEntity.java
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.balanceball.component.SizeComponent;
import com.balanceball.component.TextureComponent;
import com.sec.Entity;
package com.balanceball.enity;
/**
* Created by tijs on 16/07/2017.
*/
public class SpriteEntity extends Entity {
private String mTexturePath;
public SpriteEntity(String texturePath, Vector2 position, float width) {
init(texturePath, position, width, -1.f, 0.f);
}
public SpriteEntity(String texturePath, Vector2 position, float width, float height) {
init(texturePath, position, width, height, 0.f);
}
public SpriteEntity(String texturePath, Vector2 position, float width, float height, float rotationDegree) {
init(texturePath, position, width, height, rotationDegree);
}
protected void init(String texturePath, Vector2 position, float width, float height, float rotationDegree) {
mTexturePath = texturePath;
PositionComponent positionComponent = new PositionComponent();
positionComponent.position = new Vector2(position);
addComponent(positionComponent);
SizeComponent sizeComponent = new SizeComponent();
sizeComponent.width = width;
sizeComponent.height = height;
addComponent(sizeComponent);
| RotationComponent rotationComponent = new RotationComponent(); |
tgobbens/fluffybalance | core/src/com/balanceball/enity/SpriteEntity.java | // Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/balanceball/component/SizeComponent.java
// public class SizeComponent implements Component {
// public float width = 1.f;
// public float height = 1.f;
// }
//
// Path: core/src/com/balanceball/component/TextureComponent.java
// public class TextureComponent implements Component {
// public TextureRegion textureRegion;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
| import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.balanceball.component.SizeComponent;
import com.balanceball.component.TextureComponent;
import com.sec.Entity; | package com.balanceball.enity;
/**
* Created by tijs on 16/07/2017.
*/
public class SpriteEntity extends Entity {
private String mTexturePath;
public SpriteEntity(String texturePath, Vector2 position, float width) {
init(texturePath, position, width, -1.f, 0.f);
}
public SpriteEntity(String texturePath, Vector2 position, float width, float height) {
init(texturePath, position, width, height, 0.f);
}
public SpriteEntity(String texturePath, Vector2 position, float width, float height, float rotationDegree) {
init(texturePath, position, width, height, rotationDegree);
}
protected void init(String texturePath, Vector2 position, float width, float height, float rotationDegree) {
mTexturePath = texturePath;
PositionComponent positionComponent = new PositionComponent();
positionComponent.position = new Vector2(position);
addComponent(positionComponent);
SizeComponent sizeComponent = new SizeComponent();
sizeComponent.width = width;
sizeComponent.height = height;
addComponent(sizeComponent);
RotationComponent rotationComponent = new RotationComponent();
rotationComponent.degree = rotationDegree;
addComponent(rotationComponent);
| // Path: core/src/com/balanceball/component/PositionComponent.java
// public class PositionComponent implements Component {
// public Vector2 position = new Vector2();
// }
//
// Path: core/src/com/balanceball/component/RotationComponent.java
// public class RotationComponent implements Component {
// public float degree;
// }
//
// Path: core/src/com/balanceball/component/SizeComponent.java
// public class SizeComponent implements Component {
// public float width = 1.f;
// public float height = 1.f;
// }
//
// Path: core/src/com/balanceball/component/TextureComponent.java
// public class TextureComponent implements Component {
// public TextureRegion textureRegion;
// }
//
// Path: core/src/com/sec/Entity.java
// public abstract class Entity implements GameLifecycleListener {
// private ObjectMap<String, Component> mComponents;
//
// public static final int STATE_BECOMING_ACTIVE = 0;
// public static final int STATE_ACTIVE = 1;
// public static final int STATE_BECOMING_PAUSED = 2;
// public static final int STATE_PAUSED = 3;
//
// private int mState = STATE_BECOMING_ACTIVE;
//
// protected Engine mEngine;
//
// public Entity() {
// mComponents = new ObjectMap<String, Component>(16);
// }
//
// protected final void addComponent(Component component) {
// mComponents.put(component.getClass().getName(), component);
// }
//
// void setEngine(Engine engine) {
// mEngine = engine;
// }
//
// public int getState() {
// return mState;
// }
//
// public void becomeActive() {
// mState = STATE_BECOMING_ACTIVE;
// }
//
// public void becomePaused() {
// mState = STATE_BECOMING_PAUSED;
// }
//
// @Override
// public void resume() {
// mState = STATE_ACTIVE;
// }
//
// @Override
// public void update() {
// // do nothing
// }
//
// @Override
// public void pause() {
// mState = STATE_PAUSED;
// }
//
// @Override
// public void create() {
// // do nothing
// }
//
// @Override
// public void dispose() {
// // do nothing
// }
//
// /**
// * check if the entity matches all required components
// * @param componentsType
// * @return boolean
// */
// final boolean matchesComponentTypes(Array<Class<? extends Component>> componentsType) {
// for (Class<? extends Component> componentType : componentsType) {
// if (getComponentByType(componentType) == null) {
// return false;
// }
// }
// return true;
// }
//
// /**
// *
// * @param componentType
// * @param <T> get the component of a given type
// * @return T the component, null if not found
// */
// public final <T extends Component> T getComponentByType(Class<T> componentType) {
// Object o = mComponents.get(componentType.getName());
// return (o == null) ? null : (T) o;
// }
// }
// Path: core/src/com/balanceball/enity/SpriteEntity.java
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.balanceball.component.PositionComponent;
import com.balanceball.component.RotationComponent;
import com.balanceball.component.SizeComponent;
import com.balanceball.component.TextureComponent;
import com.sec.Entity;
package com.balanceball.enity;
/**
* Created by tijs on 16/07/2017.
*/
public class SpriteEntity extends Entity {
private String mTexturePath;
public SpriteEntity(String texturePath, Vector2 position, float width) {
init(texturePath, position, width, -1.f, 0.f);
}
public SpriteEntity(String texturePath, Vector2 position, float width, float height) {
init(texturePath, position, width, height, 0.f);
}
public SpriteEntity(String texturePath, Vector2 position, float width, float height, float rotationDegree) {
init(texturePath, position, width, height, rotationDegree);
}
protected void init(String texturePath, Vector2 position, float width, float height, float rotationDegree) {
mTexturePath = texturePath;
PositionComponent positionComponent = new PositionComponent();
positionComponent.position = new Vector2(position);
addComponent(positionComponent);
SizeComponent sizeComponent = new SizeComponent();
sizeComponent.width = width;
sizeComponent.height = height;
addComponent(sizeComponent);
RotationComponent rotationComponent = new RotationComponent();
rotationComponent.degree = rotationDegree;
addComponent(rotationComponent);
| addComponent(new TextureComponent()); |
Roanis/atg-tdd | Core/src/main/java/com/roanis/tdd/annotation/NucleusWithCatalog.java | // Path: Core/src/main/java/com/roanis/tdd/core/commerce/catalog/CatalogTestConstants.java
// public class CatalogTestConstants {
//
// // Catalogs
// public static final String BASE_CATALOG_ID = "baseCatalog";
//
// // Categories
// public static final String ROOT_CATEGORY_ID = "tddRootCategory";
// public static final String CLOTHING_CATEGORY_ID = "catClothing";
// public static final String MENS_CLOTHING_CATEGORY_ID = "catMensClothing";
// public static final String WOMENS_CLOTHING_CATEGORY_ID = "catWomensClothing";
// public static final String ELECTRICALS_CATEGORY_ID = "catElectricals";
// public static final String PHONE_CATEGORY_ID = "catPhones";
// public static final String TELEVISION_CATEGORY_ID = "catTelevisions";
//
// // Products
// public static final String MENS_BELT_PRODUCT_ID = "prodMensBelt";
// public static final String MENS_JACKET_PRODUCT_ID = "prodMensJacket";
//
// public static final String WOMENS_DRESS_PRODUCT_ID = "prodWomensDress";
// public static final String WOMENS_BOOTS_PRODUCT_ID = "prodWomensBoots";
//
// public static final String PHONE_PRODUCT_ID = "prodPhone";
// public static final String TELEVISION_PRODUCT_ID = "prodTelevision";
//
// // Skus
// public static final String CASUAL_BELT_BROWN_SMALL_SKU_ID = "skuCasualBeltBrownSmall";
// public static final String CASUAL_BELT_BROWN_MEDIUM_SKU_ID = "skuCasualBeltBrownMedium";
// public static final String CASUAL_BELT_BROWN_LARGE_SKU_ID = "skuCasualBeltBrownLarge";
// public static final String CASUAL_BELT_BLACK_SMALL_SKU_ID = "skuCasualBeltBlackSmall";
// public static final String CASUAL_BELT_BLACK_MEDIUM_SKU_ID = "skuCasualBeltBlackMedium";
// public static final String CASUAL_BELT_BLACK_LARGE_SKU_ID = "skuCasualBeltBlackLarge";
//
// public static final String JACKET_SMALL_SKU_ID = "skuMensJacketSmall";
// public static final String JACKET_MEDIUM_SKU_ID = "skuMensJacketMedium";
// public static final String JACKET_LARGE_SKU_ID = "skuMensJacketLarge";
//
// public static final String BLUE_DRESS_SIZE_8_SKU_ID = "skuDressBlue8";
// public static final String BLUE_DRESS_SIZE_10_SKU_ID = "skuDressBlue10";
// public static final String BLUE_DRESS_SIZE_12_SKU_ID = "skuDressBlue12";
// public static final String BLUE_DRESS_SIZE_14_SKU_ID = "skuDressBlue14";
//
// public static final String BOOTS_SIZE_5_SKU_ID = "skuWomensBoots5";
// public static final String BOOTS_SIZE_6_SKU_ID = "skuWomensBoots6";
// public static final String BOOTS_SIZE_7_SKU_ID = "skuWomensBoots7";
// public static final String BOOTS_SIZE_8_SKU_ID = "skuWomensBoots8";
//
// public static final String PHONE_SKU_ID = "skuPhone";
//
// public static final String TELEVISION_SKU_ID = "skuTelevision";
//
//
// }
| import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.roanis.tdd.core.commerce.catalog.CatalogTestConstants; | package com.roanis.tdd.annotation;
/**
* Indicates that a catalog should be loaded from the Catalog repository and set as the
* current catalog i.e. CatalogContext.getCurrentCatalog will return the specified catalog.
*
* <p>The catalog used can be changed by specifying a different id e.g. @NucleusWithCatalog("myCatalogID").</p>
*
* @author rory
*
*/
@NucleusTestSetup
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface NucleusWithCatalog { | // Path: Core/src/main/java/com/roanis/tdd/core/commerce/catalog/CatalogTestConstants.java
// public class CatalogTestConstants {
//
// // Catalogs
// public static final String BASE_CATALOG_ID = "baseCatalog";
//
// // Categories
// public static final String ROOT_CATEGORY_ID = "tddRootCategory";
// public static final String CLOTHING_CATEGORY_ID = "catClothing";
// public static final String MENS_CLOTHING_CATEGORY_ID = "catMensClothing";
// public static final String WOMENS_CLOTHING_CATEGORY_ID = "catWomensClothing";
// public static final String ELECTRICALS_CATEGORY_ID = "catElectricals";
// public static final String PHONE_CATEGORY_ID = "catPhones";
// public static final String TELEVISION_CATEGORY_ID = "catTelevisions";
//
// // Products
// public static final String MENS_BELT_PRODUCT_ID = "prodMensBelt";
// public static final String MENS_JACKET_PRODUCT_ID = "prodMensJacket";
//
// public static final String WOMENS_DRESS_PRODUCT_ID = "prodWomensDress";
// public static final String WOMENS_BOOTS_PRODUCT_ID = "prodWomensBoots";
//
// public static final String PHONE_PRODUCT_ID = "prodPhone";
// public static final String TELEVISION_PRODUCT_ID = "prodTelevision";
//
// // Skus
// public static final String CASUAL_BELT_BROWN_SMALL_SKU_ID = "skuCasualBeltBrownSmall";
// public static final String CASUAL_BELT_BROWN_MEDIUM_SKU_ID = "skuCasualBeltBrownMedium";
// public static final String CASUAL_BELT_BROWN_LARGE_SKU_ID = "skuCasualBeltBrownLarge";
// public static final String CASUAL_BELT_BLACK_SMALL_SKU_ID = "skuCasualBeltBlackSmall";
// public static final String CASUAL_BELT_BLACK_MEDIUM_SKU_ID = "skuCasualBeltBlackMedium";
// public static final String CASUAL_BELT_BLACK_LARGE_SKU_ID = "skuCasualBeltBlackLarge";
//
// public static final String JACKET_SMALL_SKU_ID = "skuMensJacketSmall";
// public static final String JACKET_MEDIUM_SKU_ID = "skuMensJacketMedium";
// public static final String JACKET_LARGE_SKU_ID = "skuMensJacketLarge";
//
// public static final String BLUE_DRESS_SIZE_8_SKU_ID = "skuDressBlue8";
// public static final String BLUE_DRESS_SIZE_10_SKU_ID = "skuDressBlue10";
// public static final String BLUE_DRESS_SIZE_12_SKU_ID = "skuDressBlue12";
// public static final String BLUE_DRESS_SIZE_14_SKU_ID = "skuDressBlue14";
//
// public static final String BOOTS_SIZE_5_SKU_ID = "skuWomensBoots5";
// public static final String BOOTS_SIZE_6_SKU_ID = "skuWomensBoots6";
// public static final String BOOTS_SIZE_7_SKU_ID = "skuWomensBoots7";
// public static final String BOOTS_SIZE_8_SKU_ID = "skuWomensBoots8";
//
// public static final String PHONE_SKU_ID = "skuPhone";
//
// public static final String TELEVISION_SKU_ID = "skuTelevision";
//
//
// }
// Path: Core/src/main/java/com/roanis/tdd/annotation/NucleusWithCatalog.java
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.roanis.tdd.core.commerce.catalog.CatalogTestConstants;
package com.roanis.tdd.annotation;
/**
* Indicates that a catalog should be loaded from the Catalog repository and set as the
* current catalog i.e. CatalogContext.getCurrentCatalog will return the specified catalog.
*
* <p>The catalog used can be changed by specifying a different id e.g. @NucleusWithCatalog("myCatalogID").</p>
*
* @author rory
*
*/
@NucleusTestSetup
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface NucleusWithCatalog { | String value() default CatalogTestConstants.BASE_CATALOG_ID; |
Roanis/atg-tdd | Core/src/main/java/com/roanis/tdd/annotation/NucleusWithCommerce.java | // Path: Core/src/main/java/com/roanis/tdd/core/commerce/catalog/CatalogTestConstants.java
// public class CatalogTestConstants {
//
// // Catalogs
// public static final String BASE_CATALOG_ID = "baseCatalog";
//
// // Categories
// public static final String ROOT_CATEGORY_ID = "tddRootCategory";
// public static final String CLOTHING_CATEGORY_ID = "catClothing";
// public static final String MENS_CLOTHING_CATEGORY_ID = "catMensClothing";
// public static final String WOMENS_CLOTHING_CATEGORY_ID = "catWomensClothing";
// public static final String ELECTRICALS_CATEGORY_ID = "catElectricals";
// public static final String PHONE_CATEGORY_ID = "catPhones";
// public static final String TELEVISION_CATEGORY_ID = "catTelevisions";
//
// // Products
// public static final String MENS_BELT_PRODUCT_ID = "prodMensBelt";
// public static final String MENS_JACKET_PRODUCT_ID = "prodMensJacket";
//
// public static final String WOMENS_DRESS_PRODUCT_ID = "prodWomensDress";
// public static final String WOMENS_BOOTS_PRODUCT_ID = "prodWomensBoots";
//
// public static final String PHONE_PRODUCT_ID = "prodPhone";
// public static final String TELEVISION_PRODUCT_ID = "prodTelevision";
//
// // Skus
// public static final String CASUAL_BELT_BROWN_SMALL_SKU_ID = "skuCasualBeltBrownSmall";
// public static final String CASUAL_BELT_BROWN_MEDIUM_SKU_ID = "skuCasualBeltBrownMedium";
// public static final String CASUAL_BELT_BROWN_LARGE_SKU_ID = "skuCasualBeltBrownLarge";
// public static final String CASUAL_BELT_BLACK_SMALL_SKU_ID = "skuCasualBeltBlackSmall";
// public static final String CASUAL_BELT_BLACK_MEDIUM_SKU_ID = "skuCasualBeltBlackMedium";
// public static final String CASUAL_BELT_BLACK_LARGE_SKU_ID = "skuCasualBeltBlackLarge";
//
// public static final String JACKET_SMALL_SKU_ID = "skuMensJacketSmall";
// public static final String JACKET_MEDIUM_SKU_ID = "skuMensJacketMedium";
// public static final String JACKET_LARGE_SKU_ID = "skuMensJacketLarge";
//
// public static final String BLUE_DRESS_SIZE_8_SKU_ID = "skuDressBlue8";
// public static final String BLUE_DRESS_SIZE_10_SKU_ID = "skuDressBlue10";
// public static final String BLUE_DRESS_SIZE_12_SKU_ID = "skuDressBlue12";
// public static final String BLUE_DRESS_SIZE_14_SKU_ID = "skuDressBlue14";
//
// public static final String BOOTS_SIZE_5_SKU_ID = "skuWomensBoots5";
// public static final String BOOTS_SIZE_6_SKU_ID = "skuWomensBoots6";
// public static final String BOOTS_SIZE_7_SKU_ID = "skuWomensBoots7";
// public static final String BOOTS_SIZE_8_SKU_ID = "skuWomensBoots8";
//
// public static final String PHONE_SKU_ID = "skuPhone";
//
// public static final String TELEVISION_SKU_ID = "skuTelevision";
//
//
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/commerce/order/OrderTestConstants.java
// public class OrderTestConstants {
// public static final String BASE_INCOMPLETE_ORDER_ID = "incompleteOrder";
// public static final String BASE_EMPTY_ORDER_ID = "emptyOrder";
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/commerce/pricing/priceLists/PriceListTestConstants.java
// public class PriceListTestConstants {
// public static final String BASE_PRICE_LIST_ID = "baseListPrices";
// public static final String BASE_SALE_PRICE_LIST_ID = "baseSalePrices";
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/multisite/SiteTestConstants.java
// public class SiteTestConstants {
//
// public static final String BASE_SITE_ID = "baseSite";
// public static final String BASE_SITE_NAME = "baseSiteName";
//
// public static final String ENABLED_PROPERTY_NAME = "enabled";
//
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/userprofiling/ProfileTestConstants.java
// public class ProfileTestConstants {
// public static final String BASE_USER_ID = "baseUser";
//
// }
| import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.roanis.tdd.core.commerce.catalog.CatalogTestConstants;
import com.roanis.tdd.core.commerce.order.OrderTestConstants;
import com.roanis.tdd.core.commerce.pricing.priceLists.PriceListTestConstants;
import com.roanis.tdd.core.multisite.SiteTestConstants;
import com.roanis.tdd.core.userprofiling.ProfileTestConstants; | package com.roanis.tdd.annotation;
/**
* A shortcut for using all the other annotations together, i.e. indicates that the following
* should be set up:<br/>
* <ul>
* <li>site</li>
* <li>profile</li>
* <li>catalog</li>
* <li>price list</li>
* <li>sale price list</li>
* <li>order</li>
* </ul>
*
* <p>Different ids can be specified for each property i.e. @NucleusWithCommerce(site="1", profile="2" ...).</p>
* @author rory
*
*/
@NucleusTestSetup
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface NucleusWithCommerce { | // Path: Core/src/main/java/com/roanis/tdd/core/commerce/catalog/CatalogTestConstants.java
// public class CatalogTestConstants {
//
// // Catalogs
// public static final String BASE_CATALOG_ID = "baseCatalog";
//
// // Categories
// public static final String ROOT_CATEGORY_ID = "tddRootCategory";
// public static final String CLOTHING_CATEGORY_ID = "catClothing";
// public static final String MENS_CLOTHING_CATEGORY_ID = "catMensClothing";
// public static final String WOMENS_CLOTHING_CATEGORY_ID = "catWomensClothing";
// public static final String ELECTRICALS_CATEGORY_ID = "catElectricals";
// public static final String PHONE_CATEGORY_ID = "catPhones";
// public static final String TELEVISION_CATEGORY_ID = "catTelevisions";
//
// // Products
// public static final String MENS_BELT_PRODUCT_ID = "prodMensBelt";
// public static final String MENS_JACKET_PRODUCT_ID = "prodMensJacket";
//
// public static final String WOMENS_DRESS_PRODUCT_ID = "prodWomensDress";
// public static final String WOMENS_BOOTS_PRODUCT_ID = "prodWomensBoots";
//
// public static final String PHONE_PRODUCT_ID = "prodPhone";
// public static final String TELEVISION_PRODUCT_ID = "prodTelevision";
//
// // Skus
// public static final String CASUAL_BELT_BROWN_SMALL_SKU_ID = "skuCasualBeltBrownSmall";
// public static final String CASUAL_BELT_BROWN_MEDIUM_SKU_ID = "skuCasualBeltBrownMedium";
// public static final String CASUAL_BELT_BROWN_LARGE_SKU_ID = "skuCasualBeltBrownLarge";
// public static final String CASUAL_BELT_BLACK_SMALL_SKU_ID = "skuCasualBeltBlackSmall";
// public static final String CASUAL_BELT_BLACK_MEDIUM_SKU_ID = "skuCasualBeltBlackMedium";
// public static final String CASUAL_BELT_BLACK_LARGE_SKU_ID = "skuCasualBeltBlackLarge";
//
// public static final String JACKET_SMALL_SKU_ID = "skuMensJacketSmall";
// public static final String JACKET_MEDIUM_SKU_ID = "skuMensJacketMedium";
// public static final String JACKET_LARGE_SKU_ID = "skuMensJacketLarge";
//
// public static final String BLUE_DRESS_SIZE_8_SKU_ID = "skuDressBlue8";
// public static final String BLUE_DRESS_SIZE_10_SKU_ID = "skuDressBlue10";
// public static final String BLUE_DRESS_SIZE_12_SKU_ID = "skuDressBlue12";
// public static final String BLUE_DRESS_SIZE_14_SKU_ID = "skuDressBlue14";
//
// public static final String BOOTS_SIZE_5_SKU_ID = "skuWomensBoots5";
// public static final String BOOTS_SIZE_6_SKU_ID = "skuWomensBoots6";
// public static final String BOOTS_SIZE_7_SKU_ID = "skuWomensBoots7";
// public static final String BOOTS_SIZE_8_SKU_ID = "skuWomensBoots8";
//
// public static final String PHONE_SKU_ID = "skuPhone";
//
// public static final String TELEVISION_SKU_ID = "skuTelevision";
//
//
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/commerce/order/OrderTestConstants.java
// public class OrderTestConstants {
// public static final String BASE_INCOMPLETE_ORDER_ID = "incompleteOrder";
// public static final String BASE_EMPTY_ORDER_ID = "emptyOrder";
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/commerce/pricing/priceLists/PriceListTestConstants.java
// public class PriceListTestConstants {
// public static final String BASE_PRICE_LIST_ID = "baseListPrices";
// public static final String BASE_SALE_PRICE_LIST_ID = "baseSalePrices";
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/multisite/SiteTestConstants.java
// public class SiteTestConstants {
//
// public static final String BASE_SITE_ID = "baseSite";
// public static final String BASE_SITE_NAME = "baseSiteName";
//
// public static final String ENABLED_PROPERTY_NAME = "enabled";
//
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/userprofiling/ProfileTestConstants.java
// public class ProfileTestConstants {
// public static final String BASE_USER_ID = "baseUser";
//
// }
// Path: Core/src/main/java/com/roanis/tdd/annotation/NucleusWithCommerce.java
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.roanis.tdd.core.commerce.catalog.CatalogTestConstants;
import com.roanis.tdd.core.commerce.order.OrderTestConstants;
import com.roanis.tdd.core.commerce.pricing.priceLists.PriceListTestConstants;
import com.roanis.tdd.core.multisite.SiteTestConstants;
import com.roanis.tdd.core.userprofiling.ProfileTestConstants;
package com.roanis.tdd.annotation;
/**
* A shortcut for using all the other annotations together, i.e. indicates that the following
* should be set up:<br/>
* <ul>
* <li>site</li>
* <li>profile</li>
* <li>catalog</li>
* <li>price list</li>
* <li>sale price list</li>
* <li>order</li>
* </ul>
*
* <p>Different ids can be specified for each property i.e. @NucleusWithCommerce(site="1", profile="2" ...).</p>
* @author rory
*
*/
@NucleusTestSetup
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface NucleusWithCommerce { | String site() default SiteTestConstants.BASE_SITE_ID; |
Roanis/atg-tdd | Core/src/main/java/com/roanis/tdd/annotation/NucleusWithCommerce.java | // Path: Core/src/main/java/com/roanis/tdd/core/commerce/catalog/CatalogTestConstants.java
// public class CatalogTestConstants {
//
// // Catalogs
// public static final String BASE_CATALOG_ID = "baseCatalog";
//
// // Categories
// public static final String ROOT_CATEGORY_ID = "tddRootCategory";
// public static final String CLOTHING_CATEGORY_ID = "catClothing";
// public static final String MENS_CLOTHING_CATEGORY_ID = "catMensClothing";
// public static final String WOMENS_CLOTHING_CATEGORY_ID = "catWomensClothing";
// public static final String ELECTRICALS_CATEGORY_ID = "catElectricals";
// public static final String PHONE_CATEGORY_ID = "catPhones";
// public static final String TELEVISION_CATEGORY_ID = "catTelevisions";
//
// // Products
// public static final String MENS_BELT_PRODUCT_ID = "prodMensBelt";
// public static final String MENS_JACKET_PRODUCT_ID = "prodMensJacket";
//
// public static final String WOMENS_DRESS_PRODUCT_ID = "prodWomensDress";
// public static final String WOMENS_BOOTS_PRODUCT_ID = "prodWomensBoots";
//
// public static final String PHONE_PRODUCT_ID = "prodPhone";
// public static final String TELEVISION_PRODUCT_ID = "prodTelevision";
//
// // Skus
// public static final String CASUAL_BELT_BROWN_SMALL_SKU_ID = "skuCasualBeltBrownSmall";
// public static final String CASUAL_BELT_BROWN_MEDIUM_SKU_ID = "skuCasualBeltBrownMedium";
// public static final String CASUAL_BELT_BROWN_LARGE_SKU_ID = "skuCasualBeltBrownLarge";
// public static final String CASUAL_BELT_BLACK_SMALL_SKU_ID = "skuCasualBeltBlackSmall";
// public static final String CASUAL_BELT_BLACK_MEDIUM_SKU_ID = "skuCasualBeltBlackMedium";
// public static final String CASUAL_BELT_BLACK_LARGE_SKU_ID = "skuCasualBeltBlackLarge";
//
// public static final String JACKET_SMALL_SKU_ID = "skuMensJacketSmall";
// public static final String JACKET_MEDIUM_SKU_ID = "skuMensJacketMedium";
// public static final String JACKET_LARGE_SKU_ID = "skuMensJacketLarge";
//
// public static final String BLUE_DRESS_SIZE_8_SKU_ID = "skuDressBlue8";
// public static final String BLUE_DRESS_SIZE_10_SKU_ID = "skuDressBlue10";
// public static final String BLUE_DRESS_SIZE_12_SKU_ID = "skuDressBlue12";
// public static final String BLUE_DRESS_SIZE_14_SKU_ID = "skuDressBlue14";
//
// public static final String BOOTS_SIZE_5_SKU_ID = "skuWomensBoots5";
// public static final String BOOTS_SIZE_6_SKU_ID = "skuWomensBoots6";
// public static final String BOOTS_SIZE_7_SKU_ID = "skuWomensBoots7";
// public static final String BOOTS_SIZE_8_SKU_ID = "skuWomensBoots8";
//
// public static final String PHONE_SKU_ID = "skuPhone";
//
// public static final String TELEVISION_SKU_ID = "skuTelevision";
//
//
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/commerce/order/OrderTestConstants.java
// public class OrderTestConstants {
// public static final String BASE_INCOMPLETE_ORDER_ID = "incompleteOrder";
// public static final String BASE_EMPTY_ORDER_ID = "emptyOrder";
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/commerce/pricing/priceLists/PriceListTestConstants.java
// public class PriceListTestConstants {
// public static final String BASE_PRICE_LIST_ID = "baseListPrices";
// public static final String BASE_SALE_PRICE_LIST_ID = "baseSalePrices";
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/multisite/SiteTestConstants.java
// public class SiteTestConstants {
//
// public static final String BASE_SITE_ID = "baseSite";
// public static final String BASE_SITE_NAME = "baseSiteName";
//
// public static final String ENABLED_PROPERTY_NAME = "enabled";
//
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/userprofiling/ProfileTestConstants.java
// public class ProfileTestConstants {
// public static final String BASE_USER_ID = "baseUser";
//
// }
| import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.roanis.tdd.core.commerce.catalog.CatalogTestConstants;
import com.roanis.tdd.core.commerce.order.OrderTestConstants;
import com.roanis.tdd.core.commerce.pricing.priceLists.PriceListTestConstants;
import com.roanis.tdd.core.multisite.SiteTestConstants;
import com.roanis.tdd.core.userprofiling.ProfileTestConstants; | package com.roanis.tdd.annotation;
/**
* A shortcut for using all the other annotations together, i.e. indicates that the following
* should be set up:<br/>
* <ul>
* <li>site</li>
* <li>profile</li>
* <li>catalog</li>
* <li>price list</li>
* <li>sale price list</li>
* <li>order</li>
* </ul>
*
* <p>Different ids can be specified for each property i.e. @NucleusWithCommerce(site="1", profile="2" ...).</p>
* @author rory
*
*/
@NucleusTestSetup
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface NucleusWithCommerce {
String site() default SiteTestConstants.BASE_SITE_ID; | // Path: Core/src/main/java/com/roanis/tdd/core/commerce/catalog/CatalogTestConstants.java
// public class CatalogTestConstants {
//
// // Catalogs
// public static final String BASE_CATALOG_ID = "baseCatalog";
//
// // Categories
// public static final String ROOT_CATEGORY_ID = "tddRootCategory";
// public static final String CLOTHING_CATEGORY_ID = "catClothing";
// public static final String MENS_CLOTHING_CATEGORY_ID = "catMensClothing";
// public static final String WOMENS_CLOTHING_CATEGORY_ID = "catWomensClothing";
// public static final String ELECTRICALS_CATEGORY_ID = "catElectricals";
// public static final String PHONE_CATEGORY_ID = "catPhones";
// public static final String TELEVISION_CATEGORY_ID = "catTelevisions";
//
// // Products
// public static final String MENS_BELT_PRODUCT_ID = "prodMensBelt";
// public static final String MENS_JACKET_PRODUCT_ID = "prodMensJacket";
//
// public static final String WOMENS_DRESS_PRODUCT_ID = "prodWomensDress";
// public static final String WOMENS_BOOTS_PRODUCT_ID = "prodWomensBoots";
//
// public static final String PHONE_PRODUCT_ID = "prodPhone";
// public static final String TELEVISION_PRODUCT_ID = "prodTelevision";
//
// // Skus
// public static final String CASUAL_BELT_BROWN_SMALL_SKU_ID = "skuCasualBeltBrownSmall";
// public static final String CASUAL_BELT_BROWN_MEDIUM_SKU_ID = "skuCasualBeltBrownMedium";
// public static final String CASUAL_BELT_BROWN_LARGE_SKU_ID = "skuCasualBeltBrownLarge";
// public static final String CASUAL_BELT_BLACK_SMALL_SKU_ID = "skuCasualBeltBlackSmall";
// public static final String CASUAL_BELT_BLACK_MEDIUM_SKU_ID = "skuCasualBeltBlackMedium";
// public static final String CASUAL_BELT_BLACK_LARGE_SKU_ID = "skuCasualBeltBlackLarge";
//
// public static final String JACKET_SMALL_SKU_ID = "skuMensJacketSmall";
// public static final String JACKET_MEDIUM_SKU_ID = "skuMensJacketMedium";
// public static final String JACKET_LARGE_SKU_ID = "skuMensJacketLarge";
//
// public static final String BLUE_DRESS_SIZE_8_SKU_ID = "skuDressBlue8";
// public static final String BLUE_DRESS_SIZE_10_SKU_ID = "skuDressBlue10";
// public static final String BLUE_DRESS_SIZE_12_SKU_ID = "skuDressBlue12";
// public static final String BLUE_DRESS_SIZE_14_SKU_ID = "skuDressBlue14";
//
// public static final String BOOTS_SIZE_5_SKU_ID = "skuWomensBoots5";
// public static final String BOOTS_SIZE_6_SKU_ID = "skuWomensBoots6";
// public static final String BOOTS_SIZE_7_SKU_ID = "skuWomensBoots7";
// public static final String BOOTS_SIZE_8_SKU_ID = "skuWomensBoots8";
//
// public static final String PHONE_SKU_ID = "skuPhone";
//
// public static final String TELEVISION_SKU_ID = "skuTelevision";
//
//
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/commerce/order/OrderTestConstants.java
// public class OrderTestConstants {
// public static final String BASE_INCOMPLETE_ORDER_ID = "incompleteOrder";
// public static final String BASE_EMPTY_ORDER_ID = "emptyOrder";
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/commerce/pricing/priceLists/PriceListTestConstants.java
// public class PriceListTestConstants {
// public static final String BASE_PRICE_LIST_ID = "baseListPrices";
// public static final String BASE_SALE_PRICE_LIST_ID = "baseSalePrices";
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/multisite/SiteTestConstants.java
// public class SiteTestConstants {
//
// public static final String BASE_SITE_ID = "baseSite";
// public static final String BASE_SITE_NAME = "baseSiteName";
//
// public static final String ENABLED_PROPERTY_NAME = "enabled";
//
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/userprofiling/ProfileTestConstants.java
// public class ProfileTestConstants {
// public static final String BASE_USER_ID = "baseUser";
//
// }
// Path: Core/src/main/java/com/roanis/tdd/annotation/NucleusWithCommerce.java
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.roanis.tdd.core.commerce.catalog.CatalogTestConstants;
import com.roanis.tdd.core.commerce.order.OrderTestConstants;
import com.roanis.tdd.core.commerce.pricing.priceLists.PriceListTestConstants;
import com.roanis.tdd.core.multisite.SiteTestConstants;
import com.roanis.tdd.core.userprofiling.ProfileTestConstants;
package com.roanis.tdd.annotation;
/**
* A shortcut for using all the other annotations together, i.e. indicates that the following
* should be set up:<br/>
* <ul>
* <li>site</li>
* <li>profile</li>
* <li>catalog</li>
* <li>price list</li>
* <li>sale price list</li>
* <li>order</li>
* </ul>
*
* <p>Different ids can be specified for each property i.e. @NucleusWithCommerce(site="1", profile="2" ...).</p>
* @author rory
*
*/
@NucleusTestSetup
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface NucleusWithCommerce {
String site() default SiteTestConstants.BASE_SITE_ID; | String profile() default ProfileTestConstants.BASE_USER_ID; |
Roanis/atg-tdd | Core/src/main/java/com/roanis/tdd/annotation/NucleusWithCommerce.java | // Path: Core/src/main/java/com/roanis/tdd/core/commerce/catalog/CatalogTestConstants.java
// public class CatalogTestConstants {
//
// // Catalogs
// public static final String BASE_CATALOG_ID = "baseCatalog";
//
// // Categories
// public static final String ROOT_CATEGORY_ID = "tddRootCategory";
// public static final String CLOTHING_CATEGORY_ID = "catClothing";
// public static final String MENS_CLOTHING_CATEGORY_ID = "catMensClothing";
// public static final String WOMENS_CLOTHING_CATEGORY_ID = "catWomensClothing";
// public static final String ELECTRICALS_CATEGORY_ID = "catElectricals";
// public static final String PHONE_CATEGORY_ID = "catPhones";
// public static final String TELEVISION_CATEGORY_ID = "catTelevisions";
//
// // Products
// public static final String MENS_BELT_PRODUCT_ID = "prodMensBelt";
// public static final String MENS_JACKET_PRODUCT_ID = "prodMensJacket";
//
// public static final String WOMENS_DRESS_PRODUCT_ID = "prodWomensDress";
// public static final String WOMENS_BOOTS_PRODUCT_ID = "prodWomensBoots";
//
// public static final String PHONE_PRODUCT_ID = "prodPhone";
// public static final String TELEVISION_PRODUCT_ID = "prodTelevision";
//
// // Skus
// public static final String CASUAL_BELT_BROWN_SMALL_SKU_ID = "skuCasualBeltBrownSmall";
// public static final String CASUAL_BELT_BROWN_MEDIUM_SKU_ID = "skuCasualBeltBrownMedium";
// public static final String CASUAL_BELT_BROWN_LARGE_SKU_ID = "skuCasualBeltBrownLarge";
// public static final String CASUAL_BELT_BLACK_SMALL_SKU_ID = "skuCasualBeltBlackSmall";
// public static final String CASUAL_BELT_BLACK_MEDIUM_SKU_ID = "skuCasualBeltBlackMedium";
// public static final String CASUAL_BELT_BLACK_LARGE_SKU_ID = "skuCasualBeltBlackLarge";
//
// public static final String JACKET_SMALL_SKU_ID = "skuMensJacketSmall";
// public static final String JACKET_MEDIUM_SKU_ID = "skuMensJacketMedium";
// public static final String JACKET_LARGE_SKU_ID = "skuMensJacketLarge";
//
// public static final String BLUE_DRESS_SIZE_8_SKU_ID = "skuDressBlue8";
// public static final String BLUE_DRESS_SIZE_10_SKU_ID = "skuDressBlue10";
// public static final String BLUE_DRESS_SIZE_12_SKU_ID = "skuDressBlue12";
// public static final String BLUE_DRESS_SIZE_14_SKU_ID = "skuDressBlue14";
//
// public static final String BOOTS_SIZE_5_SKU_ID = "skuWomensBoots5";
// public static final String BOOTS_SIZE_6_SKU_ID = "skuWomensBoots6";
// public static final String BOOTS_SIZE_7_SKU_ID = "skuWomensBoots7";
// public static final String BOOTS_SIZE_8_SKU_ID = "skuWomensBoots8";
//
// public static final String PHONE_SKU_ID = "skuPhone";
//
// public static final String TELEVISION_SKU_ID = "skuTelevision";
//
//
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/commerce/order/OrderTestConstants.java
// public class OrderTestConstants {
// public static final String BASE_INCOMPLETE_ORDER_ID = "incompleteOrder";
// public static final String BASE_EMPTY_ORDER_ID = "emptyOrder";
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/commerce/pricing/priceLists/PriceListTestConstants.java
// public class PriceListTestConstants {
// public static final String BASE_PRICE_LIST_ID = "baseListPrices";
// public static final String BASE_SALE_PRICE_LIST_ID = "baseSalePrices";
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/multisite/SiteTestConstants.java
// public class SiteTestConstants {
//
// public static final String BASE_SITE_ID = "baseSite";
// public static final String BASE_SITE_NAME = "baseSiteName";
//
// public static final String ENABLED_PROPERTY_NAME = "enabled";
//
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/userprofiling/ProfileTestConstants.java
// public class ProfileTestConstants {
// public static final String BASE_USER_ID = "baseUser";
//
// }
| import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.roanis.tdd.core.commerce.catalog.CatalogTestConstants;
import com.roanis.tdd.core.commerce.order.OrderTestConstants;
import com.roanis.tdd.core.commerce.pricing.priceLists.PriceListTestConstants;
import com.roanis.tdd.core.multisite.SiteTestConstants;
import com.roanis.tdd.core.userprofiling.ProfileTestConstants; | package com.roanis.tdd.annotation;
/**
* A shortcut for using all the other annotations together, i.e. indicates that the following
* should be set up:<br/>
* <ul>
* <li>site</li>
* <li>profile</li>
* <li>catalog</li>
* <li>price list</li>
* <li>sale price list</li>
* <li>order</li>
* </ul>
*
* <p>Different ids can be specified for each property i.e. @NucleusWithCommerce(site="1", profile="2" ...).</p>
* @author rory
*
*/
@NucleusTestSetup
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface NucleusWithCommerce {
String site() default SiteTestConstants.BASE_SITE_ID;
String profile() default ProfileTestConstants.BASE_USER_ID; | // Path: Core/src/main/java/com/roanis/tdd/core/commerce/catalog/CatalogTestConstants.java
// public class CatalogTestConstants {
//
// // Catalogs
// public static final String BASE_CATALOG_ID = "baseCatalog";
//
// // Categories
// public static final String ROOT_CATEGORY_ID = "tddRootCategory";
// public static final String CLOTHING_CATEGORY_ID = "catClothing";
// public static final String MENS_CLOTHING_CATEGORY_ID = "catMensClothing";
// public static final String WOMENS_CLOTHING_CATEGORY_ID = "catWomensClothing";
// public static final String ELECTRICALS_CATEGORY_ID = "catElectricals";
// public static final String PHONE_CATEGORY_ID = "catPhones";
// public static final String TELEVISION_CATEGORY_ID = "catTelevisions";
//
// // Products
// public static final String MENS_BELT_PRODUCT_ID = "prodMensBelt";
// public static final String MENS_JACKET_PRODUCT_ID = "prodMensJacket";
//
// public static final String WOMENS_DRESS_PRODUCT_ID = "prodWomensDress";
// public static final String WOMENS_BOOTS_PRODUCT_ID = "prodWomensBoots";
//
// public static final String PHONE_PRODUCT_ID = "prodPhone";
// public static final String TELEVISION_PRODUCT_ID = "prodTelevision";
//
// // Skus
// public static final String CASUAL_BELT_BROWN_SMALL_SKU_ID = "skuCasualBeltBrownSmall";
// public static final String CASUAL_BELT_BROWN_MEDIUM_SKU_ID = "skuCasualBeltBrownMedium";
// public static final String CASUAL_BELT_BROWN_LARGE_SKU_ID = "skuCasualBeltBrownLarge";
// public static final String CASUAL_BELT_BLACK_SMALL_SKU_ID = "skuCasualBeltBlackSmall";
// public static final String CASUAL_BELT_BLACK_MEDIUM_SKU_ID = "skuCasualBeltBlackMedium";
// public static final String CASUAL_BELT_BLACK_LARGE_SKU_ID = "skuCasualBeltBlackLarge";
//
// public static final String JACKET_SMALL_SKU_ID = "skuMensJacketSmall";
// public static final String JACKET_MEDIUM_SKU_ID = "skuMensJacketMedium";
// public static final String JACKET_LARGE_SKU_ID = "skuMensJacketLarge";
//
// public static final String BLUE_DRESS_SIZE_8_SKU_ID = "skuDressBlue8";
// public static final String BLUE_DRESS_SIZE_10_SKU_ID = "skuDressBlue10";
// public static final String BLUE_DRESS_SIZE_12_SKU_ID = "skuDressBlue12";
// public static final String BLUE_DRESS_SIZE_14_SKU_ID = "skuDressBlue14";
//
// public static final String BOOTS_SIZE_5_SKU_ID = "skuWomensBoots5";
// public static final String BOOTS_SIZE_6_SKU_ID = "skuWomensBoots6";
// public static final String BOOTS_SIZE_7_SKU_ID = "skuWomensBoots7";
// public static final String BOOTS_SIZE_8_SKU_ID = "skuWomensBoots8";
//
// public static final String PHONE_SKU_ID = "skuPhone";
//
// public static final String TELEVISION_SKU_ID = "skuTelevision";
//
//
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/commerce/order/OrderTestConstants.java
// public class OrderTestConstants {
// public static final String BASE_INCOMPLETE_ORDER_ID = "incompleteOrder";
// public static final String BASE_EMPTY_ORDER_ID = "emptyOrder";
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/commerce/pricing/priceLists/PriceListTestConstants.java
// public class PriceListTestConstants {
// public static final String BASE_PRICE_LIST_ID = "baseListPrices";
// public static final String BASE_SALE_PRICE_LIST_ID = "baseSalePrices";
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/multisite/SiteTestConstants.java
// public class SiteTestConstants {
//
// public static final String BASE_SITE_ID = "baseSite";
// public static final String BASE_SITE_NAME = "baseSiteName";
//
// public static final String ENABLED_PROPERTY_NAME = "enabled";
//
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/userprofiling/ProfileTestConstants.java
// public class ProfileTestConstants {
// public static final String BASE_USER_ID = "baseUser";
//
// }
// Path: Core/src/main/java/com/roanis/tdd/annotation/NucleusWithCommerce.java
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.roanis.tdd.core.commerce.catalog.CatalogTestConstants;
import com.roanis.tdd.core.commerce.order.OrderTestConstants;
import com.roanis.tdd.core.commerce.pricing.priceLists.PriceListTestConstants;
import com.roanis.tdd.core.multisite.SiteTestConstants;
import com.roanis.tdd.core.userprofiling.ProfileTestConstants;
package com.roanis.tdd.annotation;
/**
* A shortcut for using all the other annotations together, i.e. indicates that the following
* should be set up:<br/>
* <ul>
* <li>site</li>
* <li>profile</li>
* <li>catalog</li>
* <li>price list</li>
* <li>sale price list</li>
* <li>order</li>
* </ul>
*
* <p>Different ids can be specified for each property i.e. @NucleusWithCommerce(site="1", profile="2" ...).</p>
* @author rory
*
*/
@NucleusTestSetup
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface NucleusWithCommerce {
String site() default SiteTestConstants.BASE_SITE_ID;
String profile() default ProfileTestConstants.BASE_USER_ID; | String catalog() default CatalogTestConstants.BASE_CATALOG_ID; |
Roanis/atg-tdd | Core/src/main/java/com/roanis/tdd/annotation/NucleusWithCommerce.java | // Path: Core/src/main/java/com/roanis/tdd/core/commerce/catalog/CatalogTestConstants.java
// public class CatalogTestConstants {
//
// // Catalogs
// public static final String BASE_CATALOG_ID = "baseCatalog";
//
// // Categories
// public static final String ROOT_CATEGORY_ID = "tddRootCategory";
// public static final String CLOTHING_CATEGORY_ID = "catClothing";
// public static final String MENS_CLOTHING_CATEGORY_ID = "catMensClothing";
// public static final String WOMENS_CLOTHING_CATEGORY_ID = "catWomensClothing";
// public static final String ELECTRICALS_CATEGORY_ID = "catElectricals";
// public static final String PHONE_CATEGORY_ID = "catPhones";
// public static final String TELEVISION_CATEGORY_ID = "catTelevisions";
//
// // Products
// public static final String MENS_BELT_PRODUCT_ID = "prodMensBelt";
// public static final String MENS_JACKET_PRODUCT_ID = "prodMensJacket";
//
// public static final String WOMENS_DRESS_PRODUCT_ID = "prodWomensDress";
// public static final String WOMENS_BOOTS_PRODUCT_ID = "prodWomensBoots";
//
// public static final String PHONE_PRODUCT_ID = "prodPhone";
// public static final String TELEVISION_PRODUCT_ID = "prodTelevision";
//
// // Skus
// public static final String CASUAL_BELT_BROWN_SMALL_SKU_ID = "skuCasualBeltBrownSmall";
// public static final String CASUAL_BELT_BROWN_MEDIUM_SKU_ID = "skuCasualBeltBrownMedium";
// public static final String CASUAL_BELT_BROWN_LARGE_SKU_ID = "skuCasualBeltBrownLarge";
// public static final String CASUAL_BELT_BLACK_SMALL_SKU_ID = "skuCasualBeltBlackSmall";
// public static final String CASUAL_BELT_BLACK_MEDIUM_SKU_ID = "skuCasualBeltBlackMedium";
// public static final String CASUAL_BELT_BLACK_LARGE_SKU_ID = "skuCasualBeltBlackLarge";
//
// public static final String JACKET_SMALL_SKU_ID = "skuMensJacketSmall";
// public static final String JACKET_MEDIUM_SKU_ID = "skuMensJacketMedium";
// public static final String JACKET_LARGE_SKU_ID = "skuMensJacketLarge";
//
// public static final String BLUE_DRESS_SIZE_8_SKU_ID = "skuDressBlue8";
// public static final String BLUE_DRESS_SIZE_10_SKU_ID = "skuDressBlue10";
// public static final String BLUE_DRESS_SIZE_12_SKU_ID = "skuDressBlue12";
// public static final String BLUE_DRESS_SIZE_14_SKU_ID = "skuDressBlue14";
//
// public static final String BOOTS_SIZE_5_SKU_ID = "skuWomensBoots5";
// public static final String BOOTS_SIZE_6_SKU_ID = "skuWomensBoots6";
// public static final String BOOTS_SIZE_7_SKU_ID = "skuWomensBoots7";
// public static final String BOOTS_SIZE_8_SKU_ID = "skuWomensBoots8";
//
// public static final String PHONE_SKU_ID = "skuPhone";
//
// public static final String TELEVISION_SKU_ID = "skuTelevision";
//
//
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/commerce/order/OrderTestConstants.java
// public class OrderTestConstants {
// public static final String BASE_INCOMPLETE_ORDER_ID = "incompleteOrder";
// public static final String BASE_EMPTY_ORDER_ID = "emptyOrder";
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/commerce/pricing/priceLists/PriceListTestConstants.java
// public class PriceListTestConstants {
// public static final String BASE_PRICE_LIST_ID = "baseListPrices";
// public static final String BASE_SALE_PRICE_LIST_ID = "baseSalePrices";
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/multisite/SiteTestConstants.java
// public class SiteTestConstants {
//
// public static final String BASE_SITE_ID = "baseSite";
// public static final String BASE_SITE_NAME = "baseSiteName";
//
// public static final String ENABLED_PROPERTY_NAME = "enabled";
//
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/userprofiling/ProfileTestConstants.java
// public class ProfileTestConstants {
// public static final String BASE_USER_ID = "baseUser";
//
// }
| import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.roanis.tdd.core.commerce.catalog.CatalogTestConstants;
import com.roanis.tdd.core.commerce.order.OrderTestConstants;
import com.roanis.tdd.core.commerce.pricing.priceLists.PriceListTestConstants;
import com.roanis.tdd.core.multisite.SiteTestConstants;
import com.roanis.tdd.core.userprofiling.ProfileTestConstants; | package com.roanis.tdd.annotation;
/**
* A shortcut for using all the other annotations together, i.e. indicates that the following
* should be set up:<br/>
* <ul>
* <li>site</li>
* <li>profile</li>
* <li>catalog</li>
* <li>price list</li>
* <li>sale price list</li>
* <li>order</li>
* </ul>
*
* <p>Different ids can be specified for each property i.e. @NucleusWithCommerce(site="1", profile="2" ...).</p>
* @author rory
*
*/
@NucleusTestSetup
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface NucleusWithCommerce {
String site() default SiteTestConstants.BASE_SITE_ID;
String profile() default ProfileTestConstants.BASE_USER_ID;
String catalog() default CatalogTestConstants.BASE_CATALOG_ID; | // Path: Core/src/main/java/com/roanis/tdd/core/commerce/catalog/CatalogTestConstants.java
// public class CatalogTestConstants {
//
// // Catalogs
// public static final String BASE_CATALOG_ID = "baseCatalog";
//
// // Categories
// public static final String ROOT_CATEGORY_ID = "tddRootCategory";
// public static final String CLOTHING_CATEGORY_ID = "catClothing";
// public static final String MENS_CLOTHING_CATEGORY_ID = "catMensClothing";
// public static final String WOMENS_CLOTHING_CATEGORY_ID = "catWomensClothing";
// public static final String ELECTRICALS_CATEGORY_ID = "catElectricals";
// public static final String PHONE_CATEGORY_ID = "catPhones";
// public static final String TELEVISION_CATEGORY_ID = "catTelevisions";
//
// // Products
// public static final String MENS_BELT_PRODUCT_ID = "prodMensBelt";
// public static final String MENS_JACKET_PRODUCT_ID = "prodMensJacket";
//
// public static final String WOMENS_DRESS_PRODUCT_ID = "prodWomensDress";
// public static final String WOMENS_BOOTS_PRODUCT_ID = "prodWomensBoots";
//
// public static final String PHONE_PRODUCT_ID = "prodPhone";
// public static final String TELEVISION_PRODUCT_ID = "prodTelevision";
//
// // Skus
// public static final String CASUAL_BELT_BROWN_SMALL_SKU_ID = "skuCasualBeltBrownSmall";
// public static final String CASUAL_BELT_BROWN_MEDIUM_SKU_ID = "skuCasualBeltBrownMedium";
// public static final String CASUAL_BELT_BROWN_LARGE_SKU_ID = "skuCasualBeltBrownLarge";
// public static final String CASUAL_BELT_BLACK_SMALL_SKU_ID = "skuCasualBeltBlackSmall";
// public static final String CASUAL_BELT_BLACK_MEDIUM_SKU_ID = "skuCasualBeltBlackMedium";
// public static final String CASUAL_BELT_BLACK_LARGE_SKU_ID = "skuCasualBeltBlackLarge";
//
// public static final String JACKET_SMALL_SKU_ID = "skuMensJacketSmall";
// public static final String JACKET_MEDIUM_SKU_ID = "skuMensJacketMedium";
// public static final String JACKET_LARGE_SKU_ID = "skuMensJacketLarge";
//
// public static final String BLUE_DRESS_SIZE_8_SKU_ID = "skuDressBlue8";
// public static final String BLUE_DRESS_SIZE_10_SKU_ID = "skuDressBlue10";
// public static final String BLUE_DRESS_SIZE_12_SKU_ID = "skuDressBlue12";
// public static final String BLUE_DRESS_SIZE_14_SKU_ID = "skuDressBlue14";
//
// public static final String BOOTS_SIZE_5_SKU_ID = "skuWomensBoots5";
// public static final String BOOTS_SIZE_6_SKU_ID = "skuWomensBoots6";
// public static final String BOOTS_SIZE_7_SKU_ID = "skuWomensBoots7";
// public static final String BOOTS_SIZE_8_SKU_ID = "skuWomensBoots8";
//
// public static final String PHONE_SKU_ID = "skuPhone";
//
// public static final String TELEVISION_SKU_ID = "skuTelevision";
//
//
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/commerce/order/OrderTestConstants.java
// public class OrderTestConstants {
// public static final String BASE_INCOMPLETE_ORDER_ID = "incompleteOrder";
// public static final String BASE_EMPTY_ORDER_ID = "emptyOrder";
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/commerce/pricing/priceLists/PriceListTestConstants.java
// public class PriceListTestConstants {
// public static final String BASE_PRICE_LIST_ID = "baseListPrices";
// public static final String BASE_SALE_PRICE_LIST_ID = "baseSalePrices";
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/multisite/SiteTestConstants.java
// public class SiteTestConstants {
//
// public static final String BASE_SITE_ID = "baseSite";
// public static final String BASE_SITE_NAME = "baseSiteName";
//
// public static final String ENABLED_PROPERTY_NAME = "enabled";
//
// }
//
// Path: Core/src/main/java/com/roanis/tdd/core/userprofiling/ProfileTestConstants.java
// public class ProfileTestConstants {
// public static final String BASE_USER_ID = "baseUser";
//
// }
// Path: Core/src/main/java/com/roanis/tdd/annotation/NucleusWithCommerce.java
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.roanis.tdd.core.commerce.catalog.CatalogTestConstants;
import com.roanis.tdd.core.commerce.order.OrderTestConstants;
import com.roanis.tdd.core.commerce.pricing.priceLists.PriceListTestConstants;
import com.roanis.tdd.core.multisite.SiteTestConstants;
import com.roanis.tdd.core.userprofiling.ProfileTestConstants;
package com.roanis.tdd.annotation;
/**
* A shortcut for using all the other annotations together, i.e. indicates that the following
* should be set up:<br/>
* <ul>
* <li>site</li>
* <li>profile</li>
* <li>catalog</li>
* <li>price list</li>
* <li>sale price list</li>
* <li>order</li>
* </ul>
*
* <p>Different ids can be specified for each property i.e. @NucleusWithCommerce(site="1", profile="2" ...).</p>
* @author rory
*
*/
@NucleusTestSetup
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface NucleusWithCommerce {
String site() default SiteTestConstants.BASE_SITE_ID;
String profile() default ProfileTestConstants.BASE_USER_ID;
String catalog() default CatalogTestConstants.BASE_CATALOG_ID; | String priceList() default PriceListTestConstants.BASE_PRICE_LIST_ID; |
Roanis/atg-tdd | Core/src/main/java/com/roanis/tdd/annotation/NucleusWithSite.java | // Path: Core/src/main/java/com/roanis/tdd/core/multisite/SiteTestConstants.java
// public class SiteTestConstants {
//
// public static final String BASE_SITE_ID = "baseSite";
// public static final String BASE_SITE_NAME = "baseSiteName";
//
// public static final String ENABLED_PROPERTY_NAME = "enabled";
//
// }
| import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.roanis.tdd.core.multisite.SiteTestConstants; | package com.roanis.tdd.annotation;
/**
* Indicates that a site should be loaded from the Site repository
* and set as the current site i.e. SiteContextManager.getCurrentSite
* will return the specified site.
*
* <p>The site used can be changed by specifying a different id e.g. @NucleusWithSite("mySiteID").</p>
*
* @author rory
*
*/
@NucleusTestSetup
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface NucleusWithSite {
| // Path: Core/src/main/java/com/roanis/tdd/core/multisite/SiteTestConstants.java
// public class SiteTestConstants {
//
// public static final String BASE_SITE_ID = "baseSite";
// public static final String BASE_SITE_NAME = "baseSiteName";
//
// public static final String ENABLED_PROPERTY_NAME = "enabled";
//
// }
// Path: Core/src/main/java/com/roanis/tdd/annotation/NucleusWithSite.java
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.roanis.tdd.core.multisite.SiteTestConstants;
package com.roanis.tdd.annotation;
/**
* Indicates that a site should be loaded from the Site repository
* and set as the current site i.e. SiteContextManager.getCurrentSite
* will return the specified site.
*
* <p>The site used can be changed by specifying a different id e.g. @NucleusWithSite("mySiteID").</p>
*
* @author rory
*
*/
@NucleusTestSetup
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface NucleusWithSite {
| String value() default SiteTestConstants.BASE_SITE_ID; |
Roanis/atg-tdd | Core/src/main/java/com/roanis/tdd/annotation/processor/rule/CommerceProcessor.java | // Path: Core/src/main/java/com/roanis/tdd/junit4/rules/CommerceData.java
// public class CommerceData extends ExternalNucleusData {
// private String mSiteId;
// private String mProfileId;
// private String mCatalogId;
// private String mOrderId;
//
//
// @Override
// protected void before() throws Throwable {
// super.before();
//
// getTestConfiguration().getSiteTestHelper().setAsCurrent(mSiteId);
// getTestConfiguration().getProfileTestHelper().setAsCurrent(mProfileId);
// getTestConfiguration().getCatalogTestHelper().setAsCurrent(mCatalogId);
// getTestConfiguration().getOrderTestHelper().setAsCurrent(mOrderId);
// }
//
// @Override
// protected void after() {
// getTestConfiguration().getSiteTestHelper().reset();
// getTestConfiguration().getProfileTestHelper().reset();
// getTestConfiguration().getCatalogTestHelper().reset();
// getTestConfiguration().getOrderTestHelper().resetCart();
//
// super.after();
// }
//
// public static class Builder {
// private String mSiteId;
// String mProfileId;
// String mCatalogId;
// String mPriceListId;
// String mSalePriceListId;
// String mOrderId;
//
// public Builder site(String siteId){
// mSiteId = siteId;
// return this;
// }
//
// public Builder profile(String profileId){
// mProfileId = profileId;
// return this;
// }
//
// public Builder catalog(String catalogId){
// mCatalogId = catalogId;
// return this;
// }
//
// public Builder priceList(String priceListId){
// mPriceListId = priceListId;
// return this;
// }
//
// public Builder salePriceList(String salePriceListId){
// mSalePriceListId = salePriceListId;
// return this;
// }
//
// public Builder order(String orderId){
// mOrderId = orderId;
// return this;
// }
//
// public CommerceData build(){
// return new CommerceData(this);
// }
//
// }
//
// private CommerceData(Builder builder){
// mSiteId = builder.mSiteId;
// mProfileId = builder.mProfileId;
// mCatalogId = builder.mCatalogId;
// mOrderId = builder.mOrderId;
// }
//
//
//
// }
| import java.lang.annotation.Annotation;
import org.junit.rules.TestRule;
import com.roanis.tdd.annotation.NucleusWithCommerce;
import com.roanis.tdd.junit4.rules.CommerceData; | package com.roanis.tdd.annotation.processor.rule;
/**
* An {@link AnnotationRuleProcessor} implementation, which handles {@link NucleusWithCommerce} annotations.
* A {@link CommerceData} TestRule is created from the information provided in the annotation.
*
* @author rory
*
*/
public class CommerceProcessor implements AnnotationRuleProcessor {
@Override
public TestRule createRule(Annotation annotation) {
NucleusWithCommerce withCommerce = (NucleusWithCommerce) annotation; | // Path: Core/src/main/java/com/roanis/tdd/junit4/rules/CommerceData.java
// public class CommerceData extends ExternalNucleusData {
// private String mSiteId;
// private String mProfileId;
// private String mCatalogId;
// private String mOrderId;
//
//
// @Override
// protected void before() throws Throwable {
// super.before();
//
// getTestConfiguration().getSiteTestHelper().setAsCurrent(mSiteId);
// getTestConfiguration().getProfileTestHelper().setAsCurrent(mProfileId);
// getTestConfiguration().getCatalogTestHelper().setAsCurrent(mCatalogId);
// getTestConfiguration().getOrderTestHelper().setAsCurrent(mOrderId);
// }
//
// @Override
// protected void after() {
// getTestConfiguration().getSiteTestHelper().reset();
// getTestConfiguration().getProfileTestHelper().reset();
// getTestConfiguration().getCatalogTestHelper().reset();
// getTestConfiguration().getOrderTestHelper().resetCart();
//
// super.after();
// }
//
// public static class Builder {
// private String mSiteId;
// String mProfileId;
// String mCatalogId;
// String mPriceListId;
// String mSalePriceListId;
// String mOrderId;
//
// public Builder site(String siteId){
// mSiteId = siteId;
// return this;
// }
//
// public Builder profile(String profileId){
// mProfileId = profileId;
// return this;
// }
//
// public Builder catalog(String catalogId){
// mCatalogId = catalogId;
// return this;
// }
//
// public Builder priceList(String priceListId){
// mPriceListId = priceListId;
// return this;
// }
//
// public Builder salePriceList(String salePriceListId){
// mSalePriceListId = salePriceListId;
// return this;
// }
//
// public Builder order(String orderId){
// mOrderId = orderId;
// return this;
// }
//
// public CommerceData build(){
// return new CommerceData(this);
// }
//
// }
//
// private CommerceData(Builder builder){
// mSiteId = builder.mSiteId;
// mProfileId = builder.mProfileId;
// mCatalogId = builder.mCatalogId;
// mOrderId = builder.mOrderId;
// }
//
//
//
// }
// Path: Core/src/main/java/com/roanis/tdd/annotation/processor/rule/CommerceProcessor.java
import java.lang.annotation.Annotation;
import org.junit.rules.TestRule;
import com.roanis.tdd.annotation.NucleusWithCommerce;
import com.roanis.tdd.junit4.rules.CommerceData;
package com.roanis.tdd.annotation.processor.rule;
/**
* An {@link AnnotationRuleProcessor} implementation, which handles {@link NucleusWithCommerce} annotations.
* A {@link CommerceData} TestRule is created from the information provided in the annotation.
*
* @author rory
*
*/
public class CommerceProcessor implements AnnotationRuleProcessor {
@Override
public TestRule createRule(Annotation annotation) {
NucleusWithCommerce withCommerce = (NucleusWithCommerce) annotation; | return new CommerceData.Builder().site(withCommerce.site()).profile(withCommerce.profile()) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.