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
|
|---|---|---|---|---|---|---|
thehiflyer/Fettle
|
src/main/java/se/fearless/fettle/builder/EntryExitActionBuilder.java
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/MutableTransitionModel.java
// public interface MutableTransitionModel<S, E, C> extends TransitionModel<S, E, C>, StateMachineTemplate<S, E, C> {
//
// StateMachineTemplate<S, E, C> createImmutableClone();
//
// void addTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addFromAllTransition(S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addInternalTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addEntryAction(S entryState, Action<S, E, C> action);
//
// void addExitAction(S exitState, Action<S, E, C> action);
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
|
import se.fearless.fettle.Action;
import se.fearless.fettle.MutableTransitionModel;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.List;
|
package se.fearless.fettle.builder;
public class EntryExitActionBuilder<S, E, C> implements EntryExit<S, E, C> {
private final Mode mode;
private final S state;
private EntryExitActionBuilder(Mode mode, S state) {
this.mode = mode;
this.state = state;
}
private enum Mode {
ENTRY,
EXIT
}
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/MutableTransitionModel.java
// public interface MutableTransitionModel<S, E, C> extends TransitionModel<S, E, C>, StateMachineTemplate<S, E, C> {
//
// StateMachineTemplate<S, E, C> createImmutableClone();
//
// void addTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addFromAllTransition(S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addInternalTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addEntryAction(S entryState, Action<S, E, C> action);
//
// void addExitAction(S exitState, Action<S, E, C> action);
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
// Path: src/main/java/se/fearless/fettle/builder/EntryExitActionBuilder.java
import se.fearless.fettle.Action;
import se.fearless.fettle.MutableTransitionModel;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.List;
package se.fearless.fettle.builder;
public class EntryExitActionBuilder<S, E, C> implements EntryExit<S, E, C> {
private final Mode mode;
private final S state;
private EntryExitActionBuilder(Mode mode, S state) {
this.mode = mode;
this.state = state;
}
private enum Mode {
ENTRY,
EXIT
}
|
private final List<Action<S, E, C>> actions = GuavaReplacement.newArrayList();
|
thehiflyer/Fettle
|
src/main/java/se/fearless/fettle/builder/EntryExitActionBuilder.java
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/MutableTransitionModel.java
// public interface MutableTransitionModel<S, E, C> extends TransitionModel<S, E, C>, StateMachineTemplate<S, E, C> {
//
// StateMachineTemplate<S, E, C> createImmutableClone();
//
// void addTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addFromAllTransition(S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addInternalTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addEntryAction(S entryState, Action<S, E, C> action);
//
// void addExitAction(S exitState, Action<S, E, C> action);
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
|
import se.fearless.fettle.Action;
import se.fearless.fettle.MutableTransitionModel;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.List;
|
package se.fearless.fettle.builder;
public class EntryExitActionBuilder<S, E, C> implements EntryExit<S, E, C> {
private final Mode mode;
private final S state;
private EntryExitActionBuilder(Mode mode, S state) {
this.mode = mode;
this.state = state;
}
private enum Mode {
ENTRY,
EXIT
}
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/MutableTransitionModel.java
// public interface MutableTransitionModel<S, E, C> extends TransitionModel<S, E, C>, StateMachineTemplate<S, E, C> {
//
// StateMachineTemplate<S, E, C> createImmutableClone();
//
// void addTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addFromAllTransition(S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addInternalTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addEntryAction(S entryState, Action<S, E, C> action);
//
// void addExitAction(S exitState, Action<S, E, C> action);
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
// Path: src/main/java/se/fearless/fettle/builder/EntryExitActionBuilder.java
import se.fearless.fettle.Action;
import se.fearless.fettle.MutableTransitionModel;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.List;
package se.fearless.fettle.builder;
public class EntryExitActionBuilder<S, E, C> implements EntryExit<S, E, C> {
private final Mode mode;
private final S state;
private EntryExitActionBuilder(Mode mode, S state) {
this.mode = mode;
this.state = state;
}
private enum Mode {
ENTRY,
EXIT
}
|
private final List<Action<S, E, C>> actions = GuavaReplacement.newArrayList();
|
thehiflyer/Fettle
|
src/main/java/se/fearless/fettle/builder/EntryExitActionBuilder.java
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/MutableTransitionModel.java
// public interface MutableTransitionModel<S, E, C> extends TransitionModel<S, E, C>, StateMachineTemplate<S, E, C> {
//
// StateMachineTemplate<S, E, C> createImmutableClone();
//
// void addTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addFromAllTransition(S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addInternalTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addEntryAction(S entryState, Action<S, E, C> action);
//
// void addExitAction(S exitState, Action<S, E, C> action);
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
|
import se.fearless.fettle.Action;
import se.fearless.fettle.MutableTransitionModel;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.List;
|
package se.fearless.fettle.builder;
public class EntryExitActionBuilder<S, E, C> implements EntryExit<S, E, C> {
private final Mode mode;
private final S state;
private EntryExitActionBuilder(Mode mode, S state) {
this.mode = mode;
this.state = state;
}
private enum Mode {
ENTRY,
EXIT
}
private final List<Action<S, E, C>> actions = GuavaReplacement.newArrayList();
public static <S, E, C> EntryExitActionBuilder<S, E, C> entry(S to) {
return new EntryExitActionBuilder<>(Mode.ENTRY, to);
}
public static <S, E, C> EntryExitActionBuilder<S, E, C> exit(S from) {
return new EntryExitActionBuilder<>(Mode.EXIT, from);
}
@Override
public EntryExit<S, E, C> perform(Action<S, E, C> action) {
this.actions.add(action);
return this;
}
@Override
public EntryExit<S, E, C> perform(List<Action<S, E, C>> actions) {
this.actions.addAll(actions);
return this;
}
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/MutableTransitionModel.java
// public interface MutableTransitionModel<S, E, C> extends TransitionModel<S, E, C>, StateMachineTemplate<S, E, C> {
//
// StateMachineTemplate<S, E, C> createImmutableClone();
//
// void addTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addFromAllTransition(S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addInternalTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addEntryAction(S entryState, Action<S, E, C> action);
//
// void addExitAction(S exitState, Action<S, E, C> action);
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
// Path: src/main/java/se/fearless/fettle/builder/EntryExitActionBuilder.java
import se.fearless.fettle.Action;
import se.fearless.fettle.MutableTransitionModel;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.List;
package se.fearless.fettle.builder;
public class EntryExitActionBuilder<S, E, C> implements EntryExit<S, E, C> {
private final Mode mode;
private final S state;
private EntryExitActionBuilder(Mode mode, S state) {
this.mode = mode;
this.state = state;
}
private enum Mode {
ENTRY,
EXIT
}
private final List<Action<S, E, C>> actions = GuavaReplacement.newArrayList();
public static <S, E, C> EntryExitActionBuilder<S, E, C> entry(S to) {
return new EntryExitActionBuilder<>(Mode.ENTRY, to);
}
public static <S, E, C> EntryExitActionBuilder<S, E, C> exit(S from) {
return new EntryExitActionBuilder<>(Mode.EXIT, from);
}
@Override
public EntryExit<S, E, C> perform(Action<S, E, C> action) {
this.actions.add(action);
return this;
}
@Override
public EntryExit<S, E, C> perform(List<Action<S, E, C>> actions) {
this.actions.addAll(actions);
return this;
}
|
public void addToMachine(MutableTransitionModel<S, E, C> machineConstructor) {
|
thehiflyer/Fettle
|
src/main/java/se/fearless/fettle/builder/TransitionBuilder.java
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/BasicConditions.java
// public class BasicConditions {
//
// private BasicConditions() {
// }
//
// public static <C> Condition<C> always() {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return true;
// }
// };
// }
//
// public static <C> Condition<C> and(final Condition<C> first, final Condition<C> second) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return first.isSatisfied(context) && second.isSatisfied(context);
// }
// };
// }
//
// public static <C> Condition<C> and(final List<Condition<C>> conditions) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// for (Condition<C> condition : conditions) {
// if (!condition.isSatisfied(context)) {
// return false;
// }
// }
// return true;
// }
// };
// }
//
// public static <C> Condition<C> or(final Condition<C> first, final Condition<C> second) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return first.isSatisfied(context) || second.isSatisfied(context);
// }
// };
// }
//
// public static <C> Condition<C> or(final List<Condition<C>> conditions) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// for (Condition<C> condition : conditions) {
// if (condition.isSatisfied(context)) {
// return true;
// }
// }
// return false;
// }
// };
// }
//
// public static <C> Condition<C> not(final Condition<C> condition) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return !condition.isSatisfied(context);
// }
// };
// }
//
// public static <C> Condition<C> xor(final Condition<C> first, final Condition<C> second) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return first.isSatisfied(context) ^ second.isSatisfied(context);
// }
// };
// }
// }
//
// Path: src/main/java/se/fearless/fettle/Condition.java
// public interface Condition<C> {
// boolean isSatisfied(C context);
// }
//
// Path: src/main/java/se/fearless/fettle/MutableTransitionModel.java
// public interface MutableTransitionModel<S, E, C> extends TransitionModel<S, E, C>, StateMachineTemplate<S, E, C> {
//
// StateMachineTemplate<S, E, C> createImmutableClone();
//
// void addTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addFromAllTransition(S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addInternalTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addEntryAction(S entryState, Action<S, E, C> action);
//
// void addExitAction(S exitState, Action<S, E, C> action);
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
|
import se.fearless.fettle.Action;
import se.fearless.fettle.BasicConditions;
import se.fearless.fettle.Condition;
import se.fearless.fettle.MutableTransitionModel;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.List;
|
package se.fearless.fettle.builder;
class TransitionBuilder<S, E, C> implements Transition<S, E, C>, From<S, E, C>, To<S, E, C>, On<S, E, C>, When<S, E, C>, Internal<S, E, C> {
private final List<Action<S, E, C>> actions = GuavaReplacement.newArrayList();
private S from;
private S to;
private E event;
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/BasicConditions.java
// public class BasicConditions {
//
// private BasicConditions() {
// }
//
// public static <C> Condition<C> always() {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return true;
// }
// };
// }
//
// public static <C> Condition<C> and(final Condition<C> first, final Condition<C> second) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return first.isSatisfied(context) && second.isSatisfied(context);
// }
// };
// }
//
// public static <C> Condition<C> and(final List<Condition<C>> conditions) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// for (Condition<C> condition : conditions) {
// if (!condition.isSatisfied(context)) {
// return false;
// }
// }
// return true;
// }
// };
// }
//
// public static <C> Condition<C> or(final Condition<C> first, final Condition<C> second) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return first.isSatisfied(context) || second.isSatisfied(context);
// }
// };
// }
//
// public static <C> Condition<C> or(final List<Condition<C>> conditions) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// for (Condition<C> condition : conditions) {
// if (condition.isSatisfied(context)) {
// return true;
// }
// }
// return false;
// }
// };
// }
//
// public static <C> Condition<C> not(final Condition<C> condition) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return !condition.isSatisfied(context);
// }
// };
// }
//
// public static <C> Condition<C> xor(final Condition<C> first, final Condition<C> second) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return first.isSatisfied(context) ^ second.isSatisfied(context);
// }
// };
// }
// }
//
// Path: src/main/java/se/fearless/fettle/Condition.java
// public interface Condition<C> {
// boolean isSatisfied(C context);
// }
//
// Path: src/main/java/se/fearless/fettle/MutableTransitionModel.java
// public interface MutableTransitionModel<S, E, C> extends TransitionModel<S, E, C>, StateMachineTemplate<S, E, C> {
//
// StateMachineTemplate<S, E, C> createImmutableClone();
//
// void addTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addFromAllTransition(S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addInternalTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addEntryAction(S entryState, Action<S, E, C> action);
//
// void addExitAction(S exitState, Action<S, E, C> action);
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
// Path: src/main/java/se/fearless/fettle/builder/TransitionBuilder.java
import se.fearless.fettle.Action;
import se.fearless.fettle.BasicConditions;
import se.fearless.fettle.Condition;
import se.fearless.fettle.MutableTransitionModel;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.List;
package se.fearless.fettle.builder;
class TransitionBuilder<S, E, C> implements Transition<S, E, C>, From<S, E, C>, To<S, E, C>, On<S, E, C>, When<S, E, C>, Internal<S, E, C> {
private final List<Action<S, E, C>> actions = GuavaReplacement.newArrayList();
private S from;
private S to;
private E event;
|
private Condition<C> condition = BasicConditions.always();
|
thehiflyer/Fettle
|
src/main/java/se/fearless/fettle/builder/TransitionBuilder.java
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/BasicConditions.java
// public class BasicConditions {
//
// private BasicConditions() {
// }
//
// public static <C> Condition<C> always() {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return true;
// }
// };
// }
//
// public static <C> Condition<C> and(final Condition<C> first, final Condition<C> second) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return first.isSatisfied(context) && second.isSatisfied(context);
// }
// };
// }
//
// public static <C> Condition<C> and(final List<Condition<C>> conditions) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// for (Condition<C> condition : conditions) {
// if (!condition.isSatisfied(context)) {
// return false;
// }
// }
// return true;
// }
// };
// }
//
// public static <C> Condition<C> or(final Condition<C> first, final Condition<C> second) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return first.isSatisfied(context) || second.isSatisfied(context);
// }
// };
// }
//
// public static <C> Condition<C> or(final List<Condition<C>> conditions) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// for (Condition<C> condition : conditions) {
// if (condition.isSatisfied(context)) {
// return true;
// }
// }
// return false;
// }
// };
// }
//
// public static <C> Condition<C> not(final Condition<C> condition) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return !condition.isSatisfied(context);
// }
// };
// }
//
// public static <C> Condition<C> xor(final Condition<C> first, final Condition<C> second) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return first.isSatisfied(context) ^ second.isSatisfied(context);
// }
// };
// }
// }
//
// Path: src/main/java/se/fearless/fettle/Condition.java
// public interface Condition<C> {
// boolean isSatisfied(C context);
// }
//
// Path: src/main/java/se/fearless/fettle/MutableTransitionModel.java
// public interface MutableTransitionModel<S, E, C> extends TransitionModel<S, E, C>, StateMachineTemplate<S, E, C> {
//
// StateMachineTemplate<S, E, C> createImmutableClone();
//
// void addTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addFromAllTransition(S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addInternalTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addEntryAction(S entryState, Action<S, E, C> action);
//
// void addExitAction(S exitState, Action<S, E, C> action);
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
|
import se.fearless.fettle.Action;
import se.fearless.fettle.BasicConditions;
import se.fearless.fettle.Condition;
import se.fearless.fettle.MutableTransitionModel;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.List;
|
package se.fearless.fettle.builder;
class TransitionBuilder<S, E, C> implements Transition<S, E, C>, From<S, E, C>, To<S, E, C>, On<S, E, C>, When<S, E, C>, Internal<S, E, C> {
private final List<Action<S, E, C>> actions = GuavaReplacement.newArrayList();
private S from;
private S to;
private E event;
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/BasicConditions.java
// public class BasicConditions {
//
// private BasicConditions() {
// }
//
// public static <C> Condition<C> always() {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return true;
// }
// };
// }
//
// public static <C> Condition<C> and(final Condition<C> first, final Condition<C> second) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return first.isSatisfied(context) && second.isSatisfied(context);
// }
// };
// }
//
// public static <C> Condition<C> and(final List<Condition<C>> conditions) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// for (Condition<C> condition : conditions) {
// if (!condition.isSatisfied(context)) {
// return false;
// }
// }
// return true;
// }
// };
// }
//
// public static <C> Condition<C> or(final Condition<C> first, final Condition<C> second) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return first.isSatisfied(context) || second.isSatisfied(context);
// }
// };
// }
//
// public static <C> Condition<C> or(final List<Condition<C>> conditions) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// for (Condition<C> condition : conditions) {
// if (condition.isSatisfied(context)) {
// return true;
// }
// }
// return false;
// }
// };
// }
//
// public static <C> Condition<C> not(final Condition<C> condition) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return !condition.isSatisfied(context);
// }
// };
// }
//
// public static <C> Condition<C> xor(final Condition<C> first, final Condition<C> second) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return first.isSatisfied(context) ^ second.isSatisfied(context);
// }
// };
// }
// }
//
// Path: src/main/java/se/fearless/fettle/Condition.java
// public interface Condition<C> {
// boolean isSatisfied(C context);
// }
//
// Path: src/main/java/se/fearless/fettle/MutableTransitionModel.java
// public interface MutableTransitionModel<S, E, C> extends TransitionModel<S, E, C>, StateMachineTemplate<S, E, C> {
//
// StateMachineTemplate<S, E, C> createImmutableClone();
//
// void addTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addFromAllTransition(S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addInternalTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addEntryAction(S entryState, Action<S, E, C> action);
//
// void addExitAction(S exitState, Action<S, E, C> action);
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
// Path: src/main/java/se/fearless/fettle/builder/TransitionBuilder.java
import se.fearless.fettle.Action;
import se.fearless.fettle.BasicConditions;
import se.fearless.fettle.Condition;
import se.fearless.fettle.MutableTransitionModel;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.List;
package se.fearless.fettle.builder;
class TransitionBuilder<S, E, C> implements Transition<S, E, C>, From<S, E, C>, To<S, E, C>, On<S, E, C>, When<S, E, C>, Internal<S, E, C> {
private final List<Action<S, E, C>> actions = GuavaReplacement.newArrayList();
private S from;
private S to;
private E event;
|
private Condition<C> condition = BasicConditions.always();
|
thehiflyer/Fettle
|
src/main/java/se/fearless/fettle/builder/TransitionBuilder.java
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/BasicConditions.java
// public class BasicConditions {
//
// private BasicConditions() {
// }
//
// public static <C> Condition<C> always() {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return true;
// }
// };
// }
//
// public static <C> Condition<C> and(final Condition<C> first, final Condition<C> second) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return first.isSatisfied(context) && second.isSatisfied(context);
// }
// };
// }
//
// public static <C> Condition<C> and(final List<Condition<C>> conditions) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// for (Condition<C> condition : conditions) {
// if (!condition.isSatisfied(context)) {
// return false;
// }
// }
// return true;
// }
// };
// }
//
// public static <C> Condition<C> or(final Condition<C> first, final Condition<C> second) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return first.isSatisfied(context) || second.isSatisfied(context);
// }
// };
// }
//
// public static <C> Condition<C> or(final List<Condition<C>> conditions) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// for (Condition<C> condition : conditions) {
// if (condition.isSatisfied(context)) {
// return true;
// }
// }
// return false;
// }
// };
// }
//
// public static <C> Condition<C> not(final Condition<C> condition) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return !condition.isSatisfied(context);
// }
// };
// }
//
// public static <C> Condition<C> xor(final Condition<C> first, final Condition<C> second) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return first.isSatisfied(context) ^ second.isSatisfied(context);
// }
// };
// }
// }
//
// Path: src/main/java/se/fearless/fettle/Condition.java
// public interface Condition<C> {
// boolean isSatisfied(C context);
// }
//
// Path: src/main/java/se/fearless/fettle/MutableTransitionModel.java
// public interface MutableTransitionModel<S, E, C> extends TransitionModel<S, E, C>, StateMachineTemplate<S, E, C> {
//
// StateMachineTemplate<S, E, C> createImmutableClone();
//
// void addTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addFromAllTransition(S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addInternalTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addEntryAction(S entryState, Action<S, E, C> action);
//
// void addExitAction(S exitState, Action<S, E, C> action);
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
|
import se.fearless.fettle.Action;
import se.fearless.fettle.BasicConditions;
import se.fearless.fettle.Condition;
import se.fearless.fettle.MutableTransitionModel;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.List;
|
public To<S, E, C> to(S toState) {
this.to = toState;
return this;
}
@Override
public Internal<S, E, C> internal(S state) {
this.from = state;
this.to = state;
runEntryAndExit = false;
return this;
}
@Override
public When<S, E, C> when(Condition<C> condition) {
this.condition = condition;
return this;
}
@Override
public void perform(List<Action<S, E, C>> actions) {
this.actions.addAll(actions);
}
@Override
public void perform(Action<S, E, C> action) {
this.actions.add(action);
}
@SuppressWarnings("unchecked")
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/BasicConditions.java
// public class BasicConditions {
//
// private BasicConditions() {
// }
//
// public static <C> Condition<C> always() {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return true;
// }
// };
// }
//
// public static <C> Condition<C> and(final Condition<C> first, final Condition<C> second) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return first.isSatisfied(context) && second.isSatisfied(context);
// }
// };
// }
//
// public static <C> Condition<C> and(final List<Condition<C>> conditions) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// for (Condition<C> condition : conditions) {
// if (!condition.isSatisfied(context)) {
// return false;
// }
// }
// return true;
// }
// };
// }
//
// public static <C> Condition<C> or(final Condition<C> first, final Condition<C> second) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return first.isSatisfied(context) || second.isSatisfied(context);
// }
// };
// }
//
// public static <C> Condition<C> or(final List<Condition<C>> conditions) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// for (Condition<C> condition : conditions) {
// if (condition.isSatisfied(context)) {
// return true;
// }
// }
// return false;
// }
// };
// }
//
// public static <C> Condition<C> not(final Condition<C> condition) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return !condition.isSatisfied(context);
// }
// };
// }
//
// public static <C> Condition<C> xor(final Condition<C> first, final Condition<C> second) {
// return new Condition<C>() {
// @Override
// public boolean isSatisfied(C context) {
// return first.isSatisfied(context) ^ second.isSatisfied(context);
// }
// };
// }
// }
//
// Path: src/main/java/se/fearless/fettle/Condition.java
// public interface Condition<C> {
// boolean isSatisfied(C context);
// }
//
// Path: src/main/java/se/fearless/fettle/MutableTransitionModel.java
// public interface MutableTransitionModel<S, E, C> extends TransitionModel<S, E, C>, StateMachineTemplate<S, E, C> {
//
// StateMachineTemplate<S, E, C> createImmutableClone();
//
// void addTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addFromAllTransition(S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addInternalTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions);
//
// void addEntryAction(S entryState, Action<S, E, C> action);
//
// void addExitAction(S exitState, Action<S, E, C> action);
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
// Path: src/main/java/se/fearless/fettle/builder/TransitionBuilder.java
import se.fearless.fettle.Action;
import se.fearless.fettle.BasicConditions;
import se.fearless.fettle.Condition;
import se.fearless.fettle.MutableTransitionModel;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.List;
public To<S, E, C> to(S toState) {
this.to = toState;
return this;
}
@Override
public Internal<S, E, C> internal(S state) {
this.from = state;
this.to = state;
runEntryAndExit = false;
return this;
}
@Override
public When<S, E, C> when(Condition<C> condition) {
this.condition = condition;
return this;
}
@Override
public void perform(List<Action<S, E, C>> actions) {
this.actions.addAll(actions);
}
@Override
public void perform(Action<S, E, C> action) {
this.actions.add(action);
}
@SuppressWarnings("unchecked")
|
void addToTransitionModel(MutableTransitionModel<S, E, C> transitionModel) {
|
thehiflyer/Fettle
|
src/test/java/se/fearless/fettle/PredicateConditionTest.java
|
// Path: src/main/java/se/fearless/fettle/util/PredicateCondition.java
// public class PredicateCondition<C> implements Condition<C> {
//
// private final Predicate<? super C> predicate;
//
// public PredicateCondition(Predicate<? super C> predicate) {
// this.predicate = predicate;
// }
//
// @Override
// public boolean isSatisfied(C context) {
// return predicate.test(context);
// }
// }
|
import com.google.common.base.Predicates;
import org.junit.Test;
import se.fearless.fettle.util.PredicateCondition;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
|
package se.fearless.fettle;
public class PredicateConditionTest {
@Test
public void predicate() {
|
// Path: src/main/java/se/fearless/fettle/util/PredicateCondition.java
// public class PredicateCondition<C> implements Condition<C> {
//
// private final Predicate<? super C> predicate;
//
// public PredicateCondition(Predicate<? super C> predicate) {
// this.predicate = predicate;
// }
//
// @Override
// public boolean isSatisfied(C context) {
// return predicate.test(context);
// }
// }
// Path: src/test/java/se/fearless/fettle/PredicateConditionTest.java
import com.google.common.base.Predicates;
import org.junit.Test;
import se.fearless.fettle.util.PredicateCondition;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
package se.fearless.fettle;
public class PredicateConditionTest {
@Test
public void predicate() {
|
PredicateCondition<String> condition = new PredicateCondition<>(Predicates.containsPattern("foo")::apply);
|
thehiflyer/Fettle
|
src/test/java/se/fearless/fettle/TestStatesImmutable.java
|
// Path: src/main/java/se/fearless/fettle/impl/MutableTransitionModelImpl.java
// public class MutableTransitionModelImpl<S, E, C> extends AbstractTransitionModel<S, E, C> implements MutableTransitionModel<S, E, C> {
//
// private MutableTransitionModelImpl(Class<S> stateClass, Class<E> eventClass, C defaultContext) {
// super(stateClass, eventClass, defaultContext);
// }
//
// public static <S, E, C> MutableTransitionModelImpl<S, E, C> create(Class<S> stateClass, Class<E> eventClass, C defaultContext) {
// return new MutableTransitionModelImpl<>(stateClass, eventClass, defaultContext);
// }
//
// public static <S, E, C> MutableTransitionModelImpl<S, E, C> create(Class<S> stateClass, Class<E> eventClass) {
// return new MutableTransitionModelImpl<>(stateClass, eventClass, null);
// }
//
// @Override
// public StateMachine<S, E, C> newStateMachine(S init) {
// return newStateMachine(init, new ReentrantLock());
// }
//
//
// @Override
// public StateMachine<S, E, C> newStateMachine(S init, Lock lock) {
// return new TemplateBasedStateMachine<>(this, init, lock);
// }
//
//
// @Override
// public StateMachineTemplate<S, E, C> createImmutableClone() {
// return new ImmutableTransitionModel<>(stateClass, eventClass, transitionMap, fromAllTransitions, exitActions, enterActions, defaultContext);
// }
//
// @Override
// public void addTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions) {
// addTransition(from, event, new BasicTransition<>(to, condition, actions));
// }
//
// @Override
// public void addInternalTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions) {
// addTransition(from, event, new InternalTransition<>(to, condition, actions));
// }
//
// private void addTransition(S from, E event, Transition<S, E, C> transition) {
// Map<E, Collection<Transition<S, E, C>>> map = transitionMap.computeIfAbsent(from, k -> createMap(eventClass));
// Collection<Transition<S, E, C>> transitions = map.computeIfAbsent(event, k -> GuavaReplacement.newArrayList());
// transitions.add(transition);
// }
//
// @Override
// public void addFromAllTransition(S to, E event, Condition<C> condition, List<Action<S, E, C>> actions) {
// Collection<Transition<S, E, C>> transitions = fromAllTransitions.computeIfAbsent(event, k -> GuavaReplacement.newArrayList());
// transitions.add(new BasicTransition<>(to, condition, actions));
// }
//
// @Override
// public void addEntryAction(S entryState, Action<S, E, C> action) {
// addAction(entryState, action, enterActions);
// }
//
// private void addAction(S entryState, Action<S, E, C> action, Map<S, Collection<Action<S, E, C>>> map) {
// Collection<Action<S, E, C>> collection = map.computeIfAbsent(entryState, k -> GuavaReplacement.newArrayList());
// collection.add(action);
// }
//
// @Override
// public void addExitAction(S exitState, Action<S, E, C> action) {
// addAction(exitState, action, exitActions);
// }
// }
|
import com.googlecode.gentyref.TypeToken;
import org.junit.Test;
import se.fearless.fettle.impl.MutableTransitionModelImpl;
import java.util.Collections;
import static org.junit.Assert.assertEquals;
import static se.mockachino.Mockachino.mock;
import static se.mockachino.Mockachino.verifyNever;
import static se.mockachino.Mockachino.verifyOnce;
import static se.mockachino.matchers.Matchers.any;
|
package se.fearless.fettle;
public class TestStatesImmutable {
private static final TypeToken<Action<States, String, Void>> ACTION_TYPE_TOKEN = new TypeToken<Action<States, String, Void>>() {
};
@Test
public void simpleStateTransition() {
|
// Path: src/main/java/se/fearless/fettle/impl/MutableTransitionModelImpl.java
// public class MutableTransitionModelImpl<S, E, C> extends AbstractTransitionModel<S, E, C> implements MutableTransitionModel<S, E, C> {
//
// private MutableTransitionModelImpl(Class<S> stateClass, Class<E> eventClass, C defaultContext) {
// super(stateClass, eventClass, defaultContext);
// }
//
// public static <S, E, C> MutableTransitionModelImpl<S, E, C> create(Class<S> stateClass, Class<E> eventClass, C defaultContext) {
// return new MutableTransitionModelImpl<>(stateClass, eventClass, defaultContext);
// }
//
// public static <S, E, C> MutableTransitionModelImpl<S, E, C> create(Class<S> stateClass, Class<E> eventClass) {
// return new MutableTransitionModelImpl<>(stateClass, eventClass, null);
// }
//
// @Override
// public StateMachine<S, E, C> newStateMachine(S init) {
// return newStateMachine(init, new ReentrantLock());
// }
//
//
// @Override
// public StateMachine<S, E, C> newStateMachine(S init, Lock lock) {
// return new TemplateBasedStateMachine<>(this, init, lock);
// }
//
//
// @Override
// public StateMachineTemplate<S, E, C> createImmutableClone() {
// return new ImmutableTransitionModel<>(stateClass, eventClass, transitionMap, fromAllTransitions, exitActions, enterActions, defaultContext);
// }
//
// @Override
// public void addTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions) {
// addTransition(from, event, new BasicTransition<>(to, condition, actions));
// }
//
// @Override
// public void addInternalTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions) {
// addTransition(from, event, new InternalTransition<>(to, condition, actions));
// }
//
// private void addTransition(S from, E event, Transition<S, E, C> transition) {
// Map<E, Collection<Transition<S, E, C>>> map = transitionMap.computeIfAbsent(from, k -> createMap(eventClass));
// Collection<Transition<S, E, C>> transitions = map.computeIfAbsent(event, k -> GuavaReplacement.newArrayList());
// transitions.add(transition);
// }
//
// @Override
// public void addFromAllTransition(S to, E event, Condition<C> condition, List<Action<S, E, C>> actions) {
// Collection<Transition<S, E, C>> transitions = fromAllTransitions.computeIfAbsent(event, k -> GuavaReplacement.newArrayList());
// transitions.add(new BasicTransition<>(to, condition, actions));
// }
//
// @Override
// public void addEntryAction(S entryState, Action<S, E, C> action) {
// addAction(entryState, action, enterActions);
// }
//
// private void addAction(S entryState, Action<S, E, C> action, Map<S, Collection<Action<S, E, C>>> map) {
// Collection<Action<S, E, C>> collection = map.computeIfAbsent(entryState, k -> GuavaReplacement.newArrayList());
// collection.add(action);
// }
//
// @Override
// public void addExitAction(S exitState, Action<S, E, C> action) {
// addAction(exitState, action, exitActions);
// }
// }
// Path: src/test/java/se/fearless/fettle/TestStatesImmutable.java
import com.googlecode.gentyref.TypeToken;
import org.junit.Test;
import se.fearless.fettle.impl.MutableTransitionModelImpl;
import java.util.Collections;
import static org.junit.Assert.assertEquals;
import static se.mockachino.Mockachino.mock;
import static se.mockachino.Mockachino.verifyNever;
import static se.mockachino.Mockachino.verifyOnce;
import static se.mockachino.matchers.Matchers.any;
package se.fearless.fettle;
public class TestStatesImmutable {
private static final TypeToken<Action<States, String, Void>> ACTION_TYPE_TOKEN = new TypeToken<Action<States, String, Void>>() {
};
@Test
public void simpleStateTransition() {
|
MutableTransitionModelImpl<States, String, Void> model = MutableTransitionModelImpl.create(States.class, String.class);
|
thehiflyer/Fettle
|
src/test/java/se/fearless/fettle/SelfTransitionsTest.java
|
// Path: src/main/java/se/fearless/fettle/builder/StateMachineBuilder.java
// public class StateMachineBuilder<S, E, C> {
// private final List<TransitionBuilder<S, E, C>> transitionBuilders = GuavaReplacement.newArrayList();
// private final List<EntryExitActionBuilder<S, E, C>> entryExitActions = GuavaReplacement.newArrayList();
// private final Class<S> stateClass;
// private final Class<E> eventClass;
// private C defaultContext;
//
//
// private StateMachineBuilder(Class<S> stateClass, Class<E> eventClass) {
// this.stateClass = stateClass;
// this.eventClass = eventClass;
// }
//
// public static <S, E, C> StateMachineBuilder<S, E, C> create(Class<S> stateClass, Class<E> eventClass) {
// return new StateMachineBuilder<>(stateClass, eventClass);
// }
//
// public Transition<S, E, C> transition() {
// TransitionBuilder<S, E, C> transition = new TransitionBuilder<>();
// transitionBuilders.add(transition);
// return transition;
// }
//
// public EntryExit<S, E, C> onEntry(S state) {
// EntryExitActionBuilder<S, E, C> actionBuilder = EntryExitActionBuilder.entry(state);
// entryExitActions.add(actionBuilder);
// return actionBuilder;
// }
//
// public EntryExit<S, E, C> onExit(S state) {
// EntryExitActionBuilder<S, E, C> actionBuilder = EntryExitActionBuilder.exit(state);
// entryExitActions.add(actionBuilder);
// return actionBuilder;
// }
//
// public StateMachineBuilder<S, E, C> defaultContext(C defaultContext) {
// this.defaultContext = defaultContext;
// return this;
// }
//
// /**
// * Builds a state machine with the transitions and states configured by the builder.
// * Note that consecutive calls to this method will not share transition models and it's therefore inefficient to
// * use this method to create large number of state machines. This method can be considered as a short hand for
// * cases when just one state machine of a certain configuration is needed.
// * @param initial the state the machine will be in when created
// * @return a new state machine configured with all the transitions and actions specified using this builder
// * @throws IllegalArgumentException if the initial state is null
// */
// public StateMachine<S, E, C> build(S initial) {
// @SuppressWarnings("unchecked")
// StateMachineTemplate<S, E, C> build = buildTransitionModel();
// return build.newStateMachine(initial);
// }
//
// /**
// * Builds a state machine template capable of creating many instances all sharing the same
// * state transitions and actions but all with their own current state.
// * This is more memory efficient and is good when you need a large number of identical state machine instances.
// *
// * @return a state machine template configured with all the transitions and actions specified using this builder
// */
// public StateMachineTemplate<S, E, C> buildTransitionModel() {
// MutableTransitionModelImpl<S, E, C> template = MutableTransitionModelImpl.create(stateClass, eventClass, defaultContext);
// for (TransitionBuilder<S, E, C> transitionBuilder : transitionBuilders) {
// transitionBuilder.addToTransitionModel(template);
// }
// for (EntryExitActionBuilder<S, E, C> entryExitAction : entryExitActions) {
// entryExitAction.addToMachine(template);
// }
// return template;
// }
// }
|
import org.junit.Before;
import org.junit.Test;
import se.fearless.fettle.builder.StateMachineBuilder;
import se.mockachino.annotations.Mock;
import static se.mockachino.Mockachino.setupMocks;
import static se.mockachino.Mockachino.verifyOnce;
import static se.mockachino.matchers.Matchers.any;
|
package se.fearless.fettle;
public class SelfTransitionsTest {
@Mock
private Action<States, String, Void> transitionAction;
@Mock
private Action<States, String, Void> entryAction;
@Mock
private Action<States, String, Void> exitAction;
private StateMachine<States, String, Void> stateMachine;
@Before
public void setUp() throws Exception {
setupMocks(this);
|
// Path: src/main/java/se/fearless/fettle/builder/StateMachineBuilder.java
// public class StateMachineBuilder<S, E, C> {
// private final List<TransitionBuilder<S, E, C>> transitionBuilders = GuavaReplacement.newArrayList();
// private final List<EntryExitActionBuilder<S, E, C>> entryExitActions = GuavaReplacement.newArrayList();
// private final Class<S> stateClass;
// private final Class<E> eventClass;
// private C defaultContext;
//
//
// private StateMachineBuilder(Class<S> stateClass, Class<E> eventClass) {
// this.stateClass = stateClass;
// this.eventClass = eventClass;
// }
//
// public static <S, E, C> StateMachineBuilder<S, E, C> create(Class<S> stateClass, Class<E> eventClass) {
// return new StateMachineBuilder<>(stateClass, eventClass);
// }
//
// public Transition<S, E, C> transition() {
// TransitionBuilder<S, E, C> transition = new TransitionBuilder<>();
// transitionBuilders.add(transition);
// return transition;
// }
//
// public EntryExit<S, E, C> onEntry(S state) {
// EntryExitActionBuilder<S, E, C> actionBuilder = EntryExitActionBuilder.entry(state);
// entryExitActions.add(actionBuilder);
// return actionBuilder;
// }
//
// public EntryExit<S, E, C> onExit(S state) {
// EntryExitActionBuilder<S, E, C> actionBuilder = EntryExitActionBuilder.exit(state);
// entryExitActions.add(actionBuilder);
// return actionBuilder;
// }
//
// public StateMachineBuilder<S, E, C> defaultContext(C defaultContext) {
// this.defaultContext = defaultContext;
// return this;
// }
//
// /**
// * Builds a state machine with the transitions and states configured by the builder.
// * Note that consecutive calls to this method will not share transition models and it's therefore inefficient to
// * use this method to create large number of state machines. This method can be considered as a short hand for
// * cases when just one state machine of a certain configuration is needed.
// * @param initial the state the machine will be in when created
// * @return a new state machine configured with all the transitions and actions specified using this builder
// * @throws IllegalArgumentException if the initial state is null
// */
// public StateMachine<S, E, C> build(S initial) {
// @SuppressWarnings("unchecked")
// StateMachineTemplate<S, E, C> build = buildTransitionModel();
// return build.newStateMachine(initial);
// }
//
// /**
// * Builds a state machine template capable of creating many instances all sharing the same
// * state transitions and actions but all with their own current state.
// * This is more memory efficient and is good when you need a large number of identical state machine instances.
// *
// * @return a state machine template configured with all the transitions and actions specified using this builder
// */
// public StateMachineTemplate<S, E, C> buildTransitionModel() {
// MutableTransitionModelImpl<S, E, C> template = MutableTransitionModelImpl.create(stateClass, eventClass, defaultContext);
// for (TransitionBuilder<S, E, C> transitionBuilder : transitionBuilders) {
// transitionBuilder.addToTransitionModel(template);
// }
// for (EntryExitActionBuilder<S, E, C> entryExitAction : entryExitActions) {
// entryExitAction.addToMachine(template);
// }
// return template;
// }
// }
// Path: src/test/java/se/fearless/fettle/SelfTransitionsTest.java
import org.junit.Before;
import org.junit.Test;
import se.fearless.fettle.builder.StateMachineBuilder;
import se.mockachino.annotations.Mock;
import static se.mockachino.Mockachino.setupMocks;
import static se.mockachino.Mockachino.verifyOnce;
import static se.mockachino.matchers.Matchers.any;
package se.fearless.fettle;
public class SelfTransitionsTest {
@Mock
private Action<States, String, Void> transitionAction;
@Mock
private Action<States, String, Void> entryAction;
@Mock
private Action<States, String, Void> exitAction;
private StateMachine<States, String, Void> stateMachine;
@Before
public void setUp() throws Exception {
setupMocks(this);
|
StateMachineBuilder<States, String, Void> builder = Fettle.newBuilder(States.class, String.class);
|
thehiflyer/Fettle
|
src/main/java/se/fearless/fettle/impl/ImmutableTransitionModel.java
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachine.java
// public interface StateMachine<S, E, C> {
// /**
// * Gets the current state of the machine
// *
// * @return the state the machine is currently in
// */
// S getCurrentState();
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event);
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @param context the context to be sent to any actions that are run on a state change. Used to supply parameters to
// * actions and conditions
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event, C context);
//
// /**
// * Sets the state of the state machine to the rawState even if there are no transitions leading to it
// * No transition, entry or exit actions are run
// *
// * @param rawState the state the machine will be in after this method is called
// */
// void rawSetState(S rawState);
//
// /**
// * Forces the state machine to enter the forcedState even if there are no transitions leading to it
// * No transition actions are run but exit actions on the current state and entry actions on the new state are run
// *
// * @param forcedState the state the machine will be in after this method is called
// * @return true if the state machine changed state
// */
// boolean forceSetState(S forcedState);
//
// /**
// * Returns all possible transitions from a given state grouped by the event that triggers the transition.
// * @param fromState the state to retrieve the outgoing transitions from.
// * @return a map from all registered events in the fromState to the transitions they would trigger if fired.
// */
// Map<E, Collection<? extends Transition<S, E, C>>> getPossibleTransitions(S fromState);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachineTemplate.java
// public interface StateMachineTemplate<S, E, C> {
// /**
// * Creates a new state machine using the transition model as a template
// * @param init the state the machine will be in when created
// * @return a new state machine with the transitions and actions defined in this model
// */
// StateMachine<S, E, C> newStateMachine(S init);
//
// StateMachine<S, E, C> newStateMachine(S init, Lock lock);
// }
//
// Path: src/main/java/se/fearless/fettle/Transition.java
// public interface Transition<S, E, C> {
// S getTo();
//
// boolean isSatisfied(C context);
//
// void onTransition(S from, S to, E event, C context, StateMachine<S, E, C> statemachine);
//
// boolean shouldExecuteEntryAndExitActions();
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/Lock.java
// public interface Lock {
// void lock();
// void unlock();
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/ReentrantLock.java
// public class ReentrantLock implements Lock {
//
// @Override
// public void lock() {
// }
//
// @Override
// public void unlock() {
// }
// }
|
import se.fearless.fettle.Action;
import se.fearless.fettle.StateMachine;
import se.fearless.fettle.StateMachineTemplate;
import se.fearless.fettle.Transition;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
|
package se.fearless.fettle.impl;
public class ImmutableTransitionModel<S, E, C> extends AbstractTransitionModel<S, E, C> implements StateMachineTemplate<S, E, C> {
public ImmutableTransitionModel(Class<S> stateClass, Class<E> eventClass,
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachine.java
// public interface StateMachine<S, E, C> {
// /**
// * Gets the current state of the machine
// *
// * @return the state the machine is currently in
// */
// S getCurrentState();
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event);
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @param context the context to be sent to any actions that are run on a state change. Used to supply parameters to
// * actions and conditions
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event, C context);
//
// /**
// * Sets the state of the state machine to the rawState even if there are no transitions leading to it
// * No transition, entry or exit actions are run
// *
// * @param rawState the state the machine will be in after this method is called
// */
// void rawSetState(S rawState);
//
// /**
// * Forces the state machine to enter the forcedState even if there are no transitions leading to it
// * No transition actions are run but exit actions on the current state and entry actions on the new state are run
// *
// * @param forcedState the state the machine will be in after this method is called
// * @return true if the state machine changed state
// */
// boolean forceSetState(S forcedState);
//
// /**
// * Returns all possible transitions from a given state grouped by the event that triggers the transition.
// * @param fromState the state to retrieve the outgoing transitions from.
// * @return a map from all registered events in the fromState to the transitions they would trigger if fired.
// */
// Map<E, Collection<? extends Transition<S, E, C>>> getPossibleTransitions(S fromState);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachineTemplate.java
// public interface StateMachineTemplate<S, E, C> {
// /**
// * Creates a new state machine using the transition model as a template
// * @param init the state the machine will be in when created
// * @return a new state machine with the transitions and actions defined in this model
// */
// StateMachine<S, E, C> newStateMachine(S init);
//
// StateMachine<S, E, C> newStateMachine(S init, Lock lock);
// }
//
// Path: src/main/java/se/fearless/fettle/Transition.java
// public interface Transition<S, E, C> {
// S getTo();
//
// boolean isSatisfied(C context);
//
// void onTransition(S from, S to, E event, C context, StateMachine<S, E, C> statemachine);
//
// boolean shouldExecuteEntryAndExitActions();
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/Lock.java
// public interface Lock {
// void lock();
// void unlock();
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/ReentrantLock.java
// public class ReentrantLock implements Lock {
//
// @Override
// public void lock() {
// }
//
// @Override
// public void unlock() {
// }
// }
// Path: src/main/java/se/fearless/fettle/impl/ImmutableTransitionModel.java
import se.fearless.fettle.Action;
import se.fearless.fettle.StateMachine;
import se.fearless.fettle.StateMachineTemplate;
import se.fearless.fettle.Transition;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
package se.fearless.fettle.impl;
public class ImmutableTransitionModel<S, E, C> extends AbstractTransitionModel<S, E, C> implements StateMachineTemplate<S, E, C> {
public ImmutableTransitionModel(Class<S> stateClass, Class<E> eventClass,
|
Map<S, Map<E, Collection<Transition<S, E, C>>>> transitionMap,
|
thehiflyer/Fettle
|
src/main/java/se/fearless/fettle/impl/ImmutableTransitionModel.java
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachine.java
// public interface StateMachine<S, E, C> {
// /**
// * Gets the current state of the machine
// *
// * @return the state the machine is currently in
// */
// S getCurrentState();
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event);
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @param context the context to be sent to any actions that are run on a state change. Used to supply parameters to
// * actions and conditions
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event, C context);
//
// /**
// * Sets the state of the state machine to the rawState even if there are no transitions leading to it
// * No transition, entry or exit actions are run
// *
// * @param rawState the state the machine will be in after this method is called
// */
// void rawSetState(S rawState);
//
// /**
// * Forces the state machine to enter the forcedState even if there are no transitions leading to it
// * No transition actions are run but exit actions on the current state and entry actions on the new state are run
// *
// * @param forcedState the state the machine will be in after this method is called
// * @return true if the state machine changed state
// */
// boolean forceSetState(S forcedState);
//
// /**
// * Returns all possible transitions from a given state grouped by the event that triggers the transition.
// * @param fromState the state to retrieve the outgoing transitions from.
// * @return a map from all registered events in the fromState to the transitions they would trigger if fired.
// */
// Map<E, Collection<? extends Transition<S, E, C>>> getPossibleTransitions(S fromState);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachineTemplate.java
// public interface StateMachineTemplate<S, E, C> {
// /**
// * Creates a new state machine using the transition model as a template
// * @param init the state the machine will be in when created
// * @return a new state machine with the transitions and actions defined in this model
// */
// StateMachine<S, E, C> newStateMachine(S init);
//
// StateMachine<S, E, C> newStateMachine(S init, Lock lock);
// }
//
// Path: src/main/java/se/fearless/fettle/Transition.java
// public interface Transition<S, E, C> {
// S getTo();
//
// boolean isSatisfied(C context);
//
// void onTransition(S from, S to, E event, C context, StateMachine<S, E, C> statemachine);
//
// boolean shouldExecuteEntryAndExitActions();
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/Lock.java
// public interface Lock {
// void lock();
// void unlock();
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/ReentrantLock.java
// public class ReentrantLock implements Lock {
//
// @Override
// public void lock() {
// }
//
// @Override
// public void unlock() {
// }
// }
|
import se.fearless.fettle.Action;
import se.fearless.fettle.StateMachine;
import se.fearless.fettle.StateMachineTemplate;
import se.fearless.fettle.Transition;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
|
package se.fearless.fettle.impl;
public class ImmutableTransitionModel<S, E, C> extends AbstractTransitionModel<S, E, C> implements StateMachineTemplate<S, E, C> {
public ImmutableTransitionModel(Class<S> stateClass, Class<E> eventClass,
Map<S, Map<E, Collection<Transition<S, E, C>>>> transitionMap,
Map<E, Collection<Transition<S, E, C>>> fromAllTransitions,
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachine.java
// public interface StateMachine<S, E, C> {
// /**
// * Gets the current state of the machine
// *
// * @return the state the machine is currently in
// */
// S getCurrentState();
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event);
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @param context the context to be sent to any actions that are run on a state change. Used to supply parameters to
// * actions and conditions
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event, C context);
//
// /**
// * Sets the state of the state machine to the rawState even if there are no transitions leading to it
// * No transition, entry or exit actions are run
// *
// * @param rawState the state the machine will be in after this method is called
// */
// void rawSetState(S rawState);
//
// /**
// * Forces the state machine to enter the forcedState even if there are no transitions leading to it
// * No transition actions are run but exit actions on the current state and entry actions on the new state are run
// *
// * @param forcedState the state the machine will be in after this method is called
// * @return true if the state machine changed state
// */
// boolean forceSetState(S forcedState);
//
// /**
// * Returns all possible transitions from a given state grouped by the event that triggers the transition.
// * @param fromState the state to retrieve the outgoing transitions from.
// * @return a map from all registered events in the fromState to the transitions they would trigger if fired.
// */
// Map<E, Collection<? extends Transition<S, E, C>>> getPossibleTransitions(S fromState);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachineTemplate.java
// public interface StateMachineTemplate<S, E, C> {
// /**
// * Creates a new state machine using the transition model as a template
// * @param init the state the machine will be in when created
// * @return a new state machine with the transitions and actions defined in this model
// */
// StateMachine<S, E, C> newStateMachine(S init);
//
// StateMachine<S, E, C> newStateMachine(S init, Lock lock);
// }
//
// Path: src/main/java/se/fearless/fettle/Transition.java
// public interface Transition<S, E, C> {
// S getTo();
//
// boolean isSatisfied(C context);
//
// void onTransition(S from, S to, E event, C context, StateMachine<S, E, C> statemachine);
//
// boolean shouldExecuteEntryAndExitActions();
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/Lock.java
// public interface Lock {
// void lock();
// void unlock();
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/ReentrantLock.java
// public class ReentrantLock implements Lock {
//
// @Override
// public void lock() {
// }
//
// @Override
// public void unlock() {
// }
// }
// Path: src/main/java/se/fearless/fettle/impl/ImmutableTransitionModel.java
import se.fearless.fettle.Action;
import se.fearless.fettle.StateMachine;
import se.fearless.fettle.StateMachineTemplate;
import se.fearless.fettle.Transition;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
package se.fearless.fettle.impl;
public class ImmutableTransitionModel<S, E, C> extends AbstractTransitionModel<S, E, C> implements StateMachineTemplate<S, E, C> {
public ImmutableTransitionModel(Class<S> stateClass, Class<E> eventClass,
Map<S, Map<E, Collection<Transition<S, E, C>>>> transitionMap,
Map<E, Collection<Transition<S, E, C>>> fromAllTransitions,
|
Map<S, Collection<Action<S, E, C>>> exitActions,
|
thehiflyer/Fettle
|
src/main/java/se/fearless/fettle/impl/ImmutableTransitionModel.java
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachine.java
// public interface StateMachine<S, E, C> {
// /**
// * Gets the current state of the machine
// *
// * @return the state the machine is currently in
// */
// S getCurrentState();
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event);
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @param context the context to be sent to any actions that are run on a state change. Used to supply parameters to
// * actions and conditions
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event, C context);
//
// /**
// * Sets the state of the state machine to the rawState even if there are no transitions leading to it
// * No transition, entry or exit actions are run
// *
// * @param rawState the state the machine will be in after this method is called
// */
// void rawSetState(S rawState);
//
// /**
// * Forces the state machine to enter the forcedState even if there are no transitions leading to it
// * No transition actions are run but exit actions on the current state and entry actions on the new state are run
// *
// * @param forcedState the state the machine will be in after this method is called
// * @return true if the state machine changed state
// */
// boolean forceSetState(S forcedState);
//
// /**
// * Returns all possible transitions from a given state grouped by the event that triggers the transition.
// * @param fromState the state to retrieve the outgoing transitions from.
// * @return a map from all registered events in the fromState to the transitions they would trigger if fired.
// */
// Map<E, Collection<? extends Transition<S, E, C>>> getPossibleTransitions(S fromState);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachineTemplate.java
// public interface StateMachineTemplate<S, E, C> {
// /**
// * Creates a new state machine using the transition model as a template
// * @param init the state the machine will be in when created
// * @return a new state machine with the transitions and actions defined in this model
// */
// StateMachine<S, E, C> newStateMachine(S init);
//
// StateMachine<S, E, C> newStateMachine(S init, Lock lock);
// }
//
// Path: src/main/java/se/fearless/fettle/Transition.java
// public interface Transition<S, E, C> {
// S getTo();
//
// boolean isSatisfied(C context);
//
// void onTransition(S from, S to, E event, C context, StateMachine<S, E, C> statemachine);
//
// boolean shouldExecuteEntryAndExitActions();
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/Lock.java
// public interface Lock {
// void lock();
// void unlock();
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/ReentrantLock.java
// public class ReentrantLock implements Lock {
//
// @Override
// public void lock() {
// }
//
// @Override
// public void unlock() {
// }
// }
|
import se.fearless.fettle.Action;
import se.fearless.fettle.StateMachine;
import se.fearless.fettle.StateMachineTemplate;
import se.fearless.fettle.Transition;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
|
package se.fearless.fettle.impl;
public class ImmutableTransitionModel<S, E, C> extends AbstractTransitionModel<S, E, C> implements StateMachineTemplate<S, E, C> {
public ImmutableTransitionModel(Class<S> stateClass, Class<E> eventClass,
Map<S, Map<E, Collection<Transition<S, E, C>>>> transitionMap,
Map<E, Collection<Transition<S, E, C>>> fromAllTransitions,
Map<S, Collection<Action<S, E, C>>> exitActions,
Map<S, Collection<Action<S, E, C>>> enterActions, C defaultContext) {
super(stateClass, eventClass, defaultContext);
this.exitActions.putAll(copy(exitActions));
this.enterActions.putAll(copy(enterActions));
this.transitionMap.putAll(copyTransitions(transitionMap));
this.fromAllTransitions.putAll(copyTransitions3(fromAllTransitions));
}
private Map<E, Collection<Transition<S, E, C>>> copyTransitions3(Map<E, Collection<Transition<S, E, C>>> input) {
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachine.java
// public interface StateMachine<S, E, C> {
// /**
// * Gets the current state of the machine
// *
// * @return the state the machine is currently in
// */
// S getCurrentState();
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event);
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @param context the context to be sent to any actions that are run on a state change. Used to supply parameters to
// * actions and conditions
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event, C context);
//
// /**
// * Sets the state of the state machine to the rawState even if there are no transitions leading to it
// * No transition, entry or exit actions are run
// *
// * @param rawState the state the machine will be in after this method is called
// */
// void rawSetState(S rawState);
//
// /**
// * Forces the state machine to enter the forcedState even if there are no transitions leading to it
// * No transition actions are run but exit actions on the current state and entry actions on the new state are run
// *
// * @param forcedState the state the machine will be in after this method is called
// * @return true if the state machine changed state
// */
// boolean forceSetState(S forcedState);
//
// /**
// * Returns all possible transitions from a given state grouped by the event that triggers the transition.
// * @param fromState the state to retrieve the outgoing transitions from.
// * @return a map from all registered events in the fromState to the transitions they would trigger if fired.
// */
// Map<E, Collection<? extends Transition<S, E, C>>> getPossibleTransitions(S fromState);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachineTemplate.java
// public interface StateMachineTemplate<S, E, C> {
// /**
// * Creates a new state machine using the transition model as a template
// * @param init the state the machine will be in when created
// * @return a new state machine with the transitions and actions defined in this model
// */
// StateMachine<S, E, C> newStateMachine(S init);
//
// StateMachine<S, E, C> newStateMachine(S init, Lock lock);
// }
//
// Path: src/main/java/se/fearless/fettle/Transition.java
// public interface Transition<S, E, C> {
// S getTo();
//
// boolean isSatisfied(C context);
//
// void onTransition(S from, S to, E event, C context, StateMachine<S, E, C> statemachine);
//
// boolean shouldExecuteEntryAndExitActions();
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/Lock.java
// public interface Lock {
// void lock();
// void unlock();
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/ReentrantLock.java
// public class ReentrantLock implements Lock {
//
// @Override
// public void lock() {
// }
//
// @Override
// public void unlock() {
// }
// }
// Path: src/main/java/se/fearless/fettle/impl/ImmutableTransitionModel.java
import se.fearless.fettle.Action;
import se.fearless.fettle.StateMachine;
import se.fearless.fettle.StateMachineTemplate;
import se.fearless.fettle.Transition;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
package se.fearless.fettle.impl;
public class ImmutableTransitionModel<S, E, C> extends AbstractTransitionModel<S, E, C> implements StateMachineTemplate<S, E, C> {
public ImmutableTransitionModel(Class<S> stateClass, Class<E> eventClass,
Map<S, Map<E, Collection<Transition<S, E, C>>>> transitionMap,
Map<E, Collection<Transition<S, E, C>>> fromAllTransitions,
Map<S, Collection<Action<S, E, C>>> exitActions,
Map<S, Collection<Action<S, E, C>>> enterActions, C defaultContext) {
super(stateClass, eventClass, defaultContext);
this.exitActions.putAll(copy(exitActions));
this.enterActions.putAll(copy(enterActions));
this.transitionMap.putAll(copyTransitions(transitionMap));
this.fromAllTransitions.putAll(copyTransitions3(fromAllTransitions));
}
private Map<E, Collection<Transition<S, E, C>>> copyTransitions3(Map<E, Collection<Transition<S, E, C>>> input) {
|
Map<E, Collection<Transition<S, E, C>>> res = GuavaReplacement.newHashMap();
|
thehiflyer/Fettle
|
src/main/java/se/fearless/fettle/impl/ImmutableTransitionModel.java
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachine.java
// public interface StateMachine<S, E, C> {
// /**
// * Gets the current state of the machine
// *
// * @return the state the machine is currently in
// */
// S getCurrentState();
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event);
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @param context the context to be sent to any actions that are run on a state change. Used to supply parameters to
// * actions and conditions
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event, C context);
//
// /**
// * Sets the state of the state machine to the rawState even if there are no transitions leading to it
// * No transition, entry or exit actions are run
// *
// * @param rawState the state the machine will be in after this method is called
// */
// void rawSetState(S rawState);
//
// /**
// * Forces the state machine to enter the forcedState even if there are no transitions leading to it
// * No transition actions are run but exit actions on the current state and entry actions on the new state are run
// *
// * @param forcedState the state the machine will be in after this method is called
// * @return true if the state machine changed state
// */
// boolean forceSetState(S forcedState);
//
// /**
// * Returns all possible transitions from a given state grouped by the event that triggers the transition.
// * @param fromState the state to retrieve the outgoing transitions from.
// * @return a map from all registered events in the fromState to the transitions they would trigger if fired.
// */
// Map<E, Collection<? extends Transition<S, E, C>>> getPossibleTransitions(S fromState);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachineTemplate.java
// public interface StateMachineTemplate<S, E, C> {
// /**
// * Creates a new state machine using the transition model as a template
// * @param init the state the machine will be in when created
// * @return a new state machine with the transitions and actions defined in this model
// */
// StateMachine<S, E, C> newStateMachine(S init);
//
// StateMachine<S, E, C> newStateMachine(S init, Lock lock);
// }
//
// Path: src/main/java/se/fearless/fettle/Transition.java
// public interface Transition<S, E, C> {
// S getTo();
//
// boolean isSatisfied(C context);
//
// void onTransition(S from, S to, E event, C context, StateMachine<S, E, C> statemachine);
//
// boolean shouldExecuteEntryAndExitActions();
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/Lock.java
// public interface Lock {
// void lock();
// void unlock();
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/ReentrantLock.java
// public class ReentrantLock implements Lock {
//
// @Override
// public void lock() {
// }
//
// @Override
// public void unlock() {
// }
// }
|
import se.fearless.fettle.Action;
import se.fearless.fettle.StateMachine;
import se.fearless.fettle.StateMachineTemplate;
import se.fearless.fettle.Transition;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
|
return res;
}
private Map<E, Collection<Transition<S, E, C>>> copyTransitions2(Map<E, Collection<Transition<S, E, C>>> input) {
Map<E, Collection<Transition<S, E, C>>> res = GuavaReplacement.newHashMap();
for (Map.Entry<E, Collection<Transition<S, E, C>>> entry : input.entrySet()) {
E key = entry.getKey();
Collection<Transition<S, E, C>> value = entry.getValue();
res.put(key, copy(value));
}
return res;
}
private Map<S, Collection<Action<S, E, C>>> copy(Map<S, Collection<Action<S, E, C>>> input) {
Map<S, Collection<Action<S, E, C>>> res = GuavaReplacement.newHashMap();
for (Map.Entry<S, Collection<Action<S, E, C>>> entry : input.entrySet()) {
S key = entry.getKey();
Collection<Action<S, E, C>> value = entry.getValue();
res.put(key, copy(value));
}
return res;
}
private <T> Collection<T> copy(Collection<T> input) {
Collection<T> res = GuavaReplacement.newArrayList();
res.addAll(input);
return res;
}
@Override
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachine.java
// public interface StateMachine<S, E, C> {
// /**
// * Gets the current state of the machine
// *
// * @return the state the machine is currently in
// */
// S getCurrentState();
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event);
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @param context the context to be sent to any actions that are run on a state change. Used to supply parameters to
// * actions and conditions
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event, C context);
//
// /**
// * Sets the state of the state machine to the rawState even if there are no transitions leading to it
// * No transition, entry or exit actions are run
// *
// * @param rawState the state the machine will be in after this method is called
// */
// void rawSetState(S rawState);
//
// /**
// * Forces the state machine to enter the forcedState even if there are no transitions leading to it
// * No transition actions are run but exit actions on the current state and entry actions on the new state are run
// *
// * @param forcedState the state the machine will be in after this method is called
// * @return true if the state machine changed state
// */
// boolean forceSetState(S forcedState);
//
// /**
// * Returns all possible transitions from a given state grouped by the event that triggers the transition.
// * @param fromState the state to retrieve the outgoing transitions from.
// * @return a map from all registered events in the fromState to the transitions they would trigger if fired.
// */
// Map<E, Collection<? extends Transition<S, E, C>>> getPossibleTransitions(S fromState);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachineTemplate.java
// public interface StateMachineTemplate<S, E, C> {
// /**
// * Creates a new state machine using the transition model as a template
// * @param init the state the machine will be in when created
// * @return a new state machine with the transitions and actions defined in this model
// */
// StateMachine<S, E, C> newStateMachine(S init);
//
// StateMachine<S, E, C> newStateMachine(S init, Lock lock);
// }
//
// Path: src/main/java/se/fearless/fettle/Transition.java
// public interface Transition<S, E, C> {
// S getTo();
//
// boolean isSatisfied(C context);
//
// void onTransition(S from, S to, E event, C context, StateMachine<S, E, C> statemachine);
//
// boolean shouldExecuteEntryAndExitActions();
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/Lock.java
// public interface Lock {
// void lock();
// void unlock();
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/ReentrantLock.java
// public class ReentrantLock implements Lock {
//
// @Override
// public void lock() {
// }
//
// @Override
// public void unlock() {
// }
// }
// Path: src/main/java/se/fearless/fettle/impl/ImmutableTransitionModel.java
import se.fearless.fettle.Action;
import se.fearless.fettle.StateMachine;
import se.fearless.fettle.StateMachineTemplate;
import se.fearless.fettle.Transition;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
return res;
}
private Map<E, Collection<Transition<S, E, C>>> copyTransitions2(Map<E, Collection<Transition<S, E, C>>> input) {
Map<E, Collection<Transition<S, E, C>>> res = GuavaReplacement.newHashMap();
for (Map.Entry<E, Collection<Transition<S, E, C>>> entry : input.entrySet()) {
E key = entry.getKey();
Collection<Transition<S, E, C>> value = entry.getValue();
res.put(key, copy(value));
}
return res;
}
private Map<S, Collection<Action<S, E, C>>> copy(Map<S, Collection<Action<S, E, C>>> input) {
Map<S, Collection<Action<S, E, C>>> res = GuavaReplacement.newHashMap();
for (Map.Entry<S, Collection<Action<S, E, C>>> entry : input.entrySet()) {
S key = entry.getKey();
Collection<Action<S, E, C>> value = entry.getValue();
res.put(key, copy(value));
}
return res;
}
private <T> Collection<T> copy(Collection<T> input) {
Collection<T> res = GuavaReplacement.newArrayList();
res.addAll(input);
return res;
}
@Override
|
public StateMachine<S, E, C> newStateMachine(S init) {
|
thehiflyer/Fettle
|
src/main/java/se/fearless/fettle/impl/ImmutableTransitionModel.java
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachine.java
// public interface StateMachine<S, E, C> {
// /**
// * Gets the current state of the machine
// *
// * @return the state the machine is currently in
// */
// S getCurrentState();
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event);
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @param context the context to be sent to any actions that are run on a state change. Used to supply parameters to
// * actions and conditions
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event, C context);
//
// /**
// * Sets the state of the state machine to the rawState even if there are no transitions leading to it
// * No transition, entry or exit actions are run
// *
// * @param rawState the state the machine will be in after this method is called
// */
// void rawSetState(S rawState);
//
// /**
// * Forces the state machine to enter the forcedState even if there are no transitions leading to it
// * No transition actions are run but exit actions on the current state and entry actions on the new state are run
// *
// * @param forcedState the state the machine will be in after this method is called
// * @return true if the state machine changed state
// */
// boolean forceSetState(S forcedState);
//
// /**
// * Returns all possible transitions from a given state grouped by the event that triggers the transition.
// * @param fromState the state to retrieve the outgoing transitions from.
// * @return a map from all registered events in the fromState to the transitions they would trigger if fired.
// */
// Map<E, Collection<? extends Transition<S, E, C>>> getPossibleTransitions(S fromState);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachineTemplate.java
// public interface StateMachineTemplate<S, E, C> {
// /**
// * Creates a new state machine using the transition model as a template
// * @param init the state the machine will be in when created
// * @return a new state machine with the transitions and actions defined in this model
// */
// StateMachine<S, E, C> newStateMachine(S init);
//
// StateMachine<S, E, C> newStateMachine(S init, Lock lock);
// }
//
// Path: src/main/java/se/fearless/fettle/Transition.java
// public interface Transition<S, E, C> {
// S getTo();
//
// boolean isSatisfied(C context);
//
// void onTransition(S from, S to, E event, C context, StateMachine<S, E, C> statemachine);
//
// boolean shouldExecuteEntryAndExitActions();
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/Lock.java
// public interface Lock {
// void lock();
// void unlock();
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/ReentrantLock.java
// public class ReentrantLock implements Lock {
//
// @Override
// public void lock() {
// }
//
// @Override
// public void unlock() {
// }
// }
|
import se.fearless.fettle.Action;
import se.fearless.fettle.StateMachine;
import se.fearless.fettle.StateMachineTemplate;
import se.fearless.fettle.Transition;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
|
}
private Map<E, Collection<Transition<S, E, C>>> copyTransitions2(Map<E, Collection<Transition<S, E, C>>> input) {
Map<E, Collection<Transition<S, E, C>>> res = GuavaReplacement.newHashMap();
for (Map.Entry<E, Collection<Transition<S, E, C>>> entry : input.entrySet()) {
E key = entry.getKey();
Collection<Transition<S, E, C>> value = entry.getValue();
res.put(key, copy(value));
}
return res;
}
private Map<S, Collection<Action<S, E, C>>> copy(Map<S, Collection<Action<S, E, C>>> input) {
Map<S, Collection<Action<S, E, C>>> res = GuavaReplacement.newHashMap();
for (Map.Entry<S, Collection<Action<S, E, C>>> entry : input.entrySet()) {
S key = entry.getKey();
Collection<Action<S, E, C>> value = entry.getValue();
res.put(key, copy(value));
}
return res;
}
private <T> Collection<T> copy(Collection<T> input) {
Collection<T> res = GuavaReplacement.newArrayList();
res.addAll(input);
return res;
}
@Override
public StateMachine<S, E, C> newStateMachine(S init) {
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachine.java
// public interface StateMachine<S, E, C> {
// /**
// * Gets the current state of the machine
// *
// * @return the state the machine is currently in
// */
// S getCurrentState();
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event);
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @param context the context to be sent to any actions that are run on a state change. Used to supply parameters to
// * actions and conditions
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event, C context);
//
// /**
// * Sets the state of the state machine to the rawState even if there are no transitions leading to it
// * No transition, entry or exit actions are run
// *
// * @param rawState the state the machine will be in after this method is called
// */
// void rawSetState(S rawState);
//
// /**
// * Forces the state machine to enter the forcedState even if there are no transitions leading to it
// * No transition actions are run but exit actions on the current state and entry actions on the new state are run
// *
// * @param forcedState the state the machine will be in after this method is called
// * @return true if the state machine changed state
// */
// boolean forceSetState(S forcedState);
//
// /**
// * Returns all possible transitions from a given state grouped by the event that triggers the transition.
// * @param fromState the state to retrieve the outgoing transitions from.
// * @return a map from all registered events in the fromState to the transitions they would trigger if fired.
// */
// Map<E, Collection<? extends Transition<S, E, C>>> getPossibleTransitions(S fromState);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachineTemplate.java
// public interface StateMachineTemplate<S, E, C> {
// /**
// * Creates a new state machine using the transition model as a template
// * @param init the state the machine will be in when created
// * @return a new state machine with the transitions and actions defined in this model
// */
// StateMachine<S, E, C> newStateMachine(S init);
//
// StateMachine<S, E, C> newStateMachine(S init, Lock lock);
// }
//
// Path: src/main/java/se/fearless/fettle/Transition.java
// public interface Transition<S, E, C> {
// S getTo();
//
// boolean isSatisfied(C context);
//
// void onTransition(S from, S to, E event, C context, StateMachine<S, E, C> statemachine);
//
// boolean shouldExecuteEntryAndExitActions();
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/Lock.java
// public interface Lock {
// void lock();
// void unlock();
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/ReentrantLock.java
// public class ReentrantLock implements Lock {
//
// @Override
// public void lock() {
// }
//
// @Override
// public void unlock() {
// }
// }
// Path: src/main/java/se/fearless/fettle/impl/ImmutableTransitionModel.java
import se.fearless.fettle.Action;
import se.fearless.fettle.StateMachine;
import se.fearless.fettle.StateMachineTemplate;
import se.fearless.fettle.Transition;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
}
private Map<E, Collection<Transition<S, E, C>>> copyTransitions2(Map<E, Collection<Transition<S, E, C>>> input) {
Map<E, Collection<Transition<S, E, C>>> res = GuavaReplacement.newHashMap();
for (Map.Entry<E, Collection<Transition<S, E, C>>> entry : input.entrySet()) {
E key = entry.getKey();
Collection<Transition<S, E, C>> value = entry.getValue();
res.put(key, copy(value));
}
return res;
}
private Map<S, Collection<Action<S, E, C>>> copy(Map<S, Collection<Action<S, E, C>>> input) {
Map<S, Collection<Action<S, E, C>>> res = GuavaReplacement.newHashMap();
for (Map.Entry<S, Collection<Action<S, E, C>>> entry : input.entrySet()) {
S key = entry.getKey();
Collection<Action<S, E, C>> value = entry.getValue();
res.put(key, copy(value));
}
return res;
}
private <T> Collection<T> copy(Collection<T> input) {
Collection<T> res = GuavaReplacement.newArrayList();
res.addAll(input);
return res;
}
@Override
public StateMachine<S, E, C> newStateMachine(S init) {
|
return newStateMachine(init, new ReentrantLock());
|
thehiflyer/Fettle
|
src/main/java/se/fearless/fettle/impl/ImmutableTransitionModel.java
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachine.java
// public interface StateMachine<S, E, C> {
// /**
// * Gets the current state of the machine
// *
// * @return the state the machine is currently in
// */
// S getCurrentState();
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event);
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @param context the context to be sent to any actions that are run on a state change. Used to supply parameters to
// * actions and conditions
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event, C context);
//
// /**
// * Sets the state of the state machine to the rawState even if there are no transitions leading to it
// * No transition, entry or exit actions are run
// *
// * @param rawState the state the machine will be in after this method is called
// */
// void rawSetState(S rawState);
//
// /**
// * Forces the state machine to enter the forcedState even if there are no transitions leading to it
// * No transition actions are run but exit actions on the current state and entry actions on the new state are run
// *
// * @param forcedState the state the machine will be in after this method is called
// * @return true if the state machine changed state
// */
// boolean forceSetState(S forcedState);
//
// /**
// * Returns all possible transitions from a given state grouped by the event that triggers the transition.
// * @param fromState the state to retrieve the outgoing transitions from.
// * @return a map from all registered events in the fromState to the transitions they would trigger if fired.
// */
// Map<E, Collection<? extends Transition<S, E, C>>> getPossibleTransitions(S fromState);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachineTemplate.java
// public interface StateMachineTemplate<S, E, C> {
// /**
// * Creates a new state machine using the transition model as a template
// * @param init the state the machine will be in when created
// * @return a new state machine with the transitions and actions defined in this model
// */
// StateMachine<S, E, C> newStateMachine(S init);
//
// StateMachine<S, E, C> newStateMachine(S init, Lock lock);
// }
//
// Path: src/main/java/se/fearless/fettle/Transition.java
// public interface Transition<S, E, C> {
// S getTo();
//
// boolean isSatisfied(C context);
//
// void onTransition(S from, S to, E event, C context, StateMachine<S, E, C> statemachine);
//
// boolean shouldExecuteEntryAndExitActions();
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/Lock.java
// public interface Lock {
// void lock();
// void unlock();
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/ReentrantLock.java
// public class ReentrantLock implements Lock {
//
// @Override
// public void lock() {
// }
//
// @Override
// public void unlock() {
// }
// }
|
import se.fearless.fettle.Action;
import se.fearless.fettle.StateMachine;
import se.fearless.fettle.StateMachineTemplate;
import se.fearless.fettle.Transition;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
|
for (Map.Entry<E, Collection<Transition<S, E, C>>> entry : input.entrySet()) {
E key = entry.getKey();
Collection<Transition<S, E, C>> value = entry.getValue();
res.put(key, copy(value));
}
return res;
}
private Map<S, Collection<Action<S, E, C>>> copy(Map<S, Collection<Action<S, E, C>>> input) {
Map<S, Collection<Action<S, E, C>>> res = GuavaReplacement.newHashMap();
for (Map.Entry<S, Collection<Action<S, E, C>>> entry : input.entrySet()) {
S key = entry.getKey();
Collection<Action<S, E, C>> value = entry.getValue();
res.put(key, copy(value));
}
return res;
}
private <T> Collection<T> copy(Collection<T> input) {
Collection<T> res = GuavaReplacement.newArrayList();
res.addAll(input);
return res;
}
@Override
public StateMachine<S, E, C> newStateMachine(S init) {
return newStateMachine(init, new ReentrantLock());
}
@Override
|
// Path: src/main/java/se/fearless/fettle/Action.java
// public interface Action<S, E, C> {
// /**
// * Called when a transition occurs
// * @param from the state the machine was in before the transition
// * @param to the state the machine is in after the transition
// * @param causedBy the event that triggered the transition
// * @param context the context in which the event was fired supplied to the transition
// * @param stateMachine the machine for which the transition occurred
// */
// void onTransition(S from, S to, E causedBy, C context, StateMachine<S, E, C> stateMachine);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachine.java
// public interface StateMachine<S, E, C> {
// /**
// * Gets the current state of the machine
// *
// * @return the state the machine is currently in
// */
// S getCurrentState();
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event);
//
// /**
// * Fires an event at the state machine, possibly triggering a state change
// *
// * @param event the event that is fired
// * @param context the context to be sent to any actions that are run on a state change. Used to supply parameters to
// * actions and conditions
// * @return true if the event resulted in a state change, false otherwise
// */
// boolean fireEvent(E event, C context);
//
// /**
// * Sets the state of the state machine to the rawState even if there are no transitions leading to it
// * No transition, entry or exit actions are run
// *
// * @param rawState the state the machine will be in after this method is called
// */
// void rawSetState(S rawState);
//
// /**
// * Forces the state machine to enter the forcedState even if there are no transitions leading to it
// * No transition actions are run but exit actions on the current state and entry actions on the new state are run
// *
// * @param forcedState the state the machine will be in after this method is called
// * @return true if the state machine changed state
// */
// boolean forceSetState(S forcedState);
//
// /**
// * Returns all possible transitions from a given state grouped by the event that triggers the transition.
// * @param fromState the state to retrieve the outgoing transitions from.
// * @return a map from all registered events in the fromState to the transitions they would trigger if fired.
// */
// Map<E, Collection<? extends Transition<S, E, C>>> getPossibleTransitions(S fromState);
// }
//
// Path: src/main/java/se/fearless/fettle/StateMachineTemplate.java
// public interface StateMachineTemplate<S, E, C> {
// /**
// * Creates a new state machine using the transition model as a template
// * @param init the state the machine will be in when created
// * @return a new state machine with the transitions and actions defined in this model
// */
// StateMachine<S, E, C> newStateMachine(S init);
//
// StateMachine<S, E, C> newStateMachine(S init, Lock lock);
// }
//
// Path: src/main/java/se/fearless/fettle/Transition.java
// public interface Transition<S, E, C> {
// S getTo();
//
// boolean isSatisfied(C context);
//
// void onTransition(S from, S to, E event, C context, StateMachine<S, E, C> statemachine);
//
// boolean shouldExecuteEntryAndExitActions();
// }
//
// Path: src/main/java/se/fearless/fettle/util/GuavaReplacement.java
// public class GuavaReplacement {
// private GuavaReplacement() {
// }
//
// public static <T> List<T> newArrayList() {
// return new ArrayList<>();
// }
//
// public static <K, V> Map<K, V> newHashMap() {
// return new HashMap<>();
// }
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/Lock.java
// public interface Lock {
// void lock();
// void unlock();
// }
//
// Path: src/main/resources/super/java/util/concurrent/locks/ReentrantLock.java
// public class ReentrantLock implements Lock {
//
// @Override
// public void lock() {
// }
//
// @Override
// public void unlock() {
// }
// }
// Path: src/main/java/se/fearless/fettle/impl/ImmutableTransitionModel.java
import se.fearless.fettle.Action;
import se.fearless.fettle.StateMachine;
import se.fearless.fettle.StateMachineTemplate;
import se.fearless.fettle.Transition;
import se.fearless.fettle.util.GuavaReplacement;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
for (Map.Entry<E, Collection<Transition<S, E, C>>> entry : input.entrySet()) {
E key = entry.getKey();
Collection<Transition<S, E, C>> value = entry.getValue();
res.put(key, copy(value));
}
return res;
}
private Map<S, Collection<Action<S, E, C>>> copy(Map<S, Collection<Action<S, E, C>>> input) {
Map<S, Collection<Action<S, E, C>>> res = GuavaReplacement.newHashMap();
for (Map.Entry<S, Collection<Action<S, E, C>>> entry : input.entrySet()) {
S key = entry.getKey();
Collection<Action<S, E, C>> value = entry.getValue();
res.put(key, copy(value));
}
return res;
}
private <T> Collection<T> copy(Collection<T> input) {
Collection<T> res = GuavaReplacement.newArrayList();
res.addAll(input);
return res;
}
@Override
public StateMachine<S, E, C> newStateMachine(S init) {
return newStateMachine(init, new ReentrantLock());
}
@Override
|
public StateMachine<S, E, C> newStateMachine(S init, Lock lock) {
|
thehiflyer/Fettle
|
src/test/java/se/fearless/fettle/TestFireEvent.java
|
// Path: src/main/java/se/fearless/fettle/impl/MutableTransitionModelImpl.java
// public class MutableTransitionModelImpl<S, E, C> extends AbstractTransitionModel<S, E, C> implements MutableTransitionModel<S, E, C> {
//
// private MutableTransitionModelImpl(Class<S> stateClass, Class<E> eventClass, C defaultContext) {
// super(stateClass, eventClass, defaultContext);
// }
//
// public static <S, E, C> MutableTransitionModelImpl<S, E, C> create(Class<S> stateClass, Class<E> eventClass, C defaultContext) {
// return new MutableTransitionModelImpl<>(stateClass, eventClass, defaultContext);
// }
//
// public static <S, E, C> MutableTransitionModelImpl<S, E, C> create(Class<S> stateClass, Class<E> eventClass) {
// return new MutableTransitionModelImpl<>(stateClass, eventClass, null);
// }
//
// @Override
// public StateMachine<S, E, C> newStateMachine(S init) {
// return newStateMachine(init, new ReentrantLock());
// }
//
//
// @Override
// public StateMachine<S, E, C> newStateMachine(S init, Lock lock) {
// return new TemplateBasedStateMachine<>(this, init, lock);
// }
//
//
// @Override
// public StateMachineTemplate<S, E, C> createImmutableClone() {
// return new ImmutableTransitionModel<>(stateClass, eventClass, transitionMap, fromAllTransitions, exitActions, enterActions, defaultContext);
// }
//
// @Override
// public void addTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions) {
// addTransition(from, event, new BasicTransition<>(to, condition, actions));
// }
//
// @Override
// public void addInternalTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions) {
// addTransition(from, event, new InternalTransition<>(to, condition, actions));
// }
//
// private void addTransition(S from, E event, Transition<S, E, C> transition) {
// Map<E, Collection<Transition<S, E, C>>> map = transitionMap.computeIfAbsent(from, k -> createMap(eventClass));
// Collection<Transition<S, E, C>> transitions = map.computeIfAbsent(event, k -> GuavaReplacement.newArrayList());
// transitions.add(transition);
// }
//
// @Override
// public void addFromAllTransition(S to, E event, Condition<C> condition, List<Action<S, E, C>> actions) {
// Collection<Transition<S, E, C>> transitions = fromAllTransitions.computeIfAbsent(event, k -> GuavaReplacement.newArrayList());
// transitions.add(new BasicTransition<>(to, condition, actions));
// }
//
// @Override
// public void addEntryAction(S entryState, Action<S, E, C> action) {
// addAction(entryState, action, enterActions);
// }
//
// private void addAction(S entryState, Action<S, E, C> action, Map<S, Collection<Action<S, E, C>>> map) {
// Collection<Action<S, E, C>> collection = map.computeIfAbsent(entryState, k -> GuavaReplacement.newArrayList());
// collection.add(action);
// }
//
// @Override
// public void addExitAction(S exitState, Action<S, E, C> action) {
// addAction(exitState, action, exitActions);
// }
// }
|
import org.junit.Test;
import se.fearless.fettle.impl.MutableTransitionModelImpl;
import java.util.Collections;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
|
package se.fearless.fettle;
public class TestFireEvent {
enum Triggers {
FOO, BAR, BAZ
}
@Test
public void fireEvent() {
|
// Path: src/main/java/se/fearless/fettle/impl/MutableTransitionModelImpl.java
// public class MutableTransitionModelImpl<S, E, C> extends AbstractTransitionModel<S, E, C> implements MutableTransitionModel<S, E, C> {
//
// private MutableTransitionModelImpl(Class<S> stateClass, Class<E> eventClass, C defaultContext) {
// super(stateClass, eventClass, defaultContext);
// }
//
// public static <S, E, C> MutableTransitionModelImpl<S, E, C> create(Class<S> stateClass, Class<E> eventClass, C defaultContext) {
// return new MutableTransitionModelImpl<>(stateClass, eventClass, defaultContext);
// }
//
// public static <S, E, C> MutableTransitionModelImpl<S, E, C> create(Class<S> stateClass, Class<E> eventClass) {
// return new MutableTransitionModelImpl<>(stateClass, eventClass, null);
// }
//
// @Override
// public StateMachine<S, E, C> newStateMachine(S init) {
// return newStateMachine(init, new ReentrantLock());
// }
//
//
// @Override
// public StateMachine<S, E, C> newStateMachine(S init, Lock lock) {
// return new TemplateBasedStateMachine<>(this, init, lock);
// }
//
//
// @Override
// public StateMachineTemplate<S, E, C> createImmutableClone() {
// return new ImmutableTransitionModel<>(stateClass, eventClass, transitionMap, fromAllTransitions, exitActions, enterActions, defaultContext);
// }
//
// @Override
// public void addTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions) {
// addTransition(from, event, new BasicTransition<>(to, condition, actions));
// }
//
// @Override
// public void addInternalTransition(S from, S to, E event, Condition<C> condition, List<Action<S, E, C>> actions) {
// addTransition(from, event, new InternalTransition<>(to, condition, actions));
// }
//
// private void addTransition(S from, E event, Transition<S, E, C> transition) {
// Map<E, Collection<Transition<S, E, C>>> map = transitionMap.computeIfAbsent(from, k -> createMap(eventClass));
// Collection<Transition<S, E, C>> transitions = map.computeIfAbsent(event, k -> GuavaReplacement.newArrayList());
// transitions.add(transition);
// }
//
// @Override
// public void addFromAllTransition(S to, E event, Condition<C> condition, List<Action<S, E, C>> actions) {
// Collection<Transition<S, E, C>> transitions = fromAllTransitions.computeIfAbsent(event, k -> GuavaReplacement.newArrayList());
// transitions.add(new BasicTransition<>(to, condition, actions));
// }
//
// @Override
// public void addEntryAction(S entryState, Action<S, E, C> action) {
// addAction(entryState, action, enterActions);
// }
//
// private void addAction(S entryState, Action<S, E, C> action, Map<S, Collection<Action<S, E, C>>> map) {
// Collection<Action<S, E, C>> collection = map.computeIfAbsent(entryState, k -> GuavaReplacement.newArrayList());
// collection.add(action);
// }
//
// @Override
// public void addExitAction(S exitState, Action<S, E, C> action) {
// addAction(exitState, action, exitActions);
// }
// }
// Path: src/test/java/se/fearless/fettle/TestFireEvent.java
import org.junit.Test;
import se.fearless.fettle.impl.MutableTransitionModelImpl;
import java.util.Collections;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
package se.fearless.fettle;
public class TestFireEvent {
enum Triggers {
FOO, BAR, BAZ
}
@Test
public void fireEvent() {
|
MutableTransitionModelImpl<States, Triggers, Void> model = MutableTransitionModelImpl.create(States.class, Triggers.class);
|
nchambers/probschemas
|
src/main/java/nate/probschemas/EntityFiller.java
|
// Path: src/main/java/nate/EntityMention.java
// public class EntityMention {
// int entityID, sentenceID, start, end;
// String string = "";
// boolean wordBased = false;
// NERSpan.TYPE namedEntity = NERSpan.TYPE.NONE;
//
//
// public EntityMention(int sid, String text, Span span, int eid) {
// this(sid,text,span.getStart(),span.getEnd(),eid);
// wordBased = false;
// }
//
// public EntityMention(int sid, String text, int start, int end, int eid) {
// entityID = eid;
// sentenceID = sid;
// this.start = start;
// this.end = end;
// string = text;
// wordBased = true;
// }
//
// /**
// * @return The highest ID of all given mentions in the list.
// */
// public static int maxID(Collection<EntityMention> mentions) {
// int max = -1;
// for( EntityMention mention : mentions ) {
// if( mention.entityID() > max )
// max = mention.entityID();
// }
// return max;
// }
//
// /**
// * @param sent Plain text of a sentence
// * @desc Converts the character span of this mention into a word
// * indexed span, based on the given sentence.
// */
// public void convertCharSpanToIndex(String sent) {
// // System.out.println(sent);
// if( !wordBased ) {
// int s,e,wordCount = 1;
//
// for( int i = 0; i < start; i++ )
// if( sent.charAt(i) == ' ' ) wordCount++;
// s = wordCount;
//
// for( int i = start; i < end; i++ )
// if( sent.charAt(i) == ' ' ) wordCount++;
// e = wordCount;
//
// start = s;
// end = e;
// wordBased = true;
// }
// }
//
// public void setSpan(int s, int e) {
// start = s;
// end = e;
// }
//
// public void setSpan(Span span) {
// start = span.getStart();
// end = span.getEnd();
// }
//
// public void setEntityID(int id) {
// entityID = id;
// }
//
// public void setNamedEntity(NERSpan.TYPE val) {
// namedEntity = val;
// }
//
//
// public boolean isWordSpan() { return wordBased; }
// public int entityID() { return entityID; }
// public int sentenceID() { return sentenceID; }
// public int sid() { return sentenceID; }
// public int start() { return start; }
// public int end() { return end; }
// public String string() { return string; }
// public NERSpan.TYPE namedEntity() { return namedEntity; }
//
// // <ENT>32 8 17 18 the defense</ENT>
// public static EntityMention fromString(String str) {
// int space = str.indexOf(' ');
// int space2 = str.indexOf(' ',space+1);
// int space3 = str.indexOf(' ',space2+1);
// int space4 = str.indexOf(' ',space3+1);
//
// int sid = Integer.parseInt(str.substring(0,space));
// int eid = Integer.parseInt(str.substring(space+1,space2));
// int start = Integer.parseInt(str.substring(space2+1,space3));
//
// int end;
// String word;
// if( space4 > -1 ) {
// end = Integer.parseInt(str.substring(space3+1,space4));
// word = str.substring(space4+1,str.length());
// }
// else {
// end = Integer.parseInt(str.substring(space3+1,str.length()));
// word = "unknown";
// }
//
// return new EntityMention(sid,word,start,end,eid);
// }
//
// public String toString() {
// // return entityID + " " + sentenceID + " " + string + " [" + start + ".." + end + "]";
// return sentenceID + " " + entityID + " " + start + " " + end + " " + string;
// }
// }
|
import java.util.Set;
import nate.EntityMention;
|
package nate.probschemas;
public class EntityFiller {
private int _entityID;
private String _string;
private double _scoredInRole;
|
// Path: src/main/java/nate/EntityMention.java
// public class EntityMention {
// int entityID, sentenceID, start, end;
// String string = "";
// boolean wordBased = false;
// NERSpan.TYPE namedEntity = NERSpan.TYPE.NONE;
//
//
// public EntityMention(int sid, String text, Span span, int eid) {
// this(sid,text,span.getStart(),span.getEnd(),eid);
// wordBased = false;
// }
//
// public EntityMention(int sid, String text, int start, int end, int eid) {
// entityID = eid;
// sentenceID = sid;
// this.start = start;
// this.end = end;
// string = text;
// wordBased = true;
// }
//
// /**
// * @return The highest ID of all given mentions in the list.
// */
// public static int maxID(Collection<EntityMention> mentions) {
// int max = -1;
// for( EntityMention mention : mentions ) {
// if( mention.entityID() > max )
// max = mention.entityID();
// }
// return max;
// }
//
// /**
// * @param sent Plain text of a sentence
// * @desc Converts the character span of this mention into a word
// * indexed span, based on the given sentence.
// */
// public void convertCharSpanToIndex(String sent) {
// // System.out.println(sent);
// if( !wordBased ) {
// int s,e,wordCount = 1;
//
// for( int i = 0; i < start; i++ )
// if( sent.charAt(i) == ' ' ) wordCount++;
// s = wordCount;
//
// for( int i = start; i < end; i++ )
// if( sent.charAt(i) == ' ' ) wordCount++;
// e = wordCount;
//
// start = s;
// end = e;
// wordBased = true;
// }
// }
//
// public void setSpan(int s, int e) {
// start = s;
// end = e;
// }
//
// public void setSpan(Span span) {
// start = span.getStart();
// end = span.getEnd();
// }
//
// public void setEntityID(int id) {
// entityID = id;
// }
//
// public void setNamedEntity(NERSpan.TYPE val) {
// namedEntity = val;
// }
//
//
// public boolean isWordSpan() { return wordBased; }
// public int entityID() { return entityID; }
// public int sentenceID() { return sentenceID; }
// public int sid() { return sentenceID; }
// public int start() { return start; }
// public int end() { return end; }
// public String string() { return string; }
// public NERSpan.TYPE namedEntity() { return namedEntity; }
//
// // <ENT>32 8 17 18 the defense</ENT>
// public static EntityMention fromString(String str) {
// int space = str.indexOf(' ');
// int space2 = str.indexOf(' ',space+1);
// int space3 = str.indexOf(' ',space2+1);
// int space4 = str.indexOf(' ',space3+1);
//
// int sid = Integer.parseInt(str.substring(0,space));
// int eid = Integer.parseInt(str.substring(space+1,space2));
// int start = Integer.parseInt(str.substring(space2+1,space3));
//
// int end;
// String word;
// if( space4 > -1 ) {
// end = Integer.parseInt(str.substring(space3+1,space4));
// word = str.substring(space4+1,str.length());
// }
// else {
// end = Integer.parseInt(str.substring(space3+1,str.length()));
// word = "unknown";
// }
//
// return new EntityMention(sid,word,start,end,eid);
// }
//
// public String toString() {
// // return entityID + " " + sentenceID + " " + string + " [" + start + ".." + end + "]";
// return sentenceID + " " + entityID + " " + start + " " + end + " " + string;
// }
// }
// Path: src/main/java/nate/probschemas/EntityFiller.java
import java.util.Set;
import nate.EntityMention;
package nate.probschemas;
public class EntityFiller {
private int _entityID;
private String _string;
private double _scoredInRole;
|
public EntityMention _mainMention;
|
nchambers/probschemas
|
src/main/java/nate/probschemas/Frame.java
|
// Path: src/main/java/nate/util/SortableObject.java
// public class SortableObject<E> implements Comparable<SortableObject<E>> {
// double score = 0.0f;
// E key;
//
// public SortableObject(double s, E k) {
// score = s;
// key = k;
// }
// public SortableObject() { }
//
// public int compareTo(SortableObject<E> b) {
// if( b == null ) return -1;
// if( score < b.score() ) return 1;
// else if( b.score() < score ) return -1;
// else return 0;
// }
//
// public void setScore(double s) { score = s; }
// public void setKey(E k) { key = k; }
//
// public double score() { return score; }
// public E key() { return key; }
// public String toString() {
// return key + " " + score;
// }
// }
//
// Path: src/main/java/nate/util/SortableScore.java
// public class SortableScore implements Comparable<SortableScore> {
// double score = 0.0f;
// String key;
//
// public SortableScore(double s, String k) {
// score = s;
// key = k;
// }
// public SortableScore() { }
//
// public int compareTo(SortableScore b) {
// if( b == null ) return -1;
// if( score < ((SortableScore)b).score() ) return 1;
// else if( ((SortableScore)b).score() > score ) return -1;
// else return 0;
// }
//
// public void setScore(double s) { score = s; }
// public void setKey(String k) { key = k; }
//
// public double score() { return score; }
// public String key() { return key; }
// public String toString() {
// return key + " " + score;
// }
// }
|
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import nate.util.SortableObject;
import nate.util.SortableScore;
|
if( clone.getRoles() != null )
for( FrameRole role : clone.getRoles() ) addRole(role);
// _tokens = null;
// _arguments = clone.arguments();
}
public void clear() {
if( _tokenScores != null ) _tokenScores.clear();
// if( _tokens != null ) _tokens.clear();
if( _orderedByScore != null ) _orderedByScore.clear();
}
public void addToken(String token, double scoreWithFrame) {
if( _tokenScores == null ) _tokenScores = new HashMap<String, Double>();
_tokenScores.put(token, scoreWithFrame);
setTheTokenOrder();
}
public void setCentralTokens(List<String> tokens) {
_centralTokens = tokens;
}
public List<String> getCentralTokens() {
return _centralTokens;
}
public void setClusterScore(double score) {
_clusterScore = score;
}
|
// Path: src/main/java/nate/util/SortableObject.java
// public class SortableObject<E> implements Comparable<SortableObject<E>> {
// double score = 0.0f;
// E key;
//
// public SortableObject(double s, E k) {
// score = s;
// key = k;
// }
// public SortableObject() { }
//
// public int compareTo(SortableObject<E> b) {
// if( b == null ) return -1;
// if( score < b.score() ) return 1;
// else if( b.score() < score ) return -1;
// else return 0;
// }
//
// public void setScore(double s) { score = s; }
// public void setKey(E k) { key = k; }
//
// public double score() { return score; }
// public E key() { return key; }
// public String toString() {
// return key + " " + score;
// }
// }
//
// Path: src/main/java/nate/util/SortableScore.java
// public class SortableScore implements Comparable<SortableScore> {
// double score = 0.0f;
// String key;
//
// public SortableScore(double s, String k) {
// score = s;
// key = k;
// }
// public SortableScore() { }
//
// public int compareTo(SortableScore b) {
// if( b == null ) return -1;
// if( score < ((SortableScore)b).score() ) return 1;
// else if( ((SortableScore)b).score() > score ) return -1;
// else return 0;
// }
//
// public void setScore(double s) { score = s; }
// public void setKey(String k) { key = k; }
//
// public double score() { return score; }
// public String key() { return key; }
// public String toString() {
// return key + " " + score;
// }
// }
// Path: src/main/java/nate/probschemas/Frame.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import nate.util.SortableObject;
import nate.util.SortableScore;
if( clone.getRoles() != null )
for( FrameRole role : clone.getRoles() ) addRole(role);
// _tokens = null;
// _arguments = clone.arguments();
}
public void clear() {
if( _tokenScores != null ) _tokenScores.clear();
// if( _tokens != null ) _tokens.clear();
if( _orderedByScore != null ) _orderedByScore.clear();
}
public void addToken(String token, double scoreWithFrame) {
if( _tokenScores == null ) _tokenScores = new HashMap<String, Double>();
_tokenScores.put(token, scoreWithFrame);
setTheTokenOrder();
}
public void setCentralTokens(List<String> tokens) {
_centralTokens = tokens;
}
public List<String> getCentralTokens() {
return _centralTokens;
}
public void setClusterScore(double score) {
_clusterScore = score;
}
|
public void setTokenScores(Collection<SortableObject<String>> scores) {
|
nchambers/probschemas
|
src/main/java/nate/probschemas/Frame.java
|
// Path: src/main/java/nate/util/SortableObject.java
// public class SortableObject<E> implements Comparable<SortableObject<E>> {
// double score = 0.0f;
// E key;
//
// public SortableObject(double s, E k) {
// score = s;
// key = k;
// }
// public SortableObject() { }
//
// public int compareTo(SortableObject<E> b) {
// if( b == null ) return -1;
// if( score < b.score() ) return 1;
// else if( b.score() < score ) return -1;
// else return 0;
// }
//
// public void setScore(double s) { score = s; }
// public void setKey(E k) { key = k; }
//
// public double score() { return score; }
// public E key() { return key; }
// public String toString() {
// return key + " " + score;
// }
// }
//
// Path: src/main/java/nate/util/SortableScore.java
// public class SortableScore implements Comparable<SortableScore> {
// double score = 0.0f;
// String key;
//
// public SortableScore(double s, String k) {
// score = s;
// key = k;
// }
// public SortableScore() { }
//
// public int compareTo(SortableScore b) {
// if( b == null ) return -1;
// if( score < ((SortableScore)b).score() ) return 1;
// else if( ((SortableScore)b).score() > score ) return -1;
// else return 0;
// }
//
// public void setScore(double s) { score = s; }
// public void setKey(String k) { key = k; }
//
// public double score() { return score; }
// public String key() { return key; }
// public String toString() {
// return key + " " + score;
// }
// }
|
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import nate.util.SortableObject;
import nate.util.SortableScore;
|
public void setTokenScores(Map<String,Double> scores) {
if( _tokenScores == null ) _tokenScores = new HashMap<String, Double>();
clear();
for( Map.Entry<String, Double> entry : scores.entrySet() ) {
String token = (String)entry.getKey();
double score = entry.getValue();
_tokenScores.put(token, score);
}
setTheTokenOrder();
}
public void setTokens(Collection<String> strs) {
if( _tokenScores == null ) _tokenScores = new HashMap<String,Double>();
clear();
for( String str : strs )
_tokenScores.put(str, 0.0);
setTheTokenOrder();
}
/**
* Uses the global token scores and sorts the key by their scores. Saves
* the order in the token list _orderedByScore.
*/
private void setTheTokenOrder() {
if( _orderedByScore == null )
_orderedByScore = new ArrayList<String>();
else
_orderedByScore.clear();
|
// Path: src/main/java/nate/util/SortableObject.java
// public class SortableObject<E> implements Comparable<SortableObject<E>> {
// double score = 0.0f;
// E key;
//
// public SortableObject(double s, E k) {
// score = s;
// key = k;
// }
// public SortableObject() { }
//
// public int compareTo(SortableObject<E> b) {
// if( b == null ) return -1;
// if( score < b.score() ) return 1;
// else if( b.score() < score ) return -1;
// else return 0;
// }
//
// public void setScore(double s) { score = s; }
// public void setKey(E k) { key = k; }
//
// public double score() { return score; }
// public E key() { return key; }
// public String toString() {
// return key + " " + score;
// }
// }
//
// Path: src/main/java/nate/util/SortableScore.java
// public class SortableScore implements Comparable<SortableScore> {
// double score = 0.0f;
// String key;
//
// public SortableScore(double s, String k) {
// score = s;
// key = k;
// }
// public SortableScore() { }
//
// public int compareTo(SortableScore b) {
// if( b == null ) return -1;
// if( score < ((SortableScore)b).score() ) return 1;
// else if( ((SortableScore)b).score() > score ) return -1;
// else return 0;
// }
//
// public void setScore(double s) { score = s; }
// public void setKey(String k) { key = k; }
//
// public double score() { return score; }
// public String key() { return key; }
// public String toString() {
// return key + " " + score;
// }
// }
// Path: src/main/java/nate/probschemas/Frame.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import nate.util.SortableObject;
import nate.util.SortableScore;
public void setTokenScores(Map<String,Double> scores) {
if( _tokenScores == null ) _tokenScores = new HashMap<String, Double>();
clear();
for( Map.Entry<String, Double> entry : scores.entrySet() ) {
String token = (String)entry.getKey();
double score = entry.getValue();
_tokenScores.put(token, score);
}
setTheTokenOrder();
}
public void setTokens(Collection<String> strs) {
if( _tokenScores == null ) _tokenScores = new HashMap<String,Double>();
clear();
for( String str : strs )
_tokenScores.put(str, 0.0);
setTheTokenOrder();
}
/**
* Uses the global token scores and sorts the key by their scores. Saves
* the order in the token list _orderedByScore.
*/
private void setTheTokenOrder() {
if( _orderedByScore == null )
_orderedByScore = new ArrayList<String>();
else
_orderedByScore.clear();
|
SortableScore[] sorted = new SortableScore[_tokenScores.size()];
|
waldheinz/fat32-lib
|
src/main/java/de/waldheinz/fs/fat/FsInfoSector.java
|
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
|
import de.waldheinz.fs.BlockDevice;
import java.io.IOException;
|
/*
* Copyright (C) 2009-2013 Matthias Treydte <mt@waldheinz.de>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package de.waldheinz.fs.fat;
/**
* The FAT32 File System Information Sector.
*
* @author Matthias Treydte <waldheinz at gmail.com>
* @see http://en.wikipedia.org/wiki/File_Allocation_Table#FS_Information_Sector
*/
final class FsInfoSector extends Sector {
/**
* The offset to the free cluster count value in the FS info sector.
*/
public static final int FREE_CLUSTERS_OFFSET = 0x1e8;
/**
* The offset to the "last allocated cluster" value in this sector.
*/
public static final int LAST_ALLOCATED_OFFSET = 0x1ec;
/**
* The offset to the signature of this sector.
*/
public static final int SIGNATURE_OFFSET = 0x1fe;
|
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
// Path: src/main/java/de/waldheinz/fs/fat/FsInfoSector.java
import de.waldheinz.fs.BlockDevice;
import java.io.IOException;
/*
* Copyright (C) 2009-2013 Matthias Treydte <mt@waldheinz.de>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package de.waldheinz.fs.fat;
/**
* The FAT32 File System Information Sector.
*
* @author Matthias Treydte <waldheinz at gmail.com>
* @see http://en.wikipedia.org/wiki/File_Allocation_Table#FS_Information_Sector
*/
final class FsInfoSector extends Sector {
/**
* The offset to the free cluster count value in the FS info sector.
*/
public static final int FREE_CLUSTERS_OFFSET = 0x1e8;
/**
* The offset to the "last allocated cluster" value in this sector.
*/
public static final int LAST_ALLOCATED_OFFSET = 0x1ec;
/**
* The offset to the signature of this sector.
*/
public static final int SIGNATURE_OFFSET = 0x1fe;
|
private FsInfoSector(BlockDevice device, long offset) {
|
waldheinz/fat32-lib
|
src/main/java/de/waldheinz/fs/fat/Fat.java
|
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
|
import java.util.Arrays;
import de.waldheinz.fs.BlockDevice;
import java.io.IOException;
import java.nio.ByteBuffer;
|
/*
* Copyright (C) 2003-2009 JNode.org
* 2009-2013 Matthias Treydte <mt@waldheinz.de>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package de.waldheinz.fs.fat;
/**
*
*
* @author Ewout Prangsma <epr at jnode.org>
* @author Matthias Treydte <waldheinz at gmail.com>
*/
final class Fat {
/**
* The first cluster that really holds user data in a FAT.
*/
public final static int FIRST_CLUSTER = 2;
private final long[] entries;
private final FatType fatType;
private final int sectorCount;
private final int sectorSize;
|
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
// Path: src/main/java/de/waldheinz/fs/fat/Fat.java
import java.util.Arrays;
import de.waldheinz.fs.BlockDevice;
import java.io.IOException;
import java.nio.ByteBuffer;
/*
* Copyright (C) 2003-2009 JNode.org
* 2009-2013 Matthias Treydte <mt@waldheinz.de>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package de.waldheinz.fs.fat;
/**
*
*
* @author Ewout Prangsma <epr at jnode.org>
* @author Matthias Treydte <waldheinz at gmail.com>
*/
final class Fat {
/**
* The first cluster that really holds user data in a FAT.
*/
public final static int FIRST_CLUSTER = 2;
private final long[] entries;
private final FatType fatType;
private final int sectorCount;
private final int sectorSize;
|
private final BlockDevice device;
|
waldheinz/fat32-lib
|
src/test/java/de/waldheinz/fs/fat/FileSystemSizeTest.java
|
// Path: src/main/java/de/waldheinz/fs/util/RamDisk.java
// public final class RamDisk implements BlockDevice {
//
// /**
// * The default sector size for {@code RamDisk}s.
// */
// public final static int DEFAULT_SECTOR_SIZE = 512;
//
// private final int sectorSize;
// private final ByteBuffer data;
// private final int size;
// private boolean closed;
//
// /**
// * Reads a GZIP compressed disk image from the specified input stream and
// * returns a {@code RamDisk} holding the decompressed image.
// *
// * @param in the stream to read the disk image from
// * @return the decompressed {@code RamDisk}
// * @throws IOException on read or decompression error
// */
// public static RamDisk readGzipped(InputStream in) throws IOException {
// final GZIPInputStream zis = new GZIPInputStream(in);
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
//
// final byte[] buffer = new byte[4096];
//
// int read = zis.read(buffer);
// int total = 0;
//
// while (read >= 0) {
// total += read;
// bos.write(buffer, 0, read);
// read = zis.read(buffer);
// }
//
// if (total < DEFAULT_SECTOR_SIZE) throw new IOException(
// "read only " + total + " bytes"); //NOI18N
//
// final ByteBuffer bb = ByteBuffer.wrap(bos.toByteArray(), 0, total);
// return new RamDisk(bb, DEFAULT_SECTOR_SIZE);
// }
//
// /**
// * Reads a GZIP compressed file into a new {@code RamDisk} instance.
// *
// * @param f the file to read
// * @return the new RamDisk with the file contents
// * @throws FileNotFoundException if the specified file does not exist
// * @throws IOException on read error
// */
// public static RamDisk readGzipped(File f)
// throws FileNotFoundException, IOException {
//
// final FileInputStream is = new FileInputStream(f);
//
// try {
// return readGzipped(is);
// } finally {
// is.close();
// }
// }
//
// private RamDisk(ByteBuffer buffer, int sectorSize) {
// this.size = buffer.limit();
// this.sectorSize = sectorSize;
// this.data = buffer;
// this.closed = false;
// }
//
// /**
// * Creates a new instance of {@code RamDisk} of this specified
// * size and using the {@link #DEFAULT_SECTOR_SIZE}.
// *
// * @param size the size of the new block device
// */
// public RamDisk(int size) {
// this(size, DEFAULT_SECTOR_SIZE);
// }
//
// /**
// * Creates a new instance of {@code RamDisk} of this specified
// * size and sector size
// *
// * @param size the size of the new block device
// * @param sectorSize the sector size of the new block device
// */
// public RamDisk(int size, int sectorSize) {
// if (sectorSize < 1) throw new IllegalArgumentException(
// "invalid sector size"); //NOI18N
//
// this.sectorSize = sectorSize;
// this.size = size;
// this.data = ByteBuffer.allocate(size);
// }
//
// @Override
// public long getSize() {
// checkClosed();
// return this.size;
// }
//
// @Override
// public void read(long devOffset, ByteBuffer dest) throws IOException {
// checkClosed();
// if (devOffset > getSize()) throw new IllegalArgumentException();
//
// data.limit((int) (devOffset + dest.remaining()));
// data.position((int) devOffset);
//
// dest.put(data);
// }
//
// @Override
// public void write(long devOffset, ByteBuffer src) throws IOException {
// checkClosed();
//
// if (devOffset + src.remaining() > getSize()) throw new
// IllegalArgumentException(
// "offset=" + devOffset +
// ", length=" + src.remaining() +
// ", size=" + getSize());
//
// data.limit((int) (devOffset + src.remaining()));
// data.position((int) devOffset);
//
//
// data.put(src);
// }
//
// /**
// * Returns a slice of the {@code ByteBuffer} that is used by this
// * {@code RamDisk} as it's backing store. The returned buffer will be
// * live (reflecting any changes made through the
// * {@link #write(long, java.nio.ByteBuffer) method}, but read-only.
// *
// * @return a buffer holding the contents of this {@code RamDisk}
// */
// public ByteBuffer getBuffer() {
// return this.data.asReadOnlyBuffer();
// }
//
// @Override
// public void flush() throws IOException {
// checkClosed();
// }
//
// @Override
// public int getSectorSize() {
// checkClosed();
// return this.sectorSize;
// }
//
// @Override
// public void close() throws IOException {
// this.closed = true;
// }
//
// @Override
// public boolean isClosed() {
// return this.closed;
// }
//
// private void checkClosed() {
// if (closed) throw new IllegalStateException("device already closed");
// }
//
// /**
// * Returns always {@code false}, as a {@code RamDisk} is always writable.
// *
// * @return always {@code false}
// */
// @Override
// public boolean isReadOnly() {
// checkClosed();
//
// return false;
// }
//
// }
|
import org.junit.Assert;
import org.junit.Test;
import java.io.InputStream;
import de.waldheinz.fs.util.RamDisk;
|
package de.waldheinz.fs.fat;
/**
* @author Jan Seeger <jan@alphadev.net>
*/
public class FileSystemSizeTest {
@Test
public void testFat32Size() throws Exception {
System.out.println("fat32Size");
final InputStream is = getClass().getResourceAsStream(
"fat32-test.img.gz");
|
// Path: src/main/java/de/waldheinz/fs/util/RamDisk.java
// public final class RamDisk implements BlockDevice {
//
// /**
// * The default sector size for {@code RamDisk}s.
// */
// public final static int DEFAULT_SECTOR_SIZE = 512;
//
// private final int sectorSize;
// private final ByteBuffer data;
// private final int size;
// private boolean closed;
//
// /**
// * Reads a GZIP compressed disk image from the specified input stream and
// * returns a {@code RamDisk} holding the decompressed image.
// *
// * @param in the stream to read the disk image from
// * @return the decompressed {@code RamDisk}
// * @throws IOException on read or decompression error
// */
// public static RamDisk readGzipped(InputStream in) throws IOException {
// final GZIPInputStream zis = new GZIPInputStream(in);
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
//
// final byte[] buffer = new byte[4096];
//
// int read = zis.read(buffer);
// int total = 0;
//
// while (read >= 0) {
// total += read;
// bos.write(buffer, 0, read);
// read = zis.read(buffer);
// }
//
// if (total < DEFAULT_SECTOR_SIZE) throw new IOException(
// "read only " + total + " bytes"); //NOI18N
//
// final ByteBuffer bb = ByteBuffer.wrap(bos.toByteArray(), 0, total);
// return new RamDisk(bb, DEFAULT_SECTOR_SIZE);
// }
//
// /**
// * Reads a GZIP compressed file into a new {@code RamDisk} instance.
// *
// * @param f the file to read
// * @return the new RamDisk with the file contents
// * @throws FileNotFoundException if the specified file does not exist
// * @throws IOException on read error
// */
// public static RamDisk readGzipped(File f)
// throws FileNotFoundException, IOException {
//
// final FileInputStream is = new FileInputStream(f);
//
// try {
// return readGzipped(is);
// } finally {
// is.close();
// }
// }
//
// private RamDisk(ByteBuffer buffer, int sectorSize) {
// this.size = buffer.limit();
// this.sectorSize = sectorSize;
// this.data = buffer;
// this.closed = false;
// }
//
// /**
// * Creates a new instance of {@code RamDisk} of this specified
// * size and using the {@link #DEFAULT_SECTOR_SIZE}.
// *
// * @param size the size of the new block device
// */
// public RamDisk(int size) {
// this(size, DEFAULT_SECTOR_SIZE);
// }
//
// /**
// * Creates a new instance of {@code RamDisk} of this specified
// * size and sector size
// *
// * @param size the size of the new block device
// * @param sectorSize the sector size of the new block device
// */
// public RamDisk(int size, int sectorSize) {
// if (sectorSize < 1) throw new IllegalArgumentException(
// "invalid sector size"); //NOI18N
//
// this.sectorSize = sectorSize;
// this.size = size;
// this.data = ByteBuffer.allocate(size);
// }
//
// @Override
// public long getSize() {
// checkClosed();
// return this.size;
// }
//
// @Override
// public void read(long devOffset, ByteBuffer dest) throws IOException {
// checkClosed();
// if (devOffset > getSize()) throw new IllegalArgumentException();
//
// data.limit((int) (devOffset + dest.remaining()));
// data.position((int) devOffset);
//
// dest.put(data);
// }
//
// @Override
// public void write(long devOffset, ByteBuffer src) throws IOException {
// checkClosed();
//
// if (devOffset + src.remaining() > getSize()) throw new
// IllegalArgumentException(
// "offset=" + devOffset +
// ", length=" + src.remaining() +
// ", size=" + getSize());
//
// data.limit((int) (devOffset + src.remaining()));
// data.position((int) devOffset);
//
//
// data.put(src);
// }
//
// /**
// * Returns a slice of the {@code ByteBuffer} that is used by this
// * {@code RamDisk} as it's backing store. The returned buffer will be
// * live (reflecting any changes made through the
// * {@link #write(long, java.nio.ByteBuffer) method}, but read-only.
// *
// * @return a buffer holding the contents of this {@code RamDisk}
// */
// public ByteBuffer getBuffer() {
// return this.data.asReadOnlyBuffer();
// }
//
// @Override
// public void flush() throws IOException {
// checkClosed();
// }
//
// @Override
// public int getSectorSize() {
// checkClosed();
// return this.sectorSize;
// }
//
// @Override
// public void close() throws IOException {
// this.closed = true;
// }
//
// @Override
// public boolean isClosed() {
// return this.closed;
// }
//
// private void checkClosed() {
// if (closed) throw new IllegalStateException("device already closed");
// }
//
// /**
// * Returns always {@code false}, as a {@code RamDisk} is always writable.
// *
// * @return always {@code false}
// */
// @Override
// public boolean isReadOnly() {
// checkClosed();
//
// return false;
// }
//
// }
// Path: src/test/java/de/waldheinz/fs/fat/FileSystemSizeTest.java
import org.junit.Assert;
import org.junit.Test;
import java.io.InputStream;
import de.waldheinz.fs.util.RamDisk;
package de.waldheinz.fs.fat;
/**
* @author Jan Seeger <jan@alphadev.net>
*/
public class FileSystemSizeTest {
@Test
public void testFat32Size() throws Exception {
System.out.println("fat32Size");
final InputStream is = getClass().getResourceAsStream(
"fat32-test.img.gz");
|
final RamDisk rd = RamDisk.readGzipped(is);
|
waldheinz/fat32-lib
|
src/main/java/de/waldheinz/fs/fat/SuperFloppyFormatter.java
|
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
|
import de.waldheinz.fs.BlockDevice;
import java.io.IOException;
import java.util.Random;
|
/*
* Copyright (C) 2009-2013 Matthias Treydte <mt@waldheinz.de>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package de.waldheinz.fs.fat;
/**
* Allows to create FAT file systems on {@link BlockDevice}s which follow the
* "super floppy" standard. This means that the device will be formatted so
* that it does not contain a partition table. Instead, the entire device holds
* a single FAT file system.
*
* This class follows the "builder" pattern, which means it's methods always
* returns the {@code SuperFloppyFormatter} instance they're called on. This
* allows to chain the method calls like this:
* <pre>
* BlockDevice dev = new RamDisk(16700000);
* FatFileSystem fs = SuperFloppyFormatter.get(dev).
* setFatType(FatType.FAT12).format();
* </pre>
*
* @author Matthias Treydte <matthias.treydte at meetwise.com>
*/
public final class SuperFloppyFormatter {
/**
* The media descriptor used (hard disk).
*/
public final static int MEDIUM_DESCRIPTOR_HD = 0xf8;
/**
* The default number of FATs.
*/
public final static int DEFAULT_FAT_COUNT = 2;
/**
* The default number of sectors per track.
*/
public final static int DEFAULT_SECTORS_PER_TRACK = 32;
/**
* The default number of heads.
*
* @since 0.6
*/
public final static int DEFAULT_HEADS = 64;
/**
* The default number of heads.
*
* @deprecated the name of this constant was mistyped
* @see #DEFAULT_HEADS
*/
@Deprecated
public final static int DEFULT_HEADS = DEFAULT_HEADS;
/**
* The default OEM name for file systems created by this class.
*/
public final static String DEFAULT_OEM_NAME = "fat32lib"; //NOI18N
private static final int MAX_DIRECTORY = 512;
|
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
// Path: src/main/java/de/waldheinz/fs/fat/SuperFloppyFormatter.java
import de.waldheinz.fs.BlockDevice;
import java.io.IOException;
import java.util.Random;
/*
* Copyright (C) 2009-2013 Matthias Treydte <mt@waldheinz.de>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package de.waldheinz.fs.fat;
/**
* Allows to create FAT file systems on {@link BlockDevice}s which follow the
* "super floppy" standard. This means that the device will be formatted so
* that it does not contain a partition table. Instead, the entire device holds
* a single FAT file system.
*
* This class follows the "builder" pattern, which means it's methods always
* returns the {@code SuperFloppyFormatter} instance they're called on. This
* allows to chain the method calls like this:
* <pre>
* BlockDevice dev = new RamDisk(16700000);
* FatFileSystem fs = SuperFloppyFormatter.get(dev).
* setFatType(FatType.FAT12).format();
* </pre>
*
* @author Matthias Treydte <matthias.treydte at meetwise.com>
*/
public final class SuperFloppyFormatter {
/**
* The media descriptor used (hard disk).
*/
public final static int MEDIUM_DESCRIPTOR_HD = 0xf8;
/**
* The default number of FATs.
*/
public final static int DEFAULT_FAT_COUNT = 2;
/**
* The default number of sectors per track.
*/
public final static int DEFAULT_SECTORS_PER_TRACK = 32;
/**
* The default number of heads.
*
* @since 0.6
*/
public final static int DEFAULT_HEADS = 64;
/**
* The default number of heads.
*
* @deprecated the name of this constant was mistyped
* @see #DEFAULT_HEADS
*/
@Deprecated
public final static int DEFULT_HEADS = DEFAULT_HEADS;
/**
* The default OEM name for file systems created by this class.
*/
public final static String DEFAULT_OEM_NAME = "fat32lib"; //NOI18N
private static final int MAX_DIRECTORY = 512;
|
private final BlockDevice device;
|
waldheinz/fat32-lib
|
src/test/java/de/waldheinz/fs/util/FileDiskTest.java
|
// Path: src/main/java/de/waldheinz/fs/ReadOnlyException.java
// public final class ReadOnlyException extends RuntimeException {
//
// private final static long serialVersionUID = 1;
//
// /**
// * Creates a new instance of {@code ReadOnlyException}.
// *
// */
// public ReadOnlyException() {
// super("read-only");
// }
// }
|
import de.waldheinz.fs.ReadOnlyException;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Random;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
|
/*
* Copyright (C) 2009-2013 Matthias Treydte <mt@waldheinz.de>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package de.waldheinz.fs.util;
/**
*
* @author Matthias Treydte <matthias.treydte at meetwise.com>
*/
public class FileDiskTest {
private final static int SIZE = 1024 * 1024;
private FileDisk fd;
private File f;
@Before
public void setUp() throws Exception {
f = File.createTempFile("fileDiskTest", ".tmp");
f.deleteOnExit();
fd = FileDisk.create(f, SIZE);
}
@After
public void tearDown() throws IOException {
fd.close();
f.delete();
}
|
// Path: src/main/java/de/waldheinz/fs/ReadOnlyException.java
// public final class ReadOnlyException extends RuntimeException {
//
// private final static long serialVersionUID = 1;
//
// /**
// * Creates a new instance of {@code ReadOnlyException}.
// *
// */
// public ReadOnlyException() {
// super("read-only");
// }
// }
// Path: src/test/java/de/waldheinz/fs/util/FileDiskTest.java
import de.waldheinz.fs.ReadOnlyException;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Random;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
/*
* Copyright (C) 2009-2013 Matthias Treydte <mt@waldheinz.de>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package de.waldheinz.fs.util;
/**
*
* @author Matthias Treydte <matthias.treydte at meetwise.com>
*/
public class FileDiskTest {
private final static int SIZE = 1024 * 1024;
private FileDisk fd;
private File f;
@Before
public void setUp() throws Exception {
f = File.createTempFile("fileDiskTest", ".tmp");
f.deleteOnExit();
fd = FileDisk.create(f, SIZE);
}
@After
public void tearDown() throws IOException {
fd.close();
f.delete();
}
|
@Test(expected=ReadOnlyException.class)
|
waldheinz/fat32-lib
|
src/main/java/de/waldheinz/fs/fat/FatFileSystem.java
|
// Path: src/main/java/de/waldheinz/fs/AbstractFileSystem.java
// public abstract class AbstractFileSystem implements FileSystem {
// private final boolean readOnly;
// private boolean closed;
//
// /**
// * Creates a new {@code AbstractFileSystem}.
// *
// * @param readOnly if the file system should be read-only
// */
// public AbstractFileSystem(boolean readOnly) {
// this.closed = false;
// this.readOnly = readOnly;
// }
//
// @Override
// public void close() throws IOException {
// if (!isClosed()) {
// if (!isReadOnly()) {
// flush();
// }
//
// closed = true;
// }
// }
//
// @Override
// public final boolean isClosed() {
// return closed;
// }
//
// @Override
// public final boolean isReadOnly() {
// return readOnly;
// }
//
// /**
// * Checks if this {@code FileSystem} was already closed, and throws an
// * exception if it was.
// *
// * @throws IllegalStateException if this {@code FileSystem} was
// * already closed
// * @see #isClosed()
// * @see #close()
// */
// protected final void checkClosed() throws IllegalStateException {
// if (isClosed()) {
// throw new IllegalStateException("file system was already closed");
// }
// }
//
// /**
// * Checks if this {@code FileSystem} is read-only, and throws an
// * exception if it is.
// *
// * @throws ReadOnlyException if this {@code FileSystem} is read-only
// * @see #isReadOnly()
// */
// protected final void checkReadOnly() throws ReadOnlyException {
// if (isReadOnly()) {
// throw new ReadOnlyException();
// }
// }
// }
//
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
//
// Path: src/main/java/de/waldheinz/fs/ReadOnlyException.java
// public final class ReadOnlyException extends RuntimeException {
//
// private final static long serialVersionUID = 1;
//
// /**
// * Creates a new instance of {@code ReadOnlyException}.
// *
// */
// public ReadOnlyException() {
// super("read-only");
// }
// }
|
import de.waldheinz.fs.ReadOnlyException;
import de.waldheinz.fs.AbstractFileSystem;
import de.waldheinz.fs.BlockDevice;
import java.io.IOException;
|
/*
* Copyright (C) 2003-2009 JNode.org
* 2009-2013 Matthias Treydte <mt@waldheinz.de>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package de.waldheinz.fs.fat;
/**
* <p>
* Implements the {@code FileSystem} interface for the FAT family of file
* systems. This class always uses the "long file name" specification when
* writing directory entries.
* </p><p>
* For creating (aka "formatting") FAT file systems please refer to the
* {@link SuperFloppyFormatter} class.
* </p>
*
* @author Ewout Prangsma <epr at jnode.org>
* @author Matthias Treydte <waldheinz at gmail.com>
*/
public final class FatFileSystem extends AbstractFileSystem {
private final Fat fat;
private final FsInfoSector fsiSector;
private final BootSector bs;
private final FatLfnDirectory rootDir;
private final AbstractDirectory rootDirStore;
private final FatType fatType;
private final long filesOffset;
|
// Path: src/main/java/de/waldheinz/fs/AbstractFileSystem.java
// public abstract class AbstractFileSystem implements FileSystem {
// private final boolean readOnly;
// private boolean closed;
//
// /**
// * Creates a new {@code AbstractFileSystem}.
// *
// * @param readOnly if the file system should be read-only
// */
// public AbstractFileSystem(boolean readOnly) {
// this.closed = false;
// this.readOnly = readOnly;
// }
//
// @Override
// public void close() throws IOException {
// if (!isClosed()) {
// if (!isReadOnly()) {
// flush();
// }
//
// closed = true;
// }
// }
//
// @Override
// public final boolean isClosed() {
// return closed;
// }
//
// @Override
// public final boolean isReadOnly() {
// return readOnly;
// }
//
// /**
// * Checks if this {@code FileSystem} was already closed, and throws an
// * exception if it was.
// *
// * @throws IllegalStateException if this {@code FileSystem} was
// * already closed
// * @see #isClosed()
// * @see #close()
// */
// protected final void checkClosed() throws IllegalStateException {
// if (isClosed()) {
// throw new IllegalStateException("file system was already closed");
// }
// }
//
// /**
// * Checks if this {@code FileSystem} is read-only, and throws an
// * exception if it is.
// *
// * @throws ReadOnlyException if this {@code FileSystem} is read-only
// * @see #isReadOnly()
// */
// protected final void checkReadOnly() throws ReadOnlyException {
// if (isReadOnly()) {
// throw new ReadOnlyException();
// }
// }
// }
//
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
//
// Path: src/main/java/de/waldheinz/fs/ReadOnlyException.java
// public final class ReadOnlyException extends RuntimeException {
//
// private final static long serialVersionUID = 1;
//
// /**
// * Creates a new instance of {@code ReadOnlyException}.
// *
// */
// public ReadOnlyException() {
// super("read-only");
// }
// }
// Path: src/main/java/de/waldheinz/fs/fat/FatFileSystem.java
import de.waldheinz.fs.ReadOnlyException;
import de.waldheinz.fs.AbstractFileSystem;
import de.waldheinz.fs.BlockDevice;
import java.io.IOException;
/*
* Copyright (C) 2003-2009 JNode.org
* 2009-2013 Matthias Treydte <mt@waldheinz.de>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package de.waldheinz.fs.fat;
/**
* <p>
* Implements the {@code FileSystem} interface for the FAT family of file
* systems. This class always uses the "long file name" specification when
* writing directory entries.
* </p><p>
* For creating (aka "formatting") FAT file systems please refer to the
* {@link SuperFloppyFormatter} class.
* </p>
*
* @author Ewout Prangsma <epr at jnode.org>
* @author Matthias Treydte <waldheinz at gmail.com>
*/
public final class FatFileSystem extends AbstractFileSystem {
private final Fat fat;
private final FsInfoSector fsiSector;
private final BootSector bs;
private final FatLfnDirectory rootDir;
private final AbstractDirectory rootDirStore;
private final FatType fatType;
private final long filesOffset;
|
FatFileSystem(BlockDevice api, boolean readOnly) throws IOException {
|
waldheinz/fat32-lib
|
src/main/java/de/waldheinz/fs/fat/FatFileSystem.java
|
// Path: src/main/java/de/waldheinz/fs/AbstractFileSystem.java
// public abstract class AbstractFileSystem implements FileSystem {
// private final boolean readOnly;
// private boolean closed;
//
// /**
// * Creates a new {@code AbstractFileSystem}.
// *
// * @param readOnly if the file system should be read-only
// */
// public AbstractFileSystem(boolean readOnly) {
// this.closed = false;
// this.readOnly = readOnly;
// }
//
// @Override
// public void close() throws IOException {
// if (!isClosed()) {
// if (!isReadOnly()) {
// flush();
// }
//
// closed = true;
// }
// }
//
// @Override
// public final boolean isClosed() {
// return closed;
// }
//
// @Override
// public final boolean isReadOnly() {
// return readOnly;
// }
//
// /**
// * Checks if this {@code FileSystem} was already closed, and throws an
// * exception if it was.
// *
// * @throws IllegalStateException if this {@code FileSystem} was
// * already closed
// * @see #isClosed()
// * @see #close()
// */
// protected final void checkClosed() throws IllegalStateException {
// if (isClosed()) {
// throw new IllegalStateException("file system was already closed");
// }
// }
//
// /**
// * Checks if this {@code FileSystem} is read-only, and throws an
// * exception if it is.
// *
// * @throws ReadOnlyException if this {@code FileSystem} is read-only
// * @see #isReadOnly()
// */
// protected final void checkReadOnly() throws ReadOnlyException {
// if (isReadOnly()) {
// throw new ReadOnlyException();
// }
// }
// }
//
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
//
// Path: src/main/java/de/waldheinz/fs/ReadOnlyException.java
// public final class ReadOnlyException extends RuntimeException {
//
// private final static long serialVersionUID = 1;
//
// /**
// * Creates a new instance of {@code ReadOnlyException}.
// *
// */
// public ReadOnlyException() {
// super("read-only");
// }
// }
|
import de.waldheinz.fs.ReadOnlyException;
import de.waldheinz.fs.AbstractFileSystem;
import de.waldheinz.fs.BlockDevice;
import java.io.IOException;
|
checkClosed();
return this.fatType;
}
/**
* Returns the volume label of this file system.
*
* @return the volume label
*/
public String getVolumeLabel() {
checkClosed();
final String fromDir = rootDirStore.getLabel();
if (fromDir == null && fatType != FatType.FAT32) {
return ((Fat16BootSector)bs).getVolumeLabel();
} else {
return fromDir;
}
}
/**
* Sets the volume label for this file system.
*
* @param label the new volume label, may be {@code null}
* @throws ReadOnlyException if the file system is read-only
* @throws IOException on write error
*/
public void setVolumeLabel(String label)
|
// Path: src/main/java/de/waldheinz/fs/AbstractFileSystem.java
// public abstract class AbstractFileSystem implements FileSystem {
// private final boolean readOnly;
// private boolean closed;
//
// /**
// * Creates a new {@code AbstractFileSystem}.
// *
// * @param readOnly if the file system should be read-only
// */
// public AbstractFileSystem(boolean readOnly) {
// this.closed = false;
// this.readOnly = readOnly;
// }
//
// @Override
// public void close() throws IOException {
// if (!isClosed()) {
// if (!isReadOnly()) {
// flush();
// }
//
// closed = true;
// }
// }
//
// @Override
// public final boolean isClosed() {
// return closed;
// }
//
// @Override
// public final boolean isReadOnly() {
// return readOnly;
// }
//
// /**
// * Checks if this {@code FileSystem} was already closed, and throws an
// * exception if it was.
// *
// * @throws IllegalStateException if this {@code FileSystem} was
// * already closed
// * @see #isClosed()
// * @see #close()
// */
// protected final void checkClosed() throws IllegalStateException {
// if (isClosed()) {
// throw new IllegalStateException("file system was already closed");
// }
// }
//
// /**
// * Checks if this {@code FileSystem} is read-only, and throws an
// * exception if it is.
// *
// * @throws ReadOnlyException if this {@code FileSystem} is read-only
// * @see #isReadOnly()
// */
// protected final void checkReadOnly() throws ReadOnlyException {
// if (isReadOnly()) {
// throw new ReadOnlyException();
// }
// }
// }
//
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
//
// Path: src/main/java/de/waldheinz/fs/ReadOnlyException.java
// public final class ReadOnlyException extends RuntimeException {
//
// private final static long serialVersionUID = 1;
//
// /**
// * Creates a new instance of {@code ReadOnlyException}.
// *
// */
// public ReadOnlyException() {
// super("read-only");
// }
// }
// Path: src/main/java/de/waldheinz/fs/fat/FatFileSystem.java
import de.waldheinz.fs.ReadOnlyException;
import de.waldheinz.fs.AbstractFileSystem;
import de.waldheinz.fs.BlockDevice;
import java.io.IOException;
checkClosed();
return this.fatType;
}
/**
* Returns the volume label of this file system.
*
* @return the volume label
*/
public String getVolumeLabel() {
checkClosed();
final String fromDir = rootDirStore.getLabel();
if (fromDir == null && fatType != FatType.FAT32) {
return ((Fat16BootSector)bs).getVolumeLabel();
} else {
return fromDir;
}
}
/**
* Sets the volume label for this file system.
*
* @param label the new volume label, may be {@code null}
* @throws ReadOnlyException if the file system is read-only
* @throws IOException on write error
*/
public void setVolumeLabel(String label)
|
throws ReadOnlyException, IOException {
|
waldheinz/fat32-lib
|
src/main/java/de/waldheinz/fs/fat/Fat16BootSector.java
|
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
|
import de.waldheinz.fs.BlockDevice;
import java.io.IOException;
|
/*
* Copyright (C) 2009-2013 Matthias Treydte <mt@waldheinz.de>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package de.waldheinz.fs.fat;
/**
* The boot sector layout as used by the FAT12 / FAT16 variants.
*
* @author Matthias Treydte <matthias.treydte at meetwise.com>
*/
final class Fat16BootSector extends BootSector {
/**
* The default number of entries for the root directory.
*
* @see #getRootDirEntryCount()
* @see #setRootDirEntryCount(int)
*/
public static final int DEFAULT_ROOT_DIR_ENTRY_COUNT = 512;
/**
* The default volume label.
*/
public static final String DEFAULT_VOLUME_LABEL = "NO NAME"; //NOI18N
/**
* The maximum number of clusters for a FAT12 file system. This is actually
* the number of clusters where mkdosfs stop complaining about a FAT16
* partition having not enough sectors, so it would be misinterpreted
* as FAT12 without special handling.
*
* @see #getNrLogicalSectors()
*/
public static final int MAX_FAT12_CLUSTERS = 4084;
public static final int MAX_FAT16_CLUSTERS = 65524;
/**
* The offset to the sectors per FAT value.
*/
public static final int SECTORS_PER_FAT_OFFSET = 0x16;
/**
* The offset to the root directory entry count value.
*
* @see #getRootDirEntryCount()
* @see #setRootDirEntryCount(int)
*/
public static final int ROOT_DIR_ENTRIES_OFFSET = 0x11;
/**
* The offset to the first byte of the volume label.
*/
public static final int VOLUME_LABEL_OFFSET = 0x2b;
/**
* Offset to the FAT file system type string.
*
* @see #getFileSystemType()
*/
public static final int FILE_SYSTEM_TYPE_OFFSET = 0x36;
/**
* The maximum length of the volume label.
*/
public static final int MAX_VOLUME_LABEL_LENGTH = 11;
public static final int EXTENDED_BOOT_SIGNATURE_OFFSET = 0x26;
/**
* Creates a new {@code Fat16BootSector} for the specified device.
*
* @param device the {@code BlockDevice} holding the boot sector
*/
|
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
// Path: src/main/java/de/waldheinz/fs/fat/Fat16BootSector.java
import de.waldheinz.fs.BlockDevice;
import java.io.IOException;
/*
* Copyright (C) 2009-2013 Matthias Treydte <mt@waldheinz.de>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package de.waldheinz.fs.fat;
/**
* The boot sector layout as used by the FAT12 / FAT16 variants.
*
* @author Matthias Treydte <matthias.treydte at meetwise.com>
*/
final class Fat16BootSector extends BootSector {
/**
* The default number of entries for the root directory.
*
* @see #getRootDirEntryCount()
* @see #setRootDirEntryCount(int)
*/
public static final int DEFAULT_ROOT_DIR_ENTRY_COUNT = 512;
/**
* The default volume label.
*/
public static final String DEFAULT_VOLUME_LABEL = "NO NAME"; //NOI18N
/**
* The maximum number of clusters for a FAT12 file system. This is actually
* the number of clusters where mkdosfs stop complaining about a FAT16
* partition having not enough sectors, so it would be misinterpreted
* as FAT12 without special handling.
*
* @see #getNrLogicalSectors()
*/
public static final int MAX_FAT12_CLUSTERS = 4084;
public static final int MAX_FAT16_CLUSTERS = 65524;
/**
* The offset to the sectors per FAT value.
*/
public static final int SECTORS_PER_FAT_OFFSET = 0x16;
/**
* The offset to the root directory entry count value.
*
* @see #getRootDirEntryCount()
* @see #setRootDirEntryCount(int)
*/
public static final int ROOT_DIR_ENTRIES_OFFSET = 0x11;
/**
* The offset to the first byte of the volume label.
*/
public static final int VOLUME_LABEL_OFFSET = 0x2b;
/**
* Offset to the FAT file system type string.
*
* @see #getFileSystemType()
*/
public static final int FILE_SYSTEM_TYPE_OFFSET = 0x36;
/**
* The maximum length of the volume label.
*/
public static final int MAX_VOLUME_LABEL_LENGTH = 11;
public static final int EXTENDED_BOOT_SIGNATURE_OFFSET = 0x26;
/**
* Creates a new {@code Fat16BootSector} for the specified device.
*
* @param device the {@code BlockDevice} holding the boot sector
*/
|
public Fat16BootSector(BlockDevice device) {
|
waldheinz/fat32-lib
|
src/main/java/de/waldheinz/fs/util/FileDisk.java
|
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
//
// Path: src/main/java/de/waldheinz/fs/ReadOnlyException.java
// public final class ReadOnlyException extends RuntimeException {
//
// private final static long serialVersionUID = 1;
//
// /**
// * Creates a new instance of {@code ReadOnlyException}.
// *
// */
// public ReadOnlyException() {
// super("read-only");
// }
// }
|
import de.waldheinz.fs.BlockDevice;
import de.waldheinz.fs.ReadOnlyException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
|
}
}
@Override
public long getSize() throws IOException {
checkClosed();
return raf.length();
}
@Override
public void read(long devOffset, ByteBuffer dest) throws IOException {
checkClosed();
int toRead = dest.remaining();
if ((devOffset + toRead) > getSize()) throw new IOException(
"reading past end of device");
while (toRead > 0) {
final int read = fc.read(dest, devOffset);
if (read < 0) throw new IOException();
toRead -= read;
devOffset += read;
}
}
@Override
public void write(long devOffset, ByteBuffer src) throws IOException {
checkClosed();
|
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
//
// Path: src/main/java/de/waldheinz/fs/ReadOnlyException.java
// public final class ReadOnlyException extends RuntimeException {
//
// private final static long serialVersionUID = 1;
//
// /**
// * Creates a new instance of {@code ReadOnlyException}.
// *
// */
// public ReadOnlyException() {
// super("read-only");
// }
// }
// Path: src/main/java/de/waldheinz/fs/util/FileDisk.java
import de.waldheinz.fs.BlockDevice;
import de.waldheinz.fs.ReadOnlyException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
}
}
@Override
public long getSize() throws IOException {
checkClosed();
return raf.length();
}
@Override
public void read(long devOffset, ByteBuffer dest) throws IOException {
checkClosed();
int toRead = dest.remaining();
if ((devOffset + toRead) > getSize()) throw new IOException(
"reading past end of device");
while (toRead > 0) {
final int read = fc.read(dest, devOffset);
if (read < 0) throw new IOException();
toRead -= read;
devOffset += read;
}
}
@Override
public void write(long devOffset, ByteBuffer src) throws IOException {
checkClosed();
|
if (this.readOnly) throw new ReadOnlyException();
|
waldheinz/fat32-lib
|
src/main/java/de/waldheinz/fs/fat/Fat32BootSector.java
|
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
|
import de.waldheinz.fs.BlockDevice;
import java.io.IOException;
|
/*
* Copyright (C) 2009-2013 Matthias Treydte <mt@waldheinz.de>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package de.waldheinz.fs.fat;
/**
* Contains the FAT32 specific parts of the boot sector.
*
* @author Matthias Treydte <matthias.treydte at meetwise.com>
*/
final class Fat32BootSector extends BootSector {
/**
* The offset to the entry specifying the first cluster of the FAT32
* root directory.
*/
public final static int ROOT_DIR_FIRST_CLUSTER_OFFSET = 0x2c;
/**
* The offset to the 4 bytes specifying the sectors per FAT value.
*/
public static final int SECTORS_PER_FAT_OFFSET = 0x24;
/**
* Offset to the file system type label.
*/
public static final int FILE_SYSTEM_TYPE_OFFSET = 0x52;
public static final int VERSION_OFFSET = 0x2a;
public static final int VERSION = 0;
public static final int FS_INFO_SECTOR_OFFSET = 0x30;
public static final int BOOT_SECTOR_COPY_OFFSET = 0x32;
public static final int EXTENDED_BOOT_SIGNATURE_OFFSET = 0x42;
/*
* TODO: make this constructor private
*/
|
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
// Path: src/main/java/de/waldheinz/fs/fat/Fat32BootSector.java
import de.waldheinz.fs.BlockDevice;
import java.io.IOException;
/*
* Copyright (C) 2009-2013 Matthias Treydte <mt@waldheinz.de>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package de.waldheinz.fs.fat;
/**
* Contains the FAT32 specific parts of the boot sector.
*
* @author Matthias Treydte <matthias.treydte at meetwise.com>
*/
final class Fat32BootSector extends BootSector {
/**
* The offset to the entry specifying the first cluster of the FAT32
* root directory.
*/
public final static int ROOT_DIR_FIRST_CLUSTER_OFFSET = 0x2c;
/**
* The offset to the 4 bytes specifying the sectors per FAT value.
*/
public static final int SECTORS_PER_FAT_OFFSET = 0x24;
/**
* Offset to the file system type label.
*/
public static final int FILE_SYSTEM_TYPE_OFFSET = 0x52;
public static final int VERSION_OFFSET = 0x2a;
public static final int VERSION = 0;
public static final int FS_INFO_SECTOR_OFFSET = 0x30;
public static final int BOOT_SECTOR_COPY_OFFSET = 0x32;
public static final int EXTENDED_BOOT_SIGNATURE_OFFSET = 0x42;
/*
* TODO: make this constructor private
*/
|
public Fat32BootSector(BlockDevice device) throws IOException {
|
waldheinz/fat32-lib
|
src/main/java/de/waldheinz/fs/fat/ClusterChain.java
|
// Path: src/main/java/de/waldheinz/fs/AbstractFsObject.java
// public class AbstractFsObject implements FsObject {
//
// /**
// * Holds the read-only state of this object.
// */
// private final boolean readOnly;
//
// /**
// * Remembers if this object still valid.
// */
// private boolean valid;
//
// /**
// * Creates a new instance of {@code AbstractFsObject} which will be valid
// * and have the specified read-only state.
// *
// * @param readOnly if the new object will be read-only
// */
// protected AbstractFsObject(boolean readOnly) {
// this.valid = true;
// this.readOnly = readOnly;
// }
//
// /**
// * {@inheritDoc}
// *
// * @return {@inheritDoc}
// * @see #checkValid()
// * @see #invalidate()
// */
// @Override
// public final boolean isValid() {
// return this.valid;
// }
//
// /**
// * Marks this object as invalid.
// *
// * @see #isValid()
// * @see #checkValid()
// */
// protected final void invalidate() {
// this.valid = false;
// }
//
// /**
// * Convience method to check if this object is still valid and throw an
// * {@code IllegalStateException} if it is not.
// *
// * @throws IllegalStateException if this object was invalidated
// * @since 0.6
// * @see #isValid()
// * @see #invalidate()
// */
// protected final void checkValid() throws IllegalStateException {
// if (!isValid()) throw new IllegalStateException(
// this + " is not valid");
// }
//
// /**
// * Convience method to check if this object is writable. An object is
// * writable if it is both, valid and not read-only.
// *
// * @throws IllegalStateException if this object was invalidated
// * @throws ReadOnlyException if this object was created with the read-only
// * flag set
// * @since 0.6
// */
// protected final void checkWritable()
// throws IllegalStateException, ReadOnlyException {
//
// checkValid();
//
// if (isReadOnly()) {
// throw new ReadOnlyException();
// }
// }
//
// @Override
// public final boolean isReadOnly() {
// return this.readOnly;
// }
//
// }
//
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
|
import de.waldheinz.fs.AbstractFsObject;
import de.waldheinz.fs.BlockDevice;
import java.io.EOFException;
import java.io.IOException;
import java.nio.ByteBuffer;
|
/*
* Copyright (C) 2009-2013 Matthias Treydte <mt@waldheinz.de>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package de.waldheinz.fs.fat;
/**
* A chain of clusters as stored in a {@link Fat}.
*
* @author Matthias Treydte <waldheinz at gmail.com>
*/
final class ClusterChain extends AbstractFsObject {
private final Fat fat;
|
// Path: src/main/java/de/waldheinz/fs/AbstractFsObject.java
// public class AbstractFsObject implements FsObject {
//
// /**
// * Holds the read-only state of this object.
// */
// private final boolean readOnly;
//
// /**
// * Remembers if this object still valid.
// */
// private boolean valid;
//
// /**
// * Creates a new instance of {@code AbstractFsObject} which will be valid
// * and have the specified read-only state.
// *
// * @param readOnly if the new object will be read-only
// */
// protected AbstractFsObject(boolean readOnly) {
// this.valid = true;
// this.readOnly = readOnly;
// }
//
// /**
// * {@inheritDoc}
// *
// * @return {@inheritDoc}
// * @see #checkValid()
// * @see #invalidate()
// */
// @Override
// public final boolean isValid() {
// return this.valid;
// }
//
// /**
// * Marks this object as invalid.
// *
// * @see #isValid()
// * @see #checkValid()
// */
// protected final void invalidate() {
// this.valid = false;
// }
//
// /**
// * Convience method to check if this object is still valid and throw an
// * {@code IllegalStateException} if it is not.
// *
// * @throws IllegalStateException if this object was invalidated
// * @since 0.6
// * @see #isValid()
// * @see #invalidate()
// */
// protected final void checkValid() throws IllegalStateException {
// if (!isValid()) throw new IllegalStateException(
// this + " is not valid");
// }
//
// /**
// * Convience method to check if this object is writable. An object is
// * writable if it is both, valid and not read-only.
// *
// * @throws IllegalStateException if this object was invalidated
// * @throws ReadOnlyException if this object was created with the read-only
// * flag set
// * @since 0.6
// */
// protected final void checkWritable()
// throws IllegalStateException, ReadOnlyException {
//
// checkValid();
//
// if (isReadOnly()) {
// throw new ReadOnlyException();
// }
// }
//
// @Override
// public final boolean isReadOnly() {
// return this.readOnly;
// }
//
// }
//
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
// Path: src/main/java/de/waldheinz/fs/fat/ClusterChain.java
import de.waldheinz.fs.AbstractFsObject;
import de.waldheinz.fs.BlockDevice;
import java.io.EOFException;
import java.io.IOException;
import java.nio.ByteBuffer;
/*
* Copyright (C) 2009-2013 Matthias Treydte <mt@waldheinz.de>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package de.waldheinz.fs.fat;
/**
* A chain of clusters as stored in a {@link Fat}.
*
* @author Matthias Treydte <waldheinz at gmail.com>
*/
final class ClusterChain extends AbstractFsObject {
private final Fat fat;
|
private final BlockDevice device;
|
waldheinz/fat32-lib
|
src/test/java/de/waldheinz/fs/fat/MoveToReplaceTest.java
|
// Path: src/main/java/de/waldheinz/fs/util/RamDisk.java
// public final class RamDisk implements BlockDevice {
//
// /**
// * The default sector size for {@code RamDisk}s.
// */
// public final static int DEFAULT_SECTOR_SIZE = 512;
//
// private final int sectorSize;
// private final ByteBuffer data;
// private final int size;
// private boolean closed;
//
// /**
// * Reads a GZIP compressed disk image from the specified input stream and
// * returns a {@code RamDisk} holding the decompressed image.
// *
// * @param in the stream to read the disk image from
// * @return the decompressed {@code RamDisk}
// * @throws IOException on read or decompression error
// */
// public static RamDisk readGzipped(InputStream in) throws IOException {
// final GZIPInputStream zis = new GZIPInputStream(in);
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
//
// final byte[] buffer = new byte[4096];
//
// int read = zis.read(buffer);
// int total = 0;
//
// while (read >= 0) {
// total += read;
// bos.write(buffer, 0, read);
// read = zis.read(buffer);
// }
//
// if (total < DEFAULT_SECTOR_SIZE) throw new IOException(
// "read only " + total + " bytes"); //NOI18N
//
// final ByteBuffer bb = ByteBuffer.wrap(bos.toByteArray(), 0, total);
// return new RamDisk(bb, DEFAULT_SECTOR_SIZE);
// }
//
// /**
// * Reads a GZIP compressed file into a new {@code RamDisk} instance.
// *
// * @param f the file to read
// * @return the new RamDisk with the file contents
// * @throws FileNotFoundException if the specified file does not exist
// * @throws IOException on read error
// */
// public static RamDisk readGzipped(File f)
// throws FileNotFoundException, IOException {
//
// final FileInputStream is = new FileInputStream(f);
//
// try {
// return readGzipped(is);
// } finally {
// is.close();
// }
// }
//
// private RamDisk(ByteBuffer buffer, int sectorSize) {
// this.size = buffer.limit();
// this.sectorSize = sectorSize;
// this.data = buffer;
// this.closed = false;
// }
//
// /**
// * Creates a new instance of {@code RamDisk} of this specified
// * size and using the {@link #DEFAULT_SECTOR_SIZE}.
// *
// * @param size the size of the new block device
// */
// public RamDisk(int size) {
// this(size, DEFAULT_SECTOR_SIZE);
// }
//
// /**
// * Creates a new instance of {@code RamDisk} of this specified
// * size and sector size
// *
// * @param size the size of the new block device
// * @param sectorSize the sector size of the new block device
// */
// public RamDisk(int size, int sectorSize) {
// if (sectorSize < 1) throw new IllegalArgumentException(
// "invalid sector size"); //NOI18N
//
// this.sectorSize = sectorSize;
// this.size = size;
// this.data = ByteBuffer.allocate(size);
// }
//
// @Override
// public long getSize() {
// checkClosed();
// return this.size;
// }
//
// @Override
// public void read(long devOffset, ByteBuffer dest) throws IOException {
// checkClosed();
// if (devOffset > getSize()) throw new IllegalArgumentException();
//
// data.limit((int) (devOffset + dest.remaining()));
// data.position((int) devOffset);
//
// dest.put(data);
// }
//
// @Override
// public void write(long devOffset, ByteBuffer src) throws IOException {
// checkClosed();
//
// if (devOffset + src.remaining() > getSize()) throw new
// IllegalArgumentException(
// "offset=" + devOffset +
// ", length=" + src.remaining() +
// ", size=" + getSize());
//
// data.limit((int) (devOffset + src.remaining()));
// data.position((int) devOffset);
//
//
// data.put(src);
// }
//
// /**
// * Returns a slice of the {@code ByteBuffer} that is used by this
// * {@code RamDisk} as it's backing store. The returned buffer will be
// * live (reflecting any changes made through the
// * {@link #write(long, java.nio.ByteBuffer) method}, but read-only.
// *
// * @return a buffer holding the contents of this {@code RamDisk}
// */
// public ByteBuffer getBuffer() {
// return this.data.asReadOnlyBuffer();
// }
//
// @Override
// public void flush() throws IOException {
// checkClosed();
// }
//
// @Override
// public int getSectorSize() {
// checkClosed();
// return this.sectorSize;
// }
//
// @Override
// public void close() throws IOException {
// this.closed = true;
// }
//
// @Override
// public boolean isClosed() {
// return this.closed;
// }
//
// private void checkClosed() {
// if (closed) throw new IllegalStateException("device already closed");
// }
//
// /**
// * Returns always {@code false}, as a {@code RamDisk} is always writable.
// *
// * @return always {@code false}
// */
// @Override
// public boolean isReadOnly() {
// checkClosed();
//
// return false;
// }
//
// }
|
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import de.waldheinz.fs.util.RamDisk;
|
package de.waldheinz.fs.fat;
public class MoveToReplaceTest {
private static final String FILE_NAME = "file";
private static final String DIRECTORY_NAME = "dir";
private FatLfnDirectoryEntry file;
private FatLfnDirectoryEntry dir;
private FatLfnDirectory root;
private FatFileSystem fs;
@Before
public void setUp() throws IOException {
|
// Path: src/main/java/de/waldheinz/fs/util/RamDisk.java
// public final class RamDisk implements BlockDevice {
//
// /**
// * The default sector size for {@code RamDisk}s.
// */
// public final static int DEFAULT_SECTOR_SIZE = 512;
//
// private final int sectorSize;
// private final ByteBuffer data;
// private final int size;
// private boolean closed;
//
// /**
// * Reads a GZIP compressed disk image from the specified input stream and
// * returns a {@code RamDisk} holding the decompressed image.
// *
// * @param in the stream to read the disk image from
// * @return the decompressed {@code RamDisk}
// * @throws IOException on read or decompression error
// */
// public static RamDisk readGzipped(InputStream in) throws IOException {
// final GZIPInputStream zis = new GZIPInputStream(in);
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
//
// final byte[] buffer = new byte[4096];
//
// int read = zis.read(buffer);
// int total = 0;
//
// while (read >= 0) {
// total += read;
// bos.write(buffer, 0, read);
// read = zis.read(buffer);
// }
//
// if (total < DEFAULT_SECTOR_SIZE) throw new IOException(
// "read only " + total + " bytes"); //NOI18N
//
// final ByteBuffer bb = ByteBuffer.wrap(bos.toByteArray(), 0, total);
// return new RamDisk(bb, DEFAULT_SECTOR_SIZE);
// }
//
// /**
// * Reads a GZIP compressed file into a new {@code RamDisk} instance.
// *
// * @param f the file to read
// * @return the new RamDisk with the file contents
// * @throws FileNotFoundException if the specified file does not exist
// * @throws IOException on read error
// */
// public static RamDisk readGzipped(File f)
// throws FileNotFoundException, IOException {
//
// final FileInputStream is = new FileInputStream(f);
//
// try {
// return readGzipped(is);
// } finally {
// is.close();
// }
// }
//
// private RamDisk(ByteBuffer buffer, int sectorSize) {
// this.size = buffer.limit();
// this.sectorSize = sectorSize;
// this.data = buffer;
// this.closed = false;
// }
//
// /**
// * Creates a new instance of {@code RamDisk} of this specified
// * size and using the {@link #DEFAULT_SECTOR_SIZE}.
// *
// * @param size the size of the new block device
// */
// public RamDisk(int size) {
// this(size, DEFAULT_SECTOR_SIZE);
// }
//
// /**
// * Creates a new instance of {@code RamDisk} of this specified
// * size and sector size
// *
// * @param size the size of the new block device
// * @param sectorSize the sector size of the new block device
// */
// public RamDisk(int size, int sectorSize) {
// if (sectorSize < 1) throw new IllegalArgumentException(
// "invalid sector size"); //NOI18N
//
// this.sectorSize = sectorSize;
// this.size = size;
// this.data = ByteBuffer.allocate(size);
// }
//
// @Override
// public long getSize() {
// checkClosed();
// return this.size;
// }
//
// @Override
// public void read(long devOffset, ByteBuffer dest) throws IOException {
// checkClosed();
// if (devOffset > getSize()) throw new IllegalArgumentException();
//
// data.limit((int) (devOffset + dest.remaining()));
// data.position((int) devOffset);
//
// dest.put(data);
// }
//
// @Override
// public void write(long devOffset, ByteBuffer src) throws IOException {
// checkClosed();
//
// if (devOffset + src.remaining() > getSize()) throw new
// IllegalArgumentException(
// "offset=" + devOffset +
// ", length=" + src.remaining() +
// ", size=" + getSize());
//
// data.limit((int) (devOffset + src.remaining()));
// data.position((int) devOffset);
//
//
// data.put(src);
// }
//
// /**
// * Returns a slice of the {@code ByteBuffer} that is used by this
// * {@code RamDisk} as it's backing store. The returned buffer will be
// * live (reflecting any changes made through the
// * {@link #write(long, java.nio.ByteBuffer) method}, but read-only.
// *
// * @return a buffer holding the contents of this {@code RamDisk}
// */
// public ByteBuffer getBuffer() {
// return this.data.asReadOnlyBuffer();
// }
//
// @Override
// public void flush() throws IOException {
// checkClosed();
// }
//
// @Override
// public int getSectorSize() {
// checkClosed();
// return this.sectorSize;
// }
//
// @Override
// public void close() throws IOException {
// this.closed = true;
// }
//
// @Override
// public boolean isClosed() {
// return this.closed;
// }
//
// private void checkClosed() {
// if (closed) throw new IllegalStateException("device already closed");
// }
//
// /**
// * Returns always {@code false}, as a {@code RamDisk} is always writable.
// *
// * @return always {@code false}
// */
// @Override
// public boolean isReadOnly() {
// checkClosed();
//
// return false;
// }
//
// }
// Path: src/test/java/de/waldheinz/fs/fat/MoveToReplaceTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import de.waldheinz.fs.util.RamDisk;
package de.waldheinz.fs.fat;
public class MoveToReplaceTest {
private static final String FILE_NAME = "file";
private static final String DIRECTORY_NAME = "dir";
private FatLfnDirectoryEntry file;
private FatLfnDirectoryEntry dir;
private FatLfnDirectory root;
private FatFileSystem fs;
@Before
public void setUp() throws IOException {
|
RamDisk dev = new RamDisk(1024 * 1024);
|
waldheinz/fat32-lib
|
src/main/java/de/waldheinz/fs/fat/BootSector.java
|
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
|
import java.nio.ByteOrder;
import de.waldheinz.fs.BlockDevice;
import java.io.IOException;
import java.nio.ByteBuffer;
|
/*
* Copyright (C) 2003-2009 JNode.org
* 2009-2013 Matthias Treydte <mt@waldheinz.de>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package de.waldheinz.fs.fat;
/**
* The boot sector.
*
* @author Ewout Prangsma <epr at jnode.org>
* @author Matthias Treydte <waldheinz at gmail.com>
*/
abstract class BootSector extends Sector {
/**
* Offset to the byte specifying the number of FATs.
*
* @see #getNrFats()
* @see #setNrFats(int)
*/
public static final int FAT_COUNT_OFFSET = 16;
public static final int RESERVED_SECTORS_OFFSET = 14;
public static final int TOTAL_SECTORS_16_OFFSET = 19;
public static final int TOTAL_SECTORS_32_OFFSET = 32;
/**
* The length of the file system type string.
*
* @see #getFileSystemType()
*/
public static final int FILE_SYSTEM_TYPE_LENGTH = 8;
/**
* The offset to the sectors per cluster value stored in a boot sector.
*
* @see #getSectorsPerCluster()
* @see #setSectorsPerCluster(int)
*/
public static final int SECTORS_PER_CLUSTER_OFFSET = 0x0d;
public static final int EXTENDED_BOOT_SIGNATURE = 0x29;
/**
* The size of a boot sector in bytes.
*/
public final static int SIZE = 512;
|
// Path: src/main/java/de/waldheinz/fs/BlockDevice.java
// public interface BlockDevice {
//
// /**
// * Gets the total length of this device in bytes.
// *
// * @return the total number of bytes on this device
// * @throws IOException on error getting the size of this device
// */
// public abstract long getSize() throws IOException;
//
// /**
// * Read a block of data from this device.
// *
// * @param devOffset the byte offset where to read the data from
// * @param dest the destination buffer where to store the data read
// * @throws IOException on read error
// */
// public abstract void read(long devOffset, ByteBuffer dest)
// throws IOException;
//
// /**
// * Writes a block of data to this device.
// *
// * @param devOffset the byte offset where to store the data
// * @param src the source {@code ByteBuffer} to write to the device
// * @throws ReadOnlyException if this {@code BlockDevice} is read-only
// * @throws IOException on write error
// * @throws IllegalArgumentException if the {@code devOffset} is negative
// * or the write would go beyond the end of the device
// * @see #isReadOnly()
// */
// public abstract void write(long devOffset, ByteBuffer src)
// throws ReadOnlyException, IOException,
// IllegalArgumentException;
//
// /**
// * Flushes data in caches to the actual storage.
// *
// * @throws IOException on write error
// */
// public abstract void flush() throws IOException;
//
// /**
// * Returns the size of a sector on this device.
// *
// * @return the sector size in bytes
// * @throws IOException on error determining the sector size
// */
// public int getSectorSize() throws IOException;
//
// /**
// * Closes this {@code BlockDevice}. No methods of this device may be
// * accesses after this method was called.
// *
// * @throws IOException on error closing this device
// * @see #isClosed()
// */
// public void close() throws IOException;
//
// /**
// * Checks if this device was already closed. No methods may be called
// * on a closed device (except this method).
// *
// * @return if this device is closed
// */
// public boolean isClosed();
//
// /**
// * Checks if this {@code BlockDevice} is read-only.
// *
// * @return if this {@code BlockDevice} is read-only
// */
// public boolean isReadOnly();
//
// }
// Path: src/main/java/de/waldheinz/fs/fat/BootSector.java
import java.nio.ByteOrder;
import de.waldheinz.fs.BlockDevice;
import java.io.IOException;
import java.nio.ByteBuffer;
/*
* Copyright (C) 2003-2009 JNode.org
* 2009-2013 Matthias Treydte <mt@waldheinz.de>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package de.waldheinz.fs.fat;
/**
* The boot sector.
*
* @author Ewout Prangsma <epr at jnode.org>
* @author Matthias Treydte <waldheinz at gmail.com>
*/
abstract class BootSector extends Sector {
/**
* Offset to the byte specifying the number of FATs.
*
* @see #getNrFats()
* @see #setNrFats(int)
*/
public static final int FAT_COUNT_OFFSET = 16;
public static final int RESERVED_SECTORS_OFFSET = 14;
public static final int TOTAL_SECTORS_16_OFFSET = 19;
public static final int TOTAL_SECTORS_32_OFFSET = 32;
/**
* The length of the file system type string.
*
* @see #getFileSystemType()
*/
public static final int FILE_SYSTEM_TYPE_LENGTH = 8;
/**
* The offset to the sectors per cluster value stored in a boot sector.
*
* @see #getSectorsPerCluster()
* @see #setSectorsPerCluster(int)
*/
public static final int SECTORS_PER_CLUSTER_OFFSET = 0x0d;
public static final int EXTENDED_BOOT_SIGNATURE = 0x29;
/**
* The size of a boot sector in bytes.
*/
public final static int SIZE = 512;
|
protected BootSector(BlockDevice device) {
|
foobnix/android-universal-utils
|
src/com/foobnix/android/utils/broadcast/LocalBroadcastFragment.java
|
// Path: src/com/foobnix/android/utils/LOG.java
// public class LOG {
// public static boolean isEnable = true;
// public static String TAG = "DEBUG";
// public static String DELIMITER = "|";
//
// public static void printlog(String statement) {
// if (isEnable) {
// Log.d(TAG, statement);
// }
// }
//
// public static void d(Object... statement) {
// if (isEnable) {
// Log.d(TAG, asString(statement));
// }
// }
//
// public static void dMeta(Object... statement) {
// String meta = null;
// StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
// if (stackTrace.length > 3) {
// meta = asString(stackTrace[3].getClassName(), stackTrace[3].getMethodName(), stackTrace[3].getLineNumber());
// }
//
// d(meta, asString(statement));
//
// }
//
// public static void e(Throwable e, Object... statement) {
// if (isEnable) {
// Log.e(TAG, asString(statement), e);
// }
// }
//
// private static String asString(Object... statements) {
// return TxtUtils.join(DELIMITER, statements);
// }
//
// }
//
// Path: src/com/foobnix/android/utils/ResultResponse.java
// public interface ResultResponse<T> {
//
// public boolean onResultRecive(T result);
//
// }
|
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import com.foobnix.android.utils.LOG;
import com.foobnix.android.utils.ResultResponse;
|
package com.foobnix.android.utils.broadcast;
public abstract class LocalBroadcastFragment extends Fragment implements ResultResponse<Intent> {
BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
|
// Path: src/com/foobnix/android/utils/LOG.java
// public class LOG {
// public static boolean isEnable = true;
// public static String TAG = "DEBUG";
// public static String DELIMITER = "|";
//
// public static void printlog(String statement) {
// if (isEnable) {
// Log.d(TAG, statement);
// }
// }
//
// public static void d(Object... statement) {
// if (isEnable) {
// Log.d(TAG, asString(statement));
// }
// }
//
// public static void dMeta(Object... statement) {
// String meta = null;
// StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
// if (stackTrace.length > 3) {
// meta = asString(stackTrace[3].getClassName(), stackTrace[3].getMethodName(), stackTrace[3].getLineNumber());
// }
//
// d(meta, asString(statement));
//
// }
//
// public static void e(Throwable e, Object... statement) {
// if (isEnable) {
// Log.e(TAG, asString(statement), e);
// }
// }
//
// private static String asString(Object... statements) {
// return TxtUtils.join(DELIMITER, statements);
// }
//
// }
//
// Path: src/com/foobnix/android/utils/ResultResponse.java
// public interface ResultResponse<T> {
//
// public boolean onResultRecive(T result);
//
// }
// Path: src/com/foobnix/android/utils/broadcast/LocalBroadcastFragment.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import com.foobnix.android.utils.LOG;
import com.foobnix.android.utils.ResultResponse;
package com.foobnix.android.utils.broadcast;
public abstract class LocalBroadcastFragment extends Fragment implements ResultResponse<Intent> {
BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
|
LOG.d("LocalBroadcastFragment", "onReceive", intent);
|
foobnix/android-universal-utils
|
src/com/foobnix/android/utils/res/ExtraArgument_1.java
|
// Path: src/com/foobnix/android/utils/ModelFragment.java
// public abstract class ModelFragment<T extends Serializable> extends Fragment {
// public static final String EXTRA_FRAGMENT_MODEL = "model";
//
// public static final String EXTRA_ARGUMENT_1 = "EXTRA_ARGIMENT_1";
// public static final String EXTRA_ARGUMENT_2 = "EXTRA_ARGIMENT_2";
// public static final String EXTRA_ARGUMENT_3 = "EXTRA_ARGIMENT_3";
//
// private Handler handler;
//
// private Runnable onPauseLintener;
// private Runnable onResumeLintener;
// private ResultResponse<Bundle> onSaveInstanceState;
// protected T model;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// handler = new Handler();
// prepareModelFromArgumentOrBundle(savedInstanceState);
// }
//
// public ModelFragment<T> withBundles(Bundles bundles) {
// setArguments(bundles.build());
// return this;
// }
//
// public ModelFragment<T> withBundle(Bundle bundle) {
// setArguments(bundle);
// return this;
// }
//
// private void prepareModelFromArgumentOrBundle(Bundle savedInstanceState) {
// if (getArguments() != null && getArguments().containsKey(EXTRA_FRAGMENT_MODEL)) {
// model = (T) getArguments().getSerializable(EXTRA_FRAGMENT_MODEL);
// }
// if (model == null && savedInstanceState != null) {
// model = (T) savedInstanceState.getSerializable(EXTRA_FRAGMENT_MODEL);
// }
// if (model == null) {
// try {
// if (this instanceof EmptyModelFragment) {
// return;
// }
// ParameterizedType pt = (ParameterizedType) getClass().getGenericSuperclass();
// Class<?> type = (Class<?>) pt.getActualTypeArguments()[0];
// LOG.d("Model Fragment class name", type.getName());
// model = (T) type.newInstance();
// } catch (Exception e) {
// throw new RuntimeException(e.getCause());
// }
// }
// }
//
// public abstract void populateModel();
//
// public abstract void saveModel();
//
// @Override
// public void onPause() {
// super.onPause();
// if (onPauseLintener != null) {
// onPauseLintener.run();
// }
// }
//
// @Override
// public void onResume() {
// super.onResume();
// if (onResumeLintener != null) {
// onResumeLintener.run();
// }
// }
//
// @Override
// public void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// saveModel();
// outState.putSerializable(EXTRA_FRAGMENT_MODEL, model);
// if (outState != null && onSaveInstanceState != null) {
// onSaveInstanceState.onResultRecive(outState);
// }
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// handler.removeCallbacksAndMessages(null);
// }
//
// public Handler getHandler() {
// return handler;
// }
//
// public void setOnPauseLintener(Runnable onPauseLintener) {
// this.onPauseLintener = onPauseLintener;
// }
//
// public void setOnResumeLintener(Runnable onResumeLintener) {
// this.onResumeLintener = onResumeLintener;
// }
//
// public void setOnSaveInstanceState(ResultResponse<Bundle> onSaveInstanceState) {
// this.onSaveInstanceState = onSaveInstanceState;
// }
//
// }
|
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.foobnix.android.utils.ModelFragment;
|
package com.foobnix.android.utils.res;
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD })
public @interface ExtraArgument_1 {
|
// Path: src/com/foobnix/android/utils/ModelFragment.java
// public abstract class ModelFragment<T extends Serializable> extends Fragment {
// public static final String EXTRA_FRAGMENT_MODEL = "model";
//
// public static final String EXTRA_ARGUMENT_1 = "EXTRA_ARGIMENT_1";
// public static final String EXTRA_ARGUMENT_2 = "EXTRA_ARGIMENT_2";
// public static final String EXTRA_ARGUMENT_3 = "EXTRA_ARGIMENT_3";
//
// private Handler handler;
//
// private Runnable onPauseLintener;
// private Runnable onResumeLintener;
// private ResultResponse<Bundle> onSaveInstanceState;
// protected T model;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// handler = new Handler();
// prepareModelFromArgumentOrBundle(savedInstanceState);
// }
//
// public ModelFragment<T> withBundles(Bundles bundles) {
// setArguments(bundles.build());
// return this;
// }
//
// public ModelFragment<T> withBundle(Bundle bundle) {
// setArguments(bundle);
// return this;
// }
//
// private void prepareModelFromArgumentOrBundle(Bundle savedInstanceState) {
// if (getArguments() != null && getArguments().containsKey(EXTRA_FRAGMENT_MODEL)) {
// model = (T) getArguments().getSerializable(EXTRA_FRAGMENT_MODEL);
// }
// if (model == null && savedInstanceState != null) {
// model = (T) savedInstanceState.getSerializable(EXTRA_FRAGMENT_MODEL);
// }
// if (model == null) {
// try {
// if (this instanceof EmptyModelFragment) {
// return;
// }
// ParameterizedType pt = (ParameterizedType) getClass().getGenericSuperclass();
// Class<?> type = (Class<?>) pt.getActualTypeArguments()[0];
// LOG.d("Model Fragment class name", type.getName());
// model = (T) type.newInstance();
// } catch (Exception e) {
// throw new RuntimeException(e.getCause());
// }
// }
// }
//
// public abstract void populateModel();
//
// public abstract void saveModel();
//
// @Override
// public void onPause() {
// super.onPause();
// if (onPauseLintener != null) {
// onPauseLintener.run();
// }
// }
//
// @Override
// public void onResume() {
// super.onResume();
// if (onResumeLintener != null) {
// onResumeLintener.run();
// }
// }
//
// @Override
// public void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// saveModel();
// outState.putSerializable(EXTRA_FRAGMENT_MODEL, model);
// if (outState != null && onSaveInstanceState != null) {
// onSaveInstanceState.onResultRecive(outState);
// }
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// handler.removeCallbacksAndMessages(null);
// }
//
// public Handler getHandler() {
// return handler;
// }
//
// public void setOnPauseLintener(Runnable onPauseLintener) {
// this.onPauseLintener = onPauseLintener;
// }
//
// public void setOnResumeLintener(Runnable onResumeLintener) {
// this.onResumeLintener = onResumeLintener;
// }
//
// public void setOnSaveInstanceState(ResultResponse<Bundle> onSaveInstanceState) {
// this.onSaveInstanceState = onSaveInstanceState;
// }
//
// }
// Path: src/com/foobnix/android/utils/res/ExtraArgument_1.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.foobnix.android.utils.ModelFragment;
package com.foobnix.android.utils.res;
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD })
public @interface ExtraArgument_1 {
|
String value() default ModelFragment.EXTRA_ARGUMENT_1;
|
foobnix/android-universal-utils
|
src/com/foobnix/android/utils/broadcast/LocalBroadcast.java
|
// Path: src/com/foobnix/android/utils/LOG.java
// public class LOG {
// public static boolean isEnable = true;
// public static String TAG = "DEBUG";
// public static String DELIMITER = "|";
//
// public static void printlog(String statement) {
// if (isEnable) {
// Log.d(TAG, statement);
// }
// }
//
// public static void d(Object... statement) {
// if (isEnable) {
// Log.d(TAG, asString(statement));
// }
// }
//
// public static void dMeta(Object... statement) {
// String meta = null;
// StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
// if (stackTrace.length > 3) {
// meta = asString(stackTrace[3].getClassName(), stackTrace[3].getMethodName(), stackTrace[3].getLineNumber());
// }
//
// d(meta, asString(statement));
//
// }
//
// public static void e(Throwable e, Object... statement) {
// if (isEnable) {
// Log.e(TAG, asString(statement), e);
// }
// }
//
// private static String asString(Object... statements) {
// return TxtUtils.join(DELIMITER, statements);
// }
//
// }
|
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v4.content.LocalBroadcastManager;
import com.foobnix.android.utils.LOG;
|
package com.foobnix.android.utils.broadcast;
public class LocalBroadcast {
public static String LOCAL_NOTIFY_ACTION = "LOCAL_NOTIFY_ACTION";
public static IntentFilter INTENT_FILTER = new IntentFilter(LocalBroadcast.LOCAL_NOTIFY_ACTION);
public static void send(Context context, Intent intent) {
|
// Path: src/com/foobnix/android/utils/LOG.java
// public class LOG {
// public static boolean isEnable = true;
// public static String TAG = "DEBUG";
// public static String DELIMITER = "|";
//
// public static void printlog(String statement) {
// if (isEnable) {
// Log.d(TAG, statement);
// }
// }
//
// public static void d(Object... statement) {
// if (isEnable) {
// Log.d(TAG, asString(statement));
// }
// }
//
// public static void dMeta(Object... statement) {
// String meta = null;
// StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
// if (stackTrace.length > 3) {
// meta = asString(stackTrace[3].getClassName(), stackTrace[3].getMethodName(), stackTrace[3].getLineNumber());
// }
//
// d(meta, asString(statement));
//
// }
//
// public static void e(Throwable e, Object... statement) {
// if (isEnable) {
// Log.e(TAG, asString(statement), e);
// }
// }
//
// private static String asString(Object... statements) {
// return TxtUtils.join(DELIMITER, statements);
// }
//
// }
// Path: src/com/foobnix/android/utils/broadcast/LocalBroadcast.java
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v4.content.LocalBroadcastManager;
import com.foobnix.android.utils.LOG;
package com.foobnix.android.utils.broadcast;
public class LocalBroadcast {
public static String LOCAL_NOTIFY_ACTION = "LOCAL_NOTIFY_ACTION";
public static IntentFilter INTENT_FILTER = new IntentFilter(LocalBroadcast.LOCAL_NOTIFY_ACTION);
public static void send(Context context, Intent intent) {
|
LOG.d("LocalBroadcast", "send", intent);
|
foobnix/android-universal-utils
|
src/com/foobnix/android/utils/broadcast/LocalBroadcastFragmentInvisible.java
|
// Path: src/com/foobnix/android/utils/LOG.java
// public class LOG {
// public static boolean isEnable = true;
// public static String TAG = "DEBUG";
// public static String DELIMITER = "|";
//
// public static void printlog(String statement) {
// if (isEnable) {
// Log.d(TAG, statement);
// }
// }
//
// public static void d(Object... statement) {
// if (isEnable) {
// Log.d(TAG, asString(statement));
// }
// }
//
// public static void dMeta(Object... statement) {
// String meta = null;
// StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
// if (stackTrace.length > 3) {
// meta = asString(stackTrace[3].getClassName(), stackTrace[3].getMethodName(), stackTrace[3].getLineNumber());
// }
//
// d(meta, asString(statement));
//
// }
//
// public static void e(Throwable e, Object... statement) {
// if (isEnable) {
// Log.e(TAG, asString(statement), e);
// }
// }
//
// private static String asString(Object... statements) {
// return TxtUtils.join(DELIMITER, statements);
// }
//
// }
//
// Path: src/com/foobnix/android/utils/ResultResponse.java
// public interface ResultResponse<T> {
//
// public boolean onResultRecive(T result);
//
// }
|
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import com.foobnix.android.utils.LOG;
import com.foobnix.android.utils.ResultResponse;
|
package com.foobnix.android.utils.broadcast;
public abstract class LocalBroadcastFragmentInvisible extends Fragment implements ResultResponse<Intent> {
BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
|
// Path: src/com/foobnix/android/utils/LOG.java
// public class LOG {
// public static boolean isEnable = true;
// public static String TAG = "DEBUG";
// public static String DELIMITER = "|";
//
// public static void printlog(String statement) {
// if (isEnable) {
// Log.d(TAG, statement);
// }
// }
//
// public static void d(Object... statement) {
// if (isEnable) {
// Log.d(TAG, asString(statement));
// }
// }
//
// public static void dMeta(Object... statement) {
// String meta = null;
// StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
// if (stackTrace.length > 3) {
// meta = asString(stackTrace[3].getClassName(), stackTrace[3].getMethodName(), stackTrace[3].getLineNumber());
// }
//
// d(meta, asString(statement));
//
// }
//
// public static void e(Throwable e, Object... statement) {
// if (isEnable) {
// Log.e(TAG, asString(statement), e);
// }
// }
//
// private static String asString(Object... statements) {
// return TxtUtils.join(DELIMITER, statements);
// }
//
// }
//
// Path: src/com/foobnix/android/utils/ResultResponse.java
// public interface ResultResponse<T> {
//
// public boolean onResultRecive(T result);
//
// }
// Path: src/com/foobnix/android/utils/broadcast/LocalBroadcastFragmentInvisible.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import com.foobnix.android.utils.LOG;
import com.foobnix.android.utils.ResultResponse;
package com.foobnix.android.utils.broadcast;
public abstract class LocalBroadcastFragmentInvisible extends Fragment implements ResultResponse<Intent> {
BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
|
LOG.d("LocalBroadcastFragmentInvisible", "onReceive", intent);
|
foobnix/android-universal-utils
|
src/com/foobnix/android/utils/res/ExtraArgument_3.java
|
// Path: src/com/foobnix/android/utils/ModelFragment.java
// public abstract class ModelFragment<T extends Serializable> extends Fragment {
// public static final String EXTRA_FRAGMENT_MODEL = "model";
//
// public static final String EXTRA_ARGUMENT_1 = "EXTRA_ARGIMENT_1";
// public static final String EXTRA_ARGUMENT_2 = "EXTRA_ARGIMENT_2";
// public static final String EXTRA_ARGUMENT_3 = "EXTRA_ARGIMENT_3";
//
// private Handler handler;
//
// private Runnable onPauseLintener;
// private Runnable onResumeLintener;
// private ResultResponse<Bundle> onSaveInstanceState;
// protected T model;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// handler = new Handler();
// prepareModelFromArgumentOrBundle(savedInstanceState);
// }
//
// public ModelFragment<T> withBundles(Bundles bundles) {
// setArguments(bundles.build());
// return this;
// }
//
// public ModelFragment<T> withBundle(Bundle bundle) {
// setArguments(bundle);
// return this;
// }
//
// private void prepareModelFromArgumentOrBundle(Bundle savedInstanceState) {
// if (getArguments() != null && getArguments().containsKey(EXTRA_FRAGMENT_MODEL)) {
// model = (T) getArguments().getSerializable(EXTRA_FRAGMENT_MODEL);
// }
// if (model == null && savedInstanceState != null) {
// model = (T) savedInstanceState.getSerializable(EXTRA_FRAGMENT_MODEL);
// }
// if (model == null) {
// try {
// if (this instanceof EmptyModelFragment) {
// return;
// }
// ParameterizedType pt = (ParameterizedType) getClass().getGenericSuperclass();
// Class<?> type = (Class<?>) pt.getActualTypeArguments()[0];
// LOG.d("Model Fragment class name", type.getName());
// model = (T) type.newInstance();
// } catch (Exception e) {
// throw new RuntimeException(e.getCause());
// }
// }
// }
//
// public abstract void populateModel();
//
// public abstract void saveModel();
//
// @Override
// public void onPause() {
// super.onPause();
// if (onPauseLintener != null) {
// onPauseLintener.run();
// }
// }
//
// @Override
// public void onResume() {
// super.onResume();
// if (onResumeLintener != null) {
// onResumeLintener.run();
// }
// }
//
// @Override
// public void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// saveModel();
// outState.putSerializable(EXTRA_FRAGMENT_MODEL, model);
// if (outState != null && onSaveInstanceState != null) {
// onSaveInstanceState.onResultRecive(outState);
// }
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// handler.removeCallbacksAndMessages(null);
// }
//
// public Handler getHandler() {
// return handler;
// }
//
// public void setOnPauseLintener(Runnable onPauseLintener) {
// this.onPauseLintener = onPauseLintener;
// }
//
// public void setOnResumeLintener(Runnable onResumeLintener) {
// this.onResumeLintener = onResumeLintener;
// }
//
// public void setOnSaveInstanceState(ResultResponse<Bundle> onSaveInstanceState) {
// this.onSaveInstanceState = onSaveInstanceState;
// }
//
// }
|
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.foobnix.android.utils.ModelFragment;
|
package com.foobnix.android.utils.res;
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD })
public @interface ExtraArgument_3 {
|
// Path: src/com/foobnix/android/utils/ModelFragment.java
// public abstract class ModelFragment<T extends Serializable> extends Fragment {
// public static final String EXTRA_FRAGMENT_MODEL = "model";
//
// public static final String EXTRA_ARGUMENT_1 = "EXTRA_ARGIMENT_1";
// public static final String EXTRA_ARGUMENT_2 = "EXTRA_ARGIMENT_2";
// public static final String EXTRA_ARGUMENT_3 = "EXTRA_ARGIMENT_3";
//
// private Handler handler;
//
// private Runnable onPauseLintener;
// private Runnable onResumeLintener;
// private ResultResponse<Bundle> onSaveInstanceState;
// protected T model;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// handler = new Handler();
// prepareModelFromArgumentOrBundle(savedInstanceState);
// }
//
// public ModelFragment<T> withBundles(Bundles bundles) {
// setArguments(bundles.build());
// return this;
// }
//
// public ModelFragment<T> withBundle(Bundle bundle) {
// setArguments(bundle);
// return this;
// }
//
// private void prepareModelFromArgumentOrBundle(Bundle savedInstanceState) {
// if (getArguments() != null && getArguments().containsKey(EXTRA_FRAGMENT_MODEL)) {
// model = (T) getArguments().getSerializable(EXTRA_FRAGMENT_MODEL);
// }
// if (model == null && savedInstanceState != null) {
// model = (T) savedInstanceState.getSerializable(EXTRA_FRAGMENT_MODEL);
// }
// if (model == null) {
// try {
// if (this instanceof EmptyModelFragment) {
// return;
// }
// ParameterizedType pt = (ParameterizedType) getClass().getGenericSuperclass();
// Class<?> type = (Class<?>) pt.getActualTypeArguments()[0];
// LOG.d("Model Fragment class name", type.getName());
// model = (T) type.newInstance();
// } catch (Exception e) {
// throw new RuntimeException(e.getCause());
// }
// }
// }
//
// public abstract void populateModel();
//
// public abstract void saveModel();
//
// @Override
// public void onPause() {
// super.onPause();
// if (onPauseLintener != null) {
// onPauseLintener.run();
// }
// }
//
// @Override
// public void onResume() {
// super.onResume();
// if (onResumeLintener != null) {
// onResumeLintener.run();
// }
// }
//
// @Override
// public void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// saveModel();
// outState.putSerializable(EXTRA_FRAGMENT_MODEL, model);
// if (outState != null && onSaveInstanceState != null) {
// onSaveInstanceState.onResultRecive(outState);
// }
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// handler.removeCallbacksAndMessages(null);
// }
//
// public Handler getHandler() {
// return handler;
// }
//
// public void setOnPauseLintener(Runnable onPauseLintener) {
// this.onPauseLintener = onPauseLintener;
// }
//
// public void setOnResumeLintener(Runnable onResumeLintener) {
// this.onResumeLintener = onResumeLintener;
// }
//
// public void setOnSaveInstanceState(ResultResponse<Bundle> onSaveInstanceState) {
// this.onSaveInstanceState = onSaveInstanceState;
// }
//
// }
// Path: src/com/foobnix/android/utils/res/ExtraArgument_3.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.foobnix.android.utils.ModelFragment;
package com.foobnix.android.utils.res;
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD })
public @interface ExtraArgument_3 {
|
String value() default ModelFragment.EXTRA_ARGUMENT_3;
|
foobnix/android-universal-utils
|
src/com/foobnix/android/utils/res/ExtraArgument_2.java
|
// Path: src/com/foobnix/android/utils/ModelFragment.java
// public abstract class ModelFragment<T extends Serializable> extends Fragment {
// public static final String EXTRA_FRAGMENT_MODEL = "model";
//
// public static final String EXTRA_ARGUMENT_1 = "EXTRA_ARGIMENT_1";
// public static final String EXTRA_ARGUMENT_2 = "EXTRA_ARGIMENT_2";
// public static final String EXTRA_ARGUMENT_3 = "EXTRA_ARGIMENT_3";
//
// private Handler handler;
//
// private Runnable onPauseLintener;
// private Runnable onResumeLintener;
// private ResultResponse<Bundle> onSaveInstanceState;
// protected T model;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// handler = new Handler();
// prepareModelFromArgumentOrBundle(savedInstanceState);
// }
//
// public ModelFragment<T> withBundles(Bundles bundles) {
// setArguments(bundles.build());
// return this;
// }
//
// public ModelFragment<T> withBundle(Bundle bundle) {
// setArguments(bundle);
// return this;
// }
//
// private void prepareModelFromArgumentOrBundle(Bundle savedInstanceState) {
// if (getArguments() != null && getArguments().containsKey(EXTRA_FRAGMENT_MODEL)) {
// model = (T) getArguments().getSerializable(EXTRA_FRAGMENT_MODEL);
// }
// if (model == null && savedInstanceState != null) {
// model = (T) savedInstanceState.getSerializable(EXTRA_FRAGMENT_MODEL);
// }
// if (model == null) {
// try {
// if (this instanceof EmptyModelFragment) {
// return;
// }
// ParameterizedType pt = (ParameterizedType) getClass().getGenericSuperclass();
// Class<?> type = (Class<?>) pt.getActualTypeArguments()[0];
// LOG.d("Model Fragment class name", type.getName());
// model = (T) type.newInstance();
// } catch (Exception e) {
// throw new RuntimeException(e.getCause());
// }
// }
// }
//
// public abstract void populateModel();
//
// public abstract void saveModel();
//
// @Override
// public void onPause() {
// super.onPause();
// if (onPauseLintener != null) {
// onPauseLintener.run();
// }
// }
//
// @Override
// public void onResume() {
// super.onResume();
// if (onResumeLintener != null) {
// onResumeLintener.run();
// }
// }
//
// @Override
// public void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// saveModel();
// outState.putSerializable(EXTRA_FRAGMENT_MODEL, model);
// if (outState != null && onSaveInstanceState != null) {
// onSaveInstanceState.onResultRecive(outState);
// }
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// handler.removeCallbacksAndMessages(null);
// }
//
// public Handler getHandler() {
// return handler;
// }
//
// public void setOnPauseLintener(Runnable onPauseLintener) {
// this.onPauseLintener = onPauseLintener;
// }
//
// public void setOnResumeLintener(Runnable onResumeLintener) {
// this.onResumeLintener = onResumeLintener;
// }
//
// public void setOnSaveInstanceState(ResultResponse<Bundle> onSaveInstanceState) {
// this.onSaveInstanceState = onSaveInstanceState;
// }
//
// }
|
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.foobnix.android.utils.ModelFragment;
|
package com.foobnix.android.utils.res;
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD })
public @interface ExtraArgument_2 {
|
// Path: src/com/foobnix/android/utils/ModelFragment.java
// public abstract class ModelFragment<T extends Serializable> extends Fragment {
// public static final String EXTRA_FRAGMENT_MODEL = "model";
//
// public static final String EXTRA_ARGUMENT_1 = "EXTRA_ARGIMENT_1";
// public static final String EXTRA_ARGUMENT_2 = "EXTRA_ARGIMENT_2";
// public static final String EXTRA_ARGUMENT_3 = "EXTRA_ARGIMENT_3";
//
// private Handler handler;
//
// private Runnable onPauseLintener;
// private Runnable onResumeLintener;
// private ResultResponse<Bundle> onSaveInstanceState;
// protected T model;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// handler = new Handler();
// prepareModelFromArgumentOrBundle(savedInstanceState);
// }
//
// public ModelFragment<T> withBundles(Bundles bundles) {
// setArguments(bundles.build());
// return this;
// }
//
// public ModelFragment<T> withBundle(Bundle bundle) {
// setArguments(bundle);
// return this;
// }
//
// private void prepareModelFromArgumentOrBundle(Bundle savedInstanceState) {
// if (getArguments() != null && getArguments().containsKey(EXTRA_FRAGMENT_MODEL)) {
// model = (T) getArguments().getSerializable(EXTRA_FRAGMENT_MODEL);
// }
// if (model == null && savedInstanceState != null) {
// model = (T) savedInstanceState.getSerializable(EXTRA_FRAGMENT_MODEL);
// }
// if (model == null) {
// try {
// if (this instanceof EmptyModelFragment) {
// return;
// }
// ParameterizedType pt = (ParameterizedType) getClass().getGenericSuperclass();
// Class<?> type = (Class<?>) pt.getActualTypeArguments()[0];
// LOG.d("Model Fragment class name", type.getName());
// model = (T) type.newInstance();
// } catch (Exception e) {
// throw new RuntimeException(e.getCause());
// }
// }
// }
//
// public abstract void populateModel();
//
// public abstract void saveModel();
//
// @Override
// public void onPause() {
// super.onPause();
// if (onPauseLintener != null) {
// onPauseLintener.run();
// }
// }
//
// @Override
// public void onResume() {
// super.onResume();
// if (onResumeLintener != null) {
// onResumeLintener.run();
// }
// }
//
// @Override
// public void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// saveModel();
// outState.putSerializable(EXTRA_FRAGMENT_MODEL, model);
// if (outState != null && onSaveInstanceState != null) {
// onSaveInstanceState.onResultRecive(outState);
// }
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
// handler.removeCallbacksAndMessages(null);
// }
//
// public Handler getHandler() {
// return handler;
// }
//
// public void setOnPauseLintener(Runnable onPauseLintener) {
// this.onPauseLintener = onPauseLintener;
// }
//
// public void setOnResumeLintener(Runnable onResumeLintener) {
// this.onResumeLintener = onResumeLintener;
// }
//
// public void setOnSaveInstanceState(ResultResponse<Bundle> onSaveInstanceState) {
// this.onSaveInstanceState = onSaveInstanceState;
// }
//
// }
// Path: src/com/foobnix/android/utils/res/ExtraArgument_2.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.foobnix.android.utils.ModelFragment;
package com.foobnix.android.utils.res;
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD })
public @interface ExtraArgument_2 {
|
String value() default ModelFragment.EXTRA_ARGUMENT_2;
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/controller/StepController.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/StepModel.java
// public interface StepModel {
//
// }
|
import org.n52.sos.importer.model.StepModel;
import javax.swing.JPanel;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.controller;
/**
* @author r.schnuerer@uni-muenster.de
* <br />
* A StepController is the controller for a step in the workflow.
* It holds a model and a <code>StepPanel</code> for its step.
*
*/
public abstract class StepController {
/**
* called when the step controller is newly initialized
* or when the Back button is pressed, loads settings
* from the model and creates the view
*/
public abstract void loadSettings();
/**
* called when the Next button is pressed,
* checks if all information has been collected for this step
*/
public abstract boolean isFinished();
/**
* Sets the missing values in the step model using a method of GUI elements.
* <br />Called when the Next button is pressed and the step is
* finished, saves all settings of this step in the model
* and releases all views.
* <br />Called before {@link #getNextStepController()} in {@link org.n52.sos.importer.controller.BackNextController#nextButtonClicked()}
*/
public abstract void saveSettings();
/**
* returns a short description of this step to be displayed
* on the description panel of the main frame
*/
public abstract String getDescription();
/**
* returns the corresponding step panel
*/
public abstract JPanel getStepPanel();
/**
* Returns the controller for the next step:<br />
* n.? → (n+1).a
* @return a {@link org.n52.sos.importer.controller.StepController}
*/
public abstract StepController getNextStepController();
/**
* checks before loading the settings if this
* step is needed, if not it will be skipped
* @return <code>true</code>, if this step is required by the current
* set-up, else <code>false</code>.
*/
public abstract boolean isNecessary();
/**
* returns a StepController of the same type (n.a → n.b) or
* <b><code>null</code></b> when this step is finished and the next step
* level can be reached (n.a → (n+1).a).
* @return a {@link org.n52.sos.importer.controller.StepController} or
* <b><code>null</code></b>
*/
public abstract StepController getNext();
/**
* contains actions when back button was pressed. Default is do nothing.
*/
public void back() {}
/**
* checks if all conditions for this step controller
* which has been already been displayed are up to date
*/
public boolean isStillValid() { return false; }
/**
* Returns the model of this step
* @return
*/
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/StepModel.java
// public interface StepModel {
//
// }
// Path: wizard/src/main/java/org/n52/sos/importer/controller/StepController.java
import org.n52.sos.importer.model.StepModel;
import javax.swing.JPanel;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.controller;
/**
* @author r.schnuerer@uni-muenster.de
* <br />
* A StepController is the controller for a step in the workflow.
* It holds a model and a <code>StepPanel</code> for its step.
*
*/
public abstract class StepController {
/**
* called when the step controller is newly initialized
* or when the Back button is pressed, loads settings
* from the model and creates the view
*/
public abstract void loadSettings();
/**
* called when the Next button is pressed,
* checks if all information has been collected for this step
*/
public abstract boolean isFinished();
/**
* Sets the missing values in the step model using a method of GUI elements.
* <br />Called when the Next button is pressed and the step is
* finished, saves all settings of this step in the model
* and releases all views.
* <br />Called before {@link #getNextStepController()} in {@link org.n52.sos.importer.controller.BackNextController#nextButtonClicked()}
*/
public abstract void saveSettings();
/**
* returns a short description of this step to be displayed
* on the description panel of the main frame
*/
public abstract String getDescription();
/**
* returns the corresponding step panel
*/
public abstract JPanel getStepPanel();
/**
* Returns the controller for the next step:<br />
* n.? → (n+1).a
* @return a {@link org.n52.sos.importer.controller.StepController}
*/
public abstract StepController getNextStepController();
/**
* checks before loading the settings if this
* step is needed, if not it will be skipped
* @return <code>true</code>, if this step is required by the current
* set-up, else <code>false</code>.
*/
public abstract boolean isNecessary();
/**
* returns a StepController of the same type (n.a → n.b) or
* <b><code>null</code></b> when this step is finished and the next step
* level can be reached (n.a → (n+1).a).
* @return a {@link org.n52.sos.importer.controller.StepController} or
* <b><code>null</code></b>
*/
public abstract StepController getNext();
/**
* contains actions when back button was pressed. Default is do nothing.
*/
public void back() {}
/**
* checks if all conditions for this step controller
* which has been already been displayed are up to date
*/
public boolean isStillValid() { return false; }
/**
* Returns the model of this step
* @return
*/
|
public abstract StepModel getModel();
|
52North/sos-importer
|
wizard/src/test/java/org/n52/sos/importer/model/xml/Step7ModelHandlerTest.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Step7Model.java
// public class Step7Model implements StepModel {
//
// private String sosURL;
//
// private String version;
//
// private String binding;
//
// private File configFile;
//
// private boolean generateOfferingFromSensorName;
//
// private String offering;
//
// private ImportStrategy importStrategy = ImportStrategy.SingleObservation;
//
// private int sendBuffer = 25;
//
// private int hunkSize = 5000;
//
// public Step7Model(final String sosURL,
// final File configFile,
// final boolean generateOfferingFromSensorName,
// final String offering,
// final String version,
// final String binding) {
// this.sosURL = sosURL;
// this.configFile = configFile;
// this.generateOfferingFromSensorName = generateOfferingFromSensorName;
// this.offering = offering;
// this.binding = binding;
// this.version = version;
// }
//
// public Step7Model() {
// this(null,null,true,null,null,null);
// }
//
// public String getSosURL() {
// return sosURL;
// }
//
// public File getConfigFile() {
// return configFile;
// }
//
// public void setConfigFile(final File configFile) {
// this.configFile = configFile;
// }
//
// public void setSosURL(final String sosURL) {
// this.sosURL = sosURL;
// }
//
// public boolean isGenerateOfferingFromSensorName() {
// return generateOfferingFromSensorName;
// }
//
// public void setGenerateOfferingFromSensorName(
// final boolean generateOfferingFromSensorName) {
// this.generateOfferingFromSensorName = generateOfferingFromSensorName;
// }
//
// public String getOffering() {
// return offering;
// }
//
// public void setOffering(final String offering) {
// this.offering = offering;
// }
//
// public String getBinding() {
// return binding;
// }
//
// public void setSosVersion(final String version) {
// this.version = version;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setSosBinding(final String binding) {
// this.binding = binding;
// }
//
// public ImportStrategy getImportStrategy() {
// return importStrategy;
// }
//
// public Step7Model setImportStrategy(final ImportStrategy importStrategy) {
// this.importStrategy = importStrategy;
// return this;
// }
//
// public int getSendBuffer() {
// return sendBuffer;
// }
//
// public Step7Model setSendBuffer(final int sendBuffer) {
// this.sendBuffer = sendBuffer;
// return this;
// }
//
// public int getHunkSize() {
// return hunkSize;
// }
//
// public Step7Model setHunkSize(final int hunkSize) {
// this.hunkSize = hunkSize;
// return this;
// }
//
// }
|
import static org.junit.Assert.assertThat;
import java.util.NoSuchElementException;
import org.junit.Test;
import org.n52.sos.importer.Constants.ImportStrategy;
import org.n52.sos.importer.model.Step7Model;
import org.x52North.sensorweb.sos.importer.x04.KeyDocument.Key;
import org.x52North.sensorweb.sos.importer.x04.KeyDocument.Key.Enum;
import org.x52North.sensorweb.sos.importer.x04.MetadataDocument.Metadata;
import org.x52North.sensorweb.sos.importer.x04.SosImportConfigurationDocument.SosImportConfiguration;
import static java.lang.Boolean.*;
import static org.hamcrest.CoreMatchers.*;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.xml;
/**
* @author <a href="mailto:e.h.juerrens@52north.org">Eike Hinderk Jürrens</a>
*/
public class Step7ModelHandlerTest {
@Test
public void shouldAddBindingIfSetInModel() {
final String binding = "test-binding";
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Step7Model.java
// public class Step7Model implements StepModel {
//
// private String sosURL;
//
// private String version;
//
// private String binding;
//
// private File configFile;
//
// private boolean generateOfferingFromSensorName;
//
// private String offering;
//
// private ImportStrategy importStrategy = ImportStrategy.SingleObservation;
//
// private int sendBuffer = 25;
//
// private int hunkSize = 5000;
//
// public Step7Model(final String sosURL,
// final File configFile,
// final boolean generateOfferingFromSensorName,
// final String offering,
// final String version,
// final String binding) {
// this.sosURL = sosURL;
// this.configFile = configFile;
// this.generateOfferingFromSensorName = generateOfferingFromSensorName;
// this.offering = offering;
// this.binding = binding;
// this.version = version;
// }
//
// public Step7Model() {
// this(null,null,true,null,null,null);
// }
//
// public String getSosURL() {
// return sosURL;
// }
//
// public File getConfigFile() {
// return configFile;
// }
//
// public void setConfigFile(final File configFile) {
// this.configFile = configFile;
// }
//
// public void setSosURL(final String sosURL) {
// this.sosURL = sosURL;
// }
//
// public boolean isGenerateOfferingFromSensorName() {
// return generateOfferingFromSensorName;
// }
//
// public void setGenerateOfferingFromSensorName(
// final boolean generateOfferingFromSensorName) {
// this.generateOfferingFromSensorName = generateOfferingFromSensorName;
// }
//
// public String getOffering() {
// return offering;
// }
//
// public void setOffering(final String offering) {
// this.offering = offering;
// }
//
// public String getBinding() {
// return binding;
// }
//
// public void setSosVersion(final String version) {
// this.version = version;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setSosBinding(final String binding) {
// this.binding = binding;
// }
//
// public ImportStrategy getImportStrategy() {
// return importStrategy;
// }
//
// public Step7Model setImportStrategy(final ImportStrategy importStrategy) {
// this.importStrategy = importStrategy;
// return this;
// }
//
// public int getSendBuffer() {
// return sendBuffer;
// }
//
// public Step7Model setSendBuffer(final int sendBuffer) {
// this.sendBuffer = sendBuffer;
// return this;
// }
//
// public int getHunkSize() {
// return hunkSize;
// }
//
// public Step7Model setHunkSize(final int hunkSize) {
// this.hunkSize = hunkSize;
// return this;
// }
//
// }
// Path: wizard/src/test/java/org/n52/sos/importer/model/xml/Step7ModelHandlerTest.java
import static org.junit.Assert.assertThat;
import java.util.NoSuchElementException;
import org.junit.Test;
import org.n52.sos.importer.Constants.ImportStrategy;
import org.n52.sos.importer.model.Step7Model;
import org.x52North.sensorweb.sos.importer.x04.KeyDocument.Key;
import org.x52North.sensorweb.sos.importer.x04.KeyDocument.Key.Enum;
import org.x52North.sensorweb.sos.importer.x04.MetadataDocument.Metadata;
import org.x52North.sensorweb.sos.importer.x04.SosImportConfigurationDocument.SosImportConfiguration;
import static java.lang.Boolean.*;
import static org.hamcrest.CoreMatchers.*;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.xml;
/**
* @author <a href="mailto:e.h.juerrens@52north.org">Eike Hinderk Jürrens</a>
*/
public class Step7ModelHandlerTest {
@Test
public void shouldAddBindingIfSetInModel() {
final String binding = "test-binding";
|
final Step7Model stepModel = new Step7Model(null, null, false, null, null, binding);
|
52North/sos-importer
|
feeder/src/main/java/org/n52/sos/importer/feeder/model/requests/RegisterSensor.java
|
// Path: feeder/src/main/java/org/n52/sos/importer/feeder/model/ObservedProperty.java
// public class ObservedProperty extends Resource {
// public ObservedProperty(String name, String uri) {
// super(name, uri);
// }
// }
|
import org.n52.sos.importer.feeder.model.ObservedProperty;
import java.util.Collection;
import java.util.Map;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.feeder.model.requests;
/**
* Holds all information for the RegisterSensor request
* @author Raimund
* @author <a href="mailto:e.h.juerrens@52north.org">Eike Hinderk Jürrens</a>
*/
public class RegisterSensor {
private final InsertObservation io;
|
// Path: feeder/src/main/java/org/n52/sos/importer/feeder/model/ObservedProperty.java
// public class ObservedProperty extends Resource {
// public ObservedProperty(String name, String uri) {
// super(name, uri);
// }
// }
// Path: feeder/src/main/java/org/n52/sos/importer/feeder/model/requests/RegisterSensor.java
import org.n52.sos.importer.feeder.model.ObservedProperty;
import java.util.Collection;
import java.util.Map;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.feeder.model.requests;
/**
* Holds all information for the RegisterSensor request
* @author Raimund
* @author <a href="mailto:e.h.juerrens@52north.org">Eike Hinderk Jürrens</a>
*/
public class RegisterSensor {
private final InsertObservation io;
|
private final Map<ObservedProperty, String> measuredValueTypes;
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Month.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingMonthPanel.java
// public class MissingMonthPanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel monthLabel;
//
// private SpinnerNumberModel monthModel = new SpinnerNumberModel(1, 1, 12, 1);
// private JSpinner monthSpinner = new JSpinner(monthModel);
//
// public MissingMonthPanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.monthLabel = new JLabel(Lang.l().month() + ": ");
// this.add(monthLabel);
// this.add(monthSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setMonth(new Month(monthModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setMonth(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new Month(monthModel.getNumber().intValue());
// }
//
// @Override
// public void setMissingComponent(Component c) {
// monthModel.setValue(((Month)c).getValue());
// }
// }
|
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingMonthPanel;
import java.util.GregorianCalendar;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Month extends DateAndTimeComponent {
public Month(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Month(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.MONTH;
}
@Override
public String toString() {
return "Month" + super.toString();
}
@Override
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingMonthPanel.java
// public class MissingMonthPanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel monthLabel;
//
// private SpinnerNumberModel monthModel = new SpinnerNumberModel(1, 1, 12, 1);
// private JSpinner monthSpinner = new JSpinner(monthModel);
//
// public MissingMonthPanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.monthLabel = new JLabel(Lang.l().month() + ": ");
// this.add(monthLabel);
// this.add(monthSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setMonth(new Month(monthModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setMonth(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new Month(monthModel.getNumber().intValue());
// }
//
// @Override
// public void setMissingComponent(Component c) {
// monthModel.setValue(((Month)c).getValue());
// }
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Month.java
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingMonthPanel;
import java.util.GregorianCalendar;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Month extends DateAndTimeComponent {
public Month(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Month(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.MONTH;
}
@Override
public String toString() {
return "Month" + super.toString();
}
@Override
|
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Month.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingMonthPanel.java
// public class MissingMonthPanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel monthLabel;
//
// private SpinnerNumberModel monthModel = new SpinnerNumberModel(1, 1, 12, 1);
// private JSpinner monthSpinner = new JSpinner(monthModel);
//
// public MissingMonthPanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.monthLabel = new JLabel(Lang.l().month() + ": ");
// this.add(monthLabel);
// this.add(monthSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setMonth(new Month(monthModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setMonth(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new Month(monthModel.getNumber().intValue());
// }
//
// @Override
// public void setMissingComponent(Component c) {
// monthModel.setValue(((Month)c).getValue());
// }
// }
|
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingMonthPanel;
import java.util.GregorianCalendar;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Month extends DateAndTimeComponent {
public Month(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Month(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.MONTH;
}
@Override
public String toString() {
return "Month" + super.toString();
}
@Override
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingMonthPanel.java
// public class MissingMonthPanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel monthLabel;
//
// private SpinnerNumberModel monthModel = new SpinnerNumberModel(1, 1, 12, 1);
// private JSpinner monthSpinner = new JSpinner(monthModel);
//
// public MissingMonthPanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.monthLabel = new JLabel(Lang.l().month() + ": ");
// this.add(monthLabel);
// this.add(monthSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setMonth(new Month(monthModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setMonth(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new Month(monthModel.getNumber().intValue());
// }
//
// @Override
// public void setMissingComponent(Component c) {
// monthModel.setValue(((Month)c).getValue());
// }
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Month.java
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingMonthPanel;
import java.util.GregorianCalendar;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Month extends DateAndTimeComponent {
public Month(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Month(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.MONTH;
}
@Override
public String toString() {
return "Month" + super.toString();
}
@Override
|
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Month.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingMonthPanel.java
// public class MissingMonthPanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel monthLabel;
//
// private SpinnerNumberModel monthModel = new SpinnerNumberModel(1, 1, 12, 1);
// private JSpinner monthSpinner = new JSpinner(monthModel);
//
// public MissingMonthPanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.monthLabel = new JLabel(Lang.l().month() + ": ");
// this.add(monthLabel);
// this.add(monthSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setMonth(new Month(monthModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setMonth(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new Month(monthModel.getNumber().intValue());
// }
//
// @Override
// public void setMissingComponent(Component c) {
// monthModel.setValue(((Month)c).getValue());
// }
// }
|
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingMonthPanel;
import java.util.GregorianCalendar;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Month extends DateAndTimeComponent {
public Month(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Month(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.MONTH;
}
@Override
public String toString() {
return "Month" + super.toString();
}
@Override
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingMonthPanel.java
// public class MissingMonthPanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel monthLabel;
//
// private SpinnerNumberModel monthModel = new SpinnerNumberModel(1, 1, 12, 1);
// private JSpinner monthSpinner = new JSpinner(monthModel);
//
// public MissingMonthPanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.monthLabel = new JLabel(Lang.l().month() + ": ");
// this.add(monthLabel);
// this.add(monthSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setMonth(new Month(monthModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setMonth(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new Month(monthModel.getNumber().intValue());
// }
//
// @Override
// public void setMissingComponent(Component c) {
// monthModel.setValue(((Month)c).getValue());
// }
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Month.java
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingMonthPanel;
import java.util.GregorianCalendar;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Month extends DateAndTimeComponent {
public Month(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Month(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.MONTH;
}
@Override
public String toString() {
return "Month" + super.toString();
}
@Override
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
return new MissingMonthPanel((DateAndTime)c);
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Time.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/model/Component.java
// public abstract class Component {
//
// /**
// * returns a panel to complete the component
// * in case it is missing
// * @param c
// * @return
// */
// public abstract MissingComponentPanel getMissingComponentPanel(Combination c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
|
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingTimePanel;
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.Component;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
/**
* aggregates hour, minute and second
* @author Raimund
*/
public class Time extends Component {
private Hour hour;
private Minute minute;
private Second second;
public void setHour(Hour hour) {
this.hour = hour;
}
public Hour getHour() {
return hour;
}
public void setMinute(Minute minute) {
this.minute = minute;
}
public Minute getMinute() {
return minute;
}
public void setSecond(Second second) {
this.second = second;
}
public Second getSecond() {
return second;
}
@Override
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/model/Component.java
// public abstract class Component {
//
// /**
// * returns a panel to complete the component
// * in case it is missing
// * @param c
// * @return
// */
// public abstract MissingComponentPanel getMissingComponentPanel(Combination c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Time.java
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingTimePanel;
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.Component;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
/**
* aggregates hour, minute and second
* @author Raimund
*/
public class Time extends Component {
private Hour hour;
private Minute minute;
private Second second;
public void setHour(Hour hour) {
this.hour = hour;
}
public Hour getHour() {
return hour;
}
public void setMinute(Minute minute) {
this.minute = minute;
}
public Minute getMinute() {
return minute;
}
public void setSecond(Second second) {
this.second = second;
}
public Second getSecond() {
return second;
}
@Override
|
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Time.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/model/Component.java
// public abstract class Component {
//
// /**
// * returns a panel to complete the component
// * in case it is missing
// * @param c
// * @return
// */
// public abstract MissingComponentPanel getMissingComponentPanel(Combination c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
|
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingTimePanel;
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.Component;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
/**
* aggregates hour, minute and second
* @author Raimund
*/
public class Time extends Component {
private Hour hour;
private Minute minute;
private Second second;
public void setHour(Hour hour) {
this.hour = hour;
}
public Hour getHour() {
return hour;
}
public void setMinute(Minute minute) {
this.minute = minute;
}
public Minute getMinute() {
return minute;
}
public void setSecond(Second second) {
this.second = second;
}
public Second getSecond() {
return second;
}
@Override
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/model/Component.java
// public abstract class Component {
//
// /**
// * returns a panel to complete the component
// * in case it is missing
// * @param c
// * @return
// */
// public abstract MissingComponentPanel getMissingComponentPanel(Combination c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Time.java
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingTimePanel;
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.Component;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
/**
* aggregates hour, minute and second
* @author Raimund
*/
public class Time extends Component {
private Hour hour;
private Minute minute;
private Second second;
public void setHour(Hour hour) {
this.hour = hour;
}
public Hour getHour() {
return hour;
}
public void setMinute(Minute minute) {
this.minute = minute;
}
public Minute getMinute() {
return minute;
}
public void setSecond(Second second) {
this.second = second;
}
public Second getSecond() {
return second;
}
@Override
|
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Component.java
// public abstract class Component {
//
// /**
// * returns a panel to complete the component
// * in case it is missing
// * @param c
// * @return
// */
// public abstract MissingComponentPanel getMissingComponentPanel(Combination c);
// }
|
import org.n52.sos.importer.model.Component;
import javax.swing.JPanel;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.view;
/**
* Represents the view of a component (e.g. a day) which
* is not available in the CSV file; therefore, it has to
* be chosen manually
* @author Raimund Schnürer
*
*/
public abstract class MissingComponentPanel extends JPanel {
private static final long serialVersionUID = 1L;
/**
* Allocate values of the missing component
*/
public abstract void assignValues();
/**
* Release values of the missing component
*/
public abstract void unassignValues();
/**
* Checks if all values are in the defined range
* of this component; returns false, if not
* @return <b>true</b>, if all given values are in allowed ranges.<br />
* <b>false</b>, if not.
*/
public abstract boolean checkValues();
/**
* Returns the missing component
*/
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Component.java
// public abstract class Component {
//
// /**
// * returns a panel to complete the component
// * in case it is missing
// * @param c
// * @return
// */
// public abstract MissingComponentPanel getMissingComponentPanel(Combination c);
// }
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
import org.n52.sos.importer.model.Component;
import javax.swing.JPanel;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.view;
/**
* Represents the view of a component (e.g. a day) which
* is not available in the CSV file; therefore, it has to
* be chosen manually
* @author Raimund Schnürer
*
*/
public abstract class MissingComponentPanel extends JPanel {
private static final long serialVersionUID = 1L;
/**
* Allocate values of the missing component
*/
public abstract void assignValues();
/**
* Release values of the missing component
*/
public abstract void unassignValues();
/**
* Checks if all values are in the defined range
* of this component; returns false, if not
* @return <b>true</b>, if all given values are in allowed ranges.<br />
* <b>false</b>, if not.
*/
public abstract boolean checkValues();
/**
* Returns the missing component
*/
|
public abstract Component getMissingComponent();
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/position/EPSGCode.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/model/Component.java
// public abstract class Component {
//
// /**
// * returns a panel to complete the component
// * in case it is missing
// * @param c
// * @return
// */
// public abstract MissingComponentPanel getMissingComponentPanel(Combination c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
|
import org.n52.sos.importer.model.table.Cell;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.position.MissingEPSGCodePanel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.Component;
|
}
}
/**
* colors this particular component
*/
public void mark() {
if (tableElement != null) {
tableElement.mark();
}
}
@Override
public String toString() {
if (getTableElement() == null) {
return "EPSG-Code " + getValue();
} else {
return "EPSG-Code " + getTableElement();
}
}
public void setPattern(final String pattern) {
this.pattern = pattern;
}
public String getPattern() {
return pattern;
}
@Override
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/model/Component.java
// public abstract class Component {
//
// /**
// * returns a panel to complete the component
// * in case it is missing
// * @param c
// * @return
// */
// public abstract MissingComponentPanel getMissingComponentPanel(Combination c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/position/EPSGCode.java
import org.n52.sos.importer.model.table.Cell;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.position.MissingEPSGCodePanel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.Component;
}
}
/**
* colors this particular component
*/
public void mark() {
if (tableElement != null) {
tableElement.mark();
}
}
@Override
public String toString() {
if (getTableElement() == null) {
return "EPSG-Code " + getValue();
} else {
return "EPSG-Code " + getTableElement();
}
}
public void setPattern(final String pattern) {
this.pattern = pattern;
}
public String getPattern() {
return pattern;
}
@Override
|
public MissingComponentPanel getMissingComponentPanel(final Combination c) {
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/position/EPSGCode.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/model/Component.java
// public abstract class Component {
//
// /**
// * returns a panel to complete the component
// * in case it is missing
// * @param c
// * @return
// */
// public abstract MissingComponentPanel getMissingComponentPanel(Combination c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
|
import org.n52.sos.importer.model.table.Cell;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.position.MissingEPSGCodePanel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.Component;
|
}
}
/**
* colors this particular component
*/
public void mark() {
if (tableElement != null) {
tableElement.mark();
}
}
@Override
public String toString() {
if (getTableElement() == null) {
return "EPSG-Code " + getValue();
} else {
return "EPSG-Code " + getTableElement();
}
}
public void setPattern(final String pattern) {
this.pattern = pattern;
}
public String getPattern() {
return pattern;
}
@Override
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/model/Component.java
// public abstract class Component {
//
// /**
// * returns a panel to complete the component
// * in case it is missing
// * @param c
// * @return
// */
// public abstract MissingComponentPanel getMissingComponentPanel(Combination c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/position/EPSGCode.java
import org.n52.sos.importer.model.table.Cell;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.position.MissingEPSGCodePanel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.Component;
}
}
/**
* colors this particular component
*/
public void mark() {
if (tableElement != null) {
tableElement.mark();
}
}
@Override
public String toString() {
if (getTableElement() == null) {
return "EPSG-Code " + getValue();
} else {
return "EPSG-Code " + getTableElement();
}
}
public void setPattern(final String pattern) {
this.pattern = pattern;
}
public String getPattern() {
return pattern;
}
@Override
|
public MissingComponentPanel getMissingComponentPanel(final Combination c) {
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/TimeZone.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingTimeZonePanel.java
// public class MissingTimeZonePanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel timeZoneLabel;
//
// private SpinnerNumberModel timeZoneModel = new SpinnerNumberModel(0, -12, 12, 1);
// private JSpinner timeZoneSpinner = new JSpinner(timeZoneModel);
//
// public MissingTimeZonePanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// timeZoneSpinner.setToolTipText(ToolTips.get(ToolTips.TIME_ZONE));
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.timeZoneLabel = new JLabel(Lang.l().timeZone() + ": ");
// this.add(timeZoneLabel);
// this.add(timeZoneSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setTimeZone(new TimeZone(timeZoneModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setTimeZone(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new TimeZone(timeZoneModel.getNumber().intValue());
// }
//
// @Override
// public void setMissingComponent(Component c) {
// timeZoneModel.setValue(((TimeZone)c).getValue());
// }
// }
|
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingTimeZonePanel;
import java.util.GregorianCalendar;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
/**
* UTC offset
* @author Raimund
*
*/
public class TimeZone extends DateAndTimeComponent {
public TimeZone(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public TimeZone(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.ZONE_OFFSET;
}
@Override
public String toString() {
return "Timezone" + super.toString();
}
@Override
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingTimeZonePanel.java
// public class MissingTimeZonePanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel timeZoneLabel;
//
// private SpinnerNumberModel timeZoneModel = new SpinnerNumberModel(0, -12, 12, 1);
// private JSpinner timeZoneSpinner = new JSpinner(timeZoneModel);
//
// public MissingTimeZonePanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// timeZoneSpinner.setToolTipText(ToolTips.get(ToolTips.TIME_ZONE));
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.timeZoneLabel = new JLabel(Lang.l().timeZone() + ": ");
// this.add(timeZoneLabel);
// this.add(timeZoneSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setTimeZone(new TimeZone(timeZoneModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setTimeZone(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new TimeZone(timeZoneModel.getNumber().intValue());
// }
//
// @Override
// public void setMissingComponent(Component c) {
// timeZoneModel.setValue(((TimeZone)c).getValue());
// }
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/TimeZone.java
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingTimeZonePanel;
import java.util.GregorianCalendar;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
/**
* UTC offset
* @author Raimund
*
*/
public class TimeZone extends DateAndTimeComponent {
public TimeZone(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public TimeZone(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.ZONE_OFFSET;
}
@Override
public String toString() {
return "Timezone" + super.toString();
}
@Override
|
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/TimeZone.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingTimeZonePanel.java
// public class MissingTimeZonePanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel timeZoneLabel;
//
// private SpinnerNumberModel timeZoneModel = new SpinnerNumberModel(0, -12, 12, 1);
// private JSpinner timeZoneSpinner = new JSpinner(timeZoneModel);
//
// public MissingTimeZonePanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// timeZoneSpinner.setToolTipText(ToolTips.get(ToolTips.TIME_ZONE));
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.timeZoneLabel = new JLabel(Lang.l().timeZone() + ": ");
// this.add(timeZoneLabel);
// this.add(timeZoneSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setTimeZone(new TimeZone(timeZoneModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setTimeZone(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new TimeZone(timeZoneModel.getNumber().intValue());
// }
//
// @Override
// public void setMissingComponent(Component c) {
// timeZoneModel.setValue(((TimeZone)c).getValue());
// }
// }
|
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingTimeZonePanel;
import java.util.GregorianCalendar;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
/**
* UTC offset
* @author Raimund
*
*/
public class TimeZone extends DateAndTimeComponent {
public TimeZone(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public TimeZone(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.ZONE_OFFSET;
}
@Override
public String toString() {
return "Timezone" + super.toString();
}
@Override
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingTimeZonePanel.java
// public class MissingTimeZonePanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel timeZoneLabel;
//
// private SpinnerNumberModel timeZoneModel = new SpinnerNumberModel(0, -12, 12, 1);
// private JSpinner timeZoneSpinner = new JSpinner(timeZoneModel);
//
// public MissingTimeZonePanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// timeZoneSpinner.setToolTipText(ToolTips.get(ToolTips.TIME_ZONE));
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.timeZoneLabel = new JLabel(Lang.l().timeZone() + ": ");
// this.add(timeZoneLabel);
// this.add(timeZoneSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setTimeZone(new TimeZone(timeZoneModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setTimeZone(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new TimeZone(timeZoneModel.getNumber().intValue());
// }
//
// @Override
// public void setMissingComponent(Component c) {
// timeZoneModel.setValue(((TimeZone)c).getValue());
// }
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/TimeZone.java
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingTimeZonePanel;
import java.util.GregorianCalendar;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
/**
* UTC offset
* @author Raimund
*
*/
public class TimeZone extends DateAndTimeComponent {
public TimeZone(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public TimeZone(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.ZONE_OFFSET;
}
@Override
public String toString() {
return "Timezone" + super.toString();
}
@Override
|
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/TimeZone.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingTimeZonePanel.java
// public class MissingTimeZonePanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel timeZoneLabel;
//
// private SpinnerNumberModel timeZoneModel = new SpinnerNumberModel(0, -12, 12, 1);
// private JSpinner timeZoneSpinner = new JSpinner(timeZoneModel);
//
// public MissingTimeZonePanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// timeZoneSpinner.setToolTipText(ToolTips.get(ToolTips.TIME_ZONE));
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.timeZoneLabel = new JLabel(Lang.l().timeZone() + ": ");
// this.add(timeZoneLabel);
// this.add(timeZoneSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setTimeZone(new TimeZone(timeZoneModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setTimeZone(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new TimeZone(timeZoneModel.getNumber().intValue());
// }
//
// @Override
// public void setMissingComponent(Component c) {
// timeZoneModel.setValue(((TimeZone)c).getValue());
// }
// }
|
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingTimeZonePanel;
import java.util.GregorianCalendar;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
/**
* UTC offset
* @author Raimund
*
*/
public class TimeZone extends DateAndTimeComponent {
public TimeZone(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public TimeZone(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.ZONE_OFFSET;
}
@Override
public String toString() {
return "Timezone" + super.toString();
}
@Override
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingTimeZonePanel.java
// public class MissingTimeZonePanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel timeZoneLabel;
//
// private SpinnerNumberModel timeZoneModel = new SpinnerNumberModel(0, -12, 12, 1);
// private JSpinner timeZoneSpinner = new JSpinner(timeZoneModel);
//
// public MissingTimeZonePanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// timeZoneSpinner.setToolTipText(ToolTips.get(ToolTips.TIME_ZONE));
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.timeZoneLabel = new JLabel(Lang.l().timeZone() + ": ");
// this.add(timeZoneLabel);
// this.add(timeZoneSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setTimeZone(new TimeZone(timeZoneModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setTimeZone(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new TimeZone(timeZoneModel.getNumber().intValue());
// }
//
// @Override
// public void setMissingComponent(Component c) {
// timeZoneModel.setValue(((TimeZone)c).getValue());
// }
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/TimeZone.java
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingTimeZonePanel;
import java.util.GregorianCalendar;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
/**
* UTC offset
* @author Raimund
*
*/
public class TimeZone extends DateAndTimeComponent {
public TimeZone(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public TimeZone(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.ZONE_OFFSET;
}
@Override
public String toString() {
return "Timezone" + super.toString();
}
@Override
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
return new MissingTimeZonePanel((DateAndTime)c);
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Minute.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingMinutePanel.java
// public class MissingMinutePanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel minuteLabel;
//
// private SpinnerNumberModel minuteModel = new SpinnerNumberModel(0, 0, 59, 1);
// private JSpinner minuteSpinner = new JSpinner(minuteModel);
//
// public MissingMinutePanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.minuteLabel = new JLabel(Lang.l().minutes() + ": ");
// this.add(minuteLabel);
// this.add(minuteSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setMinute(new Minute(minuteModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setMinute(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new Minute(minuteModel.getNumber().intValue());
// }
//
// @Override
// public void setMissingComponent(Component c) {
// minuteModel.setValue(((Minute)c).getValue());
// }
// }
|
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingMinutePanel;
import java.util.GregorianCalendar;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Minute extends DateAndTimeComponent {
public Minute(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Minute(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.MINUTE;
}
@Override
public String toString() {
return "Minute" + super.toString();
}
@Override
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingMinutePanel.java
// public class MissingMinutePanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel minuteLabel;
//
// private SpinnerNumberModel minuteModel = new SpinnerNumberModel(0, 0, 59, 1);
// private JSpinner minuteSpinner = new JSpinner(minuteModel);
//
// public MissingMinutePanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.minuteLabel = new JLabel(Lang.l().minutes() + ": ");
// this.add(minuteLabel);
// this.add(minuteSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setMinute(new Minute(minuteModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setMinute(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new Minute(minuteModel.getNumber().intValue());
// }
//
// @Override
// public void setMissingComponent(Component c) {
// minuteModel.setValue(((Minute)c).getValue());
// }
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Minute.java
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingMinutePanel;
import java.util.GregorianCalendar;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Minute extends DateAndTimeComponent {
public Minute(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Minute(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.MINUTE;
}
@Override
public String toString() {
return "Minute" + super.toString();
}
@Override
|
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Minute.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingMinutePanel.java
// public class MissingMinutePanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel minuteLabel;
//
// private SpinnerNumberModel minuteModel = new SpinnerNumberModel(0, 0, 59, 1);
// private JSpinner minuteSpinner = new JSpinner(minuteModel);
//
// public MissingMinutePanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.minuteLabel = new JLabel(Lang.l().minutes() + ": ");
// this.add(minuteLabel);
// this.add(minuteSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setMinute(new Minute(minuteModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setMinute(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new Minute(minuteModel.getNumber().intValue());
// }
//
// @Override
// public void setMissingComponent(Component c) {
// minuteModel.setValue(((Minute)c).getValue());
// }
// }
|
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingMinutePanel;
import java.util.GregorianCalendar;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Minute extends DateAndTimeComponent {
public Minute(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Minute(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.MINUTE;
}
@Override
public String toString() {
return "Minute" + super.toString();
}
@Override
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingMinutePanel.java
// public class MissingMinutePanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel minuteLabel;
//
// private SpinnerNumberModel minuteModel = new SpinnerNumberModel(0, 0, 59, 1);
// private JSpinner minuteSpinner = new JSpinner(minuteModel);
//
// public MissingMinutePanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.minuteLabel = new JLabel(Lang.l().minutes() + ": ");
// this.add(minuteLabel);
// this.add(minuteSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setMinute(new Minute(minuteModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setMinute(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new Minute(minuteModel.getNumber().intValue());
// }
//
// @Override
// public void setMissingComponent(Component c) {
// minuteModel.setValue(((Minute)c).getValue());
// }
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Minute.java
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingMinutePanel;
import java.util.GregorianCalendar;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Minute extends DateAndTimeComponent {
public Minute(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Minute(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.MINUTE;
}
@Override
public String toString() {
return "Minute" + super.toString();
}
@Override
|
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Minute.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingMinutePanel.java
// public class MissingMinutePanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel minuteLabel;
//
// private SpinnerNumberModel minuteModel = new SpinnerNumberModel(0, 0, 59, 1);
// private JSpinner minuteSpinner = new JSpinner(minuteModel);
//
// public MissingMinutePanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.minuteLabel = new JLabel(Lang.l().minutes() + ": ");
// this.add(minuteLabel);
// this.add(minuteSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setMinute(new Minute(minuteModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setMinute(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new Minute(minuteModel.getNumber().intValue());
// }
//
// @Override
// public void setMissingComponent(Component c) {
// minuteModel.setValue(((Minute)c).getValue());
// }
// }
|
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingMinutePanel;
import java.util.GregorianCalendar;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Minute extends DateAndTimeComponent {
public Minute(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Minute(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.MINUTE;
}
@Override
public String toString() {
return "Minute" + super.toString();
}
@Override
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingMinutePanel.java
// public class MissingMinutePanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel minuteLabel;
//
// private SpinnerNumberModel minuteModel = new SpinnerNumberModel(0, 0, 59, 1);
// private JSpinner minuteSpinner = new JSpinner(minuteModel);
//
// public MissingMinutePanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.minuteLabel = new JLabel(Lang.l().minutes() + ": ");
// this.add(minuteLabel);
// this.add(minuteSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setMinute(new Minute(minuteModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setMinute(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new Minute(minuteModel.getNumber().intValue());
// }
//
// @Override
// public void setMissingComponent(Component c) {
// minuteModel.setValue(((Minute)c).getValue());
// }
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Minute.java
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingMinutePanel;
import java.util.GregorianCalendar;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Minute extends DateAndTimeComponent {
public Minute(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Minute(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.MINUTE;
}
@Override
public String toString() {
return "Minute" + super.toString();
}
@Override
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
return new MissingMinutePanel((DateAndTime)c);
|
52North/sos-importer
|
wizard/src/test/java/org/n52/sos/importer/test/Step3TestPositionInTable.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/controller/MainController.java
// public class MainController {
//
// private static MainController instance = null;
//
// private final MainFrame mainFrame = new MainFrame(this);
//
// private final Model xmlModel;
//
// private MainController() {
// //
// // Load the tooltips
// ToolTips.loadSettings();
// //
// // load the configuration for the ComboBoxItems at startup
// // first call to getInstance() calls ComboBoxItems.load()
// ComboBoxItems.getInstance();
// //
// // init xmlmodel TODO load from configuration
// xmlModel = new Model();
// }
//
// public static MainController getInstance() {
// if (MainController.instance == null) {
// MainController.instance = new MainController();
// }
// return MainController.instance;
// }
//
// /**
// * Method is called each time a button ("Next","Back", or "Finish") is clicked
// * in the GUI.
// * @param stepController
// */
// public void setStepController(final StepController stepController) {
// final DescriptionPanel descP = DescriptionPanel.getInstance();
// final BackNextModel bNM = BackNextController.getInstance().getModel();
// //
// descP.setText(stepController.getDescription());
// stepController.loadSettings();
// mainFrame.setStepPanel(stepController.getStepPanel());
// xmlModel.registerProvider(stepController.getModel());
// bNM.setCurrentStepController(stepController);
// }
//
// public void updateModel() {
// xmlModel.updateModel();
// }
//
// public boolean removeProvider(final StepModel sm) {
// return xmlModel.removeProvider(sm);
// }
//
// public boolean registerProvider(final StepModel sm) {
// return xmlModel.registerProvider(sm);
// }
//
// public void exit() {
// mainFrame.showExitDialog();
// }
//
// public void updateTitle(final String csvFilePath) {
// mainFrame.updateTitle(csvFilePath);
// }
//
// public boolean saveModel(final File file) throws IOException {
// return xmlModel.save(file);
// }
//
// public String getFilename() {
// return xmlModel.getFileName();
// }
// }
|
import org.n52.sos.importer.controller.Step3Controller;
import org.n52.sos.importer.controller.TableController;
import org.n52.sos.importer.Constants;
import org.n52.sos.importer.controller.MainController;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.test;
public class Step3TestPositionInTable {
public static void main(final String[] args) {
|
// Path: wizard/src/main/java/org/n52/sos/importer/controller/MainController.java
// public class MainController {
//
// private static MainController instance = null;
//
// private final MainFrame mainFrame = new MainFrame(this);
//
// private final Model xmlModel;
//
// private MainController() {
// //
// // Load the tooltips
// ToolTips.loadSettings();
// //
// // load the configuration for the ComboBoxItems at startup
// // first call to getInstance() calls ComboBoxItems.load()
// ComboBoxItems.getInstance();
// //
// // init xmlmodel TODO load from configuration
// xmlModel = new Model();
// }
//
// public static MainController getInstance() {
// if (MainController.instance == null) {
// MainController.instance = new MainController();
// }
// return MainController.instance;
// }
//
// /**
// * Method is called each time a button ("Next","Back", or "Finish") is clicked
// * in the GUI.
// * @param stepController
// */
// public void setStepController(final StepController stepController) {
// final DescriptionPanel descP = DescriptionPanel.getInstance();
// final BackNextModel bNM = BackNextController.getInstance().getModel();
// //
// descP.setText(stepController.getDescription());
// stepController.loadSettings();
// mainFrame.setStepPanel(stepController.getStepPanel());
// xmlModel.registerProvider(stepController.getModel());
// bNM.setCurrentStepController(stepController);
// }
//
// public void updateModel() {
// xmlModel.updateModel();
// }
//
// public boolean removeProvider(final StepModel sm) {
// return xmlModel.removeProvider(sm);
// }
//
// public boolean registerProvider(final StepModel sm) {
// return xmlModel.registerProvider(sm);
// }
//
// public void exit() {
// mainFrame.showExitDialog();
// }
//
// public void updateTitle(final String csvFilePath) {
// mainFrame.updateTitle(csvFilePath);
// }
//
// public boolean saveModel(final File file) throws IOException {
// return xmlModel.save(file);
// }
//
// public String getFilename() {
// return xmlModel.getFileName();
// }
// }
// Path: wizard/src/test/java/org/n52/sos/importer/test/Step3TestPositionInTable.java
import org.n52.sos.importer.controller.Step3Controller;
import org.n52.sos.importer.controller.TableController;
import org.n52.sos.importer.Constants;
import org.n52.sos.importer.controller.MainController;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.test;
public class Step3TestPositionInTable {
public static void main(final String[] args) {
|
final MainController f = MainController.getInstance();
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Year.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingYearPanel.java
// public class MissingYearPanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel yearLabel;
//
// private SpinnerNumberModel yearModel = new SpinnerNumberModel(2011, 1900, 2100, 1);
// private JSpinner yearSpinner = new JSpinner(yearModel);
//
// public MissingYearPanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.yearLabel = new JLabel(Lang.l().year() + ": ");
// this.add(yearLabel);
// yearSpinner.setEditor(new JSpinner.NumberEditor(yearSpinner, "#"));
// this.add(yearSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setYear(new Year(yearModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setYear(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new Year(yearModel.getNumber().intValue());
// }
//
// public void setMissingComponent(Component c) {
// yearModel.setValue(((Year)c).getValue());
// }
// }
|
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingYearPanel;
import java.util.GregorianCalendar;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Year extends DateAndTimeComponent {
public Year(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Year(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.YEAR;
}
@Override
public String toString() {
return "Year" + super.toString();
}
@Override
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingYearPanel.java
// public class MissingYearPanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel yearLabel;
//
// private SpinnerNumberModel yearModel = new SpinnerNumberModel(2011, 1900, 2100, 1);
// private JSpinner yearSpinner = new JSpinner(yearModel);
//
// public MissingYearPanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.yearLabel = new JLabel(Lang.l().year() + ": ");
// this.add(yearLabel);
// yearSpinner.setEditor(new JSpinner.NumberEditor(yearSpinner, "#"));
// this.add(yearSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setYear(new Year(yearModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setYear(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new Year(yearModel.getNumber().intValue());
// }
//
// public void setMissingComponent(Component c) {
// yearModel.setValue(((Year)c).getValue());
// }
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Year.java
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingYearPanel;
import java.util.GregorianCalendar;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Year extends DateAndTimeComponent {
public Year(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Year(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.YEAR;
}
@Override
public String toString() {
return "Year" + super.toString();
}
@Override
|
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Year.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingYearPanel.java
// public class MissingYearPanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel yearLabel;
//
// private SpinnerNumberModel yearModel = new SpinnerNumberModel(2011, 1900, 2100, 1);
// private JSpinner yearSpinner = new JSpinner(yearModel);
//
// public MissingYearPanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.yearLabel = new JLabel(Lang.l().year() + ": ");
// this.add(yearLabel);
// yearSpinner.setEditor(new JSpinner.NumberEditor(yearSpinner, "#"));
// this.add(yearSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setYear(new Year(yearModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setYear(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new Year(yearModel.getNumber().intValue());
// }
//
// public void setMissingComponent(Component c) {
// yearModel.setValue(((Year)c).getValue());
// }
// }
|
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingYearPanel;
import java.util.GregorianCalendar;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Year extends DateAndTimeComponent {
public Year(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Year(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.YEAR;
}
@Override
public String toString() {
return "Year" + super.toString();
}
@Override
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingYearPanel.java
// public class MissingYearPanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel yearLabel;
//
// private SpinnerNumberModel yearModel = new SpinnerNumberModel(2011, 1900, 2100, 1);
// private JSpinner yearSpinner = new JSpinner(yearModel);
//
// public MissingYearPanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.yearLabel = new JLabel(Lang.l().year() + ": ");
// this.add(yearLabel);
// yearSpinner.setEditor(new JSpinner.NumberEditor(yearSpinner, "#"));
// this.add(yearSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setYear(new Year(yearModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setYear(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new Year(yearModel.getNumber().intValue());
// }
//
// public void setMissingComponent(Component c) {
// yearModel.setValue(((Year)c).getValue());
// }
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Year.java
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingYearPanel;
import java.util.GregorianCalendar;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Year extends DateAndTimeComponent {
public Year(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Year(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.YEAR;
}
@Override
public String toString() {
return "Year" + super.toString();
}
@Override
|
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Year.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingYearPanel.java
// public class MissingYearPanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel yearLabel;
//
// private SpinnerNumberModel yearModel = new SpinnerNumberModel(2011, 1900, 2100, 1);
// private JSpinner yearSpinner = new JSpinner(yearModel);
//
// public MissingYearPanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.yearLabel = new JLabel(Lang.l().year() + ": ");
// this.add(yearLabel);
// yearSpinner.setEditor(new JSpinner.NumberEditor(yearSpinner, "#"));
// this.add(yearSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setYear(new Year(yearModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setYear(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new Year(yearModel.getNumber().intValue());
// }
//
// public void setMissingComponent(Component c) {
// yearModel.setValue(((Year)c).getValue());
// }
// }
|
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingYearPanel;
import java.util.GregorianCalendar;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Year extends DateAndTimeComponent {
public Year(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Year(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.YEAR;
}
@Override
public String toString() {
return "Year" + super.toString();
}
@Override
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/dateAndTime/MissingYearPanel.java
// public class MissingYearPanel extends MissingDateAndTimePanel {
//
// private static final long serialVersionUID = 1L;
//
// private JLabel yearLabel;
//
// private SpinnerNumberModel yearModel = new SpinnerNumberModel(2011, 1900, 2100, 1);
// private JSpinner yearSpinner = new JSpinner(yearModel);
//
// public MissingYearPanel(DateAndTime dateAndTime) {
// super(dateAndTime);
// this.setLayout(new FlowLayout(FlowLayout.LEFT));
// this.yearLabel = new JLabel(Lang.l().year() + ": ");
// this.add(yearLabel);
// yearSpinner.setEditor(new JSpinner.NumberEditor(yearSpinner, "#"));
// this.add(yearSpinner);
// }
//
// @Override
// public void assignValues() {
// dateAndTime.setYear(new Year(yearModel.getNumber().intValue()));
// }
//
// @Override
// public void unassignValues() {
// dateAndTime.setYear(null);
// }
//
// @Override
// public boolean checkValues() {
// return true;
// }
//
// @Override
// public Component getMissingComponent() {
// return new Year(yearModel.getNumber().intValue());
// }
//
// public void setMissingComponent(Component c) {
// yearModel.setValue(((Year)c).getValue());
// }
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Year.java
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingYearPanel;
import java.util.GregorianCalendar;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Year extends DateAndTimeComponent {
public Year(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Year(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.YEAR;
}
@Override
public String toString() {
return "Year" + super.toString();
}
@Override
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
return new MissingYearPanel((DateAndTime)c);
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/position/Height.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
|
import org.n52.sos.importer.model.table.Cell;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.position.MissingHeightPanel;
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.measuredValue.NumericValue;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.position;
public class Height extends PositionComponent {
public Height(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Height(double value, String unit) {
super(value, unit);
}
@Override
public String toString() {
return "Height" + super.toString();
}
@Override
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/position/Height.java
import org.n52.sos.importer.model.table.Cell;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.position.MissingHeightPanel;
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.measuredValue.NumericValue;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.position;
public class Height extends PositionComponent {
public Height(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Height(double value, String unit) {
super(value, unit);
}
@Override
public String toString() {
return "Height" + super.toString();
}
@Override
|
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/position/Height.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
|
import org.n52.sos.importer.model.table.Cell;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.position.MissingHeightPanel;
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.measuredValue.NumericValue;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.position;
public class Height extends PositionComponent {
public Height(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Height(double value, String unit) {
super(value, unit);
}
@Override
public String toString() {
return "Height" + super.toString();
}
@Override
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/position/Height.java
import org.n52.sos.importer.model.table.Cell;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.position.MissingHeightPanel;
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.measuredValue.NumericValue;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.position;
public class Height extends PositionComponent {
public Height(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Height(double value, String unit) {
super(value, unit);
}
@Override
public String toString() {
return "Height" + super.toString();
}
@Override
|
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/Start.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/controller/MainController.java
// public class MainController {
//
// private static MainController instance = null;
//
// private final MainFrame mainFrame = new MainFrame(this);
//
// private final Model xmlModel;
//
// private MainController() {
// //
// // Load the tooltips
// ToolTips.loadSettings();
// //
// // load the configuration for the ComboBoxItems at startup
// // first call to getInstance() calls ComboBoxItems.load()
// ComboBoxItems.getInstance();
// //
// // init xmlmodel TODO load from configuration
// xmlModel = new Model();
// }
//
// public static MainController getInstance() {
// if (MainController.instance == null) {
// MainController.instance = new MainController();
// }
// return MainController.instance;
// }
//
// /**
// * Method is called each time a button ("Next","Back", or "Finish") is clicked
// * in the GUI.
// * @param stepController
// */
// public void setStepController(final StepController stepController) {
// final DescriptionPanel descP = DescriptionPanel.getInstance();
// final BackNextModel bNM = BackNextController.getInstance().getModel();
// //
// descP.setText(stepController.getDescription());
// stepController.loadSettings();
// mainFrame.setStepPanel(stepController.getStepPanel());
// xmlModel.registerProvider(stepController.getModel());
// bNM.setCurrentStepController(stepController);
// }
//
// public void updateModel() {
// xmlModel.updateModel();
// }
//
// public boolean removeProvider(final StepModel sm) {
// return xmlModel.removeProvider(sm);
// }
//
// public boolean registerProvider(final StepModel sm) {
// return xmlModel.registerProvider(sm);
// }
//
// public void exit() {
// mainFrame.showExitDialog();
// }
//
// public void updateTitle(final String csvFilePath) {
// mainFrame.updateTitle(csvFilePath);
// }
//
// public boolean saveModel(final File file) throws IOException {
// return xmlModel.save(file);
// }
//
// public String getFilename() {
// return xmlModel.getFileName();
// }
// }
|
import org.n52.sos.importer.controller.MainController;
import org.n52.sos.importer.controller.Step1Controller;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer;
/**
* Starts the SOS-Importer
* @author Raimund Schnürer
* @author <a href="mailto:e.h.juerrens@52north.org">Eike Hinderk Jürrens</a>
*/
public class Start {
public static void main(String[] args) {
|
// Path: wizard/src/main/java/org/n52/sos/importer/controller/MainController.java
// public class MainController {
//
// private static MainController instance = null;
//
// private final MainFrame mainFrame = new MainFrame(this);
//
// private final Model xmlModel;
//
// private MainController() {
// //
// // Load the tooltips
// ToolTips.loadSettings();
// //
// // load the configuration for the ComboBoxItems at startup
// // first call to getInstance() calls ComboBoxItems.load()
// ComboBoxItems.getInstance();
// //
// // init xmlmodel TODO load from configuration
// xmlModel = new Model();
// }
//
// public static MainController getInstance() {
// if (MainController.instance == null) {
// MainController.instance = new MainController();
// }
// return MainController.instance;
// }
//
// /**
// * Method is called each time a button ("Next","Back", or "Finish") is clicked
// * in the GUI.
// * @param stepController
// */
// public void setStepController(final StepController stepController) {
// final DescriptionPanel descP = DescriptionPanel.getInstance();
// final BackNextModel bNM = BackNextController.getInstance().getModel();
// //
// descP.setText(stepController.getDescription());
// stepController.loadSettings();
// mainFrame.setStepPanel(stepController.getStepPanel());
// xmlModel.registerProvider(stepController.getModel());
// bNM.setCurrentStepController(stepController);
// }
//
// public void updateModel() {
// xmlModel.updateModel();
// }
//
// public boolean removeProvider(final StepModel sm) {
// return xmlModel.removeProvider(sm);
// }
//
// public boolean registerProvider(final StepModel sm) {
// return xmlModel.registerProvider(sm);
// }
//
// public void exit() {
// mainFrame.showExitDialog();
// }
//
// public void updateTitle(final String csvFilePath) {
// mainFrame.updateTitle(csvFilePath);
// }
//
// public boolean saveModel(final File file) throws IOException {
// return xmlModel.save(file);
// }
//
// public String getFilename() {
// return xmlModel.getFileName();
// }
// }
// Path: wizard/src/main/java/org/n52/sos/importer/Start.java
import org.n52.sos.importer.controller.MainController;
import org.n52.sos.importer.controller.Step1Controller;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer;
/**
* Starts the SOS-Importer
* @author Raimund Schnürer
* @author <a href="mailto:e.h.juerrens@52north.org">Eike Hinderk Jürrens</a>
*/
public class Start {
public static void main(String[] args) {
|
MainController.getInstance().setStepController(new Step1Controller());
|
52North/sos-importer
|
feeder/src/main/java/org/n52/sos/importer/feeder/Configuration.java
|
// Path: feeder/src/main/java/org/n52/sos/importer/feeder/csv/WrappedCSVReader.java
// public class WrappedCSVReader implements CsvParser {
//
// private CSVReader csvReader;
//
// @Override
// public String[] readNext() throws IOException {
// return csvReader.readNext();
// }
//
// @Override
// public void init(final BufferedReader bufferedReader,
// final Configuration configuration) {
// final int flwd = configuration.getFirstLineWithData();
// final char separator = configuration.getCsvSeparator(),
// quotechar = configuration.getCsvQuoteChar(),
// escape = configuration.getCsvEscape();
// csvReader = new CSVReader(bufferedReader, separator, quotechar, escape, flwd);
// }
//
// @Override
// public int getSkipLimit() {
// return 1;
// }
//
// }
|
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.MessageFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.regex.Pattern;
import javax.xml.namespace.QName;
import org.apache.xmlbeans.XmlError;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlOptions;
import org.n52.sos.importer.feeder.csv.WrappedCSVReader;
import org.n52.sos.importer.feeder.model.Offering;
import org.n52.sos.importer.feeder.model.Position;
import org.n52.sos.importer.feeder.model.Sensor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.x52North.sensorweb.sos.importer.x04.AdditionalMetadataDocument.AdditionalMetadata.FOIPosition;
import org.x52North.sensorweb.sos.importer.x04.ColumnDocument.Column;
import org.x52North.sensorweb.sos.importer.x04.FeatureOfInterestType;
import org.x52North.sensorweb.sos.importer.x04.KeyDocument.Key;
import org.x52North.sensorweb.sos.importer.x04.MetadataDocument.Metadata;
import org.x52North.sensorweb.sos.importer.x04.ObservedPropertyType;
import org.x52North.sensorweb.sos.importer.x04.RelatedFOIDocument.RelatedFOI;
import org.x52North.sensorweb.sos.importer.x04.RelatedSensorDocument.RelatedSensor;
import org.x52North.sensorweb.sos.importer.x04.SensorType;
import org.x52North.sensorweb.sos.importer.x04.SosImportConfigurationDocument;
import org.x52North.sensorweb.sos.importer.x04.SosImportConfigurationDocument.SosImportConfiguration;
import org.x52North.sensorweb.sos.importer.x04.TypeDocument.Type;
import org.x52North.sensorweb.sos.importer.x04.TypeDocument.Type.Enum;
import org.x52North.sensorweb.sos.importer.x04.UnitOfMeasurementType;
|
if (regEx != null && !regEx.isEmpty()) {
patterns.add(Pattern.compile(regEx));
}
}
return patterns.toArray(new Pattern[patterns.size()]);
}
public boolean isInsertSweArrayObservationTimeoutBufferSet() {
return importConf.getSosMetadata().isSetInsertSweArrayObservationTimeoutBuffer();
}
public int getInsertSweArrayObservationTimeoutBuffer() {
if (isInsertSweArrayObservationTimeoutBufferSet()) {
return importConf.getSosMetadata().getInsertSweArrayObservationTimeoutBuffer();
}
throw new IllegalArgumentException("Attribute 'insertSweArrayObservationTimeoutBuffer' of <SosMetadata> not set.");
}
public int getSampleSizeDivisor() {
if (isSamplingFile() && importConf.getDataFile().isSetSampleSizeDivisor()) {
return importConf.getDataFile().getSampleSizeDivisor();
}
return 1;
}
public boolean isCsvParserDefined() {
return importConf.getCsvMetadata().isSetCsvParserClass();
}
public String getCsvParser() {
|
// Path: feeder/src/main/java/org/n52/sos/importer/feeder/csv/WrappedCSVReader.java
// public class WrappedCSVReader implements CsvParser {
//
// private CSVReader csvReader;
//
// @Override
// public String[] readNext() throws IOException {
// return csvReader.readNext();
// }
//
// @Override
// public void init(final BufferedReader bufferedReader,
// final Configuration configuration) {
// final int flwd = configuration.getFirstLineWithData();
// final char separator = configuration.getCsvSeparator(),
// quotechar = configuration.getCsvQuoteChar(),
// escape = configuration.getCsvEscape();
// csvReader = new CSVReader(bufferedReader, separator, quotechar, escape, flwd);
// }
//
// @Override
// public int getSkipLimit() {
// return 1;
// }
//
// }
// Path: feeder/src/main/java/org/n52/sos/importer/feeder/Configuration.java
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.MessageFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.regex.Pattern;
import javax.xml.namespace.QName;
import org.apache.xmlbeans.XmlError;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlOptions;
import org.n52.sos.importer.feeder.csv.WrappedCSVReader;
import org.n52.sos.importer.feeder.model.Offering;
import org.n52.sos.importer.feeder.model.Position;
import org.n52.sos.importer.feeder.model.Sensor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.x52North.sensorweb.sos.importer.x04.AdditionalMetadataDocument.AdditionalMetadata.FOIPosition;
import org.x52North.sensorweb.sos.importer.x04.ColumnDocument.Column;
import org.x52North.sensorweb.sos.importer.x04.FeatureOfInterestType;
import org.x52North.sensorweb.sos.importer.x04.KeyDocument.Key;
import org.x52North.sensorweb.sos.importer.x04.MetadataDocument.Metadata;
import org.x52North.sensorweb.sos.importer.x04.ObservedPropertyType;
import org.x52North.sensorweb.sos.importer.x04.RelatedFOIDocument.RelatedFOI;
import org.x52North.sensorweb.sos.importer.x04.RelatedSensorDocument.RelatedSensor;
import org.x52North.sensorweb.sos.importer.x04.SensorType;
import org.x52North.sensorweb.sos.importer.x04.SosImportConfigurationDocument;
import org.x52North.sensorweb.sos.importer.x04.SosImportConfigurationDocument.SosImportConfiguration;
import org.x52North.sensorweb.sos.importer.x04.TypeDocument.Type;
import org.x52North.sensorweb.sos.importer.x04.TypeDocument.Type.Enum;
import org.x52North.sensorweb.sos.importer.x04.UnitOfMeasurementType;
if (regEx != null && !regEx.isEmpty()) {
patterns.add(Pattern.compile(regEx));
}
}
return patterns.toArray(new Pattern[patterns.size()]);
}
public boolean isInsertSweArrayObservationTimeoutBufferSet() {
return importConf.getSosMetadata().isSetInsertSweArrayObservationTimeoutBuffer();
}
public int getInsertSweArrayObservationTimeoutBuffer() {
if (isInsertSweArrayObservationTimeoutBufferSet()) {
return importConf.getSosMetadata().getInsertSweArrayObservationTimeoutBuffer();
}
throw new IllegalArgumentException("Attribute 'insertSweArrayObservationTimeoutBuffer' of <SosMetadata> not set.");
}
public int getSampleSizeDivisor() {
if (isSamplingFile() && importConf.getDataFile().isSetSampleSizeDivisor()) {
return importConf.getDataFile().getSampleSizeDivisor();
}
return 1;
}
public boolean isCsvParserDefined() {
return importConf.getCsvMetadata().isSetCsvParserClass();
}
public String getCsvParser() {
|
return isCsvParserDefined()?importConf.getCsvMetadata().getCsvParserClass():WrappedCSVReader.class.getName();
|
52North/sos-importer
|
wizard/src/test/java/org/n52/sos/importer/test/Step3TestMultipleDateTimeColumns.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/controller/MainController.java
// public class MainController {
//
// private static MainController instance = null;
//
// private final MainFrame mainFrame = new MainFrame(this);
//
// private final Model xmlModel;
//
// private MainController() {
// //
// // Load the tooltips
// ToolTips.loadSettings();
// //
// // load the configuration for the ComboBoxItems at startup
// // first call to getInstance() calls ComboBoxItems.load()
// ComboBoxItems.getInstance();
// //
// // init xmlmodel TODO load from configuration
// xmlModel = new Model();
// }
//
// public static MainController getInstance() {
// if (MainController.instance == null) {
// MainController.instance = new MainController();
// }
// return MainController.instance;
// }
//
// /**
// * Method is called each time a button ("Next","Back", or "Finish") is clicked
// * in the GUI.
// * @param stepController
// */
// public void setStepController(final StepController stepController) {
// final DescriptionPanel descP = DescriptionPanel.getInstance();
// final BackNextModel bNM = BackNextController.getInstance().getModel();
// //
// descP.setText(stepController.getDescription());
// stepController.loadSettings();
// mainFrame.setStepPanel(stepController.getStepPanel());
// xmlModel.registerProvider(stepController.getModel());
// bNM.setCurrentStepController(stepController);
// }
//
// public void updateModel() {
// xmlModel.updateModel();
// }
//
// public boolean removeProvider(final StepModel sm) {
// return xmlModel.removeProvider(sm);
// }
//
// public boolean registerProvider(final StepModel sm) {
// return xmlModel.registerProvider(sm);
// }
//
// public void exit() {
// mainFrame.showExitDialog();
// }
//
// public void updateTitle(final String csvFilePath) {
// mainFrame.updateTitle(csvFilePath);
// }
//
// public boolean saveModel(final File file) throws IOException {
// return xmlModel.save(file);
// }
//
// public String getFilename() {
// return xmlModel.getFileName();
// }
// }
|
import org.n52.sos.importer.controller.Step3Controller;
import org.n52.sos.importer.controller.TableController;
import org.n52.sos.importer.Constants;
import org.n52.sos.importer.controller.MainController;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.test;
public class Step3TestMultipleDateTimeColumns {
public static void main(final String[] args) {
|
// Path: wizard/src/main/java/org/n52/sos/importer/controller/MainController.java
// public class MainController {
//
// private static MainController instance = null;
//
// private final MainFrame mainFrame = new MainFrame(this);
//
// private final Model xmlModel;
//
// private MainController() {
// //
// // Load the tooltips
// ToolTips.loadSettings();
// //
// // load the configuration for the ComboBoxItems at startup
// // first call to getInstance() calls ComboBoxItems.load()
// ComboBoxItems.getInstance();
// //
// // init xmlmodel TODO load from configuration
// xmlModel = new Model();
// }
//
// public static MainController getInstance() {
// if (MainController.instance == null) {
// MainController.instance = new MainController();
// }
// return MainController.instance;
// }
//
// /**
// * Method is called each time a button ("Next","Back", or "Finish") is clicked
// * in the GUI.
// * @param stepController
// */
// public void setStepController(final StepController stepController) {
// final DescriptionPanel descP = DescriptionPanel.getInstance();
// final BackNextModel bNM = BackNextController.getInstance().getModel();
// //
// descP.setText(stepController.getDescription());
// stepController.loadSettings();
// mainFrame.setStepPanel(stepController.getStepPanel());
// xmlModel.registerProvider(stepController.getModel());
// bNM.setCurrentStepController(stepController);
// }
//
// public void updateModel() {
// xmlModel.updateModel();
// }
//
// public boolean removeProvider(final StepModel sm) {
// return xmlModel.removeProvider(sm);
// }
//
// public boolean registerProvider(final StepModel sm) {
// return xmlModel.registerProvider(sm);
// }
//
// public void exit() {
// mainFrame.showExitDialog();
// }
//
// public void updateTitle(final String csvFilePath) {
// mainFrame.updateTitle(csvFilePath);
// }
//
// public boolean saveModel(final File file) throws IOException {
// return xmlModel.save(file);
// }
//
// public String getFilename() {
// return xmlModel.getFileName();
// }
// }
// Path: wizard/src/test/java/org/n52/sos/importer/test/Step3TestMultipleDateTimeColumns.java
import org.n52.sos.importer.controller.Step3Controller;
import org.n52.sos.importer.controller.TableController;
import org.n52.sos.importer.Constants;
import org.n52.sos.importer.controller.MainController;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.test;
public class Step3TestMultipleDateTimeColumns {
public static void main(final String[] args) {
|
final MainController f = MainController.getInstance();
|
52North/sos-importer
|
feeder/src/test/java/org/n52/sos/importer/feeder/model/TimeSeriesRepositoryTest.java
|
// Path: feeder/src/main/java/org/n52/sos/importer/feeder/model/requests/RegisterSensor.java
// public class RegisterSensor {
//
// private final InsertObservation io;
//
// private final Map<ObservedProperty, String> measuredValueTypes;
//
// private final Collection<ObservedProperty> observedProperties;
//
// private final Map<ObservedProperty, String> unitOfMeasurements;
//
// public RegisterSensor(
// final InsertObservation io,
// final Collection<ObservedProperty> observedProperties,
// final Map<ObservedProperty, String> measuredValueTypes,
// final Map<ObservedProperty, String> unitOfMeasurements) {
// this.io = io;
// this.observedProperties = observedProperties;
// this.measuredValueTypes = measuredValueTypes;
// this.unitOfMeasurements = unitOfMeasurements;
// }
//
// public String getAltitudeUnit() {
// return io.getFeatureOfInterest().getPosition().getAltitudeUnit();
// }
//
// public double getAltitudeValue() {
// return io.getFeatureOfInterest().getPosition().getAltitude();
// }
//
// public String getDefaultValue() {
// if (io.getResultValue() instanceof Boolean) {
// return "false";
// }
// if (io.getResultValue() instanceof Integer) {
// return "0";
// }
// if (io.getResultValue() instanceof Double) {
// return "0.0";
// }
// if (io.getResultValue() instanceof String) {
// return " ";
// }
// return "notDefined";
// }
//
// public String getEpsgCode() {
// return io.getEpsgCode();
// }
//
// public String getFeatureOfInterestName() {
// return io.getFeatureOfInterestName();
// }
//
// public String getFeatureOfInterestURI() {
// return io.getFeatureOfInterestURI();
// }
//
// public String getLatitudeUnit() {
// return io.getFeatureOfInterest().getPosition().getLatitudeUnit();
// }
//
// public double getLatitudeValue() {
// return io.getLatitudeValue();
// }
//
// public String getLongitudeUnit() {
// return io.getFeatureOfInterest().getPosition().getLongitudeUnit();
// }
//
// public double getLongitudeValue() {
// return io.getLongitudeValue();
// }
//
// public String getMeasuredValueType(final ObservedProperty observedProperty)
// {
// return measuredValueTypes.get(observedProperty);
// }
//
// public Collection<ObservedProperty> getObservedProperties()
// {
// return observedProperties;
// }
//
// public String getOfferingName() {
// return io.getOffering().getName();
// }
//
// public String getOfferingUri() {
// return io.getOffering().getUri();
// }
//
// public String getSensorName() {
// return io.getSensorName();
// }
//
// public String getSensorURI() {
// return io.getSensorURI();
// }
//
// public String getUnitOfMeasurementCode(final ObservedProperty observedProperty) {
// return unitOfMeasurements.get(observedProperty);
// }
//
// }
|
import static org.junit.Assert.assertThat;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.n52.sos.importer.feeder.model.requests.InsertObservation;
import org.n52.sos.importer.feeder.model.requests.RegisterSensor;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.hasSize;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.feeder.model;
public class TimeSeriesRepositoryTest {
@Test
public void shouldReturnRegisterSensorForCorrectSensor() {
TimeSeriesRepository tsr = new TimeSeriesRepository(2);
String sensorURI = "test-sensor-1-uri";
ObservedProperty observedProperty1 = new ObservedProperty("test-obs-prop-1-name", "test-obs-prop-1-uri");
ObservedProperty observedProperty2 = new ObservedProperty("test-obs-prop-2-name", "test-obs-prop-2-uri");
UnitOfMeasurement uom = new UnitOfMeasurement("uom-code", "uom-uri");
Sensor sensor = new Sensor("test-sensor-1-name", sensorURI);
FeatureOfInterest foi = new FeatureOfInterest("foi-name", "foi-uri", null);
Object value = 1;
Timestamp timeStamp = new Timestamp().set(System.currentTimeMillis());
Offering off = new Offering("offering-name", "offering-uri");
String mvType = "mv-type";
InsertObservation io = new InsertObservation(sensor, foi, value, timeStamp, uom , observedProperty1, off, mvType);
InsertObservation io2 = new InsertObservation(sensor, foi, 2, timeStamp, uom, observedProperty2, off, mvType);
InsertObservation[] ios = {io, io2 };
tsr.addObservations(ios);
|
// Path: feeder/src/main/java/org/n52/sos/importer/feeder/model/requests/RegisterSensor.java
// public class RegisterSensor {
//
// private final InsertObservation io;
//
// private final Map<ObservedProperty, String> measuredValueTypes;
//
// private final Collection<ObservedProperty> observedProperties;
//
// private final Map<ObservedProperty, String> unitOfMeasurements;
//
// public RegisterSensor(
// final InsertObservation io,
// final Collection<ObservedProperty> observedProperties,
// final Map<ObservedProperty, String> measuredValueTypes,
// final Map<ObservedProperty, String> unitOfMeasurements) {
// this.io = io;
// this.observedProperties = observedProperties;
// this.measuredValueTypes = measuredValueTypes;
// this.unitOfMeasurements = unitOfMeasurements;
// }
//
// public String getAltitudeUnit() {
// return io.getFeatureOfInterest().getPosition().getAltitudeUnit();
// }
//
// public double getAltitudeValue() {
// return io.getFeatureOfInterest().getPosition().getAltitude();
// }
//
// public String getDefaultValue() {
// if (io.getResultValue() instanceof Boolean) {
// return "false";
// }
// if (io.getResultValue() instanceof Integer) {
// return "0";
// }
// if (io.getResultValue() instanceof Double) {
// return "0.0";
// }
// if (io.getResultValue() instanceof String) {
// return " ";
// }
// return "notDefined";
// }
//
// public String getEpsgCode() {
// return io.getEpsgCode();
// }
//
// public String getFeatureOfInterestName() {
// return io.getFeatureOfInterestName();
// }
//
// public String getFeatureOfInterestURI() {
// return io.getFeatureOfInterestURI();
// }
//
// public String getLatitudeUnit() {
// return io.getFeatureOfInterest().getPosition().getLatitudeUnit();
// }
//
// public double getLatitudeValue() {
// return io.getLatitudeValue();
// }
//
// public String getLongitudeUnit() {
// return io.getFeatureOfInterest().getPosition().getLongitudeUnit();
// }
//
// public double getLongitudeValue() {
// return io.getLongitudeValue();
// }
//
// public String getMeasuredValueType(final ObservedProperty observedProperty)
// {
// return measuredValueTypes.get(observedProperty);
// }
//
// public Collection<ObservedProperty> getObservedProperties()
// {
// return observedProperties;
// }
//
// public String getOfferingName() {
// return io.getOffering().getName();
// }
//
// public String getOfferingUri() {
// return io.getOffering().getUri();
// }
//
// public String getSensorName() {
// return io.getSensorName();
// }
//
// public String getSensorURI() {
// return io.getSensorURI();
// }
//
// public String getUnitOfMeasurementCode(final ObservedProperty observedProperty) {
// return unitOfMeasurements.get(observedProperty);
// }
//
// }
// Path: feeder/src/test/java/org/n52/sos/importer/feeder/model/TimeSeriesRepositoryTest.java
import static org.junit.Assert.assertThat;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.n52.sos.importer.feeder.model.requests.InsertObservation;
import org.n52.sos.importer.feeder.model.requests.RegisterSensor;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.hasSize;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.feeder.model;
public class TimeSeriesRepositoryTest {
@Test
public void shouldReturnRegisterSensorForCorrectSensor() {
TimeSeriesRepository tsr = new TimeSeriesRepository(2);
String sensorURI = "test-sensor-1-uri";
ObservedProperty observedProperty1 = new ObservedProperty("test-obs-prop-1-name", "test-obs-prop-1-uri");
ObservedProperty observedProperty2 = new ObservedProperty("test-obs-prop-2-name", "test-obs-prop-2-uri");
UnitOfMeasurement uom = new UnitOfMeasurement("uom-code", "uom-uri");
Sensor sensor = new Sensor("test-sensor-1-name", sensorURI);
FeatureOfInterest foi = new FeatureOfInterest("foi-name", "foi-uri", null);
Object value = 1;
Timestamp timeStamp = new Timestamp().set(System.currentTimeMillis());
Offering off = new Offering("offering-name", "offering-uri");
String mvType = "mv-type";
InsertObservation io = new InsertObservation(sensor, foi, value, timeStamp, uom , observedProperty1, off, mvType);
InsertObservation io2 = new InsertObservation(sensor, foi, 2, timeStamp, uom, observedProperty2, off, mvType);
InsertObservation[] ios = {io, io2 };
tsr.addObservations(ios);
|
RegisterSensor registerSensor = tsr.getRegisterSensor(sensorURI);
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Hour.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
|
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingHourPanel;
import java.util.GregorianCalendar;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Hour extends DateAndTimeComponent {
public Hour(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Hour(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.HOUR_OF_DAY;
}
@Override
public String toString() {
return "Hour" + super.toString();
}
@Override
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Hour.java
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingHourPanel;
import java.util.GregorianCalendar;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Hour extends DateAndTimeComponent {
public Hour(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Hour(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.HOUR_OF_DAY;
}
@Override
public String toString() {
return "Hour" + super.toString();
}
@Override
|
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Hour.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
|
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingHourPanel;
import java.util.GregorianCalendar;
|
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Hour extends DateAndTimeComponent {
public Hour(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Hour(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.HOUR_OF_DAY;
}
@Override
public String toString() {
return "Hour" + super.toString();
}
@Override
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/Combination.java
// public abstract class Combination implements Formatable, Parseable {
//
// /** for parsing */
// private String pattern;
//
// /** for merging */
// private String group;
//
// public void setPattern(String pattern) {
// this.pattern = pattern;
// }
//
// public String getPattern() {
// return pattern;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getGroup() {
// return group;
// }
// }
//
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/dateAndTime/Hour.java
import org.n52.sos.importer.model.Combination;
import org.n52.sos.importer.model.table.TableElement;
import org.n52.sos.importer.view.MissingComponentPanel;
import org.n52.sos.importer.view.dateAndTime.MissingHourPanel;
import java.util.GregorianCalendar;
/**
* Copyright (C) 2011-2015 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* 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.
*/
package org.n52.sos.importer.model.dateAndTime;
public class Hour extends DateAndTimeComponent {
public Hour(TableElement tableElement, String pattern) {
super(tableElement, pattern);
}
public Hour(int value) {
super(value);
}
@Override
public int getGregorianCalendarField() {
return GregorianCalendar.HOUR_OF_DAY;
}
@Override
public String toString() {
return "Hour" + super.toString();
}
@Override
|
public MissingComponentPanel getMissingComponentPanel(Combination c) {
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/model/xml/Helper.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/table/Row.java
// public class Row extends TableElement {
//
// private int number = -1;
//
// public Row(int number) {
// this.number = number;
// }
//
// public void setNumber(int number) {
// this.number = number;
// }
//
// public int getNumber() {
// return number;
// }
//
// public void mark() {
// TableController.getInstance().mark(this);
// }
//
// @Override
// public String getValueFor(Cell c) {
// return TableController.getInstance().getValueAt(this.getNumber(), c.getColumn());
// }
//
// @Override
// public Cell getCellFor(Cell c) {
// return new Cell(this.getNumber(), c.getColumn());
// }
//
// @Override
// public HashSet<String> getValues() {
// HashSet<String> values = new HashSet<String>();
// for (int i = 0; i < TableController.getInstance().getColumnCount(); i++) {
// String value = TableController.getInstance().getValueAt(this.getNumber(), i);
// values.add(value);
// }
// return values;
// }
//
// @Override
// public String toString() {
// return "row[" + number + "]";
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + number;
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (!(obj instanceof Row))
// return false;
// Row other = (Row) obj;
// if (number != other.number)
// return false;
// return true;
// }
// }
|
import org.n52.sos.importer.model.table.TableElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.x52North.sensorweb.sos.importer.x04.ColumnAssignmentsDocument.ColumnAssignments;
import org.x52North.sensorweb.sos.importer.x04.ColumnDocument.Column;
import org.x52North.sensorweb.sos.importer.x04.CsvMetadataDocument.CsvMetadata;
import org.x52North.sensorweb.sos.importer.x04.KeyDocument.Key.Enum;
import org.x52North.sensorweb.sos.importer.x04.MetadataDocument.Metadata;
import org.x52North.sensorweb.sos.importer.x04.RelatedSensorDocument.RelatedSensor;
import org.x52North.sensorweb.sos.importer.x04.SosImportConfigurationDocument.SosImportConfiguration;
import org.n52.sos.importer.model.table.Cell;
import org.n52.sos.importer.model.table.Row;
|
meta = col.addNewMetadata();
meta.setKey(key);
addedOrUpdated = "Added";
}
meta.setValue(value);
if (logger.isDebugEnabled()) {
logger.debug(addedOrUpdated + " column metadata. Key: " + key + "; Value: " +
value + " in column " + col.getNumber());
}
return (meta.getValue().equalsIgnoreCase(value));
}
/**
* @param tabElem
* @return the id of the column of this TableElement or -1
*/
protected static int getColumnIdFromTableElement(final TableElement tabElem) {
if (logger.isTraceEnabled()) {
logger.trace("getColumnIdFromTableElement()");
}
if (tabElem == null) {
return -1;
}
if (tabElem instanceof Cell) {
final Cell c = (Cell) tabElem;
return c.getColumn();
} else if (tabElem instanceof org.n52.sos.importer.model.table.Column) {
final org.n52.sos.importer.model.table.Column c = (org.n52.sos.importer.model.table.Column) tabElem;
return c.getNumber();
// TODO What is the reason for having it in rows?
|
// Path: wizard/src/main/java/org/n52/sos/importer/model/table/Row.java
// public class Row extends TableElement {
//
// private int number = -1;
//
// public Row(int number) {
// this.number = number;
// }
//
// public void setNumber(int number) {
// this.number = number;
// }
//
// public int getNumber() {
// return number;
// }
//
// public void mark() {
// TableController.getInstance().mark(this);
// }
//
// @Override
// public String getValueFor(Cell c) {
// return TableController.getInstance().getValueAt(this.getNumber(), c.getColumn());
// }
//
// @Override
// public Cell getCellFor(Cell c) {
// return new Cell(this.getNumber(), c.getColumn());
// }
//
// @Override
// public HashSet<String> getValues() {
// HashSet<String> values = new HashSet<String>();
// for (int i = 0; i < TableController.getInstance().getColumnCount(); i++) {
// String value = TableController.getInstance().getValueAt(this.getNumber(), i);
// values.add(value);
// }
// return values;
// }
//
// @Override
// public String toString() {
// return "row[" + number + "]";
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + number;
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (!(obj instanceof Row))
// return false;
// Row other = (Row) obj;
// if (number != other.number)
// return false;
// return true;
// }
// }
// Path: wizard/src/main/java/org/n52/sos/importer/model/xml/Helper.java
import org.n52.sos.importer.model.table.TableElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.x52North.sensorweb.sos.importer.x04.ColumnAssignmentsDocument.ColumnAssignments;
import org.x52North.sensorweb.sos.importer.x04.ColumnDocument.Column;
import org.x52North.sensorweb.sos.importer.x04.CsvMetadataDocument.CsvMetadata;
import org.x52North.sensorweb.sos.importer.x04.KeyDocument.Key.Enum;
import org.x52North.sensorweb.sos.importer.x04.MetadataDocument.Metadata;
import org.x52North.sensorweb.sos.importer.x04.RelatedSensorDocument.RelatedSensor;
import org.x52North.sensorweb.sos.importer.x04.SosImportConfigurationDocument.SosImportConfiguration;
import org.n52.sos.importer.model.table.Cell;
import org.n52.sos.importer.model.table.Row;
meta = col.addNewMetadata();
meta.setKey(key);
addedOrUpdated = "Added";
}
meta.setValue(value);
if (logger.isDebugEnabled()) {
logger.debug(addedOrUpdated + " column metadata. Key: " + key + "; Value: " +
value + " in column " + col.getNumber());
}
return (meta.getValue().equalsIgnoreCase(value));
}
/**
* @param tabElem
* @return the id of the column of this TableElement or -1
*/
protected static int getColumnIdFromTableElement(final TableElement tabElem) {
if (logger.isTraceEnabled()) {
logger.trace("getColumnIdFromTableElement()");
}
if (tabElem == null) {
return -1;
}
if (tabElem instanceof Cell) {
final Cell c = (Cell) tabElem;
return c.getColumn();
} else if (tabElem instanceof org.n52.sos.importer.model.table.Column) {
final org.n52.sos.importer.model.table.Column c = (org.n52.sos.importer.model.table.Column) tabElem;
return c.getNumber();
// TODO What is the reason for having it in rows?
|
} else if (tabElem instanceof Row) {
|
52North/sos-importer
|
wizard/src/main/java/org/n52/sos/importer/view/position/MissingPositionPanel.java
|
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
|
import javax.swing.JPanel;
import org.n52.sos.importer.Constants;
import org.n52.sos.importer.model.Step6cModel;
import org.n52.sos.importer.model.position.Position;
import org.n52.sos.importer.view.MissingComponentPanel;
import java.awt.BorderLayout;
import java.awt.GridLayout;
|
this.s6cM = s6cM;
manualInputPanel = initManualInputPanel(s6cM);
containerPanel = new JPanel();
containerPanel.setLayout(new BorderLayout(0,0));
containerPanel.add(manualInputPanel,BorderLayout.CENTER);
add(containerPanel,BorderLayout.CENTER);
if (Constants.GUI_DEBUG) {
manualInputPanel.setBorder(Constants.DEBUG_BORDER);
}
setVisible(true);
}
private JPanel initManualInputPanel(final Step6cModel s6cM) {
final JPanel manualInputPanel = new JPanel();
manualInputPanel.setLayout(new GridLayout(4, 1));
manualInputPanel.add(new MissingLatitudePanel(s6cM.getPosition()));
manualInputPanel.add(new MissingLongitudePanel(s6cM.getPosition()));
manualInputPanel.add(new MissingHeightPanel(s6cM.getPosition()));
manualInputPanel.add(new MissingEPSGCodePanel(s6cM.getPosition()));
return manualInputPanel;
}
public boolean isFinished() {
final java.awt.Component[] subPanels = manualInputPanel.getComponents();
for (final java.awt.Component component : subPanels) {
|
// Path: wizard/src/main/java/org/n52/sos/importer/view/MissingComponentPanel.java
// public abstract class MissingComponentPanel extends JPanel {
//
// private static final long serialVersionUID = 1L;
//
// /**
// * Allocate values of the missing component
// */
// public abstract void assignValues();
//
// /**
// * Release values of the missing component
// */
// public abstract void unassignValues();
//
// /**
// * Checks if all values are in the defined range
// * of this component; returns false, if not
// * @return <b>true</b>, if all given values are in allowed ranges.<br />
// * <b>false</b>, if not.
// */
// public abstract boolean checkValues();
//
// /**
// * Returns the missing component
// */
// public abstract Component getMissingComponent();
//
// /**
// * Initialises the missing component
// */
// public abstract void setMissingComponent(Component c);
// }
// Path: wizard/src/main/java/org/n52/sos/importer/view/position/MissingPositionPanel.java
import javax.swing.JPanel;
import org.n52.sos.importer.Constants;
import org.n52.sos.importer.model.Step6cModel;
import org.n52.sos.importer.model.position.Position;
import org.n52.sos.importer.view.MissingComponentPanel;
import java.awt.BorderLayout;
import java.awt.GridLayout;
this.s6cM = s6cM;
manualInputPanel = initManualInputPanel(s6cM);
containerPanel = new JPanel();
containerPanel.setLayout(new BorderLayout(0,0));
containerPanel.add(manualInputPanel,BorderLayout.CENTER);
add(containerPanel,BorderLayout.CENTER);
if (Constants.GUI_DEBUG) {
manualInputPanel.setBorder(Constants.DEBUG_BORDER);
}
setVisible(true);
}
private JPanel initManualInputPanel(final Step6cModel s6cM) {
final JPanel manualInputPanel = new JPanel();
manualInputPanel.setLayout(new GridLayout(4, 1));
manualInputPanel.add(new MissingLatitudePanel(s6cM.getPosition()));
manualInputPanel.add(new MissingLongitudePanel(s6cM.getPosition()));
manualInputPanel.add(new MissingHeightPanel(s6cM.getPosition()));
manualInputPanel.add(new MissingEPSGCodePanel(s6cM.getPosition()));
return manualInputPanel;
}
public boolean isFinished() {
final java.awt.Component[] subPanels = manualInputPanel.getComponents();
for (final java.awt.Component component : subPanels) {
|
if (component instanceof MissingComponentPanel) {
|
SW-Team/java-TelegramBot
|
src/milk/telegram/method/getter/ChatGetter.java
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/chat/Chat.java
// public abstract class Chat implements Identifier<Long>{
//
// private long id;
//
// private String type;
//
// protected Chat(JSONObject object){
// this.id = object.getLong("id");
// this.type = object.getString("type");
// }
//
// public static Chat create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
//
// switch(object.getString("type")){
// case "group":
// return new Group(object);
// case "channel":
// return new Channel(object);
// case "supergroup":
// return new SuperGroup(object);
// case "private":
// return new PrivateChat(object);
// }
// return null;
// }
//
// public Long getId(){
// return this.id;
// }
//
// public String getType(){
// return this.type;
// }
//
// }
|
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.chat.Chat;
|
package milk.telegram.method.getter;
public class ChatGetter extends Getter{
public ChatGetter(TelegramBot bot){
super(bot);
}
public String getChatId(){
return this.optString("chat_id");
}
public ChatGetter setChatId(Object chat_id){
this.put("chat_id", (chat_id instanceof Number ? ((Number) chat_id).longValue() : chat_id) + "");
return this;
}
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/chat/Chat.java
// public abstract class Chat implements Identifier<Long>{
//
// private long id;
//
// private String type;
//
// protected Chat(JSONObject object){
// this.id = object.getLong("id");
// this.type = object.getString("type");
// }
//
// public static Chat create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
//
// switch(object.getString("type")){
// case "group":
// return new Group(object);
// case "channel":
// return new Channel(object);
// case "supergroup":
// return new SuperGroup(object);
// case "private":
// return new PrivateChat(object);
// }
// return null;
// }
//
// public Long getId(){
// return this.id;
// }
//
// public String getType(){
// return this.type;
// }
//
// }
// Path: src/milk/telegram/method/getter/ChatGetter.java
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.chat.Chat;
package milk.telegram.method.getter;
public class ChatGetter extends Getter{
public ChatGetter(TelegramBot bot){
super(bot);
}
public String getChatId(){
return this.optString("chat_id");
}
public ChatGetter setChatId(Object chat_id){
this.put("chat_id", (chat_id instanceof Number ? ((Number) chat_id).longValue() : chat_id) + "");
return this;
}
|
public Chat send(){
|
SW-Team/java-TelegramBot
|
src/milk/telegram/type/inline/InlineQuery.java
|
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/file/Location.java
// public class Location{
//
// private final double latitude;
// private final double longitude;
//
// private Location(JSONObject object){
// this.latitude = object.getDouble("latitude");
// this.longitude = object.getDouble("longitude");
// }
//
// public static Location create(JSONObject object){
// if(object == null){
// return null;
// }
// return new Location(object);
// }
//
// public double getLatitude(){
// return latitude;
// }
//
// public double getLongitude(){
// return longitude;
// }
//
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
|
import milk.telegram.type.Identifier;
import milk.telegram.type.file.Location;
import milk.telegram.type.user.User;
import org.json.JSONObject;
|
package milk.telegram.type.inline;
public class InlineQuery implements Identifier<String>{
private final String id;
|
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/file/Location.java
// public class Location{
//
// private final double latitude;
// private final double longitude;
//
// private Location(JSONObject object){
// this.latitude = object.getDouble("latitude");
// this.longitude = object.getDouble("longitude");
// }
//
// public static Location create(JSONObject object){
// if(object == null){
// return null;
// }
// return new Location(object);
// }
//
// public double getLatitude(){
// return latitude;
// }
//
// public double getLongitude(){
// return longitude;
// }
//
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
// Path: src/milk/telegram/type/inline/InlineQuery.java
import milk.telegram.type.Identifier;
import milk.telegram.type.file.Location;
import milk.telegram.type.user.User;
import org.json.JSONObject;
package milk.telegram.type.inline;
public class InlineQuery implements Identifier<String>{
private final String id;
|
private final User from;
|
SW-Team/java-TelegramBot
|
src/milk/telegram/type/inline/InlineQuery.java
|
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/file/Location.java
// public class Location{
//
// private final double latitude;
// private final double longitude;
//
// private Location(JSONObject object){
// this.latitude = object.getDouble("latitude");
// this.longitude = object.getDouble("longitude");
// }
//
// public static Location create(JSONObject object){
// if(object == null){
// return null;
// }
// return new Location(object);
// }
//
// public double getLatitude(){
// return latitude;
// }
//
// public double getLongitude(){
// return longitude;
// }
//
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
|
import milk.telegram.type.Identifier;
import milk.telegram.type.file.Location;
import milk.telegram.type.user.User;
import org.json.JSONObject;
|
package milk.telegram.type.inline;
public class InlineQuery implements Identifier<String>{
private final String id;
private final User from;
|
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/file/Location.java
// public class Location{
//
// private final double latitude;
// private final double longitude;
//
// private Location(JSONObject object){
// this.latitude = object.getDouble("latitude");
// this.longitude = object.getDouble("longitude");
// }
//
// public static Location create(JSONObject object){
// if(object == null){
// return null;
// }
// return new Location(object);
// }
//
// public double getLatitude(){
// return latitude;
// }
//
// public double getLongitude(){
// return longitude;
// }
//
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
// Path: src/milk/telegram/type/inline/InlineQuery.java
import milk.telegram.type.Identifier;
import milk.telegram.type.file.Location;
import milk.telegram.type.user.User;
import org.json.JSONObject;
package milk.telegram.type.inline;
public class InlineQuery implements Identifier<String>{
private final String id;
private final User from;
|
private final Location location;
|
SW-Team/java-TelegramBot
|
src/milk/telegram/type/inline/ChosenInlineResult.java
|
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/file/Location.java
// public class Location{
//
// private final double latitude;
// private final double longitude;
//
// private Location(JSONObject object){
// this.latitude = object.getDouble("latitude");
// this.longitude = object.getDouble("longitude");
// }
//
// public static Location create(JSONObject object){
// if(object == null){
// return null;
// }
// return new Location(object);
// }
//
// public double getLatitude(){
// return latitude;
// }
//
// public double getLongitude(){
// return longitude;
// }
//
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
|
import milk.telegram.type.Identifier;
import milk.telegram.type.file.Location;
import milk.telegram.type.user.User;
import org.json.JSONObject;
|
package milk.telegram.type.inline;
public class ChosenInlineResult implements Identifier<String>{
private final String id;
|
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/file/Location.java
// public class Location{
//
// private final double latitude;
// private final double longitude;
//
// private Location(JSONObject object){
// this.latitude = object.getDouble("latitude");
// this.longitude = object.getDouble("longitude");
// }
//
// public static Location create(JSONObject object){
// if(object == null){
// return null;
// }
// return new Location(object);
// }
//
// public double getLatitude(){
// return latitude;
// }
//
// public double getLongitude(){
// return longitude;
// }
//
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
// Path: src/milk/telegram/type/inline/ChosenInlineResult.java
import milk.telegram.type.Identifier;
import milk.telegram.type.file.Location;
import milk.telegram.type.user.User;
import org.json.JSONObject;
package milk.telegram.type.inline;
public class ChosenInlineResult implements Identifier<String>{
private final String id;
|
private final User from;
|
SW-Team/java-TelegramBot
|
src/milk/telegram/type/inline/ChosenInlineResult.java
|
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/file/Location.java
// public class Location{
//
// private final double latitude;
// private final double longitude;
//
// private Location(JSONObject object){
// this.latitude = object.getDouble("latitude");
// this.longitude = object.getDouble("longitude");
// }
//
// public static Location create(JSONObject object){
// if(object == null){
// return null;
// }
// return new Location(object);
// }
//
// public double getLatitude(){
// return latitude;
// }
//
// public double getLongitude(){
// return longitude;
// }
//
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
|
import milk.telegram.type.Identifier;
import milk.telegram.type.file.Location;
import milk.telegram.type.user.User;
import org.json.JSONObject;
|
package milk.telegram.type.inline;
public class ChosenInlineResult implements Identifier<String>{
private final String id;
private final User from;
|
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/file/Location.java
// public class Location{
//
// private final double latitude;
// private final double longitude;
//
// private Location(JSONObject object){
// this.latitude = object.getDouble("latitude");
// this.longitude = object.getDouble("longitude");
// }
//
// public static Location create(JSONObject object){
// if(object == null){
// return null;
// }
// return new Location(object);
// }
//
// public double getLatitude(){
// return latitude;
// }
//
// public double getLongitude(){
// return longitude;
// }
//
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
// Path: src/milk/telegram/type/inline/ChosenInlineResult.java
import milk.telegram.type.Identifier;
import milk.telegram.type.file.Location;
import milk.telegram.type.user.User;
import org.json.JSONObject;
package milk.telegram.type.inline;
public class ChosenInlineResult implements Identifier<String>{
private final String id;
private final User from;
|
private final Location location;
|
SW-Team/java-TelegramBot
|
src/milk/telegram/method/other/LeaveChat.java
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/method/SendInstance.java
// public abstract class SendInstance extends JSONObject{
//
// protected final TelegramBot bot;
//
// public SendInstance(TelegramBot bot){
// this.bot = bot;
// }
//
// public abstract Object send();
//
// public void asyncSend(){
// new Thread(this::send).start();
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
|
import milk.telegram.bot.TelegramBot;
import milk.telegram.method.SendInstance;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import org.json.JSONObject;
|
package milk.telegram.method.other;
public class LeaveChat extends SendInstance{
public LeaveChat(TelegramBot bot){
super(bot);
}
public LeaveChat setChatId(Object chat_id){
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/method/SendInstance.java
// public abstract class SendInstance extends JSONObject{
//
// protected final TelegramBot bot;
//
// public SendInstance(TelegramBot bot){
// this.bot = bot;
// }
//
// public abstract Object send();
//
// public void asyncSend(){
// new Thread(this::send).start();
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
// Path: src/milk/telegram/method/other/LeaveChat.java
import milk.telegram.bot.TelegramBot;
import milk.telegram.method.SendInstance;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import org.json.JSONObject;
package milk.telegram.method.other;
public class LeaveChat extends SendInstance{
public LeaveChat(TelegramBot bot){
super(bot);
}
public LeaveChat setChatId(Object chat_id){
|
if(chat_id instanceof Identifier){
|
SW-Team/java-TelegramBot
|
src/milk/telegram/method/other/LeaveChat.java
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/method/SendInstance.java
// public abstract class SendInstance extends JSONObject{
//
// protected final TelegramBot bot;
//
// public SendInstance(TelegramBot bot){
// this.bot = bot;
// }
//
// public abstract Object send();
//
// public void asyncSend(){
// new Thread(this::send).start();
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
|
import milk.telegram.bot.TelegramBot;
import milk.telegram.method.SendInstance;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import org.json.JSONObject;
|
package milk.telegram.method.other;
public class LeaveChat extends SendInstance{
public LeaveChat(TelegramBot bot){
super(bot);
}
public LeaveChat setChatId(Object chat_id){
if(chat_id instanceof Identifier){
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/method/SendInstance.java
// public abstract class SendInstance extends JSONObject{
//
// protected final TelegramBot bot;
//
// public SendInstance(TelegramBot bot){
// this.bot = bot;
// }
//
// public abstract Object send();
//
// public void asyncSend(){
// new Thread(this::send).start();
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
// Path: src/milk/telegram/method/other/LeaveChat.java
import milk.telegram.bot.TelegramBot;
import milk.telegram.method.SendInstance;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import org.json.JSONObject;
package milk.telegram.method.other;
public class LeaveChat extends SendInstance{
public LeaveChat(TelegramBot bot){
super(bot);
}
public LeaveChat setChatId(Object chat_id){
if(chat_id instanceof Identifier){
|
chat_id = chat_id instanceof Channel ? "@" + ((Usernamed) chat_id).getUsername() : ((Identifier) chat_id).getId();
|
SW-Team/java-TelegramBot
|
src/milk/telegram/method/other/LeaveChat.java
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/method/SendInstance.java
// public abstract class SendInstance extends JSONObject{
//
// protected final TelegramBot bot;
//
// public SendInstance(TelegramBot bot){
// this.bot = bot;
// }
//
// public abstract Object send();
//
// public void asyncSend(){
// new Thread(this::send).start();
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
|
import milk.telegram.bot.TelegramBot;
import milk.telegram.method.SendInstance;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import org.json.JSONObject;
|
package milk.telegram.method.other;
public class LeaveChat extends SendInstance{
public LeaveChat(TelegramBot bot){
super(bot);
}
public LeaveChat setChatId(Object chat_id){
if(chat_id instanceof Identifier){
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/method/SendInstance.java
// public abstract class SendInstance extends JSONObject{
//
// protected final TelegramBot bot;
//
// public SendInstance(TelegramBot bot){
// this.bot = bot;
// }
//
// public abstract Object send();
//
// public void asyncSend(){
// new Thread(this::send).start();
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
// Path: src/milk/telegram/method/other/LeaveChat.java
import milk.telegram.bot.TelegramBot;
import milk.telegram.method.SendInstance;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import org.json.JSONObject;
package milk.telegram.method.other;
public class LeaveChat extends SendInstance{
public LeaveChat(TelegramBot bot){
super(bot);
}
public LeaveChat setChatId(Object chat_id){
if(chat_id instanceof Identifier){
|
chat_id = chat_id instanceof Channel ? "@" + ((Usernamed) chat_id).getUsername() : ((Identifier) chat_id).getId();
|
SW-Team/java-TelegramBot
|
src/milk/telegram/type/message/PhotoMessage.java
|
// Path: src/milk/telegram/type/Textable.java
// public interface Textable{
//
// String getText();
// }
//
// Path: src/milk/telegram/type/file/photo/PhotoSize.java
// public class PhotoSize implements Identifier<String>{
//
// private final String id;
//
// private final int width;
// private final int height;
//
// private final Integer size;
//
// private PhotoSize(JSONObject object){
// this.id = object.getString("file_id");
// this.width = object.getInt("width");
// this.height = object.getInt("height");
// this.size = object.has("file_size") ? object.getInt("file_size") : null;
// }
//
// public static PhotoSize create(JSONObject object){
// if(object == null){
// return null;
// }
// return new PhotoSize(object);
// }
//
// public String getId(){
// return id;
// }
//
// public int getWidth(){
// return this.width;
// }
//
// public int getHeight(){
// return this.height;
// }
//
// public Integer getSize(){
// return size;
// }
//
// }
|
import milk.telegram.type.Textable;
import milk.telegram.type.file.photo.PhotoSize;
import org.json.JSONObject;
import java.util.ArrayList;
|
package milk.telegram.type.message;
public class PhotoMessage extends Message implements Textable{
private final String caption;
|
// Path: src/milk/telegram/type/Textable.java
// public interface Textable{
//
// String getText();
// }
//
// Path: src/milk/telegram/type/file/photo/PhotoSize.java
// public class PhotoSize implements Identifier<String>{
//
// private final String id;
//
// private final int width;
// private final int height;
//
// private final Integer size;
//
// private PhotoSize(JSONObject object){
// this.id = object.getString("file_id");
// this.width = object.getInt("width");
// this.height = object.getInt("height");
// this.size = object.has("file_size") ? object.getInt("file_size") : null;
// }
//
// public static PhotoSize create(JSONObject object){
// if(object == null){
// return null;
// }
// return new PhotoSize(object);
// }
//
// public String getId(){
// return id;
// }
//
// public int getWidth(){
// return this.width;
// }
//
// public int getHeight(){
// return this.height;
// }
//
// public Integer getSize(){
// return size;
// }
//
// }
// Path: src/milk/telegram/type/message/PhotoMessage.java
import milk.telegram.type.Textable;
import milk.telegram.type.file.photo.PhotoSize;
import org.json.JSONObject;
import java.util.ArrayList;
package milk.telegram.type.message;
public class PhotoMessage extends Message implements Textable{
private final String caption;
|
private final ArrayList<PhotoSize> photo = new ArrayList<>();
|
SW-Team/java-TelegramBot
|
src/milk/telegram/type/file/media/Video.java
|
// Path: src/milk/telegram/type/file/photo/PhotoSize.java
// public class PhotoSize implements Identifier<String>{
//
// private final String id;
//
// private final int width;
// private final int height;
//
// private final Integer size;
//
// private PhotoSize(JSONObject object){
// this.id = object.getString("file_id");
// this.width = object.getInt("width");
// this.height = object.getInt("height");
// this.size = object.has("file_size") ? object.getInt("file_size") : null;
// }
//
// public static PhotoSize create(JSONObject object){
// if(object == null){
// return null;
// }
// return new PhotoSize(object);
// }
//
// public String getId(){
// return id;
// }
//
// public int getWidth(){
// return this.width;
// }
//
// public int getHeight(){
// return this.height;
// }
//
// public Integer getSize(){
// return size;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
|
import milk.telegram.type.file.photo.PhotoSize;
import milk.telegram.type.Identifier;
import org.json.JSONObject;
|
package milk.telegram.type.file.media;
public class Video implements Identifier<String>{
private final String id;
private final String mime_type;
private final int width;
private final int height;
private final int duration;
|
// Path: src/milk/telegram/type/file/photo/PhotoSize.java
// public class PhotoSize implements Identifier<String>{
//
// private final String id;
//
// private final int width;
// private final int height;
//
// private final Integer size;
//
// private PhotoSize(JSONObject object){
// this.id = object.getString("file_id");
// this.width = object.getInt("width");
// this.height = object.getInt("height");
// this.size = object.has("file_size") ? object.getInt("file_size") : null;
// }
//
// public static PhotoSize create(JSONObject object){
// if(object == null){
// return null;
// }
// return new PhotoSize(object);
// }
//
// public String getId(){
// return id;
// }
//
// public int getWidth(){
// return this.width;
// }
//
// public int getHeight(){
// return this.height;
// }
//
// public Integer getSize(){
// return size;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
// Path: src/milk/telegram/type/file/media/Video.java
import milk.telegram.type.file.photo.PhotoSize;
import milk.telegram.type.Identifier;
import org.json.JSONObject;
package milk.telegram.type.file.media;
public class Video implements Identifier<String>{
private final String id;
private final String mime_type;
private final int width;
private final int height;
private final int duration;
|
private final PhotoSize thumb;
|
SW-Team/java-TelegramBot
|
src/milk/telegram/method/getter/FileGetter.java
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/file/File.java
// public class File implements Identifier<String>{
//
// private final String file_id;
// private final String file_path;
//
// private final Integer file_size;
//
// private File(JSONObject object){
// this.file_id = object.getString("file_id");
// this.file_path = object.optString("file_path");
// this.file_size = object.has("file_size") ? object.getInt("file_size") : null;
// }
//
// public static File create(JSONObject object){
// if(object == null){
// return null;
// }
// return new File(object);
// }
//
// public String getId(){
// return file_id;
// }
//
// public String getPath(){
// return file_path;
// }
//
// public Integer getSize(){
// return file_size;
// }
// }
|
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.file.File;
import org.json.JSONObject;
|
package milk.telegram.method.getter;
public class FileGetter extends Getter{
protected String file_id;
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/file/File.java
// public class File implements Identifier<String>{
//
// private final String file_id;
// private final String file_path;
//
// private final Integer file_size;
//
// private File(JSONObject object){
// this.file_id = object.getString("file_id");
// this.file_path = object.optString("file_path");
// this.file_size = object.has("file_size") ? object.getInt("file_size") : null;
// }
//
// public static File create(JSONObject object){
// if(object == null){
// return null;
// }
// return new File(object);
// }
//
// public String getId(){
// return file_id;
// }
//
// public String getPath(){
// return file_path;
// }
//
// public Integer getSize(){
// return file_size;
// }
// }
// Path: src/milk/telegram/method/getter/FileGetter.java
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.file.File;
import org.json.JSONObject;
package milk.telegram.method.getter;
public class FileGetter extends Getter{
protected String file_id;
|
public FileGetter(TelegramBot bot){
|
SW-Team/java-TelegramBot
|
src/milk/telegram/method/getter/FileGetter.java
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/file/File.java
// public class File implements Identifier<String>{
//
// private final String file_id;
// private final String file_path;
//
// private final Integer file_size;
//
// private File(JSONObject object){
// this.file_id = object.getString("file_id");
// this.file_path = object.optString("file_path");
// this.file_size = object.has("file_size") ? object.getInt("file_size") : null;
// }
//
// public static File create(JSONObject object){
// if(object == null){
// return null;
// }
// return new File(object);
// }
//
// public String getId(){
// return file_id;
// }
//
// public String getPath(){
// return file_path;
// }
//
// public Integer getSize(){
// return file_size;
// }
// }
|
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.file.File;
import org.json.JSONObject;
|
package milk.telegram.method.getter;
public class FileGetter extends Getter{
protected String file_id;
public FileGetter(TelegramBot bot){
super(bot);
}
public String getFileId(){
return file_id;
}
public FileGetter setFileId(String file_id){
this.file_id = file_id;
return this;
}
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/file/File.java
// public class File implements Identifier<String>{
//
// private final String file_id;
// private final String file_path;
//
// private final Integer file_size;
//
// private File(JSONObject object){
// this.file_id = object.getString("file_id");
// this.file_path = object.optString("file_path");
// this.file_size = object.has("file_size") ? object.getInt("file_size") : null;
// }
//
// public static File create(JSONObject object){
// if(object == null){
// return null;
// }
// return new File(object);
// }
//
// public String getId(){
// return file_id;
// }
//
// public String getPath(){
// return file_path;
// }
//
// public Integer getSize(){
// return file_size;
// }
// }
// Path: src/milk/telegram/method/getter/FileGetter.java
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.file.File;
import org.json.JSONObject;
package milk.telegram.method.getter;
public class FileGetter extends Getter{
protected String file_id;
public FileGetter(TelegramBot bot){
super(bot);
}
public String getFileId(){
return file_id;
}
public FileGetter setFileId(String file_id){
this.file_id = file_id;
return this;
}
|
public File send(){
|
SW-Team/java-TelegramBot
|
src/milk/telegram/type/game/GameHighScore.java
|
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
|
import milk.telegram.type.user.User;
import org.json.JSONObject;
|
package milk.telegram.type.game;
public class GameHighScore{
private final long score;
private final long position;
|
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
// Path: src/milk/telegram/type/game/GameHighScore.java
import milk.telegram.type.user.User;
import org.json.JSONObject;
package milk.telegram.type.game;
public class GameHighScore{
private final long score;
private final long position;
|
private final User user;
|
SW-Team/java-TelegramBot
|
src/milk/telegram/type/message/Message.java
|
// Path: src/milk/telegram/type/chat/Chat.java
// public abstract class Chat implements Identifier<Long>{
//
// private long id;
//
// private String type;
//
// protected Chat(JSONObject object){
// this.id = object.getLong("id");
// this.type = object.getString("type");
// }
//
// public static Chat create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
//
// switch(object.getString("type")){
// case "group":
// return new Group(object);
// case "channel":
// return new Channel(object);
// case "supergroup":
// return new SuperGroup(object);
// case "private":
// return new PrivateChat(object);
// }
// return null;
// }
//
// public Long getId(){
// return this.id;
// }
//
// public String getType(){
// return this.type;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
|
import milk.telegram.type.chat.Chat;
import milk.telegram.type.Identifier;
import milk.telegram.type.user.User;
import org.json.JSONObject;
|
package milk.telegram.type.message;
public class Message implements Identifier<Integer>{
private final int date;
private final int message_id;
|
// Path: src/milk/telegram/type/chat/Chat.java
// public abstract class Chat implements Identifier<Long>{
//
// private long id;
//
// private String type;
//
// protected Chat(JSONObject object){
// this.id = object.getLong("id");
// this.type = object.getString("type");
// }
//
// public static Chat create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
//
// switch(object.getString("type")){
// case "group":
// return new Group(object);
// case "channel":
// return new Channel(object);
// case "supergroup":
// return new SuperGroup(object);
// case "private":
// return new PrivateChat(object);
// }
// return null;
// }
//
// public Long getId(){
// return this.id;
// }
//
// public String getType(){
// return this.type;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
// Path: src/milk/telegram/type/message/Message.java
import milk.telegram.type.chat.Chat;
import milk.telegram.type.Identifier;
import milk.telegram.type.user.User;
import org.json.JSONObject;
package milk.telegram.type.message;
public class Message implements Identifier<Integer>{
private final int date;
private final int message_id;
|
private final User from;
|
SW-Team/java-TelegramBot
|
src/milk/telegram/type/message/Message.java
|
// Path: src/milk/telegram/type/chat/Chat.java
// public abstract class Chat implements Identifier<Long>{
//
// private long id;
//
// private String type;
//
// protected Chat(JSONObject object){
// this.id = object.getLong("id");
// this.type = object.getString("type");
// }
//
// public static Chat create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
//
// switch(object.getString("type")){
// case "group":
// return new Group(object);
// case "channel":
// return new Channel(object);
// case "supergroup":
// return new SuperGroup(object);
// case "private":
// return new PrivateChat(object);
// }
// return null;
// }
//
// public Long getId(){
// return this.id;
// }
//
// public String getType(){
// return this.type;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
|
import milk.telegram.type.chat.Chat;
import milk.telegram.type.Identifier;
import milk.telegram.type.user.User;
import org.json.JSONObject;
|
package milk.telegram.type.message;
public class Message implements Identifier<Integer>{
private final int date;
private final int message_id;
private final User from;
|
// Path: src/milk/telegram/type/chat/Chat.java
// public abstract class Chat implements Identifier<Long>{
//
// private long id;
//
// private String type;
//
// protected Chat(JSONObject object){
// this.id = object.getLong("id");
// this.type = object.getString("type");
// }
//
// public static Chat create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
//
// switch(object.getString("type")){
// case "group":
// return new Group(object);
// case "channel":
// return new Channel(object);
// case "supergroup":
// return new SuperGroup(object);
// case "private":
// return new PrivateChat(object);
// }
// return null;
// }
//
// public Long getId(){
// return this.id;
// }
//
// public String getType(){
// return this.type;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
// Path: src/milk/telegram/type/message/Message.java
import milk.telegram.type.chat.Chat;
import milk.telegram.type.Identifier;
import milk.telegram.type.user.User;
import org.json.JSONObject;
package milk.telegram.type.message;
public class Message implements Identifier<Integer>{
private final int date;
private final int message_id;
private final User from;
|
private final Chat chat;
|
SW-Team/java-TelegramBot
|
src/milk/telegram/bot/TelegramBot.java
|
// Path: src/milk/telegram/handler/Handler.java
// public interface Handler{
//
// void update(List<Update> list);
//
// }
//
// Path: src/milk/telegram/update/Update.java
// public class Update implements Identifier<Integer>{
//
// private final int id;
//
// private final Message message;
// private final Message edited_message;
//
// private final InlineQuery inline_query;
// private final CallbackQuery callback_query;
//
// private final ChosenInlineResult chosen_inline_result;
//
// private Update(JSONObject object){
// this.id = object.getInt("update_id");
// this.message = Message.create(object.optJSONObject("message"));
// this.edited_message = Message.create(object.optJSONObject("edited_message"));
//
// this.inline_query = InlineQuery.create(object.optJSONObject("inline_query"));
// this.callback_query = CallbackQuery.create(object.optJSONObject("callback_query"));
//
// this.chosen_inline_result = ChosenInlineResult.create(object.optJSONObject("chosen_inline_result"));
// }
//
// public static Update create(JSONObject object){
// if(object == null){
// return null;
// }
// return new Update(object);
// }
//
// public Integer getId(){
// return id;
// }
//
// public Message getMessage(){
// return message;
// }
//
// public Message getEditMessage(){
// return edited_message;
// }
//
// public InlineQuery getInlineQuery(){
// return inline_query;
// }
//
// public CallbackQuery getCallbackQuery(){
// return callback_query;
// }
//
// public ChosenInlineResult getChosenInlineResult(){
// return chosen_inline_result;
// }
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
|
import milk.telegram.handler.Handler;
import milk.telegram.update.Update;
import milk.telegram.type.user.User;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
|
package milk.telegram.bot;
public class TelegramBot extends Thread{
public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
private String token = "";
private int lastId = 0;
private int limit = 100;
private int timeout = 1500;
|
// Path: src/milk/telegram/handler/Handler.java
// public interface Handler{
//
// void update(List<Update> list);
//
// }
//
// Path: src/milk/telegram/update/Update.java
// public class Update implements Identifier<Integer>{
//
// private final int id;
//
// private final Message message;
// private final Message edited_message;
//
// private final InlineQuery inline_query;
// private final CallbackQuery callback_query;
//
// private final ChosenInlineResult chosen_inline_result;
//
// private Update(JSONObject object){
// this.id = object.getInt("update_id");
// this.message = Message.create(object.optJSONObject("message"));
// this.edited_message = Message.create(object.optJSONObject("edited_message"));
//
// this.inline_query = InlineQuery.create(object.optJSONObject("inline_query"));
// this.callback_query = CallbackQuery.create(object.optJSONObject("callback_query"));
//
// this.chosen_inline_result = ChosenInlineResult.create(object.optJSONObject("chosen_inline_result"));
// }
//
// public static Update create(JSONObject object){
// if(object == null){
// return null;
// }
// return new Update(object);
// }
//
// public Integer getId(){
// return id;
// }
//
// public Message getMessage(){
// return message;
// }
//
// public Message getEditMessage(){
// return edited_message;
// }
//
// public InlineQuery getInlineQuery(){
// return inline_query;
// }
//
// public CallbackQuery getCallbackQuery(){
// return callback_query;
// }
//
// public ChosenInlineResult getChosenInlineResult(){
// return chosen_inline_result;
// }
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
// Path: src/milk/telegram/bot/TelegramBot.java
import milk.telegram.handler.Handler;
import milk.telegram.update.Update;
import milk.telegram.type.user.User;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
package milk.telegram.bot;
public class TelegramBot extends Thread{
public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
private String token = "";
private int lastId = 0;
private int limit = 100;
private int timeout = 1500;
|
private User me;
|
SW-Team/java-TelegramBot
|
src/milk/telegram/bot/TelegramBot.java
|
// Path: src/milk/telegram/handler/Handler.java
// public interface Handler{
//
// void update(List<Update> list);
//
// }
//
// Path: src/milk/telegram/update/Update.java
// public class Update implements Identifier<Integer>{
//
// private final int id;
//
// private final Message message;
// private final Message edited_message;
//
// private final InlineQuery inline_query;
// private final CallbackQuery callback_query;
//
// private final ChosenInlineResult chosen_inline_result;
//
// private Update(JSONObject object){
// this.id = object.getInt("update_id");
// this.message = Message.create(object.optJSONObject("message"));
// this.edited_message = Message.create(object.optJSONObject("edited_message"));
//
// this.inline_query = InlineQuery.create(object.optJSONObject("inline_query"));
// this.callback_query = CallbackQuery.create(object.optJSONObject("callback_query"));
//
// this.chosen_inline_result = ChosenInlineResult.create(object.optJSONObject("chosen_inline_result"));
// }
//
// public static Update create(JSONObject object){
// if(object == null){
// return null;
// }
// return new Update(object);
// }
//
// public Integer getId(){
// return id;
// }
//
// public Message getMessage(){
// return message;
// }
//
// public Message getEditMessage(){
// return edited_message;
// }
//
// public InlineQuery getInlineQuery(){
// return inline_query;
// }
//
// public CallbackQuery getCallbackQuery(){
// return callback_query;
// }
//
// public ChosenInlineResult getChosenInlineResult(){
// return chosen_inline_result;
// }
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
|
import milk.telegram.handler.Handler;
import milk.telegram.update.Update;
import milk.telegram.type.user.User;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
|
package milk.telegram.bot;
public class TelegramBot extends Thread{
public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
private String token = "";
private int lastId = 0;
private int limit = 100;
private int timeout = 1500;
private User me;
|
// Path: src/milk/telegram/handler/Handler.java
// public interface Handler{
//
// void update(List<Update> list);
//
// }
//
// Path: src/milk/telegram/update/Update.java
// public class Update implements Identifier<Integer>{
//
// private final int id;
//
// private final Message message;
// private final Message edited_message;
//
// private final InlineQuery inline_query;
// private final CallbackQuery callback_query;
//
// private final ChosenInlineResult chosen_inline_result;
//
// private Update(JSONObject object){
// this.id = object.getInt("update_id");
// this.message = Message.create(object.optJSONObject("message"));
// this.edited_message = Message.create(object.optJSONObject("edited_message"));
//
// this.inline_query = InlineQuery.create(object.optJSONObject("inline_query"));
// this.callback_query = CallbackQuery.create(object.optJSONObject("callback_query"));
//
// this.chosen_inline_result = ChosenInlineResult.create(object.optJSONObject("chosen_inline_result"));
// }
//
// public static Update create(JSONObject object){
// if(object == null){
// return null;
// }
// return new Update(object);
// }
//
// public Integer getId(){
// return id;
// }
//
// public Message getMessage(){
// return message;
// }
//
// public Message getEditMessage(){
// return edited_message;
// }
//
// public InlineQuery getInlineQuery(){
// return inline_query;
// }
//
// public CallbackQuery getCallbackQuery(){
// return callback_query;
// }
//
// public ChosenInlineResult getChosenInlineResult(){
// return chosen_inline_result;
// }
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
// Path: src/milk/telegram/bot/TelegramBot.java
import milk.telegram.handler.Handler;
import milk.telegram.update.Update;
import milk.telegram.type.user.User;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
package milk.telegram.bot;
public class TelegramBot extends Thread{
public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
private String token = "";
private int lastId = 0;
private int limit = 100;
private int timeout = 1500;
private User me;
|
private Handler handler;
|
SW-Team/java-TelegramBot
|
src/milk/telegram/bot/TelegramBot.java
|
// Path: src/milk/telegram/handler/Handler.java
// public interface Handler{
//
// void update(List<Update> list);
//
// }
//
// Path: src/milk/telegram/update/Update.java
// public class Update implements Identifier<Integer>{
//
// private final int id;
//
// private final Message message;
// private final Message edited_message;
//
// private final InlineQuery inline_query;
// private final CallbackQuery callback_query;
//
// private final ChosenInlineResult chosen_inline_result;
//
// private Update(JSONObject object){
// this.id = object.getInt("update_id");
// this.message = Message.create(object.optJSONObject("message"));
// this.edited_message = Message.create(object.optJSONObject("edited_message"));
//
// this.inline_query = InlineQuery.create(object.optJSONObject("inline_query"));
// this.callback_query = CallbackQuery.create(object.optJSONObject("callback_query"));
//
// this.chosen_inline_result = ChosenInlineResult.create(object.optJSONObject("chosen_inline_result"));
// }
//
// public static Update create(JSONObject object){
// if(object == null){
// return null;
// }
// return new Update(object);
// }
//
// public Integer getId(){
// return id;
// }
//
// public Message getMessage(){
// return message;
// }
//
// public Message getEditMessage(){
// return edited_message;
// }
//
// public InlineQuery getInlineQuery(){
// return inline_query;
// }
//
// public CallbackQuery getCallbackQuery(){
// return callback_query;
// }
//
// public ChosenInlineResult getChosenInlineResult(){
// return chosen_inline_result;
// }
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
|
import milk.telegram.handler.Handler;
import milk.telegram.update.Update;
import milk.telegram.type.user.User;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
|
stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
}
return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
}catch(IOException ex){
}catch(Exception e){
e.printStackTrace();
}
return null;
}
public void run(){
while(true){
if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
try{
JSONObject k = new JSONObject();
k.put("limit", this.getLimit());
if(this.lastId > 0) k.put("offset", this.lastId + 1);
JSONObject update = this.updateResponse("getUpdates", k);
if(update == null){
continue;
}
JSONArray array = update.optJSONArray("result");
if(array == null){
continue;
}
|
// Path: src/milk/telegram/handler/Handler.java
// public interface Handler{
//
// void update(List<Update> list);
//
// }
//
// Path: src/milk/telegram/update/Update.java
// public class Update implements Identifier<Integer>{
//
// private final int id;
//
// private final Message message;
// private final Message edited_message;
//
// private final InlineQuery inline_query;
// private final CallbackQuery callback_query;
//
// private final ChosenInlineResult chosen_inline_result;
//
// private Update(JSONObject object){
// this.id = object.getInt("update_id");
// this.message = Message.create(object.optJSONObject("message"));
// this.edited_message = Message.create(object.optJSONObject("edited_message"));
//
// this.inline_query = InlineQuery.create(object.optJSONObject("inline_query"));
// this.callback_query = CallbackQuery.create(object.optJSONObject("callback_query"));
//
// this.chosen_inline_result = ChosenInlineResult.create(object.optJSONObject("chosen_inline_result"));
// }
//
// public static Update create(JSONObject object){
// if(object == null){
// return null;
// }
// return new Update(object);
// }
//
// public Integer getId(){
// return id;
// }
//
// public Message getMessage(){
// return message;
// }
//
// public Message getEditMessage(){
// return edited_message;
// }
//
// public InlineQuery getInlineQuery(){
// return inline_query;
// }
//
// public CallbackQuery getCallbackQuery(){
// return callback_query;
// }
//
// public ChosenInlineResult getChosenInlineResult(){
// return chosen_inline_result;
// }
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
// Path: src/milk/telegram/bot/TelegramBot.java
import milk.telegram.handler.Handler;
import milk.telegram.update.Update;
import milk.telegram.type.user.User;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
}
return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
}catch(IOException ex){
}catch(Exception e){
e.printStackTrace();
}
return null;
}
public void run(){
while(true){
if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
try{
JSONObject k = new JSONObject();
k.put("limit", this.getLimit());
if(this.lastId > 0) k.put("offset", this.lastId + 1);
JSONObject update = this.updateResponse("getUpdates", k);
if(update == null){
continue;
}
JSONArray array = update.optJSONArray("result");
if(array == null){
continue;
}
|
List<Update> list = new ArrayList<>();
|
SW-Team/java-TelegramBot
|
src/milk/telegram/method/getter/ChatAdministratorsGetter.java
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
//
// Path: src/milk/telegram/type/user/ChatMember.java
// public class ChatMember{
//
// private final User user;
// private final String status;
//
// private ChatMember(JSONObject object){
// this.user = User.create(object.getJSONObject("user"));
// this.status = object.getString("status");
// }
//
// public static ChatMember create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new ChatMember(object);
// }
//
// public User getUser(){
// return user;
// }
//
// public String getStatus(){
// return status;
// }
//
// }
|
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import milk.telegram.type.user.ChatMember;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
|
package milk.telegram.method.getter;
public class ChatAdministratorsGetter extends Getter{
public ChatAdministratorsGetter(TelegramBot bot){
super(bot);
}
public String getChatId(){
return this.optString("chat_id");
}
public ChatAdministratorsGetter setChatId(Object chat_id){
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
//
// Path: src/milk/telegram/type/user/ChatMember.java
// public class ChatMember{
//
// private final User user;
// private final String status;
//
// private ChatMember(JSONObject object){
// this.user = User.create(object.getJSONObject("user"));
// this.status = object.getString("status");
// }
//
// public static ChatMember create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new ChatMember(object);
// }
//
// public User getUser(){
// return user;
// }
//
// public String getStatus(){
// return status;
// }
//
// }
// Path: src/milk/telegram/method/getter/ChatAdministratorsGetter.java
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import milk.telegram.type.user.ChatMember;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
package milk.telegram.method.getter;
public class ChatAdministratorsGetter extends Getter{
public ChatAdministratorsGetter(TelegramBot bot){
super(bot);
}
public String getChatId(){
return this.optString("chat_id");
}
public ChatAdministratorsGetter setChatId(Object chat_id){
|
if(chat_id instanceof Identifier){
|
SW-Team/java-TelegramBot
|
src/milk/telegram/method/getter/ChatAdministratorsGetter.java
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
//
// Path: src/milk/telegram/type/user/ChatMember.java
// public class ChatMember{
//
// private final User user;
// private final String status;
//
// private ChatMember(JSONObject object){
// this.user = User.create(object.getJSONObject("user"));
// this.status = object.getString("status");
// }
//
// public static ChatMember create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new ChatMember(object);
// }
//
// public User getUser(){
// return user;
// }
//
// public String getStatus(){
// return status;
// }
//
// }
|
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import milk.telegram.type.user.ChatMember;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
|
package milk.telegram.method.getter;
public class ChatAdministratorsGetter extends Getter{
public ChatAdministratorsGetter(TelegramBot bot){
super(bot);
}
public String getChatId(){
return this.optString("chat_id");
}
public ChatAdministratorsGetter setChatId(Object chat_id){
if(chat_id instanceof Identifier){
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
//
// Path: src/milk/telegram/type/user/ChatMember.java
// public class ChatMember{
//
// private final User user;
// private final String status;
//
// private ChatMember(JSONObject object){
// this.user = User.create(object.getJSONObject("user"));
// this.status = object.getString("status");
// }
//
// public static ChatMember create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new ChatMember(object);
// }
//
// public User getUser(){
// return user;
// }
//
// public String getStatus(){
// return status;
// }
//
// }
// Path: src/milk/telegram/method/getter/ChatAdministratorsGetter.java
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import milk.telegram.type.user.ChatMember;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
package milk.telegram.method.getter;
public class ChatAdministratorsGetter extends Getter{
public ChatAdministratorsGetter(TelegramBot bot){
super(bot);
}
public String getChatId(){
return this.optString("chat_id");
}
public ChatAdministratorsGetter setChatId(Object chat_id){
if(chat_id instanceof Identifier){
|
chat_id = chat_id instanceof Channel ? "@" + ((Usernamed) chat_id).getUsername() : ((Identifier) chat_id).getId();
|
SW-Team/java-TelegramBot
|
src/milk/telegram/method/getter/ChatAdministratorsGetter.java
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
//
// Path: src/milk/telegram/type/user/ChatMember.java
// public class ChatMember{
//
// private final User user;
// private final String status;
//
// private ChatMember(JSONObject object){
// this.user = User.create(object.getJSONObject("user"));
// this.status = object.getString("status");
// }
//
// public static ChatMember create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new ChatMember(object);
// }
//
// public User getUser(){
// return user;
// }
//
// public String getStatus(){
// return status;
// }
//
// }
|
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import milk.telegram.type.user.ChatMember;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
|
package milk.telegram.method.getter;
public class ChatAdministratorsGetter extends Getter{
public ChatAdministratorsGetter(TelegramBot bot){
super(bot);
}
public String getChatId(){
return this.optString("chat_id");
}
public ChatAdministratorsGetter setChatId(Object chat_id){
if(chat_id instanceof Identifier){
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
//
// Path: src/milk/telegram/type/user/ChatMember.java
// public class ChatMember{
//
// private final User user;
// private final String status;
//
// private ChatMember(JSONObject object){
// this.user = User.create(object.getJSONObject("user"));
// this.status = object.getString("status");
// }
//
// public static ChatMember create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new ChatMember(object);
// }
//
// public User getUser(){
// return user;
// }
//
// public String getStatus(){
// return status;
// }
//
// }
// Path: src/milk/telegram/method/getter/ChatAdministratorsGetter.java
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import milk.telegram.type.user.ChatMember;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
package milk.telegram.method.getter;
public class ChatAdministratorsGetter extends Getter{
public ChatAdministratorsGetter(TelegramBot bot){
super(bot);
}
public String getChatId(){
return this.optString("chat_id");
}
public ChatAdministratorsGetter setChatId(Object chat_id){
if(chat_id instanceof Identifier){
|
chat_id = chat_id instanceof Channel ? "@" + ((Usernamed) chat_id).getUsername() : ((Identifier) chat_id).getId();
|
SW-Team/java-TelegramBot
|
src/milk/telegram/method/getter/ChatMembersCountGetter.java
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
|
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import org.json.JSONObject;
|
package milk.telegram.method.getter;
public class ChatMembersCountGetter extends Getter{
protected String chat_id;
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
// Path: src/milk/telegram/method/getter/ChatMembersCountGetter.java
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import org.json.JSONObject;
package milk.telegram.method.getter;
public class ChatMembersCountGetter extends Getter{
protected String chat_id;
|
public ChatMembersCountGetter(TelegramBot bot){
|
SW-Team/java-TelegramBot
|
src/milk/telegram/method/getter/ChatMembersCountGetter.java
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
|
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import org.json.JSONObject;
|
package milk.telegram.method.getter;
public class ChatMembersCountGetter extends Getter{
protected String chat_id;
public ChatMembersCountGetter(TelegramBot bot){
super(bot);
}
public String getChatId(){
return chat_id;
}
public ChatMembersCountGetter setChatId(Object chat_id){
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
// Path: src/milk/telegram/method/getter/ChatMembersCountGetter.java
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import org.json.JSONObject;
package milk.telegram.method.getter;
public class ChatMembersCountGetter extends Getter{
protected String chat_id;
public ChatMembersCountGetter(TelegramBot bot){
super(bot);
}
public String getChatId(){
return chat_id;
}
public ChatMembersCountGetter setChatId(Object chat_id){
|
if(chat_id instanceof Identifier){
|
SW-Team/java-TelegramBot
|
src/milk/telegram/method/getter/ChatMembersCountGetter.java
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
|
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import org.json.JSONObject;
|
package milk.telegram.method.getter;
public class ChatMembersCountGetter extends Getter{
protected String chat_id;
public ChatMembersCountGetter(TelegramBot bot){
super(bot);
}
public String getChatId(){
return chat_id;
}
public ChatMembersCountGetter setChatId(Object chat_id){
if(chat_id instanceof Identifier){
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
// Path: src/milk/telegram/method/getter/ChatMembersCountGetter.java
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import org.json.JSONObject;
package milk.telegram.method.getter;
public class ChatMembersCountGetter extends Getter{
protected String chat_id;
public ChatMembersCountGetter(TelegramBot bot){
super(bot);
}
public String getChatId(){
return chat_id;
}
public ChatMembersCountGetter setChatId(Object chat_id){
if(chat_id instanceof Identifier){
|
chat_id = chat_id instanceof Channel ? "@" + ((Usernamed) chat_id).getUsername() : ((Identifier) chat_id).getId();
|
SW-Team/java-TelegramBot
|
src/milk/telegram/method/getter/ChatMembersCountGetter.java
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
|
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import org.json.JSONObject;
|
package milk.telegram.method.getter;
public class ChatMembersCountGetter extends Getter{
protected String chat_id;
public ChatMembersCountGetter(TelegramBot bot){
super(bot);
}
public String getChatId(){
return chat_id;
}
public ChatMembersCountGetter setChatId(Object chat_id){
if(chat_id instanceof Identifier){
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/Usernamed.java
// public interface Usernamed{
//
// String getUsername();
//
// }
//
// Path: src/milk/telegram/type/chat/Channel.java
// public class Channel extends Chat implements Titled, Usernamed{
//
// private String title;
// private String username;
//
// public Channel(JSONObject object){
// super(object);
//
// this.title = object.getString("title");
// this.username = object.optString("username", null);
// }
//
// public String getTitle(){
// return this.title;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// }
// Path: src/milk/telegram/method/getter/ChatMembersCountGetter.java
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.Identifier;
import milk.telegram.type.Usernamed;
import milk.telegram.type.chat.Channel;
import org.json.JSONObject;
package milk.telegram.method.getter;
public class ChatMembersCountGetter extends Getter{
protected String chat_id;
public ChatMembersCountGetter(TelegramBot bot){
super(bot);
}
public String getChatId(){
return chat_id;
}
public ChatMembersCountGetter setChatId(Object chat_id){
if(chat_id instanceof Identifier){
|
chat_id = chat_id instanceof Channel ? "@" + ((Usernamed) chat_id).getUsername() : ((Identifier) chat_id).getId();
|
SW-Team/java-TelegramBot
|
src/milk/telegram/method/replier/CallbackReplier.java
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/callback/CallbackQuery.java
// public class CallbackQuery implements Identifier<String>{
//
// private final String id;
// private final User from;
// private final Message message;
//
// private final String chat_instance;
//
// private final String data;
// private final String inline_message_id;
//
// private final String game_short_name;
//
// private CallbackQuery(JSONObject object){
// this.id = object.getString("id");
// this.from = User.create(object.getJSONObject("from"));
// this.message = Message.create(object.optJSONObject("message"));
//
// this.chat_instance = object.optString("chat_instance", null);
//
// this.data = object.optString("data", null);
// this.inline_message_id = object.optString("inline_message_id");
//
// this.game_short_name = object.optString("game_short_name", null);
// }
//
// public static CallbackQuery create(JSONObject object){
// if(object == null){
// return null;
// }
// return new CallbackQuery(object);
// }
//
// public String getId(){
// return id;
// }
//
// public User getFrom(){
// return from;
// }
//
// public String getData(){
// return data;
// }
//
// public String getInlineId(){
// return inline_message_id;
// }
//
// public Message getMessage(){
// return message;
// }
//
// public String getGameShortName(){
// return game_short_name;
// }
//
// public String getChatInstance(){
// return chat_instance;
// }
// }
|
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.callback.CallbackQuery;
import org.json.JSONObject;
|
package milk.telegram.method.replier;
public class CallbackReplier extends Replier{
public CallbackReplier(TelegramBot bot){
super(bot);
}
public String getUrl(){
return optString("url");
}
public String getText(){
return optString("text");
}
public boolean isShowAlert(){
return optBoolean("show_alert");
}
public String getQueryId(){
return optString("query_id");
}
public CallbackReplier setUrl(String url){
this.put("url", url);
return this;
}
public CallbackReplier setText(String text){
this.put("text", text);
return this;
}
public CallbackReplier setShowAlert(boolean show_alert){
this.put("show_alert", show_alert);
return this;
}
public CallbackReplier setQueryId(Object query_id){
|
// Path: src/milk/telegram/bot/TelegramBot.java
// public class TelegramBot extends Thread{
//
// public static final String BASE_URL = "https://api.telegram.org/bot%s/%s";
//
// private String token = "";
//
// private int lastId = 0;
// private int limit = 100;
// private int timeout = 1500;
//
// private User me;
//
// private Handler handler;
//
// public TelegramBot(String token){
// this(token, null);
// }
//
// public TelegramBot(String token, Handler handler){
// this(token, handler, 1000);
// }
//
// public TelegramBot(String token, Handler handler, int timeout){
// this.setToken(token);
// this.setHandler(handler);
// this.setTimeout(timeout);
// }
//
// public final JSONObject updateResponse(String key, JSONObject object){
// try{
// URL url = new URL(String.format(BASE_URL, this.token, key));
// URLConnection connection = url.openConnection();
// connection.setDoInput(true);
// connection.setConnectTimeout(this.timeout);
// connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
//
// if(object != null && object.length() > 0){
// connection.setDoOutput(true);
// OutputStream stream = connection.getOutputStream();
// stream.write(object.toString().getBytes(StandardCharsets.UTF_8));
// }
//
// return new JSONObject(new JSONTokener(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)));
// }catch(IOException ex){
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
//
// public void run(){
// while(true){
// if(this.isInterrupted() || this.token.length() < 45 || this.handler == null) break;
//
// try{
// JSONObject k = new JSONObject();
// k.put("limit", this.getLimit());
// if(this.lastId > 0) k.put("offset", this.lastId + 1);
//
// JSONObject update = this.updateResponse("getUpdates", k);
// if(update == null){
// continue;
// }
//
// JSONArray array = update.optJSONArray("result");
// if(array == null){
// continue;
// }
//
// List<Update> list = new ArrayList<>();
// for(int i = 0; i < array.length(); i++){
// Update kkk = Update.create(array.optJSONObject(i));
// if(kkk == null){
// continue;
// }
// list.add(kkk);
// this.lastId = kkk.getId();
// }
// this.handler.update(list);
// }catch(Exception e){
// e.printStackTrace();
// }
// }
// }
//
// public User getMe(){
// if(this.me == null){
// this.me = User.create(updateResponse("getMe", null));
// }
// return this.me;
// }
//
// public int getLimit(){
// return limit;
// }
//
// public int getTimeout(){
// return this.timeout;
// }
//
// public String getToken(){
// return token;
// }
//
// public void setToken(String token){
// if(token.length() != 45){
// return;
// }
// this.me = null;
// this.token = token;
// }
//
// public void setLimit(int value){
// this.limit = Math.max(1, Math.min(100, value));
// }
//
// public void setTimeout(int time){
// this.timeout = Math.max(time, 500);
// }
//
// public void setHandler(Handler handler){
// this.handler = handler;
// }
//
// }
//
// Path: src/milk/telegram/type/callback/CallbackQuery.java
// public class CallbackQuery implements Identifier<String>{
//
// private final String id;
// private final User from;
// private final Message message;
//
// private final String chat_instance;
//
// private final String data;
// private final String inline_message_id;
//
// private final String game_short_name;
//
// private CallbackQuery(JSONObject object){
// this.id = object.getString("id");
// this.from = User.create(object.getJSONObject("from"));
// this.message = Message.create(object.optJSONObject("message"));
//
// this.chat_instance = object.optString("chat_instance", null);
//
// this.data = object.optString("data", null);
// this.inline_message_id = object.optString("inline_message_id");
//
// this.game_short_name = object.optString("game_short_name", null);
// }
//
// public static CallbackQuery create(JSONObject object){
// if(object == null){
// return null;
// }
// return new CallbackQuery(object);
// }
//
// public String getId(){
// return id;
// }
//
// public User getFrom(){
// return from;
// }
//
// public String getData(){
// return data;
// }
//
// public String getInlineId(){
// return inline_message_id;
// }
//
// public Message getMessage(){
// return message;
// }
//
// public String getGameShortName(){
// return game_short_name;
// }
//
// public String getChatInstance(){
// return chat_instance;
// }
// }
// Path: src/milk/telegram/method/replier/CallbackReplier.java
import milk.telegram.bot.TelegramBot;
import milk.telegram.type.callback.CallbackQuery;
import org.json.JSONObject;
package milk.telegram.method.replier;
public class CallbackReplier extends Replier{
public CallbackReplier(TelegramBot bot){
super(bot);
}
public String getUrl(){
return optString("url");
}
public String getText(){
return optString("text");
}
public boolean isShowAlert(){
return optBoolean("show_alert");
}
public String getQueryId(){
return optString("query_id");
}
public CallbackReplier setUrl(String url){
this.put("url", url);
return this;
}
public CallbackReplier setText(String text){
this.put("text", text);
return this;
}
public CallbackReplier setShowAlert(boolean show_alert){
this.put("show_alert", show_alert);
return this;
}
public CallbackReplier setQueryId(Object query_id){
|
if(query_id instanceof CallbackQuery){
|
SW-Team/java-TelegramBot
|
src/milk/telegram/type/game/Game.java
|
// Path: src/milk/telegram/type/Titled.java
// public interface Titled{
//
// String getTitle();
//
// }
//
// Path: src/milk/telegram/type/file/photo/PhotoSize.java
// public class PhotoSize implements Identifier<String>{
//
// private final String id;
//
// private final int width;
// private final int height;
//
// private final Integer size;
//
// private PhotoSize(JSONObject object){
// this.id = object.getString("file_id");
// this.width = object.getInt("width");
// this.height = object.getInt("height");
// this.size = object.has("file_size") ? object.getInt("file_size") : null;
// }
//
// public static PhotoSize create(JSONObject object){
// if(object == null){
// return null;
// }
// return new PhotoSize(object);
// }
//
// public String getId(){
// return id;
// }
//
// public int getWidth(){
// return this.width;
// }
//
// public int getHeight(){
// return this.height;
// }
//
// public Integer getSize(){
// return size;
// }
//
// }
//
// Path: src/milk/telegram/type/message/MessageEntity.java
// public class MessageEntity{
//
// private final String type;
//
// private final String url;
//
// private final int offset;
// private final int length;
//
// private final User user;
//
// private MessageEntity(JSONObject object){
// this.type = object.getString("type");
//
// this.offset = object.getInt("offset");
// this.length = object.getInt("length");
//
// this.url = object.optString("url");
// this.user = User.create(object.optJSONObject("user"));
// }
//
// public static MessageEntity create(JSONObject object){
// if(object == null){
// return null;
// }
// return new MessageEntity(object);
// }
//
// public String getType(){
// return type;
// }
//
// public int getOffset(){
// return offset;
// }
//
// public int getLength(){
// return length;
// }
//
// public String getUrl(){
// return url;
// }
//
// public User getUser(){
// return user;
// }
//
// }
//
// Path: src/milk/telegram/type/Textable.java
// public interface Textable{
//
// String getText();
// }
|
import milk.telegram.type.Titled;
import milk.telegram.type.file.photo.PhotoSize;
import milk.telegram.type.message.MessageEntity;
import milk.telegram.type.Textable;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
|
package milk.telegram.type.game;
public class Game implements Titled, Textable{
private String text;
private String title;
private String description;
private Animation animation;
|
// Path: src/milk/telegram/type/Titled.java
// public interface Titled{
//
// String getTitle();
//
// }
//
// Path: src/milk/telegram/type/file/photo/PhotoSize.java
// public class PhotoSize implements Identifier<String>{
//
// private final String id;
//
// private final int width;
// private final int height;
//
// private final Integer size;
//
// private PhotoSize(JSONObject object){
// this.id = object.getString("file_id");
// this.width = object.getInt("width");
// this.height = object.getInt("height");
// this.size = object.has("file_size") ? object.getInt("file_size") : null;
// }
//
// public static PhotoSize create(JSONObject object){
// if(object == null){
// return null;
// }
// return new PhotoSize(object);
// }
//
// public String getId(){
// return id;
// }
//
// public int getWidth(){
// return this.width;
// }
//
// public int getHeight(){
// return this.height;
// }
//
// public Integer getSize(){
// return size;
// }
//
// }
//
// Path: src/milk/telegram/type/message/MessageEntity.java
// public class MessageEntity{
//
// private final String type;
//
// private final String url;
//
// private final int offset;
// private final int length;
//
// private final User user;
//
// private MessageEntity(JSONObject object){
// this.type = object.getString("type");
//
// this.offset = object.getInt("offset");
// this.length = object.getInt("length");
//
// this.url = object.optString("url");
// this.user = User.create(object.optJSONObject("user"));
// }
//
// public static MessageEntity create(JSONObject object){
// if(object == null){
// return null;
// }
// return new MessageEntity(object);
// }
//
// public String getType(){
// return type;
// }
//
// public int getOffset(){
// return offset;
// }
//
// public int getLength(){
// return length;
// }
//
// public String getUrl(){
// return url;
// }
//
// public User getUser(){
// return user;
// }
//
// }
//
// Path: src/milk/telegram/type/Textable.java
// public interface Textable{
//
// String getText();
// }
// Path: src/milk/telegram/type/game/Game.java
import milk.telegram.type.Titled;
import milk.telegram.type.file.photo.PhotoSize;
import milk.telegram.type.message.MessageEntity;
import milk.telegram.type.Textable;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
package milk.telegram.type.game;
public class Game implements Titled, Textable{
private String text;
private String title;
private String description;
private Animation animation;
|
private ArrayList<PhotoSize> photo = new ArrayList<>();
|
SW-Team/java-TelegramBot
|
src/milk/telegram/type/game/Game.java
|
// Path: src/milk/telegram/type/Titled.java
// public interface Titled{
//
// String getTitle();
//
// }
//
// Path: src/milk/telegram/type/file/photo/PhotoSize.java
// public class PhotoSize implements Identifier<String>{
//
// private final String id;
//
// private final int width;
// private final int height;
//
// private final Integer size;
//
// private PhotoSize(JSONObject object){
// this.id = object.getString("file_id");
// this.width = object.getInt("width");
// this.height = object.getInt("height");
// this.size = object.has("file_size") ? object.getInt("file_size") : null;
// }
//
// public static PhotoSize create(JSONObject object){
// if(object == null){
// return null;
// }
// return new PhotoSize(object);
// }
//
// public String getId(){
// return id;
// }
//
// public int getWidth(){
// return this.width;
// }
//
// public int getHeight(){
// return this.height;
// }
//
// public Integer getSize(){
// return size;
// }
//
// }
//
// Path: src/milk/telegram/type/message/MessageEntity.java
// public class MessageEntity{
//
// private final String type;
//
// private final String url;
//
// private final int offset;
// private final int length;
//
// private final User user;
//
// private MessageEntity(JSONObject object){
// this.type = object.getString("type");
//
// this.offset = object.getInt("offset");
// this.length = object.getInt("length");
//
// this.url = object.optString("url");
// this.user = User.create(object.optJSONObject("user"));
// }
//
// public static MessageEntity create(JSONObject object){
// if(object == null){
// return null;
// }
// return new MessageEntity(object);
// }
//
// public String getType(){
// return type;
// }
//
// public int getOffset(){
// return offset;
// }
//
// public int getLength(){
// return length;
// }
//
// public String getUrl(){
// return url;
// }
//
// public User getUser(){
// return user;
// }
//
// }
//
// Path: src/milk/telegram/type/Textable.java
// public interface Textable{
//
// String getText();
// }
|
import milk.telegram.type.Titled;
import milk.telegram.type.file.photo.PhotoSize;
import milk.telegram.type.message.MessageEntity;
import milk.telegram.type.Textable;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
|
package milk.telegram.type.game;
public class Game implements Titled, Textable{
private String text;
private String title;
private String description;
private Animation animation;
private ArrayList<PhotoSize> photo = new ArrayList<>();
|
// Path: src/milk/telegram/type/Titled.java
// public interface Titled{
//
// String getTitle();
//
// }
//
// Path: src/milk/telegram/type/file/photo/PhotoSize.java
// public class PhotoSize implements Identifier<String>{
//
// private final String id;
//
// private final int width;
// private final int height;
//
// private final Integer size;
//
// private PhotoSize(JSONObject object){
// this.id = object.getString("file_id");
// this.width = object.getInt("width");
// this.height = object.getInt("height");
// this.size = object.has("file_size") ? object.getInt("file_size") : null;
// }
//
// public static PhotoSize create(JSONObject object){
// if(object == null){
// return null;
// }
// return new PhotoSize(object);
// }
//
// public String getId(){
// return id;
// }
//
// public int getWidth(){
// return this.width;
// }
//
// public int getHeight(){
// return this.height;
// }
//
// public Integer getSize(){
// return size;
// }
//
// }
//
// Path: src/milk/telegram/type/message/MessageEntity.java
// public class MessageEntity{
//
// private final String type;
//
// private final String url;
//
// private final int offset;
// private final int length;
//
// private final User user;
//
// private MessageEntity(JSONObject object){
// this.type = object.getString("type");
//
// this.offset = object.getInt("offset");
// this.length = object.getInt("length");
//
// this.url = object.optString("url");
// this.user = User.create(object.optJSONObject("user"));
// }
//
// public static MessageEntity create(JSONObject object){
// if(object == null){
// return null;
// }
// return new MessageEntity(object);
// }
//
// public String getType(){
// return type;
// }
//
// public int getOffset(){
// return offset;
// }
//
// public int getLength(){
// return length;
// }
//
// public String getUrl(){
// return url;
// }
//
// public User getUser(){
// return user;
// }
//
// }
//
// Path: src/milk/telegram/type/Textable.java
// public interface Textable{
//
// String getText();
// }
// Path: src/milk/telegram/type/game/Game.java
import milk.telegram.type.Titled;
import milk.telegram.type.file.photo.PhotoSize;
import milk.telegram.type.message.MessageEntity;
import milk.telegram.type.Textable;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
package milk.telegram.type.game;
public class Game implements Titled, Textable{
private String text;
private String title;
private String description;
private Animation animation;
private ArrayList<PhotoSize> photo = new ArrayList<>();
|
private ArrayList<MessageEntity> text_entities = new ArrayList<>();
|
SW-Team/java-TelegramBot
|
src/milk/telegram/type/message/DocumentMessage.java
|
// Path: src/milk/telegram/type/Textable.java
// public interface Textable{
//
// String getText();
// }
//
// Path: src/milk/telegram/type/file/Document.java
// public class Document implements Identifier<String>{
//
// private final String file_id;
// private final String file_name;
//
// private final String mime_type;
//
// private final PhotoSize thumb;
//
// private final Integer size;
//
// private Document(JSONObject object){
// this.file_id = object.getString("file_id");
// this.file_name = object.optString("file_name");
// this.mime_type = object.optString("mime_type");
//
// this.thumb = PhotoSize.create(object.optJSONObject("thumb"));
// this.size = object.has("file_size") ? object.getInt("file_size") : null;
// }
//
// public static Document create(JSONObject object){
// if(object == null){
// return null;
// }
// return new Document(object);
// }
//
// public String getId(){
// return file_id;
// }
//
// public PhotoSize getThumb(){
// return thumb;
// }
//
// public String getFileName(){
// return file_name;
// }
//
// public String getMimeType(){
// return mime_type;
// }
//
// public Integer getSize(){
// return size;
// }
//
// }
|
import milk.telegram.type.Textable;
import milk.telegram.type.file.Document;
import org.json.JSONObject;
|
package milk.telegram.type.message;
public class DocumentMessage extends Message implements Textable{
private String caption;
|
// Path: src/milk/telegram/type/Textable.java
// public interface Textable{
//
// String getText();
// }
//
// Path: src/milk/telegram/type/file/Document.java
// public class Document implements Identifier<String>{
//
// private final String file_id;
// private final String file_name;
//
// private final String mime_type;
//
// private final PhotoSize thumb;
//
// private final Integer size;
//
// private Document(JSONObject object){
// this.file_id = object.getString("file_id");
// this.file_name = object.optString("file_name");
// this.mime_type = object.optString("mime_type");
//
// this.thumb = PhotoSize.create(object.optJSONObject("thumb"));
// this.size = object.has("file_size") ? object.getInt("file_size") : null;
// }
//
// public static Document create(JSONObject object){
// if(object == null){
// return null;
// }
// return new Document(object);
// }
//
// public String getId(){
// return file_id;
// }
//
// public PhotoSize getThumb(){
// return thumb;
// }
//
// public String getFileName(){
// return file_name;
// }
//
// public String getMimeType(){
// return mime_type;
// }
//
// public Integer getSize(){
// return size;
// }
//
// }
// Path: src/milk/telegram/type/message/DocumentMessage.java
import milk.telegram.type.Textable;
import milk.telegram.type.file.Document;
import org.json.JSONObject;
package milk.telegram.type.message;
public class DocumentMessage extends Message implements Textable{
private String caption;
|
private Document document;
|
SW-Team/java-TelegramBot
|
src/milk/telegram/type/message/MessageEntity.java
|
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
|
import milk.telegram.type.user.User;
import org.json.JSONObject;
|
package milk.telegram.type.message;
public class MessageEntity{
private final String type;
private final String url;
private final int offset;
private final int length;
|
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
// Path: src/milk/telegram/type/message/MessageEntity.java
import milk.telegram.type.user.User;
import org.json.JSONObject;
package milk.telegram.type.message;
public class MessageEntity{
private final String type;
private final String url;
private final int offset;
private final int length;
|
private final User user;
|
SW-Team/java-TelegramBot
|
src/milk/telegram/type/callback/CallbackQuery.java
|
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/message/Message.java
// public class Message implements Identifier<Integer>{
//
// private final int date;
// private final int message_id;
//
// private final User from;
// private final Chat chat;
//
// private final Message reply_message;
//
// private final User forward_from;
// private final Chat forward_from_chat;
//
// private final JSONObject object;
//
// protected Message(JSONObject object){
// this.object = object;
//
// this.date = object.getInt("date");
// this.message_id = object.getInt("message_id");
// this.chat = Chat.create(object.getJSONObject("chat"));
//
// this.from = User.create(object.optJSONObject("from"));
// this.reply_message = Message.create(object.optJSONObject("reply_to_message"));
//
// this.forward_from = User.create(object.optJSONObject("forward_from"));
// this.forward_from_chat = Chat.create(object.optJSONObject("forward_from_chat"));
// }
//
// public static Message create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object == null || object.length() < 1){
// return null;
// }
// }
//
// if(object.has("game")){
// return new GameMessage(object);
// }else if(object.has("audio")){
// return new AudioMessage(object);
// }else if(object.has("contact")){
// return new ContactMessage(object);
// }else if(object.has("document")){
// return new DocumentMessage(object);
// }else if(object.has("location")){
// return new LocationMessage(object);
// }else if(object.has("photo")){
// return new PhotoMessage(object);
// }else if(object.has("sticker")){
// return new StickerMessage(object);
// }else if(object.has("text")){
// return new TextMessage(object);
// }else if(object.has("venue")){
// return new VenueMessage(object);
// }else if(object.has("video")){
// return new VideoMessage(object);
// }else if(object.has("voice")){
// return new VoiceMessage(object);
// }
// return new Message(object);
// }
//
// public Integer getId(){
// return this.message_id;
// }
//
// public int getDate(){
// return this.date;
// }
//
// public User getFrom(){
// return this.from;
// }
//
// public Chat getChat(){
// return this.chat;
// }
//
// public boolean isReplyMessage(){
// return this.reply_message != null;
// }
//
// public boolean isForwardMessage(){
// return this.forward_from != null || this.forward_from_chat != null;
// }
//
// public Message getReplyMessage(){
// return this.reply_message;
// }
//
// public User getForwardFrom(){
// return forward_from;
// }
//
// public Chat getForwardChat(){
// return forward_from_chat;
// }
//
// public String getName(){
// return "메시지";
// }
//
// public JSONObject toJSONObject(){
// return object;
// }
//
// @Override
// public String toString(){
// return this.getName();
// }
//
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
|
import milk.telegram.type.Identifier;
import milk.telegram.type.message.Message;
import milk.telegram.type.user.User;
import org.json.JSONObject;
|
package milk.telegram.type.callback;
public class CallbackQuery implements Identifier<String>{
private final String id;
|
// Path: src/milk/telegram/type/Identifier.java
// public interface Identifier<T>{
//
// T getId();
//
// }
//
// Path: src/milk/telegram/type/message/Message.java
// public class Message implements Identifier<Integer>{
//
// private final int date;
// private final int message_id;
//
// private final User from;
// private final Chat chat;
//
// private final Message reply_message;
//
// private final User forward_from;
// private final Chat forward_from_chat;
//
// private final JSONObject object;
//
// protected Message(JSONObject object){
// this.object = object;
//
// this.date = object.getInt("date");
// this.message_id = object.getInt("message_id");
// this.chat = Chat.create(object.getJSONObject("chat"));
//
// this.from = User.create(object.optJSONObject("from"));
// this.reply_message = Message.create(object.optJSONObject("reply_to_message"));
//
// this.forward_from = User.create(object.optJSONObject("forward_from"));
// this.forward_from_chat = Chat.create(object.optJSONObject("forward_from_chat"));
// }
//
// public static Message create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object == null || object.length() < 1){
// return null;
// }
// }
//
// if(object.has("game")){
// return new GameMessage(object);
// }else if(object.has("audio")){
// return new AudioMessage(object);
// }else if(object.has("contact")){
// return new ContactMessage(object);
// }else if(object.has("document")){
// return new DocumentMessage(object);
// }else if(object.has("location")){
// return new LocationMessage(object);
// }else if(object.has("photo")){
// return new PhotoMessage(object);
// }else if(object.has("sticker")){
// return new StickerMessage(object);
// }else if(object.has("text")){
// return new TextMessage(object);
// }else if(object.has("venue")){
// return new VenueMessage(object);
// }else if(object.has("video")){
// return new VideoMessage(object);
// }else if(object.has("voice")){
// return new VoiceMessage(object);
// }
// return new Message(object);
// }
//
// public Integer getId(){
// return this.message_id;
// }
//
// public int getDate(){
// return this.date;
// }
//
// public User getFrom(){
// return this.from;
// }
//
// public Chat getChat(){
// return this.chat;
// }
//
// public boolean isReplyMessage(){
// return this.reply_message != null;
// }
//
// public boolean isForwardMessage(){
// return this.forward_from != null || this.forward_from_chat != null;
// }
//
// public Message getReplyMessage(){
// return this.reply_message;
// }
//
// public User getForwardFrom(){
// return forward_from;
// }
//
// public Chat getForwardChat(){
// return forward_from_chat;
// }
//
// public String getName(){
// return "메시지";
// }
//
// public JSONObject toJSONObject(){
// return object;
// }
//
// @Override
// public String toString(){
// return this.getName();
// }
//
// }
//
// Path: src/milk/telegram/type/user/User.java
// public class User implements Identifier<Integer>, Usernamed{
//
// private int id;
//
// private String last;
// private String first;
// private String username;
//
// private User(JSONObject object){
// this.id = object.getInt("id");
// this.last = object.optString("last_name", null);
// this.first = object.optString("first_name", null);
// this.username = object.optString("username", null);
// }
//
// public static User create(JSONObject object){
// if(object == null){
// return null;
// }else if(object.has("result")){
// object = object.optJSONObject("result");
// if(object.length() < 1){
// return null;
// }
// }
// return new User(object);
// }
//
// public Integer getId(){
// return this.id;
// }
//
// public String getFirstName(){
// return this.first;
// }
//
// public String getLastName(){
// return this.last;
// }
//
// public String getUsername(){
// return this.username;
// }
//
// public String getFullName(){
// return (this.getLastName() == null ? "" : this.getLastName() + " ") + this.getFirstName();
// }
//
// }
// Path: src/milk/telegram/type/callback/CallbackQuery.java
import milk.telegram.type.Identifier;
import milk.telegram.type.message.Message;
import milk.telegram.type.user.User;
import org.json.JSONObject;
package milk.telegram.type.callback;
public class CallbackQuery implements Identifier<String>{
private final String id;
|
private final User from;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.