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 |
|---|---|---|---|---|---|---|
paritytrading/nassau | libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64Client.java | // Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64.java
// class MoldUDP64 {
//
// static final int MESSAGE_COUNT_HEARTBEAT = 0x0;
//
// static final int MESSAGE_COUNT_END_OF_SESSION = 0xFFFF;
//
// static final int MAX_MESSAGE_COUNT = MESSAGE_COUNT_END_OF_SESSION - 1;
//
// static final int HEADER_LENGTH = 20;
//
// static final int MAX_PAYLOAD_LENGTH = 1400;
//
// static final int SESSION_LENGTH = 10;
//
// private static final byte SPACE = ' ';
//
// static byte[] session(String name) {
// byte[] session = new byte[SESSION_LENGTH];
// fill(session, SPACE);
//
// byte[] bytes = name.getBytes(US_ASCII);
// System.arraycopy(bytes, 0, session, 0, Math.min(bytes.length, session.length));
//
// return session;
// }
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64ClientState.java
// public enum MoldUDP64ClientState {
//
// /**
// * The state of the client in relation to the server is unknown.
// */
// UNKNOWN,
//
// /**
// * The client is yet to achieve synchronization with the server.
// */
// BACKFILL,
//
// /**
// * The client is in synchronization with the server.
// */
// SYNCHRONIZED,
//
// /**
// * The client has fallen out of synchronization with the server.
// */
// GAP_FILL,
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/Clock.java
// public interface Clock {
//
// /**
// * Get the current time in milliseconds.
// *
// * @return the current time in milliseconds
// */
// long currentTimeMillis();
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/MessageListener.java
// public interface MessageListener {
//
// /**
// * Receive a message. The message is contained in the buffer between the
// * current position and the limit.
// *
// * @param buffer a buffer
// * @throws IOException if an I/O error occurs
// */
// void message(ByteBuffer buffer) throws IOException;
//
// }
| import static com.paritytrading.foundation.ByteBuffers.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64ClientState.*;
import com.paritytrading.nassau.Clock;
import com.paritytrading.nassau.MessageListener;
import java.io.Closeable;
import java.io.IOException;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.DatagramChannel; | /*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.moldudp64;
/**
* An implementation of a MoldUDP64 client.
*/
public class MoldUDP64Client implements Closeable {
private static final int RX_BUFFER_LENGTH = 65535;
private static final long REQUEST_UNTIL_SEQUENCE_NUMBER_UNKNOWN = -1;
private static final long REQUEST_TIMEOUT_MILLIS = 1000;
| // Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64.java
// class MoldUDP64 {
//
// static final int MESSAGE_COUNT_HEARTBEAT = 0x0;
//
// static final int MESSAGE_COUNT_END_OF_SESSION = 0xFFFF;
//
// static final int MAX_MESSAGE_COUNT = MESSAGE_COUNT_END_OF_SESSION - 1;
//
// static final int HEADER_LENGTH = 20;
//
// static final int MAX_PAYLOAD_LENGTH = 1400;
//
// static final int SESSION_LENGTH = 10;
//
// private static final byte SPACE = ' ';
//
// static byte[] session(String name) {
// byte[] session = new byte[SESSION_LENGTH];
// fill(session, SPACE);
//
// byte[] bytes = name.getBytes(US_ASCII);
// System.arraycopy(bytes, 0, session, 0, Math.min(bytes.length, session.length));
//
// return session;
// }
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64ClientState.java
// public enum MoldUDP64ClientState {
//
// /**
// * The state of the client in relation to the server is unknown.
// */
// UNKNOWN,
//
// /**
// * The client is yet to achieve synchronization with the server.
// */
// BACKFILL,
//
// /**
// * The client is in synchronization with the server.
// */
// SYNCHRONIZED,
//
// /**
// * The client has fallen out of synchronization with the server.
// */
// GAP_FILL,
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/Clock.java
// public interface Clock {
//
// /**
// * Get the current time in milliseconds.
// *
// * @return the current time in milliseconds
// */
// long currentTimeMillis();
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/MessageListener.java
// public interface MessageListener {
//
// /**
// * Receive a message. The message is contained in the buffer between the
// * current position and the limit.
// *
// * @param buffer a buffer
// * @throws IOException if an I/O error occurs
// */
// void message(ByteBuffer buffer) throws IOException;
//
// }
// Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64Client.java
import static com.paritytrading.foundation.ByteBuffers.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64ClientState.*;
import com.paritytrading.nassau.Clock;
import com.paritytrading.nassau.MessageListener;
import java.io.Closeable;
import java.io.IOException;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.DatagramChannel;
/*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.moldudp64;
/**
* An implementation of a MoldUDP64 client.
*/
public class MoldUDP64Client implements Closeable {
private static final int RX_BUFFER_LENGTH = 65535;
private static final long REQUEST_UNTIL_SEQUENCE_NUMBER_UNKNOWN = -1;
private static final long REQUEST_TIMEOUT_MILLIS = 1000;
| private final Clock clock; |
paritytrading/nassau | libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64Client.java | // Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64.java
// class MoldUDP64 {
//
// static final int MESSAGE_COUNT_HEARTBEAT = 0x0;
//
// static final int MESSAGE_COUNT_END_OF_SESSION = 0xFFFF;
//
// static final int MAX_MESSAGE_COUNT = MESSAGE_COUNT_END_OF_SESSION - 1;
//
// static final int HEADER_LENGTH = 20;
//
// static final int MAX_PAYLOAD_LENGTH = 1400;
//
// static final int SESSION_LENGTH = 10;
//
// private static final byte SPACE = ' ';
//
// static byte[] session(String name) {
// byte[] session = new byte[SESSION_LENGTH];
// fill(session, SPACE);
//
// byte[] bytes = name.getBytes(US_ASCII);
// System.arraycopy(bytes, 0, session, 0, Math.min(bytes.length, session.length));
//
// return session;
// }
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64ClientState.java
// public enum MoldUDP64ClientState {
//
// /**
// * The state of the client in relation to the server is unknown.
// */
// UNKNOWN,
//
// /**
// * The client is yet to achieve synchronization with the server.
// */
// BACKFILL,
//
// /**
// * The client is in synchronization with the server.
// */
// SYNCHRONIZED,
//
// /**
// * The client has fallen out of synchronization with the server.
// */
// GAP_FILL,
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/Clock.java
// public interface Clock {
//
// /**
// * Get the current time in milliseconds.
// *
// * @return the current time in milliseconds
// */
// long currentTimeMillis();
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/MessageListener.java
// public interface MessageListener {
//
// /**
// * Receive a message. The message is contained in the buffer between the
// * current position and the limit.
// *
// * @param buffer a buffer
// * @throws IOException if an I/O error occurs
// */
// void message(ByteBuffer buffer) throws IOException;
//
// }
| import static com.paritytrading.foundation.ByteBuffers.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64ClientState.*;
import com.paritytrading.nassau.Clock;
import com.paritytrading.nassau.MessageListener;
import java.io.Closeable;
import java.io.IOException;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.DatagramChannel; | /*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.moldudp64;
/**
* An implementation of a MoldUDP64 client.
*/
public class MoldUDP64Client implements Closeable {
private static final int RX_BUFFER_LENGTH = 65535;
private static final long REQUEST_UNTIL_SEQUENCE_NUMBER_UNKNOWN = -1;
private static final long REQUEST_TIMEOUT_MILLIS = 1000;
private final Clock clock;
private final DatagramChannel channel;
private final DatagramChannel requestChannel;
private final SocketAddress requestAddress;
| // Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64.java
// class MoldUDP64 {
//
// static final int MESSAGE_COUNT_HEARTBEAT = 0x0;
//
// static final int MESSAGE_COUNT_END_OF_SESSION = 0xFFFF;
//
// static final int MAX_MESSAGE_COUNT = MESSAGE_COUNT_END_OF_SESSION - 1;
//
// static final int HEADER_LENGTH = 20;
//
// static final int MAX_PAYLOAD_LENGTH = 1400;
//
// static final int SESSION_LENGTH = 10;
//
// private static final byte SPACE = ' ';
//
// static byte[] session(String name) {
// byte[] session = new byte[SESSION_LENGTH];
// fill(session, SPACE);
//
// byte[] bytes = name.getBytes(US_ASCII);
// System.arraycopy(bytes, 0, session, 0, Math.min(bytes.length, session.length));
//
// return session;
// }
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64ClientState.java
// public enum MoldUDP64ClientState {
//
// /**
// * The state of the client in relation to the server is unknown.
// */
// UNKNOWN,
//
// /**
// * The client is yet to achieve synchronization with the server.
// */
// BACKFILL,
//
// /**
// * The client is in synchronization with the server.
// */
// SYNCHRONIZED,
//
// /**
// * The client has fallen out of synchronization with the server.
// */
// GAP_FILL,
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/Clock.java
// public interface Clock {
//
// /**
// * Get the current time in milliseconds.
// *
// * @return the current time in milliseconds
// */
// long currentTimeMillis();
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/MessageListener.java
// public interface MessageListener {
//
// /**
// * Receive a message. The message is contained in the buffer between the
// * current position and the limit.
// *
// * @param buffer a buffer
// * @throws IOException if an I/O error occurs
// */
// void message(ByteBuffer buffer) throws IOException;
//
// }
// Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64Client.java
import static com.paritytrading.foundation.ByteBuffers.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64ClientState.*;
import com.paritytrading.nassau.Clock;
import com.paritytrading.nassau.MessageListener;
import java.io.Closeable;
import java.io.IOException;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.DatagramChannel;
/*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.moldudp64;
/**
* An implementation of a MoldUDP64 client.
*/
public class MoldUDP64Client implements Closeable {
private static final int RX_BUFFER_LENGTH = 65535;
private static final long REQUEST_UNTIL_SEQUENCE_NUMBER_UNKNOWN = -1;
private static final long REQUEST_TIMEOUT_MILLIS = 1000;
private final Clock clock;
private final DatagramChannel channel;
private final DatagramChannel requestChannel;
private final SocketAddress requestAddress;
| private final MessageListener listener; |
paritytrading/nassau | libraries/core/src/test/java/com/paritytrading/nassau/moldudp64/MoldUDP64SessionTest.java | // Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64ClientState.java
// public enum MoldUDP64ClientState {
//
// /**
// * The state of the client in relation to the server is unknown.
// */
// UNKNOWN,
//
// /**
// * The client is yet to achieve synchronization with the server.
// */
// BACKFILL,
//
// /**
// * The client is in synchronization with the server.
// */
// SYNCHRONIZED,
//
// /**
// * The client has fallen out of synchronization with the server.
// */
// GAP_FILL,
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/Strings.java
// public class Strings {
//
// private Strings() {
// }
//
// public static final MessageParser<String> MESSAGE_PARSER = new MessageParser<String>() {
//
// @Override
// public String parse(ByteBuffer buffer) {
// return remaining(buffer);
// }
//
// };
//
// public static String get(ByteBuffer buffer, int length) {
// byte[] bytes = new byte[length];
//
// buffer.get(bytes);
//
// return new String(bytes, UTF_8);
// }
//
// public static String remaining(ByteBuffer buffer) {
// return get(buffer, buffer.remaining());
// }
//
// public static ByteBuffer wrap(String value) {
// return ByteBuffer.wrap(value.getBytes(UTF_8));
// }
//
// public static String repeat(char c, int num) {
// StringBuilder builder = new StringBuilder(num);
//
// for (int i = 0; i < num; i++)
// builder.append(c);
//
// return builder.toString();
// }
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/FixedClock.java
// public class FixedClock implements Clock {
//
// private long currentTimeMillis;
//
// @Override
// public long currentTimeMillis() {
// return currentTimeMillis;
// }
//
// public void setCurrentTimeMillis(long currentTimeMillis) {
// this.currentTimeMillis = currentTimeMillis;
// }
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/Messages.java
// public class Messages<M> implements MessageListener {
//
// private MessageParser<M> parser;
//
// private List<M> messages;
//
// public Messages(MessageParser<M> parser) {
// this.parser = parser;
//
// this.messages = new ArrayList<>();
// }
//
// public List<M> collect() {
// return messages;
// }
//
// @Override
// public void message(ByteBuffer buffer) {
// messages.add(parser.parse(buffer));
// }
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/Strings.java
// public class Strings {
//
// private Strings() {
// }
//
// public static final MessageParser<String> MESSAGE_PARSER = new MessageParser<String>() {
//
// @Override
// public String parse(ByteBuffer buffer) {
// return remaining(buffer);
// }
//
// };
//
// public static String get(ByteBuffer buffer, int length) {
// byte[] bytes = new byte[length];
//
// buffer.get(bytes);
//
// return new String(bytes, UTF_8);
// }
//
// public static String remaining(ByteBuffer buffer) {
// return get(buffer, buffer.remaining());
// }
//
// public static ByteBuffer wrap(String value) {
// return ByteBuffer.wrap(value.getBytes(UTF_8));
// }
//
// public static String repeat(char c, int num) {
// StringBuilder builder = new StringBuilder(num);
//
// for (int i = 0; i < num; i++)
// builder.append(c);
//
// return builder.toString();
// }
//
// }
| import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import static com.paritytrading.nassau.moldudp64.MoldUDP64ClientState.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64ClientStatus.*;
import static com.paritytrading.nassau.Strings.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static org.junit.jupiter.api.Assertions.*;
import com.paritytrading.nassau.FixedClock;
import com.paritytrading.nassau.Messages;
import com.paritytrading.nassau.Strings;
import java.net.SocketAddress;
import java.nio.channels.DatagramChannel;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.AfterEach; | /*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.moldudp64;
@Timeout(value=1, unit=TimeUnit.SECONDS)
class MoldUDP64SessionTest {
| // Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64ClientState.java
// public enum MoldUDP64ClientState {
//
// /**
// * The state of the client in relation to the server is unknown.
// */
// UNKNOWN,
//
// /**
// * The client is yet to achieve synchronization with the server.
// */
// BACKFILL,
//
// /**
// * The client is in synchronization with the server.
// */
// SYNCHRONIZED,
//
// /**
// * The client has fallen out of synchronization with the server.
// */
// GAP_FILL,
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/Strings.java
// public class Strings {
//
// private Strings() {
// }
//
// public static final MessageParser<String> MESSAGE_PARSER = new MessageParser<String>() {
//
// @Override
// public String parse(ByteBuffer buffer) {
// return remaining(buffer);
// }
//
// };
//
// public static String get(ByteBuffer buffer, int length) {
// byte[] bytes = new byte[length];
//
// buffer.get(bytes);
//
// return new String(bytes, UTF_8);
// }
//
// public static String remaining(ByteBuffer buffer) {
// return get(buffer, buffer.remaining());
// }
//
// public static ByteBuffer wrap(String value) {
// return ByteBuffer.wrap(value.getBytes(UTF_8));
// }
//
// public static String repeat(char c, int num) {
// StringBuilder builder = new StringBuilder(num);
//
// for (int i = 0; i < num; i++)
// builder.append(c);
//
// return builder.toString();
// }
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/FixedClock.java
// public class FixedClock implements Clock {
//
// private long currentTimeMillis;
//
// @Override
// public long currentTimeMillis() {
// return currentTimeMillis;
// }
//
// public void setCurrentTimeMillis(long currentTimeMillis) {
// this.currentTimeMillis = currentTimeMillis;
// }
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/Messages.java
// public class Messages<M> implements MessageListener {
//
// private MessageParser<M> parser;
//
// private List<M> messages;
//
// public Messages(MessageParser<M> parser) {
// this.parser = parser;
//
// this.messages = new ArrayList<>();
// }
//
// public List<M> collect() {
// return messages;
// }
//
// @Override
// public void message(ByteBuffer buffer) {
// messages.add(parser.parse(buffer));
// }
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/Strings.java
// public class Strings {
//
// private Strings() {
// }
//
// public static final MessageParser<String> MESSAGE_PARSER = new MessageParser<String>() {
//
// @Override
// public String parse(ByteBuffer buffer) {
// return remaining(buffer);
// }
//
// };
//
// public static String get(ByteBuffer buffer, int length) {
// byte[] bytes = new byte[length];
//
// buffer.get(bytes);
//
// return new String(bytes, UTF_8);
// }
//
// public static String remaining(ByteBuffer buffer) {
// return get(buffer, buffer.remaining());
// }
//
// public static ByteBuffer wrap(String value) {
// return ByteBuffer.wrap(value.getBytes(UTF_8));
// }
//
// public static String repeat(char c, int num) {
// StringBuilder builder = new StringBuilder(num);
//
// for (int i = 0; i < num; i++)
// builder.append(c);
//
// return builder.toString();
// }
//
// }
// Path: libraries/core/src/test/java/com/paritytrading/nassau/moldudp64/MoldUDP64SessionTest.java
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import static com.paritytrading.nassau.moldudp64.MoldUDP64ClientState.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64ClientStatus.*;
import static com.paritytrading.nassau.Strings.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static org.junit.jupiter.api.Assertions.*;
import com.paritytrading.nassau.FixedClock;
import com.paritytrading.nassau.Messages;
import com.paritytrading.nassau.Strings;
import java.net.SocketAddress;
import java.nio.channels.DatagramChannel;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.AfterEach;
/*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.moldudp64;
@Timeout(value=1, unit=TimeUnit.SECONDS)
class MoldUDP64SessionTest {
| private FixedClock clock; |
paritytrading/nassau | libraries/core/src/test/java/com/paritytrading/nassau/moldudp64/MoldUDP64SessionTest.java | // Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64ClientState.java
// public enum MoldUDP64ClientState {
//
// /**
// * The state of the client in relation to the server is unknown.
// */
// UNKNOWN,
//
// /**
// * The client is yet to achieve synchronization with the server.
// */
// BACKFILL,
//
// /**
// * The client is in synchronization with the server.
// */
// SYNCHRONIZED,
//
// /**
// * The client has fallen out of synchronization with the server.
// */
// GAP_FILL,
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/Strings.java
// public class Strings {
//
// private Strings() {
// }
//
// public static final MessageParser<String> MESSAGE_PARSER = new MessageParser<String>() {
//
// @Override
// public String parse(ByteBuffer buffer) {
// return remaining(buffer);
// }
//
// };
//
// public static String get(ByteBuffer buffer, int length) {
// byte[] bytes = new byte[length];
//
// buffer.get(bytes);
//
// return new String(bytes, UTF_8);
// }
//
// public static String remaining(ByteBuffer buffer) {
// return get(buffer, buffer.remaining());
// }
//
// public static ByteBuffer wrap(String value) {
// return ByteBuffer.wrap(value.getBytes(UTF_8));
// }
//
// public static String repeat(char c, int num) {
// StringBuilder builder = new StringBuilder(num);
//
// for (int i = 0; i < num; i++)
// builder.append(c);
//
// return builder.toString();
// }
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/FixedClock.java
// public class FixedClock implements Clock {
//
// private long currentTimeMillis;
//
// @Override
// public long currentTimeMillis() {
// return currentTimeMillis;
// }
//
// public void setCurrentTimeMillis(long currentTimeMillis) {
// this.currentTimeMillis = currentTimeMillis;
// }
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/Messages.java
// public class Messages<M> implements MessageListener {
//
// private MessageParser<M> parser;
//
// private List<M> messages;
//
// public Messages(MessageParser<M> parser) {
// this.parser = parser;
//
// this.messages = new ArrayList<>();
// }
//
// public List<M> collect() {
// return messages;
// }
//
// @Override
// public void message(ByteBuffer buffer) {
// messages.add(parser.parse(buffer));
// }
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/Strings.java
// public class Strings {
//
// private Strings() {
// }
//
// public static final MessageParser<String> MESSAGE_PARSER = new MessageParser<String>() {
//
// @Override
// public String parse(ByteBuffer buffer) {
// return remaining(buffer);
// }
//
// };
//
// public static String get(ByteBuffer buffer, int length) {
// byte[] bytes = new byte[length];
//
// buffer.get(bytes);
//
// return new String(bytes, UTF_8);
// }
//
// public static String remaining(ByteBuffer buffer) {
// return get(buffer, buffer.remaining());
// }
//
// public static ByteBuffer wrap(String value) {
// return ByteBuffer.wrap(value.getBytes(UTF_8));
// }
//
// public static String repeat(char c, int num) {
// StringBuilder builder = new StringBuilder(num);
//
// for (int i = 0; i < num; i++)
// builder.append(c);
//
// return builder.toString();
// }
//
// }
| import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import static com.paritytrading.nassau.moldudp64.MoldUDP64ClientState.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64ClientStatus.*;
import static com.paritytrading.nassau.Strings.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static org.junit.jupiter.api.Assertions.*;
import com.paritytrading.nassau.FixedClock;
import com.paritytrading.nassau.Messages;
import com.paritytrading.nassau.Strings;
import java.net.SocketAddress;
import java.nio.channels.DatagramChannel;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.AfterEach; | /*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.moldudp64;
@Timeout(value=1, unit=TimeUnit.SECONDS)
class MoldUDP64SessionTest {
private FixedClock clock;
private MoldUDP64DownstreamPacket packet;
| // Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64ClientState.java
// public enum MoldUDP64ClientState {
//
// /**
// * The state of the client in relation to the server is unknown.
// */
// UNKNOWN,
//
// /**
// * The client is yet to achieve synchronization with the server.
// */
// BACKFILL,
//
// /**
// * The client is in synchronization with the server.
// */
// SYNCHRONIZED,
//
// /**
// * The client has fallen out of synchronization with the server.
// */
// GAP_FILL,
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/Strings.java
// public class Strings {
//
// private Strings() {
// }
//
// public static final MessageParser<String> MESSAGE_PARSER = new MessageParser<String>() {
//
// @Override
// public String parse(ByteBuffer buffer) {
// return remaining(buffer);
// }
//
// };
//
// public static String get(ByteBuffer buffer, int length) {
// byte[] bytes = new byte[length];
//
// buffer.get(bytes);
//
// return new String(bytes, UTF_8);
// }
//
// public static String remaining(ByteBuffer buffer) {
// return get(buffer, buffer.remaining());
// }
//
// public static ByteBuffer wrap(String value) {
// return ByteBuffer.wrap(value.getBytes(UTF_8));
// }
//
// public static String repeat(char c, int num) {
// StringBuilder builder = new StringBuilder(num);
//
// for (int i = 0; i < num; i++)
// builder.append(c);
//
// return builder.toString();
// }
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/FixedClock.java
// public class FixedClock implements Clock {
//
// private long currentTimeMillis;
//
// @Override
// public long currentTimeMillis() {
// return currentTimeMillis;
// }
//
// public void setCurrentTimeMillis(long currentTimeMillis) {
// this.currentTimeMillis = currentTimeMillis;
// }
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/Messages.java
// public class Messages<M> implements MessageListener {
//
// private MessageParser<M> parser;
//
// private List<M> messages;
//
// public Messages(MessageParser<M> parser) {
// this.parser = parser;
//
// this.messages = new ArrayList<>();
// }
//
// public List<M> collect() {
// return messages;
// }
//
// @Override
// public void message(ByteBuffer buffer) {
// messages.add(parser.parse(buffer));
// }
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/Strings.java
// public class Strings {
//
// private Strings() {
// }
//
// public static final MessageParser<String> MESSAGE_PARSER = new MessageParser<String>() {
//
// @Override
// public String parse(ByteBuffer buffer) {
// return remaining(buffer);
// }
//
// };
//
// public static String get(ByteBuffer buffer, int length) {
// byte[] bytes = new byte[length];
//
// buffer.get(bytes);
//
// return new String(bytes, UTF_8);
// }
//
// public static String remaining(ByteBuffer buffer) {
// return get(buffer, buffer.remaining());
// }
//
// public static ByteBuffer wrap(String value) {
// return ByteBuffer.wrap(value.getBytes(UTF_8));
// }
//
// public static String repeat(char c, int num) {
// StringBuilder builder = new StringBuilder(num);
//
// for (int i = 0; i < num; i++)
// builder.append(c);
//
// return builder.toString();
// }
//
// }
// Path: libraries/core/src/test/java/com/paritytrading/nassau/moldudp64/MoldUDP64SessionTest.java
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import static com.paritytrading.nassau.moldudp64.MoldUDP64ClientState.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64ClientStatus.*;
import static com.paritytrading.nassau.Strings.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static org.junit.jupiter.api.Assertions.*;
import com.paritytrading.nassau.FixedClock;
import com.paritytrading.nassau.Messages;
import com.paritytrading.nassau.Strings;
import java.net.SocketAddress;
import java.nio.channels.DatagramChannel;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.AfterEach;
/*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.moldudp64;
@Timeout(value=1, unit=TimeUnit.SECONDS)
class MoldUDP64SessionTest {
private FixedClock clock;
private MoldUDP64DownstreamPacket packet;
| private Messages<String> clientMessages; |
paritytrading/nassau | libraries/core/src/test/java/com/paritytrading/nassau/moldudp64/MoldUDP64SessionTest.java | // Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64ClientState.java
// public enum MoldUDP64ClientState {
//
// /**
// * The state of the client in relation to the server is unknown.
// */
// UNKNOWN,
//
// /**
// * The client is yet to achieve synchronization with the server.
// */
// BACKFILL,
//
// /**
// * The client is in synchronization with the server.
// */
// SYNCHRONIZED,
//
// /**
// * The client has fallen out of synchronization with the server.
// */
// GAP_FILL,
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/Strings.java
// public class Strings {
//
// private Strings() {
// }
//
// public static final MessageParser<String> MESSAGE_PARSER = new MessageParser<String>() {
//
// @Override
// public String parse(ByteBuffer buffer) {
// return remaining(buffer);
// }
//
// };
//
// public static String get(ByteBuffer buffer, int length) {
// byte[] bytes = new byte[length];
//
// buffer.get(bytes);
//
// return new String(bytes, UTF_8);
// }
//
// public static String remaining(ByteBuffer buffer) {
// return get(buffer, buffer.remaining());
// }
//
// public static ByteBuffer wrap(String value) {
// return ByteBuffer.wrap(value.getBytes(UTF_8));
// }
//
// public static String repeat(char c, int num) {
// StringBuilder builder = new StringBuilder(num);
//
// for (int i = 0; i < num; i++)
// builder.append(c);
//
// return builder.toString();
// }
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/FixedClock.java
// public class FixedClock implements Clock {
//
// private long currentTimeMillis;
//
// @Override
// public long currentTimeMillis() {
// return currentTimeMillis;
// }
//
// public void setCurrentTimeMillis(long currentTimeMillis) {
// this.currentTimeMillis = currentTimeMillis;
// }
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/Messages.java
// public class Messages<M> implements MessageListener {
//
// private MessageParser<M> parser;
//
// private List<M> messages;
//
// public Messages(MessageParser<M> parser) {
// this.parser = parser;
//
// this.messages = new ArrayList<>();
// }
//
// public List<M> collect() {
// return messages;
// }
//
// @Override
// public void message(ByteBuffer buffer) {
// messages.add(parser.parse(buffer));
// }
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/Strings.java
// public class Strings {
//
// private Strings() {
// }
//
// public static final MessageParser<String> MESSAGE_PARSER = new MessageParser<String>() {
//
// @Override
// public String parse(ByteBuffer buffer) {
// return remaining(buffer);
// }
//
// };
//
// public static String get(ByteBuffer buffer, int length) {
// byte[] bytes = new byte[length];
//
// buffer.get(bytes);
//
// return new String(bytes, UTF_8);
// }
//
// public static String remaining(ByteBuffer buffer) {
// return get(buffer, buffer.remaining());
// }
//
// public static ByteBuffer wrap(String value) {
// return ByteBuffer.wrap(value.getBytes(UTF_8));
// }
//
// public static String repeat(char c, int num) {
// StringBuilder builder = new StringBuilder(num);
//
// for (int i = 0; i < num; i++)
// builder.append(c);
//
// return builder.toString();
// }
//
// }
| import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import static com.paritytrading.nassau.moldudp64.MoldUDP64ClientState.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64ClientStatus.*;
import static com.paritytrading.nassau.Strings.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static org.junit.jupiter.api.Assertions.*;
import com.paritytrading.nassau.FixedClock;
import com.paritytrading.nassau.Messages;
import com.paritytrading.nassau.Strings;
import java.net.SocketAddress;
import java.nio.channels.DatagramChannel;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.AfterEach; | /*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.moldudp64;
@Timeout(value=1, unit=TimeUnit.SECONDS)
class MoldUDP64SessionTest {
private FixedClock clock;
private MoldUDP64DownstreamPacket packet;
private Messages<String> clientMessages;
private MoldUDP64ClientStatus clientStatus;
private MoldUDP64Client client;
private MoldUDP64Server server;
private MoldUDP64RequestServer requestServer;
private MoldUDP64DefaultMessageStore store;
@BeforeEach
void setUp() throws Exception {
DatagramChannel clientChannel = DatagramChannels.openClientChannel();
DatagramChannel clientRequestChannel = DatagramChannels.openClientRequestChannel();
DatagramChannel serverChannel = DatagramChannels.openServerChannel(clientChannel);
DatagramChannel serverRequestChannel = DatagramChannels.openServerRequestChannel();
SocketAddress requestAddress = serverRequestChannel.getLocalAddress();
clock = new FixedClock();
packet = new MoldUDP64DownstreamPacket();
| // Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64ClientState.java
// public enum MoldUDP64ClientState {
//
// /**
// * The state of the client in relation to the server is unknown.
// */
// UNKNOWN,
//
// /**
// * The client is yet to achieve synchronization with the server.
// */
// BACKFILL,
//
// /**
// * The client is in synchronization with the server.
// */
// SYNCHRONIZED,
//
// /**
// * The client has fallen out of synchronization with the server.
// */
// GAP_FILL,
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/Strings.java
// public class Strings {
//
// private Strings() {
// }
//
// public static final MessageParser<String> MESSAGE_PARSER = new MessageParser<String>() {
//
// @Override
// public String parse(ByteBuffer buffer) {
// return remaining(buffer);
// }
//
// };
//
// public static String get(ByteBuffer buffer, int length) {
// byte[] bytes = new byte[length];
//
// buffer.get(bytes);
//
// return new String(bytes, UTF_8);
// }
//
// public static String remaining(ByteBuffer buffer) {
// return get(buffer, buffer.remaining());
// }
//
// public static ByteBuffer wrap(String value) {
// return ByteBuffer.wrap(value.getBytes(UTF_8));
// }
//
// public static String repeat(char c, int num) {
// StringBuilder builder = new StringBuilder(num);
//
// for (int i = 0; i < num; i++)
// builder.append(c);
//
// return builder.toString();
// }
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/FixedClock.java
// public class FixedClock implements Clock {
//
// private long currentTimeMillis;
//
// @Override
// public long currentTimeMillis() {
// return currentTimeMillis;
// }
//
// public void setCurrentTimeMillis(long currentTimeMillis) {
// this.currentTimeMillis = currentTimeMillis;
// }
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/Messages.java
// public class Messages<M> implements MessageListener {
//
// private MessageParser<M> parser;
//
// private List<M> messages;
//
// public Messages(MessageParser<M> parser) {
// this.parser = parser;
//
// this.messages = new ArrayList<>();
// }
//
// public List<M> collect() {
// return messages;
// }
//
// @Override
// public void message(ByteBuffer buffer) {
// messages.add(parser.parse(buffer));
// }
//
// }
//
// Path: libraries/core/src/test/java/com/paritytrading/nassau/Strings.java
// public class Strings {
//
// private Strings() {
// }
//
// public static final MessageParser<String> MESSAGE_PARSER = new MessageParser<String>() {
//
// @Override
// public String parse(ByteBuffer buffer) {
// return remaining(buffer);
// }
//
// };
//
// public static String get(ByteBuffer buffer, int length) {
// byte[] bytes = new byte[length];
//
// buffer.get(bytes);
//
// return new String(bytes, UTF_8);
// }
//
// public static String remaining(ByteBuffer buffer) {
// return get(buffer, buffer.remaining());
// }
//
// public static ByteBuffer wrap(String value) {
// return ByteBuffer.wrap(value.getBytes(UTF_8));
// }
//
// public static String repeat(char c, int num) {
// StringBuilder builder = new StringBuilder(num);
//
// for (int i = 0; i < num; i++)
// builder.append(c);
//
// return builder.toString();
// }
//
// }
// Path: libraries/core/src/test/java/com/paritytrading/nassau/moldudp64/MoldUDP64SessionTest.java
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import static com.paritytrading.nassau.moldudp64.MoldUDP64ClientState.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64ClientStatus.*;
import static com.paritytrading.nassau.Strings.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static org.junit.jupiter.api.Assertions.*;
import com.paritytrading.nassau.FixedClock;
import com.paritytrading.nassau.Messages;
import com.paritytrading.nassau.Strings;
import java.net.SocketAddress;
import java.nio.channels.DatagramChannel;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.AfterEach;
/*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.moldudp64;
@Timeout(value=1, unit=TimeUnit.SECONDS)
class MoldUDP64SessionTest {
private FixedClock clock;
private MoldUDP64DownstreamPacket packet;
private Messages<String> clientMessages;
private MoldUDP64ClientStatus clientStatus;
private MoldUDP64Client client;
private MoldUDP64Server server;
private MoldUDP64RequestServer requestServer;
private MoldUDP64DefaultMessageStore store;
@BeforeEach
void setUp() throws Exception {
DatagramChannel clientChannel = DatagramChannels.openClientChannel();
DatagramChannel clientRequestChannel = DatagramChannels.openClientRequestChannel();
DatagramChannel serverChannel = DatagramChannels.openServerChannel(clientChannel);
DatagramChannel serverRequestChannel = DatagramChannels.openServerRequestChannel();
SocketAddress requestAddress = serverRequestChannel.getLocalAddress();
clock = new FixedClock();
packet = new MoldUDP64DownstreamPacket();
| clientMessages = new Messages<>(Strings.MESSAGE_PARSER); |
paritytrading/nassau | libraries/util/src/main/java/com/paritytrading/nassau/util/BinaryFILE.java | // Path: libraries/core/src/main/java/com/paritytrading/nassau/MessageListener.java
// public interface MessageListener {
//
// /**
// * Receive a message. The message is contained in the buffer between the
// * current position and the limit.
// *
// * @param buffer a buffer
// * @throws IOException if an I/O error occurs
// */
// void message(ByteBuffer buffer) throws IOException;
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/binaryfile/BinaryFILEReader.java
// public class BinaryFILEReader implements Closeable {
//
// private static final int BUFFER_SIZE = 128 * 1024;
//
// private static final int GZIP_BUFFER_SIZE = 64 * 1024;
//
// private final ReadableByteChannel channel;
//
// private final MessageListener listener;
//
// private final ByteBuffer buffer;
//
// /**
// * Create a BinaryFILE reader.
// *
// * @param stream an input stream
// * @param listener a message listener
// */
// public BinaryFILEReader(InputStream stream, MessageListener listener) {
// this(Channels.newChannel(stream), listener);
// }
//
// /**
// * Create a BinaryFILE reader.
// *
// * @param channel an input channel
// * @param listener a message listener
// */
// public BinaryFILEReader(ReadableByteChannel channel, MessageListener listener) {
// this.channel = channel;
// this.listener = listener;
//
// this.buffer = ByteBuffer.allocateDirect(BUFFER_SIZE);
// }
//
// /**
// * Open a BinaryFILE reader. The input file can be either uncompressed or
// * compressed with the GZIP file format.
// *
// * @param file the input file
// * @param listener the message listener
// * @return a BinaryFILE reader
// * @throws IOException if an I/O error occurs
// */
// public static BinaryFILEReader open(File file, MessageListener listener) throws IOException {
// FileInputStream stream = new FileInputStream(file);
//
// if (file.getName().endsWith(".gz"))
// return new BinaryFILEReader(new GZIPInputStream(stream, GZIP_BUFFER_SIZE), listener);
// else
// return new BinaryFILEReader(stream.getChannel(), listener);
// }
//
// /**
// * Read messages. Invoke the message listener on each message.
// *
// * @return the number of bytes read, possibly zero, or {@code -1} if the
// * channel has reached end-of-stream
// * @throws IOException if an I/O error occurs
// */
// public int read() throws IOException {
// int bytes = channel.read(buffer);
//
// if (bytes <= 0)
// return bytes;
//
// buffer.flip();
//
// while (parse());
//
// buffer.compact();
//
// return bytes;
// }
//
// private boolean parse() throws IOException {
// if (buffer.remaining() < 2)
// return false;
//
// buffer.mark();
//
// buffer.order(ByteOrder.BIG_ENDIAN);
//
// int payloadLength = getUnsignedShort(buffer);
//
// if (buffer.remaining() < payloadLength) {
// buffer.reset();
//
// return false;
// }
//
// int limit = buffer.limit();
//
// buffer.limit(buffer.position() + payloadLength);
//
// listener.message(buffer);
//
// buffer.position(buffer.limit());
// buffer.limit(limit);
//
// return true;
// }
//
// /**
// * Close the underlying channel.
// *
// * @throws IOException if an I/O error occurs
// */
// @Override
// public void close() throws IOException {
// channel.close();
// }
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/binaryfile/BinaryFILEStatusListener.java
// public interface BinaryFILEStatusListener {
//
// /**
// * Read a payload with length of zero indicating the End of Session.
// *
// * @throws IOException if an I/O error occurs
// */
// void endOfSession() throws IOException;
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/binaryfile/BinaryFILEStatusParser.java
// public class BinaryFILEStatusParser implements MessageListener {
//
// private final MessageListener listener;
//
// private final BinaryFILEStatusListener statusListener;
//
// /**
// * Create a parser for status events. The parser passes payloads that do
// * not correspond to status events to the message listener.
// *
// * @param listener a message listener
// * @param statusListener a status listener
// */
// public BinaryFILEStatusParser(MessageListener listener, BinaryFILEStatusListener statusListener) {
// this.listener = listener;
//
// this.statusListener = statusListener;
// }
//
// @Override
// public void message(ByteBuffer buffer) throws IOException {
// if (buffer.hasRemaining())
// listener.message(buffer);
// else
// statusListener.endOfSession();
// }
//
// }
| import com.paritytrading.nassau.MessageListener;
import com.paritytrading.nassau.binaryfile.BinaryFILEReader;
import com.paritytrading.nassau.binaryfile.BinaryFILEStatusListener;
import com.paritytrading.nassau.binaryfile.BinaryFILEStatusParser;
import java.io.File;
import java.io.IOException; | /*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.util;
/**
* Utility methods for working with the BinaryFILE 1.00 file format.
*/
public class BinaryFILE {
private BinaryFILE() {
}
/**
* Read messages. Invoke the message listener on each message. Continue
* until either a payload with length of zero indicating the End of Session
* is encountered or the end-of-file is reached.
*
* @param file a file
* @param listener a message listener
* @throws IOException if an I/O error occurs
*/ | // Path: libraries/core/src/main/java/com/paritytrading/nassau/MessageListener.java
// public interface MessageListener {
//
// /**
// * Receive a message. The message is contained in the buffer between the
// * current position and the limit.
// *
// * @param buffer a buffer
// * @throws IOException if an I/O error occurs
// */
// void message(ByteBuffer buffer) throws IOException;
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/binaryfile/BinaryFILEReader.java
// public class BinaryFILEReader implements Closeable {
//
// private static final int BUFFER_SIZE = 128 * 1024;
//
// private static final int GZIP_BUFFER_SIZE = 64 * 1024;
//
// private final ReadableByteChannel channel;
//
// private final MessageListener listener;
//
// private final ByteBuffer buffer;
//
// /**
// * Create a BinaryFILE reader.
// *
// * @param stream an input stream
// * @param listener a message listener
// */
// public BinaryFILEReader(InputStream stream, MessageListener listener) {
// this(Channels.newChannel(stream), listener);
// }
//
// /**
// * Create a BinaryFILE reader.
// *
// * @param channel an input channel
// * @param listener a message listener
// */
// public BinaryFILEReader(ReadableByteChannel channel, MessageListener listener) {
// this.channel = channel;
// this.listener = listener;
//
// this.buffer = ByteBuffer.allocateDirect(BUFFER_SIZE);
// }
//
// /**
// * Open a BinaryFILE reader. The input file can be either uncompressed or
// * compressed with the GZIP file format.
// *
// * @param file the input file
// * @param listener the message listener
// * @return a BinaryFILE reader
// * @throws IOException if an I/O error occurs
// */
// public static BinaryFILEReader open(File file, MessageListener listener) throws IOException {
// FileInputStream stream = new FileInputStream(file);
//
// if (file.getName().endsWith(".gz"))
// return new BinaryFILEReader(new GZIPInputStream(stream, GZIP_BUFFER_SIZE), listener);
// else
// return new BinaryFILEReader(stream.getChannel(), listener);
// }
//
// /**
// * Read messages. Invoke the message listener on each message.
// *
// * @return the number of bytes read, possibly zero, or {@code -1} if the
// * channel has reached end-of-stream
// * @throws IOException if an I/O error occurs
// */
// public int read() throws IOException {
// int bytes = channel.read(buffer);
//
// if (bytes <= 0)
// return bytes;
//
// buffer.flip();
//
// while (parse());
//
// buffer.compact();
//
// return bytes;
// }
//
// private boolean parse() throws IOException {
// if (buffer.remaining() < 2)
// return false;
//
// buffer.mark();
//
// buffer.order(ByteOrder.BIG_ENDIAN);
//
// int payloadLength = getUnsignedShort(buffer);
//
// if (buffer.remaining() < payloadLength) {
// buffer.reset();
//
// return false;
// }
//
// int limit = buffer.limit();
//
// buffer.limit(buffer.position() + payloadLength);
//
// listener.message(buffer);
//
// buffer.position(buffer.limit());
// buffer.limit(limit);
//
// return true;
// }
//
// /**
// * Close the underlying channel.
// *
// * @throws IOException if an I/O error occurs
// */
// @Override
// public void close() throws IOException {
// channel.close();
// }
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/binaryfile/BinaryFILEStatusListener.java
// public interface BinaryFILEStatusListener {
//
// /**
// * Read a payload with length of zero indicating the End of Session.
// *
// * @throws IOException if an I/O error occurs
// */
// void endOfSession() throws IOException;
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/binaryfile/BinaryFILEStatusParser.java
// public class BinaryFILEStatusParser implements MessageListener {
//
// private final MessageListener listener;
//
// private final BinaryFILEStatusListener statusListener;
//
// /**
// * Create a parser for status events. The parser passes payloads that do
// * not correspond to status events to the message listener.
// *
// * @param listener a message listener
// * @param statusListener a status listener
// */
// public BinaryFILEStatusParser(MessageListener listener, BinaryFILEStatusListener statusListener) {
// this.listener = listener;
//
// this.statusListener = statusListener;
// }
//
// @Override
// public void message(ByteBuffer buffer) throws IOException {
// if (buffer.hasRemaining())
// listener.message(buffer);
// else
// statusListener.endOfSession();
// }
//
// }
// Path: libraries/util/src/main/java/com/paritytrading/nassau/util/BinaryFILE.java
import com.paritytrading.nassau.MessageListener;
import com.paritytrading.nassau.binaryfile.BinaryFILEReader;
import com.paritytrading.nassau.binaryfile.BinaryFILEStatusListener;
import com.paritytrading.nassau.binaryfile.BinaryFILEStatusParser;
import java.io.File;
import java.io.IOException;
/*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.util;
/**
* Utility methods for working with the BinaryFILE 1.00 file format.
*/
public class BinaryFILE {
private BinaryFILE() {
}
/**
* Read messages. Invoke the message listener on each message. Continue
* until either a payload with length of zero indicating the End of Session
* is encountered or the end-of-file is reached.
*
* @param file a file
* @param listener a message listener
* @throws IOException if an I/O error occurs
*/ | public static void read(File file, MessageListener listener) throws IOException { |
paritytrading/nassau | libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64DownstreamPacket.java | // Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64.java
// class MoldUDP64 {
//
// static final int MESSAGE_COUNT_HEARTBEAT = 0x0;
//
// static final int MESSAGE_COUNT_END_OF_SESSION = 0xFFFF;
//
// static final int MAX_MESSAGE_COUNT = MESSAGE_COUNT_END_OF_SESSION - 1;
//
// static final int HEADER_LENGTH = 20;
//
// static final int MAX_PAYLOAD_LENGTH = 1400;
//
// static final int SESSION_LENGTH = 10;
//
// private static final byte SPACE = ' ';
//
// static byte[] session(String name) {
// byte[] session = new byte[SESSION_LENGTH];
// fill(session, SPACE);
//
// byte[] bytes = name.getBytes(US_ASCII);
// System.arraycopy(bytes, 0, session, 0, Math.min(bytes.length, session.length));
//
// return session;
// }
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/MessageListener.java
// public interface MessageListener {
//
// /**
// * Receive a message. The message is contained in the buffer between the
// * current position and the limit.
// *
// * @param buffer a buffer
// * @throws IOException if an I/O error occurs
// */
// void message(ByteBuffer buffer) throws IOException;
//
// }
| import static com.paritytrading.foundation.ByteBuffers.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64.*;
import com.paritytrading.nassau.MessageListener;
import java.io.IOException;
import java.nio.ByteBuffer; | /*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.moldudp64;
/**
* An implementation of a MoldUDP64 downstream packet.
*/
public class MoldUDP64DownstreamPacket {
private int messageCount;
private final ByteBuffer payload;
/**
* Create a downstream packet.
*/
public MoldUDP64DownstreamPacket() {
this.messageCount = 0;
this.payload = ByteBuffer.allocateDirect(MAX_PAYLOAD_LENGTH);
}
/**
* Append a message to this downstream packet.
*
* @param buffer a buffer containing a message
* @throws MoldUDP64Exception if the message is too large
*/
public void put(ByteBuffer buffer) throws MoldUDP64Exception {
if (remaining() < buffer.remaining())
throw new MoldUDP64Exception("Buffer overflow");
putUnsignedShort(payload, buffer.remaining());
payload.put(buffer);
messageCount++;
}
/**
* Apply the message listener to each message in this downstream packet.
*
* @param listener a message listener
* @throws IOException if an I/O error occurs in the message listener
*/ | // Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64.java
// class MoldUDP64 {
//
// static final int MESSAGE_COUNT_HEARTBEAT = 0x0;
//
// static final int MESSAGE_COUNT_END_OF_SESSION = 0xFFFF;
//
// static final int MAX_MESSAGE_COUNT = MESSAGE_COUNT_END_OF_SESSION - 1;
//
// static final int HEADER_LENGTH = 20;
//
// static final int MAX_PAYLOAD_LENGTH = 1400;
//
// static final int SESSION_LENGTH = 10;
//
// private static final byte SPACE = ' ';
//
// static byte[] session(String name) {
// byte[] session = new byte[SESSION_LENGTH];
// fill(session, SPACE);
//
// byte[] bytes = name.getBytes(US_ASCII);
// System.arraycopy(bytes, 0, session, 0, Math.min(bytes.length, session.length));
//
// return session;
// }
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/MessageListener.java
// public interface MessageListener {
//
// /**
// * Receive a message. The message is contained in the buffer between the
// * current position and the limit.
// *
// * @param buffer a buffer
// * @throws IOException if an I/O error occurs
// */
// void message(ByteBuffer buffer) throws IOException;
//
// }
// Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64DownstreamPacket.java
import static com.paritytrading.foundation.ByteBuffers.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64.*;
import com.paritytrading.nassau.MessageListener;
import java.io.IOException;
import java.nio.ByteBuffer;
/*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.moldudp64;
/**
* An implementation of a MoldUDP64 downstream packet.
*/
public class MoldUDP64DownstreamPacket {
private int messageCount;
private final ByteBuffer payload;
/**
* Create a downstream packet.
*/
public MoldUDP64DownstreamPacket() {
this.messageCount = 0;
this.payload = ByteBuffer.allocateDirect(MAX_PAYLOAD_LENGTH);
}
/**
* Append a message to this downstream packet.
*
* @param buffer a buffer containing a message
* @throws MoldUDP64Exception if the message is too large
*/
public void put(ByteBuffer buffer) throws MoldUDP64Exception {
if (remaining() < buffer.remaining())
throw new MoldUDP64Exception("Buffer overflow");
putUnsignedShort(payload, buffer.remaining());
payload.put(buffer);
messageCount++;
}
/**
* Apply the message listener to each message in this downstream packet.
*
* @param listener a message listener
* @throws IOException if an I/O error occurs in the message listener
*/ | public void apply(MessageListener listener) throws IOException { |
paritytrading/nassau | libraries/core/src/test/java/com/paritytrading/nassau/soupbintcp/SoupBinTCPClientStatus.java | // Path: libraries/core/src/test/java/com/paritytrading/nassau/Value.java
// public class Value {
//
// private static final ToStringStyle STYLE = new StandardToStringStyle() {
// {
// setUseShortClassName(true);
// setUseFieldNames(false);
// setUseIdentityHashCode(false);
// setContentStart("(");
// setContentEnd(")");
// }
// };
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, STYLE);
// }
//
// }
| import static com.paritytrading.nassau.soupbintcp.SoupBinTCPSessionStatus.*;
import com.paritytrading.nassau.Value;
import java.util.ArrayList;
import java.util.List; | /*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.soupbintcp;
class SoupBinTCPClientStatus implements SoupBinTCPClientStatusListener {
private List<Event> events;
public SoupBinTCPClientStatus() {
this.events = new ArrayList<>();
}
public List<Event> collect() {
return events;
}
@Override
public void loginAccepted(SoupBinTCPClient client, SoupBinTCP.LoginAccepted payload) {
String session = payload.getSession();
long sequenceNumber = payload.getSequenceNumber();
events.add(new LoginAccepted(session, sequenceNumber));
}
@Override
public void loginRejected(SoupBinTCPClient client, SoupBinTCP.LoginRejected payload) {
events.add(new LoginRejected(payload.getRejectReasonCode()));
}
@Override
public void endOfSession(SoupBinTCPClient client) {
events.add(new EndOfSession());
}
@Override
public void heartbeatTimeout(SoupBinTCPClient client) {
events.add(new HeartbeatTimeout());
}
public interface Event {
}
| // Path: libraries/core/src/test/java/com/paritytrading/nassau/Value.java
// public class Value {
//
// private static final ToStringStyle STYLE = new StandardToStringStyle() {
// {
// setUseShortClassName(true);
// setUseFieldNames(false);
// setUseIdentityHashCode(false);
// setContentStart("(");
// setContentEnd(")");
// }
// };
//
// @Override
// public boolean equals(Object obj) {
// return EqualsBuilder.reflectionEquals(this, obj);
// }
//
// @Override
// public int hashCode() {
// return HashCodeBuilder.reflectionHashCode(this);
// }
//
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this, STYLE);
// }
//
// }
// Path: libraries/core/src/test/java/com/paritytrading/nassau/soupbintcp/SoupBinTCPClientStatus.java
import static com.paritytrading.nassau.soupbintcp.SoupBinTCPSessionStatus.*;
import com.paritytrading.nassau.Value;
import java.util.ArrayList;
import java.util.List;
/*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.soupbintcp;
class SoupBinTCPClientStatus implements SoupBinTCPClientStatusListener {
private List<Event> events;
public SoupBinTCPClientStatus() {
this.events = new ArrayList<>();
}
public List<Event> collect() {
return events;
}
@Override
public void loginAccepted(SoupBinTCPClient client, SoupBinTCP.LoginAccepted payload) {
String session = payload.getSession();
long sequenceNumber = payload.getSequenceNumber();
events.add(new LoginAccepted(session, sequenceNumber));
}
@Override
public void loginRejected(SoupBinTCPClient client, SoupBinTCP.LoginRejected payload) {
events.add(new LoginRejected(payload.getRejectReasonCode()));
}
@Override
public void endOfSession(SoupBinTCPClient client) {
events.add(new EndOfSession());
}
@Override
public void heartbeatTimeout(SoupBinTCPClient client) {
events.add(new HeartbeatTimeout());
}
public interface Event {
}
| public static class LoginAccepted extends Value implements Event { |
paritytrading/nassau | libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64Server.java | // Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64.java
// class MoldUDP64 {
//
// static final int MESSAGE_COUNT_HEARTBEAT = 0x0;
//
// static final int MESSAGE_COUNT_END_OF_SESSION = 0xFFFF;
//
// static final int MAX_MESSAGE_COUNT = MESSAGE_COUNT_END_OF_SESSION - 1;
//
// static final int HEADER_LENGTH = 20;
//
// static final int MAX_PAYLOAD_LENGTH = 1400;
//
// static final int SESSION_LENGTH = 10;
//
// private static final byte SPACE = ' ';
//
// static byte[] session(String name) {
// byte[] session = new byte[SESSION_LENGTH];
// fill(session, SPACE);
//
// byte[] bytes = name.getBytes(US_ASCII);
// System.arraycopy(bytes, 0, session, 0, Math.min(bytes.length, session.length));
//
// return session;
// }
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/Clock.java
// public interface Clock {
//
// /**
// * Get the current time in milliseconds.
// *
// * @return the current time in milliseconds
// */
// long currentTimeMillis();
//
// }
| import static com.paritytrading.foundation.ByteBuffers.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64.*;
import com.paritytrading.nassau.Clock;
import java.io.Closeable;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel; | /*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.moldudp64;
/**
* An implementation of a MoldUDP64 server.
*/
public class MoldUDP64Server implements Closeable {
private static final long HEARTBEAT_INTERVAL_MILLIS = 1000;
| // Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64.java
// class MoldUDP64 {
//
// static final int MESSAGE_COUNT_HEARTBEAT = 0x0;
//
// static final int MESSAGE_COUNT_END_OF_SESSION = 0xFFFF;
//
// static final int MAX_MESSAGE_COUNT = MESSAGE_COUNT_END_OF_SESSION - 1;
//
// static final int HEADER_LENGTH = 20;
//
// static final int MAX_PAYLOAD_LENGTH = 1400;
//
// static final int SESSION_LENGTH = 10;
//
// private static final byte SPACE = ' ';
//
// static byte[] session(String name) {
// byte[] session = new byte[SESSION_LENGTH];
// fill(session, SPACE);
//
// byte[] bytes = name.getBytes(US_ASCII);
// System.arraycopy(bytes, 0, session, 0, Math.min(bytes.length, session.length));
//
// return session;
// }
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/Clock.java
// public interface Clock {
//
// /**
// * Get the current time in milliseconds.
// *
// * @return the current time in milliseconds
// */
// long currentTimeMillis();
//
// }
// Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64Server.java
import static com.paritytrading.foundation.ByteBuffers.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64.*;
import com.paritytrading.nassau.Clock;
import java.io.Closeable;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel;
/*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.moldudp64;
/**
* An implementation of a MoldUDP64 server.
*/
public class MoldUDP64Server implements Closeable {
private static final long HEARTBEAT_INTERVAL_MILLIS = 1000;
| private final Clock clock; |
paritytrading/nassau | libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64Server.java | // Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64.java
// class MoldUDP64 {
//
// static final int MESSAGE_COUNT_HEARTBEAT = 0x0;
//
// static final int MESSAGE_COUNT_END_OF_SESSION = 0xFFFF;
//
// static final int MAX_MESSAGE_COUNT = MESSAGE_COUNT_END_OF_SESSION - 1;
//
// static final int HEADER_LENGTH = 20;
//
// static final int MAX_PAYLOAD_LENGTH = 1400;
//
// static final int SESSION_LENGTH = 10;
//
// private static final byte SPACE = ' ';
//
// static byte[] session(String name) {
// byte[] session = new byte[SESSION_LENGTH];
// fill(session, SPACE);
//
// byte[] bytes = name.getBytes(US_ASCII);
// System.arraycopy(bytes, 0, session, 0, Math.min(bytes.length, session.length));
//
// return session;
// }
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/Clock.java
// public interface Clock {
//
// /**
// * Get the current time in milliseconds.
// *
// * @return the current time in milliseconds
// */
// long currentTimeMillis();
//
// }
| import static com.paritytrading.foundation.ByteBuffers.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64.*;
import com.paritytrading.nassau.Clock;
import java.io.Closeable;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel; | /*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.moldudp64;
/**
* An implementation of a MoldUDP64 server.
*/
public class MoldUDP64Server implements Closeable {
private static final long HEARTBEAT_INTERVAL_MILLIS = 1000;
private final Clock clock;
private final DatagramChannel channel;
private final ByteBuffer[] txBuffers;
private final byte[] session;
private long nextSequenceNumber;
private long lastHeartbeatMillis;
/**
* Create a server. The underlying datagram channel must be connected, but
* it can be either blocking or non-blocking.
*
* @param channel the underlying datagram channel
* @param session the session name
*/
public MoldUDP64Server(DatagramChannel channel, String session) {
this(System::currentTimeMillis, channel, session);
}
/**
* Create a server. The underlying datagram channel must be connected, but
* it can be either blocking or non-blocking.
*
* @param clock a clock
* @param channel the underlying datagram channel
* @param session the session name
*/
public MoldUDP64Server(Clock clock, DatagramChannel channel, String session) { | // Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64.java
// class MoldUDP64 {
//
// static final int MESSAGE_COUNT_HEARTBEAT = 0x0;
//
// static final int MESSAGE_COUNT_END_OF_SESSION = 0xFFFF;
//
// static final int MAX_MESSAGE_COUNT = MESSAGE_COUNT_END_OF_SESSION - 1;
//
// static final int HEADER_LENGTH = 20;
//
// static final int MAX_PAYLOAD_LENGTH = 1400;
//
// static final int SESSION_LENGTH = 10;
//
// private static final byte SPACE = ' ';
//
// static byte[] session(String name) {
// byte[] session = new byte[SESSION_LENGTH];
// fill(session, SPACE);
//
// byte[] bytes = name.getBytes(US_ASCII);
// System.arraycopy(bytes, 0, session, 0, Math.min(bytes.length, session.length));
//
// return session;
// }
//
// }
//
// Path: libraries/core/src/main/java/com/paritytrading/nassau/Clock.java
// public interface Clock {
//
// /**
// * Get the current time in milliseconds.
// *
// * @return the current time in milliseconds
// */
// long currentTimeMillis();
//
// }
// Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64Server.java
import static com.paritytrading.foundation.ByteBuffers.*;
import static com.paritytrading.nassau.moldudp64.MoldUDP64.*;
import com.paritytrading.nassau.Clock;
import java.io.Closeable;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel;
/*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.moldudp64;
/**
* An implementation of a MoldUDP64 server.
*/
public class MoldUDP64Server implements Closeable {
private static final long HEARTBEAT_INTERVAL_MILLIS = 1000;
private final Clock clock;
private final DatagramChannel channel;
private final ByteBuffer[] txBuffers;
private final byte[] session;
private long nextSequenceNumber;
private long lastHeartbeatMillis;
/**
* Create a server. The underlying datagram channel must be connected, but
* it can be either blocking or non-blocking.
*
* @param channel the underlying datagram channel
* @param session the session name
*/
public MoldUDP64Server(DatagramChannel channel, String session) {
this(System::currentTimeMillis, channel, session);
}
/**
* Create a server. The underlying datagram channel must be connected, but
* it can be either blocking or non-blocking.
*
* @param clock a clock
* @param channel the underlying datagram channel
* @param session the session name
*/
public MoldUDP64Server(Clock clock, DatagramChannel channel, String session) { | this(clock, channel, MoldUDP64.session(session)); |
paritytrading/nassau | libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64DefaultMessageStore.java | // Path: libraries/core/src/main/java/com/paritytrading/nassau/MessageListener.java
// public interface MessageListener {
//
// /**
// * Receive a message. The message is contained in the buffer between the
// * current position and the limit.
// *
// * @param buffer a buffer
// * @throws IOException if an I/O error occurs
// */
// void message(ByteBuffer buffer) throws IOException;
//
// }
| import static com.paritytrading.foundation.ByteBuffers.*;
import com.paritytrading.nassau.MessageListener;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List; | /*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.moldudp64;
/**
* The default implementation of a MoldUDP64 message store.
*/
public class MoldUDP64DefaultMessageStore implements MoldUDP64MessageStore {
private final List<byte[]> messages;
| // Path: libraries/core/src/main/java/com/paritytrading/nassau/MessageListener.java
// public interface MessageListener {
//
// /**
// * Receive a message. The message is contained in the buffer between the
// * current position and the limit.
// *
// * @param buffer a buffer
// * @throws IOException if an I/O error occurs
// */
// void message(ByteBuffer buffer) throws IOException;
//
// }
// Path: libraries/core/src/main/java/com/paritytrading/nassau/moldudp64/MoldUDP64DefaultMessageStore.java
import static com.paritytrading.foundation.ByteBuffers.*;
import com.paritytrading.nassau.MessageListener;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
/*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.moldudp64;
/**
* The default implementation of a MoldUDP64 message store.
*/
public class MoldUDP64DefaultMessageStore implements MoldUDP64MessageStore {
private final List<byte[]> messages;
| private final MessageListener listener; |
paritytrading/nassau | libraries/core/src/main/java/com/paritytrading/nassau/binaryfile/BinaryFILEReader.java | // Path: libraries/core/src/main/java/com/paritytrading/nassau/MessageListener.java
// public interface MessageListener {
//
// /**
// * Receive a message. The message is contained in the buffer between the
// * current position and the limit.
// *
// * @param buffer a buffer
// * @throws IOException if an I/O error occurs
// */
// void message(ByteBuffer buffer) throws IOException;
//
// }
| import static com.paritytrading.foundation.ByteBuffers.*;
import com.paritytrading.nassau.MessageListener;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.zip.GZIPInputStream; | /*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.binaryfile;
/**
* An implementation of a BinaryFILE reader.
*/
public class BinaryFILEReader implements Closeable {
private static final int BUFFER_SIZE = 128 * 1024;
private static final int GZIP_BUFFER_SIZE = 64 * 1024;
private final ReadableByteChannel channel;
| // Path: libraries/core/src/main/java/com/paritytrading/nassau/MessageListener.java
// public interface MessageListener {
//
// /**
// * Receive a message. The message is contained in the buffer between the
// * current position and the limit.
// *
// * @param buffer a buffer
// * @throws IOException if an I/O error occurs
// */
// void message(ByteBuffer buffer) throws IOException;
//
// }
// Path: libraries/core/src/main/java/com/paritytrading/nassau/binaryfile/BinaryFILEReader.java
import static com.paritytrading.foundation.ByteBuffers.*;
import com.paritytrading.nassau.MessageListener;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.zip.GZIPInputStream;
/*
* Copyright 2014 Nassau authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.paritytrading.nassau.binaryfile;
/**
* An implementation of a BinaryFILE reader.
*/
public class BinaryFILEReader implements Closeable {
private static final int BUFFER_SIZE = 128 * 1024;
private static final int GZIP_BUFFER_SIZE = 64 * 1024;
private final ReadableByteChannel channel;
| private final MessageListener listener; |
tekrei/JavaExamples | DSRMI/src/main/java/dsrmi/server/InformationRetrievalImpl.java | // Path: DSRMI/src/main/java/dsrmi/data/Currency.java
// public class Currency implements java.io.Serializable {
// private float crossOrder;
// private float unit;
// private String isim;
// private String kod;
// private String CurrencyName;
// private String currencyCode;
// private float forexBuying;
// private float forexSelling;
// private float banknoteBuying;
// private float banknoteSelling;
//
// public float getCrossOrder() {
// return crossOrder;
// }
//
// public void setCrossOrder(float crossOrder) {
// this.crossOrder = crossOrder;
// }
//
// public float getUnit() {
// return unit;
// }
//
// public void setUnit(float unit) {
// this.unit = unit;
// }
//
// public String getIsim() {
// return isim;
// }
//
// public void setIsim(String isim) {
// this.isim = isim;
// }
//
// public String getKod() {
// return kod;
// }
//
// public void setKod(String kod) {
// this.kod = kod;
// }
//
// public String getCurrencyName() {
// return CurrencyName;
// }
//
// public void setCurrencyName(String currencyName) {
// this.CurrencyName = currencyName;
// }
//
// public String getCurrencyCode() {
// return currencyCode;
// }
//
// public void setCurrencyCode(String currencyCode) {
// this.currencyCode = currencyCode;
// }
//
// public float getForexBuying() {
// return forexBuying;
// }
//
// public void setForexBuying(float forexBuying) {
// this.forexBuying = forexBuying;
// }
//
// public float getForexSelling() {
// return forexSelling;
// }
//
// public void setForexSelling(float forexSelling) {
// this.forexSelling = forexSelling;
// }
//
// public float getBanknoteBuying() {
// return banknoteBuying;
// }
//
// public void setBanknoteBuying(float banknoteBuying) {
// this.banknoteBuying = banknoteBuying;
// }
//
// public float getBanknoteSelling() {
// return banknoteSelling;
// }
//
// public void setBanknoteSelling(float banknoteSelling) {
// this.banknoteSelling = banknoteSelling;
// }
//
// @Override
// public String toString() {
// return String.format("Currency{CurrencyName='%s', currencyCode='%s', forexBuying=%s, forexSelling=%s}", CurrencyName, currencyCode, forexBuying, forexSelling);
// }
// }
//
// Path: DSRMI/src/main/java/dsrmi/interfaces/InformationRetrieval.java
// public interface InformationRetrieval extends java.rmi.Remote {
//
// String[] getCurrencies() throws java.rmi.RemoteException;
//
// float convertCurrency(String kod1, String kod2, float amount)
// throws java.rmi.RemoteException;
// }
//
// Path: DSRMI/src/main/java/dsrmi/reader/TCMBReader.java
// public class TCMBReader {
//
// public static void main(String[] args) {
// new TCMBReader().getCurrencies();
// }
//
// public List<Currency> getCurrencies() {
// System.out.println("Retrieving the currencies");
// try {
// XmlMapper mapper = XmlMapper.builder()
// .defaultUseWrapper(false)
// .enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
// .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
// .build();
//
// return mapper.readValue(new URL("https://www.tcmb.gov.tr/kurlar/today.xml"), new TypeReference<List<Currency>>() {
// })
// .stream()
// .filter(item -> item.getCurrencyCode() != null)
// .collect(Collectors.toList());
// } catch (Exception e) {
// e.printStackTrace();
// }
// return new ArrayList<>();
// }
// }
| import dsrmi.data.Currency;
import dsrmi.interfaces.InformationRetrieval;
import dsrmi.reader.TCMBReader;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import java.util.List; | package dsrmi.server;
public class InformationRetrievalImpl implements
InformationRetrieval {
| // Path: DSRMI/src/main/java/dsrmi/data/Currency.java
// public class Currency implements java.io.Serializable {
// private float crossOrder;
// private float unit;
// private String isim;
// private String kod;
// private String CurrencyName;
// private String currencyCode;
// private float forexBuying;
// private float forexSelling;
// private float banknoteBuying;
// private float banknoteSelling;
//
// public float getCrossOrder() {
// return crossOrder;
// }
//
// public void setCrossOrder(float crossOrder) {
// this.crossOrder = crossOrder;
// }
//
// public float getUnit() {
// return unit;
// }
//
// public void setUnit(float unit) {
// this.unit = unit;
// }
//
// public String getIsim() {
// return isim;
// }
//
// public void setIsim(String isim) {
// this.isim = isim;
// }
//
// public String getKod() {
// return kod;
// }
//
// public void setKod(String kod) {
// this.kod = kod;
// }
//
// public String getCurrencyName() {
// return CurrencyName;
// }
//
// public void setCurrencyName(String currencyName) {
// this.CurrencyName = currencyName;
// }
//
// public String getCurrencyCode() {
// return currencyCode;
// }
//
// public void setCurrencyCode(String currencyCode) {
// this.currencyCode = currencyCode;
// }
//
// public float getForexBuying() {
// return forexBuying;
// }
//
// public void setForexBuying(float forexBuying) {
// this.forexBuying = forexBuying;
// }
//
// public float getForexSelling() {
// return forexSelling;
// }
//
// public void setForexSelling(float forexSelling) {
// this.forexSelling = forexSelling;
// }
//
// public float getBanknoteBuying() {
// return banknoteBuying;
// }
//
// public void setBanknoteBuying(float banknoteBuying) {
// this.banknoteBuying = banknoteBuying;
// }
//
// public float getBanknoteSelling() {
// return banknoteSelling;
// }
//
// public void setBanknoteSelling(float banknoteSelling) {
// this.banknoteSelling = banknoteSelling;
// }
//
// @Override
// public String toString() {
// return String.format("Currency{CurrencyName='%s', currencyCode='%s', forexBuying=%s, forexSelling=%s}", CurrencyName, currencyCode, forexBuying, forexSelling);
// }
// }
//
// Path: DSRMI/src/main/java/dsrmi/interfaces/InformationRetrieval.java
// public interface InformationRetrieval extends java.rmi.Remote {
//
// String[] getCurrencies() throws java.rmi.RemoteException;
//
// float convertCurrency(String kod1, String kod2, float amount)
// throws java.rmi.RemoteException;
// }
//
// Path: DSRMI/src/main/java/dsrmi/reader/TCMBReader.java
// public class TCMBReader {
//
// public static void main(String[] args) {
// new TCMBReader().getCurrencies();
// }
//
// public List<Currency> getCurrencies() {
// System.out.println("Retrieving the currencies");
// try {
// XmlMapper mapper = XmlMapper.builder()
// .defaultUseWrapper(false)
// .enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
// .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
// .build();
//
// return mapper.readValue(new URL("https://www.tcmb.gov.tr/kurlar/today.xml"), new TypeReference<List<Currency>>() {
// })
// .stream()
// .filter(item -> item.getCurrencyCode() != null)
// .collect(Collectors.toList());
// } catch (Exception e) {
// e.printStackTrace();
// }
// return new ArrayList<>();
// }
// }
// Path: DSRMI/src/main/java/dsrmi/server/InformationRetrievalImpl.java
import dsrmi.data.Currency;
import dsrmi.interfaces.InformationRetrieval;
import dsrmi.reader.TCMBReader;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import java.util.List;
package dsrmi.server;
public class InformationRetrievalImpl implements
InformationRetrieval {
| final List<Currency> currencies = new TCMBReader().getCurrencies(); |
tekrei/JavaExamples | DSRMI/src/main/java/dsrmi/server/InformationRetrievalImpl.java | // Path: DSRMI/src/main/java/dsrmi/data/Currency.java
// public class Currency implements java.io.Serializable {
// private float crossOrder;
// private float unit;
// private String isim;
// private String kod;
// private String CurrencyName;
// private String currencyCode;
// private float forexBuying;
// private float forexSelling;
// private float banknoteBuying;
// private float banknoteSelling;
//
// public float getCrossOrder() {
// return crossOrder;
// }
//
// public void setCrossOrder(float crossOrder) {
// this.crossOrder = crossOrder;
// }
//
// public float getUnit() {
// return unit;
// }
//
// public void setUnit(float unit) {
// this.unit = unit;
// }
//
// public String getIsim() {
// return isim;
// }
//
// public void setIsim(String isim) {
// this.isim = isim;
// }
//
// public String getKod() {
// return kod;
// }
//
// public void setKod(String kod) {
// this.kod = kod;
// }
//
// public String getCurrencyName() {
// return CurrencyName;
// }
//
// public void setCurrencyName(String currencyName) {
// this.CurrencyName = currencyName;
// }
//
// public String getCurrencyCode() {
// return currencyCode;
// }
//
// public void setCurrencyCode(String currencyCode) {
// this.currencyCode = currencyCode;
// }
//
// public float getForexBuying() {
// return forexBuying;
// }
//
// public void setForexBuying(float forexBuying) {
// this.forexBuying = forexBuying;
// }
//
// public float getForexSelling() {
// return forexSelling;
// }
//
// public void setForexSelling(float forexSelling) {
// this.forexSelling = forexSelling;
// }
//
// public float getBanknoteBuying() {
// return banknoteBuying;
// }
//
// public void setBanknoteBuying(float banknoteBuying) {
// this.banknoteBuying = banknoteBuying;
// }
//
// public float getBanknoteSelling() {
// return banknoteSelling;
// }
//
// public void setBanknoteSelling(float banknoteSelling) {
// this.banknoteSelling = banknoteSelling;
// }
//
// @Override
// public String toString() {
// return String.format("Currency{CurrencyName='%s', currencyCode='%s', forexBuying=%s, forexSelling=%s}", CurrencyName, currencyCode, forexBuying, forexSelling);
// }
// }
//
// Path: DSRMI/src/main/java/dsrmi/interfaces/InformationRetrieval.java
// public interface InformationRetrieval extends java.rmi.Remote {
//
// String[] getCurrencies() throws java.rmi.RemoteException;
//
// float convertCurrency(String kod1, String kod2, float amount)
// throws java.rmi.RemoteException;
// }
//
// Path: DSRMI/src/main/java/dsrmi/reader/TCMBReader.java
// public class TCMBReader {
//
// public static void main(String[] args) {
// new TCMBReader().getCurrencies();
// }
//
// public List<Currency> getCurrencies() {
// System.out.println("Retrieving the currencies");
// try {
// XmlMapper mapper = XmlMapper.builder()
// .defaultUseWrapper(false)
// .enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
// .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
// .build();
//
// return mapper.readValue(new URL("https://www.tcmb.gov.tr/kurlar/today.xml"), new TypeReference<List<Currency>>() {
// })
// .stream()
// .filter(item -> item.getCurrencyCode() != null)
// .collect(Collectors.toList());
// } catch (Exception e) {
// e.printStackTrace();
// }
// return new ArrayList<>();
// }
// }
| import dsrmi.data.Currency;
import dsrmi.interfaces.InformationRetrieval;
import dsrmi.reader.TCMBReader;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import java.util.List; | package dsrmi.server;
public class InformationRetrievalImpl implements
InformationRetrieval {
| // Path: DSRMI/src/main/java/dsrmi/data/Currency.java
// public class Currency implements java.io.Serializable {
// private float crossOrder;
// private float unit;
// private String isim;
// private String kod;
// private String CurrencyName;
// private String currencyCode;
// private float forexBuying;
// private float forexSelling;
// private float banknoteBuying;
// private float banknoteSelling;
//
// public float getCrossOrder() {
// return crossOrder;
// }
//
// public void setCrossOrder(float crossOrder) {
// this.crossOrder = crossOrder;
// }
//
// public float getUnit() {
// return unit;
// }
//
// public void setUnit(float unit) {
// this.unit = unit;
// }
//
// public String getIsim() {
// return isim;
// }
//
// public void setIsim(String isim) {
// this.isim = isim;
// }
//
// public String getKod() {
// return kod;
// }
//
// public void setKod(String kod) {
// this.kod = kod;
// }
//
// public String getCurrencyName() {
// return CurrencyName;
// }
//
// public void setCurrencyName(String currencyName) {
// this.CurrencyName = currencyName;
// }
//
// public String getCurrencyCode() {
// return currencyCode;
// }
//
// public void setCurrencyCode(String currencyCode) {
// this.currencyCode = currencyCode;
// }
//
// public float getForexBuying() {
// return forexBuying;
// }
//
// public void setForexBuying(float forexBuying) {
// this.forexBuying = forexBuying;
// }
//
// public float getForexSelling() {
// return forexSelling;
// }
//
// public void setForexSelling(float forexSelling) {
// this.forexSelling = forexSelling;
// }
//
// public float getBanknoteBuying() {
// return banknoteBuying;
// }
//
// public void setBanknoteBuying(float banknoteBuying) {
// this.banknoteBuying = banknoteBuying;
// }
//
// public float getBanknoteSelling() {
// return banknoteSelling;
// }
//
// public void setBanknoteSelling(float banknoteSelling) {
// this.banknoteSelling = banknoteSelling;
// }
//
// @Override
// public String toString() {
// return String.format("Currency{CurrencyName='%s', currencyCode='%s', forexBuying=%s, forexSelling=%s}", CurrencyName, currencyCode, forexBuying, forexSelling);
// }
// }
//
// Path: DSRMI/src/main/java/dsrmi/interfaces/InformationRetrieval.java
// public interface InformationRetrieval extends java.rmi.Remote {
//
// String[] getCurrencies() throws java.rmi.RemoteException;
//
// float convertCurrency(String kod1, String kod2, float amount)
// throws java.rmi.RemoteException;
// }
//
// Path: DSRMI/src/main/java/dsrmi/reader/TCMBReader.java
// public class TCMBReader {
//
// public static void main(String[] args) {
// new TCMBReader().getCurrencies();
// }
//
// public List<Currency> getCurrencies() {
// System.out.println("Retrieving the currencies");
// try {
// XmlMapper mapper = XmlMapper.builder()
// .defaultUseWrapper(false)
// .enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
// .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
// .build();
//
// return mapper.readValue(new URL("https://www.tcmb.gov.tr/kurlar/today.xml"), new TypeReference<List<Currency>>() {
// })
// .stream()
// .filter(item -> item.getCurrencyCode() != null)
// .collect(Collectors.toList());
// } catch (Exception e) {
// e.printStackTrace();
// }
// return new ArrayList<>();
// }
// }
// Path: DSRMI/src/main/java/dsrmi/server/InformationRetrievalImpl.java
import dsrmi.data.Currency;
import dsrmi.interfaces.InformationRetrieval;
import dsrmi.reader.TCMBReader;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import java.util.List;
package dsrmi.server;
public class InformationRetrievalImpl implements
InformationRetrieval {
| final List<Currency> currencies = new TCMBReader().getCurrencies(); |
tekrei/JavaExamples | OnlineTranslator/src/main/java/translator/data/Tureng.java | // Path: OnlineTranslator/src/main/java/translator/utility/HttpUtility.java
// public class HttpUtility {
//
// public static String executePost(String actionURL, List<NameValuePair> postData) {
// try {
// HttpPost method = new HttpPost(actionURL);
// method.setEntity(new UrlEncodedFormEntity(postData));
// return execute(method);
// } catch (Exception e) {
// e.printStackTrace();
// return e.getMessage();
// }
// }
//
// public static String executeGet(String actionURL) {
// try {
// return execute(new HttpGet(actionURL));
// } catch (Exception e) {
// e.printStackTrace();
// return e.getMessage();
// }
// }
//
// private static String execute(HttpRequestBase method) throws IOException {
// method.setHeader("User-Agent", USER_AGENT);
// HttpResponse status = HttpClientBuilder.create().build().execute(method);
// if (status.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
// method.releaseConnection();
// return "CONNECTION ERROR";
// } else {
// BufferedReader rd = new BufferedReader(new InputStreamReader(status.getEntity().getContent()));
//
// StringBuilder result = new StringBuilder();
// String line;
// while ((line = rd.readLine()) != null) {
// result.append(line);
// }
// String response = result.toString();
// method.releaseConnection();
// return response;
// }
// }
//
// }
| import org.jsoup.Jsoup;
import translator.utility.HttpUtility; | package translator.data;
public class Tureng implements Translator {
private final Language[] supportedLanguages = new Language[]{
new Language("English", "english"),
new Language("French", "french"),
new Language("German", "german"),
new Language("Turkish", "turkish")
};
public Language[] getLanguages() {
return supportedLanguages;
}
public String translate(String text, String from, String to) {
try {
String url;
if (from.equals("english")) {
url = "http://www.tureng.com/en/" + to + "-" + from + "/" + text;
} else {
url = "http://www.tureng.com/en/" + from + "-" + to + "/" + text;
} | // Path: OnlineTranslator/src/main/java/translator/utility/HttpUtility.java
// public class HttpUtility {
//
// public static String executePost(String actionURL, List<NameValuePair> postData) {
// try {
// HttpPost method = new HttpPost(actionURL);
// method.setEntity(new UrlEncodedFormEntity(postData));
// return execute(method);
// } catch (Exception e) {
// e.printStackTrace();
// return e.getMessage();
// }
// }
//
// public static String executeGet(String actionURL) {
// try {
// return execute(new HttpGet(actionURL));
// } catch (Exception e) {
// e.printStackTrace();
// return e.getMessage();
// }
// }
//
// private static String execute(HttpRequestBase method) throws IOException {
// method.setHeader("User-Agent", USER_AGENT);
// HttpResponse status = HttpClientBuilder.create().build().execute(method);
// if (status.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
// method.releaseConnection();
// return "CONNECTION ERROR";
// } else {
// BufferedReader rd = new BufferedReader(new InputStreamReader(status.getEntity().getContent()));
//
// StringBuilder result = new StringBuilder();
// String line;
// while ((line = rd.readLine()) != null) {
// result.append(line);
// }
// String response = result.toString();
// method.releaseConnection();
// return response;
// }
// }
//
// }
// Path: OnlineTranslator/src/main/java/translator/data/Tureng.java
import org.jsoup.Jsoup;
import translator.utility.HttpUtility;
package translator.data;
public class Tureng implements Translator {
private final Language[] supportedLanguages = new Language[]{
new Language("English", "english"),
new Language("French", "french"),
new Language("German", "german"),
new Language("Turkish", "turkish")
};
public Language[] getLanguages() {
return supportedLanguages;
}
public String translate(String text, String from, String to) {
try {
String url;
if (from.equals("english")) {
url = "http://www.tureng.com/en/" + to + "-" + from + "/" + text;
} else {
url = "http://www.tureng.com/en/" + from + "-" + to + "/" + text;
} | return Jsoup.parse(HttpUtility.executeGet(url)).select(".tureng-searchresults-col-left").outerHtml(); |
tekrei/JavaExamples | DSRMI/src/main/java/dsrmi/reader/TCMBReader.java | // Path: DSRMI/src/main/java/dsrmi/data/Currency.java
// public class Currency implements java.io.Serializable {
// private float crossOrder;
// private float unit;
// private String isim;
// private String kod;
// private String CurrencyName;
// private String currencyCode;
// private float forexBuying;
// private float forexSelling;
// private float banknoteBuying;
// private float banknoteSelling;
//
// public float getCrossOrder() {
// return crossOrder;
// }
//
// public void setCrossOrder(float crossOrder) {
// this.crossOrder = crossOrder;
// }
//
// public float getUnit() {
// return unit;
// }
//
// public void setUnit(float unit) {
// this.unit = unit;
// }
//
// public String getIsim() {
// return isim;
// }
//
// public void setIsim(String isim) {
// this.isim = isim;
// }
//
// public String getKod() {
// return kod;
// }
//
// public void setKod(String kod) {
// this.kod = kod;
// }
//
// public String getCurrencyName() {
// return CurrencyName;
// }
//
// public void setCurrencyName(String currencyName) {
// this.CurrencyName = currencyName;
// }
//
// public String getCurrencyCode() {
// return currencyCode;
// }
//
// public void setCurrencyCode(String currencyCode) {
// this.currencyCode = currencyCode;
// }
//
// public float getForexBuying() {
// return forexBuying;
// }
//
// public void setForexBuying(float forexBuying) {
// this.forexBuying = forexBuying;
// }
//
// public float getForexSelling() {
// return forexSelling;
// }
//
// public void setForexSelling(float forexSelling) {
// this.forexSelling = forexSelling;
// }
//
// public float getBanknoteBuying() {
// return banknoteBuying;
// }
//
// public void setBanknoteBuying(float banknoteBuying) {
// this.banknoteBuying = banknoteBuying;
// }
//
// public float getBanknoteSelling() {
// return banknoteSelling;
// }
//
// public void setBanknoteSelling(float banknoteSelling) {
// this.banknoteSelling = banknoteSelling;
// }
//
// @Override
// public String toString() {
// return String.format("Currency{CurrencyName='%s', currencyCode='%s', forexBuying=%s, forexSelling=%s}", CurrencyName, currencyCode, forexBuying, forexSelling);
// }
// }
| import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import dsrmi.data.Currency;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors; | package dsrmi.reader;
public class TCMBReader {
public static void main(String[] args) {
new TCMBReader().getCurrencies();
}
| // Path: DSRMI/src/main/java/dsrmi/data/Currency.java
// public class Currency implements java.io.Serializable {
// private float crossOrder;
// private float unit;
// private String isim;
// private String kod;
// private String CurrencyName;
// private String currencyCode;
// private float forexBuying;
// private float forexSelling;
// private float banknoteBuying;
// private float banknoteSelling;
//
// public float getCrossOrder() {
// return crossOrder;
// }
//
// public void setCrossOrder(float crossOrder) {
// this.crossOrder = crossOrder;
// }
//
// public float getUnit() {
// return unit;
// }
//
// public void setUnit(float unit) {
// this.unit = unit;
// }
//
// public String getIsim() {
// return isim;
// }
//
// public void setIsim(String isim) {
// this.isim = isim;
// }
//
// public String getKod() {
// return kod;
// }
//
// public void setKod(String kod) {
// this.kod = kod;
// }
//
// public String getCurrencyName() {
// return CurrencyName;
// }
//
// public void setCurrencyName(String currencyName) {
// this.CurrencyName = currencyName;
// }
//
// public String getCurrencyCode() {
// return currencyCode;
// }
//
// public void setCurrencyCode(String currencyCode) {
// this.currencyCode = currencyCode;
// }
//
// public float getForexBuying() {
// return forexBuying;
// }
//
// public void setForexBuying(float forexBuying) {
// this.forexBuying = forexBuying;
// }
//
// public float getForexSelling() {
// return forexSelling;
// }
//
// public void setForexSelling(float forexSelling) {
// this.forexSelling = forexSelling;
// }
//
// public float getBanknoteBuying() {
// return banknoteBuying;
// }
//
// public void setBanknoteBuying(float banknoteBuying) {
// this.banknoteBuying = banknoteBuying;
// }
//
// public float getBanknoteSelling() {
// return banknoteSelling;
// }
//
// public void setBanknoteSelling(float banknoteSelling) {
// this.banknoteSelling = banknoteSelling;
// }
//
// @Override
// public String toString() {
// return String.format("Currency{CurrencyName='%s', currencyCode='%s', forexBuying=%s, forexSelling=%s}", CurrencyName, currencyCode, forexBuying, forexSelling);
// }
// }
// Path: DSRMI/src/main/java/dsrmi/reader/TCMBReader.java
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import dsrmi.data.Currency;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
package dsrmi.reader;
public class TCMBReader {
public static void main(String[] args) {
new TCMBReader().getCurrencies();
}
| public List<Currency> getCurrencies() { |
tekrei/JavaExamples | OnlineTranslator/src/main/java/translator/data/Seslisozluk.java | // Path: OnlineTranslator/src/main/java/translator/utility/HttpUtility.java
// public class HttpUtility {
//
// public static String executePost(String actionURL, List<NameValuePair> postData) {
// try {
// HttpPost method = new HttpPost(actionURL);
// method.setEntity(new UrlEncodedFormEntity(postData));
// return execute(method);
// } catch (Exception e) {
// e.printStackTrace();
// return e.getMessage();
// }
// }
//
// public static String executeGet(String actionURL) {
// try {
// return execute(new HttpGet(actionURL));
// } catch (Exception e) {
// e.printStackTrace();
// return e.getMessage();
// }
// }
//
// private static String execute(HttpRequestBase method) throws IOException {
// method.setHeader("User-Agent", USER_AGENT);
// HttpResponse status = HttpClientBuilder.create().build().execute(method);
// if (status.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
// method.releaseConnection();
// return "CONNECTION ERROR";
// } else {
// BufferedReader rd = new BufferedReader(new InputStreamReader(status.getEntity().getContent()));
//
// StringBuilder result = new StringBuilder();
// String line;
// while ((line = rd.readLine()) != null) {
// result.append(line);
// }
// String response = result.toString();
// method.releaseConnection();
// return response;
// }
// }
//
// }
| import org.jsoup.Jsoup;
import translator.utility.HttpUtility; | package translator.data;
public class Seslisozluk implements Translator {
private final Language[] supportedLanguages = new Language[]{
new Language("Turkish", "turkish"),
new Language("English", "english")
};
public Language[] getLanguages() {
return supportedLanguages;
}
public String translate(String text, String from, String to) {
try {
String url = "https://www.seslisozluk.net/" + text + "-nedir-ne-demek/"; | // Path: OnlineTranslator/src/main/java/translator/utility/HttpUtility.java
// public class HttpUtility {
//
// public static String executePost(String actionURL, List<NameValuePair> postData) {
// try {
// HttpPost method = new HttpPost(actionURL);
// method.setEntity(new UrlEncodedFormEntity(postData));
// return execute(method);
// } catch (Exception e) {
// e.printStackTrace();
// return e.getMessage();
// }
// }
//
// public static String executeGet(String actionURL) {
// try {
// return execute(new HttpGet(actionURL));
// } catch (Exception e) {
// e.printStackTrace();
// return e.getMessage();
// }
// }
//
// private static String execute(HttpRequestBase method) throws IOException {
// method.setHeader("User-Agent", USER_AGENT);
// HttpResponse status = HttpClientBuilder.create().build().execute(method);
// if (status.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
// method.releaseConnection();
// return "CONNECTION ERROR";
// } else {
// BufferedReader rd = new BufferedReader(new InputStreamReader(status.getEntity().getContent()));
//
// StringBuilder result = new StringBuilder();
// String line;
// while ((line = rd.readLine()) != null) {
// result.append(line);
// }
// String response = result.toString();
// method.releaseConnection();
// return response;
// }
// }
//
// }
// Path: OnlineTranslator/src/main/java/translator/data/Seslisozluk.java
import org.jsoup.Jsoup;
import translator.utility.HttpUtility;
package translator.data;
public class Seslisozluk implements Translator {
private final Language[] supportedLanguages = new Language[]{
new Language("Turkish", "turkish"),
new Language("English", "english")
};
public Language[] getLanguages() {
return supportedLanguages;
}
public String translate(String text, String from, String to) {
try {
String url = "https://www.seslisozluk.net/" + text + "-nedir-ne-demek/"; | return Jsoup.parse(HttpUtility.executeGet(url)).select(".trans-box-shadow").outerHtml(); |
tekrei/JavaExamples | SimpleBrowser/src/main/java/browser/SitePanel.java | // Path: SimpleBrowser/src/main/java/browser/Database.java
// static class Site {
// final String isim;
// final String url;
//
// Site(String _isim, String _url) {
// isim = _isim;
// url = _url;
// }
//
// public String toString() {
// return isim;
// }
// }
| import browser.Database.Site;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList; | package browser;
class SitePanel extends JPanel {
private static final long serialVersionUID = 1L;
private final Main browser;
private JComboBox<String> cmbCategory; | // Path: SimpleBrowser/src/main/java/browser/Database.java
// static class Site {
// final String isim;
// final String url;
//
// Site(String _isim, String _url) {
// isim = _isim;
// url = _url;
// }
//
// public String toString() {
// return isim;
// }
// }
// Path: SimpleBrowser/src/main/java/browser/SitePanel.java
import browser.Database.Site;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
package browser;
class SitePanel extends JPanel {
private static final long serialVersionUID = 1L;
private final Main browser;
private JComboBox<String> cmbCategory; | private JList<Site> lstSites; |
tekrei/JavaExamples | SocketCalculator/src/main/java/socketcalculator/Client.java | // Path: SocketCalculator/src/main/java/socketcalculator/Operation.java
// enum OperationType {
// ADD, MULTIPLY, DIVIDE, SUBTRACT
// }
| import socketcalculator.Operation.OperationType;
import javax.swing.*;
import java.awt.*;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket; | package socketcalculator;
/**
* Client of calculator with Swing based GUI
*/
public class Client extends JFrame {
private JTextField txtNumber1 = null;
private JTextField txtNumber2 = null;
private JLabel lblResult = null; | // Path: SocketCalculator/src/main/java/socketcalculator/Operation.java
// enum OperationType {
// ADD, MULTIPLY, DIVIDE, SUBTRACT
// }
// Path: SocketCalculator/src/main/java/socketcalculator/Client.java
import socketcalculator.Operation.OperationType;
import javax.swing.*;
import java.awt.*;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
package socketcalculator;
/**
* Client of calculator with Swing based GUI
*/
public class Client extends JFrame {
private JTextField txtNumber1 = null;
private JTextField txtNumber2 = null;
private JLabel lblResult = null; | private JComboBox<Operation.OperationType> cmbOperation = null; |
tekrei/JavaExamples | DSRMI/src/main/java/dsrmi/client/RMIManager.java | // Path: DSRMI/src/main/java/dsrmi/interfaces/InformationRetrieval.java
// public interface InformationRetrieval extends java.rmi.Remote {
//
// String[] getCurrencies() throws java.rmi.RemoteException;
//
// float convertCurrency(String kod1, String kod2, float amount)
// throws java.rmi.RemoteException;
// }
| import dsrmi.interfaces.InformationRetrieval;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry; | package dsrmi.client;
public class RMIManager {
private static RMIManager instance = null;
| // Path: DSRMI/src/main/java/dsrmi/interfaces/InformationRetrieval.java
// public interface InformationRetrieval extends java.rmi.Remote {
//
// String[] getCurrencies() throws java.rmi.RemoteException;
//
// float convertCurrency(String kod1, String kod2, float amount)
// throws java.rmi.RemoteException;
// }
// Path: DSRMI/src/main/java/dsrmi/client/RMIManager.java
import dsrmi.interfaces.InformationRetrieval;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
package dsrmi.client;
public class RMIManager {
private static RMIManager instance = null;
| private InformationRetrieval ir; |
tekrei/JavaExamples | OnlineTranslator/src/main/java/translator/Main.java | // Path: OnlineTranslator/src/main/java/translator/data/Language.java
// public class Language {
// private final String description;
// private final String language;
//
// Language(String _desc, String _lang) {
// this.description = _desc;
// this.language = _lang;
// }
//
// public String getLanguage() {
// return language;
// }
//
// public String toString() {
// return description;
// }
// }
//
// Path: OnlineTranslator/src/main/java/translator/data/Translator.java
// public interface Translator {
//
// String translate(String text, String from, String to);
//
// Language[] getLanguages();
// }
//
// Path: OnlineTranslator/src/main/java/translator/data/TranslatorFactory.java
// public class TranslatorFactory {
// public static Vector<Translator> getTranslators() {
// Vector<Translator> translators = new Vector<>();
// translators.add(new Tureng());
// translators.add(new Seslisozluk());
// return translators;
// }
// }
| import translator.data.Language;
import translator.data.Translator;
import translator.data.TranslatorFactory;
import javax.swing.*;
import java.awt.*; | package translator;
/**
* A simple HTTP page request and parsing example
* <p>
* - Apache HttpComponents to request and download page (https://hc.apache.org/)
* - jsoup to parse HTML file (https://jsoup.org/)
*/
public class Main extends JFrame {
private JComboBox<Language> cmbFrom = null;
private JComboBox<Language> cmbTo = null; | // Path: OnlineTranslator/src/main/java/translator/data/Language.java
// public class Language {
// private final String description;
// private final String language;
//
// Language(String _desc, String _lang) {
// this.description = _desc;
// this.language = _lang;
// }
//
// public String getLanguage() {
// return language;
// }
//
// public String toString() {
// return description;
// }
// }
//
// Path: OnlineTranslator/src/main/java/translator/data/Translator.java
// public interface Translator {
//
// String translate(String text, String from, String to);
//
// Language[] getLanguages();
// }
//
// Path: OnlineTranslator/src/main/java/translator/data/TranslatorFactory.java
// public class TranslatorFactory {
// public static Vector<Translator> getTranslators() {
// Vector<Translator> translators = new Vector<>();
// translators.add(new Tureng());
// translators.add(new Seslisozluk());
// return translators;
// }
// }
// Path: OnlineTranslator/src/main/java/translator/Main.java
import translator.data.Language;
import translator.data.Translator;
import translator.data.TranslatorFactory;
import javax.swing.*;
import java.awt.*;
package translator;
/**
* A simple HTTP page request and parsing example
* <p>
* - Apache HttpComponents to request and download page (https://hc.apache.org/)
* - jsoup to parse HTML file (https://jsoup.org/)
*/
public class Main extends JFrame {
private JComboBox<Language> cmbFrom = null;
private JComboBox<Language> cmbTo = null; | private JComboBox<Translator> cmbService = null; |
tekrei/JavaExamples | OnlineTranslator/src/main/java/translator/Main.java | // Path: OnlineTranslator/src/main/java/translator/data/Language.java
// public class Language {
// private final String description;
// private final String language;
//
// Language(String _desc, String _lang) {
// this.description = _desc;
// this.language = _lang;
// }
//
// public String getLanguage() {
// return language;
// }
//
// public String toString() {
// return description;
// }
// }
//
// Path: OnlineTranslator/src/main/java/translator/data/Translator.java
// public interface Translator {
//
// String translate(String text, String from, String to);
//
// Language[] getLanguages();
// }
//
// Path: OnlineTranslator/src/main/java/translator/data/TranslatorFactory.java
// public class TranslatorFactory {
// public static Vector<Translator> getTranslators() {
// Vector<Translator> translators = new Vector<>();
// translators.add(new Tureng());
// translators.add(new Seslisozluk());
// return translators;
// }
// }
| import translator.data.Language;
import translator.data.Translator;
import translator.data.TranslatorFactory;
import javax.swing.*;
import java.awt.*; | package translator;
/**
* A simple HTTP page request and parsing example
* <p>
* - Apache HttpComponents to request and download page (https://hc.apache.org/)
* - jsoup to parse HTML file (https://jsoup.org/)
*/
public class Main extends JFrame {
private JComboBox<Language> cmbFrom = null;
private JComboBox<Language> cmbTo = null;
private JComboBox<Translator> cmbService = null;
private Main() {
super();
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
this.setSize(800, 600);
this.setContentPane(getJContentPane());
this.setTitle("Online Translator");
this.setVisible(true);
}
public static void main(String[] args) {
new Main();
}
private JPanel getJContentPane() {
JPanel jContentPane = new JPanel(null);
cmbFrom = new JComboBox<>();
cmbFrom.setBounds(5, 5, 200, 20);
jContentPane.add(cmbFrom);
cmbTo = new JComboBox<>();
cmbTo.setBounds(210, 5, 200, 20);
jContentPane.add(cmbTo);
| // Path: OnlineTranslator/src/main/java/translator/data/Language.java
// public class Language {
// private final String description;
// private final String language;
//
// Language(String _desc, String _lang) {
// this.description = _desc;
// this.language = _lang;
// }
//
// public String getLanguage() {
// return language;
// }
//
// public String toString() {
// return description;
// }
// }
//
// Path: OnlineTranslator/src/main/java/translator/data/Translator.java
// public interface Translator {
//
// String translate(String text, String from, String to);
//
// Language[] getLanguages();
// }
//
// Path: OnlineTranslator/src/main/java/translator/data/TranslatorFactory.java
// public class TranslatorFactory {
// public static Vector<Translator> getTranslators() {
// Vector<Translator> translators = new Vector<>();
// translators.add(new Tureng());
// translators.add(new Seslisozluk());
// return translators;
// }
// }
// Path: OnlineTranslator/src/main/java/translator/Main.java
import translator.data.Language;
import translator.data.Translator;
import translator.data.TranslatorFactory;
import javax.swing.*;
import java.awt.*;
package translator;
/**
* A simple HTTP page request and parsing example
* <p>
* - Apache HttpComponents to request and download page (https://hc.apache.org/)
* - jsoup to parse HTML file (https://jsoup.org/)
*/
public class Main extends JFrame {
private JComboBox<Language> cmbFrom = null;
private JComboBox<Language> cmbTo = null;
private JComboBox<Translator> cmbService = null;
private Main() {
super();
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
this.setSize(800, 600);
this.setContentPane(getJContentPane());
this.setTitle("Online Translator");
this.setVisible(true);
}
public static void main(String[] args) {
new Main();
}
private JPanel getJContentPane() {
JPanel jContentPane = new JPanel(null);
cmbFrom = new JComboBox<>();
cmbFrom.setBounds(5, 5, 200, 20);
jContentPane.add(cmbFrom);
cmbTo = new JComboBox<>();
cmbTo.setBounds(210, 5, 200, 20);
jContentPane.add(cmbTo);
| cmbService = new JComboBox<>(TranslatorFactory.getTranslators()); |
tekrei/JavaExamples | DB2POJO/src/main/java/db2pojo/generator/PojoGenerator.java | // Path: DB2POJO/src/main/java/db2pojo/database/DBManager.java
// public class DBManager {
//
// private static DBManager _instance;
// private ConnectionPool connectionPool;
//
// private DBManager(String driverName, String databaseURL, String username, String password) {
// try {
// connectionPool = new ConnectionPool(databaseURL, username, password, driverName, 10);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public static void initManager(String surucu, String url, String kullanici, String sifre) {
// _instance = new DBManager(surucu, url, kullanici, sifre);
// }
//
// public static DBManager getInstance() {
// return _instance;
// }
//
// public boolean execute(String sql) {
// Connection conn = null;
//
// try {
// conn = connectionPool.getConnection();
//
// PreparedStatement ps = conn.prepareStatement(sql);
// System.out.println("execute:" + sql);
// return ps.execute();
// } catch (SQLException e) {
// e.printStackTrace();
// } finally {
// if (conn != null) {
// connectionPool.releaseConnection(conn);
// }
// }
// return false;
// }
//
// public long insert(String sql) {
// Connection conn = null;
//
// try {
// conn = connectionPool.getConnection();
//
// PreparedStatement ps = conn.prepareStatement(sql, PreparedStatement.RETURN_GENERATED_KEYS);
//
// ps.executeUpdate();
// ResultSet rs = ps.getGeneratedKeys();
// rs.next();
// long key = rs.getLong(1);
//
// System.out.println("insert:" + sql);
// return key;
//
// } catch (SQLException e) {
// e.printStackTrace();
// } finally {
// if (conn != null) {
// connectionPool.releaseConnection(conn);
// }
// }
// return -1;
// }
//
// public ResultSet executeQuery(String sql) {
// Connection conn = null;
//
// try {
// conn = connectionPool.getConnection();
//
// PreparedStatement ps = conn.prepareStatement(sql);
//
// System.out.println("executeQuery:" + sql);
// return ps.executeQuery();
// } catch (SQLException e) {
// e.printStackTrace();
// } finally {
// if (conn != null) {
// connectionPool.releaseConnection(conn);
// }
// }
// return null;
// }
//
// public ResultSetMetaData getMetadata(String table) {
// Connection conn = null;
//
// try {
// conn = connectionPool.getConnection();
//
// PreparedStatement ps = conn.prepareStatement("SELECT * FROM " + table);
// return ps.executeQuery().getMetaData();
// } catch (SQLException e) {
// e.printStackTrace();
// } finally {
// if (conn != null) {
// connectionPool.releaseConnection(conn);
// }
// }
// return null;
// }
//
// public Connection getConnection() {
// return connectionPool.getConnection();
// }
//
// public String[] getTableNames() {
// Connection conn = null;
//
// ArrayList<String> tables = new ArrayList<>();
//
// try {
// conn = connectionPool.getConnection();
// DatabaseMetaData metaData = conn.getMetaData();
//
// ResultSet rs = metaData.getTables(null, null, null, new String[]{"Table"});
// while (rs.next()) {
// tables.add(rs.getString("TABLE_NAME"));
// }
//
// } catch (SQLException e) {
// e.printStackTrace();
// } finally {
// if (conn != null) {
// connectionPool.releaseConnection(conn);
// }
// }
// return tables.toArray(new String[]{});
// }
// }
| import db2pojo.database.DBManager;
import java.sql.ResultSetMetaData;
import java.util.Locale; | package db2pojo.generator;
/**
* This class generates POJO from parameters
*
* @author emre
*/
public class PojoGenerator {
private static PojoGenerator instance = null;
private PojoGenerator() {
}
public static PojoGenerator getInstance() {
if (instance == null) {
instance = new PojoGenerator();
}
return instance;
}
/**
* This method generated POJO of the table given as parameter
*
* @param tableName table to create POJO from
*/
public String getPojo(String tableName) {
StringBuilder result = new StringBuilder("/*\n* TABLE_NAME: " + tableName + "\n*/\n");
result.append("public class ").append(getClassName(tableName)).append(" {\n");
try { | // Path: DB2POJO/src/main/java/db2pojo/database/DBManager.java
// public class DBManager {
//
// private static DBManager _instance;
// private ConnectionPool connectionPool;
//
// private DBManager(String driverName, String databaseURL, String username, String password) {
// try {
// connectionPool = new ConnectionPool(databaseURL, username, password, driverName, 10);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public static void initManager(String surucu, String url, String kullanici, String sifre) {
// _instance = new DBManager(surucu, url, kullanici, sifre);
// }
//
// public static DBManager getInstance() {
// return _instance;
// }
//
// public boolean execute(String sql) {
// Connection conn = null;
//
// try {
// conn = connectionPool.getConnection();
//
// PreparedStatement ps = conn.prepareStatement(sql);
// System.out.println("execute:" + sql);
// return ps.execute();
// } catch (SQLException e) {
// e.printStackTrace();
// } finally {
// if (conn != null) {
// connectionPool.releaseConnection(conn);
// }
// }
// return false;
// }
//
// public long insert(String sql) {
// Connection conn = null;
//
// try {
// conn = connectionPool.getConnection();
//
// PreparedStatement ps = conn.prepareStatement(sql, PreparedStatement.RETURN_GENERATED_KEYS);
//
// ps.executeUpdate();
// ResultSet rs = ps.getGeneratedKeys();
// rs.next();
// long key = rs.getLong(1);
//
// System.out.println("insert:" + sql);
// return key;
//
// } catch (SQLException e) {
// e.printStackTrace();
// } finally {
// if (conn != null) {
// connectionPool.releaseConnection(conn);
// }
// }
// return -1;
// }
//
// public ResultSet executeQuery(String sql) {
// Connection conn = null;
//
// try {
// conn = connectionPool.getConnection();
//
// PreparedStatement ps = conn.prepareStatement(sql);
//
// System.out.println("executeQuery:" + sql);
// return ps.executeQuery();
// } catch (SQLException e) {
// e.printStackTrace();
// } finally {
// if (conn != null) {
// connectionPool.releaseConnection(conn);
// }
// }
// return null;
// }
//
// public ResultSetMetaData getMetadata(String table) {
// Connection conn = null;
//
// try {
// conn = connectionPool.getConnection();
//
// PreparedStatement ps = conn.prepareStatement("SELECT * FROM " + table);
// return ps.executeQuery().getMetaData();
// } catch (SQLException e) {
// e.printStackTrace();
// } finally {
// if (conn != null) {
// connectionPool.releaseConnection(conn);
// }
// }
// return null;
// }
//
// public Connection getConnection() {
// return connectionPool.getConnection();
// }
//
// public String[] getTableNames() {
// Connection conn = null;
//
// ArrayList<String> tables = new ArrayList<>();
//
// try {
// conn = connectionPool.getConnection();
// DatabaseMetaData metaData = conn.getMetaData();
//
// ResultSet rs = metaData.getTables(null, null, null, new String[]{"Table"});
// while (rs.next()) {
// tables.add(rs.getString("TABLE_NAME"));
// }
//
// } catch (SQLException e) {
// e.printStackTrace();
// } finally {
// if (conn != null) {
// connectionPool.releaseConnection(conn);
// }
// }
// return tables.toArray(new String[]{});
// }
// }
// Path: DB2POJO/src/main/java/db2pojo/generator/PojoGenerator.java
import db2pojo.database.DBManager;
import java.sql.ResultSetMetaData;
import java.util.Locale;
package db2pojo.generator;
/**
* This class generates POJO from parameters
*
* @author emre
*/
public class PojoGenerator {
private static PojoGenerator instance = null;
private PojoGenerator() {
}
public static PojoGenerator getInstance() {
if (instance == null) {
instance = new PojoGenerator();
}
return instance;
}
/**
* This method generated POJO of the table given as parameter
*
* @param tableName table to create POJO from
*/
public String getPojo(String tableName) {
StringBuilder result = new StringBuilder("/*\n* TABLE_NAME: " + tableName + "\n*/\n");
result.append("public class ").append(getClassName(tableName)).append(" {\n");
try { | ResultSetMetaData metaData = DBManager.getInstance().getMetadata(tableName); |
tekrei/JavaExamples | xox/src/main/java/xox/ai/AI.java | // Path: xox/src/main/java/xox/game/Board.java
// public class Board {
// public static final byte HUMAN = -1;
// public static final byte COMPUTER = 1;
// static final byte EMPTY = 0;
// private byte[] board = new byte[9];
//
// public Board() {
//
// }
//
// private Board(byte[] _board) {
// board = _board;
// }
//
// /**
// * Checks if the move applied to an empty place
// *
// * @param move move to make
// * @return if the move is empty or not
// */
// boolean isEmpty(Move move) {
// return board[move.getRow() + (move.getColumn() * 3)] == EMPTY;
// }
//
// public void empty(int r, int c) {
// board[c * 3 + r] = Board.EMPTY;
// }
//
// /**
// * Checks if board is filled or not
// *
// * @return true if board is full
// */
// public boolean isFull() {
// for (int i = 0; i < 9; i++) {
// if (board[i] == EMPTY) {
// return false;
// }
// }
// return true;
// }
//
// /**
// * checks if player is the winner in the board
// *
// * @param player player to check if it is winner on the board
// */
// public boolean isWinner(byte player) {
// // we check if player is the winner on the board
// for (int i = 0; i < 3; i++) {
// // check rows
// if (board[(i * 3)] == player && board[(1) + (i * 3)] == player && board[(2) + (i * 3)] == player) {
// return true;
// }
// // check columns
// if (board[i] == player && board[i + 3] == player && board[i + 6] == player) {
// return true;
// }
// }
// // check both diagonals
// if (board[0] == player && board[4] == player && board[8] == player) {
// return true;
// }
// //not winner
// return board[2] == player && board[4] == player && board[6] == player;
// }
//
// /**
// * Method making the move
// *
// * @param move move to make
// */
// public boolean doMove(Move move) {
// if (board[(move.getColumn() * 3) + move.getRow()] != EMPTY) {
// return false;
// } else {
// board[move.getColumn() * 3 + move.getRow()] = move.getPlayer();
// return true;
// }
// }
//
// Board getClone() {
// return new Board(Arrays.copyOf(board, board.length));
// }
// }
//
// Path: xox/src/main/java/xox/game/Move.java
// public class Move {
//
// private final int row;
//
// private final int column;
//
// private final byte player;
//
// public Move(int r, int c, byte p) {
// super();
// this.row = r;
// this.column = c;
// this.player = p;
// }
//
// byte getPlayer() {
// return player;
// }
//
// public int getRow() {
// return row;
// }
//
// public int getColumn() {
// return column;
// }
//
// }
//
// Path: xox/src/main/java/xox/game/Node.java
// public class Node {
//
// private final Board board;
//
// private Move move = null;
//
// private Node[] children;
//
// public Node(Board b, Move m) {
// board = b;
// move = m;
// generateChildren();
// }
//
// /**
// * Will change the player given as parameter
// *
// * @param player previous player
// */
// private static byte changePlayer(byte player) {
//
// if (player == Board.HUMAN) {
// return Board.COMPUTER;
// } else if (player == Board.COMPUTER) {
// return Board.HUMAN;
// } else {
// throw new IllegalArgumentException("Only " + Board.HUMAN + " or " + Board.COMPUTER + " is allowed.");
// }
// }
//
// public Move getMove() {
// return move;
// }
//
// private byte getPlayer() {
// return (move == null ? Board.HUMAN : changePlayer(move.getPlayer()));
// }
//
// public boolean isLeaf() {
// return children == null || (children.length == 0);
// }
//
// /**
// * Method to calculate value of this node
// *
// * @return value of this node
// */
// public byte getValue() {
// if (board.isWinner(Board.COMPUTER)) {
// return Board.COMPUTER;
// } else if (board.isWinner(Board.HUMAN)) {
// return Board.HUMAN;
// } else {
// return Board.EMPTY;
// }
// }
//
// /**
// * Method to generate children of the node (next possible moves)
// */
// private void generateChildren() {
// ArrayList<Node> c = null;
// for (int x = 0; x < 3; x++) {
// for (int y = 0; y < 3; y++) {
// Move m = new Move(x, y, this.getPlayer());
// if (board.isEmpty(m)) {
// if (c == null) {
// c = new ArrayList<>();
// }
// Board newPos = board.getClone();
// newPos.doMove(m);
// c.add(new Node(newPos, m));
// }
// }
// }
// if (c != null) {
// children = c.toArray(new Node[]{});
// } else {
// children = new Node[0];
// }
// }
//
// public Node[] getChildren() {
// return children;
// }
// }
| import xox.game.Board;
import xox.game.Move;
import xox.game.Node; | package xox.ai;
public class AI {
public static Move getMove(Board board, Move previous) {
// Create the move as Node | // Path: xox/src/main/java/xox/game/Board.java
// public class Board {
// public static final byte HUMAN = -1;
// public static final byte COMPUTER = 1;
// static final byte EMPTY = 0;
// private byte[] board = new byte[9];
//
// public Board() {
//
// }
//
// private Board(byte[] _board) {
// board = _board;
// }
//
// /**
// * Checks if the move applied to an empty place
// *
// * @param move move to make
// * @return if the move is empty or not
// */
// boolean isEmpty(Move move) {
// return board[move.getRow() + (move.getColumn() * 3)] == EMPTY;
// }
//
// public void empty(int r, int c) {
// board[c * 3 + r] = Board.EMPTY;
// }
//
// /**
// * Checks if board is filled or not
// *
// * @return true if board is full
// */
// public boolean isFull() {
// for (int i = 0; i < 9; i++) {
// if (board[i] == EMPTY) {
// return false;
// }
// }
// return true;
// }
//
// /**
// * checks if player is the winner in the board
// *
// * @param player player to check if it is winner on the board
// */
// public boolean isWinner(byte player) {
// // we check if player is the winner on the board
// for (int i = 0; i < 3; i++) {
// // check rows
// if (board[(i * 3)] == player && board[(1) + (i * 3)] == player && board[(2) + (i * 3)] == player) {
// return true;
// }
// // check columns
// if (board[i] == player && board[i + 3] == player && board[i + 6] == player) {
// return true;
// }
// }
// // check both diagonals
// if (board[0] == player && board[4] == player && board[8] == player) {
// return true;
// }
// //not winner
// return board[2] == player && board[4] == player && board[6] == player;
// }
//
// /**
// * Method making the move
// *
// * @param move move to make
// */
// public boolean doMove(Move move) {
// if (board[(move.getColumn() * 3) + move.getRow()] != EMPTY) {
// return false;
// } else {
// board[move.getColumn() * 3 + move.getRow()] = move.getPlayer();
// return true;
// }
// }
//
// Board getClone() {
// return new Board(Arrays.copyOf(board, board.length));
// }
// }
//
// Path: xox/src/main/java/xox/game/Move.java
// public class Move {
//
// private final int row;
//
// private final int column;
//
// private final byte player;
//
// public Move(int r, int c, byte p) {
// super();
// this.row = r;
// this.column = c;
// this.player = p;
// }
//
// byte getPlayer() {
// return player;
// }
//
// public int getRow() {
// return row;
// }
//
// public int getColumn() {
// return column;
// }
//
// }
//
// Path: xox/src/main/java/xox/game/Node.java
// public class Node {
//
// private final Board board;
//
// private Move move = null;
//
// private Node[] children;
//
// public Node(Board b, Move m) {
// board = b;
// move = m;
// generateChildren();
// }
//
// /**
// * Will change the player given as parameter
// *
// * @param player previous player
// */
// private static byte changePlayer(byte player) {
//
// if (player == Board.HUMAN) {
// return Board.COMPUTER;
// } else if (player == Board.COMPUTER) {
// return Board.HUMAN;
// } else {
// throw new IllegalArgumentException("Only " + Board.HUMAN + " or " + Board.COMPUTER + " is allowed.");
// }
// }
//
// public Move getMove() {
// return move;
// }
//
// private byte getPlayer() {
// return (move == null ? Board.HUMAN : changePlayer(move.getPlayer()));
// }
//
// public boolean isLeaf() {
// return children == null || (children.length == 0);
// }
//
// /**
// * Method to calculate value of this node
// *
// * @return value of this node
// */
// public byte getValue() {
// if (board.isWinner(Board.COMPUTER)) {
// return Board.COMPUTER;
// } else if (board.isWinner(Board.HUMAN)) {
// return Board.HUMAN;
// } else {
// return Board.EMPTY;
// }
// }
//
// /**
// * Method to generate children of the node (next possible moves)
// */
// private void generateChildren() {
// ArrayList<Node> c = null;
// for (int x = 0; x < 3; x++) {
// for (int y = 0; y < 3; y++) {
// Move m = new Move(x, y, this.getPlayer());
// if (board.isEmpty(m)) {
// if (c == null) {
// c = new ArrayList<>();
// }
// Board newPos = board.getClone();
// newPos.doMove(m);
// c.add(new Node(newPos, m));
// }
// }
// }
// if (c != null) {
// children = c.toArray(new Node[]{});
// } else {
// children = new Node[0];
// }
// }
//
// public Node[] getChildren() {
// return children;
// }
// }
// Path: xox/src/main/java/xox/ai/AI.java
import xox.game.Board;
import xox.game.Move;
import xox.game.Node;
package xox.ai;
public class AI {
public static Move getMove(Board board, Move previous) {
// Create the move as Node | Node root = new Node(board, previous); |
tekrei/JavaExamples | SimpleBrowser/src/main/java/browser/SiteButtonPanel.java | // Path: SimpleBrowser/src/main/java/browser/Database.java
// static class Site {
// final String isim;
// final String url;
//
// Site(String _isim, String _url) {
// isim = _isim;
// url = _url;
// }
//
// public String toString() {
// return isim;
// }
// }
| import browser.Database.Site;
import javax.swing.*; | package browser;
class SiteButtonPanel extends JPanel {
private static final long serialVersionUID = 1L;
private final Main tarayici;
SiteButtonPanel(Main _t) {
tarayici = _t;
initialize();
}
private void initialize() {
JButton btn = new JButton("Add");
btn.addActionListener(e -> {
String ad = (String) JOptionPane.showInputDialog(tarayici, "Site adı:", "Site adı",
JOptionPane.PLAIN_MESSAGE, null, null, null);
String adres = (String) JOptionPane.showInputDialog(tarayici, "Site adresi:", "Site adresi",
JOptionPane.PLAIN_MESSAGE, null, null, null);
// If a string was returned, say so.
if ((ad != null) && (ad.length() > 0) && ((adres != null) && (adres.length() > 0))) { | // Path: SimpleBrowser/src/main/java/browser/Database.java
// static class Site {
// final String isim;
// final String url;
//
// Site(String _isim, String _url) {
// isim = _isim;
// url = _url;
// }
//
// public String toString() {
// return isim;
// }
// }
// Path: SimpleBrowser/src/main/java/browser/SiteButtonPanel.java
import browser.Database.Site;
import javax.swing.*;
package browser;
class SiteButtonPanel extends JPanel {
private static final long serialVersionUID = 1L;
private final Main tarayici;
SiteButtonPanel(Main _t) {
tarayici = _t;
initialize();
}
private void initialize() {
JButton btn = new JButton("Add");
btn.addActionListener(e -> {
String ad = (String) JOptionPane.showInputDialog(tarayici, "Site adı:", "Site adı",
JOptionPane.PLAIN_MESSAGE, null, null, null);
String adres = (String) JOptionPane.showInputDialog(tarayici, "Site adresi:", "Site adresi",
JOptionPane.PLAIN_MESSAGE, null, null, null);
// If a string was returned, say so.
if ((ad != null) && (ad.length() > 0) && ((adres != null) && (adres.length() > 0))) { | tarayici.addSite(new Site(ad, adres)); |
tekrei/JavaExamples | ThreadSync/src/main/java/ds/Main.java | // Path: ThreadSync/src/main/java/ds/producer/FlourProducer.java
// public class FlourProducer extends Thread {
//
// private final Silo silo;
//
// public FlourProducer(Silo silo) {
// super("Flour Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/OilProducer.java
// public class OilProducer extends Thread {
//
// private final Silo silo;
//
// public OilProducer(Silo silo) {
// super("Oil Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/SugarProducer.java
// public class SugarProducer extends Thread {
//
// private final Silo silo;
//
// public SugarProducer(Silo silo) {
// super("Sugar Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HalvahShop.java
// public class HalvahShop extends Thread {
//
// private final Silo oilSilo;
// private final Silo flourSilo;
// private final Silo sugarSilo;
//
// public HalvahShop(Silo osilo, Silo fsilo, Silo ssilo) {
// super("Halvah");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// this.sugarSilo = ssilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //2 unit oil
// oilSilo.get();
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// //3 unit sugar
// sugarSilo.get();
// sugarSilo.get();
// sugarSilo.get();
// }
// }
//
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HotFlakyPastyShop.java
// public class HotFlakyPastyShop extends Thread {
//
// private final Silo flourSilo;
// private final Silo oilSilo;
//
// public HotFlakyPastyShop(Silo osilo, Silo fsilo) {
// super("Hot Flaky Pasty");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //1 unit oil
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/silo/Silo.java
// public class Silo {
// //make the producers wait when it exceedes to 20 unit
// private final String what;
// private int unit;
//
// public Silo(String what) {
// super();
// this.what = what;
// }
//
// public synchronized void get() {
// // we don't have any product at hand
// while (unit == 0) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit--;
// System.out.println(Thread.currentThread().getName() + " getting " + this.what);
// notify();
// }
//
// public synchronized void put() {
// while (unit == 20) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit++;
// System.out.println(Thread.currentThread().getName() + " putting " + this.what);
// notify();
// }
//
// public String toString() {
// return what + ":" + unit;
// }
// }
| import ds.producer.FlourProducer;
import ds.producer.OilProducer;
import ds.producer.SugarProducer;
import ds.shop.HalvahShop;
import ds.shop.HotFlakyPastyShop;
import ds.silo.Silo; | package ds;
public class Main {
public static void main(String[] args) { | // Path: ThreadSync/src/main/java/ds/producer/FlourProducer.java
// public class FlourProducer extends Thread {
//
// private final Silo silo;
//
// public FlourProducer(Silo silo) {
// super("Flour Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/OilProducer.java
// public class OilProducer extends Thread {
//
// private final Silo silo;
//
// public OilProducer(Silo silo) {
// super("Oil Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/SugarProducer.java
// public class SugarProducer extends Thread {
//
// private final Silo silo;
//
// public SugarProducer(Silo silo) {
// super("Sugar Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HalvahShop.java
// public class HalvahShop extends Thread {
//
// private final Silo oilSilo;
// private final Silo flourSilo;
// private final Silo sugarSilo;
//
// public HalvahShop(Silo osilo, Silo fsilo, Silo ssilo) {
// super("Halvah");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// this.sugarSilo = ssilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //2 unit oil
// oilSilo.get();
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// //3 unit sugar
// sugarSilo.get();
// sugarSilo.get();
// sugarSilo.get();
// }
// }
//
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HotFlakyPastyShop.java
// public class HotFlakyPastyShop extends Thread {
//
// private final Silo flourSilo;
// private final Silo oilSilo;
//
// public HotFlakyPastyShop(Silo osilo, Silo fsilo) {
// super("Hot Flaky Pasty");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //1 unit oil
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/silo/Silo.java
// public class Silo {
// //make the producers wait when it exceedes to 20 unit
// private final String what;
// private int unit;
//
// public Silo(String what) {
// super();
// this.what = what;
// }
//
// public synchronized void get() {
// // we don't have any product at hand
// while (unit == 0) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit--;
// System.out.println(Thread.currentThread().getName() + " getting " + this.what);
// notify();
// }
//
// public synchronized void put() {
// while (unit == 20) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit++;
// System.out.println(Thread.currentThread().getName() + " putting " + this.what);
// notify();
// }
//
// public String toString() {
// return what + ":" + unit;
// }
// }
// Path: ThreadSync/src/main/java/ds/Main.java
import ds.producer.FlourProducer;
import ds.producer.OilProducer;
import ds.producer.SugarProducer;
import ds.shop.HalvahShop;
import ds.shop.HotFlakyPastyShop;
import ds.silo.Silo;
package ds;
public class Main {
public static void main(String[] args) { | Silo sugarSilo = new Silo("Sugar"); |
tekrei/JavaExamples | ThreadSync/src/main/java/ds/Main.java | // Path: ThreadSync/src/main/java/ds/producer/FlourProducer.java
// public class FlourProducer extends Thread {
//
// private final Silo silo;
//
// public FlourProducer(Silo silo) {
// super("Flour Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/OilProducer.java
// public class OilProducer extends Thread {
//
// private final Silo silo;
//
// public OilProducer(Silo silo) {
// super("Oil Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/SugarProducer.java
// public class SugarProducer extends Thread {
//
// private final Silo silo;
//
// public SugarProducer(Silo silo) {
// super("Sugar Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HalvahShop.java
// public class HalvahShop extends Thread {
//
// private final Silo oilSilo;
// private final Silo flourSilo;
// private final Silo sugarSilo;
//
// public HalvahShop(Silo osilo, Silo fsilo, Silo ssilo) {
// super("Halvah");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// this.sugarSilo = ssilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //2 unit oil
// oilSilo.get();
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// //3 unit sugar
// sugarSilo.get();
// sugarSilo.get();
// sugarSilo.get();
// }
// }
//
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HotFlakyPastyShop.java
// public class HotFlakyPastyShop extends Thread {
//
// private final Silo flourSilo;
// private final Silo oilSilo;
//
// public HotFlakyPastyShop(Silo osilo, Silo fsilo) {
// super("Hot Flaky Pasty");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //1 unit oil
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/silo/Silo.java
// public class Silo {
// //make the producers wait when it exceedes to 20 unit
// private final String what;
// private int unit;
//
// public Silo(String what) {
// super();
// this.what = what;
// }
//
// public synchronized void get() {
// // we don't have any product at hand
// while (unit == 0) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit--;
// System.out.println(Thread.currentThread().getName() + " getting " + this.what);
// notify();
// }
//
// public synchronized void put() {
// while (unit == 20) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit++;
// System.out.println(Thread.currentThread().getName() + " putting " + this.what);
// notify();
// }
//
// public String toString() {
// return what + ":" + unit;
// }
// }
| import ds.producer.FlourProducer;
import ds.producer.OilProducer;
import ds.producer.SugarProducer;
import ds.shop.HalvahShop;
import ds.shop.HotFlakyPastyShop;
import ds.silo.Silo; | package ds;
public class Main {
public static void main(String[] args) {
Silo sugarSilo = new Silo("Sugar");
Silo oilSilo = new Silo("Oil");
Silo flourSilo = new Silo("Flour");
| // Path: ThreadSync/src/main/java/ds/producer/FlourProducer.java
// public class FlourProducer extends Thread {
//
// private final Silo silo;
//
// public FlourProducer(Silo silo) {
// super("Flour Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/OilProducer.java
// public class OilProducer extends Thread {
//
// private final Silo silo;
//
// public OilProducer(Silo silo) {
// super("Oil Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/SugarProducer.java
// public class SugarProducer extends Thread {
//
// private final Silo silo;
//
// public SugarProducer(Silo silo) {
// super("Sugar Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HalvahShop.java
// public class HalvahShop extends Thread {
//
// private final Silo oilSilo;
// private final Silo flourSilo;
// private final Silo sugarSilo;
//
// public HalvahShop(Silo osilo, Silo fsilo, Silo ssilo) {
// super("Halvah");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// this.sugarSilo = ssilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //2 unit oil
// oilSilo.get();
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// //3 unit sugar
// sugarSilo.get();
// sugarSilo.get();
// sugarSilo.get();
// }
// }
//
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HotFlakyPastyShop.java
// public class HotFlakyPastyShop extends Thread {
//
// private final Silo flourSilo;
// private final Silo oilSilo;
//
// public HotFlakyPastyShop(Silo osilo, Silo fsilo) {
// super("Hot Flaky Pasty");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //1 unit oil
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/silo/Silo.java
// public class Silo {
// //make the producers wait when it exceedes to 20 unit
// private final String what;
// private int unit;
//
// public Silo(String what) {
// super();
// this.what = what;
// }
//
// public synchronized void get() {
// // we don't have any product at hand
// while (unit == 0) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit--;
// System.out.println(Thread.currentThread().getName() + " getting " + this.what);
// notify();
// }
//
// public synchronized void put() {
// while (unit == 20) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit++;
// System.out.println(Thread.currentThread().getName() + " putting " + this.what);
// notify();
// }
//
// public String toString() {
// return what + ":" + unit;
// }
// }
// Path: ThreadSync/src/main/java/ds/Main.java
import ds.producer.FlourProducer;
import ds.producer.OilProducer;
import ds.producer.SugarProducer;
import ds.shop.HalvahShop;
import ds.shop.HotFlakyPastyShop;
import ds.silo.Silo;
package ds;
public class Main {
public static void main(String[] args) {
Silo sugarSilo = new Silo("Sugar");
Silo oilSilo = new Silo("Oil");
Silo flourSilo = new Silo("Flour");
| new SugarProducer(sugarSilo).start(); |
tekrei/JavaExamples | ThreadSync/src/main/java/ds/Main.java | // Path: ThreadSync/src/main/java/ds/producer/FlourProducer.java
// public class FlourProducer extends Thread {
//
// private final Silo silo;
//
// public FlourProducer(Silo silo) {
// super("Flour Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/OilProducer.java
// public class OilProducer extends Thread {
//
// private final Silo silo;
//
// public OilProducer(Silo silo) {
// super("Oil Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/SugarProducer.java
// public class SugarProducer extends Thread {
//
// private final Silo silo;
//
// public SugarProducer(Silo silo) {
// super("Sugar Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HalvahShop.java
// public class HalvahShop extends Thread {
//
// private final Silo oilSilo;
// private final Silo flourSilo;
// private final Silo sugarSilo;
//
// public HalvahShop(Silo osilo, Silo fsilo, Silo ssilo) {
// super("Halvah");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// this.sugarSilo = ssilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //2 unit oil
// oilSilo.get();
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// //3 unit sugar
// sugarSilo.get();
// sugarSilo.get();
// sugarSilo.get();
// }
// }
//
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HotFlakyPastyShop.java
// public class HotFlakyPastyShop extends Thread {
//
// private final Silo flourSilo;
// private final Silo oilSilo;
//
// public HotFlakyPastyShop(Silo osilo, Silo fsilo) {
// super("Hot Flaky Pasty");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //1 unit oil
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/silo/Silo.java
// public class Silo {
// //make the producers wait when it exceedes to 20 unit
// private final String what;
// private int unit;
//
// public Silo(String what) {
// super();
// this.what = what;
// }
//
// public synchronized void get() {
// // we don't have any product at hand
// while (unit == 0) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit--;
// System.out.println(Thread.currentThread().getName() + " getting " + this.what);
// notify();
// }
//
// public synchronized void put() {
// while (unit == 20) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit++;
// System.out.println(Thread.currentThread().getName() + " putting " + this.what);
// notify();
// }
//
// public String toString() {
// return what + ":" + unit;
// }
// }
| import ds.producer.FlourProducer;
import ds.producer.OilProducer;
import ds.producer.SugarProducer;
import ds.shop.HalvahShop;
import ds.shop.HotFlakyPastyShop;
import ds.silo.Silo; | package ds;
public class Main {
public static void main(String[] args) {
Silo sugarSilo = new Silo("Sugar");
Silo oilSilo = new Silo("Oil");
Silo flourSilo = new Silo("Flour");
new SugarProducer(sugarSilo).start(); | // Path: ThreadSync/src/main/java/ds/producer/FlourProducer.java
// public class FlourProducer extends Thread {
//
// private final Silo silo;
//
// public FlourProducer(Silo silo) {
// super("Flour Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/OilProducer.java
// public class OilProducer extends Thread {
//
// private final Silo silo;
//
// public OilProducer(Silo silo) {
// super("Oil Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/SugarProducer.java
// public class SugarProducer extends Thread {
//
// private final Silo silo;
//
// public SugarProducer(Silo silo) {
// super("Sugar Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HalvahShop.java
// public class HalvahShop extends Thread {
//
// private final Silo oilSilo;
// private final Silo flourSilo;
// private final Silo sugarSilo;
//
// public HalvahShop(Silo osilo, Silo fsilo, Silo ssilo) {
// super("Halvah");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// this.sugarSilo = ssilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //2 unit oil
// oilSilo.get();
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// //3 unit sugar
// sugarSilo.get();
// sugarSilo.get();
// sugarSilo.get();
// }
// }
//
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HotFlakyPastyShop.java
// public class HotFlakyPastyShop extends Thread {
//
// private final Silo flourSilo;
// private final Silo oilSilo;
//
// public HotFlakyPastyShop(Silo osilo, Silo fsilo) {
// super("Hot Flaky Pasty");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //1 unit oil
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/silo/Silo.java
// public class Silo {
// //make the producers wait when it exceedes to 20 unit
// private final String what;
// private int unit;
//
// public Silo(String what) {
// super();
// this.what = what;
// }
//
// public synchronized void get() {
// // we don't have any product at hand
// while (unit == 0) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit--;
// System.out.println(Thread.currentThread().getName() + " getting " + this.what);
// notify();
// }
//
// public synchronized void put() {
// while (unit == 20) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit++;
// System.out.println(Thread.currentThread().getName() + " putting " + this.what);
// notify();
// }
//
// public String toString() {
// return what + ":" + unit;
// }
// }
// Path: ThreadSync/src/main/java/ds/Main.java
import ds.producer.FlourProducer;
import ds.producer.OilProducer;
import ds.producer.SugarProducer;
import ds.shop.HalvahShop;
import ds.shop.HotFlakyPastyShop;
import ds.silo.Silo;
package ds;
public class Main {
public static void main(String[] args) {
Silo sugarSilo = new Silo("Sugar");
Silo oilSilo = new Silo("Oil");
Silo flourSilo = new Silo("Flour");
new SugarProducer(sugarSilo).start(); | new OilProducer(oilSilo).start(); |
tekrei/JavaExamples | ThreadSync/src/main/java/ds/Main.java | // Path: ThreadSync/src/main/java/ds/producer/FlourProducer.java
// public class FlourProducer extends Thread {
//
// private final Silo silo;
//
// public FlourProducer(Silo silo) {
// super("Flour Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/OilProducer.java
// public class OilProducer extends Thread {
//
// private final Silo silo;
//
// public OilProducer(Silo silo) {
// super("Oil Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/SugarProducer.java
// public class SugarProducer extends Thread {
//
// private final Silo silo;
//
// public SugarProducer(Silo silo) {
// super("Sugar Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HalvahShop.java
// public class HalvahShop extends Thread {
//
// private final Silo oilSilo;
// private final Silo flourSilo;
// private final Silo sugarSilo;
//
// public HalvahShop(Silo osilo, Silo fsilo, Silo ssilo) {
// super("Halvah");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// this.sugarSilo = ssilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //2 unit oil
// oilSilo.get();
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// //3 unit sugar
// sugarSilo.get();
// sugarSilo.get();
// sugarSilo.get();
// }
// }
//
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HotFlakyPastyShop.java
// public class HotFlakyPastyShop extends Thread {
//
// private final Silo flourSilo;
// private final Silo oilSilo;
//
// public HotFlakyPastyShop(Silo osilo, Silo fsilo) {
// super("Hot Flaky Pasty");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //1 unit oil
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/silo/Silo.java
// public class Silo {
// //make the producers wait when it exceedes to 20 unit
// private final String what;
// private int unit;
//
// public Silo(String what) {
// super();
// this.what = what;
// }
//
// public synchronized void get() {
// // we don't have any product at hand
// while (unit == 0) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit--;
// System.out.println(Thread.currentThread().getName() + " getting " + this.what);
// notify();
// }
//
// public synchronized void put() {
// while (unit == 20) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit++;
// System.out.println(Thread.currentThread().getName() + " putting " + this.what);
// notify();
// }
//
// public String toString() {
// return what + ":" + unit;
// }
// }
| import ds.producer.FlourProducer;
import ds.producer.OilProducer;
import ds.producer.SugarProducer;
import ds.shop.HalvahShop;
import ds.shop.HotFlakyPastyShop;
import ds.silo.Silo; | package ds;
public class Main {
public static void main(String[] args) {
Silo sugarSilo = new Silo("Sugar");
Silo oilSilo = new Silo("Oil");
Silo flourSilo = new Silo("Flour");
new SugarProducer(sugarSilo).start();
new OilProducer(oilSilo).start(); | // Path: ThreadSync/src/main/java/ds/producer/FlourProducer.java
// public class FlourProducer extends Thread {
//
// private final Silo silo;
//
// public FlourProducer(Silo silo) {
// super("Flour Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/OilProducer.java
// public class OilProducer extends Thread {
//
// private final Silo silo;
//
// public OilProducer(Silo silo) {
// super("Oil Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/SugarProducer.java
// public class SugarProducer extends Thread {
//
// private final Silo silo;
//
// public SugarProducer(Silo silo) {
// super("Sugar Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HalvahShop.java
// public class HalvahShop extends Thread {
//
// private final Silo oilSilo;
// private final Silo flourSilo;
// private final Silo sugarSilo;
//
// public HalvahShop(Silo osilo, Silo fsilo, Silo ssilo) {
// super("Halvah");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// this.sugarSilo = ssilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //2 unit oil
// oilSilo.get();
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// //3 unit sugar
// sugarSilo.get();
// sugarSilo.get();
// sugarSilo.get();
// }
// }
//
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HotFlakyPastyShop.java
// public class HotFlakyPastyShop extends Thread {
//
// private final Silo flourSilo;
// private final Silo oilSilo;
//
// public HotFlakyPastyShop(Silo osilo, Silo fsilo) {
// super("Hot Flaky Pasty");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //1 unit oil
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/silo/Silo.java
// public class Silo {
// //make the producers wait when it exceedes to 20 unit
// private final String what;
// private int unit;
//
// public Silo(String what) {
// super();
// this.what = what;
// }
//
// public synchronized void get() {
// // we don't have any product at hand
// while (unit == 0) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit--;
// System.out.println(Thread.currentThread().getName() + " getting " + this.what);
// notify();
// }
//
// public synchronized void put() {
// while (unit == 20) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit++;
// System.out.println(Thread.currentThread().getName() + " putting " + this.what);
// notify();
// }
//
// public String toString() {
// return what + ":" + unit;
// }
// }
// Path: ThreadSync/src/main/java/ds/Main.java
import ds.producer.FlourProducer;
import ds.producer.OilProducer;
import ds.producer.SugarProducer;
import ds.shop.HalvahShop;
import ds.shop.HotFlakyPastyShop;
import ds.silo.Silo;
package ds;
public class Main {
public static void main(String[] args) {
Silo sugarSilo = new Silo("Sugar");
Silo oilSilo = new Silo("Oil");
Silo flourSilo = new Silo("Flour");
new SugarProducer(sugarSilo).start();
new OilProducer(oilSilo).start(); | new FlourProducer(flourSilo).start(); |
tekrei/JavaExamples | ThreadSync/src/main/java/ds/Main.java | // Path: ThreadSync/src/main/java/ds/producer/FlourProducer.java
// public class FlourProducer extends Thread {
//
// private final Silo silo;
//
// public FlourProducer(Silo silo) {
// super("Flour Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/OilProducer.java
// public class OilProducer extends Thread {
//
// private final Silo silo;
//
// public OilProducer(Silo silo) {
// super("Oil Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/SugarProducer.java
// public class SugarProducer extends Thread {
//
// private final Silo silo;
//
// public SugarProducer(Silo silo) {
// super("Sugar Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HalvahShop.java
// public class HalvahShop extends Thread {
//
// private final Silo oilSilo;
// private final Silo flourSilo;
// private final Silo sugarSilo;
//
// public HalvahShop(Silo osilo, Silo fsilo, Silo ssilo) {
// super("Halvah");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// this.sugarSilo = ssilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //2 unit oil
// oilSilo.get();
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// //3 unit sugar
// sugarSilo.get();
// sugarSilo.get();
// sugarSilo.get();
// }
// }
//
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HotFlakyPastyShop.java
// public class HotFlakyPastyShop extends Thread {
//
// private final Silo flourSilo;
// private final Silo oilSilo;
//
// public HotFlakyPastyShop(Silo osilo, Silo fsilo) {
// super("Hot Flaky Pasty");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //1 unit oil
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/silo/Silo.java
// public class Silo {
// //make the producers wait when it exceedes to 20 unit
// private final String what;
// private int unit;
//
// public Silo(String what) {
// super();
// this.what = what;
// }
//
// public synchronized void get() {
// // we don't have any product at hand
// while (unit == 0) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit--;
// System.out.println(Thread.currentThread().getName() + " getting " + this.what);
// notify();
// }
//
// public synchronized void put() {
// while (unit == 20) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit++;
// System.out.println(Thread.currentThread().getName() + " putting " + this.what);
// notify();
// }
//
// public String toString() {
// return what + ":" + unit;
// }
// }
| import ds.producer.FlourProducer;
import ds.producer.OilProducer;
import ds.producer.SugarProducer;
import ds.shop.HalvahShop;
import ds.shop.HotFlakyPastyShop;
import ds.silo.Silo; | package ds;
public class Main {
public static void main(String[] args) {
Silo sugarSilo = new Silo("Sugar");
Silo oilSilo = new Silo("Oil");
Silo flourSilo = new Silo("Flour");
new SugarProducer(sugarSilo).start();
new OilProducer(oilSilo).start();
new FlourProducer(flourSilo).start(); | // Path: ThreadSync/src/main/java/ds/producer/FlourProducer.java
// public class FlourProducer extends Thread {
//
// private final Silo silo;
//
// public FlourProducer(Silo silo) {
// super("Flour Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/OilProducer.java
// public class OilProducer extends Thread {
//
// private final Silo silo;
//
// public OilProducer(Silo silo) {
// super("Oil Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/SugarProducer.java
// public class SugarProducer extends Thread {
//
// private final Silo silo;
//
// public SugarProducer(Silo silo) {
// super("Sugar Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HalvahShop.java
// public class HalvahShop extends Thread {
//
// private final Silo oilSilo;
// private final Silo flourSilo;
// private final Silo sugarSilo;
//
// public HalvahShop(Silo osilo, Silo fsilo, Silo ssilo) {
// super("Halvah");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// this.sugarSilo = ssilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //2 unit oil
// oilSilo.get();
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// //3 unit sugar
// sugarSilo.get();
// sugarSilo.get();
// sugarSilo.get();
// }
// }
//
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HotFlakyPastyShop.java
// public class HotFlakyPastyShop extends Thread {
//
// private final Silo flourSilo;
// private final Silo oilSilo;
//
// public HotFlakyPastyShop(Silo osilo, Silo fsilo) {
// super("Hot Flaky Pasty");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //1 unit oil
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/silo/Silo.java
// public class Silo {
// //make the producers wait when it exceedes to 20 unit
// private final String what;
// private int unit;
//
// public Silo(String what) {
// super();
// this.what = what;
// }
//
// public synchronized void get() {
// // we don't have any product at hand
// while (unit == 0) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit--;
// System.out.println(Thread.currentThread().getName() + " getting " + this.what);
// notify();
// }
//
// public synchronized void put() {
// while (unit == 20) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit++;
// System.out.println(Thread.currentThread().getName() + " putting " + this.what);
// notify();
// }
//
// public String toString() {
// return what + ":" + unit;
// }
// }
// Path: ThreadSync/src/main/java/ds/Main.java
import ds.producer.FlourProducer;
import ds.producer.OilProducer;
import ds.producer.SugarProducer;
import ds.shop.HalvahShop;
import ds.shop.HotFlakyPastyShop;
import ds.silo.Silo;
package ds;
public class Main {
public static void main(String[] args) {
Silo sugarSilo = new Silo("Sugar");
Silo oilSilo = new Silo("Oil");
Silo flourSilo = new Silo("Flour");
new SugarProducer(sugarSilo).start();
new OilProducer(oilSilo).start();
new FlourProducer(flourSilo).start(); | new HotFlakyPastyShop(oilSilo, flourSilo).start(); |
tekrei/JavaExamples | ThreadSync/src/main/java/ds/Main.java | // Path: ThreadSync/src/main/java/ds/producer/FlourProducer.java
// public class FlourProducer extends Thread {
//
// private final Silo silo;
//
// public FlourProducer(Silo silo) {
// super("Flour Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/OilProducer.java
// public class OilProducer extends Thread {
//
// private final Silo silo;
//
// public OilProducer(Silo silo) {
// super("Oil Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/SugarProducer.java
// public class SugarProducer extends Thread {
//
// private final Silo silo;
//
// public SugarProducer(Silo silo) {
// super("Sugar Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HalvahShop.java
// public class HalvahShop extends Thread {
//
// private final Silo oilSilo;
// private final Silo flourSilo;
// private final Silo sugarSilo;
//
// public HalvahShop(Silo osilo, Silo fsilo, Silo ssilo) {
// super("Halvah");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// this.sugarSilo = ssilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //2 unit oil
// oilSilo.get();
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// //3 unit sugar
// sugarSilo.get();
// sugarSilo.get();
// sugarSilo.get();
// }
// }
//
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HotFlakyPastyShop.java
// public class HotFlakyPastyShop extends Thread {
//
// private final Silo flourSilo;
// private final Silo oilSilo;
//
// public HotFlakyPastyShop(Silo osilo, Silo fsilo) {
// super("Hot Flaky Pasty");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //1 unit oil
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/silo/Silo.java
// public class Silo {
// //make the producers wait when it exceedes to 20 unit
// private final String what;
// private int unit;
//
// public Silo(String what) {
// super();
// this.what = what;
// }
//
// public synchronized void get() {
// // we don't have any product at hand
// while (unit == 0) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit--;
// System.out.println(Thread.currentThread().getName() + " getting " + this.what);
// notify();
// }
//
// public synchronized void put() {
// while (unit == 20) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit++;
// System.out.println(Thread.currentThread().getName() + " putting " + this.what);
// notify();
// }
//
// public String toString() {
// return what + ":" + unit;
// }
// }
| import ds.producer.FlourProducer;
import ds.producer.OilProducer;
import ds.producer.SugarProducer;
import ds.shop.HalvahShop;
import ds.shop.HotFlakyPastyShop;
import ds.silo.Silo; | package ds;
public class Main {
public static void main(String[] args) {
Silo sugarSilo = new Silo("Sugar");
Silo oilSilo = new Silo("Oil");
Silo flourSilo = new Silo("Flour");
new SugarProducer(sugarSilo).start();
new OilProducer(oilSilo).start();
new FlourProducer(flourSilo).start();
new HotFlakyPastyShop(oilSilo, flourSilo).start();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
} | // Path: ThreadSync/src/main/java/ds/producer/FlourProducer.java
// public class FlourProducer extends Thread {
//
// private final Silo silo;
//
// public FlourProducer(Silo silo) {
// super("Flour Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/OilProducer.java
// public class OilProducer extends Thread {
//
// private final Silo silo;
//
// public OilProducer(Silo silo) {
// super("Oil Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/producer/SugarProducer.java
// public class SugarProducer extends Thread {
//
// private final Silo silo;
//
// public SugarProducer(Silo silo) {
// super("Sugar Producer");
// this.silo = silo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// silo.put();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HalvahShop.java
// public class HalvahShop extends Thread {
//
// private final Silo oilSilo;
// private final Silo flourSilo;
// private final Silo sugarSilo;
//
// public HalvahShop(Silo osilo, Silo fsilo, Silo ssilo) {
// super("Halvah");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// this.sugarSilo = ssilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //2 unit oil
// oilSilo.get();
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// //3 unit sugar
// sugarSilo.get();
// sugarSilo.get();
// sugarSilo.get();
// }
// }
//
// }
//
// Path: ThreadSync/src/main/java/ds/shop/HotFlakyPastyShop.java
// public class HotFlakyPastyShop extends Thread {
//
// private final Silo flourSilo;
// private final Silo oilSilo;
//
// public HotFlakyPastyShop(Silo osilo, Silo fsilo) {
// super("Hot Flaky Pasty");
// this.flourSilo = fsilo;
// this.oilSilo = osilo;
// }
//
// public void run() {
// while (true) {
// try {
// sleep((int) (Math.random() * 100));
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// //1 unit oil
// oilSilo.get();
// //1 unit flour
// flourSilo.get();
// }
// }
// }
//
// Path: ThreadSync/src/main/java/ds/silo/Silo.java
// public class Silo {
// //make the producers wait when it exceedes to 20 unit
// private final String what;
// private int unit;
//
// public Silo(String what) {
// super();
// this.what = what;
// }
//
// public synchronized void get() {
// // we don't have any product at hand
// while (unit == 0) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit--;
// System.out.println(Thread.currentThread().getName() + " getting " + this.what);
// notify();
// }
//
// public synchronized void put() {
// while (unit == 20) {
// try {
// wait();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// unit++;
// System.out.println(Thread.currentThread().getName() + " putting " + this.what);
// notify();
// }
//
// public String toString() {
// return what + ":" + unit;
// }
// }
// Path: ThreadSync/src/main/java/ds/Main.java
import ds.producer.FlourProducer;
import ds.producer.OilProducer;
import ds.producer.SugarProducer;
import ds.shop.HalvahShop;
import ds.shop.HotFlakyPastyShop;
import ds.silo.Silo;
package ds;
public class Main {
public static void main(String[] args) {
Silo sugarSilo = new Silo("Sugar");
Silo oilSilo = new Silo("Oil");
Silo flourSilo = new Silo("Flour");
new SugarProducer(sugarSilo).start();
new OilProducer(oilSilo).start();
new FlourProducer(flourSilo).start();
new HotFlakyPastyShop(oilSilo, flourSilo).start();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
} | new HalvahShop(oilSilo, flourSilo, sugarSilo).start(); |
tekrei/JavaExamples | BirIslem/src/main/java/birislem/utility/NumberUtility.java | // Path: BirIslem/src/main/java/birislem/exception/EarlyConvergenceException.java
// public class EarlyConvergenceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// // Hangi operatorde hedef sayiya ulastik
// private final int whichOperator;
//
// public EarlyConvergenceException(int whichOperator) {
// super();
// this.whichOperator = whichOperator;
// }
//
// public int getWhichOperator() {
// return this.whichOperator;
// }
// }
//
// Path: BirIslem/src/main/java/birislem/exception/FractionDivideException.java
// public class FractionDivideException extends Exception {
// private static final long serialVersionUID = 1L;
// // FIX Performans kazanci
// // Her seferinde bu istisnadan yeni bir tane yaratmak yerine
// // tum uygulamada sadece bir ornegini kullanmak icin
// // singleton kullaniliyor
// private static FractionDivideException instance = null;
//
// private FractionDivideException() {
//
// }
//
// public static FractionDivideException getInstance() {
// if (instance == null) {
// instance = new FractionDivideException();
// }
// return instance;
// }
//
// }
| import java.util.Random;
import birislem.exception.EarlyConvergenceException;
import birislem.exception.FractionDivideException; | /**
* Rastgele uretilen noktali sayi ureten metot
*
* @return rastgele uretilmis noktali sayi
*/
public float nextFloat() {
return generator.nextFloat();
}
/**
* 0 ile (ustSinir-1) arasinda rastgele tamsayi ureten metot
*
* @param ustSinir araligin ust siniri
* @return uretilen rastgele sayi
*/
public int nextInt(int ustSinir) {
return generator.nextInt(ustSinir);
}
/**
* Bu metot girilen parametrelere gore hesaplama sonucunu uretiyor
*
* @param sayilar hesaplamada kullanilacak sayilara indisler
* @param operatorler hesaplamada kullanilacak operatorler
* @return hesaplama sonucu (tamsayi)
* @throws FractionDivideException eger bolme islemi tamsayi sonuc uretmiyorsa
* @throws EarlyConvergenceException hesaplamanin erken asamalarinda hedefe ulasirsak
*/
public int getHesapSonuc(int[] sayilar, int[] operatorler) | // Path: BirIslem/src/main/java/birislem/exception/EarlyConvergenceException.java
// public class EarlyConvergenceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// // Hangi operatorde hedef sayiya ulastik
// private final int whichOperator;
//
// public EarlyConvergenceException(int whichOperator) {
// super();
// this.whichOperator = whichOperator;
// }
//
// public int getWhichOperator() {
// return this.whichOperator;
// }
// }
//
// Path: BirIslem/src/main/java/birislem/exception/FractionDivideException.java
// public class FractionDivideException extends Exception {
// private static final long serialVersionUID = 1L;
// // FIX Performans kazanci
// // Her seferinde bu istisnadan yeni bir tane yaratmak yerine
// // tum uygulamada sadece bir ornegini kullanmak icin
// // singleton kullaniliyor
// private static FractionDivideException instance = null;
//
// private FractionDivideException() {
//
// }
//
// public static FractionDivideException getInstance() {
// if (instance == null) {
// instance = new FractionDivideException();
// }
// return instance;
// }
//
// }
// Path: BirIslem/src/main/java/birislem/utility/NumberUtility.java
import java.util.Random;
import birislem.exception.EarlyConvergenceException;
import birislem.exception.FractionDivideException;
/**
* Rastgele uretilen noktali sayi ureten metot
*
* @return rastgele uretilmis noktali sayi
*/
public float nextFloat() {
return generator.nextFloat();
}
/**
* 0 ile (ustSinir-1) arasinda rastgele tamsayi ureten metot
*
* @param ustSinir araligin ust siniri
* @return uretilen rastgele sayi
*/
public int nextInt(int ustSinir) {
return generator.nextInt(ustSinir);
}
/**
* Bu metot girilen parametrelere gore hesaplama sonucunu uretiyor
*
* @param sayilar hesaplamada kullanilacak sayilara indisler
* @param operatorler hesaplamada kullanilacak operatorler
* @return hesaplama sonucu (tamsayi)
* @throws FractionDivideException eger bolme islemi tamsayi sonuc uretmiyorsa
* @throws EarlyConvergenceException hesaplamanin erken asamalarinda hedefe ulasirsak
*/
public int getHesapSonuc(int[] sayilar, int[] operatorler) | throws FractionDivideException, EarlyConvergenceException { |
tekrei/JavaExamples | BirIslem/src/main/java/birislem/utility/NumberUtility.java | // Path: BirIslem/src/main/java/birislem/exception/EarlyConvergenceException.java
// public class EarlyConvergenceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// // Hangi operatorde hedef sayiya ulastik
// private final int whichOperator;
//
// public EarlyConvergenceException(int whichOperator) {
// super();
// this.whichOperator = whichOperator;
// }
//
// public int getWhichOperator() {
// return this.whichOperator;
// }
// }
//
// Path: BirIslem/src/main/java/birislem/exception/FractionDivideException.java
// public class FractionDivideException extends Exception {
// private static final long serialVersionUID = 1L;
// // FIX Performans kazanci
// // Her seferinde bu istisnadan yeni bir tane yaratmak yerine
// // tum uygulamada sadece bir ornegini kullanmak icin
// // singleton kullaniliyor
// private static FractionDivideException instance = null;
//
// private FractionDivideException() {
//
// }
//
// public static FractionDivideException getInstance() {
// if (instance == null) {
// instance = new FractionDivideException();
// }
// return instance;
// }
//
// }
| import java.util.Random;
import birislem.exception.EarlyConvergenceException;
import birislem.exception.FractionDivideException; | /**
* Rastgele uretilen noktali sayi ureten metot
*
* @return rastgele uretilmis noktali sayi
*/
public float nextFloat() {
return generator.nextFloat();
}
/**
* 0 ile (ustSinir-1) arasinda rastgele tamsayi ureten metot
*
* @param ustSinir araligin ust siniri
* @return uretilen rastgele sayi
*/
public int nextInt(int ustSinir) {
return generator.nextInt(ustSinir);
}
/**
* Bu metot girilen parametrelere gore hesaplama sonucunu uretiyor
*
* @param sayilar hesaplamada kullanilacak sayilara indisler
* @param operatorler hesaplamada kullanilacak operatorler
* @return hesaplama sonucu (tamsayi)
* @throws FractionDivideException eger bolme islemi tamsayi sonuc uretmiyorsa
* @throws EarlyConvergenceException hesaplamanin erken asamalarinda hedefe ulasirsak
*/
public int getHesapSonuc(int[] sayilar, int[] operatorler) | // Path: BirIslem/src/main/java/birislem/exception/EarlyConvergenceException.java
// public class EarlyConvergenceException extends Exception {
// private static final long serialVersionUID = 1L;
//
// // Hangi operatorde hedef sayiya ulastik
// private final int whichOperator;
//
// public EarlyConvergenceException(int whichOperator) {
// super();
// this.whichOperator = whichOperator;
// }
//
// public int getWhichOperator() {
// return this.whichOperator;
// }
// }
//
// Path: BirIslem/src/main/java/birislem/exception/FractionDivideException.java
// public class FractionDivideException extends Exception {
// private static final long serialVersionUID = 1L;
// // FIX Performans kazanci
// // Her seferinde bu istisnadan yeni bir tane yaratmak yerine
// // tum uygulamada sadece bir ornegini kullanmak icin
// // singleton kullaniliyor
// private static FractionDivideException instance = null;
//
// private FractionDivideException() {
//
// }
//
// public static FractionDivideException getInstance() {
// if (instance == null) {
// instance = new FractionDivideException();
// }
// return instance;
// }
//
// }
// Path: BirIslem/src/main/java/birislem/utility/NumberUtility.java
import java.util.Random;
import birislem.exception.EarlyConvergenceException;
import birislem.exception.FractionDivideException;
/**
* Rastgele uretilen noktali sayi ureten metot
*
* @return rastgele uretilmis noktali sayi
*/
public float nextFloat() {
return generator.nextFloat();
}
/**
* 0 ile (ustSinir-1) arasinda rastgele tamsayi ureten metot
*
* @param ustSinir araligin ust siniri
* @return uretilen rastgele sayi
*/
public int nextInt(int ustSinir) {
return generator.nextInt(ustSinir);
}
/**
* Bu metot girilen parametrelere gore hesaplama sonucunu uretiyor
*
* @param sayilar hesaplamada kullanilacak sayilara indisler
* @param operatorler hesaplamada kullanilacak operatorler
* @return hesaplama sonucu (tamsayi)
* @throws FractionDivideException eger bolme islemi tamsayi sonuc uretmiyorsa
* @throws EarlyConvergenceException hesaplamanin erken asamalarinda hedefe ulasirsak
*/
public int getHesapSonuc(int[] sayilar, int[] operatorler) | throws FractionDivideException, EarlyConvergenceException { |
khmarbaise/maven-buildtime-profiler | src/main/java/com/soebes/maven/extensions/metadata/MetadataDownloadTimer.java | // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
| import java.text.NumberFormat;
import java.util.Map.Entry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.soebes.maven.extensions.TimePlusSize; | package com.soebes.maven.extensions.metadata;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* @author Karl Heinz Marbaise <a href="mailto:kama@soebes.de">kama@soebes.de</a>
*/
public class MetadataDownloadTimer
extends AbstractMetadataTimer
{
private final Logger LOGGER = LoggerFactory.getLogger( getClass() );
public MetadataDownloadTimer()
{
super();
}
public void report()
{
if ( getTimerEvents().isEmpty() )
{
return;
}
long totalInstallationTime = 0;
long totalInstallationSize = 0; | // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
// Path: src/main/java/com/soebes/maven/extensions/metadata/MetadataDownloadTimer.java
import java.text.NumberFormat;
import java.util.Map.Entry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.soebes.maven.extensions.TimePlusSize;
package com.soebes.maven.extensions.metadata;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* @author Karl Heinz Marbaise <a href="mailto:kama@soebes.de">kama@soebes.de</a>
*/
public class MetadataDownloadTimer
extends AbstractMetadataTimer
{
private final Logger LOGGER = LoggerFactory.getLogger( getClass() );
public MetadataDownloadTimer()
{
super();
}
public void report()
{
if ( getTimerEvents().isEmpty() )
{
return;
}
long totalInstallationTime = 0;
long totalInstallationSize = 0; | for ( Entry<String, TimePlusSize> item : this.getTimerEvents().entrySet() ) |
khmarbaise/maven-buildtime-profiler | src/main/java/com/soebes/maven/extensions/metadata/MetadataDeploymentTimer.java | // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
| import java.text.NumberFormat;
import java.util.Map.Entry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.soebes.maven.extensions.TimePlusSize; | package com.soebes.maven.extensions.metadata;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* @author Karl Heinz Marbaise <a href="mailto:kama@soebes.de">kama@soebes.de</a>
*/
public class MetadataDeploymentTimer
extends AbstractMetadataTimer
{
private final Logger LOGGER = LoggerFactory.getLogger( getClass() );
public MetadataDeploymentTimer()
{
super();
}
public void report()
{
if ( getTimerEvents().isEmpty() )
{
return;
}
long totalInstallationTime = 0;
long totalInstallationSize = 0; | // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
// Path: src/main/java/com/soebes/maven/extensions/metadata/MetadataDeploymentTimer.java
import java.text.NumberFormat;
import java.util.Map.Entry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.soebes.maven.extensions.TimePlusSize;
package com.soebes.maven.extensions.metadata;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* @author Karl Heinz Marbaise <a href="mailto:kama@soebes.de">kama@soebes.de</a>
*/
public class MetadataDeploymentTimer
extends AbstractMetadataTimer
{
private final Logger LOGGER = LoggerFactory.getLogger( getClass() );
public MetadataDeploymentTimer()
{
super();
}
public void report()
{
if ( getTimerEvents().isEmpty() )
{
return;
}
long totalInstallationTime = 0;
long totalInstallationSize = 0; | for ( Entry<String, TimePlusSize> item : this.getTimerEvents().entrySet() ) |
khmarbaise/maven-buildtime-profiler | src/it/non-lifecycle/src/test/java/test/maven/plugin/profiler/PomReadIT.java | // Path: src/it/non-lifecycle/src/main/java/test/maven/plugin/profiler/PomRead.java
// public class PomRead {
//
// public String getPomVersion(Model model) {
// String result = model.getVersion();
// if (result == null) {
// throw new IllegalArgumentException("The artifact does not define a version.");
// }
// return result;
// }
//
// public Model readModel(InputStream is) throws IOException, XmlPullParserException {
// MavenXpp3Reader model = new MavenXpp3Reader();
// Model read = model.read(is);
// return read;
// }
//
// public Model readModel(File file) throws IOException, XmlPullParserException {
// FileInputStream fis = new FileInputStream(file);
// return readModel(fis);
// }
//
// public String getVersionFromPom(File pomFile) throws IOException, XmlPullParserException {
// Model model = readModel(pomFile);
// return getPomVersion(model);
// }
//
// public static void main(String[] args) {
// if (args.length != 1) {
// System.err.println("Invalid number of arguments.");
// System.err.println("");
// System.err.println("usage: pom.xml");
// return;
// }
//
// String pom = args[0];
// File pomFile = new File(pom);
// if (!pomFile.exists() || !pomFile.isFile() || !pomFile.canRead()) {
// System.err.println("File " + pomFile + " can not be accessed or does not exist.");
// return;
// }
//
// PomRead pomRead = new PomRead();
// try {
// String version = pomRead.getVersionFromPom(pomFile);
// System.out.println(version);
// } catch (IllegalArgumentException e) {
// System.err.println(e.getMessage());
// } catch (IOException e) {
// System.err.println(e.getMessage());
// } catch (XmlPullParserException e) {
// System.err.println(e.getMessage());
// }
//
// }
// }
| import static org.assertj.core.api.Assertions.assertThat;
import java.io.File;
import java.io.OutputStream;
import java.io.PrintStream;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import test.maven.plugin.profiler.PomRead;
| public void println(String s) {
consoleOutputStdOut.append(s);
consoleOutputStdOut.append(LINE_FEED);
}
public void print(String s) {
consoleOutputStdOut.append(s);
}
}
private PrintStream originalStdOut;
private PrintStream originalStdErr;
@BeforeMethod
public void beforeMethod() {
consoleOutputStdErr = new StringBuilder();
consoleOutputStdOut = new StringBuilder();
originalStdErr = System.err;
originalStdOut = System.out;
PrintStream interceptorStdOut = new InterceptorStdOut(originalStdOut);
PrintStream interceptorStdErr = new InterceptorStdErr(originalStdErr);
System.setOut(interceptorStdOut);
System.setErr(interceptorStdErr);
}
@Test
public void shouldFailWithErrorBasedOnTooLessArguments() {
| // Path: src/it/non-lifecycle/src/main/java/test/maven/plugin/profiler/PomRead.java
// public class PomRead {
//
// public String getPomVersion(Model model) {
// String result = model.getVersion();
// if (result == null) {
// throw new IllegalArgumentException("The artifact does not define a version.");
// }
// return result;
// }
//
// public Model readModel(InputStream is) throws IOException, XmlPullParserException {
// MavenXpp3Reader model = new MavenXpp3Reader();
// Model read = model.read(is);
// return read;
// }
//
// public Model readModel(File file) throws IOException, XmlPullParserException {
// FileInputStream fis = new FileInputStream(file);
// return readModel(fis);
// }
//
// public String getVersionFromPom(File pomFile) throws IOException, XmlPullParserException {
// Model model = readModel(pomFile);
// return getPomVersion(model);
// }
//
// public static void main(String[] args) {
// if (args.length != 1) {
// System.err.println("Invalid number of arguments.");
// System.err.println("");
// System.err.println("usage: pom.xml");
// return;
// }
//
// String pom = args[0];
// File pomFile = new File(pom);
// if (!pomFile.exists() || !pomFile.isFile() || !pomFile.canRead()) {
// System.err.println("File " + pomFile + " can not be accessed or does not exist.");
// return;
// }
//
// PomRead pomRead = new PomRead();
// try {
// String version = pomRead.getVersionFromPom(pomFile);
// System.out.println(version);
// } catch (IllegalArgumentException e) {
// System.err.println(e.getMessage());
// } catch (IOException e) {
// System.err.println(e.getMessage());
// } catch (XmlPullParserException e) {
// System.err.println(e.getMessage());
// }
//
// }
// }
// Path: src/it/non-lifecycle/src/test/java/test/maven/plugin/profiler/PomReadIT.java
import static org.assertj.core.api.Assertions.assertThat;
import java.io.File;
import java.io.OutputStream;
import java.io.PrintStream;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import test.maven.plugin.profiler.PomRead;
public void println(String s) {
consoleOutputStdOut.append(s);
consoleOutputStdOut.append(LINE_FEED);
}
public void print(String s) {
consoleOutputStdOut.append(s);
}
}
private PrintStream originalStdOut;
private PrintStream originalStdErr;
@BeforeMethod
public void beforeMethod() {
consoleOutputStdErr = new StringBuilder();
consoleOutputStdOut = new StringBuilder();
originalStdErr = System.err;
originalStdOut = System.out;
PrintStream interceptorStdOut = new InterceptorStdOut(originalStdOut);
PrintStream interceptorStdErr = new InterceptorStdErr(originalStdErr);
System.setOut(interceptorStdOut);
System.setErr(interceptorStdErr);
}
@Test
public void shouldFailWithErrorBasedOnTooLessArguments() {
| PomRead.main(new String[] {});
|
khmarbaise/maven-buildtime-profiler | src/test/java/com/soebes/maven/extensions/metadata/AbstractMetadataTimerTest.java | // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
| import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.File;
import org.eclipse.aether.RepositoryEvent;
import org.eclipse.aether.RepositoryEvent.EventType;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.metadata.Metadata;
import org.eclipse.aether.metadata.Metadata.Nature;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.soebes.maven.extensions.TimePlusSize; | @Test
public void shouldResultWitClassifier()
{
Metadata artifact = createMockMetadata( "groupId", "artifactId", "version", "type", Nature.RELEASE );
String result = aat.getArtifactId( artifact );
assertThat( result ).isEqualTo( "groupId:artifactId:version:type:RELEASE" );
}
@Test
public void shouldResultInSingleEntryInTimerEvents()
throws InterruptedException
{
Metadata artifact = createMockMetadata( "groupId", "artifactId", "version", "jar", null );
RepositoryEvent build =
new RepositoryEvent.Builder( mock( RepositorySystemSession.class ),
EventType.ARTIFACT_DEPLOYED ).setMetadata( artifact ).build();
aat.start( build );
Thread.sleep( 10L );
aat.stop( build );
String key = aat.getArtifactId( artifact );
assertThat( aat.getTimerEvents() ).hasSize( 1 ).containsKey( key );
| // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
// Path: src/test/java/com/soebes/maven/extensions/metadata/AbstractMetadataTimerTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.File;
import org.eclipse.aether.RepositoryEvent;
import org.eclipse.aether.RepositoryEvent.EventType;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.metadata.Metadata;
import org.eclipse.aether.metadata.Metadata.Nature;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.soebes.maven.extensions.TimePlusSize;
@Test
public void shouldResultWitClassifier()
{
Metadata artifact = createMockMetadata( "groupId", "artifactId", "version", "type", Nature.RELEASE );
String result = aat.getArtifactId( artifact );
assertThat( result ).isEqualTo( "groupId:artifactId:version:type:RELEASE" );
}
@Test
public void shouldResultInSingleEntryInTimerEvents()
throws InterruptedException
{
Metadata artifact = createMockMetadata( "groupId", "artifactId", "version", "jar", null );
RepositoryEvent build =
new RepositoryEvent.Builder( mock( RepositorySystemSession.class ),
EventType.ARTIFACT_DEPLOYED ).setMetadata( artifact ).build();
aat.start( build );
Thread.sleep( 10L );
aat.stop( build );
String key = aat.getArtifactId( artifact );
assertThat( aat.getTimerEvents() ).hasSize( 1 ).containsKey( key );
| TimePlusSize timePlusSize = aat.getTimerEvents().get( key ); |
khmarbaise/maven-buildtime-profiler | src/main/java/com/soebes/maven/extensions/artifact/DownloadTimer.java | // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
| import java.text.NumberFormat;
import java.util.Map.Entry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.soebes.maven.extensions.TimePlusSize; | package com.soebes.maven.extensions.artifact;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* @author Karl Heinz Marbaise <a href="mailto:kama@soebes.de">kama@soebes.de</a>
*/
public class DownloadTimer
extends AbstractArtifactTimer
{
private final Logger LOGGER = LoggerFactory.getLogger( getClass() );
public DownloadTimer()
{
super();
}
public void report()
{
if ( getTimerEvents().isEmpty() )
{
return;
}
LOGGER.info( "Artifact Download summary:" );
long totalInstallationTime = 0;
long totalInstallationSize = 0; | // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
// Path: src/main/java/com/soebes/maven/extensions/artifact/DownloadTimer.java
import java.text.NumberFormat;
import java.util.Map.Entry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.soebes.maven.extensions.TimePlusSize;
package com.soebes.maven.extensions.artifact;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* @author Karl Heinz Marbaise <a href="mailto:kama@soebes.de">kama@soebes.de</a>
*/
public class DownloadTimer
extends AbstractArtifactTimer
{
private final Logger LOGGER = LoggerFactory.getLogger( getClass() );
public DownloadTimer()
{
super();
}
public void report()
{
if ( getTimerEvents().isEmpty() )
{
return;
}
LOGGER.info( "Artifact Download summary:" );
long totalInstallationTime = 0;
long totalInstallationSize = 0; | for ( Entry<String, TimePlusSize> item : this.getTimerEvents().entrySet() ) |
khmarbaise/maven-buildtime-profiler | src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java | // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
| import java.text.NumberFormat;
import java.util.Map.Entry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.soebes.maven.extensions.TimePlusSize; | package com.soebes.maven.extensions.artifact;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* @author Karl Heinz Marbaise <a href="mailto:kama@soebes.de">kama@soebes.de</a>
*/
public class InstallTimer
extends AbstractArtifactTimer
{
private final Logger LOGGER = LoggerFactory.getLogger( getClass() );
public InstallTimer()
{
super();
}
public void report()
{
if ( getTimerEvents().isEmpty() )
{
return;
}
LOGGER.info( "Installation summary:" );
long totalInstallationTime = 0;
long totalInstallationSize = 0; | // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
// Path: src/main/java/com/soebes/maven/extensions/artifact/InstallTimer.java
import java.text.NumberFormat;
import java.util.Map.Entry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.soebes.maven.extensions.TimePlusSize;
package com.soebes.maven.extensions.artifact;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* @author Karl Heinz Marbaise <a href="mailto:kama@soebes.de">kama@soebes.de</a>
*/
public class InstallTimer
extends AbstractArtifactTimer
{
private final Logger LOGGER = LoggerFactory.getLogger( getClass() );
public InstallTimer()
{
super();
}
public void report()
{
if ( getTimerEvents().isEmpty() )
{
return;
}
LOGGER.info( "Installation summary:" );
long totalInstallationTime = 0;
long totalInstallationSize = 0; | for ( Entry<String, TimePlusSize> item : this.getTimerEvents().entrySet() ) |
khmarbaise/maven-buildtime-profiler | src/test/java/com/soebes/maven/extensions/artifact/AbstractArtifactTimerTest.java | // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
| import org.testng.annotations.Test;
import com.soebes.maven.extensions.TimePlusSize;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.File;
import org.eclipse.aether.RepositoryEvent;
import org.eclipse.aether.RepositoryEvent.EventType;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.testng.annotations.BeforeMethod; | @Test
public void shouldResultWitClassifier()
{
Artifact artifact = createMockArtifact( "groupId", "artifactId", "version", "jar", "classifier" );
String result = aat.getArtifactId( artifact );
assertThat( result ).isEqualTo( "groupId:artifactId:version:classifier:jar" );
}
@Test
public void shouldResultInSingleEntryInTimerEvents()
throws InterruptedException
{
Artifact artifact = createMockArtifact( "groupId", "artifactId", "version", "jar", "" ); // as per javadoc, extension is never null
RepositoryEvent build =
new RepositoryEvent.Builder( mock( RepositorySystemSession.class ),
EventType.ARTIFACT_DEPLOYED ).setArtifact( artifact ).build();
aat.start( build );
Thread.sleep( 10L );
aat.stop( build );
String key = aat.getArtifactId( artifact );
assertThat( aat.getTimerEvents() ).hasSize( 1 ).containsKey( key );
| // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
// Path: src/test/java/com/soebes/maven/extensions/artifact/AbstractArtifactTimerTest.java
import org.testng.annotations.Test;
import com.soebes.maven.extensions.TimePlusSize;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.File;
import org.eclipse.aether.RepositoryEvent;
import org.eclipse.aether.RepositoryEvent.EventType;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.testng.annotations.BeforeMethod;
@Test
public void shouldResultWitClassifier()
{
Artifact artifact = createMockArtifact( "groupId", "artifactId", "version", "jar", "classifier" );
String result = aat.getArtifactId( artifact );
assertThat( result ).isEqualTo( "groupId:artifactId:version:classifier:jar" );
}
@Test
public void shouldResultInSingleEntryInTimerEvents()
throws InterruptedException
{
Artifact artifact = createMockArtifact( "groupId", "artifactId", "version", "jar", "" ); // as per javadoc, extension is never null
RepositoryEvent build =
new RepositoryEvent.Builder( mock( RepositorySystemSession.class ),
EventType.ARTIFACT_DEPLOYED ).setArtifact( artifact ).build();
aat.start( build );
Thread.sleep( 10L );
aat.stop( build );
String key = aat.getArtifactId( artifact );
assertThat( aat.getTimerEvents() ).hasSize( 1 ).containsKey( key );
| TimePlusSize timePlusSize = aat.getTimerEvents().get( key ); |
khmarbaise/maven-buildtime-profiler | src/main/java/com/soebes/maven/extensions/artifact/AbstractArtifactTimer.java | // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
| import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.aether.RepositoryEvent;
import org.eclipse.aether.artifact.Artifact;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.soebes.maven.extensions.TimePlusSize; | package com.soebes.maven.extensions.artifact;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* @author Karl Heinz Marbaise <a href="mailto:kama@soebes.de">kama@soebes.de</a>
*/
public abstract class AbstractArtifactTimer
{
private final Logger LOGGER = LoggerFactory.getLogger( getClass() );
| // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
// Path: src/main/java/com/soebes/maven/extensions/artifact/AbstractArtifactTimer.java
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.aether.RepositoryEvent;
import org.eclipse.aether.artifact.Artifact;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.soebes.maven.extensions.TimePlusSize;
package com.soebes.maven.extensions.artifact;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* @author Karl Heinz Marbaise <a href="mailto:kama@soebes.de">kama@soebes.de</a>
*/
public abstract class AbstractArtifactTimer
{
private final Logger LOGGER = LoggerFactory.getLogger( getClass() );
| private Map<String, TimePlusSize> timerEvents; |
khmarbaise/maven-buildtime-profiler | src/main/java/com/soebes/maven/extensions/artifact/DeployTimer.java | // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
| import java.text.NumberFormat;
import java.util.Map.Entry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.soebes.maven.extensions.TimePlusSize; | package com.soebes.maven.extensions.artifact;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* @author Karl Heinz Marbaise <a href="mailto:kama@soebes.de">kama@soebes.de</a>
*/
public class DeployTimer
extends AbstractArtifactTimer
{
private final Logger LOGGER = LoggerFactory.getLogger( getClass() );
public DeployTimer()
{
super();
}
public void report()
{
if ( getTimerEvents().isEmpty() )
{
return;
}
LOGGER.info( "Deployment summary:" );
long totalInstallationTime = 0;
long totalInstallationSize = 0; | // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
// Path: src/main/java/com/soebes/maven/extensions/artifact/DeployTimer.java
import java.text.NumberFormat;
import java.util.Map.Entry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.soebes.maven.extensions.TimePlusSize;
package com.soebes.maven.extensions.artifact;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* @author Karl Heinz Marbaise <a href="mailto:kama@soebes.de">kama@soebes.de</a>
*/
public class DeployTimer
extends AbstractArtifactTimer
{
private final Logger LOGGER = LoggerFactory.getLogger( getClass() );
public DeployTimer()
{
super();
}
public void report()
{
if ( getTimerEvents().isEmpty() )
{
return;
}
LOGGER.info( "Deployment summary:" );
long totalInstallationTime = 0;
long totalInstallationSize = 0; | for ( Entry<String, TimePlusSize> item : this.getTimerEvents().entrySet() ) |
khmarbaise/maven-buildtime-profiler | src/main/java/com/soebes/maven/extensions/metadata/MetadataInstallTimer.java | // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
| import java.text.NumberFormat;
import java.util.Map.Entry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.soebes.maven.extensions.TimePlusSize; | package com.soebes.maven.extensions.metadata;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* @author Karl Heinz Marbaise <a href="mailto:kama@soebes.de">kama@soebes.de</a>
*/
public class MetadataInstallTimer
extends AbstractMetadataTimer
{
private final Logger LOGGER = LoggerFactory.getLogger( getClass() );
public MetadataInstallTimer()
{
super();
}
public void report()
{
if ( getTimerEvents().isEmpty() )
{
return;
}
long totalInstallationTime = 0;
long totalInstallationSize = 0; | // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
// Path: src/main/java/com/soebes/maven/extensions/metadata/MetadataInstallTimer.java
import java.text.NumberFormat;
import java.util.Map.Entry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.soebes.maven.extensions.TimePlusSize;
package com.soebes.maven.extensions.metadata;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* @author Karl Heinz Marbaise <a href="mailto:kama@soebes.de">kama@soebes.de</a>
*/
public class MetadataInstallTimer
extends AbstractMetadataTimer
{
private final Logger LOGGER = LoggerFactory.getLogger( getClass() );
public MetadataInstallTimer()
{
super();
}
public void report()
{
if ( getTimerEvents().isEmpty() )
{
return;
}
long totalInstallationTime = 0;
long totalInstallationSize = 0; | for ( Entry<String, TimePlusSize> item : this.getTimerEvents().entrySet() ) |
khmarbaise/maven-buildtime-profiler | src/main/java/com/soebes/maven/extensions/metadata/AbstractMetadataTimer.java | // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
| import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.aether.RepositoryEvent;
import org.eclipse.aether.metadata.Metadata;
import com.soebes.maven.extensions.TimePlusSize; | package com.soebes.maven.extensions.metadata;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* @author Karl Heinz Marbaise <a href="mailto:kama@soebes.de">kama@soebes.de</a>
*/
public abstract class AbstractMetadataTimer
{ | // Path: src/main/java/com/soebes/maven/extensions/TimePlusSize.java
// public class TimePlusSize
// extends SystemTime
// {
//
// private long size;
//
// public TimePlusSize()
// {
// super();
// }
//
// public long getSize()
// {
// return size;
// }
//
// public void setSize( long size )
// {
// this.size = size;
// }
//
// }
// Path: src/main/java/com/soebes/maven/extensions/metadata/AbstractMetadataTimer.java
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.aether.RepositoryEvent;
import org.eclipse.aether.metadata.Metadata;
import com.soebes.maven.extensions.TimePlusSize;
package com.soebes.maven.extensions.metadata;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* @author Karl Heinz Marbaise <a href="mailto:kama@soebes.de">kama@soebes.de</a>
*/
public abstract class AbstractMetadataTimer
{ | private Map<String, TimePlusSize> timerEvents; |
loicortola/led-controller | android/app/src/main/java/com/loicortola/controller/persistence/DaoMaster.java | // Path: android/app/src/main/java/com/loicortola/controller/persistence/DeviceDao.java
// public class DeviceDao extends AbstractDao<Device, Long> {
//
// public static final String TABLENAME = "DEVICE";
//
// /**
// * Properties of entity Device.<br/>
// * Can be used for QueryBuilder and for referencing column names.
// */
// public static class Properties {
// public final static Property Id = new Property(0, Long.class, "id", true, "_id");
// public final static Property DeviceId = new Property(1, String.class, "deviceId", false, "DEVICE_ID");
// public final static Property DeviceResolver = new Property(2, String.class, "deviceResolver", false, "DEVICE_RESOLVER");
// public final static Property Name = new Property(3, String.class, "name", false, "NAME");
// public final static Property Icon = new Property(4, long.class, "icon", false, "ICON");
// public final static Property Host = new Property(5, String.class, "host", false, "HOST");
// public final static Property Key = new Property(6, String.class, "key", false, "KEY");
// };
//
//
// public DeviceDao(DaoConfig config) {
// super(config);
// }
//
// public DeviceDao(DaoConfig config, DaoSession daoSession) {
// super(config, daoSession);
// }
//
// /** Creates the underlying database table. */
// public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
// String constraint = ifNotExists? "IF NOT EXISTS ": "";
// db.execSQL("CREATE TABLE " + constraint + "\"DEVICE\" (" + //
// "\"_id\" INTEGER PRIMARY KEY ," + // 0: id
// "\"DEVICE_ID\" TEXT NOT NULL UNIQUE ," + // 1: deviceId
// "\"DEVICE_RESOLVER\" TEXT NOT NULL ," + // 2: deviceResolver
// "\"NAME\" TEXT NOT NULL ," + // 3: name
// "\"ICON\" INTEGER NOT NULL ," + // 4: icon
// "\"HOST\" TEXT NOT NULL ," + // 5: host
// "\"KEY\" TEXT);"); // 6: key
// }
//
// /** Drops the underlying database table. */
// public static void dropTable(SQLiteDatabase db, boolean ifExists) {
// String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"DEVICE\"";
// db.execSQL(sql);
// }
//
// /** @inheritdoc */
// @Override
// protected void bindValues(SQLiteStatement stmt, Device entity) {
// stmt.clearBindings();
//
// Long id = entity.getId();
// if (id != null) {
// stmt.bindLong(1, id);
// }
// stmt.bindString(2, entity.getDeviceId());
// stmt.bindString(3, entity.getDeviceResolver());
// stmt.bindString(4, entity.getName());
// stmt.bindLong(5, entity.getIcon());
// stmt.bindString(6, entity.getHost());
//
// String key = entity.getKey();
// if (key != null) {
// stmt.bindString(7, key);
// }
// }
//
// /** @inheritdoc */
// @Override
// public Long readKey(Cursor cursor, int offset) {
// return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
// }
//
// /** @inheritdoc */
// @Override
// public Device readEntity(Cursor cursor, int offset) {
// Device entity = new Device( //
// cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
// cursor.getString(offset + 1), // deviceId
// cursor.getString(offset + 2), // deviceResolver
// cursor.getString(offset + 3), // name
// cursor.getLong(offset + 4), // icon
// cursor.getString(offset + 5), // host
// cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6) // key
// );
// return entity;
// }
//
// /** @inheritdoc */
// @Override
// public void readEntity(Cursor cursor, Device entity, int offset) {
// entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
// entity.setDeviceId(cursor.getString(offset + 1));
// entity.setDeviceResolver(cursor.getString(offset + 2));
// entity.setName(cursor.getString(offset + 3));
// entity.setIcon(cursor.getLong(offset + 4));
// entity.setHost(cursor.getString(offset + 5));
// entity.setKey(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
// }
//
// /** @inheritdoc */
// @Override
// protected Long updateKeyAfterInsert(Device entity, long rowId) {
// entity.setId(rowId);
// return rowId;
// }
//
// /** @inheritdoc */
// @Override
// public Long getKey(Device entity) {
// if(entity != null) {
// return entity.getId();
// } else {
// return null;
// }
// }
//
// /** @inheritdoc */
// @Override
// protected boolean isEntityUpdateable() {
// return true;
// }
//
// }
| import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import de.greenrobot.dao.AbstractDaoMaster;
import de.greenrobot.dao.identityscope.IdentityScopeType;
import com.loicortola.controller.persistence.DeviceDao; | package com.loicortola.controller.persistence;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* Master of DAO (schema version 2): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 2;
/** Creates underlying database table using DAOs. */
public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) { | // Path: android/app/src/main/java/com/loicortola/controller/persistence/DeviceDao.java
// public class DeviceDao extends AbstractDao<Device, Long> {
//
// public static final String TABLENAME = "DEVICE";
//
// /**
// * Properties of entity Device.<br/>
// * Can be used for QueryBuilder and for referencing column names.
// */
// public static class Properties {
// public final static Property Id = new Property(0, Long.class, "id", true, "_id");
// public final static Property DeviceId = new Property(1, String.class, "deviceId", false, "DEVICE_ID");
// public final static Property DeviceResolver = new Property(2, String.class, "deviceResolver", false, "DEVICE_RESOLVER");
// public final static Property Name = new Property(3, String.class, "name", false, "NAME");
// public final static Property Icon = new Property(4, long.class, "icon", false, "ICON");
// public final static Property Host = new Property(5, String.class, "host", false, "HOST");
// public final static Property Key = new Property(6, String.class, "key", false, "KEY");
// };
//
//
// public DeviceDao(DaoConfig config) {
// super(config);
// }
//
// public DeviceDao(DaoConfig config, DaoSession daoSession) {
// super(config, daoSession);
// }
//
// /** Creates the underlying database table. */
// public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
// String constraint = ifNotExists? "IF NOT EXISTS ": "";
// db.execSQL("CREATE TABLE " + constraint + "\"DEVICE\" (" + //
// "\"_id\" INTEGER PRIMARY KEY ," + // 0: id
// "\"DEVICE_ID\" TEXT NOT NULL UNIQUE ," + // 1: deviceId
// "\"DEVICE_RESOLVER\" TEXT NOT NULL ," + // 2: deviceResolver
// "\"NAME\" TEXT NOT NULL ," + // 3: name
// "\"ICON\" INTEGER NOT NULL ," + // 4: icon
// "\"HOST\" TEXT NOT NULL ," + // 5: host
// "\"KEY\" TEXT);"); // 6: key
// }
//
// /** Drops the underlying database table. */
// public static void dropTable(SQLiteDatabase db, boolean ifExists) {
// String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"DEVICE\"";
// db.execSQL(sql);
// }
//
// /** @inheritdoc */
// @Override
// protected void bindValues(SQLiteStatement stmt, Device entity) {
// stmt.clearBindings();
//
// Long id = entity.getId();
// if (id != null) {
// stmt.bindLong(1, id);
// }
// stmt.bindString(2, entity.getDeviceId());
// stmt.bindString(3, entity.getDeviceResolver());
// stmt.bindString(4, entity.getName());
// stmt.bindLong(5, entity.getIcon());
// stmt.bindString(6, entity.getHost());
//
// String key = entity.getKey();
// if (key != null) {
// stmt.bindString(7, key);
// }
// }
//
// /** @inheritdoc */
// @Override
// public Long readKey(Cursor cursor, int offset) {
// return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
// }
//
// /** @inheritdoc */
// @Override
// public Device readEntity(Cursor cursor, int offset) {
// Device entity = new Device( //
// cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
// cursor.getString(offset + 1), // deviceId
// cursor.getString(offset + 2), // deviceResolver
// cursor.getString(offset + 3), // name
// cursor.getLong(offset + 4), // icon
// cursor.getString(offset + 5), // host
// cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6) // key
// );
// return entity;
// }
//
// /** @inheritdoc */
// @Override
// public void readEntity(Cursor cursor, Device entity, int offset) {
// entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
// entity.setDeviceId(cursor.getString(offset + 1));
// entity.setDeviceResolver(cursor.getString(offset + 2));
// entity.setName(cursor.getString(offset + 3));
// entity.setIcon(cursor.getLong(offset + 4));
// entity.setHost(cursor.getString(offset + 5));
// entity.setKey(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
// }
//
// /** @inheritdoc */
// @Override
// protected Long updateKeyAfterInsert(Device entity, long rowId) {
// entity.setId(rowId);
// return rowId;
// }
//
// /** @inheritdoc */
// @Override
// public Long getKey(Device entity) {
// if(entity != null) {
// return entity.getId();
// } else {
// return null;
// }
// }
//
// /** @inheritdoc */
// @Override
// protected boolean isEntityUpdateable() {
// return true;
// }
//
// }
// Path: android/app/src/main/java/com/loicortola/controller/persistence/DaoMaster.java
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import de.greenrobot.dao.AbstractDaoMaster;
import de.greenrobot.dao.identityscope.IdentityScopeType;
import com.loicortola.controller.persistence.DeviceDao;
package com.loicortola.controller.persistence;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* Master of DAO (schema version 2): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 2;
/** Creates underlying database table using DAOs. */
public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) { | DeviceDao.createTable(db, ifNotExists); |
loicortola/led-controller | android/app/src/main/java/com/loicortola/controller/command/behavior/Animable.java | // Path: android/app/src/main/java/com/loicortola/controller/model/Animation.java
// public class Animation {
//
// public int c;
// public long animationTime;
//
// public Animation(int c, long animationTime) {
// this.c = c;
// this.animationTime = animationTime;
// }
// }
| import com.loicortola.controller.model.Animation; | package com.loicortola.controller.command.behavior;
/**
* Created by loic on 28/03/2016.
*/
public interface Animable {
interface OnAnimationSetListener {
void onAnimationSet(boolean success);
}
| // Path: android/app/src/main/java/com/loicortola/controller/model/Animation.java
// public class Animation {
//
// public int c;
// public long animationTime;
//
// public Animation(int c, long animationTime) {
// this.c = c;
// this.animationTime = animationTime;
// }
// }
// Path: android/app/src/main/java/com/loicortola/controller/command/behavior/Animable.java
import com.loicortola.controller.model.Animation;
package com.loicortola.controller.command.behavior;
/**
* Created by loic on 28/03/2016.
*/
public interface Animable {
interface OnAnimationSetListener {
void onAnimationSet(boolean success);
}
| void animate(Animation a, OnAnimationSetListener l); |
loicortola/led-controller | android/app/src/main/java/com/loicortola/controller/model/Device.java | // Path: android/app/src/main/java/com/loicortola/controller/command/Command.java
// public interface Command {
// void execute();
// }
//
// Path: android/app/src/main/java/com/loicortola/controller/device/DeviceTypeResolver.java
// public interface DeviceTypeResolver<T> {
// boolean isSecure();
// boolean supports(NsdServiceInfo info);
// boolean supports(SsdpService service);
// boolean supports(Class<? extends Command> clazz);
// Device resolve(NsdServiceInfo info);
// Device resolve(SsdpService service);
// <T> T getRemoteControl(Device d);
// }
| import com.loicortola.controller.command.Command;
import com.loicortola.controller.device.DeviceTypeResolver;
import com.loicortola.controller.R; | package com.loicortola.controller.model;
/**
* Created by loic on 28/03/2016.
*/
public class Device {
protected Long dbId;
protected String id;
protected int iconDrawable;
protected String name;
protected String host;
protected String key; | // Path: android/app/src/main/java/com/loicortola/controller/command/Command.java
// public interface Command {
// void execute();
// }
//
// Path: android/app/src/main/java/com/loicortola/controller/device/DeviceTypeResolver.java
// public interface DeviceTypeResolver<T> {
// boolean isSecure();
// boolean supports(NsdServiceInfo info);
// boolean supports(SsdpService service);
// boolean supports(Class<? extends Command> clazz);
// Device resolve(NsdServiceInfo info);
// Device resolve(SsdpService service);
// <T> T getRemoteControl(Device d);
// }
// Path: android/app/src/main/java/com/loicortola/controller/model/Device.java
import com.loicortola.controller.command.Command;
import com.loicortola.controller.device.DeviceTypeResolver;
import com.loicortola.controller.R;
package com.loicortola.controller.model;
/**
* Created by loic on 28/03/2016.
*/
public class Device {
protected Long dbId;
protected String id;
protected int iconDrawable;
protected String name;
protected String host;
protected String key; | private DeviceTypeResolver resolver; |
loicortola/led-controller | android/app/src/main/java/com/loicortola/controller/model/Device.java | // Path: android/app/src/main/java/com/loicortola/controller/command/Command.java
// public interface Command {
// void execute();
// }
//
// Path: android/app/src/main/java/com/loicortola/controller/device/DeviceTypeResolver.java
// public interface DeviceTypeResolver<T> {
// boolean isSecure();
// boolean supports(NsdServiceInfo info);
// boolean supports(SsdpService service);
// boolean supports(Class<? extends Command> clazz);
// Device resolve(NsdServiceInfo info);
// Device resolve(SsdpService service);
// <T> T getRemoteControl(Device d);
// }
| import com.loicortola.controller.command.Command;
import com.loicortola.controller.device.DeviceTypeResolver;
import com.loicortola.controller.R; | package com.loicortola.controller.model;
/**
* Created by loic on 28/03/2016.
*/
public class Device {
protected Long dbId;
protected String id;
protected int iconDrawable;
protected String name;
protected String host;
protected String key;
private DeviceTypeResolver resolver;
public Device() {
}
| // Path: android/app/src/main/java/com/loicortola/controller/command/Command.java
// public interface Command {
// void execute();
// }
//
// Path: android/app/src/main/java/com/loicortola/controller/device/DeviceTypeResolver.java
// public interface DeviceTypeResolver<T> {
// boolean isSecure();
// boolean supports(NsdServiceInfo info);
// boolean supports(SsdpService service);
// boolean supports(Class<? extends Command> clazz);
// Device resolve(NsdServiceInfo info);
// Device resolve(SsdpService service);
// <T> T getRemoteControl(Device d);
// }
// Path: android/app/src/main/java/com/loicortola/controller/model/Device.java
import com.loicortola.controller.command.Command;
import com.loicortola.controller.device.DeviceTypeResolver;
import com.loicortola.controller.R;
package com.loicortola.controller.model;
/**
* Created by loic on 28/03/2016.
*/
public class Device {
protected Long dbId;
protected String id;
protected int iconDrawable;
protected String name;
protected String host;
protected String key;
private DeviceTypeResolver resolver;
public Device() {
}
| public boolean supports(Class<? extends Command> clazz) { |
loicortola/led-controller | android/com/loicortola/controller/DaoMaster.java | // Path: android/com/loicortola/controller/DeviceDao.java
// public class DeviceDao extends AbstractDao<Device, Long> {
//
// public static final String TABLENAME = "DEVICE";
//
// /**
// * Properties of entity Device.<br/>
// * Can be used for QueryBuilder and for referencing column names.
// */
// public static class Properties {
// public final static Property Id = new Property(0, Long.class, "id", true, "_id");
// public final static Property DeviceId = new Property(1, String.class, "deviceId", false, "DEVICE_ID");
// public final static Property Name = new Property(2, String.class, "name", false, "NAME");
// public final static Property Icon = new Property(3, long.class, "icon", false, "ICON");
// public final static Property Host = new Property(4, String.class, "host", false, "HOST");
// public final static Property Key = new Property(5, String.class, "key", false, "KEY");
// };
//
//
// public DeviceDao(DaoConfig config) {
// super(config);
// }
//
// public DeviceDao(DaoConfig config, DaoSession daoSession) {
// super(config, daoSession);
// }
//
// /** Creates the underlying database table. */
// public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
// String constraint = ifNotExists? "IF NOT EXISTS ": "";
// db.execSQL("CREATE TABLE " + constraint + "\"DEVICE\" (" + //
// "\"_id\" INTEGER PRIMARY KEY ," + // 0: id
// "\"DEVICE_ID\" TEXT NOT NULL UNIQUE ," + // 1: deviceId
// "\"NAME\" TEXT NOT NULL ," + // 2: name
// "\"ICON\" INTEGER NOT NULL ," + // 3: icon
// "\"HOST\" TEXT NOT NULL ," + // 4: host
// "\"KEY\" TEXT);"); // 5: key
// }
//
// /** Drops the underlying database table. */
// public static void dropTable(SQLiteDatabase db, boolean ifExists) {
// String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"DEVICE\"";
// db.execSQL(sql);
// }
//
// /** @inheritdoc */
// @Override
// protected void bindValues(SQLiteStatement stmt, Device entity) {
// stmt.clearBindings();
//
// Long id = entity.getId();
// if (id != null) {
// stmt.bindLong(1, id);
// }
// stmt.bindString(2, entity.getDeviceId());
// stmt.bindString(3, entity.getName());
// stmt.bindLong(4, entity.getIcon());
// stmt.bindString(5, entity.getHost());
//
// String key = entity.getKey();
// if (key != null) {
// stmt.bindString(6, key);
// }
// }
//
// /** @inheritdoc */
// @Override
// public Long readKey(Cursor cursor, int offset) {
// return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
// }
//
// /** @inheritdoc */
// @Override
// public Device readEntity(Cursor cursor, int offset) {
// Device entity = new Device( //
// cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
// cursor.getString(offset + 1), // deviceId
// cursor.getString(offset + 2), // name
// cursor.getLong(offset + 3), // icon
// cursor.getString(offset + 4), // host
// cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // key
// );
// return entity;
// }
//
// /** @inheritdoc */
// @Override
// public void readEntity(Cursor cursor, Device entity, int offset) {
// entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
// entity.setDeviceId(cursor.getString(offset + 1));
// entity.setName(cursor.getString(offset + 2));
// entity.setIcon(cursor.getLong(offset + 3));
// entity.setHost(cursor.getString(offset + 4));
// entity.setKey(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
// }
//
// /** @inheritdoc */
// @Override
// protected Long updateKeyAfterInsert(Device entity, long rowId) {
// entity.setId(rowId);
// return rowId;
// }
//
// /** @inheritdoc */
// @Override
// public Long getKey(Device entity) {
// if(entity != null) {
// return entity.getId();
// } else {
// return null;
// }
// }
//
// /** @inheritdoc */
// @Override
// protected boolean isEntityUpdateable() {
// return true;
// }
//
// }
| import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import de.greenrobot.dao.AbstractDaoMaster;
import de.greenrobot.dao.identityscope.IdentityScopeType;
import com.loicortola.controller.DeviceDao; | package com.loicortola.controller;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* Master of DAO (schema version 1000): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 1000;
/** Creates underlying database table using DAOs. */
public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) { | // Path: android/com/loicortola/controller/DeviceDao.java
// public class DeviceDao extends AbstractDao<Device, Long> {
//
// public static final String TABLENAME = "DEVICE";
//
// /**
// * Properties of entity Device.<br/>
// * Can be used for QueryBuilder and for referencing column names.
// */
// public static class Properties {
// public final static Property Id = new Property(0, Long.class, "id", true, "_id");
// public final static Property DeviceId = new Property(1, String.class, "deviceId", false, "DEVICE_ID");
// public final static Property Name = new Property(2, String.class, "name", false, "NAME");
// public final static Property Icon = new Property(3, long.class, "icon", false, "ICON");
// public final static Property Host = new Property(4, String.class, "host", false, "HOST");
// public final static Property Key = new Property(5, String.class, "key", false, "KEY");
// };
//
//
// public DeviceDao(DaoConfig config) {
// super(config);
// }
//
// public DeviceDao(DaoConfig config, DaoSession daoSession) {
// super(config, daoSession);
// }
//
// /** Creates the underlying database table. */
// public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
// String constraint = ifNotExists? "IF NOT EXISTS ": "";
// db.execSQL("CREATE TABLE " + constraint + "\"DEVICE\" (" + //
// "\"_id\" INTEGER PRIMARY KEY ," + // 0: id
// "\"DEVICE_ID\" TEXT NOT NULL UNIQUE ," + // 1: deviceId
// "\"NAME\" TEXT NOT NULL ," + // 2: name
// "\"ICON\" INTEGER NOT NULL ," + // 3: icon
// "\"HOST\" TEXT NOT NULL ," + // 4: host
// "\"KEY\" TEXT);"); // 5: key
// }
//
// /** Drops the underlying database table. */
// public static void dropTable(SQLiteDatabase db, boolean ifExists) {
// String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"DEVICE\"";
// db.execSQL(sql);
// }
//
// /** @inheritdoc */
// @Override
// protected void bindValues(SQLiteStatement stmt, Device entity) {
// stmt.clearBindings();
//
// Long id = entity.getId();
// if (id != null) {
// stmt.bindLong(1, id);
// }
// stmt.bindString(2, entity.getDeviceId());
// stmt.bindString(3, entity.getName());
// stmt.bindLong(4, entity.getIcon());
// stmt.bindString(5, entity.getHost());
//
// String key = entity.getKey();
// if (key != null) {
// stmt.bindString(6, key);
// }
// }
//
// /** @inheritdoc */
// @Override
// public Long readKey(Cursor cursor, int offset) {
// return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
// }
//
// /** @inheritdoc */
// @Override
// public Device readEntity(Cursor cursor, int offset) {
// Device entity = new Device( //
// cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
// cursor.getString(offset + 1), // deviceId
// cursor.getString(offset + 2), // name
// cursor.getLong(offset + 3), // icon
// cursor.getString(offset + 4), // host
// cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // key
// );
// return entity;
// }
//
// /** @inheritdoc */
// @Override
// public void readEntity(Cursor cursor, Device entity, int offset) {
// entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
// entity.setDeviceId(cursor.getString(offset + 1));
// entity.setName(cursor.getString(offset + 2));
// entity.setIcon(cursor.getLong(offset + 3));
// entity.setHost(cursor.getString(offset + 4));
// entity.setKey(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
// }
//
// /** @inheritdoc */
// @Override
// protected Long updateKeyAfterInsert(Device entity, long rowId) {
// entity.setId(rowId);
// return rowId;
// }
//
// /** @inheritdoc */
// @Override
// public Long getKey(Device entity) {
// if(entity != null) {
// return entity.getId();
// } else {
// return null;
// }
// }
//
// /** @inheritdoc */
// @Override
// protected boolean isEntityUpdateable() {
// return true;
// }
//
// }
// Path: android/com/loicortola/controller/DaoMaster.java
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import de.greenrobot.dao.AbstractDaoMaster;
import de.greenrobot.dao.identityscope.IdentityScopeType;
import com.loicortola.controller.DeviceDao;
package com.loicortola.controller;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* Master of DAO (schema version 1000): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 1000;
/** Creates underlying database table using DAOs. */
public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) { | DeviceDao.createTable(db, ifNotExists); |
loicortola/led-controller | android/app/src/main/java/com/loicortola/controller/ui/adapter/PresetAdapter.java | // Path: android/app/src/main/java/com/loicortola/controller/model/Preset.java
// public class Preset {
//
// public int drawableResId;
// public int stringResId;
// public Object content;
//
// public Preset drawableResId(int resId) {
// this.drawableResId = resId;
// return this;
// }
//
// public Preset stringResId(int resId) {
// this.stringResId = resId;
// return this;
// }
//
// public Preset content(Object content) {
// this.content = content;
// return this;
// }
//
// public Preset addTo(Collection<Preset> c) {
// if (c != null) {
// c.add(this);
// }
// return this;
// }
//
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.loicortola.controller.model.Preset;
import com.loicortola.controller.R;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List; | package com.loicortola.controller.ui.adapter;
/**
* Created by loic on 28/03/2016.
*/
public class PresetAdapter extends RecyclerView.Adapter<PresetAdapter.ViewHolder> {
private final Context mCtx; | // Path: android/app/src/main/java/com/loicortola/controller/model/Preset.java
// public class Preset {
//
// public int drawableResId;
// public int stringResId;
// public Object content;
//
// public Preset drawableResId(int resId) {
// this.drawableResId = resId;
// return this;
// }
//
// public Preset stringResId(int resId) {
// this.stringResId = resId;
// return this;
// }
//
// public Preset content(Object content) {
// this.content = content;
// return this;
// }
//
// public Preset addTo(Collection<Preset> c) {
// if (c != null) {
// c.add(this);
// }
// return this;
// }
//
// }
// Path: android/app/src/main/java/com/loicortola/controller/ui/adapter/PresetAdapter.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.loicortola.controller.model.Preset;
import com.loicortola.controller.R;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
package com.loicortola.controller.ui.adapter;
/**
* Created by loic on 28/03/2016.
*/
public class PresetAdapter extends RecyclerView.Adapter<PresetAdapter.ViewHolder> {
private final Context mCtx; | private List<Preset> mDataset; |
loicortola/led-controller | android/app/src/main/java/com/loicortola/controller/command/behavior/PresetAware.java | // Path: android/app/src/main/java/com/loicortola/controller/model/Preset.java
// public class Preset {
//
// public int drawableResId;
// public int stringResId;
// public Object content;
//
// public Preset drawableResId(int resId) {
// this.drawableResId = resId;
// return this;
// }
//
// public Preset stringResId(int resId) {
// this.stringResId = resId;
// return this;
// }
//
// public Preset content(Object content) {
// this.content = content;
// return this;
// }
//
// public Preset addTo(Collection<Preset> c) {
// if (c != null) {
// c.add(this);
// }
// return this;
// }
//
// }
| import com.loicortola.controller.model.Preset;
import java.util.List; | package com.loicortola.controller.command.behavior;
/**
* Created by loic on 28/03/2016.
*/
public interface PresetAware {
interface OnPresetChangedListener {
void onPresetChanged(boolean success);
}
interface OnPresetLoadedListener { | // Path: android/app/src/main/java/com/loicortola/controller/model/Preset.java
// public class Preset {
//
// public int drawableResId;
// public int stringResId;
// public Object content;
//
// public Preset drawableResId(int resId) {
// this.drawableResId = resId;
// return this;
// }
//
// public Preset stringResId(int resId) {
// this.stringResId = resId;
// return this;
// }
//
// public Preset content(Object content) {
// this.content = content;
// return this;
// }
//
// public Preset addTo(Collection<Preset> c) {
// if (c != null) {
// c.add(this);
// }
// return this;
// }
//
// }
// Path: android/app/src/main/java/com/loicortola/controller/command/behavior/PresetAware.java
import com.loicortola.controller.model.Preset;
import java.util.List;
package com.loicortola.controller.command.behavior;
/**
* Created by loic on 28/03/2016.
*/
public interface PresetAware {
interface OnPresetChangedListener {
void onPresetChanged(boolean success);
}
interface OnPresetLoadedListener { | void onPresetLoaded(Preset p); |
loicortola/led-controller | android/app/src/main/java/com/loicortola/controller/device/DeviceTypeResolver.java | // Path: android/app/src/main/java/com/loicortola/controller/command/Command.java
// public interface Command {
// void execute();
// }
//
// Path: android/app/src/main/java/com/loicortola/controller/model/Device.java
// public class Device {
//
// protected Long dbId;
// protected String id;
// protected int iconDrawable;
// protected String name;
// protected String host;
// protected String key;
// private DeviceTypeResolver resolver;
//
// public Device() {
//
// }
//
// public boolean supports(Class<? extends Command> clazz) {
// return resolver.supports(clazz);
// }
//
// public void setDbId(Long dbId) {
// this.dbId = dbId;
// }
//
// public Long getDbId() {
// return dbId;
// }
//
// public String getId() {
// return id;
// }
//
// public int getIconDrawable() {
// return iconDrawable;
// }
//
// public DeviceTypeResolver getResolver() {
// return resolver;
// }
//
// public <T> T getRemoteControl() {
// return (T) getResolver().getRemoteControl(this);
// }
//
// public String getName() {
// return name;
// }
//
// public String getHost() {
// return host;
// }
//
// public String getKey() {
// return key;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public void setIconDrawable(int iconDrawable) {
// this.iconDrawable = iconDrawable;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// public void setResolver(DeviceTypeResolver resolver) {
// this.resolver = resolver;
// }
//
// @Override
// public String toString() {
// return "Device{" +
// "dbId=" + dbId +
// ", id='" + id + '\'' +
// ", iconDrawable=" + iconDrawable +
// ", name='" + name + '\'' +
// ", host='" + host + '\'' +
// ", key='" + key + '\'' +
// ", resolver=" + resolver +
// '}';
// }
//
// public static Builder builder() {
// return new Builder();
// }
//
// public static class Builder {
//
// private Device d;
//
// private Builder() {
// d = new Device();
// d.iconDrawable = R.drawable.default_bulb;
// d.name = "Device X";
// }
//
// public Builder id(String id) {
// d.id = id;
// return this;
// }
//
// public Builder dbId(Long id) {
// d.dbId = id;
// return this;
// }
//
// public Builder icon(int iconDrawable) {
// d.iconDrawable = iconDrawable;
// return this;
// }
//
// public Builder name(String name) {
// d.name = name;
// return this;
// }
//
// public Builder host(String host) {
// d.host = host;
// return this;
// }
//
// public Builder key(String key) {
// d.key = key;
// return this;
// }
//
// public Builder resolver(DeviceTypeResolver resolver) {
// d.resolver = resolver;
// return this;
// }
//
// public Device build() {
// return d;
// }
// }
//
// }
| import android.net.nsd.NsdServiceInfo;
import com.loicortola.controller.command.Command;
import com.loicortola.controller.model.Device;
import io.resourcepool.jarpic.model.SsdpService; | package com.loicortola.controller.device;
/**
* Created by loic on 28/03/2016.
*/
public interface DeviceTypeResolver<T> {
boolean isSecure();
boolean supports(NsdServiceInfo info);
boolean supports(SsdpService service); | // Path: android/app/src/main/java/com/loicortola/controller/command/Command.java
// public interface Command {
// void execute();
// }
//
// Path: android/app/src/main/java/com/loicortola/controller/model/Device.java
// public class Device {
//
// protected Long dbId;
// protected String id;
// protected int iconDrawable;
// protected String name;
// protected String host;
// protected String key;
// private DeviceTypeResolver resolver;
//
// public Device() {
//
// }
//
// public boolean supports(Class<? extends Command> clazz) {
// return resolver.supports(clazz);
// }
//
// public void setDbId(Long dbId) {
// this.dbId = dbId;
// }
//
// public Long getDbId() {
// return dbId;
// }
//
// public String getId() {
// return id;
// }
//
// public int getIconDrawable() {
// return iconDrawable;
// }
//
// public DeviceTypeResolver getResolver() {
// return resolver;
// }
//
// public <T> T getRemoteControl() {
// return (T) getResolver().getRemoteControl(this);
// }
//
// public String getName() {
// return name;
// }
//
// public String getHost() {
// return host;
// }
//
// public String getKey() {
// return key;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public void setIconDrawable(int iconDrawable) {
// this.iconDrawable = iconDrawable;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// public void setResolver(DeviceTypeResolver resolver) {
// this.resolver = resolver;
// }
//
// @Override
// public String toString() {
// return "Device{" +
// "dbId=" + dbId +
// ", id='" + id + '\'' +
// ", iconDrawable=" + iconDrawable +
// ", name='" + name + '\'' +
// ", host='" + host + '\'' +
// ", key='" + key + '\'' +
// ", resolver=" + resolver +
// '}';
// }
//
// public static Builder builder() {
// return new Builder();
// }
//
// public static class Builder {
//
// private Device d;
//
// private Builder() {
// d = new Device();
// d.iconDrawable = R.drawable.default_bulb;
// d.name = "Device X";
// }
//
// public Builder id(String id) {
// d.id = id;
// return this;
// }
//
// public Builder dbId(Long id) {
// d.dbId = id;
// return this;
// }
//
// public Builder icon(int iconDrawable) {
// d.iconDrawable = iconDrawable;
// return this;
// }
//
// public Builder name(String name) {
// d.name = name;
// return this;
// }
//
// public Builder host(String host) {
// d.host = host;
// return this;
// }
//
// public Builder key(String key) {
// d.key = key;
// return this;
// }
//
// public Builder resolver(DeviceTypeResolver resolver) {
// d.resolver = resolver;
// return this;
// }
//
// public Device build() {
// return d;
// }
// }
//
// }
// Path: android/app/src/main/java/com/loicortola/controller/device/DeviceTypeResolver.java
import android.net.nsd.NsdServiceInfo;
import com.loicortola.controller.command.Command;
import com.loicortola.controller.model.Device;
import io.resourcepool.jarpic.model.SsdpService;
package com.loicortola.controller.device;
/**
* Created by loic on 28/03/2016.
*/
public interface DeviceTypeResolver<T> {
boolean isSecure();
boolean supports(NsdServiceInfo info);
boolean supports(SsdpService service); | boolean supports(Class<? extends Command> clazz); |
loicortola/led-controller | android/app/src/main/java/com/loicortola/controller/device/DeviceTypeResolver.java | // Path: android/app/src/main/java/com/loicortola/controller/command/Command.java
// public interface Command {
// void execute();
// }
//
// Path: android/app/src/main/java/com/loicortola/controller/model/Device.java
// public class Device {
//
// protected Long dbId;
// protected String id;
// protected int iconDrawable;
// protected String name;
// protected String host;
// protected String key;
// private DeviceTypeResolver resolver;
//
// public Device() {
//
// }
//
// public boolean supports(Class<? extends Command> clazz) {
// return resolver.supports(clazz);
// }
//
// public void setDbId(Long dbId) {
// this.dbId = dbId;
// }
//
// public Long getDbId() {
// return dbId;
// }
//
// public String getId() {
// return id;
// }
//
// public int getIconDrawable() {
// return iconDrawable;
// }
//
// public DeviceTypeResolver getResolver() {
// return resolver;
// }
//
// public <T> T getRemoteControl() {
// return (T) getResolver().getRemoteControl(this);
// }
//
// public String getName() {
// return name;
// }
//
// public String getHost() {
// return host;
// }
//
// public String getKey() {
// return key;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public void setIconDrawable(int iconDrawable) {
// this.iconDrawable = iconDrawable;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// public void setResolver(DeviceTypeResolver resolver) {
// this.resolver = resolver;
// }
//
// @Override
// public String toString() {
// return "Device{" +
// "dbId=" + dbId +
// ", id='" + id + '\'' +
// ", iconDrawable=" + iconDrawable +
// ", name='" + name + '\'' +
// ", host='" + host + '\'' +
// ", key='" + key + '\'' +
// ", resolver=" + resolver +
// '}';
// }
//
// public static Builder builder() {
// return new Builder();
// }
//
// public static class Builder {
//
// private Device d;
//
// private Builder() {
// d = new Device();
// d.iconDrawable = R.drawable.default_bulb;
// d.name = "Device X";
// }
//
// public Builder id(String id) {
// d.id = id;
// return this;
// }
//
// public Builder dbId(Long id) {
// d.dbId = id;
// return this;
// }
//
// public Builder icon(int iconDrawable) {
// d.iconDrawable = iconDrawable;
// return this;
// }
//
// public Builder name(String name) {
// d.name = name;
// return this;
// }
//
// public Builder host(String host) {
// d.host = host;
// return this;
// }
//
// public Builder key(String key) {
// d.key = key;
// return this;
// }
//
// public Builder resolver(DeviceTypeResolver resolver) {
// d.resolver = resolver;
// return this;
// }
//
// public Device build() {
// return d;
// }
// }
//
// }
| import android.net.nsd.NsdServiceInfo;
import com.loicortola.controller.command.Command;
import com.loicortola.controller.model.Device;
import io.resourcepool.jarpic.model.SsdpService; | package com.loicortola.controller.device;
/**
* Created by loic on 28/03/2016.
*/
public interface DeviceTypeResolver<T> {
boolean isSecure();
boolean supports(NsdServiceInfo info);
boolean supports(SsdpService service);
boolean supports(Class<? extends Command> clazz); | // Path: android/app/src/main/java/com/loicortola/controller/command/Command.java
// public interface Command {
// void execute();
// }
//
// Path: android/app/src/main/java/com/loicortola/controller/model/Device.java
// public class Device {
//
// protected Long dbId;
// protected String id;
// protected int iconDrawable;
// protected String name;
// protected String host;
// protected String key;
// private DeviceTypeResolver resolver;
//
// public Device() {
//
// }
//
// public boolean supports(Class<? extends Command> clazz) {
// return resolver.supports(clazz);
// }
//
// public void setDbId(Long dbId) {
// this.dbId = dbId;
// }
//
// public Long getDbId() {
// return dbId;
// }
//
// public String getId() {
// return id;
// }
//
// public int getIconDrawable() {
// return iconDrawable;
// }
//
// public DeviceTypeResolver getResolver() {
// return resolver;
// }
//
// public <T> T getRemoteControl() {
// return (T) getResolver().getRemoteControl(this);
// }
//
// public String getName() {
// return name;
// }
//
// public String getHost() {
// return host;
// }
//
// public String getKey() {
// return key;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public void setIconDrawable(int iconDrawable) {
// this.iconDrawable = iconDrawable;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// public void setResolver(DeviceTypeResolver resolver) {
// this.resolver = resolver;
// }
//
// @Override
// public String toString() {
// return "Device{" +
// "dbId=" + dbId +
// ", id='" + id + '\'' +
// ", iconDrawable=" + iconDrawable +
// ", name='" + name + '\'' +
// ", host='" + host + '\'' +
// ", key='" + key + '\'' +
// ", resolver=" + resolver +
// '}';
// }
//
// public static Builder builder() {
// return new Builder();
// }
//
// public static class Builder {
//
// private Device d;
//
// private Builder() {
// d = new Device();
// d.iconDrawable = R.drawable.default_bulb;
// d.name = "Device X";
// }
//
// public Builder id(String id) {
// d.id = id;
// return this;
// }
//
// public Builder dbId(Long id) {
// d.dbId = id;
// return this;
// }
//
// public Builder icon(int iconDrawable) {
// d.iconDrawable = iconDrawable;
// return this;
// }
//
// public Builder name(String name) {
// d.name = name;
// return this;
// }
//
// public Builder host(String host) {
// d.host = host;
// return this;
// }
//
// public Builder key(String key) {
// d.key = key;
// return this;
// }
//
// public Builder resolver(DeviceTypeResolver resolver) {
// d.resolver = resolver;
// return this;
// }
//
// public Device build() {
// return d;
// }
// }
//
// }
// Path: android/app/src/main/java/com/loicortola/controller/device/DeviceTypeResolver.java
import android.net.nsd.NsdServiceInfo;
import com.loicortola.controller.command.Command;
import com.loicortola.controller.model.Device;
import io.resourcepool.jarpic.model.SsdpService;
package com.loicortola.controller.device;
/**
* Created by loic on 28/03/2016.
*/
public interface DeviceTypeResolver<T> {
boolean isSecure();
boolean supports(NsdServiceInfo info);
boolean supports(SsdpService service);
boolean supports(Class<? extends Command> clazz); | Device resolve(NsdServiceInfo info); |
loicortola/led-controller | android/app/src/main/java/com/loicortola/controller/command/AnimateCommand.java | // Path: android/app/src/main/java/com/loicortola/controller/command/behavior/Animable.java
// public interface Animable {
//
// interface OnAnimationSetListener {
// void onAnimationSet(boolean success);
// }
//
// void animate(Animation a, OnAnimationSetListener l);
//
// }
//
// Path: android/app/src/main/java/com/loicortola/controller/model/Animation.java
// public class Animation {
//
// public int c;
// public long animationTime;
//
// public Animation(int c, long animationTime) {
// this.c = c;
// this.animationTime = animationTime;
// }
// }
| import com.loicortola.controller.command.behavior.Animable;
import com.loicortola.controller.model.Animation;
import java.util.concurrent.Future; | package com.loicortola.controller.command;
/**
* Created by loic on 28/03/2016.
*/
public class AnimateCommand implements Command {
private Animable a; | // Path: android/app/src/main/java/com/loicortola/controller/command/behavior/Animable.java
// public interface Animable {
//
// interface OnAnimationSetListener {
// void onAnimationSet(boolean success);
// }
//
// void animate(Animation a, OnAnimationSetListener l);
//
// }
//
// Path: android/app/src/main/java/com/loicortola/controller/model/Animation.java
// public class Animation {
//
// public int c;
// public long animationTime;
//
// public Animation(int c, long animationTime) {
// this.c = c;
// this.animationTime = animationTime;
// }
// }
// Path: android/app/src/main/java/com/loicortola/controller/command/AnimateCommand.java
import com.loicortola.controller.command.behavior.Animable;
import com.loicortola.controller.model.Animation;
import java.util.concurrent.Future;
package com.loicortola.controller.command;
/**
* Created by loic on 28/03/2016.
*/
public class AnimateCommand implements Command {
private Animable a; | private Animation t; |
loicortola/led-controller | android/app/src/main/java/com/loicortola/controller/device/DeviceTypeResolverService.java | // Path: android/app/src/mocked/java/com/loicortola/controller/library/ledstrip/resolver/LedStripTypeResolver.java
// public class LedStripTypeResolver implements DeviceTypeResolver<LedStripRemoteControl> {
//
// @Override
// public boolean isSecure() {
// return true;
// }
//
// @Override
// public boolean supports(NsdServiceInfo info) {
// return false;
// }
//
// @Override
// public boolean supports(SsdpService service) {
// return false;
// }
//
// @Override
// public boolean supports(Class<? extends Command> clazz) {
// if (ChangeColorCommand.class.equals(clazz)) {
// return true;
// }
//
// if (CheckSecretKeyCommand.class.equals(clazz)) {
// return true;
// }
//
// if (SwitchCommand.class.equals(clazz)) {
// return true;
// }
//
// if (AnimateCommand.class.equals(clazz)) {
// return true;
// }
//
// if (CheckHealthCommand.class.equals(clazz)) {
// return true;
// }
//
// if (LoadPresetCommand.class.equals(clazz)) {
// return true;
// }
//
// return false;
// }
//
// @Override
// public Device resolve(NsdServiceInfo info) {
// return null;
// }
//
// @Override
// public Device resolve(SsdpService service) {
// return null;
// }
//
// @Override
// public LedStripRemoteControl getRemoteControl(Device d) {
// return new LedStripRemoteControl(d);
// }
// }
| import android.net.nsd.NsdServiceInfo;
import com.loicortola.controller.library.ledstrip.resolver.LedStripTypeResolver;
import java.util.ArrayList;
import java.util.List;
import io.resourcepool.jarpic.model.SsdpService; | package com.loicortola.controller.device;
/**
* Created by loic on 28/03/2016.
*/
public class DeviceTypeResolverService {
private List<DeviceTypeResolver> typeResolvers;
public DeviceTypeResolverService() {
typeResolvers = new ArrayList<>(); | // Path: android/app/src/mocked/java/com/loicortola/controller/library/ledstrip/resolver/LedStripTypeResolver.java
// public class LedStripTypeResolver implements DeviceTypeResolver<LedStripRemoteControl> {
//
// @Override
// public boolean isSecure() {
// return true;
// }
//
// @Override
// public boolean supports(NsdServiceInfo info) {
// return false;
// }
//
// @Override
// public boolean supports(SsdpService service) {
// return false;
// }
//
// @Override
// public boolean supports(Class<? extends Command> clazz) {
// if (ChangeColorCommand.class.equals(clazz)) {
// return true;
// }
//
// if (CheckSecretKeyCommand.class.equals(clazz)) {
// return true;
// }
//
// if (SwitchCommand.class.equals(clazz)) {
// return true;
// }
//
// if (AnimateCommand.class.equals(clazz)) {
// return true;
// }
//
// if (CheckHealthCommand.class.equals(clazz)) {
// return true;
// }
//
// if (LoadPresetCommand.class.equals(clazz)) {
// return true;
// }
//
// return false;
// }
//
// @Override
// public Device resolve(NsdServiceInfo info) {
// return null;
// }
//
// @Override
// public Device resolve(SsdpService service) {
// return null;
// }
//
// @Override
// public LedStripRemoteControl getRemoteControl(Device d) {
// return new LedStripRemoteControl(d);
// }
// }
// Path: android/app/src/main/java/com/loicortola/controller/device/DeviceTypeResolverService.java
import android.net.nsd.NsdServiceInfo;
import com.loicortola.controller.library.ledstrip.resolver.LedStripTypeResolver;
import java.util.ArrayList;
import java.util.List;
import io.resourcepool.jarpic.model.SsdpService;
package com.loicortola.controller.device;
/**
* Created by loic on 28/03/2016.
*/
public class DeviceTypeResolverService {
private List<DeviceTypeResolver> typeResolvers;
public DeviceTypeResolverService() {
typeResolvers = new ArrayList<>(); | typeResolvers.add(new LedStripTypeResolver()); |
loicortola/led-controller | android/app/src/main/java/com/loicortola/controller/library/ledstrip/service/LedStripService.java | // Path: android/app/src/main/java/com/loicortola/controller/library/ledstrip/model/Color.java
// public class Color {
// public int r;
// public int g;
// public int b;
// }
//
// Path: android/app/src/main/java/com/loicortola/controller/library/ledstrip/model/Status.java
// public class Status {
// public int mode;
// public boolean switchedOn;
// public Color color;
// public Animation animation;
// public List<Animation> animationSet;
// }
| import com.loicortola.controller.library.ledstrip.model.Color;
import com.loicortola.controller.library.ledstrip.model.Status;
import java.util.List;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.POST;
import retrofit2.http.Query; | package com.loicortola.controller.library.ledstrip.service;
/**
* Created by loic on 28/03/2016.
*/
public interface LedStripService {
@GET("api/status") | // Path: android/app/src/main/java/com/loicortola/controller/library/ledstrip/model/Color.java
// public class Color {
// public int r;
// public int g;
// public int b;
// }
//
// Path: android/app/src/main/java/com/loicortola/controller/library/ledstrip/model/Status.java
// public class Status {
// public int mode;
// public boolean switchedOn;
// public Color color;
// public Animation animation;
// public List<Animation> animationSet;
// }
// Path: android/app/src/main/java/com/loicortola/controller/library/ledstrip/service/LedStripService.java
import com.loicortola.controller.library.ledstrip.model.Color;
import com.loicortola.controller.library.ledstrip.model.Status;
import java.util.List;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.POST;
import retrofit2.http.Query;
package com.loicortola.controller.library.ledstrip.service;
/**
* Created by loic on 28/03/2016.
*/
public interface LedStripService {
@GET("api/status") | Call<Status> getStatus(@Header("Authorization") String key); |
loicortola/led-controller | android/app/src/main/java/com/loicortola/controller/command/LoadPresetCommand.java | // Path: android/app/src/main/java/com/loicortola/controller/command/behavior/Colorable.java
// public interface Colorable {
//
// interface OnColorChangedListener {
// void onColorSet(boolean success);
// }
// interface OnColorGetListener {
// void onColorGet(Integer c);
// }
//
// void changeColor(int c, OnColorChangedListener l);
// void setColor(int c, OnColorChangedListener l);
// void getColor(OnColorGetListener l);
//
// }
//
// Path: android/app/src/main/java/com/loicortola/controller/command/behavior/PresetAware.java
// public interface PresetAware {
//
// interface OnPresetChangedListener {
// void onPresetChanged(boolean success);
// }
// interface OnPresetLoadedListener {
// void onPresetLoaded(Preset p);
// }
// List<Preset> getPresets();
// void setPreset(Preset p, OnPresetChangedListener l);
// void getPreset(OnPresetLoadedListener l);
//
// }
//
// Path: android/app/src/main/java/com/loicortola/controller/model/Preset.java
// public class Preset {
//
// public int drawableResId;
// public int stringResId;
// public Object content;
//
// public Preset drawableResId(int resId) {
// this.drawableResId = resId;
// return this;
// }
//
// public Preset stringResId(int resId) {
// this.stringResId = resId;
// return this;
// }
//
// public Preset content(Object content) {
// this.content = content;
// return this;
// }
//
// public Preset addTo(Collection<Preset> c) {
// if (c != null) {
// c.add(this);
// }
// return this;
// }
//
// }
| import com.loicortola.controller.command.behavior.Colorable;
import com.loicortola.controller.command.behavior.PresetAware;
import com.loicortola.controller.model.Preset; | package com.loicortola.controller.command;
/**
* Created by loic on 28/03/2016.
*/
public class LoadPresetCommand implements Command {
private PresetAware p; | // Path: android/app/src/main/java/com/loicortola/controller/command/behavior/Colorable.java
// public interface Colorable {
//
// interface OnColorChangedListener {
// void onColorSet(boolean success);
// }
// interface OnColorGetListener {
// void onColorGet(Integer c);
// }
//
// void changeColor(int c, OnColorChangedListener l);
// void setColor(int c, OnColorChangedListener l);
// void getColor(OnColorGetListener l);
//
// }
//
// Path: android/app/src/main/java/com/loicortola/controller/command/behavior/PresetAware.java
// public interface PresetAware {
//
// interface OnPresetChangedListener {
// void onPresetChanged(boolean success);
// }
// interface OnPresetLoadedListener {
// void onPresetLoaded(Preset p);
// }
// List<Preset> getPresets();
// void setPreset(Preset p, OnPresetChangedListener l);
// void getPreset(OnPresetLoadedListener l);
//
// }
//
// Path: android/app/src/main/java/com/loicortola/controller/model/Preset.java
// public class Preset {
//
// public int drawableResId;
// public int stringResId;
// public Object content;
//
// public Preset drawableResId(int resId) {
// this.drawableResId = resId;
// return this;
// }
//
// public Preset stringResId(int resId) {
// this.stringResId = resId;
// return this;
// }
//
// public Preset content(Object content) {
// this.content = content;
// return this;
// }
//
// public Preset addTo(Collection<Preset> c) {
// if (c != null) {
// c.add(this);
// }
// return this;
// }
//
// }
// Path: android/app/src/main/java/com/loicortola/controller/command/LoadPresetCommand.java
import com.loicortola.controller.command.behavior.Colorable;
import com.loicortola.controller.command.behavior.PresetAware;
import com.loicortola.controller.model.Preset;
package com.loicortola.controller.command;
/**
* Created by loic on 28/03/2016.
*/
public class LoadPresetCommand implements Command {
private PresetAware p; | private Preset t; |
jlaw90/Grimja | liblab/src/com/sqrt/liblab/entry/model/set/Sector.java | // Path: liblab/src/com/sqrt/liblab/threed/Vector3f.java
// public class Vector3f implements Comparable<Vector3f> {
// public final float x, y, z;
// public static final Vector3f zero = new Vector3f(0, 0, 0);
//
// public Vector3f(float x, float y, float z) {
// this.x = x;
// this.y = y;
// this.z = z;
// }
//
// public boolean equals(Object o) {
// return o == this || (o instanceof Vector3f && equals((Vector3f) o));
// }
//
// public boolean equals(Vector3f v) {
// return v == this || (v.x == x && v.y == y && v.z == z);
// }
//
// public int hashCode() {
// return ((Float.floatToIntBits(x) & 0x3ff) << 20) | ((Float.floatToIntBits(y) & 0x3ff) << 10) |
// (Float.floatToIntBits(z)&0x3ff);
// }
//
// public int compareTo(Vector3f o) {
// return Float.compare(x, o.x) + Float.compare(y, o.y) + Float.compare(z, o.z);
// }
//
// public Vector3f add(Vector3f v) {
// return new Vector3f(x+v.x, y+v.y, z+v.z);
// }
//
// public Vector3f sub(Vector3f v) {
// return new Vector3f(x-v.x, y-v.y, z-v.z);
// }
//
// public Vector3f mult(float f) {
// return new Vector3f(x*f, y*f, z*f);
// }
//
// public Vector3f div(float f) {
// return new Vector3f(x/f, y/f, z/f);
// }
//
// public float length() {
// return (float)Math.sqrt(x*x+y*y+z*z);
// }
//
// public float dot(Vector3f o) {
// return (x*o.x)+(y*o.y)+(z*o.z);
// }
//
// public Vector3f cross(Vector3f o) {
// float resX = ((y * o.z) - (z * o.y));
// float resY = ((z * o.x) - (x * o.z));
// float resZ = ((x * o.y) - (y * o.x));
// return new Vector3f(resX, resY, resZ);
// }
// }
| import com.sqrt.liblab.threed.Vector3f; | /*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of LibLab.
*
* LibLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sqrt.liblab.entry.model.set;
/**
* Created by James on 30/09/2014.
*/
public class Sector {
public String name;
public int id;
public String type;
public boolean defaultVisibility;
public float height; | // Path: liblab/src/com/sqrt/liblab/threed/Vector3f.java
// public class Vector3f implements Comparable<Vector3f> {
// public final float x, y, z;
// public static final Vector3f zero = new Vector3f(0, 0, 0);
//
// public Vector3f(float x, float y, float z) {
// this.x = x;
// this.y = y;
// this.z = z;
// }
//
// public boolean equals(Object o) {
// return o == this || (o instanceof Vector3f && equals((Vector3f) o));
// }
//
// public boolean equals(Vector3f v) {
// return v == this || (v.x == x && v.y == y && v.z == z);
// }
//
// public int hashCode() {
// return ((Float.floatToIntBits(x) & 0x3ff) << 20) | ((Float.floatToIntBits(y) & 0x3ff) << 10) |
// (Float.floatToIntBits(z)&0x3ff);
// }
//
// public int compareTo(Vector3f o) {
// return Float.compare(x, o.x) + Float.compare(y, o.y) + Float.compare(z, o.z);
// }
//
// public Vector3f add(Vector3f v) {
// return new Vector3f(x+v.x, y+v.y, z+v.z);
// }
//
// public Vector3f sub(Vector3f v) {
// return new Vector3f(x-v.x, y-v.y, z-v.z);
// }
//
// public Vector3f mult(float f) {
// return new Vector3f(x*f, y*f, z*f);
// }
//
// public Vector3f div(float f) {
// return new Vector3f(x/f, y/f, z/f);
// }
//
// public float length() {
// return (float)Math.sqrt(x*x+y*y+z*z);
// }
//
// public float dot(Vector3f o) {
// return (x*o.x)+(y*o.y)+(z*o.z);
// }
//
// public Vector3f cross(Vector3f o) {
// float resX = ((y * o.z) - (z * o.y));
// float resY = ((z * o.x) - (x * o.z));
// float resZ = ((x * o.y) - (y * o.x));
// return new Vector3f(resX, resY, resZ);
// }
// }
// Path: liblab/src/com/sqrt/liblab/entry/model/set/Sector.java
import com.sqrt.liblab.threed.Vector3f;
/*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of LibLab.
*
* LibLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sqrt.liblab.entry.model.set;
/**
* Created by James on 30/09/2014.
*/
public class Sector {
public String name;
public int id;
public String type;
public boolean defaultVisibility;
public float height; | public Vector3f[] vertices; |
jlaw90/Grimja | grimedi/src/com/sqrt4/grimedi/ui/editor/MaterialView.java | // Path: liblab/src/com/sqrt/liblab/entry/model/Material.java
// public class Material extends LabEntry {
// /**
// * The textures
// */
// public final List<Texture> textures = new LinkedList<Texture>();
//
// public Material(LabFile container, String name) {
// super(container, name);
// }
// }
//
// Path: liblab/src/com/sqrt/liblab/entry/model/Texture.java
// public class Texture {
// /**
// * Whether index 0 should be transparent
// */
// public boolean hasAlpha;
// /**
// * The width of this texture in pixels
// */
// public final int width;
// /**
// * The height of this texture in pixels
// */
// public final int height;
// /**
// * Indices into a colormap
// */
// public final byte[] indices;
//
// /**
// * Constructs a new texture of the specified dimension with the specified indices
// * @param width the width of the texture
// * @param height the height of the texture
// * @param indices the indices into the colormap
// */
// public Texture(int width, int height, byte[] indices) {
// this.width = width;
// this.height = height;
// this.indices = indices;
// }
//
// /**
// * Returns a bufferedimage that represents this texture when indexed against the specified colormap
// * @param colorMap the colormap that contains the colors
// * @return an image
// */
// public BufferedImage render(ColorMap colorMap) {
// if (colorMap == null)
// return null;
// BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED, colorMap.toColorModel());
// bi.getRaster().setDataElements(0, 0, width, height, indices);
// return bi;
// }
// }
//
// Path: grimedi/src/com/sqrt4/grimedi/ui/component/ColorMapSelector.java
// public class ColorMapSelector extends JPanel {
// private LabCollection _last;
//
// public ColorMapSelector() {
// initComponents();
// }
//
// public void setLabFile(LabFile container) {
// if (container.container == _last)
// return;
// _last = container.container;
// Vector<DataSource> colorMaps = new Vector<DataSource>();
// colorMaps.addAll(container.container.findByType(ColorMap.class));
// colorMapSelector.setModel(new DefaultComboBoxModel(colorMaps));
// }
//
// public void addItemListener(ItemListener listener) {
// colorMapSelector.addItemListener(listener);
// }
//
// public void removeItemListener(ItemListener listener) {
// colorMapSelector.removeItemListener(listener);
// }
//
// public ColorMap getSelected() {
// DataSource edp = (DataSource) colorMapSelector.getSelectedItem();
// try {
// edp.position(0);
// return (ColorMap) CodecMapper.codecForProvider(edp).read(edp);
// } catch (IOException e) {
// MainWindow.getInstance().handleException(e);
// return null;
// }
// }
//
// public void setEnabled(boolean enabled) {
// super.setEnabled(enabled);
// colorMapSelector.setEnabled(enabled);
// }
//
// private void createUIComponents() {
// colorMapSelector = new JComboBox();
// }
//
// private void initComponents() {
// // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
// createUIComponents();
//
//
// //======== this ========
// setLayout(new BorderLayout());
// add(colorMapSelector, BorderLayout.CENTER);
// // JFormDesigner - End of component initialization //GEN-END:initComponents
// }
//
// // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// private JComboBox colorMapSelector;
// // JFormDesigner - End of variables declaration //GEN-END:variables
// }
| import javax.swing.event.ListDataListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map;
import com.sqrt.liblab.entry.model.Material;
import com.sqrt.liblab.entry.model.Texture;
import com.sqrt4.grimedi.ui.component.ColorMapSelector;
import javax.swing.*; |
/*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of GrimEdi.
*
* GrimEdi is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Created by JFormDesigner on Mon Mar 18 20:01:59 GMT 2013
*/
package com.sqrt4.grimedi.ui.editor;
/**
* @author James Lawrence
*/
public class MaterialView extends EditorPanel<Material> {
public MaterialView() {
initComponents();
}
ImageIcon icon = new ImageIcon(getClass().getResource("/material.png"));
public ImageIcon getIcon() {
return icon;
}
private void updatePreview() {
preview.setIcon(null);
if (imageList.getSelectedValue() == null || colorMapSelector.getSelected() == null)
return; | // Path: liblab/src/com/sqrt/liblab/entry/model/Material.java
// public class Material extends LabEntry {
// /**
// * The textures
// */
// public final List<Texture> textures = new LinkedList<Texture>();
//
// public Material(LabFile container, String name) {
// super(container, name);
// }
// }
//
// Path: liblab/src/com/sqrt/liblab/entry/model/Texture.java
// public class Texture {
// /**
// * Whether index 0 should be transparent
// */
// public boolean hasAlpha;
// /**
// * The width of this texture in pixels
// */
// public final int width;
// /**
// * The height of this texture in pixels
// */
// public final int height;
// /**
// * Indices into a colormap
// */
// public final byte[] indices;
//
// /**
// * Constructs a new texture of the specified dimension with the specified indices
// * @param width the width of the texture
// * @param height the height of the texture
// * @param indices the indices into the colormap
// */
// public Texture(int width, int height, byte[] indices) {
// this.width = width;
// this.height = height;
// this.indices = indices;
// }
//
// /**
// * Returns a bufferedimage that represents this texture when indexed against the specified colormap
// * @param colorMap the colormap that contains the colors
// * @return an image
// */
// public BufferedImage render(ColorMap colorMap) {
// if (colorMap == null)
// return null;
// BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED, colorMap.toColorModel());
// bi.getRaster().setDataElements(0, 0, width, height, indices);
// return bi;
// }
// }
//
// Path: grimedi/src/com/sqrt4/grimedi/ui/component/ColorMapSelector.java
// public class ColorMapSelector extends JPanel {
// private LabCollection _last;
//
// public ColorMapSelector() {
// initComponents();
// }
//
// public void setLabFile(LabFile container) {
// if (container.container == _last)
// return;
// _last = container.container;
// Vector<DataSource> colorMaps = new Vector<DataSource>();
// colorMaps.addAll(container.container.findByType(ColorMap.class));
// colorMapSelector.setModel(new DefaultComboBoxModel(colorMaps));
// }
//
// public void addItemListener(ItemListener listener) {
// colorMapSelector.addItemListener(listener);
// }
//
// public void removeItemListener(ItemListener listener) {
// colorMapSelector.removeItemListener(listener);
// }
//
// public ColorMap getSelected() {
// DataSource edp = (DataSource) colorMapSelector.getSelectedItem();
// try {
// edp.position(0);
// return (ColorMap) CodecMapper.codecForProvider(edp).read(edp);
// } catch (IOException e) {
// MainWindow.getInstance().handleException(e);
// return null;
// }
// }
//
// public void setEnabled(boolean enabled) {
// super.setEnabled(enabled);
// colorMapSelector.setEnabled(enabled);
// }
//
// private void createUIComponents() {
// colorMapSelector = new JComboBox();
// }
//
// private void initComponents() {
// // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
// createUIComponents();
//
//
// //======== this ========
// setLayout(new BorderLayout());
// add(colorMapSelector, BorderLayout.CENTER);
// // JFormDesigner - End of component initialization //GEN-END:initComponents
// }
//
// // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// private JComboBox colorMapSelector;
// // JFormDesigner - End of variables declaration //GEN-END:variables
// }
// Path: grimedi/src/com/sqrt4/grimedi/ui/editor/MaterialView.java
import javax.swing.event.ListDataListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map;
import com.sqrt.liblab.entry.model.Material;
import com.sqrt.liblab.entry.model.Texture;
import com.sqrt4.grimedi.ui.component.ColorMapSelector;
import javax.swing.*;
/*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of GrimEdi.
*
* GrimEdi is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Created by JFormDesigner on Mon Mar 18 20:01:59 GMT 2013
*/
package com.sqrt4.grimedi.ui.editor;
/**
* @author James Lawrence
*/
public class MaterialView extends EditorPanel<Material> {
public MaterialView() {
initComponents();
}
ImageIcon icon = new ImageIcon(getClass().getResource("/material.png"));
public ImageIcon getIcon() {
return icon;
}
private void updatePreview() {
preview.setIcon(null);
if (imageList.getSelectedValue() == null || colorMapSelector.getSelected() == null)
return; | preview.setIcon(new ImageIcon(((Texture) imageList.getSelectedValue()).render(colorMapSelector.getSelected()))); |
jlaw90/Grimja | grimedi/src/com/sqrt4/grimedi/ui/editor/MaterialView.java | // Path: liblab/src/com/sqrt/liblab/entry/model/Material.java
// public class Material extends LabEntry {
// /**
// * The textures
// */
// public final List<Texture> textures = new LinkedList<Texture>();
//
// public Material(LabFile container, String name) {
// super(container, name);
// }
// }
//
// Path: liblab/src/com/sqrt/liblab/entry/model/Texture.java
// public class Texture {
// /**
// * Whether index 0 should be transparent
// */
// public boolean hasAlpha;
// /**
// * The width of this texture in pixels
// */
// public final int width;
// /**
// * The height of this texture in pixels
// */
// public final int height;
// /**
// * Indices into a colormap
// */
// public final byte[] indices;
//
// /**
// * Constructs a new texture of the specified dimension with the specified indices
// * @param width the width of the texture
// * @param height the height of the texture
// * @param indices the indices into the colormap
// */
// public Texture(int width, int height, byte[] indices) {
// this.width = width;
// this.height = height;
// this.indices = indices;
// }
//
// /**
// * Returns a bufferedimage that represents this texture when indexed against the specified colormap
// * @param colorMap the colormap that contains the colors
// * @return an image
// */
// public BufferedImage render(ColorMap colorMap) {
// if (colorMap == null)
// return null;
// BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED, colorMap.toColorModel());
// bi.getRaster().setDataElements(0, 0, width, height, indices);
// return bi;
// }
// }
//
// Path: grimedi/src/com/sqrt4/grimedi/ui/component/ColorMapSelector.java
// public class ColorMapSelector extends JPanel {
// private LabCollection _last;
//
// public ColorMapSelector() {
// initComponents();
// }
//
// public void setLabFile(LabFile container) {
// if (container.container == _last)
// return;
// _last = container.container;
// Vector<DataSource> colorMaps = new Vector<DataSource>();
// colorMaps.addAll(container.container.findByType(ColorMap.class));
// colorMapSelector.setModel(new DefaultComboBoxModel(colorMaps));
// }
//
// public void addItemListener(ItemListener listener) {
// colorMapSelector.addItemListener(listener);
// }
//
// public void removeItemListener(ItemListener listener) {
// colorMapSelector.removeItemListener(listener);
// }
//
// public ColorMap getSelected() {
// DataSource edp = (DataSource) colorMapSelector.getSelectedItem();
// try {
// edp.position(0);
// return (ColorMap) CodecMapper.codecForProvider(edp).read(edp);
// } catch (IOException e) {
// MainWindow.getInstance().handleException(e);
// return null;
// }
// }
//
// public void setEnabled(boolean enabled) {
// super.setEnabled(enabled);
// colorMapSelector.setEnabled(enabled);
// }
//
// private void createUIComponents() {
// colorMapSelector = new JComboBox();
// }
//
// private void initComponents() {
// // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
// createUIComponents();
//
//
// //======== this ========
// setLayout(new BorderLayout());
// add(colorMapSelector, BorderLayout.CENTER);
// // JFormDesigner - End of component initialization //GEN-END:initComponents
// }
//
// // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// private JComboBox colorMapSelector;
// // JFormDesigner - End of variables declaration //GEN-END:variables
// }
| import javax.swing.event.ListDataListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map;
import com.sqrt.liblab.entry.model.Material;
import com.sqrt.liblab.entry.model.Texture;
import com.sqrt4.grimedi.ui.component.ColorMapSelector;
import javax.swing.*; |
/*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of GrimEdi.
*
* GrimEdi is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Created by JFormDesigner on Mon Mar 18 20:01:59 GMT 2013
*/
package com.sqrt4.grimedi.ui.editor;
/**
* @author James Lawrence
*/
public class MaterialView extends EditorPanel<Material> {
public MaterialView() {
initComponents();
}
ImageIcon icon = new ImageIcon(getClass().getResource("/material.png"));
public ImageIcon getIcon() {
return icon;
}
private void updatePreview() {
preview.setIcon(null);
if (imageList.getSelectedValue() == null || colorMapSelector.getSelected() == null)
return;
preview.setIcon(new ImageIcon(((Texture) imageList.getSelectedValue()).render(colorMapSelector.getSelected())));
}
private void imageSelected(ListSelectionEvent e) {
updatePreview();
}
private void createUIComponents() { | // Path: liblab/src/com/sqrt/liblab/entry/model/Material.java
// public class Material extends LabEntry {
// /**
// * The textures
// */
// public final List<Texture> textures = new LinkedList<Texture>();
//
// public Material(LabFile container, String name) {
// super(container, name);
// }
// }
//
// Path: liblab/src/com/sqrt/liblab/entry/model/Texture.java
// public class Texture {
// /**
// * Whether index 0 should be transparent
// */
// public boolean hasAlpha;
// /**
// * The width of this texture in pixels
// */
// public final int width;
// /**
// * The height of this texture in pixels
// */
// public final int height;
// /**
// * Indices into a colormap
// */
// public final byte[] indices;
//
// /**
// * Constructs a new texture of the specified dimension with the specified indices
// * @param width the width of the texture
// * @param height the height of the texture
// * @param indices the indices into the colormap
// */
// public Texture(int width, int height, byte[] indices) {
// this.width = width;
// this.height = height;
// this.indices = indices;
// }
//
// /**
// * Returns a bufferedimage that represents this texture when indexed against the specified colormap
// * @param colorMap the colormap that contains the colors
// * @return an image
// */
// public BufferedImage render(ColorMap colorMap) {
// if (colorMap == null)
// return null;
// BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED, colorMap.toColorModel());
// bi.getRaster().setDataElements(0, 0, width, height, indices);
// return bi;
// }
// }
//
// Path: grimedi/src/com/sqrt4/grimedi/ui/component/ColorMapSelector.java
// public class ColorMapSelector extends JPanel {
// private LabCollection _last;
//
// public ColorMapSelector() {
// initComponents();
// }
//
// public void setLabFile(LabFile container) {
// if (container.container == _last)
// return;
// _last = container.container;
// Vector<DataSource> colorMaps = new Vector<DataSource>();
// colorMaps.addAll(container.container.findByType(ColorMap.class));
// colorMapSelector.setModel(new DefaultComboBoxModel(colorMaps));
// }
//
// public void addItemListener(ItemListener listener) {
// colorMapSelector.addItemListener(listener);
// }
//
// public void removeItemListener(ItemListener listener) {
// colorMapSelector.removeItemListener(listener);
// }
//
// public ColorMap getSelected() {
// DataSource edp = (DataSource) colorMapSelector.getSelectedItem();
// try {
// edp.position(0);
// return (ColorMap) CodecMapper.codecForProvider(edp).read(edp);
// } catch (IOException e) {
// MainWindow.getInstance().handleException(e);
// return null;
// }
// }
//
// public void setEnabled(boolean enabled) {
// super.setEnabled(enabled);
// colorMapSelector.setEnabled(enabled);
// }
//
// private void createUIComponents() {
// colorMapSelector = new JComboBox();
// }
//
// private void initComponents() {
// // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
// createUIComponents();
//
//
// //======== this ========
// setLayout(new BorderLayout());
// add(colorMapSelector, BorderLayout.CENTER);
// // JFormDesigner - End of component initialization //GEN-END:initComponents
// }
//
// // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// private JComboBox colorMapSelector;
// // JFormDesigner - End of variables declaration //GEN-END:variables
// }
// Path: grimedi/src/com/sqrt4/grimedi/ui/editor/MaterialView.java
import javax.swing.event.ListDataListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map;
import com.sqrt.liblab.entry.model.Material;
import com.sqrt.liblab.entry.model.Texture;
import com.sqrt4.grimedi.ui.component.ColorMapSelector;
import javax.swing.*;
/*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of GrimEdi.
*
* GrimEdi is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Created by JFormDesigner on Mon Mar 18 20:01:59 GMT 2013
*/
package com.sqrt4.grimedi.ui.editor;
/**
* @author James Lawrence
*/
public class MaterialView extends EditorPanel<Material> {
public MaterialView() {
initComponents();
}
ImageIcon icon = new ImageIcon(getClass().getResource("/material.png"));
public ImageIcon getIcon() {
return icon;
}
private void updatePreview() {
preview.setIcon(null);
if (imageList.getSelectedValue() == null || colorMapSelector.getSelected() == null)
return;
preview.setIcon(new ImageIcon(((Texture) imageList.getSelectedValue()).render(colorMapSelector.getSelected())));
}
private void imageSelected(ListSelectionEvent e) {
updatePreview();
}
private void createUIComponents() { | colorMapSelector = new ColorMapSelector(); |
jlaw90/Grimja | liblab/src/com/sqrt/liblab/entry/video/AudioTrack.java | // Path: liblab/src/com/sqrt/liblab/entry/audio/AudioInputStream.java
// public abstract class AudioInputStream extends InputStream {
// /**
// * Seeks to the specified position
// * @param pos the position to position to
// * @throws IOException
// */
// public abstract void seek(int pos) throws IOException;
// }
| import com.sqrt.liblab.entry.audio.AudioInputStream; | /*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of LibLab.
*
* LibLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sqrt.liblab.entry.video;
public class AudioTrack {
public int channels;
public int bits;
public int sampleRate; | // Path: liblab/src/com/sqrt/liblab/entry/audio/AudioInputStream.java
// public abstract class AudioInputStream extends InputStream {
// /**
// * Seeks to the specified position
// * @param pos the position to position to
// * @throws IOException
// */
// public abstract void seek(int pos) throws IOException;
// }
// Path: liblab/src/com/sqrt/liblab/entry/video/AudioTrack.java
import com.sqrt.liblab.entry.audio.AudioInputStream;
/*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of LibLab.
*
* LibLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sqrt.liblab.entry.video;
public class AudioTrack {
public int channels;
public int bits;
public int sampleRate; | public AudioInputStream stream; |
jlaw90/Grimja | grimedi/src/com/sqrt4/grimedi/ui/component/Vector3Editor.java | // Path: liblab/src/com/sqrt/liblab/threed/Vector3f.java
// public class Vector3f implements Comparable<Vector3f> {
// public final float x, y, z;
// public static final Vector3f zero = new Vector3f(0, 0, 0);
//
// public Vector3f(float x, float y, float z) {
// this.x = x;
// this.y = y;
// this.z = z;
// }
//
// public boolean equals(Object o) {
// return o == this || (o instanceof Vector3f && equals((Vector3f) o));
// }
//
// public boolean equals(Vector3f v) {
// return v == this || (v.x == x && v.y == y && v.z == z);
// }
//
// public int hashCode() {
// return ((Float.floatToIntBits(x) & 0x3ff) << 20) | ((Float.floatToIntBits(y) & 0x3ff) << 10) |
// (Float.floatToIntBits(z)&0x3ff);
// }
//
// public int compareTo(Vector3f o) {
// return Float.compare(x, o.x) + Float.compare(y, o.y) + Float.compare(z, o.z);
// }
//
// public Vector3f add(Vector3f v) {
// return new Vector3f(x+v.x, y+v.y, z+v.z);
// }
//
// public Vector3f sub(Vector3f v) {
// return new Vector3f(x-v.x, y-v.y, z-v.z);
// }
//
// public Vector3f mult(float f) {
// return new Vector3f(x*f, y*f, z*f);
// }
//
// public Vector3f div(float f) {
// return new Vector3f(x/f, y/f, z/f);
// }
//
// public float length() {
// return (float)Math.sqrt(x*x+y*y+z*z);
// }
//
// public float dot(Vector3f o) {
// return (x*o.x)+(y*o.y)+(z*o.z);
// }
//
// public Vector3f cross(Vector3f o) {
// float resX = ((y * o.z) - (z * o.y));
// float resY = ((z * o.x) - (x * o.z));
// float resZ = ((x * o.y) - (y * o.x));
// return new Vector3f(resX, resY, resZ);
// }
// }
| import com.sqrt.liblab.threed.Vector3f;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import java.awt.*; | /*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of GrimEdi.
*
* GrimEdi is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Created by JFormDesigner on Fri Mar 22 13:36:17 GMT 2013
*/
package com.sqrt4.grimedi.ui.component;
/**
* @author James Lawrence
*/
public class Vector3Editor extends JPanel {
public Vector3Editor() {
initComponents();
final float inc = 0.01f;
float min = -9999;
float max = 9999;
xSpinner.setModel(new SpinnerNumberModel(0, min, max, inc));
ySpinner.setModel(new SpinnerNumberModel(0, min, max, inc));
zSpinner.setModel(new SpinnerNumberModel(0, min, max, inc));
}
public void addChangeListener(ChangeListener cl) {
xSpinner.addChangeListener(cl);
ySpinner.addChangeListener(cl);
zSpinner.addChangeListener(cl);
}
public void removeChangeListener(ChangeListener cl) {
xSpinner.removeChangeListener(cl);
ySpinner.removeChangeListener(cl);
zSpinner.removeChangeListener(cl);
}
| // Path: liblab/src/com/sqrt/liblab/threed/Vector3f.java
// public class Vector3f implements Comparable<Vector3f> {
// public final float x, y, z;
// public static final Vector3f zero = new Vector3f(0, 0, 0);
//
// public Vector3f(float x, float y, float z) {
// this.x = x;
// this.y = y;
// this.z = z;
// }
//
// public boolean equals(Object o) {
// return o == this || (o instanceof Vector3f && equals((Vector3f) o));
// }
//
// public boolean equals(Vector3f v) {
// return v == this || (v.x == x && v.y == y && v.z == z);
// }
//
// public int hashCode() {
// return ((Float.floatToIntBits(x) & 0x3ff) << 20) | ((Float.floatToIntBits(y) & 0x3ff) << 10) |
// (Float.floatToIntBits(z)&0x3ff);
// }
//
// public int compareTo(Vector3f o) {
// return Float.compare(x, o.x) + Float.compare(y, o.y) + Float.compare(z, o.z);
// }
//
// public Vector3f add(Vector3f v) {
// return new Vector3f(x+v.x, y+v.y, z+v.z);
// }
//
// public Vector3f sub(Vector3f v) {
// return new Vector3f(x-v.x, y-v.y, z-v.z);
// }
//
// public Vector3f mult(float f) {
// return new Vector3f(x*f, y*f, z*f);
// }
//
// public Vector3f div(float f) {
// return new Vector3f(x/f, y/f, z/f);
// }
//
// public float length() {
// return (float)Math.sqrt(x*x+y*y+z*z);
// }
//
// public float dot(Vector3f o) {
// return (x*o.x)+(y*o.y)+(z*o.z);
// }
//
// public Vector3f cross(Vector3f o) {
// float resX = ((y * o.z) - (z * o.y));
// float resY = ((z * o.x) - (x * o.z));
// float resZ = ((x * o.y) - (y * o.x));
// return new Vector3f(resX, resY, resZ);
// }
// }
// Path: grimedi/src/com/sqrt4/grimedi/ui/component/Vector3Editor.java
import com.sqrt.liblab.threed.Vector3f;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import java.awt.*;
/*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of GrimEdi.
*
* GrimEdi is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Created by JFormDesigner on Fri Mar 22 13:36:17 GMT 2013
*/
package com.sqrt4.grimedi.ui.component;
/**
* @author James Lawrence
*/
public class Vector3Editor extends JPanel {
public Vector3Editor() {
initComponents();
final float inc = 0.01f;
float min = -9999;
float max = 9999;
xSpinner.setModel(new SpinnerNumberModel(0, min, max, inc));
ySpinner.setModel(new SpinnerNumberModel(0, min, max, inc));
zSpinner.setModel(new SpinnerNumberModel(0, min, max, inc));
}
public void addChangeListener(ChangeListener cl) {
xSpinner.addChangeListener(cl);
ySpinner.addChangeListener(cl);
zSpinner.addChangeListener(cl);
}
public void removeChangeListener(ChangeListener cl) {
xSpinner.removeChangeListener(cl);
ySpinner.removeChangeListener(cl);
zSpinner.removeChangeListener(cl);
}
| public Vector3f getValue() { |
jlaw90/Grimja | grimedi/src/com/sqrt4/grimedi/ui/component/AngleEditor.java | // Path: liblab/src/com/sqrt/liblab/threed/Angle.java
// public class Angle {
// /**
// * No rotation (0 degrees)
// */
// public static final Angle zero = new Angle(0);
//
//
// private boolean hasRads;
// private float rads;
// /**
// * The angle in degrees
// */
// public final float degrees;
//
// /**
// * Constructs a new Angle with the specified angle...
// * @param degrees the angle in degrees
// */
// public Angle(float degrees) {
// this.degrees = degrees;
// }
//
// /**
// * Copies an angle
// * @param a the angle to copy
// */
// public Angle(Angle a) {
// this.degrees = a.degrees;
// }
//
// /**
// * Normalizes this angle to the specified central angle and returns it
// * @param low the central angle
// * @return the result
// */
// public Angle normalize(float low) {
// return new Angle(getDegrees(low));
// }
//
// /**
// * Clamps this angle to a range within the specified magnitude
// * @param mag the magnitude
// * @return the clamped angle
// */
// public Angle clamp(float mag) {
// float degrees = getDegrees(-180f);
// if(degrees > mag)
// degrees = mag;
// else if(degrees < -mag)
// degrees = -mag;
// return new Angle(degrees);
// }
//
// /**
// * Returns this angle normalized around the specified central point
// * @param low the center point of this angle
// * @return the result
// */
// public float getDegrees(float low) {
// return normalize(degrees, low);
// }
//
// /**
// * Adds this angle to the specified angle and returns the result
// * @param a the angle to add
// * @return the result of the addition
// */
// public Angle add(Angle a) {
// return new Angle(a.degrees + degrees);
// }
//
// /**
// * Multiplies this angle against the specified float value and returns the result
// * @param f the multiplication factor
// * @return the result
// */
// public Angle mult(float f) {
// return new Angle(degrees*f);
// }
//
// /**
// * Subtracts the specified angle from this angle and returns the result
// * @param a the angle to subtract
// * @return the result
// */
// public Angle sub(Angle a) {
// return new Angle(degrees - a.degrees);
// }
//
// /**
// * Returns this angle in radians
// * @return this angle in radians
// */
// public float radians() {
// if(!hasRads) {
// rads = (float) Math.toRadians(degrees);
// hasRads = true;
// }
// return rads;
// }
//
// public static float normalize(float degrees, float low) {
// if (degrees >= low + 360.f) {
// float x = (float) Math.floor((degrees - low) / 360f);
// degrees -= 360.f * x;
// } else if (degrees < low) {
// float x = (float) Math.floor((degrees - low) / 360.f);
// degrees -= 360.f * x;
// }
// return degrees;
// }
//
// public static Angle fromRadians(float rads) {
// Angle a = new Angle((float) Math.toDegrees(rads));
// a.hasRads = true;
// a.rads = rads;
// return a;
// }
// }
| import java.beans.PropertyChangeListener;
import java.util.LinkedList;
import java.util.List;
import com.sqrt.liblab.threed.Angle;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.beans.PropertyChangeEvent; | /*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of GrimEdi.
*
* GrimEdi is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Created by JFormDesigner on Fri Mar 22 11:21:22 GMT 2013
*/
package com.sqrt4.grimedi.ui.component;
/**
* @author James Lawrence
*/
public class AngleEditor extends JPanel {
private List<PropertyChangeListener> listeners = new LinkedList<PropertyChangeListener>();
private boolean adjusting = false;
public AngleEditor() {
initComponents();
}
public void setAngle(float degrees) {
float old = getDegrees();
adjusting = true;
angleDisplay.setValue(degrees);
angleChooser.setAngle(degrees);
adjusting = false;
if(listeners.isEmpty())
return;
PropertyChangeEvent pce = new PropertyChangeEvent(this, "angle", old, degrees);
for(int i = 0; i < listeners.size(); i++)
listeners.get(i).propertyChange(pce);
}
public float getDegrees() {
if(angleDisplay == null || angleDisplay.getValue() == null)
return 0;
return ((Number) angleDisplay.getValue()).floatValue(); // more precise...
}
| // Path: liblab/src/com/sqrt/liblab/threed/Angle.java
// public class Angle {
// /**
// * No rotation (0 degrees)
// */
// public static final Angle zero = new Angle(0);
//
//
// private boolean hasRads;
// private float rads;
// /**
// * The angle in degrees
// */
// public final float degrees;
//
// /**
// * Constructs a new Angle with the specified angle...
// * @param degrees the angle in degrees
// */
// public Angle(float degrees) {
// this.degrees = degrees;
// }
//
// /**
// * Copies an angle
// * @param a the angle to copy
// */
// public Angle(Angle a) {
// this.degrees = a.degrees;
// }
//
// /**
// * Normalizes this angle to the specified central angle and returns it
// * @param low the central angle
// * @return the result
// */
// public Angle normalize(float low) {
// return new Angle(getDegrees(low));
// }
//
// /**
// * Clamps this angle to a range within the specified magnitude
// * @param mag the magnitude
// * @return the clamped angle
// */
// public Angle clamp(float mag) {
// float degrees = getDegrees(-180f);
// if(degrees > mag)
// degrees = mag;
// else if(degrees < -mag)
// degrees = -mag;
// return new Angle(degrees);
// }
//
// /**
// * Returns this angle normalized around the specified central point
// * @param low the center point of this angle
// * @return the result
// */
// public float getDegrees(float low) {
// return normalize(degrees, low);
// }
//
// /**
// * Adds this angle to the specified angle and returns the result
// * @param a the angle to add
// * @return the result of the addition
// */
// public Angle add(Angle a) {
// return new Angle(a.degrees + degrees);
// }
//
// /**
// * Multiplies this angle against the specified float value and returns the result
// * @param f the multiplication factor
// * @return the result
// */
// public Angle mult(float f) {
// return new Angle(degrees*f);
// }
//
// /**
// * Subtracts the specified angle from this angle and returns the result
// * @param a the angle to subtract
// * @return the result
// */
// public Angle sub(Angle a) {
// return new Angle(degrees - a.degrees);
// }
//
// /**
// * Returns this angle in radians
// * @return this angle in radians
// */
// public float radians() {
// if(!hasRads) {
// rads = (float) Math.toRadians(degrees);
// hasRads = true;
// }
// return rads;
// }
//
// public static float normalize(float degrees, float low) {
// if (degrees >= low + 360.f) {
// float x = (float) Math.floor((degrees - low) / 360f);
// degrees -= 360.f * x;
// } else if (degrees < low) {
// float x = (float) Math.floor((degrees - low) / 360.f);
// degrees -= 360.f * x;
// }
// return degrees;
// }
//
// public static Angle fromRadians(float rads) {
// Angle a = new Angle((float) Math.toDegrees(rads));
// a.hasRads = true;
// a.rads = rads;
// return a;
// }
// }
// Path: grimedi/src/com/sqrt4/grimedi/ui/component/AngleEditor.java
import java.beans.PropertyChangeListener;
import java.util.LinkedList;
import java.util.List;
import com.sqrt.liblab.threed.Angle;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.beans.PropertyChangeEvent;
/*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of GrimEdi.
*
* GrimEdi is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Created by JFormDesigner on Fri Mar 22 11:21:22 GMT 2013
*/
package com.sqrt4.grimedi.ui.component;
/**
* @author James Lawrence
*/
public class AngleEditor extends JPanel {
private List<PropertyChangeListener> listeners = new LinkedList<PropertyChangeListener>();
private boolean adjusting = false;
public AngleEditor() {
initComponents();
}
public void setAngle(float degrees) {
float old = getDegrees();
adjusting = true;
angleDisplay.setValue(degrees);
angleChooser.setAngle(degrees);
adjusting = false;
if(listeners.isEmpty())
return;
PropertyChangeEvent pce = new PropertyChangeEvent(this, "angle", old, degrees);
for(int i = 0; i < listeners.size(); i++)
listeners.get(i).propertyChange(pce);
}
public float getDegrees() {
if(angleDisplay == null || angleDisplay.getValue() == null)
return 0;
return ((Number) angleDisplay.getValue()).floatValue(); // more precise...
}
| public Angle getAngle() { |
jlaw90/Grimja | grimedi/src/com/sqrt4/grimedi/ui/component/RadialAngleChooser.java | // Path: liblab/src/com/sqrt/liblab/threed/Angle.java
// public class Angle {
// /**
// * No rotation (0 degrees)
// */
// public static final Angle zero = new Angle(0);
//
//
// private boolean hasRads;
// private float rads;
// /**
// * The angle in degrees
// */
// public final float degrees;
//
// /**
// * Constructs a new Angle with the specified angle...
// * @param degrees the angle in degrees
// */
// public Angle(float degrees) {
// this.degrees = degrees;
// }
//
// /**
// * Copies an angle
// * @param a the angle to copy
// */
// public Angle(Angle a) {
// this.degrees = a.degrees;
// }
//
// /**
// * Normalizes this angle to the specified central angle and returns it
// * @param low the central angle
// * @return the result
// */
// public Angle normalize(float low) {
// return new Angle(getDegrees(low));
// }
//
// /**
// * Clamps this angle to a range within the specified magnitude
// * @param mag the magnitude
// * @return the clamped angle
// */
// public Angle clamp(float mag) {
// float degrees = getDegrees(-180f);
// if(degrees > mag)
// degrees = mag;
// else if(degrees < -mag)
// degrees = -mag;
// return new Angle(degrees);
// }
//
// /**
// * Returns this angle normalized around the specified central point
// * @param low the center point of this angle
// * @return the result
// */
// public float getDegrees(float low) {
// return normalize(degrees, low);
// }
//
// /**
// * Adds this angle to the specified angle and returns the result
// * @param a the angle to add
// * @return the result of the addition
// */
// public Angle add(Angle a) {
// return new Angle(a.degrees + degrees);
// }
//
// /**
// * Multiplies this angle against the specified float value and returns the result
// * @param f the multiplication factor
// * @return the result
// */
// public Angle mult(float f) {
// return new Angle(degrees*f);
// }
//
// /**
// * Subtracts the specified angle from this angle and returns the result
// * @param a the angle to subtract
// * @return the result
// */
// public Angle sub(Angle a) {
// return new Angle(degrees - a.degrees);
// }
//
// /**
// * Returns this angle in radians
// * @return this angle in radians
// */
// public float radians() {
// if(!hasRads) {
// rads = (float) Math.toRadians(degrees);
// hasRads = true;
// }
// return rads;
// }
//
// public static float normalize(float degrees, float low) {
// if (degrees >= low + 360.f) {
// float x = (float) Math.floor((degrees - low) / 360f);
// degrees -= 360.f * x;
// } else if (degrees < low) {
// float x = (float) Math.floor((degrees - low) / 360.f);
// degrees -= 360.f * x;
// }
// return degrees;
// }
//
// public static Angle fromRadians(float rads) {
// Angle a = new Angle((float) Math.toDegrees(rads));
// a.hasRads = true;
// a.rads = rads;
// return a;
// }
// }
| import com.sqrt.liblab.threed.Angle;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.*;
import java.util.LinkedList;
import java.util.List; | /*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of GrimEdi.
*
* GrimEdi is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sqrt4.grimedi.ui.component;
/**
* Created by James on 01/10/2014.
*/
public class RadialAngleChooser extends JPanel implements MouseListener, MouseWheelListener, MouseMotionListener {
private final List<ChangeListener> listeners = new LinkedList<>();
// angle, between -180 and 180
private float angle;
public RadialAngleChooser() {
addMouseListener(this);
addMouseWheelListener(this);
addMouseMotionListener(this);
}
public void setAngle(float angle) { | // Path: liblab/src/com/sqrt/liblab/threed/Angle.java
// public class Angle {
// /**
// * No rotation (0 degrees)
// */
// public static final Angle zero = new Angle(0);
//
//
// private boolean hasRads;
// private float rads;
// /**
// * The angle in degrees
// */
// public final float degrees;
//
// /**
// * Constructs a new Angle with the specified angle...
// * @param degrees the angle in degrees
// */
// public Angle(float degrees) {
// this.degrees = degrees;
// }
//
// /**
// * Copies an angle
// * @param a the angle to copy
// */
// public Angle(Angle a) {
// this.degrees = a.degrees;
// }
//
// /**
// * Normalizes this angle to the specified central angle and returns it
// * @param low the central angle
// * @return the result
// */
// public Angle normalize(float low) {
// return new Angle(getDegrees(low));
// }
//
// /**
// * Clamps this angle to a range within the specified magnitude
// * @param mag the magnitude
// * @return the clamped angle
// */
// public Angle clamp(float mag) {
// float degrees = getDegrees(-180f);
// if(degrees > mag)
// degrees = mag;
// else if(degrees < -mag)
// degrees = -mag;
// return new Angle(degrees);
// }
//
// /**
// * Returns this angle normalized around the specified central point
// * @param low the center point of this angle
// * @return the result
// */
// public float getDegrees(float low) {
// return normalize(degrees, low);
// }
//
// /**
// * Adds this angle to the specified angle and returns the result
// * @param a the angle to add
// * @return the result of the addition
// */
// public Angle add(Angle a) {
// return new Angle(a.degrees + degrees);
// }
//
// /**
// * Multiplies this angle against the specified float value and returns the result
// * @param f the multiplication factor
// * @return the result
// */
// public Angle mult(float f) {
// return new Angle(degrees*f);
// }
//
// /**
// * Subtracts the specified angle from this angle and returns the result
// * @param a the angle to subtract
// * @return the result
// */
// public Angle sub(Angle a) {
// return new Angle(degrees - a.degrees);
// }
//
// /**
// * Returns this angle in radians
// * @return this angle in radians
// */
// public float radians() {
// if(!hasRads) {
// rads = (float) Math.toRadians(degrees);
// hasRads = true;
// }
// return rads;
// }
//
// public static float normalize(float degrees, float low) {
// if (degrees >= low + 360.f) {
// float x = (float) Math.floor((degrees - low) / 360f);
// degrees -= 360.f * x;
// } else if (degrees < low) {
// float x = (float) Math.floor((degrees - low) / 360.f);
// degrees -= 360.f * x;
// }
// return degrees;
// }
//
// public static Angle fromRadians(float rads) {
// Angle a = new Angle((float) Math.toDegrees(rads));
// a.hasRads = true;
// a.rads = rads;
// return a;
// }
// }
// Path: grimedi/src/com/sqrt4/grimedi/ui/component/RadialAngleChooser.java
import com.sqrt.liblab.threed.Angle;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.*;
import java.util.LinkedList;
import java.util.List;
/*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of GrimEdi.
*
* GrimEdi is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sqrt4.grimedi.ui.component;
/**
* Created by James on 01/10/2014.
*/
public class RadialAngleChooser extends JPanel implements MouseListener, MouseWheelListener, MouseMotionListener {
private final List<ChangeListener> listeners = new LinkedList<>();
// angle, between -180 and 180
private float angle;
public RadialAngleChooser() {
addMouseListener(this);
addMouseWheelListener(this);
addMouseMotionListener(this);
}
public void setAngle(float angle) { | this.angle = Angle.normalize(angle, -180f); |
jlaw90/Grimja | grimedi/src/com/sqrt4/grimedi/ui/editor/FontView.java | // Path: liblab/src/com/sqrt/liblab/entry/graphics/FontGlyph.java
// public class FontGlyph {
// /**
// * The character code of this glyph (not necessarily ASCII)
// */
// public int index;
// /**
// * The width of this glyph
// */
// public int charWidth;
// /**
// * The x offset of this glyph
// */
// public int xOff;
// /**
// * The y offset of this glyph
// */
// public int yOff;
// /**
// * The glyph in ARGB with just the alpha value of each pixel set
// */
// public BufferedImage mask;
// }
//
// Path: liblab/src/com/sqrt/liblab/entry/graphics/GrimFont.java
// public class GrimFont extends LabEntry {
// /**
// * The height of a line in this font
// */
// public int height;
// /**
// * The baseline for this font
// */
// public int yOffset;
// /**
// * The first character contained in this font
// */
// public int firstChar;
// /**
// * The last character contained in this font
// */
// public int lastChar;
// // Todo: firstChar and lastChar needed?
// /**
// * The glyphs of this font
// */
// public List<FontGlyph> glyphs;
//
// /**
// * Constructs a new font
// * @param container the container of this font
// * @param name the name of this font
// * @param firstChar the first character contained within this font file
// * @param lastChar the last character contained within this font file
// * @param yOffset the baseline of this font
// * @param height the height of this font
// * @param glyphs the glyphs
// */
// public GrimFont(LabFile container, String name, int firstChar, int lastChar, int yOffset, int height, List<FontGlyph> glyphs) {
// super(container, name);
// this.firstChar = firstChar;
// this.lastChar = lastChar;
// this.yOffset = yOffset;
// this.height = height;
// this.glyphs = new LinkedList<FontGlyph>();
// this.glyphs.addAll(glyphs);
// }
//
// /**
// * Returns the glyph that corresponds to the character code specified
// * @param c the code
// * @return the glyph or null if none was found
// */
// public FontGlyph getGlyph(char c) {
// if(glyphs.get(c).index == c)
// return glyphs.get(c);
// for(FontGlyph g: glyphs) {
// if(g.index == c)
// return g;
// }
// return null;
// }
// }
| import javax.swing.event.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.HashMap;
import java.util.Map;
import com.sqrt.liblab.entry.graphics.FontGlyph;
import com.sqrt.liblab.entry.graphics.GrimFont;
import javax.swing.*;
import javax.swing.border.TitledBorder; |
/*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of GrimEdi.
*
* GrimEdi is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Created by JFormDesigner on Sat Mar 16 10:40:39 GMT 2013
*/
package com.sqrt4.grimedi.ui.editor;
/**
* @author James Lawrence
*/
public class FontView extends EditorPanel<GrimFont> {
private String _previewedText;
private static final int mult = 8;
private BufferedImage _glyphPreview;
public FontView() {
initComponents();
}
ImageIcon icon = new ImageIcon(getClass().getResource("/font.png"));
public ImageIcon getIcon() {
return icon;
}
private void updatePreview() {
int height = data.height;
int width = 0;
int y = data.yOffset;
int x = 0;
String text = previewText.getText();
char[] charArray = text.toCharArray();
for (char c : charArray) { | // Path: liblab/src/com/sqrt/liblab/entry/graphics/FontGlyph.java
// public class FontGlyph {
// /**
// * The character code of this glyph (not necessarily ASCII)
// */
// public int index;
// /**
// * The width of this glyph
// */
// public int charWidth;
// /**
// * The x offset of this glyph
// */
// public int xOff;
// /**
// * The y offset of this glyph
// */
// public int yOff;
// /**
// * The glyph in ARGB with just the alpha value of each pixel set
// */
// public BufferedImage mask;
// }
//
// Path: liblab/src/com/sqrt/liblab/entry/graphics/GrimFont.java
// public class GrimFont extends LabEntry {
// /**
// * The height of a line in this font
// */
// public int height;
// /**
// * The baseline for this font
// */
// public int yOffset;
// /**
// * The first character contained in this font
// */
// public int firstChar;
// /**
// * The last character contained in this font
// */
// public int lastChar;
// // Todo: firstChar and lastChar needed?
// /**
// * The glyphs of this font
// */
// public List<FontGlyph> glyphs;
//
// /**
// * Constructs a new font
// * @param container the container of this font
// * @param name the name of this font
// * @param firstChar the first character contained within this font file
// * @param lastChar the last character contained within this font file
// * @param yOffset the baseline of this font
// * @param height the height of this font
// * @param glyphs the glyphs
// */
// public GrimFont(LabFile container, String name, int firstChar, int lastChar, int yOffset, int height, List<FontGlyph> glyphs) {
// super(container, name);
// this.firstChar = firstChar;
// this.lastChar = lastChar;
// this.yOffset = yOffset;
// this.height = height;
// this.glyphs = new LinkedList<FontGlyph>();
// this.glyphs.addAll(glyphs);
// }
//
// /**
// * Returns the glyph that corresponds to the character code specified
// * @param c the code
// * @return the glyph or null if none was found
// */
// public FontGlyph getGlyph(char c) {
// if(glyphs.get(c).index == c)
// return glyphs.get(c);
// for(FontGlyph g: glyphs) {
// if(g.index == c)
// return g;
// }
// return null;
// }
// }
// Path: grimedi/src/com/sqrt4/grimedi/ui/editor/FontView.java
import javax.swing.event.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.HashMap;
import java.util.Map;
import com.sqrt.liblab.entry.graphics.FontGlyph;
import com.sqrt.liblab.entry.graphics.GrimFont;
import javax.swing.*;
import javax.swing.border.TitledBorder;
/*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of GrimEdi.
*
* GrimEdi is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Created by JFormDesigner on Sat Mar 16 10:40:39 GMT 2013
*/
package com.sqrt4.grimedi.ui.editor;
/**
* @author James Lawrence
*/
public class FontView extends EditorPanel<GrimFont> {
private String _previewedText;
private static final int mult = 8;
private BufferedImage _glyphPreview;
public FontView() {
initComponents();
}
ImageIcon icon = new ImageIcon(getClass().getResource("/font.png"));
public ImageIcon getIcon() {
return icon;
}
private void updatePreview() {
int height = data.height;
int width = 0;
int y = data.yOffset;
int x = 0;
String text = previewText.getText();
char[] charArray = text.toCharArray();
for (char c : charArray) { | FontGlyph g = data.getGlyph(c); |
jlaw90/Grimja | liblab/src/com/sqrt/liblab/entry/model/Mesh.java | // Path: liblab/src/com/sqrt/liblab/threed/Bounds3.java
// public class Bounds3 {
// /**
// * The minimum vector of this bounding box
// */
// public final Vector3f min;
// /**
// * The maximum vector of this bounding box
// */
// public final Vector3f max;
// /**
// * The center of this bounding box
// */
// public final Vector3f center;
// /**
// * The extents of this bounding box
// */
// public final Vector3f extent;
//
//
// /**
// * Constructs a new bounding box from the specified minimum and maximum vectors
// * @param min the minimum vector
// * @param max the maximum vector
// */
// public Bounds3(Vector3f min, Vector3f max) {
// this.min = min;
// this.max = max;
// this.extent = max.sub(min).div(2f);
// this.center = min.add(extent);
// }
//
// /**
// * Returns a bounding box that encapsulates both this and the specified bounding box
// * @param b the bounding box we also want the result to contain
// * @return a bounding box that contains the specified bounding box and ourselves
// */
// public Bounds3 encapsulate(Bounds3 b) {
// return new Bounds3(
// new Vector3f(Math.min(b.min.x, min.x), Math.min(b.min.y, min.y), Math.min(b.min.z, min.z)),
// new Vector3f(Math.max(b.max.x, max.x), Math.max(b.max.y, max.y), Math.max(b.max.z, max.z))
// );
// }
// }
//
// Path: liblab/src/com/sqrt/liblab/threed/Vector3f.java
// public class Vector3f implements Comparable<Vector3f> {
// public final float x, y, z;
// public static final Vector3f zero = new Vector3f(0, 0, 0);
//
// public Vector3f(float x, float y, float z) {
// this.x = x;
// this.y = y;
// this.z = z;
// }
//
// public boolean equals(Object o) {
// return o == this || (o instanceof Vector3f && equals((Vector3f) o));
// }
//
// public boolean equals(Vector3f v) {
// return v == this || (v.x == x && v.y == y && v.z == z);
// }
//
// public int hashCode() {
// return ((Float.floatToIntBits(x) & 0x3ff) << 20) | ((Float.floatToIntBits(y) & 0x3ff) << 10) |
// (Float.floatToIntBits(z)&0x3ff);
// }
//
// public int compareTo(Vector3f o) {
// return Float.compare(x, o.x) + Float.compare(y, o.y) + Float.compare(z, o.z);
// }
//
// public Vector3f add(Vector3f v) {
// return new Vector3f(x+v.x, y+v.y, z+v.z);
// }
//
// public Vector3f sub(Vector3f v) {
// return new Vector3f(x-v.x, y-v.y, z-v.z);
// }
//
// public Vector3f mult(float f) {
// return new Vector3f(x*f, y*f, z*f);
// }
//
// public Vector3f div(float f) {
// return new Vector3f(x/f, y/f, z/f);
// }
//
// public float length() {
// return (float)Math.sqrt(x*x+y*y+z*z);
// }
//
// public float dot(Vector3f o) {
// return (x*o.x)+(y*o.y)+(z*o.z);
// }
//
// public Vector3f cross(Vector3f o) {
// float resX = ((y * o.z) - (z * o.y));
// float resY = ((z * o.x) - (x * o.z));
// float resZ = ((x * o.y) - (y * o.x));
// return new Vector3f(resX, resY, resZ);
// }
// }
| import java.util.LinkedList;
import java.util.List;
import com.sqrt.liblab.threed.Bounds3;
import com.sqrt.liblab.threed.Vector3f; | /*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of LibLab.
*
* LibLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sqrt.liblab.entry.model;
/**
* A mesh contained in a model
*/
public class Mesh {
/**
* The name of this mesh
*/
public String name;
public int geomMode, lightMode, texMode, shadow;
public float radius;
/**
* The faces of this mesh
*/
public final List<MeshFace> faces = new LinkedList<MeshFace>();
/**
* Calculates the 3d bounds of this mesh
* @param pos the offset of this mesh from the model origin
* @return the bounds
*/ | // Path: liblab/src/com/sqrt/liblab/threed/Bounds3.java
// public class Bounds3 {
// /**
// * The minimum vector of this bounding box
// */
// public final Vector3f min;
// /**
// * The maximum vector of this bounding box
// */
// public final Vector3f max;
// /**
// * The center of this bounding box
// */
// public final Vector3f center;
// /**
// * The extents of this bounding box
// */
// public final Vector3f extent;
//
//
// /**
// * Constructs a new bounding box from the specified minimum and maximum vectors
// * @param min the minimum vector
// * @param max the maximum vector
// */
// public Bounds3(Vector3f min, Vector3f max) {
// this.min = min;
// this.max = max;
// this.extent = max.sub(min).div(2f);
// this.center = min.add(extent);
// }
//
// /**
// * Returns a bounding box that encapsulates both this and the specified bounding box
// * @param b the bounding box we also want the result to contain
// * @return a bounding box that contains the specified bounding box and ourselves
// */
// public Bounds3 encapsulate(Bounds3 b) {
// return new Bounds3(
// new Vector3f(Math.min(b.min.x, min.x), Math.min(b.min.y, min.y), Math.min(b.min.z, min.z)),
// new Vector3f(Math.max(b.max.x, max.x), Math.max(b.max.y, max.y), Math.max(b.max.z, max.z))
// );
// }
// }
//
// Path: liblab/src/com/sqrt/liblab/threed/Vector3f.java
// public class Vector3f implements Comparable<Vector3f> {
// public final float x, y, z;
// public static final Vector3f zero = new Vector3f(0, 0, 0);
//
// public Vector3f(float x, float y, float z) {
// this.x = x;
// this.y = y;
// this.z = z;
// }
//
// public boolean equals(Object o) {
// return o == this || (o instanceof Vector3f && equals((Vector3f) o));
// }
//
// public boolean equals(Vector3f v) {
// return v == this || (v.x == x && v.y == y && v.z == z);
// }
//
// public int hashCode() {
// return ((Float.floatToIntBits(x) & 0x3ff) << 20) | ((Float.floatToIntBits(y) & 0x3ff) << 10) |
// (Float.floatToIntBits(z)&0x3ff);
// }
//
// public int compareTo(Vector3f o) {
// return Float.compare(x, o.x) + Float.compare(y, o.y) + Float.compare(z, o.z);
// }
//
// public Vector3f add(Vector3f v) {
// return new Vector3f(x+v.x, y+v.y, z+v.z);
// }
//
// public Vector3f sub(Vector3f v) {
// return new Vector3f(x-v.x, y-v.y, z-v.z);
// }
//
// public Vector3f mult(float f) {
// return new Vector3f(x*f, y*f, z*f);
// }
//
// public Vector3f div(float f) {
// return new Vector3f(x/f, y/f, z/f);
// }
//
// public float length() {
// return (float)Math.sqrt(x*x+y*y+z*z);
// }
//
// public float dot(Vector3f o) {
// return (x*o.x)+(y*o.y)+(z*o.z);
// }
//
// public Vector3f cross(Vector3f o) {
// float resX = ((y * o.z) - (z * o.y));
// float resY = ((z * o.x) - (x * o.z));
// float resZ = ((x * o.y) - (y * o.x));
// return new Vector3f(resX, resY, resZ);
// }
// }
// Path: liblab/src/com/sqrt/liblab/entry/model/Mesh.java
import java.util.LinkedList;
import java.util.List;
import com.sqrt.liblab.threed.Bounds3;
import com.sqrt.liblab.threed.Vector3f;
/*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of LibLab.
*
* LibLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sqrt.liblab.entry.model;
/**
* A mesh contained in a model
*/
public class Mesh {
/**
* The name of this mesh
*/
public String name;
public int geomMode, lightMode, texMode, shadow;
public float radius;
/**
* The faces of this mesh
*/
public final List<MeshFace> faces = new LinkedList<MeshFace>();
/**
* Calculates the 3d bounds of this mesh
* @param pos the offset of this mesh from the model origin
* @return the bounds
*/ | public Bounds3 getBounds(Vector3f pos) { |
jlaw90/Grimja | liblab/src/com/sqrt/liblab/entry/model/Mesh.java | // Path: liblab/src/com/sqrt/liblab/threed/Bounds3.java
// public class Bounds3 {
// /**
// * The minimum vector of this bounding box
// */
// public final Vector3f min;
// /**
// * The maximum vector of this bounding box
// */
// public final Vector3f max;
// /**
// * The center of this bounding box
// */
// public final Vector3f center;
// /**
// * The extents of this bounding box
// */
// public final Vector3f extent;
//
//
// /**
// * Constructs a new bounding box from the specified minimum and maximum vectors
// * @param min the minimum vector
// * @param max the maximum vector
// */
// public Bounds3(Vector3f min, Vector3f max) {
// this.min = min;
// this.max = max;
// this.extent = max.sub(min).div(2f);
// this.center = min.add(extent);
// }
//
// /**
// * Returns a bounding box that encapsulates both this and the specified bounding box
// * @param b the bounding box we also want the result to contain
// * @return a bounding box that contains the specified bounding box and ourselves
// */
// public Bounds3 encapsulate(Bounds3 b) {
// return new Bounds3(
// new Vector3f(Math.min(b.min.x, min.x), Math.min(b.min.y, min.y), Math.min(b.min.z, min.z)),
// new Vector3f(Math.max(b.max.x, max.x), Math.max(b.max.y, max.y), Math.max(b.max.z, max.z))
// );
// }
// }
//
// Path: liblab/src/com/sqrt/liblab/threed/Vector3f.java
// public class Vector3f implements Comparable<Vector3f> {
// public final float x, y, z;
// public static final Vector3f zero = new Vector3f(0, 0, 0);
//
// public Vector3f(float x, float y, float z) {
// this.x = x;
// this.y = y;
// this.z = z;
// }
//
// public boolean equals(Object o) {
// return o == this || (o instanceof Vector3f && equals((Vector3f) o));
// }
//
// public boolean equals(Vector3f v) {
// return v == this || (v.x == x && v.y == y && v.z == z);
// }
//
// public int hashCode() {
// return ((Float.floatToIntBits(x) & 0x3ff) << 20) | ((Float.floatToIntBits(y) & 0x3ff) << 10) |
// (Float.floatToIntBits(z)&0x3ff);
// }
//
// public int compareTo(Vector3f o) {
// return Float.compare(x, o.x) + Float.compare(y, o.y) + Float.compare(z, o.z);
// }
//
// public Vector3f add(Vector3f v) {
// return new Vector3f(x+v.x, y+v.y, z+v.z);
// }
//
// public Vector3f sub(Vector3f v) {
// return new Vector3f(x-v.x, y-v.y, z-v.z);
// }
//
// public Vector3f mult(float f) {
// return new Vector3f(x*f, y*f, z*f);
// }
//
// public Vector3f div(float f) {
// return new Vector3f(x/f, y/f, z/f);
// }
//
// public float length() {
// return (float)Math.sqrt(x*x+y*y+z*z);
// }
//
// public float dot(Vector3f o) {
// return (x*o.x)+(y*o.y)+(z*o.z);
// }
//
// public Vector3f cross(Vector3f o) {
// float resX = ((y * o.z) - (z * o.y));
// float resY = ((z * o.x) - (x * o.z));
// float resZ = ((x * o.y) - (y * o.x));
// return new Vector3f(resX, resY, resZ);
// }
// }
| import java.util.LinkedList;
import java.util.List;
import com.sqrt.liblab.threed.Bounds3;
import com.sqrt.liblab.threed.Vector3f; | /*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of LibLab.
*
* LibLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sqrt.liblab.entry.model;
/**
* A mesh contained in a model
*/
public class Mesh {
/**
* The name of this mesh
*/
public String name;
public int geomMode, lightMode, texMode, shadow;
public float radius;
/**
* The faces of this mesh
*/
public final List<MeshFace> faces = new LinkedList<MeshFace>();
/**
* Calculates the 3d bounds of this mesh
* @param pos the offset of this mesh from the model origin
* @return the bounds
*/ | // Path: liblab/src/com/sqrt/liblab/threed/Bounds3.java
// public class Bounds3 {
// /**
// * The minimum vector of this bounding box
// */
// public final Vector3f min;
// /**
// * The maximum vector of this bounding box
// */
// public final Vector3f max;
// /**
// * The center of this bounding box
// */
// public final Vector3f center;
// /**
// * The extents of this bounding box
// */
// public final Vector3f extent;
//
//
// /**
// * Constructs a new bounding box from the specified minimum and maximum vectors
// * @param min the minimum vector
// * @param max the maximum vector
// */
// public Bounds3(Vector3f min, Vector3f max) {
// this.min = min;
// this.max = max;
// this.extent = max.sub(min).div(2f);
// this.center = min.add(extent);
// }
//
// /**
// * Returns a bounding box that encapsulates both this and the specified bounding box
// * @param b the bounding box we also want the result to contain
// * @return a bounding box that contains the specified bounding box and ourselves
// */
// public Bounds3 encapsulate(Bounds3 b) {
// return new Bounds3(
// new Vector3f(Math.min(b.min.x, min.x), Math.min(b.min.y, min.y), Math.min(b.min.z, min.z)),
// new Vector3f(Math.max(b.max.x, max.x), Math.max(b.max.y, max.y), Math.max(b.max.z, max.z))
// );
// }
// }
//
// Path: liblab/src/com/sqrt/liblab/threed/Vector3f.java
// public class Vector3f implements Comparable<Vector3f> {
// public final float x, y, z;
// public static final Vector3f zero = new Vector3f(0, 0, 0);
//
// public Vector3f(float x, float y, float z) {
// this.x = x;
// this.y = y;
// this.z = z;
// }
//
// public boolean equals(Object o) {
// return o == this || (o instanceof Vector3f && equals((Vector3f) o));
// }
//
// public boolean equals(Vector3f v) {
// return v == this || (v.x == x && v.y == y && v.z == z);
// }
//
// public int hashCode() {
// return ((Float.floatToIntBits(x) & 0x3ff) << 20) | ((Float.floatToIntBits(y) & 0x3ff) << 10) |
// (Float.floatToIntBits(z)&0x3ff);
// }
//
// public int compareTo(Vector3f o) {
// return Float.compare(x, o.x) + Float.compare(y, o.y) + Float.compare(z, o.z);
// }
//
// public Vector3f add(Vector3f v) {
// return new Vector3f(x+v.x, y+v.y, z+v.z);
// }
//
// public Vector3f sub(Vector3f v) {
// return new Vector3f(x-v.x, y-v.y, z-v.z);
// }
//
// public Vector3f mult(float f) {
// return new Vector3f(x*f, y*f, z*f);
// }
//
// public Vector3f div(float f) {
// return new Vector3f(x/f, y/f, z/f);
// }
//
// public float length() {
// return (float)Math.sqrt(x*x+y*y+z*z);
// }
//
// public float dot(Vector3f o) {
// return (x*o.x)+(y*o.y)+(z*o.z);
// }
//
// public Vector3f cross(Vector3f o) {
// float resX = ((y * o.z) - (z * o.y));
// float resY = ((z * o.x) - (x * o.z));
// float resZ = ((x * o.y) - (y * o.x));
// return new Vector3f(resX, resY, resZ);
// }
// }
// Path: liblab/src/com/sqrt/liblab/entry/model/Mesh.java
import java.util.LinkedList;
import java.util.List;
import com.sqrt.liblab.threed.Bounds3;
import com.sqrt.liblab.threed.Vector3f;
/*
* Copyright (C) 2014 James Lawrence.
*
* This file is part of LibLab.
*
* LibLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sqrt.liblab.entry.model;
/**
* A mesh contained in a model
*/
public class Mesh {
/**
* The name of this mesh
*/
public String name;
public int geomMode, lightMode, texMode, shadow;
public float radius;
/**
* The faces of this mesh
*/
public final List<MeshFace> faces = new LinkedList<MeshFace>();
/**
* Calculates the 3d bounds of this mesh
* @param pos the offset of this mesh from the model origin
* @return the bounds
*/ | public Bounds3 getBounds(Vector3f pos) { |
JetBrains/teamcity-achievements | achievements-server/src/test/java/org/jetbrains/buildServer/achievements/impl/UserEventsRegistryImplTest.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/UserEventsRegistryImpl.java
// public class UserEventsRegistryImpl implements UserEventsRegistry {
// private final EventDispatcher<UserEventsListener> myEventDispatcher = EventDispatcher.create(UserEventsListener.class);
// private Map<Long, UserEvents> myUserEvents = new HashMap<Long, UserEvents>();
// private final TimeService myTimeService;
//
// public UserEventsRegistryImpl(@NotNull TimeService timeService) {
// myTimeService = timeService;
// }
//
// @NotNull
// public UserEvents getUserEvents(@NotNull final User user) {
// UserEvents userEvents = myUserEvents.get(user.getId());
// if (userEvents == null) {
// userEvents = new UserEventsImpl(myTimeService) {
// @Override
// public synchronized void registerEvent(@NotNull String eventName) {
// super.registerEvent(eventName);
// myEventDispatcher.getMulticaster().userEventPublished(user, eventName, null);
// }
//
// public void registerEvent(@NotNull String eventName, @Nullable Object additionalData) {
// super.registerEvent(eventName);
// myEventDispatcher.getMulticaster().userEventPublished(user, eventName, additionalData);
// }
// };
// myUserEvents.put(user.getId(), userEvents);
// }
// return userEvents;
// }
//
//
// public void addListener(@NotNull UserEventsListener listener) {
// myEventDispatcher.addListener(listener);
// }
//
// public void removeListener(@NotNull UserEventsListener listener) {
// myEventDispatcher.removeListener(listener);
// }
// }
| import jetbrains.buildServer.BaseTestCase;
import jetbrains.buildServer.users.SUser;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.impl.UserEventsRegistryImpl;
import org.jmock.Mock;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.Date;
import java.util.List; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
@Test
public class UserEventsRegistryImplTest extends AchievementsTestCase {
public void test_register_event() { | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/UserEventsRegistryImpl.java
// public class UserEventsRegistryImpl implements UserEventsRegistry {
// private final EventDispatcher<UserEventsListener> myEventDispatcher = EventDispatcher.create(UserEventsListener.class);
// private Map<Long, UserEvents> myUserEvents = new HashMap<Long, UserEvents>();
// private final TimeService myTimeService;
//
// public UserEventsRegistryImpl(@NotNull TimeService timeService) {
// myTimeService = timeService;
// }
//
// @NotNull
// public UserEvents getUserEvents(@NotNull final User user) {
// UserEvents userEvents = myUserEvents.get(user.getId());
// if (userEvents == null) {
// userEvents = new UserEventsImpl(myTimeService) {
// @Override
// public synchronized void registerEvent(@NotNull String eventName) {
// super.registerEvent(eventName);
// myEventDispatcher.getMulticaster().userEventPublished(user, eventName, null);
// }
//
// public void registerEvent(@NotNull String eventName, @Nullable Object additionalData) {
// super.registerEvent(eventName);
// myEventDispatcher.getMulticaster().userEventPublished(user, eventName, additionalData);
// }
// };
// myUserEvents.put(user.getId(), userEvents);
// }
// return userEvents;
// }
//
//
// public void addListener(@NotNull UserEventsListener listener) {
// myEventDispatcher.addListener(listener);
// }
//
// public void removeListener(@NotNull UserEventsListener listener) {
// myEventDispatcher.removeListener(listener);
// }
// }
// Path: achievements-server/src/test/java/org/jetbrains/buildServer/achievements/impl/UserEventsRegistryImplTest.java
import jetbrains.buildServer.BaseTestCase;
import jetbrains.buildServer.users.SUser;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.impl.UserEventsRegistryImpl;
import org.jmock.Mock;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.Date;
import java.util.List;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
@Test
public class UserEventsRegistryImplTest extends AchievementsTestCase {
public void test_register_event() { | UserEvents userEvents = getUserEvents(createUser()); |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/Crusher.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
| import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class Crusher extends SimpleAchievement {
public Crusher() { | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/Crusher.java
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class Crusher extends SimpleAchievement {
public Crusher() { | super(AchievementEvents.compilationBroken.name(), 3); |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/Debugger.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
| import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class Debugger extends SimpleAchievement {
public Debugger() { | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/Debugger.java
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class Debugger extends SimpleAchievement {
public Debugger() { | super(AchievementEvents.issueMentioned.name(), 10); |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/Achievement.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
| import jetbrains.buildServer.users.SUser;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.UserEvents; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public interface Achievement {
@NotNull
String getId();
@NotNull
String getName();
@NotNull
String getDescription();
@Nullable
String getIconClassNames();
| // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/Achievement.java
import jetbrains.buildServer.users.SUser;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.UserEvents;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public interface Achievement {
@NotNull
String getId();
@NotNull
String getName();
@NotNull
String getDescription();
@Nullable
String getIconClassNames();
| boolean shouldGrantAchievement(@NotNull SUser user, @NotNull UserEvents events, @NotNull String lastEventName, @Nullable Object lastEventAdditionalData); |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/AchievementsGrantor.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementsConfig.java
// public class AchievementsConfig {
// private final List<Achievement> myAchievements;
//
// public AchievementsConfig(@NotNull Collection<Achievement> achievements) {
// myAchievements = new ArrayList<Achievement>(achievements);
// Collections.sort(myAchievements, new Comparator<Achievement>() {
// public int compare(Achievement o1, Achievement o2) {
// return o1.getName().compareToIgnoreCase(o2.getName());
// }
// });
// }
//
// @NotNull
// public List<Achievement> getAchievements() {
// return Collections.unmodifiableList(myAchievements);
// }
//
// @NotNull
// public Map<String, Achievement> getAchievementsMap() {
// Map<String, Achievement> res = new HashMap<String, Achievement>();
// for (Achievement a: myAchievements) {
// res.put(a.getId(), a);
// }
// return res;
// }
//
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsListener.java
// public interface UserEventsListener extends EventListener {
// void userEventPublished(@NotNull User user, @NotNull String eventName, @Nullable Object additionalData);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsRegistry.java
// public interface UserEventsRegistry {
// @NotNull
// UserEvents getUserEvents(@NotNull User user);
//
// void addListener(@NotNull UserEventsListener listener);
//
// void removeListener(@NotNull UserEventsListener listener);
// }
| import com.intellij.openapi.diagnostic.Logger;
import jetbrains.buildServer.serverSide.SecurityContextEx;
import jetbrains.buildServer.serverSide.impl.LogUtil;
import jetbrains.buildServer.users.*;
import jetbrains.buildServer.util.ExceptionUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementsConfig;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.UserEventsListener;
import org.jetbrains.buildserver.achievements.UserEventsRegistry;
import java.util.*; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class AchievementsGrantor implements UserEventsListener {
private final static Logger LOG = Logger.getInstance(AchievementsGrantor.class.getName());
| // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementsConfig.java
// public class AchievementsConfig {
// private final List<Achievement> myAchievements;
//
// public AchievementsConfig(@NotNull Collection<Achievement> achievements) {
// myAchievements = new ArrayList<Achievement>(achievements);
// Collections.sort(myAchievements, new Comparator<Achievement>() {
// public int compare(Achievement o1, Achievement o2) {
// return o1.getName().compareToIgnoreCase(o2.getName());
// }
// });
// }
//
// @NotNull
// public List<Achievement> getAchievements() {
// return Collections.unmodifiableList(myAchievements);
// }
//
// @NotNull
// public Map<String, Achievement> getAchievementsMap() {
// Map<String, Achievement> res = new HashMap<String, Achievement>();
// for (Achievement a: myAchievements) {
// res.put(a.getId(), a);
// }
// return res;
// }
//
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsListener.java
// public interface UserEventsListener extends EventListener {
// void userEventPublished(@NotNull User user, @NotNull String eventName, @Nullable Object additionalData);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsRegistry.java
// public interface UserEventsRegistry {
// @NotNull
// UserEvents getUserEvents(@NotNull User user);
//
// void addListener(@NotNull UserEventsListener listener);
//
// void removeListener(@NotNull UserEventsListener listener);
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/AchievementsGrantor.java
import com.intellij.openapi.diagnostic.Logger;
import jetbrains.buildServer.serverSide.SecurityContextEx;
import jetbrains.buildServer.serverSide.impl.LogUtil;
import jetbrains.buildServer.users.*;
import jetbrains.buildServer.util.ExceptionUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementsConfig;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.UserEventsListener;
import org.jetbrains.buildserver.achievements.UserEventsRegistry;
import java.util.*;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class AchievementsGrantor implements UserEventsListener {
private final static Logger LOG = Logger.getInstance(AchievementsGrantor.class.getName());
| private final AchievementsConfig myConfig; |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/AchievementsGrantor.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementsConfig.java
// public class AchievementsConfig {
// private final List<Achievement> myAchievements;
//
// public AchievementsConfig(@NotNull Collection<Achievement> achievements) {
// myAchievements = new ArrayList<Achievement>(achievements);
// Collections.sort(myAchievements, new Comparator<Achievement>() {
// public int compare(Achievement o1, Achievement o2) {
// return o1.getName().compareToIgnoreCase(o2.getName());
// }
// });
// }
//
// @NotNull
// public List<Achievement> getAchievements() {
// return Collections.unmodifiableList(myAchievements);
// }
//
// @NotNull
// public Map<String, Achievement> getAchievementsMap() {
// Map<String, Achievement> res = new HashMap<String, Achievement>();
// for (Achievement a: myAchievements) {
// res.put(a.getId(), a);
// }
// return res;
// }
//
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsListener.java
// public interface UserEventsListener extends EventListener {
// void userEventPublished(@NotNull User user, @NotNull String eventName, @Nullable Object additionalData);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsRegistry.java
// public interface UserEventsRegistry {
// @NotNull
// UserEvents getUserEvents(@NotNull User user);
//
// void addListener(@NotNull UserEventsListener listener);
//
// void removeListener(@NotNull UserEventsListener listener);
// }
| import com.intellij.openapi.diagnostic.Logger;
import jetbrains.buildServer.serverSide.SecurityContextEx;
import jetbrains.buildServer.serverSide.impl.LogUtil;
import jetbrains.buildServer.users.*;
import jetbrains.buildServer.util.ExceptionUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementsConfig;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.UserEventsListener;
import org.jetbrains.buildserver.achievements.UserEventsRegistry;
import java.util.*; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class AchievementsGrantor implements UserEventsListener {
private final static Logger LOG = Logger.getInstance(AchievementsGrantor.class.getName());
private final AchievementsConfig myConfig; | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementsConfig.java
// public class AchievementsConfig {
// private final List<Achievement> myAchievements;
//
// public AchievementsConfig(@NotNull Collection<Achievement> achievements) {
// myAchievements = new ArrayList<Achievement>(achievements);
// Collections.sort(myAchievements, new Comparator<Achievement>() {
// public int compare(Achievement o1, Achievement o2) {
// return o1.getName().compareToIgnoreCase(o2.getName());
// }
// });
// }
//
// @NotNull
// public List<Achievement> getAchievements() {
// return Collections.unmodifiableList(myAchievements);
// }
//
// @NotNull
// public Map<String, Achievement> getAchievementsMap() {
// Map<String, Achievement> res = new HashMap<String, Achievement>();
// for (Achievement a: myAchievements) {
// res.put(a.getId(), a);
// }
// return res;
// }
//
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsListener.java
// public interface UserEventsListener extends EventListener {
// void userEventPublished(@NotNull User user, @NotNull String eventName, @Nullable Object additionalData);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsRegistry.java
// public interface UserEventsRegistry {
// @NotNull
// UserEvents getUserEvents(@NotNull User user);
//
// void addListener(@NotNull UserEventsListener listener);
//
// void removeListener(@NotNull UserEventsListener listener);
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/AchievementsGrantor.java
import com.intellij.openapi.diagnostic.Logger;
import jetbrains.buildServer.serverSide.SecurityContextEx;
import jetbrains.buildServer.serverSide.impl.LogUtil;
import jetbrains.buildServer.users.*;
import jetbrains.buildServer.util.ExceptionUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementsConfig;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.UserEventsListener;
import org.jetbrains.buildserver.achievements.UserEventsRegistry;
import java.util.*;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class AchievementsGrantor implements UserEventsListener {
private final static Logger LOG = Logger.getInstance(AchievementsGrantor.class.getName());
private final AchievementsConfig myConfig; | private final UserEventsRegistry myEventsRegistry; |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/AchievementsGrantor.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementsConfig.java
// public class AchievementsConfig {
// private final List<Achievement> myAchievements;
//
// public AchievementsConfig(@NotNull Collection<Achievement> achievements) {
// myAchievements = new ArrayList<Achievement>(achievements);
// Collections.sort(myAchievements, new Comparator<Achievement>() {
// public int compare(Achievement o1, Achievement o2) {
// return o1.getName().compareToIgnoreCase(o2.getName());
// }
// });
// }
//
// @NotNull
// public List<Achievement> getAchievements() {
// return Collections.unmodifiableList(myAchievements);
// }
//
// @NotNull
// public Map<String, Achievement> getAchievementsMap() {
// Map<String, Achievement> res = new HashMap<String, Achievement>();
// for (Achievement a: myAchievements) {
// res.put(a.getId(), a);
// }
// return res;
// }
//
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsListener.java
// public interface UserEventsListener extends EventListener {
// void userEventPublished(@NotNull User user, @NotNull String eventName, @Nullable Object additionalData);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsRegistry.java
// public interface UserEventsRegistry {
// @NotNull
// UserEvents getUserEvents(@NotNull User user);
//
// void addListener(@NotNull UserEventsListener listener);
//
// void removeListener(@NotNull UserEventsListener listener);
// }
| import com.intellij.openapi.diagnostic.Logger;
import jetbrains.buildServer.serverSide.SecurityContextEx;
import jetbrains.buildServer.serverSide.impl.LogUtil;
import jetbrains.buildServer.users.*;
import jetbrains.buildServer.util.ExceptionUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementsConfig;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.UserEventsListener;
import org.jetbrains.buildserver.achievements.UserEventsRegistry;
import java.util.*; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class AchievementsGrantor implements UserEventsListener {
private final static Logger LOG = Logger.getInstance(AchievementsGrantor.class.getName());
private final AchievementsConfig myConfig;
private final UserEventsRegistry myEventsRegistry;
private final UserModel myUserModel;
private final SecurityContextEx mySecurityContext;
public AchievementsGrantor(@NotNull AchievementsConfig config,
@NotNull UserEventsRegistry userEventsRegistry,
@NotNull UserModel userModel,
@NotNull SecurityContextEx securityContext) {
myConfig = config;
myEventsRegistry = userEventsRegistry;
myUserModel = userModel;
mySecurityContext = securityContext;
userEventsRegistry.addListener(this);
}
public void userEventPublished(@NotNull User user, @NotNull String eventName, @Nullable Object additionalData) {
if (!isEnabled(user)) return; | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementsConfig.java
// public class AchievementsConfig {
// private final List<Achievement> myAchievements;
//
// public AchievementsConfig(@NotNull Collection<Achievement> achievements) {
// myAchievements = new ArrayList<Achievement>(achievements);
// Collections.sort(myAchievements, new Comparator<Achievement>() {
// public int compare(Achievement o1, Achievement o2) {
// return o1.getName().compareToIgnoreCase(o2.getName());
// }
// });
// }
//
// @NotNull
// public List<Achievement> getAchievements() {
// return Collections.unmodifiableList(myAchievements);
// }
//
// @NotNull
// public Map<String, Achievement> getAchievementsMap() {
// Map<String, Achievement> res = new HashMap<String, Achievement>();
// for (Achievement a: myAchievements) {
// res.put(a.getId(), a);
// }
// return res;
// }
//
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsListener.java
// public interface UserEventsListener extends EventListener {
// void userEventPublished(@NotNull User user, @NotNull String eventName, @Nullable Object additionalData);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsRegistry.java
// public interface UserEventsRegistry {
// @NotNull
// UserEvents getUserEvents(@NotNull User user);
//
// void addListener(@NotNull UserEventsListener listener);
//
// void removeListener(@NotNull UserEventsListener listener);
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/AchievementsGrantor.java
import com.intellij.openapi.diagnostic.Logger;
import jetbrains.buildServer.serverSide.SecurityContextEx;
import jetbrains.buildServer.serverSide.impl.LogUtil;
import jetbrains.buildServer.users.*;
import jetbrains.buildServer.util.ExceptionUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementsConfig;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.UserEventsListener;
import org.jetbrains.buildserver.achievements.UserEventsRegistry;
import java.util.*;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class AchievementsGrantor implements UserEventsListener {
private final static Logger LOG = Logger.getInstance(AchievementsGrantor.class.getName());
private final AchievementsConfig myConfig;
private final UserEventsRegistry myEventsRegistry;
private final UserModel myUserModel;
private final SecurityContextEx mySecurityContext;
public AchievementsGrantor(@NotNull AchievementsConfig config,
@NotNull UserEventsRegistry userEventsRegistry,
@NotNull UserModel userModel,
@NotNull SecurityContextEx securityContext) {
myConfig = config;
myEventsRegistry = userEventsRegistry;
myUserModel = userModel;
mySecurityContext = securityContext;
userEventsRegistry.addListener(this);
}
public void userEventPublished(@NotNull User user, @NotNull String eventName, @Nullable Object additionalData) {
if (!isEnabled(user)) return; | UserEvents events = myEventsRegistry.getUserEvents(user); |
JetBrains/teamcity-achievements | achievements-server/src/test/java/org/jetbrains/buildServer/achievements/impl/AchievementsTestCase.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/UserEventsRegistryImpl.java
// public class UserEventsRegistryImpl implements UserEventsRegistry {
// private final EventDispatcher<UserEventsListener> myEventDispatcher = EventDispatcher.create(UserEventsListener.class);
// private Map<Long, UserEvents> myUserEvents = new HashMap<Long, UserEvents>();
// private final TimeService myTimeService;
//
// public UserEventsRegistryImpl(@NotNull TimeService timeService) {
// myTimeService = timeService;
// }
//
// @NotNull
// public UserEvents getUserEvents(@NotNull final User user) {
// UserEvents userEvents = myUserEvents.get(user.getId());
// if (userEvents == null) {
// userEvents = new UserEventsImpl(myTimeService) {
// @Override
// public synchronized void registerEvent(@NotNull String eventName) {
// super.registerEvent(eventName);
// myEventDispatcher.getMulticaster().userEventPublished(user, eventName, null);
// }
//
// public void registerEvent(@NotNull String eventName, @Nullable Object additionalData) {
// super.registerEvent(eventName);
// myEventDispatcher.getMulticaster().userEventPublished(user, eventName, additionalData);
// }
// };
// myUserEvents.put(user.getId(), userEvents);
// }
// return userEvents;
// }
//
//
// public void addListener(@NotNull UserEventsListener listener) {
// myEventDispatcher.addListener(listener);
// }
//
// public void removeListener(@NotNull UserEventsListener listener) {
// myEventDispatcher.removeListener(listener);
// }
// }
| import jetbrains.buildServer.BaseTestCase;
import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.util.TimeService;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.impl.UserEventsRegistryImpl;
import org.jmock.Mock;
import org.testng.annotations.BeforeMethod;
import java.util.Date; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class AchievementsTestCase extends BaseTestCase {
private UserEventsRegistryImpl myRegistry;
private long myTime;
@BeforeMethod
protected void setUp() throws Exception {
super.setUp();
TimeService timeService = new TimeService() {
public long now() {
return myTime;
}
};
myTime = new Date().getTime();
myRegistry = new UserEventsRegistryImpl(timeService);
}
public SUser createUser() {
Mock userMock = mock(SUser.class);
userMock.stubs().method("getId").will(returnValue(1L));
return (SUser) userMock.proxy();
}
| // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/UserEventsRegistryImpl.java
// public class UserEventsRegistryImpl implements UserEventsRegistry {
// private final EventDispatcher<UserEventsListener> myEventDispatcher = EventDispatcher.create(UserEventsListener.class);
// private Map<Long, UserEvents> myUserEvents = new HashMap<Long, UserEvents>();
// private final TimeService myTimeService;
//
// public UserEventsRegistryImpl(@NotNull TimeService timeService) {
// myTimeService = timeService;
// }
//
// @NotNull
// public UserEvents getUserEvents(@NotNull final User user) {
// UserEvents userEvents = myUserEvents.get(user.getId());
// if (userEvents == null) {
// userEvents = new UserEventsImpl(myTimeService) {
// @Override
// public synchronized void registerEvent(@NotNull String eventName) {
// super.registerEvent(eventName);
// myEventDispatcher.getMulticaster().userEventPublished(user, eventName, null);
// }
//
// public void registerEvent(@NotNull String eventName, @Nullable Object additionalData) {
// super.registerEvent(eventName);
// myEventDispatcher.getMulticaster().userEventPublished(user, eventName, additionalData);
// }
// };
// myUserEvents.put(user.getId(), userEvents);
// }
// return userEvents;
// }
//
//
// public void addListener(@NotNull UserEventsListener listener) {
// myEventDispatcher.addListener(listener);
// }
//
// public void removeListener(@NotNull UserEventsListener listener) {
// myEventDispatcher.removeListener(listener);
// }
// }
// Path: achievements-server/src/test/java/org/jetbrains/buildServer/achievements/impl/AchievementsTestCase.java
import jetbrains.buildServer.BaseTestCase;
import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.util.TimeService;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.impl.UserEventsRegistryImpl;
import org.jmock.Mock;
import org.testng.annotations.BeforeMethod;
import java.util.Date;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class AchievementsTestCase extends BaseTestCase {
private UserEventsRegistryImpl myRegistry;
private long myTime;
@BeforeMethod
protected void setUp() throws Exception {
super.setUp();
TimeService timeService = new TimeService() {
public long now() {
return myTime;
}
};
myTime = new Date().getTime();
myRegistry = new UserEventsRegistryImpl(timeService);
}
public SUser createUser() {
Mock userMock = mock(SUser.class);
userMock.stubs().method("getId").will(returnValue(1L));
return (SUser) userMock.proxy();
}
| public UserEvents getUserEvents(@NotNull SUser user) { |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/NightOwl.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
| import jetbrains.buildServer.users.SUser;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import java.util.TimeZone; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class NightOwl implements Achievement {
@NotNull
public String getId() {
return "nightOwl";
}
@NotNull
public String getName() {
return "Night Owl";
}
@NotNull
public String getDescription() {
return "Granted for some late action on the build server.";
}
@Nullable
public String getIconClassNames() {
return "icon-time";
}
| // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/NightOwl.java
import jetbrains.buildServer.users.SUser;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import java.util.TimeZone;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class NightOwl implements Achievement {
@NotNull
public String getId() {
return "nightOwl";
}
@NotNull
public String getName() {
return "Night Owl";
}
@NotNull
public String getDescription() {
return "Granted for some late action on the build server.";
}
@Nullable
public String getIconClassNames() {
return "icon-time";
}
| public boolean shouldGrantAchievement(@NotNull SUser user, @NotNull UserEvents events, @NotNull String lastEventName, Object additionalData) { |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/NightOwl.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
| import jetbrains.buildServer.users.SUser;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import java.util.TimeZone; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class NightOwl implements Achievement {
@NotNull
public String getId() {
return "nightOwl";
}
@NotNull
public String getName() {
return "Night Owl";
}
@NotNull
public String getDescription() {
return "Granted for some late action on the build server.";
}
@Nullable
public String getIconClassNames() {
return "icon-time";
}
public boolean shouldGrantAchievement(@NotNull SUser user, @NotNull UserEvents events, @NotNull String lastEventName, Object additionalData) { | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/NightOwl.java
import jetbrains.buildServer.users.SUser;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import java.util.TimeZone;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class NightOwl implements Achievement {
@NotNull
public String getId() {
return "nightOwl";
}
@NotNull
public String getName() {
return "Night Owl";
}
@NotNull
public String getDescription() {
return "Granted for some late action on the build server.";
}
@Nullable
public String getIconClassNames() {
return "icon-time";
}
public boolean shouldGrantAchievement(@NotNull SUser user, @NotNull UserEvents events, @NotNull String lastEventName, Object additionalData) { | return lastEventName.equals(AchievementEvents.userAction.name()) && |
JetBrains/teamcity-achievements | achievements-server/src/test/java/org/jetbrains/buildServer/achievements/impl/AchievementsConfigTest.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
| import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.vcs.SVcsModification;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jmock.Mock;
import org.testng.annotations.Test;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
@Test
public class AchievementsConfigTest extends AchievementsTestCase {
public void night_owl() {
Achievement achievement = new NightOwl();
SUser user = createUser(); | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
// Path: achievements-server/src/test/java/org/jetbrains/buildServer/achievements/impl/AchievementsConfigTest.java
import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.vcs.SVcsModification;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jmock.Mock;
import org.testng.annotations.Test;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
@Test
public class AchievementsConfigTest extends AchievementsTestCase {
public void night_owl() {
Achievement achievement = new NightOwl();
SUser user = createUser(); | UserEvents userEvents = getUserEvents(user); |
JetBrains/teamcity-achievements | achievements-server/src/test/java/org/jetbrains/buildServer/achievements/impl/AchievementsConfigTest.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
| import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.vcs.SVcsModification;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jmock.Mock;
import org.testng.annotations.Test;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
@Test
public class AchievementsConfigTest extends AchievementsTestCase {
public void night_owl() {
Achievement achievement = new NightOwl();
SUser user = createUser();
UserEvents userEvents = getUserEvents(user);
setHour(1);
TimeZone tz = TimeZone.getDefault(); | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
// Path: achievements-server/src/test/java/org/jetbrains/buildServer/achievements/impl/AchievementsConfigTest.java
import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.vcs.SVcsModification;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jmock.Mock;
import org.testng.annotations.Test;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
@Test
public class AchievementsConfigTest extends AchievementsTestCase {
public void night_owl() {
Achievement achievement = new NightOwl();
SUser user = createUser();
UserEvents userEvents = getUserEvents(user);
setHour(1);
TimeZone tz = TimeZone.getDefault(); | userEvents.registerEvent(AchievementEvents.userAction.name(), tz); |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/BoyScout.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
| import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class BoyScout extends SimpleAchievement {
public BoyScout() { | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/BoyScout.java
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class BoyScout extends SimpleAchievement {
public BoyScout() { | super(AchievementEvents.investigationTaken.name(), 10); |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/Saboteur.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
| import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class Saboteur extends SimpleAchievement {
public Saboteur() { | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/Saboteur.java
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class Saboteur extends SimpleAchievement {
public Saboteur() { | super(AchievementEvents.testBombed.name(), 20); |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/Sapper.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
| import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class Sapper extends SimpleAchievement {
public Sapper() { | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/Sapper.java
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class Sapper extends SimpleAchievement {
public Sapper() { | super(AchievementEvents.testDisarmed.name(), 20); |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/Novelist.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
| import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.vcs.SVcsModification;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class Novelist implements Achievement {
@NotNull
public String getId() {
return "novelist";
}
@NotNull
public String getName() {
return "Novelist";
}
@NotNull
public String getDescription() {
return "Granted for extra long commit descriptions.";
}
@Nullable
public String getIconClassNames() {
return "icon-book";
}
| // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/Novelist.java
import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.vcs.SVcsModification;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class Novelist implements Achievement {
@NotNull
public String getId() {
return "novelist";
}
@NotNull
public String getName() {
return "Novelist";
}
@NotNull
public String getDescription() {
return "Granted for extra long commit descriptions.";
}
@Nullable
public String getIconClassNames() {
return "icon-book";
}
| public boolean shouldGrantAchievement(@NotNull SUser user, @NotNull UserEvents events, @NotNull String lastEventName, Object additionalData) { |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/Novelist.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
| import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.vcs.SVcsModification;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class Novelist implements Achievement {
@NotNull
public String getId() {
return "novelist";
}
@NotNull
public String getName() {
return "Novelist";
}
@NotNull
public String getDescription() {
return "Granted for extra long commit descriptions.";
}
@Nullable
public String getIconClassNames() {
return "icon-book";
}
public boolean shouldGrantAchievement(@NotNull SUser user, @NotNull UserEvents events, @NotNull String lastEventName, Object additionalData) { | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/Novelist.java
import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.vcs.SVcsModification;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class Novelist implements Achievement {
@NotNull
public String getId() {
return "novelist";
}
@NotNull
public String getName() {
return "Novelist";
}
@NotNull
public String getDescription() {
return "Granted for extra long commit descriptions.";
}
@Nullable
public String getIconClassNames() {
return "icon-book";
}
public boolean shouldGrantAchievement(@NotNull SUser user, @NotNull UserEvents events, @NotNull String lastEventName, Object additionalData) { | if (!lastEventName.equals(AchievementEvents.changeAdded.name())) return false; |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/controller/AchievementBean.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/Achievement.java
// public interface Achievement {
// @NotNull
// String getId();
//
// @NotNull
// String getName();
//
// @NotNull
// String getDescription();
//
// @Nullable
// String getIconClassNames();
//
// boolean shouldGrantAchievement(@NotNull SUser user, @NotNull UserEvents events, @NotNull String lastEventName, @Nullable Object lastEventAdditionalData);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/AchievementProperties.java
// public class AchievementProperties {
// @NotNull
// public static PluginPropertyKey getHidePropertyKey(@NotNull Achievement achievement) {
// return new PluginPropertyKey("achievements", "achievements", "achievement.hidden." + achievement.getId());
// }
//
// @NotNull
// public static PluginPropertyKey getGrantedPropertyKey(@NotNull Achievement achievement) {
// return new PluginPropertyKey("achievements", "achievements", "achievement.granted." + achievement.getId());
// }
//
// @NotNull
// public static PluginPropertyKey getAchievementsEnabledPropertyKey() {
// return new PluginPropertyKey("achievements", "achievements", "enabled");
// }
// }
| import jetbrains.buildServer.users.PluginPropertyKey;
import jetbrains.buildServer.users.User;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.buildserver.achievements.impl.Achievement;
import org.jetbrains.buildserver.achievements.impl.AchievementProperties; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.controller;
public class AchievementBean {
private final Achievement myAchievement;
public AchievementBean(@NotNull Achievement achievement) {
myAchievement = achievement;
}
@NotNull
public String getHidePropertyKey() {
return makePropertyKey().getKey();
}
public Achievement getAchievement() {
return myAchievement;
}
public boolean isHidden(@NotNull User user) {
return user.getBooleanProperty(makePropertyKey());
}
@NotNull
private PluginPropertyKey makePropertyKey() { | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/Achievement.java
// public interface Achievement {
// @NotNull
// String getId();
//
// @NotNull
// String getName();
//
// @NotNull
// String getDescription();
//
// @Nullable
// String getIconClassNames();
//
// boolean shouldGrantAchievement(@NotNull SUser user, @NotNull UserEvents events, @NotNull String lastEventName, @Nullable Object lastEventAdditionalData);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/AchievementProperties.java
// public class AchievementProperties {
// @NotNull
// public static PluginPropertyKey getHidePropertyKey(@NotNull Achievement achievement) {
// return new PluginPropertyKey("achievements", "achievements", "achievement.hidden." + achievement.getId());
// }
//
// @NotNull
// public static PluginPropertyKey getGrantedPropertyKey(@NotNull Achievement achievement) {
// return new PluginPropertyKey("achievements", "achievements", "achievement.granted." + achievement.getId());
// }
//
// @NotNull
// public static PluginPropertyKey getAchievementsEnabledPropertyKey() {
// return new PluginPropertyKey("achievements", "achievements", "enabled");
// }
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/controller/AchievementBean.java
import jetbrains.buildServer.users.PluginPropertyKey;
import jetbrains.buildServer.users.User;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.buildserver.achievements.impl.Achievement;
import org.jetbrains.buildserver.achievements.impl.AchievementProperties;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.controller;
public class AchievementBean {
private final Achievement myAchievement;
public AchievementBean(@NotNull Achievement achievement) {
myAchievement = achievement;
}
@NotNull
public String getHidePropertyKey() {
return makePropertyKey().getKey();
}
public Achievement getAchievement() {
return myAchievement;
}
public boolean isHidden(@NotNull User user) {
return user.getBooleanProperty(makePropertyKey());
}
@NotNull
private PluginPropertyKey makePropertyKey() { | return AchievementProperties.getHidePropertyKey(myAchievement); |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/BigBrother.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
| import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class BigBrother extends SimpleAchievement {
public BigBrother() { | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/BigBrother.java
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class BigBrother extends SimpleAchievement {
public BigBrother() { | super(AchievementEvents.investigationDelegated.name(), 10); |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/CleanupBooster.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
| import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class CleanupBooster extends SimpleAchievement {
public CleanupBooster() { | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/CleanupBooster.java
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class CleanupBooster extends SimpleAchievement {
public CleanupBooster() { | super(AchievementEvents.buildUnpinned.name(), 10); |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/UserActionUtil.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
| import org.jetbrains.annotations.NotNull;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.TimeZone; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class UserActionUtil {
public static boolean checkUserActionsMadeBetween(@NotNull UserEvents events, @NotNull TimeZone userTimeZone, int minHour, int maxHour) {
int numEvents = 3; | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/UserActionUtil.java
import org.jetbrains.annotations.NotNull;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class UserActionUtil {
public static boolean checkUserActionsMadeBetween(@NotNull UserEvents events, @NotNull TimeZone userTimeZone, int minHour, int maxHour) {
int numEvents = 3; | List<Long> times = events.getEventTimes(AchievementEvents.userAction.name()); |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/ServerEventsAdapter.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsRegistry.java
// public interface UserEventsRegistry {
// @NotNull
// UserEvents getUserEvents(@NotNull User user);
//
// void addListener(@NotNull UserEventsListener listener);
//
// void removeListener(@NotNull UserEventsListener listener);
// }
| import jetbrains.buildServer.BuildProblemTypes;
import jetbrains.buildServer.issueTracker.Issue;
import jetbrains.buildServer.responsibility.ResponsibilityEntry;
import jetbrains.buildServer.serverSide.*;
import jetbrains.buildServer.serverSide.mute.MuteInfo;
import jetbrains.buildServer.serverSide.problems.BuildProblem;
import jetbrains.buildServer.serverSide.problems.BuildProblemInfo;
import jetbrains.buildServer.tests.TestName;
import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.users.User;
import jetbrains.buildServer.util.EventDispatcher;
import jetbrains.buildServer.vcs.SVcsModification;
import jetbrains.buildServer.vcs.VcsModification;
import jetbrains.buildServer.vcs.VcsRoot;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEventsRegistry;
import java.util.Collection;
import java.util.List;
import java.util.Map; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class ServerEventsAdapter extends BuildServerAdapter {
private final UserEventsRegistry myUserEventsRegistry;
public ServerEventsAdapter(@NotNull UserEventsRegistry userEventsRegistry,
@NotNull EventDispatcher<BuildServerListener> serverDispatcher) {
myUserEventsRegistry = userEventsRegistry;
serverDispatcher.addListener(this);
}
@Override
public void buildUnpinned(@NotNull SBuild build, @Nullable User user, @Nullable String comment) {
super.buildUnpinned(build, user, comment);
if (user != null) { | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsRegistry.java
// public interface UserEventsRegistry {
// @NotNull
// UserEvents getUserEvents(@NotNull User user);
//
// void addListener(@NotNull UserEventsListener listener);
//
// void removeListener(@NotNull UserEventsListener listener);
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/ServerEventsAdapter.java
import jetbrains.buildServer.BuildProblemTypes;
import jetbrains.buildServer.issueTracker.Issue;
import jetbrains.buildServer.responsibility.ResponsibilityEntry;
import jetbrains.buildServer.serverSide.*;
import jetbrains.buildServer.serverSide.mute.MuteInfo;
import jetbrains.buildServer.serverSide.problems.BuildProblem;
import jetbrains.buildServer.serverSide.problems.BuildProblemInfo;
import jetbrains.buildServer.tests.TestName;
import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.users.User;
import jetbrains.buildServer.util.EventDispatcher;
import jetbrains.buildServer.vcs.SVcsModification;
import jetbrains.buildServer.vcs.VcsModification;
import jetbrains.buildServer.vcs.VcsRoot;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEventsRegistry;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class ServerEventsAdapter extends BuildServerAdapter {
private final UserEventsRegistry myUserEventsRegistry;
public ServerEventsAdapter(@NotNull UserEventsRegistry userEventsRegistry,
@NotNull EventDispatcher<BuildServerListener> serverDispatcher) {
myUserEventsRegistry = userEventsRegistry;
serverDispatcher.addListener(this);
}
@Override
public void buildUnpinned(@NotNull SBuild build, @Nullable User user, @Nullable String comment) {
super.buildUnpinned(build, user, comment);
if (user != null) { | registerUserEvent(user, AchievementEvents.buildUnpinned.name()); |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/ProductivityBoost.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsListener.java
// public interface UserEventsListener extends EventListener {
// void userEventPublished(@NotNull User user, @NotNull String eventName, @Nullable Object additionalData);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsRegistry.java
// public interface UserEventsRegistry {
// @NotNull
// UserEvents getUserEvents(@NotNull User user);
//
// void addListener(@NotNull UserEventsListener listener);
//
// void removeListener(@NotNull UserEventsListener listener);
// }
| import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.users.User;
import jetbrains.buildServer.vcs.SVcsModification;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.UserEventsListener;
import org.jetbrains.buildserver.achievements.UserEventsRegistry;
import java.util.Calendar;
import java.util.Date; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class ProductivityBoost extends SimpleAchievement {
public ProductivityBoost(@NotNull final UserEventsRegistry userEventsRegistry) { | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsListener.java
// public interface UserEventsListener extends EventListener {
// void userEventPublished(@NotNull User user, @NotNull String eventName, @Nullable Object additionalData);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsRegistry.java
// public interface UserEventsRegistry {
// @NotNull
// UserEvents getUserEvents(@NotNull User user);
//
// void addListener(@NotNull UserEventsListener listener);
//
// void removeListener(@NotNull UserEventsListener listener);
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/ProductivityBoost.java
import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.users.User;
import jetbrains.buildServer.vcs.SVcsModification;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.UserEventsListener;
import org.jetbrains.buildserver.achievements.UserEventsRegistry;
import java.util.Calendar;
import java.util.Date;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class ProductivityBoost extends SimpleAchievement {
public ProductivityBoost(@NotNull final UserEventsRegistry userEventsRegistry) { | super(AchievementEvents.changeAdded.name(), 20); |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/ProductivityBoost.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsListener.java
// public interface UserEventsListener extends EventListener {
// void userEventPublished(@NotNull User user, @NotNull String eventName, @Nullable Object additionalData);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsRegistry.java
// public interface UserEventsRegistry {
// @NotNull
// UserEvents getUserEvents(@NotNull User user);
//
// void addListener(@NotNull UserEventsListener listener);
//
// void removeListener(@NotNull UserEventsListener listener);
// }
| import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.users.User;
import jetbrains.buildServer.vcs.SVcsModification;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.UserEventsListener;
import org.jetbrains.buildserver.achievements.UserEventsRegistry;
import java.util.Calendar;
import java.util.Date; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class ProductivityBoost extends SimpleAchievement {
public ProductivityBoost(@NotNull final UserEventsRegistry userEventsRegistry) {
super(AchievementEvents.changeAdded.name(), 20); | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsListener.java
// public interface UserEventsListener extends EventListener {
// void userEventPublished(@NotNull User user, @NotNull String eventName, @Nullable Object additionalData);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsRegistry.java
// public interface UserEventsRegistry {
// @NotNull
// UserEvents getUserEvents(@NotNull User user);
//
// void addListener(@NotNull UserEventsListener listener);
//
// void removeListener(@NotNull UserEventsListener listener);
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/ProductivityBoost.java
import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.users.User;
import jetbrains.buildServer.vcs.SVcsModification;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.UserEventsListener;
import org.jetbrains.buildserver.achievements.UserEventsRegistry;
import java.util.Calendar;
import java.util.Date;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class ProductivityBoost extends SimpleAchievement {
public ProductivityBoost(@NotNull final UserEventsRegistry userEventsRegistry) {
super(AchievementEvents.changeAdded.name(), 20); | userEventsRegistry.addListener(new UserEventsListener() { |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/ProductivityBoost.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsListener.java
// public interface UserEventsListener extends EventListener {
// void userEventPublished(@NotNull User user, @NotNull String eventName, @Nullable Object additionalData);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsRegistry.java
// public interface UserEventsRegistry {
// @NotNull
// UserEvents getUserEvents(@NotNull User user);
//
// void addListener(@NotNull UserEventsListener listener);
//
// void removeListener(@NotNull UserEventsListener listener);
// }
| import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.users.User;
import jetbrains.buildServer.vcs.SVcsModification;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.UserEventsListener;
import org.jetbrains.buildserver.achievements.UserEventsRegistry;
import java.util.Calendar;
import java.util.Date; | SVcsModification mod = (SVcsModification) additionalData;
Date vcsDate = mod.getVcsDate();
if (Calendar.getInstance().getTime().getTime() - vcsDate.getTime() < 24 * 3600 * 1000) {
userEventsRegistry.getUserEvents(user).registerEvent(getId() + ":changeAdded");
}
}
});
}
@NotNull
public String getId() {
return "productivityBoost";
}
@NotNull
public String getName() {
return "Productivity Boost";
}
@NotNull
public String getDescription() {
return "Granted for making a lot of commits during the day.";
}
@Nullable
public String getIconClassNames() {
return "icon-thumbs-up";
}
@Override | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsListener.java
// public interface UserEventsListener extends EventListener {
// void userEventPublished(@NotNull User user, @NotNull String eventName, @Nullable Object additionalData);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsRegistry.java
// public interface UserEventsRegistry {
// @NotNull
// UserEvents getUserEvents(@NotNull User user);
//
// void addListener(@NotNull UserEventsListener listener);
//
// void removeListener(@NotNull UserEventsListener listener);
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/ProductivityBoost.java
import jetbrains.buildServer.users.SUser;
import jetbrains.buildServer.users.User;
import jetbrains.buildServer.vcs.SVcsModification;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.UserEventsListener;
import org.jetbrains.buildserver.achievements.UserEventsRegistry;
import java.util.Calendar;
import java.util.Date;
SVcsModification mod = (SVcsModification) additionalData;
Date vcsDate = mod.getVcsDate();
if (Calendar.getInstance().getTime().getTime() - vcsDate.getTime() < 24 * 3600 * 1000) {
userEventsRegistry.getUserEvents(user).registerEvent(getId() + ":changeAdded");
}
}
});
}
@NotNull
public String getId() {
return "productivityBoost";
}
@NotNull
public String getName() {
return "Productivity Boost";
}
@NotNull
public String getDescription() {
return "Granted for making a lot of commits during the day.";
}
@Nullable
public String getIconClassNames() {
return "icon-thumbs-up";
}
@Override | public boolean shouldGrantAchievement(@NotNull SUser user, @NotNull UserEvents events, @NotNull String lastEventName, @Nullable Object additionalData) { |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/Taxonomist.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
| import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class Taxonomist extends SimpleAchievement {
public Taxonomist() { | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/Taxonomist.java
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class Taxonomist extends SimpleAchievement {
public Taxonomist() { | super(AchievementEvents.buildTagged.name(), 10); |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/UserEventsRegistryImpl.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsListener.java
// public interface UserEventsListener extends EventListener {
// void userEventPublished(@NotNull User user, @NotNull String eventName, @Nullable Object additionalData);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsRegistry.java
// public interface UserEventsRegistry {
// @NotNull
// UserEvents getUserEvents(@NotNull User user);
//
// void addListener(@NotNull UserEventsListener listener);
//
// void removeListener(@NotNull UserEventsListener listener);
// }
| import jetbrains.buildServer.users.User;
import jetbrains.buildServer.util.EventDispatcher;
import jetbrains.buildServer.util.SystemTimeService;
import jetbrains.buildServer.util.TimeService;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.UserEventsListener;
import org.jetbrains.buildserver.achievements.UserEventsRegistry;
import java.util.HashMap;
import java.util.Map; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class UserEventsRegistryImpl implements UserEventsRegistry {
private final EventDispatcher<UserEventsListener> myEventDispatcher = EventDispatcher.create(UserEventsListener.class); | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsListener.java
// public interface UserEventsListener extends EventListener {
// void userEventPublished(@NotNull User user, @NotNull String eventName, @Nullable Object additionalData);
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEventsRegistry.java
// public interface UserEventsRegistry {
// @NotNull
// UserEvents getUserEvents(@NotNull User user);
//
// void addListener(@NotNull UserEventsListener listener);
//
// void removeListener(@NotNull UserEventsListener listener);
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/UserEventsRegistryImpl.java
import jetbrains.buildServer.users.User;
import jetbrains.buildServer.util.EventDispatcher;
import jetbrains.buildServer.util.SystemTimeService;
import jetbrains.buildServer.util.TimeService;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.UserEvents;
import org.jetbrains.buildserver.achievements.UserEventsListener;
import org.jetbrains.buildserver.achievements.UserEventsRegistry;
import java.util.HashMap;
import java.util.Map;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class UserEventsRegistryImpl implements UserEventsRegistry {
private final EventDispatcher<UserEventsListener> myEventDispatcher = EventDispatcher.create(UserEventsListener.class); | private Map<Long, UserEvents> myUserEvents = new HashMap<Long, UserEvents>(); |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/EarlyBird.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
| import jetbrains.buildServer.users.SUser;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import java.util.TimeZone; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class EarlyBird implements Achievement {
@NotNull
public String getId() {
return "earlyBird_2";
}
@NotNull
public String getName() {
return "Early Bird";
}
@NotNull
public String getDescription() {
return "Granted for some early action on the build server.";
}
@Nullable
public String getIconClassNames() {
return "icon-twitter early-bird";
}
| // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/EarlyBird.java
import jetbrains.buildServer.users.SUser;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import java.util.TimeZone;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class EarlyBird implements Achievement {
@NotNull
public String getId() {
return "earlyBird_2";
}
@NotNull
public String getName() {
return "Early Bird";
}
@NotNull
public String getDescription() {
return "Granted for some early action on the build server.";
}
@Nullable
public String getIconClassNames() {
return "icon-twitter early-bird";
}
| public boolean shouldGrantAchievement(@NotNull SUser user, @NotNull UserEvents events, @NotNull String lastEventName, Object additionalData) { |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/EarlyBird.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
| import jetbrains.buildServer.users.SUser;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import java.util.TimeZone; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class EarlyBird implements Achievement {
@NotNull
public String getId() {
return "earlyBird_2";
}
@NotNull
public String getName() {
return "Early Bird";
}
@NotNull
public String getDescription() {
return "Granted for some early action on the build server.";
}
@Nullable
public String getIconClassNames() {
return "icon-twitter early-bird";
}
public boolean shouldGrantAchievement(@NotNull SUser user, @NotNull UserEvents events, @NotNull String lastEventName, Object additionalData) { | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/AchievementEvents.java
// public enum AchievementEvents {
// buildUnpinned,
// buildTagged,
// testBombed,
// testDisarmed,
// compilationBroken,
// investigationDelegated,
// investigationTaken,
// issueMentioned,
// changeAdded,
// userAction // with 5 minutes resolution
// }
//
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/EarlyBird.java
import jetbrains.buildServer.users.SUser;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.AchievementEvents;
import org.jetbrains.buildserver.achievements.UserEvents;
import java.util.TimeZone;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public class EarlyBird implements Achievement {
@NotNull
public String getId() {
return "earlyBird_2";
}
@NotNull
public String getName() {
return "Early Bird";
}
@NotNull
public String getDescription() {
return "Granted for some early action on the build server.";
}
@Nullable
public String getIconClassNames() {
return "icon-twitter early-bird";
}
public boolean shouldGrantAchievement(@NotNull SUser user, @NotNull UserEvents events, @NotNull String lastEventName, Object additionalData) { | return lastEventName.equals(AchievementEvents.userAction.name()) && |
JetBrains/teamcity-achievements | achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/SimpleAchievement.java | // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
| import jetbrains.buildServer.users.SUser;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.UserEvents; | /*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public abstract class SimpleAchievement implements Achievement {
private final String myEventName;
private final int myEventsCount;
protected SimpleAchievement(@NotNull String eventName, int eventsCount) {
myEventName = eventName;
myEventsCount = eventsCount;
}
| // Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/UserEvents.java
// public interface UserEvents {
// void registerEvent(@NotNull String eventName);
//
// void registerEvent(@NotNull String eventName, @Nullable Object additionalData);
//
// long getLastEventTime(@NotNull String eventName);
//
// // most recent first
// @NotNull
// List<Long> getEventTimes(@NotNull String eventName);
//
// int getNumberOfEvents(@NotNull String eventName);
//
// float getEventsRate(@NotNull String eventName, int timeIntervalSeconds);
// }
// Path: achievements-server/src/main/java/org/jetbrains/buildserver/achievements/impl/SimpleAchievement.java
import jetbrains.buildServer.users.SUser;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.buildserver.achievements.UserEvents;
/*
* Copyright 2000-2021 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.buildserver.achievements.impl;
public abstract class SimpleAchievement implements Achievement {
private final String myEventName;
private final int myEventsCount;
protected SimpleAchievement(@NotNull String eventName, int eventsCount) {
myEventName = eventName;
myEventsCount = eventsCount;
}
| public boolean shouldGrantAchievement(@NotNull SUser user, @NotNull UserEvents events, @NotNull String lastEventName, @Nullable Object additionalData) { |
Chicken-Bones/WirelessRedstone | src/codechicken/wirelessredstone/core/RenderWirelessBolt.java | // Path: src/codechicken/wirelessredstone/core/WirelessBolt.java
// public class Segment
// {
// public Segment(BoltPoint start, BoltPoint end, float light, int segmentnumber, int splitnumber) {
// this.startpoint = start;
// this.endpoint = end;
// this.light = light;
// this.segmentno = segmentnumber;
// this.splitno = splitnumber;
//
// calcDiff();
// }
//
// public Segment(Vector3 start, Vector3 end) {
// this(new BoltPoint(start, new Vector3(0, 0, 0)), new BoltPoint(end, new Vector3(0, 0, 0)), 1, 0, 0);
// }
//
// public void calcDiff() {
// diff = endpoint.point.copy().subtract(startpoint.point);
// }
//
// public void calcEndDiffs() {
// if (prev != null) {
// Vector3 prevdiffnorm = prev.diff.copy().normalize();
// Vector3 thisdiffnorm = diff.copy().normalize();
//
// prevdiff = thisdiffnorm.copy().add(prevdiffnorm).normalize();
// sinprev = (float) Math.sin(thisdiffnorm.angle(prevdiffnorm.negate()) / 2);
// } else {
// prevdiff = diff.copy().normalize();
// sinprev = 1;
// }
//
// if (next != null) {
// Vector3 nextdiffnorm = next.diff.copy().normalize();
// Vector3 thisdiffnorm = diff.copy().normalize();
//
// nextdiff = thisdiffnorm.add(nextdiffnorm).normalize();
// sinnext = (float) Math.sin(thisdiffnorm.angle(nextdiffnorm.negate()) / 2);
// } else {
// nextdiff = diff.copy().normalize();
// sinnext = 1;
// }
// }
//
// public String toString() {
// return startpoint.point.toString() + " " + endpoint.point.toString();
// }
//
// public BoltPoint startpoint;
// public BoltPoint endpoint;
//
// public Vector3 diff;
//
// public Segment prev;
// public Segment next;
//
// public Vector3 nextdiff;
// public Vector3 prevdiff;
//
// public float sinprev;
// public float sinnext;
// public float light;
//
// public int segmentno;
// public int splitno;
// }
| import java.util.Iterator;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.entity.Entity;
import net.minecraft.client.renderer.Tessellator;
import org.lwjgl.opengl.GL11;
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.RenderUtils;
import codechicken.lib.vec.Vector3;
import codechicken.wirelessredstone.core.WirelessBolt.Segment; | for(WirelessBolt bolt : WirelessBolt.clientboltlist)
renderBolt(bolt, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 0);
CCRenderState.draw();
CCRenderState.changeTexture("wrcbe_core:textures/lightning_redstone.png");
CCRenderState.startDrawing(7);
for(WirelessBolt bolt : WirelessBolt.clientboltlist)
renderBolt(bolt, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 1);
CCRenderState.draw();
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
GL11.glPopMatrix();
}
private static void renderBolt(WirelessBolt bolt, float partialframe, float cosyaw, float cospitch, float sinyaw, float cossinpitch, int pass)
{
Tessellator t = Tessellator.instance;
float boltage = bolt.particleAge < 0 ? 0 : (float)bolt.particleAge / (float)bolt.particleMaxAge;
float mainalpha = 1;
if(pass == 0)
mainalpha = (1 - boltage) * 0.4F;
else
mainalpha = 1 - boltage * 0.5F;
int expandTime = (int)(bolt.length*WirelessBolt.speed);
int renderstart = (int) ((expandTime/2-bolt.particleMaxAge+bolt.particleAge) / (float)(expandTime/2) * bolt.numsegments0);
int renderend = (int) ((bolt.particleAge+expandTime) / (float)expandTime * bolt.numsegments0);
| // Path: src/codechicken/wirelessredstone/core/WirelessBolt.java
// public class Segment
// {
// public Segment(BoltPoint start, BoltPoint end, float light, int segmentnumber, int splitnumber) {
// this.startpoint = start;
// this.endpoint = end;
// this.light = light;
// this.segmentno = segmentnumber;
// this.splitno = splitnumber;
//
// calcDiff();
// }
//
// public Segment(Vector3 start, Vector3 end) {
// this(new BoltPoint(start, new Vector3(0, 0, 0)), new BoltPoint(end, new Vector3(0, 0, 0)), 1, 0, 0);
// }
//
// public void calcDiff() {
// diff = endpoint.point.copy().subtract(startpoint.point);
// }
//
// public void calcEndDiffs() {
// if (prev != null) {
// Vector3 prevdiffnorm = prev.diff.copy().normalize();
// Vector3 thisdiffnorm = diff.copy().normalize();
//
// prevdiff = thisdiffnorm.copy().add(prevdiffnorm).normalize();
// sinprev = (float) Math.sin(thisdiffnorm.angle(prevdiffnorm.negate()) / 2);
// } else {
// prevdiff = diff.copy().normalize();
// sinprev = 1;
// }
//
// if (next != null) {
// Vector3 nextdiffnorm = next.diff.copy().normalize();
// Vector3 thisdiffnorm = diff.copy().normalize();
//
// nextdiff = thisdiffnorm.add(nextdiffnorm).normalize();
// sinnext = (float) Math.sin(thisdiffnorm.angle(nextdiffnorm.negate()) / 2);
// } else {
// nextdiff = diff.copy().normalize();
// sinnext = 1;
// }
// }
//
// public String toString() {
// return startpoint.point.toString() + " " + endpoint.point.toString();
// }
//
// public BoltPoint startpoint;
// public BoltPoint endpoint;
//
// public Vector3 diff;
//
// public Segment prev;
// public Segment next;
//
// public Vector3 nextdiff;
// public Vector3 prevdiff;
//
// public float sinprev;
// public float sinnext;
// public float light;
//
// public int segmentno;
// public int splitno;
// }
// Path: src/codechicken/wirelessredstone/core/RenderWirelessBolt.java
import java.util.Iterator;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.entity.Entity;
import net.minecraft.client.renderer.Tessellator;
import org.lwjgl.opengl.GL11;
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.RenderUtils;
import codechicken.lib.vec.Vector3;
import codechicken.wirelessredstone.core.WirelessBolt.Segment;
for(WirelessBolt bolt : WirelessBolt.clientboltlist)
renderBolt(bolt, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 0);
CCRenderState.draw();
CCRenderState.changeTexture("wrcbe_core:textures/lightning_redstone.png");
CCRenderState.startDrawing(7);
for(WirelessBolt bolt : WirelessBolt.clientboltlist)
renderBolt(bolt, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 1);
CCRenderState.draw();
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
GL11.glPopMatrix();
}
private static void renderBolt(WirelessBolt bolt, float partialframe, float cosyaw, float cospitch, float sinyaw, float cossinpitch, int pass)
{
Tessellator t = Tessellator.instance;
float boltage = bolt.particleAge < 0 ? 0 : (float)bolt.particleAge / (float)bolt.particleMaxAge;
float mainalpha = 1;
if(pass == 0)
mainalpha = (1 - boltage) * 0.4F;
else
mainalpha = 1 - boltage * 0.5F;
int expandTime = (int)(bolt.length*WirelessBolt.speed);
int renderstart = (int) ((expandTime/2-bolt.particleMaxAge+bolt.particleAge) / (float)(expandTime/2) * bolt.numsegments0);
int renderend = (int) ((bolt.particleAge+expandTime) / (float)expandTime * bolt.numsegments0);
| for(Iterator<Segment> iterator = bolt.segments.iterator(); iterator.hasNext();) |
Chicken-Bones/WirelessRedstone | src/codechicken/wirelessredstone/logic/WRLogicProxy.java | // Path: src/codechicken/wirelessredstone/core/WirelessRedstoneCore.java
// @Mod(modid = "WR-CBE|Core", dependencies = "required-after:CodeChickenCore@[" + CodeChickenCorePlugin.version + ",);" +
// "required-after:ForgeMultipart")//have to make sure it's before all mods within this container until FML fixes proxy injection.
// public class WirelessRedstoneCore
// {
// public static Item obsidianStick;
// public static Item stoneBowl;
// public static Item retherPearl;
// public static Item wirelessTransceiver;
// public static Item blazeTransceiver;
// public static Item recieverDish;
// public static Item blazeRecieverDish;
//
// public static DamageSource damagebolt;
// public static final String channel = "WRCBE";
//
// @SidedProxy(clientSide = "codechicken.wirelessredstone.core.WRCoreClientProxy",
// serverSide = "codechicken.wirelessredstone.core.WRCoreProxy")
// public static WRCoreProxy proxy;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// proxy.preInit();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init();
// }
//
// @EventHandler
// public void serverStarting(FMLServerStartingEvent event) {
// CommandHandler commandManager = (CommandHandler) event.getServer().getCommandManager();
// commandManager.registerCommand(new CommandFreq());
// }
// }
//
// Path: src/codechicken/wirelessredstone/logic/WirelessRedstoneLogic.java
// @Mod(modid = "WR-CBE|Logic", dependencies = "required-after:WR-CBE|Core;required-after:ForgeMultipart")
// public class WirelessRedstoneLogic
// {
// public static Item itemwireless;
//
// @SidedProxy(clientSide="codechicken.wirelessredstone.logic.WRLogicClientProxy",
// serverSide="codechicken.wirelessredstone.logic.WRLogicProxy")
// public static WRLogicProxy proxy;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event)
// {
// proxy.init();
// }
// }
| import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.ShapedOreRecipe;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.MultipartGenerator;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.MultiPartRegistry.IPartFactory;
import codechicken.wirelessredstone.core.WirelessRedstoneCore;
import cpw.mods.fml.common.registry.GameRegistry;
import static codechicken.wirelessredstone.logic.WirelessRedstoneLogic.*; | package codechicken.wirelessredstone.logic;
public class WRLogicProxy implements IPartFactory
{
public void init()
{
MultiPartRegistry.registerParts(this, new String[]{
"wrcbe-tran",
"wrcbe-recv",
"wrcbe-jamm"
});
MultipartGenerator.registerPassThroughInterface("codechicken.wirelessredstone.core.ITileWireless");
MultipartGenerator.registerPassThroughInterface("codechicken.wirelessredstone.core.ITileReceiver");
MultipartGenerator.registerPassThroughInterface("codechicken.wirelessredstone.core.ITileJammer");
//until CC proper integration
//MultipartGenerator.registerPassThroughInterface("dan200.computer.api.IPeripheral");
itemwireless = new ItemWirelessPart().setCreativeTab(CreativeTabs.tabRedstone);
GameRegistry.registerItem(itemwireless, "wirelessLogic");
addRecipies();
}
private static void addRecipies()
{
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemwireless, 1, 0),
"t ",
"srr",
"fff", | // Path: src/codechicken/wirelessredstone/core/WirelessRedstoneCore.java
// @Mod(modid = "WR-CBE|Core", dependencies = "required-after:CodeChickenCore@[" + CodeChickenCorePlugin.version + ",);" +
// "required-after:ForgeMultipart")//have to make sure it's before all mods within this container until FML fixes proxy injection.
// public class WirelessRedstoneCore
// {
// public static Item obsidianStick;
// public static Item stoneBowl;
// public static Item retherPearl;
// public static Item wirelessTransceiver;
// public static Item blazeTransceiver;
// public static Item recieverDish;
// public static Item blazeRecieverDish;
//
// public static DamageSource damagebolt;
// public static final String channel = "WRCBE";
//
// @SidedProxy(clientSide = "codechicken.wirelessredstone.core.WRCoreClientProxy",
// serverSide = "codechicken.wirelessredstone.core.WRCoreProxy")
// public static WRCoreProxy proxy;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// proxy.preInit();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init();
// }
//
// @EventHandler
// public void serverStarting(FMLServerStartingEvent event) {
// CommandHandler commandManager = (CommandHandler) event.getServer().getCommandManager();
// commandManager.registerCommand(new CommandFreq());
// }
// }
//
// Path: src/codechicken/wirelessredstone/logic/WirelessRedstoneLogic.java
// @Mod(modid = "WR-CBE|Logic", dependencies = "required-after:WR-CBE|Core;required-after:ForgeMultipart")
// public class WirelessRedstoneLogic
// {
// public static Item itemwireless;
//
// @SidedProxy(clientSide="codechicken.wirelessredstone.logic.WRLogicClientProxy",
// serverSide="codechicken.wirelessredstone.logic.WRLogicProxy")
// public static WRLogicProxy proxy;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event)
// {
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event)
// {
// proxy.init();
// }
// }
// Path: src/codechicken/wirelessredstone/logic/WRLogicProxy.java
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.ShapedOreRecipe;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.MultipartGenerator;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.MultiPartRegistry.IPartFactory;
import codechicken.wirelessredstone.core.WirelessRedstoneCore;
import cpw.mods.fml.common.registry.GameRegistry;
import static codechicken.wirelessredstone.logic.WirelessRedstoneLogic.*;
package codechicken.wirelessredstone.logic;
public class WRLogicProxy implements IPartFactory
{
public void init()
{
MultiPartRegistry.registerParts(this, new String[]{
"wrcbe-tran",
"wrcbe-recv",
"wrcbe-jamm"
});
MultipartGenerator.registerPassThroughInterface("codechicken.wirelessredstone.core.ITileWireless");
MultipartGenerator.registerPassThroughInterface("codechicken.wirelessredstone.core.ITileReceiver");
MultipartGenerator.registerPassThroughInterface("codechicken.wirelessredstone.core.ITileJammer");
//until CC proper integration
//MultipartGenerator.registerPassThroughInterface("dan200.computer.api.IPeripheral");
itemwireless = new ItemWirelessPart().setCreativeTab(CreativeTabs.tabRedstone);
GameRegistry.registerItem(itemwireless, "wirelessLogic");
addRecipies();
}
private static void addRecipies()
{
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemwireless, 1, 0),
"t ",
"srr",
"fff", | 't', WirelessRedstoneCore.wirelessTransceiver, |
Chicken-Bones/WirelessRedstone | src/codechicken/wirelessredstone/core/WRCoreClientProxy.java | // Path: src/codechicken/wirelessredstone/core/WirelessRedstoneCore.java
// @Mod(modid = "WR-CBE|Core", dependencies = "required-after:CodeChickenCore@[" + CodeChickenCorePlugin.version + ",);" +
// "required-after:ForgeMultipart")//have to make sure it's before all mods within this container until FML fixes proxy injection.
// public class WirelessRedstoneCore
// {
// public static Item obsidianStick;
// public static Item stoneBowl;
// public static Item retherPearl;
// public static Item wirelessTransceiver;
// public static Item blazeTransceiver;
// public static Item recieverDish;
// public static Item blazeRecieverDish;
//
// public static DamageSource damagebolt;
// public static final String channel = "WRCBE";
//
// @SidedProxy(clientSide = "codechicken.wirelessredstone.core.WRCoreClientProxy",
// serverSide = "codechicken.wirelessredstone.core.WRCoreProxy")
// public static WRCoreProxy proxy;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// proxy.preInit();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init();
// }
//
// @EventHandler
// public void serverStarting(FMLServerStartingEvent event) {
// CommandHandler commandManager = (CommandHandler) event.getServer().getCommandManager();
// commandManager.registerCommand(new CommandFreq());
// }
// }
| import codechicken.core.ClientUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import codechicken.core.CCUpdateChecker;
import codechicken.lib.packet.PacketCustom;
import cpw.mods.fml.common.Mod;
import static codechicken.wirelessredstone.core.WirelessRedstoneCore.*; | package codechicken.wirelessredstone.core;
public class WRCoreClientProxy extends WRCoreProxy
{
@Override
public void init()
{
if(SaveManager.config().getTag("checkUpdates").getBooleanValue(true)) | // Path: src/codechicken/wirelessredstone/core/WirelessRedstoneCore.java
// @Mod(modid = "WR-CBE|Core", dependencies = "required-after:CodeChickenCore@[" + CodeChickenCorePlugin.version + ",);" +
// "required-after:ForgeMultipart")//have to make sure it's before all mods within this container until FML fixes proxy injection.
// public class WirelessRedstoneCore
// {
// public static Item obsidianStick;
// public static Item stoneBowl;
// public static Item retherPearl;
// public static Item wirelessTransceiver;
// public static Item blazeTransceiver;
// public static Item recieverDish;
// public static Item blazeRecieverDish;
//
// public static DamageSource damagebolt;
// public static final String channel = "WRCBE";
//
// @SidedProxy(clientSide = "codechicken.wirelessredstone.core.WRCoreClientProxy",
// serverSide = "codechicken.wirelessredstone.core.WRCoreProxy")
// public static WRCoreProxy proxy;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// proxy.preInit();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// proxy.init();
// }
//
// @EventHandler
// public void serverStarting(FMLServerStartingEvent event) {
// CommandHandler commandManager = (CommandHandler) event.getServer().getCommandManager();
// commandManager.registerCommand(new CommandFreq());
// }
// }
// Path: src/codechicken/wirelessredstone/core/WRCoreClientProxy.java
import codechicken.core.ClientUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import codechicken.core.CCUpdateChecker;
import codechicken.lib.packet.PacketCustom;
import cpw.mods.fml.common.Mod;
import static codechicken.wirelessredstone.core.WirelessRedstoneCore.*;
package codechicken.wirelessredstone.core;
public class WRCoreClientProxy extends WRCoreProxy
{
@Override
public void init()
{
if(SaveManager.config().getTag("checkUpdates").getBooleanValue(true)) | CCUpdateChecker.updateCheck("WR-CBE", WirelessRedstoneCore.class.getAnnotation(Mod.class).version()); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.